XY LineChart move left/right
In the code below that line can be moved (dragged) left / right side of the left mouse click and dragimport javafx.application.Application;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.event.EventHandler;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.XYChart;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.chart.LineChart;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.BorderPane;
public class XYMove extends Application {
BorderPane pane;
XYChart.Series series1 = new XYChart.Series();
SimpleDoubleProperty rectinitX = new SimpleDoubleProperty();
SimpleDoubleProperty rectX = new SimpleDoubleProperty();
SimpleDoubleProperty rectY = new SimpleDoubleProperty();
@Override
public void start(Stage stage) {
final NumberAxis xAxis = new NumberAxis(4, 16, 1);
final NumberAxis yAxis = new NumberAxis(0.53000, 0.53910, 0.0005);
xAxis.setAnimated(false);
yAxis.setAnimated(false);
yAxis.setTickLabelFormatter(new NumberAxis.DefaultFormatter(yAxis) {
@Override
public String toString(Number object) {
return String.format("%7.5f", object);
}
});
final LineChart<Number, Number> lineChart = new LineChart<Number, Number>(xAxis, yAxis);
lineChart.setCreateSymbols(false);
lineChart.setAlternativeRowFillVisible(false);
lineChart.setAnimated(false);
lineChart.setLegendVisible(false);
series1.getData().add(new XYChart.Data(1, 0.53185));
series1.getData().add(new XYChart.Data(2, 0.532235));
series1.getData().add(new XYChart.Data(3, 0.53234));
series1.getData().add(new XYChart.Data(4, 0.538765));
series1.getData().add(new XYChart.Data(5, 0.53442));
series1.getData().add(new XYChart.Data(6, 0.534658));
series1.getData().add(new XYChart.Data(7, 0.53023));
series1.getData().add(new XYChart.Data(8, 0.53001));
series1.getData().add(new XYChart.Data(9, 0.53589));
series1.getData().add(new XYChart.Data(10, 0.53476));
series1.getData().add(new XYChart.Data(11, 0.53023));
series1.getData().add(new XYChart.Data(12, 0.53001));
series1.getData().add(new XYChart.Data(13, 0.53589));
series1.getData().add(new XYChart.Data(14, 0.53476));
pane = new BorderPane();
pane.setCenter(lineChart);
Scene scene = new Scene(pane, 800, 600);
lineChart.getData().addAll(series1);
stage.setScene(scene);
scene.setOnMouseClicked(mouseHandler);
scene.setOnMouseDragged(mouseHandler);
scene.setOnMouseEntered(mouseHandler);
scene.setOnMouseExited(mouseHandler);
scene.setOnMouseMoved(mouseHandler);
scene.setOnMousePressed(mouseHandler);
scene.setOnMouseReleased(mouseHandler);
stage.show();
}
EventHandler<MouseEvent> mouseHandler = new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent mouseEvent) {
if (mouseEvent.getEventType() == MouseEvent.MOUSE_PRESSED) {
rectinitX.set(mouseEvent.getX());
}
else if (mouseEvent.getEventType() == MouseEvent.MOUSE_DRAGGED || mouseEvent.getEventType() == MouseEvent.MOUSE_MOVED) {
LineChart<Number, Number> lineChart = (LineChart<Number, Number>) pane.getCenter();
NumberAxis xAxis = (NumberAxis) lineChart.getXAxis();
double Tgap = xAxis.getWidth()/(xAxis.getUpperBound() - xAxis.getLowerBound());
double newXlower=xAxis.getLowerBound(), newXupper=xAxis.getUpperBound();
double Delta=0.3;
if(mouseEvent.getEventType() == MouseEvent.MOUSE_DRAGGED){
if(rectinitX.get() < mouseEvent.getX()){
newXlower=xAxis.getLowerBound()-Delta;
newXupper=xAxis.getUpperBound()-Delta;
}
else if(rectinitX.get() > mouseEvent.getX()){
newXlower=xAxis.getLowerBound()+Delta;
newXupper=xAxis.getUpperBound()+Delta;
}
xAxis.setLowerBound( newXlower );
xAxis.setUpperBound( newXupper );
}
rectinitX.set(mouseEvent.getX());
}
}
};
public static void main(String[] args) {
launch(args);
}
}
My question is: how to modify this code so to stop this movement left / right when the X value is == 0 (no need to strengthen negative X values) and X == end value for NumberAxis? (in this case is 16).final NumberAxis xAxis = new NumberAxis(4, 16, 1);
Thank you all
Just change to this part:
if (rectinitX.get() < mouseEvent.getX() && newXlower >= 0) {
newXlower = xAxis.getLowerBound() - Delta;
newXupper = xAxis.getUpperBound() - Delta;
} else if (rectinitX.get() > mouseEvent.getX() && newXupper <= 16) {
newXlower = xAxis.getLowerBound() + Delta;
newXupper = xAxis.getUpperBound() + Delta;
}
I just added: * & newXlower > = 0 * and * & newXupper<=>=>
Published by: 981077 on January 14, 2013 06:47
Tags: Java
Similar Questions
-
BlackBerry Smartphones "BOLD" Trackball died - only movement left/right
Six days old and everything suddenly while using the calculator the trackball died - only move left or right, not upwards or downwards. Tried the deactivation/activation, then outgoing/incoming battery and reboot. No luck - e-mails arrive but cannot scroll down to retrieve or read (or delete). Cannot scroll to place calls.
Read this please
-
Basic: how to move left/right areas within the track?
Hello
I have a selected area that I want to move to the left or right within its own track and LPX leaves me no move at all. I selected the pointer tool and I try to click on and drag the box left or right, and it does not move. When I'm clicking, I do I click on the lower half of the region. What should I do to move the regions?
Thanks in advance
10.11.5 / LPX 10.2.2
Make sure that your drag is set on overlap and click on and hold the header at the top of the region portion to drag to the left or right
-
My laptop continues to turn upside down, left or right when I press the left/right click or even move my screen a little. My problem is not how to go backwards, his way to completely stop it help please?
Original title: windows 4540 s probook
Hello
What version of Windows are you using? Windows 8?
Right-click on the desktop > select screen resolution
Uncheck allow the screen to auto-rotation
Click OK
Using the keyboard:
Winkey + O (letter alpha) is to switch the feature off or on
-
The task bar is not locked, but he won't move in right or left clicking and dragging.
original title: taskbar is not locked, but he won't move in right or left clicking and dragging. Tried a different mouse, no results.
The task bar will not move but not locked.
Click to the right or left mouse drag, nothing happens.Used another mouse, still no movement.Hello
Method 1:
Try to make an auditor of the system files on your computer and search for errors on the disc: How to use the tool File Checker system to troubleshoot missing or corrupted system files on Windows Vista or Windows 7 http://support.microsoft.com/kb/929833
Method 2:
Step 1:
Start the computer in safe mode and see if the problem occurs. Follow the steps from the link to start in safe mode: http://windows.microsoft.com/en-US/windows7/Start-your-computer-in-safe-mode
Step 2:
Start the computer and check to see if this helps: How to troubleshoot a problem by performing a clean Windows Vista or Windows 7 boot http://support.microsoft.com/kb/929135
Note: when you are finished troubleshooting, follow step 7 to start the computer in normal startup.
Method 3:
Step 1:
Try creating a new user account and check if it works very well: http://windows.microsoft.com/en-us/Windows7/Create-a-user-account
Step 2:
If it works fine, then try to move the files and folders from the old account to the new user account user: http://windows.microsoft.com/en-US/Windows7/Fix-a-corrupted-user-profile
-
How do I move focus left/right/up/down
Imagine that you have created a customized with 5 place BitmapFields Manager placed like this:
..... [ ]
[ ] [X] [ ]
..... [ ]
where 'X' represents the selected field.
Now normally, if you move the trackball, the focus would go in linear order in which the fields have been added to the Manager. So, they can move from the top to the left, middle, right, and then down.
But, given that if the trackball can move up, down, left, right, I want to be able to concentrate to the up/down/left/right of the fireplace which precede with a trackBall revealing movement?
In the handler, I know I can get the movement of the trackball with navigationMovement(). But I do not understand what to substitute in the My Manager or fields to achieve the desired result.
Patrick
OK, understood the part I didn't understand the framework. The API documentation tells you that you must "return true" to indicate that the movement has been handled with:
protected boolean navigationMovement (int dx, int dy, int, int time status) {}
int d;
Block b (block) = this.getFieldWithFocus ();
If (Math.abs (dx) > Math.abs (dy)) {}
If (dx > 0) {}
d = Board.RIGHT;
} else {}
d = Board.LEFT;
}
} else {}
If (dy > 0) {}
d = Board.DOWN;
} else {}
d = Board.UP;
}
}
newFocus(b,_d).setFocus (); Focus new set
Returns true; True, since we are consuming events and manages the update
}So, basically, it's the only method I should use to control the change in emphasis. This isn't at all obvious in the API, especially given the lack of mention on the return value. Interestingly, some reminders require scythes and other true to indicate the "consumption" or the management of the event.
Anyway, problem solved.
-
How to create a gallery page that you can click on an image, expand it and move left or right to see more images?
@
You can use the slideshow widget to do this. For more details: Adobe Muse Help | Working with slide show widgets
-
Movements of left-right reversed with CS6 crops
I had CS4 on an old PC, I recently bought a new PC and consider buying CS6. I got a demo of CS6 - when I crop an image and you want to adjust the location of my crop, the left and right movements are reversed compared to what they were on CS4 - how can I change this?
In CS6, left & right keys move the default image. If you want to go back to the way it was in older versions of Photoshop (for around the choice of crops and not the image so that the crop tool), follow these steps:
First, select the crop tool. On the menu bar above, click the dropdown settings.
Select 'Use Classic Mode'. It will come back to legacy crop tool, you giving cultures control would have been pre - CS6.
-
I HAD A BUTTON AT HOME ON THE SIDE RIGHT NOW I DON'T HAVE AT ALL. NOW I HAVE TO GO TO THE TOP OF THE PAGE, CLICK ON THE YAHOO BUTTON, THEN MOVE THE SLIDER TO THE BOTTOM CAN REACH TO THE RIGHT, AND THEN CLICK NEW. ALSO MY LEFT & RIGHT ARROWS HAVE DISAPPEARED.
Hi FARKLE111,
If you have the Firefox menu at the top left, press Alt to temporarily show the menu bar. Go in view > toolbars and enable the bar of Navigation, the bookmarks bar and menu bar. This will give you a more familiar look for Firefox.
You can also read the Knowledge Base article the Navigation buttons such as back, home, bookmarks and recharge are missing. There are lots of good information in there also.
If this does not work, you can try the cor - el tips in this thread.
Hope this helps!
-
Satellite click Mini L9W - B cursor moves left to finish in the top left
the cursor on my mini click, every now and then continues to move left at the top left end, this causes the typos. What is the cause? and how can I put it right.
see you soon
JOTry to clean the whole keyboard, maybe it can require a recalibration. I already had problems with the touchpad and removed additional drivers that came with it
-
Gmail - compose E-mail - shortcut command-left/right does not
Firefox 3.6.12
Mac OS X 10.5.8In the window "Compose mail" Gmail command or shortcut command-left arrow + right arrow to move to respectively the beginning or end of a line, does not work. Command-up/down (going up/down) and option-left/right (jump by Word) are all working well.
I tried to run Firefox in safe mode, but always the same question. Also tried to clear the cache and history, but nothing helped.
In Safari, the shortcut works fine but I would stick to Firefox.Thanks for your suggestions.
Despite being marked as "resolved" I'm on Firefox 10.0.1 and it's always a problem. I also wanted to mention a similar key combination command + DELETE. In another application, this removes everything between the cursor and the beginning of the current line.
-
Prevent development leave Manager then moving left/right
I have a screen with a manager at the top, lower-left editfield and a button at the bottom right. I am trying to find a way to make sure if the user tries to move their development (with wheel) left/right, it moves back and fourth between these two fields. If the user moves to the top (in other fields), it will go directly to the Manager at the top, and if they move down it will stay on all the areas that they were on.
I could get this to work with navigationMovement, but then the editfield would no longer work.
Anyone have any ideas?
After looking around the docs a bit more, I've finally came up with this solution. It is a bit hardcoded for my specific case, but should help others who have similar problems.
protected int moveFocus(int amount, int status, int time) { int original = getFieldWithFocusIndex(); int result = super.moveFocus(amount, status, time); boolean fieldChanged = (original != getFieldWithFocusIndex()); // Move focus vertically if ((status & Field.STATUS_MOVE_FOCUS_VERTICALLY) == Field.STATUS_MOVE_FOCUS_VERTICALLY) { if (amount > 0) { // Move Down // Just stay at the original field if (fieldChanged) getField(original).setFocus(); } else { // Move Up // If the field changed leave manager if (fieldChanged) { return -1; } // If the field didn't change return the result return result; } } // Don't leave the manager return 0; }
-
I want to catch even down, left, right, I coded like this:
{} public boolean keyChar (key char, int status, int time)
If ((key==Characters.CONTROL_UP) |) (key == Characters.CONTROL_DOWN) | (key == Characters.CONTROL_LEFT) | (key is Characters.CONTROL_RIGHT)) {
Dialog.Alert ("Move");
Returns true;
}If {(key is Characters.ENTER)
Dialog.Alert ("Enter");
Returns true;
}Return super.keyChar (key, status, time);
}But only Characters.Enter can be caught, but Character.CONTROL_LEFT, on the RIGHT, upwards, downwards cannot be caught. I work with BlackBerry 8820 Simulator. Please help me. Thank you
navigationMovement() "listener" is what I think you need. Search through fields and the things that are derived from fields (such as the screens).
-
Hello
My site, I designed for my client is superb and I love Muse! However when I view it on the phone and Tablet it moves to the left.
Everything looks good, but moving. I reviewed my work to make sure that no graphics floated out there and everything is clean.
I also created a version of the phone which is not picking up. Please take a look and let me know what I can do to solve this problem.
www.farmtoforkloudoun.com
Thank you,
Vicky Quick
QUEBEC graphics
This was not it.
However I repair. In brower fill the tab that says "scroll" and the box that you can view called "query", it has been verified. I removed it and now it fits perfectly in my mobile window and does not move to the left more! Also my site on desktop computers does move not left right either which is the way I want it.
Something I would of never thought, but I was trying everything to make it work.
-
Left/right view Zoom with shortcuts
I'm a newbie and have not found the answer to my question, although it might have been addressed already somewhere.
I want to continue to use the outside of a zone currently with zoom adjustment brush without having to jump out of the pan with the mouse to the next area of the image. (If I change panning by mouse click adjustment brush, I just lost the end of my (painted) area formerly brushed, because it can be "reactivated" only with his pin code, which is outside the new zone where I just moved in pan with the mouse.)
I can move from top to bottom with the roll of scrolling without leaving the adjustment brush, but I did not understand how move sideways and horizontally with a shortcut (for example something like SHIFT + left/right arrow).
I am aware that by using the shift + PgUp/PgDn keys I can pan to the top, and then down in the adjacent band and upward, then again in the third strip, etc. But this "vertical zig - zag" is very time consuming and takes me not necessarily right at the target area.
Is a shortcut for a pan in Zoom?
With the selected AdjBrush, press the space bar on the keyboard. As it is pressed, the AdjBrush will change the symbol of the hand that allows you to drag the image around there where you need paint.
Release the SPACEBAR and the AdjBrush is back.
Works the same way with the Clone / heal tool.
Maybe you are looking for
-
When I start to type a destination to search how to stop unwanted suggestions printed under the box
When I type in a search destination, even the first letter, I printed under the destination application box search a list of destinations that I called and visited in the past which begin with this destination filled even request letter or a part. I
-
How to separate the numbers in a string?
I had a string that contains a lot of numbers, how can I separate them? I tried to use unbundle, but it does not work
-
After the system recovery, windows updates shows 64 installed updates. Many have the same title with another date. Should I install all updates or just the most recent version of each update? Is there a certain order to install these updates because
-
HP photosmart C4780: Hp Solution Center
I have recently upgraded to Windows 10 and now I can not scan from my computor using HP solution center app as before in windows 7. I tried several times following the instructions from HP. A problem in trying to uninstall the existing software, it w
-
Error loading C:WINDOWS\opetafuzacan.dll the specified module could not be found
When I boot, the following message is displayed: error loading C:WINDOWS\opetafuzacan.dll the specified module could not be found Anyone know what it is? I have not noticed a difference in the way the computer runs