Node Container that does not resize with Window Resize Event

Hello,
I'm not new to Java but I am new to JavaFX.
I plan to have a container/Canvas with multiple shapes (Lines, Text, Rectangle etc) in it. This Container can be X times in the Szene with different Text Shapes. I need to Zoom and Pan (maybe rotation) the whole Szene and the Containers/Canvas.
So I was playing around with that but I have two issues.
1) all Canvas classes that I found (like Pane for example) do resize with the main window resize event. The content of the canvas isn't centered any more.
2) I added a couple of Rectangles to the canvas and both the rectangles and the canvas have a mouse listener which will rotate the item/canvas. Problem is, that even if I click the rectangle also the underlaying canvas is rotated...I think I need some kind of Z-Info to find out what was clicked.
Here is the little example program, it makes no produktiv sense but it demonstrates my problem.
Does anybody has a tip what canvas class would fit and does not resize with the main window and how to figure out what was clicked?
public class Test extends Application
     Scene mainScene;
     Group root;
     public static void main(String[] args)
        launch(args);
    @Override
    public void init()
        root = new Group();
        int x = 0;
        int y = -100;
        for(int i = 0; i < 5; i++)
             x = 0;
             y = y + 100;
             for (int j = 0; j < 5; j++)
                  final Rectangle rect = new Rectangle(x, y, 30 , 30);
                   final RotateTransition rotateTransition = RotateTransitionBuilder.create()
                         .node(rect)
                         .duration(Duration.seconds(4))
                         .fromAngle(0)
                         .toAngle(720)
                         .cycleCount(Timeline.INDEFINITE)
                         .autoReverse(true)
                         .build();
                 rect.setOnMouseClicked(new EventHandler<MouseEvent>()
                      public void handle(MouseEvent me)
                           if(rotateTransition.getStatus().equals(Animation.Status.RUNNING))
                                rotateTransition.setToAngle(0);
                                rotateTransition.stop();
                                rect.setFill(Color.BLACK);
                                rect.setScaleX(1.0);
                                rect.setScaleY(1.0);
                           else
                                rect.setFill(Color.AQUAMARINE);
                                rect.setScaleX(2.0);
                                rect.setScaleY(2.0);
                                rotateTransition.play();
                  root.getChildren().add(rect);
                  x = x + 100;
    public void start(Stage primaryStage)
         final Pane pane = new Pane();
         pane.setStyle("-fx-background-color: #CCFF99");
         pane.setOnScroll(new EventHandler<ScrollEvent>()
               @Override
               public void handle(ScrollEvent se)
                    if(se.getDeltaY() > 0)
                         pane.setScaleX(pane.getScaleX() + 0.01);
                         pane.setScaleY(pane.getScaleY() + 0.01);
                    else
                         pane.setScaleX(pane.getScaleX() - 0.01);
                         pane.setScaleY(pane.getScaleY() - 0.01);
         pane.getChildren().addAll(root);
         pane.setOnMouseClicked(new EventHandler<MouseEvent>(){
               @Override
               public void handle(MouseEvent event)
                    System.out.println(event.getButton());
                    if(event.getButton().equals(MouseButton.PRIMARY))
                         System.out.println("primary button");
                         final RotateTransition rotateTransition2 = RotateTransitionBuilder.create()
                              .node(pane)
                              .duration(Duration.seconds(10))
                              .fromAngle(0)
                              .toAngle(360)
                              .cycleCount(Timeline.INDEFINITE)
                              .autoReverse(false)
                              .build();
                         rotateTransition2.play();
         mainScene = new Scene(pane, 400, 400);
         primaryStage.setScene(mainScene);
        primaryStage.show();
}Edited by: 953596 on 19.08.2012 12:03

To answer my own Question, it depends how you add childs.
It seems that the "master Container", the one added to the Scene will allways resize with the window. To avoid that you can add a container to the "master Container" and tell it to be
pane.setPrefSize(<child>.getWidth(), <child>.getHeight());
pane.setMaxSize(<child>.getWidth(), <child>.getHeight());
root.getChildren().add(pane);and it will stay the size even if the window is resized.
Here is the modified code. Zooming and panning is working, zomming to window size is not right now. I'll work on that.
import javafx.animation.Animation;
import javafx.animation.ParallelTransition;
import javafx.animation.ParallelTransitionBuilder;
import javafx.animation.RotateTransition;
import javafx.animation.RotateTransitionBuilder;
import javafx.animation.ScaleTransitionBuilder;
import javafx.animation.Timeline;
import javafx.animation.TranslateTransitionBuilder;
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.geometry.Point2D;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent;
import javafx.scene.input.ScrollEvent;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
import javafx.util.Duration;
public class Test extends Application
     Stage primStage;
    Scene mainScene;
     Group root;
     Pane masterPane;
     Point2D dragAnchor;
     double initX;
    double initY;
     public static void main(String[] args)
        launch(args);
    @Override
    public void init()
        root = new Group();
        final Pane pane = new Pane();
        pane.setStyle("-fx-background-color: #CCFF99");
        pane.setOnScroll(new EventHandler<ScrollEvent>()
            @Override
            public void handle(ScrollEvent se)
                if(se.getDeltaY() > 0)
                    pane.setScaleX(pane.getScaleX() + pane.getScaleX()/15);
                    pane.setScaleY(pane.getScaleY() + pane.getScaleY()/15);
                    System.out.println(pane.getScaleX() + " " + pane.getScaleY());
                else
                    pane.setScaleX(pane.getScaleX() - pane.getScaleX()/15);
                    pane.setScaleY(pane.getScaleY() - pane.getScaleY()/15);
                    System.out.println(pane.getScaleX() + " " + pane.getScaleY());
        pane.setOnMousePressed(new EventHandler<MouseEvent>()
            public void handle(MouseEvent me)
                initX = pane.getTranslateX();
                initY = pane.getTranslateY();
                dragAnchor = new Point2D(me.getSceneX(), me.getSceneY());
        pane.setOnMouseDragged(new EventHandler<MouseEvent>()
            public void handle(MouseEvent me) {
                double dragX = me.getSceneX() - dragAnchor.getX();
                double dragY = me.getSceneY() - dragAnchor.getY();
                //calculate new position of the pane
                double newXPosition = initX + dragX;
                double newYPosition = initY + dragY;
                //if new position do not exceeds borders of the rectangle, translate to this position
                pane.setTranslateX(newXPosition);
                pane.setTranslateY(newYPosition);
        int x = 0;
        int y = -100;
        for(int i = 0; i < 5; i++)
             x = 0;
             y = y + 100;
             for (int j = 0; j < 5; j++)
                  final Rectangle rect = new Rectangle(x, y, 30 , 30);
                   final RotateTransition rotateTransition = RotateTransitionBuilder.create()
                         .node(rect)
                         .duration(Duration.seconds(4))
                         .fromAngle(0)
                         .toAngle(720)
                         .cycleCount(Timeline.INDEFINITE)
                         .autoReverse(true)
                         .build();
                 rect.setOnMouseClicked(new EventHandler<MouseEvent>()
                      public void handle(MouseEvent me)
                           if(rotateTransition.getStatus().equals(Animation.Status.RUNNING))
                                rotateTransition.setToAngle(0);
                                rotateTransition.stop();
                                rect.setFill(Color.BLACK);
                                rect.setScaleX(1.0);
                                rect.setScaleY(1.0);
                           else
                                rect.setFill(Color.AQUAMARINE);
                                rect.setScaleX(2.0);
                                rect.setScaleY(2.0);
                                rotateTransition.play();
                  pane.getChildren().add(rect);
                  x = x + 100;
        pane.autosize();
        pane.setPrefSize(pane.getWidth(), pane.getHeight());
        pane.setMaxSize(pane.getWidth(), pane.getHeight());
        root.getChildren().add(pane);
        masterPane = new Pane();
        masterPane.getChildren().add(root);
        masterPane.setStyle("-fx-background-color: #AABBCC");
        masterPane.setOnMousePressed(new EventHandler<MouseEvent>()
           public void handle(MouseEvent me)
               System.out.println(me.getButton());
               if((MouseButton.MIDDLE).equals(me.getButton()))
                   double screenWidth  = masterPane.getWidth();
                   double screenHeight = masterPane.getHeight();
                   System.out.println("screenWidth  " + screenWidth);
                   System.out.println("screenHeight " + screenHeight);
                   System.out.println(screenHeight);
                   double scaleXIs     = pane.getScaleX();
                   double scaleYIs     = pane.getScaleY();
                   double paneWidth    = pane.getWidth()  * scaleXIs;
                   double paneHeight   = pane.getHeight() * scaleYIs;
                   double screenCalc    = screenWidth > screenHeight ? screenHeight : screenWidth;
                   double scaleOperator = screenCalc  / paneWidth;
                   double moveToX       = (screenWidth/2)  - (paneWidth/2);
                   double moveToY       = (screenHeight/2) - (paneHeight/2);
                   System.out.println("movetoX :" + moveToX);
                   System.out.println("movetoY :" + moveToY);
                   //double scaleYTo = screenHeight / paneHeight;
                   ParallelTransition parallelTransition = ParallelTransitionBuilder.create()
                           .node(pane)
                           .children(
                               TranslateTransitionBuilder.create()
                                   .duration(Duration.seconds(2))
                                   .toX(moveToX)
                                   .toY(moveToY)
                                   .build()
                               ScaleTransitionBuilder.create()
                                   .duration(Duration.seconds(2))
                                   .toX(scaleOperator)
                                   .toY(scaleOperator)
                                   .build()
                  .build();
                   parallelTransition.play();
    public void start(Stage primaryStage)
         primStage = primaryStage;
        mainScene = new Scene(masterPane, 430, 430);
         primaryStage.setScene(mainScene);
        primaryStage.show();
}

Similar Messages

  • ITunes 12.1.1 does NOT work with Windows - Fix??

    Hi everyone,
    I had issue after issue with the latest iTunes update (12.1.1) not working on my windows 7. It simply would not lunch when clicking on the shortcut to open.
    After a fair bit of searching I found this alternative version which seemed to do the trick and now it works:
    iTunes 12.1.1.4 for Windows (64-bit - for older video cards) - iTunes64Setup.exe(2015-02-18)

    The "for older video cards" installer - which, like most prior "64 bit" versions of iTunes, is actually a 32 bit application with a 64 bit installer - may be a useful fallback if the full 64 bit version does not install or run correctly.  Although 12.1.1.4 is a major improvement over 12.1.0.71, there are clearly still some lurking incompatibilities with some 64 bit Windows systems/components.  It is, however, a little misleading to say that "iTunes 12.1.1 does NOT work with Windows" - in many cases it works fine without switching to the alternative version.  I have the full 64-bit version of 12.1.1.4 running on three systems - two Windows 7 and one Windows 8.1 - no issues with either installation or operation on any of them.

  • ACROBAT XI - DOES NOT WORK WITH WINDOWS VISTA

    WHY DOESN'T THE COMPANY STATE ACROBAT XI PRO DOES NOT WORK WITH WINDOWS VISTA.
    THE COMPANY NEEDS TO WARN PEOPLE.  THE ACROBAT TECH SUPPORT FINALLY FIGURED OUT THAT IT'S NOT COMPATIBLE WITH WINDOWS VISTA.

    The Acrobat website and the box lists the compatible OSs. You want Adobe to list all of the incompatible OSs---going back how far.
    Acrobat XI Pro system requirements
    These system requirements are for Adobe® Acrobat® XI Pro software, v11.0. Because system requirements change with each software update, refer to the Release Notes for your software version for the latest information on supported operating systems and browsers.
    Windows
    1.3GHz or faster processor
    Microsoft® Windows® XP with Service Pack 3 for 32 bit or Service Pack 2 for 64 bit; Windows Server® 2003 R2 (32 bit and 64 bit); Windows Server 2008 or 2008 R2 (32 bit and 64 bit); Windows 7 (32 bit and 64 bit); or Windows 8 (32 bit and 64 bit)
    512MB of RAM (1GB recommended)
    1.85GB of available hard-disk space
    1024x768 screen resolution
    DVD-ROM drive
    Internet Explorer 7, 8, 9, or 10; Firefox Extended Support Release; or Chrome
    Video hardware acceleration (optional)
    Note: For 64-bit versions of Windows Server 2003 R2 and Windows XP (with Service Pack 2), Microsoft Update KB930627 is required.

  • Better privecy does not work with windows vista home prem. what other program removes LSO'S AND HOW can I stop trackers?

    Question
    better privacy does not work with windows vista home prem. what other program removes LSO'S AND HOW can I stop trackers? edit
    Details

    As a temporary workaround, I believe this Adobe management page allows you to clear your "Flash cookies": [http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager07.html Adobe - Flash Player : Settings Manager - Website Storage Settings panel] (hosted on macromedia.com -- Macromedia was the original developer of Flash).
    Regarding the script error, if I'm reading the script correctly, it is related to accessing your Flash cookies directory. It seems the publisher's support forum is not currently available for searching, but that might be a good next step.
    In the meantime, could you check whether the script has the correct location for your Flash cookies directory? If you can't access Tool > BetterPrivacy, you could check here:
    (1) In a new tab, type or paste '''about:config''' in the address bar and press Enter. Click the button promising to be careful.
    (2) In the filter box, type or paste '''bpr''' and pause while the list is filtered
    (3) There should be a bolded setting named '''extensions.bprivacy.DataDir''' which looks approximately like the following:
    C:\Users\''yourWindowsUsername''\AppData\Roaming\Macromedia
    Do you have a similar value? If you paste the path used by BetterPrivacy into a Windows Explorer window, does it open? Also, click a couple levels in the folder, can you see:
    Flash Player \ #SharedObjects
    If the value is wrong, right-click the wrong value and choose Reset. BetterPrivacy should update the value the next time you try to access it.
    If the value is blank, you could try inserting a sensible value and see whether that helps.
    Any luck?

  • HP Deskjet 2540 scan does not work with windows 10

    my HP Deskjet 2540 scan does not work with windows 10, however, it still does eprinting. i need the solution and i haven't got it.  

    OK, More information.   Installed Media Portal 1.  This works with the tuner card without additional modification, so this appears to be some kind of issue with the software.  Media Portal 1 does install a different version of Direct X, I don't know if that could have anything to do with it, but HP MediaSmart Live TV still comes up with the same error and will not run.

  • You must have connected the Time Capsule with a router that does not work with my direct cable from my ISP

    you must have connected the Time Capsule with a router that does not work with my direct cable from my ISP

    I tried to answer in your other post.. please stick to one thread ..
    What method of internet do you have.. is this fibre install.. if so the TC should just plug in and use dhcp in router mode.. press and hold the reset and it will go back to router mode by default.

  • ITunes randomly stops playing purchases that have previously viewed on the same hardware. It has an error message about HD. How can this issue be resolved?  What information is available besides the "learn more" option that does not deal with the problem?

    iTunes randomly stops playing purchases that have previously viewed on the same hardware. It has an error message about HD. How can this issue be resolved?  What information is available besides the "learn more" option that does not deal with the problem?
    Many people have the same problem. However, there is little or nothing readily available to users. This problem has existed for two or more years. Does anyone have anything to offer about this disturbing problem?

    Thanks for the suggestion kcell. I've tried both versions
    9.0.115 and 9.0.124 and both fail with the policy permission error.
    I also tried with and without your crossdomain.xml file but
    with the same result. It looks like this file is intended for URL
    policy, instead of socket policy. Recently Adobe separated the two.
    When I run with the files installed on my dev PC, it does
    work, which makes sense because the flash player isn't loaded from
    an unknown domain.
    I did get one step closer. If a crossdomain.xml in the server
    root exists and the socketpolicy file is loaded from the app folder
    then the first two warnings disappear. The logs now show:
    OK: Root-level SWF loaded:
    https://192.168.2.5/trunk/myapp.swf
    OK: Policy file accepted: https://192.168.2.5/crossdomain.xml
    OK: Policy file accepted:
    https://192.168.2.5/trunk/socketpolicy.xml
    Warning: Timeout on xmlsocket://192.168.2.5:843 (at 3
    seconds) while waiting for socket policy file. This should not
    cause any problems, but see
    http://www.adobe.com/go/strict_policy_files
    for an explanation.
    Warning: [strict] Ignoring policy file with incorrect syntax:
    xmlsocket://192.168.2.5:993
    Error: Request for resource at xmlsocket://192.168.2.5:993 by
    requestor from https://192.168.2.5/trunk/myapp.swf is denied due to
    lack of policy file permissions.
    Which basically says, everything is okay, but you stay out
    anyway.
    PS: I found the XML schema files here:
    http://www.adobe.com/devnet/flashplayer/articles/fplayer9_security_02.html
    and the socket policy schema:
    http://www.adobe.com/xml/schemas/PolicyFileSocket.xsd.
    UPDATE: When serving up the policy file on port 843 using the
    example perl script then the socket connection seems to be accepted
    and the connect succeeds. After that flex hangs trying to logon to
    the IMAP server.

  • My Mac operating system is OSX 10.4.11 and I "replaced" my older version of Firefox with a newer one that does not open with my system. Can you send me an older version of Firefox? Thanks!

    My Mac operating system is OSX 10.4.11 and I "replaced" my older version of Firefox with a newer one that does not open with my system. Can you send me an older version of Firefox? Thanks!

    You can get Firefox 3.6.20 from here. <br />
    http://www.mozilla.com/en-US/firefox/all-older.html

  • My iPhone does not synced with windows 7 but synced with windows Xp

    My iPhone does not synced with windows 7 but synced with windows Xp

    Just today evening I have replaced a brand new iPhone 5 with Apple store, so I came at home  &amp; try to restore my iPhone but it is not synced (mean my iPhone does not shown in iTunes,) &amp; at the same time I m restart my PC with windows Xp , now my iPhone connected with iTunes. So what is the problem of my windows 7 ,

  • How to map a url that does not match with the context root  ?

    does weblogic support url that does not match the context root ?
    ex. the context root is AAA. the welcome page can be
    retrieved using http://localhost:7001/AAA
    Can it be configured to use http://localhost:7001/BBB to bring up the index.html in context root AAA ? if so, how ?

    I agree with Imp68.
    It still amazes me that in 2014 so many web sites are still not standards-compliant and instead insist on sniffing for the user-agent.  And, in the majority of cases, I've found that the websites work fine with any modern browser.
    phardell,
    To be clear, Safari is not the problem, the website is!  The developer of this website is still living in the 1990s and needs to move forward with the times.  Imp68's suggestion will cause Safari to "pretend" to be whatever browser you wish.  Try choosing "Safari 7" if that worked for you in the past and the website will likely go back to working.  If that does not work then try choosing "Internet Explorer 10" from the menu and see if that works.
    No matter what the result, you should look at the bottom of the page for a link to report problems with the website.  Submit a comment that tells them that they need to "modernize your website to support all modern web browsers".
    Good luck.

  • Windows 8.1 DPI scaling does not work with Windows 7 client ?

    I have a Surface Pro with Windows 8.1 and a PC with Win7 SP1 both fully updated including optional updates (RDP8.1 client for Win7, verified in about box).
    Still, when I connect to my Surface from my PC everything is enlarged.
    My PC has two monitors: primary 1920x1080 and secondary 1680x1050. I've tried opening connection on each one of them as well as on both (multi monitor). I've also attempted to use windowed mode with lower resolutions.
    Surface is set to default DPI settings (slider moved to Larger and "Let me choose one scaling" is unchecked). Also, when I'm connected via RDP I cannot move the slider ("Some display settings can't be changed from a remote session") though
    I can click "Let me choose..." but that requires a sign-out. Another oddity is that my remote desktop client does not have a "Smart sizing" window menu item.

    Hi,
    When you are within a session you should be able to check the option Let me choose one scaling level for all displays, change the scaling, sign out, then when you reconnect it will have the new dpi setting applied.  This is the expected method for a
    Windows 7 client.
    -TP

  • Skype does NOT start with Windows Anymore (start S...

    My Skype NO LONGER starts with Windows anymore!!! I HAVE to manually open Skype!!! I cheked the options and "start Skype with Windows" IS checked!!! I tried unchecking the option and rechecking it, made no difference!!! how do I fix??

     Just because Skype isn't starting up automatically doesn't mean it isn't trying.  Other applications you have loading at startup could be slowing down Skype's ability to start.  You can run msconfig ( Start - Run  (Wink key + R) -  "msconfig".  Under the startup tab you can see if Skype is set to start or not.  You can also uncheck everything else but Skype and see if it comes up them.  If it does, using a process of elimination you should be able to determine the application causing the probelm.  If you do not see anything for Skype you can use the registry files provided to toggle that feature on/off just as the Skype program attempts to.
    Attachments:
    Start_Skype.zip ‏2 KB

  • HP Laserjet P1102 does not work with Windows 10

    I have just upgraded from Windows 7 to Windows 10 and whilst my Canon MG6150 works with Windows 10, the other printer HP Laserjet P1102 does not. Looking at the HP website it seems that the Windows 10 drivers for this printer are not yet available. Is there any way I can use the printer without the dedicated drivers? I have been told I should try to roll back but the printer is not recognised in device manager. Please help!

    Manual, Please let me know the outcome.

  • USB Ultranav keyboard does not work with Windows 7

    Hi, I recently installed Windows 7 to my Dell Latitude XT tablet and was disappointed to learn that my USB Ultranav Keyboard only works as a keyboard and not a 'mouse'; that is, the ultranav devices (touchpad, buttons, and trackpoint) do not work.  I have not had problems with the keyboard functioning in XP or Vista, so it was surprising to find that it will not work with W7.
    I thought all was going well when W7 recognized the Ultranav keyboard when I plugged-in the device, but all did not go as planned.  I let W7 find the drivers through Windows update, but then once they didn't prove to work, I followed W7's directions of reinstalling the drivers in its version of 'Compatability Mode', but that still didn't prove to work.  I would really appreciate any insights into this problem as it is one of my only (current) hesitancies about using W7.
    Thank you for your time and attention to my inquiry.
    Cheers,
    Tsugazi

    Hi, strangely enough, I got it to work.  Here's the what I did differently (for those with a similar problem):
    After installing W7, I plugged in my keyboard and let Windows find the drivers.  When this didn't provide functionality of the ultranav devices, I tried installing the Ultranav drivers, and when Windows said there was a compatability problem, I then opted to let Windows re-install the Ultranav driver.  Unfortunately, this didn't provide functionality either.
    Jump ahead 12 hrs and re-install of W7 (for other reasons).  This time out, I installed the Ultranav driver, THEN plugged in my keyboard.  Everything works now!  I don't know that this sequence will work for everyone, but it did for me.
    Thanks for your comments.
    Cheers,
    tsugazi

  • Printer does not work with Windows 7

    I need help for printing with my HP Deskjet IA 3545 eAiO printer.
    I cannot print with my laptop running on Windows 7. I have tried uninstalling and re-installing countless times over the past 3 days using the accompanying CD as well as trying to get the latest driver updates from the internet but all failed to print. I have also tried using Wireless Direct but that did not work as well. The printer printed the  internal page when I ran the HP Printing and Scanning Doctor tool.
    I have no such printing issue with thsi printer model while using my desktop and other laptop running on Windows 8.1. This Windows 7 laptop prints smoothly however when I switch to my Brother DCP-J315W and Canon LBP7100Cn printers.
    Windows Updates lets me know there is one important update for the driver for this printer but for some mysterious reason the Windows 7 laptop just will not accept the down-loading and installation operations for this particular update.
    Please assist me.

    Hi there @YuLen , 
    Welcome to the HP Forums
    I read your post about how your Deskjet Ink Advantage 3545 is not completely functioning on your own computer running Windows 7 however, another computer functions fine with the printer, and the printer will also print out test pages successfully. This seems to sound like an operating system issue so far, and I have some ideas in mind for you to try out that might help.
    1. Run the Microsoft Fix It Tool to uninstall the printer.
    2. Restart your computer.
    3. Perform a Clean Boot.
    4. Restart the PC again.
    5. Run Windows Updates: Use your Start menu to check for updates
    6. Download and run the full installation here: HP Deskjet Ink Advantage 3540 e-All-in-One Printer series Full Feature Software and Drivers
    7. Try printing now!
    If there is still an issue with performing the Windows Updates, contact Microsoft: Microsoft Support Forums
    Good luck!
    R a i n b o w 7000I work on behalf of HP
    Click the “Kudos Thumbs Up" at the bottom of this post to say
    “Thanks” for helping!
    Click “Accept as Solution” if you feel my post solved your issue, it will help others find the solution!

Maybe you are looking for