How to move Line, Grid and X Ticks together?

The code below plots a XYLineChart: by left mouse click and drag the plotted line can be translated left/right.
package javafxapplication3;
import 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 GridMove 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(1, 12, 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));
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: now by moving the Line left/right, Grid and X Ticks does not move: so, how to translate Line, Grid and X Ticks together?
Any help really appreciated!
Thanks
Edit: nobody willing to help?
Edited by: 932518 on 30-ott-2012 1.31
Edited by: 932518 on 31-ott-2012 8.49

Some code improvements, now grid and line moves together. It only remains to move X axis ticks along with line and grid, and vertical grid lines are missing outside line range values
import javafx.application.Application;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.collections.ObservableList;
import javafx.event.EventHandler; 
import javafx.scene.chart.Axis;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.XYChart;
import javafx.scene.chart.XYChart.Series;
import javafx.stage.Stage;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.chart.LineChart;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.BorderPane;
import javafx.scene.shape.LineTo;
import javafx.scene.shape.MoveTo;
import javafx.scene.shape.Path;
public class GridMove extends Application {
BorderPane pane;
XYChart.Series series1 = new XYChart.Series();
SimpleDoubleProperty rectinitX = new SimpleDoubleProperty();
SimpleDoubleProperty rectX = new SimpleDoubleProperty();
SimpleDoubleProperty rectY = new SimpleDoubleProperty();
LineChart<Number, Number> lineChart;
@Override
public void start(Stage stage) {
    final NumberAxis xAxis = new NumberAxis(1, 12, 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);
    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));
    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 newXlower = xAxis.getLowerBound(), newXupper = xAxis.getUpperBound();
            double Delta = 0.3;
            if (mouseEvent.getEventType() == MouseEvent.MOUSE_DRAGGED) {
                if (rectinitX.get() < mouseEvent.getX()) {
                    Delta *= -1;                   
                newXlower = xAxis.getLowerBound() + Delta;
                newXupper = xAxis.getUpperBound() + Delta;
                xAxis.setLowerBound(newXlower);
                xAxis.setUpperBound(newXupper);
                DoubleProperty p1 = xAxis.scaleXProperty();
                DoubleProperty p2 = xAxis.translateXProperty();
                double horizontalValueRange = xAxis.getUpperBound() - xAxis.getLowerBound();
                double horizontalWidthPixels = xAxis.getWidth();
                //pixels per unit
                double xScale = horizontalWidthPixels / horizontalValueRange;
                Set<Node> nodes = lineChart.lookupAll(".chart-vertical-grid-lines");
                for (Node n: nodes) {
                    Path p = (Path) n;
                    double currLayoutX = p.getLayoutX();
                    p.setLayoutX(currLayoutX + (Delta*-1) * xScale);
                double lox = xAxis.getLayoutX();                                     
            rectinitX.set(mouseEvent.getX());
public static void main(String[] args) {
    launch(args);
}Any help very much appreciated!

Similar Messages

  • Need a document about how to move the fact and dimension table's to different server's

    Hello Experts,
    I need a detailed doc on how to move the fact and dimension tables to different server's.Please help me out from this
           Thanks in advance....

    You still haven't told anyone what products besides Essbase you are using, without which this is an impossible question to answer.
    https://forums.oracle.com/thread/2585515
    https://forums.oracle.com/thread/2585171
    Are you connecting to these tables from Essbase with a load rule / ODBC?  Using Studio?  Using Integration Services?  Any Drill-Through reporting set up?
    This may sound harsh, but if you truly don't know how to answer any of these questions you should probably not be anywhere near this task...

  • How to use line wrapping and line spacing in java?how to use line wrapping

    how to use line wrapping and line spacing in java?how to use line wrapping and line spacing in java?how to use line wrapping and line spacing in java?how to use line wrapping and line spacing in java?how to use line wrapping and line spacing in java?how to use line wrapping and line spacing in java?how to use line wrapping and line spacing in java?how to use line wrapping and line spacing in java?how to use line wrapping and line spacing in java?how to use line wrapping and line spacing in java?how to use line wrapping and line spacing in java?how to use line wrapping and line spacing in java?how to use line wrapping and line spacing in java?how to use line wrapping and line spacing in java?how to use line wrapping and line spacing in java?how to use line wrapping and line spacing in java?how to use line wrapping and line spacing in java?how to use line wrapping and line spacing in java?how to use line wrapping and line spacing in java?how to use line wrapping and line spacing in java?how to use line wrapping and line spacing in java?how to use line wrapping and line spacing in java?how to use line wrapping and line spacing in java?how to use line wrapping and line spacing in java?

    Hello,
    You should post your question at:
    http://java.forum.sun.com
    Thanks
    - Rose

  • HT4527 How can move the apps and playlists on my iPad to my Mac? Whenever I attempt to sync, I get a message stating that all apps and music on my iPad will be replaced by content from my Mac and there are no content. Thanks.

    How can move the apps and playlists on my iPad to my Mac? Whenever I attempt to sync, I get a message stating that all apps and music on my iPad will be replaced by content from my Mac and there are no content. Thanks.

    the apps will not be deleted if the itunes is authorised for the apple id from which you downloaded the apps.
    for the songs if you have downloaded it from a store other than itunes an app "TuneAid" will help you. download the full version then you can copy all the songs on the ipad to ur itunes library

  • How to use line wrapping and line spacing in java?

    how to use line wrapping and line spacing in java?

    Hi,
    This is explained in the java Tutorial. Please see the link:
    http://java.sun.com/docs/books/tutorial/i18n/text/line.html
    and find some sample examples.
    Hope this helps,
    --Sun/DTS                                                                                                                                                                                                                                                                                                                                                                                       

  • How to move the mirrlogA and mirrlogB from C drive to D drive

    Hi experts,
    I Need to move the mirrlogA and mirrlogB directories from C drive to D drive do i need to make any modifications to the configuration files.
    i can only this line in intDEV.ora file.but i can see the directories in C drive mirrlogA and mirrlogB but i cant find the entries in initDev.ora abt the C drive.
    "control_files = (D:\oracle\DEV\origlogA\cntrl\cntlrDEV.dbf, D:\oracle\DEV\origlogB\cntrl\cntrlDEV.dbf, D:\oracle\DEV\sapdata1\cntrl\cntrlDEV.dbf)"
    Can you suggest me how to move them and how to restart the system with out errors.
    regards,
    surya.

    Hello Surya,
    > I Need to move the mirrlogA and mirrlogB directories from C drive to D drive do i need to make any modifications to the configuration files.
    If you do not modify any oracle "settings" .. you have to do 2 things.
    1) Change the entry in the pfile / spfile for the control files
    2) Rename the redo log files to the new location with the ALTER DATABASE RENAME command after you have shutdown your database
    For more information how to rename a file take a look at:
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14231/onlineredo.htm#sthref951
    Regards
    Stefan

  • How to - move ACR cache and LR cache and catalog

    Hi all,
    in the try of speeding things up a bit with my LR (v. 2.4 64 bit on Vista 64 SP2, E8650 proc and 8 GB RAM) I got an 2nd hand WD Raptor 150 GB 10K rpm, and I'd like to move there the ACR cache (around 60GB now) and the LR previews and catalogs (around 20 GB) . Which is the right and safer procedure to do that!? :-)
    Another question: my setting about File Handling are the following:
    1680 pixels as standards preview file size
    Preview quality Medium
    Never discard 1:1 preview size
    and in the grid mode (library) when I page down or up ... I always have the 3 white dots (of waiting) the pictures taken 3-4 secs go from fuzzy to sharp. How can I improve that time?
    Thanks to all who will answer :-)
    Have a nice day,
    gianluca

    There is nothing you can do to change the time that thumbnails to refresh. The fuzziness is normal while the three dots are visible and indicates that Lr is scanning the files within the Grid for external metadata or develop changes.
    To move the catalog and preview folder you simply drag (copy) it to the new drive, open the relocated folder and double click on the .lrcat (catalog) file. The double click operation will open Lightroom with the relocated catalog active.
    You can drag the ACR cache file to the new drive. However, to ensure Lightroom/Camera Raw use the correct ACR cache you will need to open Preferences>File Handling and point to the location that you want the cache files to be saved.
    Be aware that moving above folder is going to take a fair amount of time, albeit significantly less than rebuilding the cache and previews from scratch.

  • How to move the code and deploy the code from Dev environment to SIT.

    Hi,
    I have a requirement.
    I want to move the components and deploy the code from dev Environment to SIT environment using Ant Script for AIA.
    Before doing this is any pre-requisites required?
    Can you please help on this,how to do?
    Thanks in advance.

    Further to add to Anish Statement follow the steps to easily migrate the code to different environment.
    Steps:
    First log on to the EM Console and export the Composite Flow as a SAR file to a location.
    In Jdeveloper create a project using the same name of a SAR file like - ProcessSalesorderFlow
    import the project using the option import the composite using a SAR File.
    After import , then click on the composite and then generate the config plan.
    In config plan add all the url changes using the search and replace Tags.
    And in case if you have a JCA Adapters the same has to be taken care in SIT environment why because during deployment a lookup happens and deployment fails if it dont find the JNDI Name.
    Take the SAR file adn config plan seperately from JDeveloper.
    Now open em console again and then deploy it using the config file and SAR file.
    Thanks,
    Venugopal SSS RAJA

  • How to move elements (figures and tables) to float

    Hi all,
    We have created an XSLT for the XML-IN in Indesign, its working fine and all the styles are applied automatically and figures and tables were placed as inline.
    Now we need to move the INLINE elements to FLOATING.
    How to move the INLINE elements such as figures and tables to Floating. This is for automation purpose.
    We are stuck up, please suggest.
    Our requirement is need to move the "figures" from "Inline" to "float" for auto pagination purpose.
    Please give us a route to end with proper result. We are at learning stage of Java Script.
    We use Indesign CS3 with JavaScript, I am not asking the full code, just give us an idea, how to pick from the XML tree and make it as float.
    Kavya

    Use one of the selection tools, e.g. selection brush, lasso tool, to select the object, then place it on its own layer.
    In your example, you would select the moon. You will see "marching ants" surrounding the selection, delineating  the boundary of the selection and that it is active.
    To place the object on its own layer, go to Layer menu>new> layer via copy, or CTRL+J. You will see the object surrounded by transparency (checkerboard pattern).
    Use the move tool to position the moon object wherever you want
    Place a blank layer below the layer created in step #2, then fill it with your new background.
    You can select multiple objects and place them this way to suit. Again, back to your hypothetical of.10 objects on 10 layers, you can link these layers by pressing CTRL+left clicking on each of the 10 layers in the layers palette.
    If you use the move tool, you will see that they move as a block. If you are unhappy with one of the layers as you go along, simply delete it, and replace it with a new one.
    As for naming the layers, right click on a layer, and from the menu select "rename" layer to bring up the layers properties, then rename it to something meaningful.
    Good luck with your project.

  • HT4910 how to move my videos and photos from ipad storage to icloud storage?

    I would like to purchase more videos and music from apple store, however i dont have enough storage space left, i purchased more storage for icloud back up, now i am having hard time to move files of movies, photos and music to icloud back up storage and i still can not buy more movies or music. How to move things to icloud storage please?

    iCloud doesn't store movies or music.  It only allows you to redownload purchases from the iTunes store if you ever lose them (assuming they are still available to redownload, and in the case of movies, that the studio permits it.)  Also iCloud only stores your camera roll photos in your backup, which can only be accessed by restoring your iPad to the entire backup.
    iCloud isn't designed to do what you are trying to do.  iCloud is for syncing data across all your devices and for backing up your devices, not storing your data.  You use iTunes on your computer for that.  iTunes will add your purchased videos and music to your iTunes library so you can remove it from your iPad and add it back later if you want.  To save your photos you import them to your computer (and then delete them from your iPad if you want) as described in this article: http://support.apple.com/kb/HT4083.

  • How to chage the grid and flip pages

    How to change the grid to horizontal, and flip pages?

    Hi saidimd,
    Are you referring to rotating the pages of a PDF file? If so, you would need to use Acrobat for that. In Reader, you can change rotate the page display, but that doesn't actually rotate the pages themselves.
    Best,
    Sara

  • How to move lines in "vi"?

    Hi all,
    How to simply move several lines from place A to place B (such as from top to bottom) in a file using vi?
    Thanks

    To move 15 lines, place your cursor on the first of these lines and :<br>
    <escape>15dd<br>
    <br>
    Go where you want to past, at the previous line, and <br>
    <escape>p<br>
    <br>
    But I'm not sure that's the good forum for vi question.<br>
    <br>
    Nicolas.

  • How to move rows up and down on a SharePoint List Item

    Hello,
    I have created a simple Project Plan Template for my team using a SharePoint list.
    I have listed a sample below:
         Date  
                                Tasks        
                                               Owner
    03/09/14                             Gather requirement                        
        X
    05/09/14                             Develop                          
                          Y
    07/09/14                             Deploy                          
                            Y
    Currently there is no functionality in the template to add another task to update the Plan. eg: I want to add another task with a due date 04/09/14 to confirm requirements.
    So basically I want to be able to add an item (task) towards the end and then move it to desired position depending on the due date.
    Please suggest how this can be implemented without complex code changes as I am new to working with SharePoint.
    Many Thanks in advance,
    BH

    Hi ,
    Thanks for the response.
    But I am looking to move the rows in a particular list A and not between 2 separate list items A and B according to the date.
    List Project A has separate tasks defined which needs to accomplished in a timely manner for the project to complete on schedule.
    I want to be able to move these tasks which are in a table on the SharePoint List.
    Hope this is clear.
    Please let me know if you have suggestions for this.
    -BH

  • How to move documents, favorites, and downloads from a windows to a mac?

    I have some of these things in a USB but when I try to move them to where I think they are supposed to be they are not the same like with documents it just tells me it came from a Hewlett Packard and when the last time I used it was, favorites doesn't even have a place in my Mac,  and downloads also doesn't have a place in my Mac. Also some of the files are lnk files so it would be nice to know how to fix that.

    Hi lilbro1212!
    I have an article for you that can help explain to you how to get the information from your PC into your new Mac right here:
    How to transfer data from a PC to a Mac
    http://support.apple.com/kb/ht1408
    Thanks for coming to the Apple Support Communities!
    Regards,
    Braden

  • How to move all files, and authorisations...

    Hi.
    I have been making music on a G4 powerbook for a while, but now i have got an imac G5 20" machine ready and waiting for me.
    The powerbook is running 10.3.9 and the imac will be running the latest tiger os.
    I need to find out the most painless way of moving all my software (i have a lot of music software (logic pro, audio instruments, each with their own validation codes etc) and i need to work out how to get this over to the other mac without having to move things one by one.
    Can it be done, or do i have to do everything one app at a time?
    Many thanks
    David Tobin

    You should be able to use the Setup Assistant found in your Utilities folder without a problem.
    Apple has a description and some FAQs HERE for you.

Maybe you are looking for