Help me on HSlider with two thumbs
Hi Friends,
I have a problem with HSlider. I am working on a slider with two thumbs. I have a requirement to overlap two thumbs. But the problem with overlapping is i can slide in reverse also. I need to restrict that. Please suggest me solution and save my time.
I will explain with example:
I have a slider to select classes from 1 - 12. For this i am using HSlider with two thumbs.
Now a user can select class range between 1 - 12. i.e., 5-6 or 8-9 or 2-9 etc..
I am giving an option to select 1-1 or 4-4 or 5-5 by overlapping the thumbs.
Now the problem i am facing is : user can select 9-5 or 6-1 or 5-3 etc, because i am giving chance to overlap thumbs.
But i have to restrict that behaviour... The user should not be able to select reverse.
I tried to Override getSnapValue method to restirct that behavior. But it is not working as expected. Please suggest me a solution for this. Please share me if you have any example which is having same or similar behavior.
Thanks,
Venu S.
Hi Bhasker,
Thanks for immediate response.
Here is my code:
package
import mx.controls.HSlider;
import mx.controls.sliderClasses.SliderThumb;
import mx.core.mx_internal;
use namespace mx_internal;
public class CustonSlider extends HSlider{
public function CustonSlider (){
override mx_internal function getSnapValue(value:Number, thumb:SliderThumb = null):Number{
if (!isNaN(snapInterval) && snapInterval != 0){
var val:Number = getValueFromX(value);
trace("value min max val "+value+" "+minimum+" "+maximum+" "+val);
//if (thumb && (thumbs.numChildren > 1) && !allowThumbOverlap)
if (thumb && (2 > 1) && !allowThumbOverlap){
var check_bounds:Boolean = true;
var bounds:Object
bounds = getXBounds(thumb.thumbIndex);
var prevThumb:SliderThumb =thumb.thumbIndex > 0 ?
//SliderThumb(thumbs.getChildAt(thumb.thumbIndex- 1)) :
SliderThumb(getThumbAt(thumb.thumbIndex- 1)) :
null;
var nextThumb:SliderThumb =
//thumb.thumbIndex + 1 < thumbs.numChildren ?
thumb.thumbIndex + 1 < 2 ?
//SliderThumb(thumbs.getChildAt(thumb.thumbIndex + 1)) :
SliderThumb(getThumbAt(thumb.thumbIndex + 1)) :
null;
if (prevThumb){
bounds.min -= (prevThumb.width / 2);
trace("bounds.min "+bounds.min);
// check if thumb is at minimum, if not we can ignore the bounds logic
if (val == minimum)
if (getValueFromX((prevThumb.xPosition - prevThumb.width/2)) <= minimum)check_bounds =
false;}
else
if (val >= minimum)check_bounds =
false;}
if (nextThumb){
bounds.max += (nextThumb.width / 2);
trace("bounds.max "+bounds.max);
// check if thumb is at maximum, if not we can ignore the bounds logic
if (val == maximum)
if (getValueFromX((nextThumb.xPosition + nextThumb.width/2)) >= maximum)check_bounds =
false;}
else
if (val <= maximum)check_bounds =
false;}
trace("check_bounds : "+check_bounds);
if (check_bounds)val = Math.min(Math.max(val, getValueFromX(Math.round(bounds.min)) + snapInterval),
getValueFromX(Math.round(bounds.max)) - snapInterval);
return getXFromValue(val);}
return value;}
I am calling the above snippet in my application.
But it is not working as i expected. Let us consider two thumbs as left thumb and right thumb, the left thumb should not move to right and rite thumb should move to right thumb. I can achieve this functionality if i set the boolean property "allowThumbOverlap" to false. But if i did this i cannot select range between 1-1 0r 4-4 or 9-9 etc. I have to give a chance to select range between 1-1 or 4-4 or 9-9 etc
Message was edited by: SVenu_2703
Similar Messages
-
How to bind to an Hslider with multiple thumbs?
OK folks,
I have a Hslider with three thumbs.
One thumb for the min of a range, a thumb for the value I
want to bind, and the third thumb for the max of a range.
My problem is data binding does not work when i use the
VALUES array property of the Hslider since I need to use a square
bracket operator to address the middle thumb.
When I compile, I get the warning:
Data binding will not be able to detect changes when using
square bracket operator. For Array, please use
ArrayCollection.getItemAt() instead.
Thing is, the VALUES property is just a regular array and not
an ArrayCollection.
Any hints?See this page for helpful information.
http://samsoft.org.uk/iTunes/grouping.asp
B-rock -
How can I create a Slieder with two thumb?
Hello forum,
who can help me to create a slider with lower bound and upper bound thumbs?
Thanks in advancedSounds pretty clear to me. He wants a slider where you have a slider with which you can set one value (a lower bound for example) and another slider (in the same control) that can set a 2nd value (an upper bound for example). Basically, a single control to select a range of values.
Google for images of: range slider
Anyway, I doubt JavaFX has something standard for this, but I'm sure it could be created. -
Advice/Help needed migrating/working with two macs
I currently own a mid-2010 (I think) Macbook Pro and a couple of months ago I bought a Mac Mini. Unfortunately when I set up the Mac Mini I was short on time and my excitement/lack of patience got the better of me so I copied everything on the HDD from my MBP over to the Mac Mini and I have been using the same profile to login on both machines.
This causes a few problems, particularly when I'm trying to connect the two machines via a network to share files. They can never connect, I'm thinking probably because they're using the same profile and get confused. I also haven't taken the time to properly install all the applications and so some do not work on the mini.
Rather than trying to pull my hair out trying to solve the issues, I think I've reached a point where I think I need to either start over or get some advice on what to do.
Ideally I'd like to use the Mini mainly for music apps (Garageband, possibly Logic Pro X in the future) and occassional internet and iTunes use. Since it has a bigger HDD, I'd like to store my music on the Mini.
I would then use the MBP as my general internet and iTunes machine. I would however like to be able to use it for music production stuff (again GB and/or Logic) if I am travelling. I know that I will need to upgrade the OS and the RAM which I am happy to do.
I would like to be able to have most of the same apps on both machines and also be able to easily transfer files, music etc. between the two.
So in light of what I'd like to achieve, what would be my best course of action? Would I be best to start over and try to migrate from fresh or can I make something work with what I have?
A further complication is that I have since used both machines so I will have some new stuff saved on both machines that won't be on the other. Is there any way to keep these new files if I start over?
Would anyone be gracious enough to point me in the direction of an easy to follow guide to help me achieve what I want?
Sorry for the long-winded post (and if I've posted in the wrong section) but I really think I lept into the migration without really knowing what I was doing and I could really use some advice to help me work out what to do!With your project open, press Shift + Q to open System Settings.
Where are your render files being stored to? The path should be pointing to your external. I'm betting that it's set to your system drive instead. -
UI Design help / Slider with multiple thumbs?
I've got an application which is trying to set multiple bounds
around a single value. For instance, if my value was "temperature",
possible bounds might be cold, temperate, hot.
I want my user to be able to assign all of those ranges.
My first thought was to use a slider with multiple thumbs. I could
have 0 and 100 as min and max, say, with 2 sliders. Everything
to the left of the first slider is "cold", everything between the two
sliders is "temperate", and everything to the right of the second
slider is "hot.
Of course, JSlider does not have support for multiple thumbs.
So, I was hoping someone could either suggest a freeware/LGPL
widget that did *or* could propose a clever redesign to obviate
the need for one.
In reality, my problem is more complex -- multiple values with
varying start values, end values, and number of thresholds. I'm
using multiple sliders right now, and it's functional, but really fugly.
Thanks for any help you might be able to provide!
EricHave found this triple slider from Gene Vishnevsky. Needs some work to adapt to your needs :
* TripleSlider_Test.java
import java.awt.*;
import java.awt.event.*;
import java.text.*;
import javax.swing.*;
public class TripleSlider_Test extends JFrame {
public TripleSlider_Test() {
setTitle("TripleSlider Test");
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setSize(400,300);
setLocationRelativeTo(null);
MyTripleSlider slider = new MyTripleSlider();
add(slider, BorderLayout.NORTH);
public static void main(String args[]) {
new TripleSlider_Test().setVisible(true);
class MyTripleSlider extends TripleSlider{
* This method is called when the "thumb" of the slider is dragged by
* the user. Must be overridden to give the slider some behavior.
public void Motion(){
// TODO add your handling code here:
* TripleSlider
* Description: Slider with two thumbs that divide the bar
* into three parts. Relative size of each part is
* the value of that part, so the three values add up to 1.
* Author: Gene Vishnevsky Oct. 15, 1997
* This class produces a slider with 2 thumbs that has 3 values.
class TripleSlider extends JPanel {
private final static int THUMB_SIZE = 14;
private final static int BUFFER = 2;
private final static int TEXT_HEIGHT = 18;
private final static int TEXT_BUFFER = 3;
private final static int DEFAULT_WIDTH = 300; //200;
private final static int DEFAULT_HEIGHT = 15;
/** Array that holds colors of each of the 3 parts. */
protected Color colors[];
private boolean enabled=true;
private Dimension preferredSize_;
/* this value depends on resizing */
protected int pixMin_, pixMax_, width_;
private int pix1_, pix2_; // pixel position of the thumbs
private double values[]; // the 3 values
/** current font of the labels. */
protected Font font;
* Enables/disables the slider.
public void setEnabled( boolean flag ) {
enabled = flag;
* Constructs and initializes the slider.
public TripleSlider() {
values = new double[3];
colors = new Color[3];
preferredSize_ = new Dimension( DEFAULT_WIDTH,
DEFAULT_HEIGHT + TEXT_HEIGHT + TEXT_BUFFER );
font = new Font("TimesRoman", Font.PLAIN, 12);
pixMax_ = DEFAULT_WIDTH - THUMB_SIZE - 1;
pixMax_ = DEFAULT_WIDTH - THUMB_SIZE - 1;
width_ = DEFAULT_WIDTH;
resize( width_, DEFAULT_HEIGHT + TEXT_HEIGHT /*�+ TEXT_BUFFER*/ );
setValues( 0.33333, 0.33333 );
setColor( 0, Color.blue );
setColor( 1, Color.green );
setColor( 2, Color.red );
addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent evt) {
mouseDown(evt);
addMouseMotionListener(new MouseMotionAdapter() {
public void mouseDragged(MouseEvent evt) {
mouseDrag(evt);
* Sets color of a part.
public void setColor( int part, Color color ) {
colors[part] = color;
* Returns color of a part.
* @return current part's color.
public Color getColor( int part ) {
return colors[part];
* This method is called by the runtime when the slider is resized.
public void reshape( int x, int y, int width, int height ) {
// setBounds() is not called.
super.reshape(x, y, width, height);
width_ = width;
pixMin_ = THUMB_SIZE;
pixMax_ = width - THUMB_SIZE - 1;
// recompute new thumbs pixels (for the same values)
setValues( values[0], values[1], values[2] );
repaint();
private void setValues( double a, double b, double c ) {
// we know the values are valid
values[0] = a;
values[1] = b;
values[2] = c;
double total = (double)( width_ - THUMB_SIZE * 4 ); // sum
pix1_ = (int)(a * total) + THUMB_SIZE;
pix2_ = (int)(b * total) + pix1_ + THUMB_SIZE * 2;
* Sets new values of the slider.
* is 1 - a - b.
public void setValues( double a, double b ) {
double sum_ab = a + b;
if( sum_ab > 1. || sum_ab < 0. ) {
/* invalid input: should throw exception */
System.out.println("invalid input");
return;
/* call this private method */
setValues( a, b, 1 - sum_ab );
repaint();
private void updateValues() {
double total = (double)( width_ - THUMB_SIZE * 4 ); // sum
int a = pix1_ - THUMB_SIZE;
int b = pix2_ - pix1_ - THUMB_SIZE * 2;
int c = width_ - (pix2_ + THUMB_SIZE);
values[0] = (double)a / total;
values[1] = (double)b / total;
values[2] = (double)c / total;
* Returns value for a part.
* @return value for the part.
public double getValue( int part ) {
return values[part];
* This method is called when the "thumb" of the slider is dragged by
* the user. Must be overridden to give the slider some behavior.
public void Motion() {
* Paints the whole slider and labels.
public void paint( Graphics g ) {
int width = size().width;
int height = size().height;
g.setColor( Color.lightGray ); // bground
g.fillRect( 0, 0, width, TEXT_HEIGHT );
g.setColor( colors[0] );
g.fillRect( 0, TEXT_HEIGHT,
pix1_ - THUMB_SIZE, height - TEXT_HEIGHT );
g.setColor( colors[1] );
g.fillRect( pix1_ + THUMB_SIZE, TEXT_HEIGHT,
pix2_ - pix1_ - THUMB_SIZE * 2, height - TEXT_HEIGHT );
g.setColor( colors[2] );
g.fillRect( pix2_ + THUMB_SIZE, TEXT_HEIGHT,
width_ - pix2_ - THUMB_SIZE, height - TEXT_HEIGHT );
/* draw two thumbs */
g.setColor( Color.lightGray );
g.fill3DRect( pix1_ - THUMB_SIZE, TEXT_HEIGHT /*+ BUFFER*/,
THUMB_SIZE * 2 + 1, height /*- 2 * BUFFER*/ - TEXT_HEIGHT,
true);
g.fill3DRect( pix2_ - THUMB_SIZE, TEXT_HEIGHT /*+ BUFFER*/,
THUMB_SIZE * 2 + 1, height /*- 2 * BUFFER*/ - TEXT_HEIGHT,
true);
g.setColor( Color.black );
g.drawLine(pix1_, TEXT_HEIGHT + BUFFER + 1,
pix1_, height - 2 * BUFFER);
g.drawLine(pix2_, TEXT_HEIGHT + BUFFER + 1,
pix2_, height - 2 * BUFFER);
g.setFont(font);
// center each value in the middle
String str = render( getValue(0) );
g.drawString(str,
pix1_ / 2 - (int)(getFontMetrics(font).stringWidth(str) / 2),
TEXT_HEIGHT - TEXT_BUFFER);
str = render( getValue(1) );
g.drawString(str,
(pix2_ - pix1_ ) / 2 + pix1_ -
(int)(getFontMetrics(font).stringWidth(str) / 2),
TEXT_HEIGHT - TEXT_BUFFER);
str = render( getValue(2) );
g.drawString(str,
(width_ - pix2_ ) / 2 + pix2_ -
(int)(getFontMetrics(font).stringWidth(str) / 2),
TEXT_HEIGHT - TEXT_BUFFER);
private String render(double value){
DecimalFormat myF = new DecimalFormat("###,###,###.#");
return myF.format(value);
* An internal method used to handle mouse down events.
private void mouseDown(MouseEvent e) {
if( enabled ) {
HandleMouse((int)e.getPoint().getX());
Motion();
* An internal method used to handle mouse drag events.
private void mouseDrag(MouseEvent e) {
if( enabled ) {
HandleMouse((int)e.getPoint().getX());
Motion();
* Does all the recalculations related to user interaction with
* the slider.
protected void HandleMouse(int x) {
boolean leftControl = false;
int left = pix1_, right = pix2_;
int xmin = THUMB_SIZE;
int xmax = width_ - THUMB_SIZE;
// Which thumb is closer?
if( x < (pix1_ + (pix2_ - pix1_) / 2 ) ) {
leftControl = true;
left = x;
} else {
right = x;
/* verify boundaries and reconcile */
if( leftControl ) {
if( left < xmin ) {
left = xmin;
} else if( left > (xmax - THUMB_SIZE*2) ) {
left = xmax - THUMB_SIZE*2;
} else {
if( left > (right - THUMB_SIZE * 2) && right < xmax ) {
// push right
right = left + THUMB_SIZE * 2;
} else {
// right control
if( right > xmax ) {
right = xmax;
} else if( right < (xmin + THUMB_SIZE*2) ) {
right = xmin + THUMB_SIZE*2;
} else {
if( right < (left + THUMB_SIZE * 2) && left > xmin ) {
// push left
left = right - THUMB_SIZE * 2;
pix1_ = left;
pix2_ = right;
updateValues();
repaint();
* Overrides the default update(Graphics) method
* in order not to clear screen to avoid flicker.
public void update( Graphics g ) {
paint( g );
* Overrides the default preferredSize() method.
* @return new Dimension
public Dimension preferredSize() {
return preferredSize_;
* Overrides the default minimumSize() method.
* @return new Dimension
public Dimension minimumSize() {
return preferredSize_;
} -
Peak detection with two thresholds
Dear colleagues!
Excuse me, but I need example or any help for peak detection with two thresholds. Namely two adjustable thresholds with standard peak detector for creating a detection's bandwith or range.
Peak detector have only one level threshold... But why only one...
Solved!
Go to Solution.If I understand correctly, you want to set two thresholds as shown in the image below.
The top peak is easy, so no need to go into details for that one.
The peak for the second threshold (red) will be a bit more difficult to do.
You would need to filter out the signals that cross the top threshold (blue). This would be done by identifying the values as they cross the top threshold boundary. You would then need to build a "window" around them (we'll come back to this one).
You would need to define a range of valid values for the 2nd peak, which are from the bottom threshold to the top threshold. Search for the number of values that cross the top threshold plus one. The "plus one" is the one you will want to search. With all the other peaks that you do not want, you can create windows around them. The remaining one is the peak of interest.
Message Edited by Ray.R on 10-23-2009 08:21 AM
Attachments:
2Thresholds.PNG 6 KB -
I was setting up my Airport and thought the first set up dod not go through, then I set up again and ended up with two wireless accounts. I use it for the prointer and the iPad, and I can see both accounts in the iPad. How do I get rid of one account? Thanks for the help!
me.com accounts can be used for iCloud. See the FAQ section in:
<http://support.apple.com/kb/ht4895>
but it may be too late if you have already created a new AppleID.
A few years ago Apple said they were working on allowing account merging, but it never happened (maybe objections from copyright holders). -
Hey!
when starting my computer the screen is gray with two harddrives. One is named Macintosh HD and the other Recovery 10.9. My computer has never done this before! I am really worrid that my files will be lost if i choose to start the wrong harddrive. Which one should i choose? HELP!!You probably held down the Option or Command R keys when you heard the startup tone. Simply choose the HD. To learn what the Recovery partition is please read OS X: About OS X Recovery
-
I bought my macbook pro on August 2011 at an apple store, with the Intel i7. However mirrorring in not working with two of my Apple TVs. These Apple TVs are 2nd and 3rd generation loaded with the latest software. I can succesfully transmit from my itunes on my Macbook pro to both Apple TVs, but I can not see the airplay icon on the taskbar. Can someone help?
About AirPlay and Airplay Mirroring
AirPlay Mirroring requires a second-generation Apple TV or later, and is supported on the following Mac models: iMac (Mid 2011 or newer), Mac mini (Mid 2011 or newer), MacBook Air (Mid 2011 or newer), and MacBook Pro (Early 2011 or newer). For non-qualifying Macs you can try using Air Parrot.
Several Apple Articles Regarding AirPlay
Apple TV (2nd and 3rd gen)- How to use AirPlay Mirroring
How to set up and configure AirPort Express for AirPlay and iTunes
About AirPlay Mirroring in OS X Mountain Lion
iTunes 10- About playing music with AirPlay
Troubleshooting AirPlay and AirPlay Mirroring
Using AirPlay -
I am using Mail 5.3 with two separate gmail addresses.
One is personal the other is business.
When I send emails from the BUSINESS address, any auto-replies/out of office notices I get come to my PERSONAL INBOX.
I imagine that this is a setting? Please help!Edit the SMTP server list. Add a new one for the business account. Put the correct password and information for it. Give it a description so you will know which server is which. Mke sure the correct server is highlighted in the account selected and check the box to use only that server for that account. Do that for the other account also.
-
I WANT TO PURCHASE NFS MOST WANTED GAME FROM APP STORE BUT IT DOESN'T ALLOW ME TO PROCEED FURTHER
after trying many times with two different debit cards still does not allows me to buy a game from the app store gives error "YOUR PAYMENT METHOD WAS DECLINE.PLEASE ENTER VALID PAYMENT METHOD INFORMATION" Please help me outIn most cases, you can't use a Debit card anymore. So, either redeem an iTunes gift card or use a credit card.
-
Help with two scripts - Mounting remote DMG and Checking which network I'm connected to
Hey guys, I need some help with two separate scripts:
1. The first script I'm trying to create to mount a DMG stored remotely on another Mac using an AppleScript or shell script. Using the following:
set cmd to "hdiutil mount 'afp://username:[email protected]/Lion/Users/username/Desktop/Test.sparseim age'"
do shell script cmd
results in the following error:
error "hdiutil: mount failed - not recognized" number 1
I'm not very experienced regarding AppleScript or using hdiutil, could somebody point out what's wrong with my script?
2. The second script I'm working on to try and essentially prevent the 'Could Not Find Server' Finder dialog when a network mount is unavailable. I guess what I'd like it to do is detect which network I'm connected to, and if I'm connected to the correct network, then mount the shares, otherwise just fail silently without any errors. From the searching I've done, using try statements should do this, but they do not, and I'm still presented with an error dialog after the server cannot be found.
Does anybody have any suggestions on this script? Also, I've seen some tips regarding detecting which wireless network the Mac is connected to, which could work, but what about when connected via Ethernet?
Thanks!Edit: I need to clarify on my first script request:
I need to mount the DMG on the remote Mac, not on the Mac I'm running the script from. -
We took pictures during oue holidays with two cameras and an iPad. I put all the pictures on my PC and reorganized them by date, time and/or subject, By putting a number in front of the picture name. Then I synced with my iPad. All the pictures show in a misselaneous order. What went or did I wrong?
You did nothing wrong, but the photo app puts stuff in chronological order.
You can look for another app. Afraid I don't have one to suggest, but I do understand that other apps will sort photos differently. -
I am having trouble with two cover flows on my IPOD, duplicating themselves more than once, they haven't duplicated themselves in my Itunes library, just the ipod, could anyone have any ideas on how I could fix this problem. I have tried so many times, even if I restore the ipod, it still does the same thing. Please if possible email me at [email protected] with any suggestions.
Aha! I have sorted it.
For those with similar problems, the solution is this:
Macintosh HD > Library > Audio > MIDI Drivers
Then delete DigiDioMidiDriver.plugin -
Help!printing float values with two decimal places
hi there java pips! im a newbie to this technology so forgive me for this really stupid question....i would like to perform mathematical operations on two float values....the problem is i want to print them in a standard format and that is i want them to be displayed with two decimal places (e.g 190.00, 12,72, 1,000.01) how can i do this?
Try java.text.DecimalFormat
NumberFormat nf = new DecimalFormat("0.00");
System.out.println(nf.format(x));
Maybe you are looking for
-
Not able to Upload data in Demand Planning data view
Hi I am trying to upload a csv file in to Demand planning interactive planning through " Upload Data " functionality First I exported data from interactive planning , updated some data in file and again trying to upload same file. I am getting follo
-
How to use tree tables with CRUD operation for begineers ADF 11g
This is Friday night call for help. This is only few sample ressources on the web for tree table and only one with CRUD operation. I used this one http://jobinesh.blogspot.com/2010/05/crud-operations-on-tree-table.html because this is the only one th
-
How do I import gradient map settings from one computer to another?
Quick Question, How do I import my gradient map settings from CS3 on my old I mac into my new Mac that uses CS6? Is there a folder somewhere that I can just copy and paste? Thanks, Mike
-
For Web_lansdale - No Phone Service - Internet and TV Work.
I hear you and wanted to reply but they closed the feature on your post.... Same problem here, mine is a repeat. I wonder if they have some kind of central office structural failure affecting all of us (landline or fios).... gudguy1 {edited for priv
-
ipad can work as a cellphone by putting a SIM card, reciving calls and messages? The messages are send to other cellphones. that don't belong to apple