Interesting things, however, strangers? StackPane, animations and filters.

CHANGE (17/01/2014):


As suggested by jsmith , I changed this thread so we could treat the on only one thing. Other issues that existed here before I put each in its own separate discussion. I hope that now we can deal with it properly, so start New:


For the first test case, I tried to create a program that has some controls and I put a animated background behind her done with nodes in transition. With such a test, I received the following Visual result:


http://s24.postimg.org/tk0psfm2t/programa_errado.jpg

The background is made of white circles que increase and decrease more than time asynchronously. Notice how the interface (controls) is put on the top, and Unfortunately, it is not aligned for what is of the application window. Tthere resulting code from the image above can be seen below:


import javafx.animation.Animation;
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.effect.GaussianBlur;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Font;
import javafx.stage.Stage;
import javafx.util.Duration;

public class AnimatedBackground extends Application
{
    // #########################################################################################################
    //                                                                                                      MAIN
    // #########################################################################################################
   
    public static void main(String[] args)
    {
        Application.launch(args);
    }

    // #########################################################################################################
    //                                                                                                INSTANCES
    // #########################################################################################################
   
    private Group root;
    private Group grp_hexagons;
    private Rectangle rect_background;
    private Scene cenario;
   
    // UI
   
    private VBox lay_box_controls;
   
    private Label lab_test;
    private TextArea texA_test;
    private Button but_test;
   
    // #########################################################################################################
    //                                                                                                 FX INIT
    // #########################################################################################################
   
    @Override public void start(Stage stage) throws Exception
    {
        this.confFX();
       
        cenario = new Scene(this.root , 640 , 480);
       
        this.rect_background.widthProperty().bind(this.cenario.widthProperty());
        this.rect_background.heightProperty().bind(this.cenario.heightProperty());

        stage.setScene(cenario);
        stage.setTitle("Meu programa JavaFX - R.D.S.");
        stage.show();
    }
   
    protected void confFX()
    {
        this.root = new Group();
        this.grp_hexagons = new Group();
       
        // Initiate the circles and all animation asynchronously.
        for(int cont = 0 ; cont < 15 ; cont++)
        {
            Circle circle = new Circle();
            circle.setFill(Color.WHITE);
            circle.setEffect(new GaussianBlur(Math.random() * 8 + 2));
            circle.setOpacity(Math.random());
            circle.setRadius(20);
           
            this.grp_hexagons.getChildren().add(circle);
           
            double randScale = (Math.random() * 4) + 1;
           
            KeyValue kValueX = new KeyValue(circle.scaleXProperty() , randScale);
            KeyValue kValueY = new KeyValue(circle.scaleYProperty() , randScale);
            KeyFrame kFrame = new KeyFrame(Duration.millis(5000 + (Math.random() * 5000)) , kValueX , kValueY);
           
            Timeline timeL = new Timeline();
            timeL.getKeyFrames().add(kFrame);
            timeL.setAutoReverse(true);
            timeL.setCycleCount(Animation.INDEFINITE);
            timeL.play();
        }

        this.rect_background = new Rectangle();

        this.root.getChildren().add(this.rect_background);
        this.root.getChildren().add(this.grp_hexagons);
       
        // UI
       
        this.lay_box_controls = new VBox();
        this.lay_box_controls.setSpacing(20);
        this.lay_box_controls.setAlignment(Pos.CENTER);
       
        this.but_test = new Button("CHANGE POSITIONS");
        this.but_test.setAlignment(Pos.CENTER);
       
// Change circles position when button is pressed.
        this.but_test.setOnAction(new EventHandler<ActionEvent>()
        {
            @Override public void handle(ActionEvent e)
            {
                for(Node hexagon : grp_hexagons.getChildren())
                {
                    hexagon.setTranslateX(Math.random() * cenario.getWidth());
                    hexagon.setTranslateY(Math.random() * cenario.getHeight());
                }
            }
        });
       
        this.texA_test = new TextArea();
        this.texA_test.setText("This is just a test.");
       
        this.lab_test = new Label("This is just a label.");
        this.lab_test.setTextFill(Color.WHITE);
        this.lab_test.setFont(new Font(32));
       
        this.lay_box_controls.getChildren().add(this.lab_test);
        this.lay_box_controls.getChildren().add(this.texA_test);
        this.lay_box_controls.getChildren().add(this.but_test);
       
        this.root.getChildren().add(this.lay_box_controls);
    }
}


I think that my tree of nodes is structured as follows :


http://S27.postimg.org/pjpvnlywz/rvore_de_n_s.jpg


I also have tried to change the root of my scene graph to StackPane. Unfortunately, the result was weird. Despite my interface controls went to the middle of the window (which is what I wanted), the bottom began to to animate in a totally weird way. I don't know what else to do on this subject. , It would be strange If this type of feature is not exist in JavaFX, because I could easily do this kind of thing to the Swing Framework library and timming. So far, I still can't understand how I could get around this problem. As a user of JavaFX, I think that it would be more interesting if the JavaFX developers would put more cool similar things to present in the documentation us. Well... If someone can help me Iwill be really grateful. I don't know a lot of people peut Can also take advantage of this too.


Thank you for your attention and patience in any case.


Editada por Mensagem: Loa

It seems to me that I finally got the result I wanted, thanks to God and to you for this. I'd love to share with the community here:

Using StackPane as root, it seemed to me that I was not getting the desired result. As you say, make use of the group for circles, causes odd effect I spoke. That's because you showed me in the JavaFX API, group is committed to the size of its child nodes. As in this type of animation background changes its size in transition (and because it's in a layout that centralizes things like StackPane), it seems that the circles are not calm and move every time they becoming or shrinkage. Using StackPane as one parent node to the circles, they are all mainly in the center of the Panel, as it is one of the goals of StackPane. As I intend to change their positions, I used the following code block so that it is possible (in the case where triggered when the button is clicked):

circle.setTranslateX(Math.random() * cenario.getWidth());
circle.setTranslateY(Math.random() * cenario.getHeight());

He was supposed to distribute the circles in the background of the window. However, it was not quite what happened. This that this resulted in circles in the background OF THE CENTER OF THE BACKGROUND, not distributing from the upper left, as initially planned by me. This means that the starting position in the center of a StackPane node leaves, that is to say StackPane not only centralizes things, but also change the initial position of them. For the circles to be distributed properly, I had to take into account the negative positions, since their origin was like being in the Center. With that, I could find the following code:

circle.setTranslateX( random.nextInt((int) cenario.getWidth()) - cenario.getWidth() / 2 );
circle.setTranslateY( random.nextInt((int) cenario.getHeight()) - cenario.getHeight() / 2 );

All this race about ended up giving me the tree of the following nodes:

http://S14.postimg.org/y887ps3zz/finalnodes.jpg

And also the following final code:

import java.util.Random;

import javafx.animation.Animation;
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.effect.GaussianBlur;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Font;
import javafx.stage.Stage;
import javafx.util.Duration;

public class AnimatedBackground extends Application
{
    // #########################################################################################################
    //                                                                                                      MAIN
    // #########################################################################################################

    public static void main(String[] args)
    {
        Application.launch(args);
    }

    // #########################################################################################################
    //                                                                                                INSTÂNCIAS
    // #########################################################################################################

    private StackPane root;
    private StackPane circles;
    private Rectangle rect_background;
    private Scene cenario;

    // UI

    private VBox lay_box_controls;

    private Label lab_test;
    private TextArea texA_test;
    private Button but_test;

    // #########################################################################################################
    //                                                                                                 INÍCIO FX
    // #########################################################################################################

    @Override public void start(Stage stage) throws Exception
    {
        this.confFX();

        cenario = new Scene(this.root , 640 , 480);

        this.rect_background.widthProperty().bind(this.cenario.widthProperty());
        this.rect_background.heightProperty().bind(this.cenario.heightProperty());

        stage.setScene(cenario);
        stage.setTitle("Meu programa JavaFX - R.D.S.");
        stage.show();
    }

    protected void confFX()
    {
        this.root = new StackPane();

        this.circles = new StackPane();
        this.circles.setStyle("-fx-border-color:blue");

        // Initiate the circles and all animation stuff.
        for(int cont = 0 ; cont < 15 ; cont++)
        {
            Circle circle = new Circle();
            circle.setFill(Color.WHITE);
            circle.setEffect(new GaussianBlur(Math.random() * 8 + 2));
            circle.setOpacity(Math.random());
            circle.setRadius(20);

            this.circles.getChildren().add(circle);

            double randScale = (Math.random() * 4) + 1;

            KeyValue kValueX = new KeyValue(circle.scaleXProperty() , randScale);
            KeyValue kValueY = new KeyValue(circle.scaleYProperty() , randScale);
            KeyFrame kFrame = new KeyFrame(Duration.millis(5000 + (Math.random() * 5000)) , kValueX , kValueY);

            Timeline timeL = new Timeline();
            timeL.getKeyFrames().add(kFrame);
            timeL.setAutoReverse(true);
            timeL.setCycleCount(Animation.INDEFINITE);
            timeL.play();
        }

        this.rect_background = new Rectangle();

        this.root.getChildren().add(this.rect_background);
        this.root.getChildren().add(this.circles);

        // UI

        this.lay_box_controls = new VBox();
        this.lay_box_controls.setSpacing(20);
        this.lay_box_controls.setAlignment(Pos.CENTER);
        this.lay_box_controls.setPadding(new Insets(0 , 90 , 0 , 90));

        this.but_test = new Button("CHANGE POSITIONS");
        this.but_test.setAlignment(Pos.CENTER);

        // Pressing the button, the circles will change to random positions.
        this.but_test.setOnAction(new EventHandler()
        {
            @Override public void handle(ActionEvent e)
            {
                Random random = new Random();

                for(Node circle : circles.getChildren())
                {
                    // The layout behaves in a very unexpected way.
                    circle.setTranslateX( random.nextInt((int) cenario.getWidth()) - cenario.getWidth() / 2 );
                    circle.setTranslateY( random.nextInt((int) cenario.getHeight()) - cenario.getHeight() / 2 );
                }
            }
        });

        this.texA_test = new TextArea();
        this.texA_test.setText("This is just a test.");

        this.lab_test = new Label("This is just a label.");
        this.lab_test.setTextFill(Color.WHITE);
        this.lab_test.setFont(new Font(32));

        this.lay_box_controls.getChildren().add(this.lab_test);
        this.lay_box_controls.getChildren().add(this.texA_test);
        this.lay_box_controls.getChildren().add(this.but_test);

        this.root.getChildren().add(this.lay_box_controls);
    }
}

The only little problem that 'left' now is when the user resizes the application. Once that circles are distributed whenever the application is resized they need be distributed again. My test application doesn't have with that in mind, but I think I can solve this problem easily using a layout that arranges the nodes by the edges of a panel using a proportional positioning. For example, should be a sign of provision for organizing nodes always a certain percentage of the edges. This can be done easily with a layout of the custom panel, because AnchorPane behaves in a different way.

I think that what I have to do now is go back and learn how to create a custom layout Panel. I want to thank all of you for your patience and your good intention to help. Thank you, really!

If anyone has anything to add, or corrections to what I said earlier, I would be very happy. The richest is this thread, best JavaFX is accepted for other users.

Tags: Java

Similar Questions

  • Acquisition of data and filtering on FPGA

    Hi all

    I have trouble to design a FPGA program for acquisition of data and filtering.

    I have two NOR 9205 modules configured to work in terminal mode of DIFF, i.e. There are 32 entries this program must read every Ts seconds. (Ts is the time discretization, i.e. during the period of loop)

    With respect to the digital filter, I implemented a possible simple filter with transfer function G (s) = 1 /(1+sT), which is part of the field of discrete-time equal to y (k) = a * u (k - 1) + b * y (k-1), where u is the original signal, and there is filtered signal. The coefficients a and b are equal to: a = 1-exp(-Ts/T), b = exp(-Ts/T), and T is the time constant of the filter (usually T > 5 * Ts).

    The implementation of main program for the acquisition of data and filtering are:

    This application is for the digital filter:

    However, the problem is that this program cannot take the FPGA resources on cRIO-9114, and Yes, I tried to define the criteria of compilation for the area. I also tried to implement the multipliers in digital filter as lut and DSP, unfortunately without a bit of luck.

    Because I don't have that much experience in programming of FPGA, someone has any suggestions how to improve this code to adapt existing FPGA resources?

    Best regards

    Marko.

    Hey Norbert_B,

    I managed to solve the problem. First, I changed the reentrancy of Preallocated incoming execution clone to not reentrant execution. As no reentrant VIs have States, I had to use the node of the feedback to the main VI to get u(k-1) and y(k-1). Another important thing is to choose Ignore FPGA reset method in the node of the properties of FPGA implementationfeedback, since in this case, the feedback node uses less resources.

    Here is the new main program VI:

    And here's the 'filter' VI:

    Thanks for the help!

    Best regards

    Marko.

  • Group of Essbase Export and filters in 11.1.2.1

    Hello

    I understand that it is a very old topic in the export of security as groups and filters using LCM.

    However, my requirement is something different. I'm almost 15 Applications Essbase in 11.1.2.1. and I just export 2 Essbase security via LCM.

    Groups and filters other requests remain intact; application groups only 2 are absent.

    Can you advise how to do this please

    Thank you
    UB.

    Same thing here.

    And MaxL isn't really easy either - it must export privileges and then parse the output of MaxL in instructions MaxL. There is a more complete description here: Re: export security and the copy?

  • My tags and filters disappear when I migrate to another computer. How to get those back?

    I use Thunderbird to work, and I need to use several computers (desktop and laptop - Mac). I was able to successfully migrate everything by copying the profile folder, but the tags and filters exceed. The address book either, but I just use the import/export for this tool. I crept over all files filter, but it still does not. I manually create tags, but when I mark an e-mail on one computer, it won't label it on the other.

    Thank you, Diego. It turns out that the module does not work with the latest version, but this one does: https://addons.mozilla.org/en-US/thunderbird/addon/tb-import-export-wind-li-port/?src=search

    I installed it and it picked up my filters and my color labels.

    Thank you!

  • My iPhone my iPhone 5 guard by clicking on things at random, by clicking on the things im not clicking on and freeze momentarily. But the screen is not cracked

    My iPhone 5 guard by clicking on things at random, by clicking on the things im not clicking on and freeze momentarily. But the screen is not cracked

    You should go to the apple store and ask them to check it for you! You may have a faulty screen or faulty motherboard! in any case it is best to call or go to the apple store

  • With the help of transformations and filters without device drivers

    Hello

    I came across NIMS as a possible solution for some transformations and filtering, or generating data of the signal of the test for seismic application. I'm evaluating NIMS for optimal for what we need/want to accomplish.

    Basically, we have some seismic data, and we want to treat these data through a series of transformations and filters to Denoise and choose data for seismic analysis. No sense in reinventing the wheel, if we can adopt and adapt a library then third as NIMS in our application.

    We must not necessarily device drivers, although I noticed NIMS installation requires. I hope that we can opt in or out depending on what is actually needed. Can anyone help clarify the nature of the dependency driver?

    Anyway, as I said I am evaluating for most able to adapt to our application, but in the meantime if anyone can shed some light on the concerns above, questions, etc., would begreat.

    Thank you...

    Best regards.

    You don't need to install device drivers to use Measurement Studio. If you are prompted to do so by the wizard to insall, just leave the guest of driver installation.

    -Mike

  • Is there such a thing as the Windows support and Service Center, phone 02032866214?

    Is there such a thing as the supported Windows and Service Centre, Tel. 02032866214, or is it a phone scam?

    If someone rings you claiming to be from Microsoft and that you did not go to Microsoft you call, then it is a scam. Microsoft never make these requested no calls to technical support. Do not let them give any info, do not give access to your PC, not give them all the money and do not go to all the websites that they suggest. One moment. See:

    http://www.microsoft.com/en-gb/security/online-privacy/msname.aspx .

    (these scammers can use names other than Microsoft as well)

  • I have always used the windows logo + L key to lock my computer, I remove things from my hard drive and now it locks not for me... need your help :)

    I have always used the windows logo + L key to lock my computer, I remove things from my hard drive and now it locks not for me... need your help :)

    Hi ddbowers01,

    The other shortcut keys work?

    Try pressing CTRL + ALT + DELETE and then try to lock the computer and check.

    Check the setting below:

    a. in the Control Panel, click user accounts.

    b. click on change the way users log on or off the power.

    c. Click to uncheck use the screen of welcome for a quick and easy connection.

    d. click OK.

    With regard to:

    Samhrutha G S - Microsoft technical support.

    Visit our Microsoft answers feedback Forum and let us know what you think.

  • Rub the animation and did not go constantly to find out if it syncs correctly

    (Note, I use Flash CS6. And as I have no idea where to put this discussion, I might as well make the note here)

    How to make it so that I can actually scrub through animation and without having to constantly make sure if it syncs correctly? I can't make it work for me. I do an animation, and it would be useful to at least try to match the sounds with the action instead of random guessing.

    You must set your sounds to flow on the timeline.

  • Importing animations and videos-videos are important to small

    I was searching for an answer to my problem. I have a project with animations and video. When I matter my animations, photos and music is the perfect size. When I import my video it's small in the display screen. Very small. If I import on another project, it is important properly. I don't know how to change the setting of the sequence before importing the video, or if I can import the video with different parameters. Help, please

    Apparently you create your your forests of animation sequences, then adding videos later? What image size are they? PrPro creates a sequence with the settings according to the material in FLAC to an area empty timeline, so if say your animations are defined in 1920 x 1080 and your video is 1280 x 720 and you started with the animation first, PrPro would create a sequence of 1920 x 1080, and when you put the video on the timeline it will put in the small box in the Middle , but the size of 1280 x 720.

    Say your animations and still images are 4096 x 2304, if the size of the sequence that you will receive, and if your video is 1920 x 1080, once again, you will get a small video in what appears to be a box in the middle.

    Maybe you should check your sequence settings by right-clicking on a sequence, then select Properties... post a screenshot of this back here.

    And also... What are the dimensions in pixels of your video media, your photos and your animations? Sounds like you may need to set your sequence to match your video and maybe use 'set of sequence' for your entertainment & stills if they are no longer large width x height as your video clips.

    Neil

  • Hi, I have four images purchased with a license standard Adobe, used for book covers. If I want to use images for other things like mugs, T-shirts and so on, I need a license and how to buy that? "I see an option on my page for.

    Hi, I have four images purchased with a license standard Adobe, used for book covers. If I want to use images for other things like mugs, T-shirts and so on, I need a license and how to buy that? I see an option on my page for the "license again", which is the one to use?

    Hello

    Please see the frequently asked questions, Adobe Stock

    Hope that helps!

    Kind regards

    Sheena

  • Bad job first elements 10.0. I made a flash animation and has decided to add sound in first - Elements.It turned jerks. How to fix this error

    Bad job first elements 10.0. I made a flash animation and has decided to add sound in first - Elements.It turned jerks. How to fix this error

    Dear Sirs. I ask you to give special attention that the frame rate vidio input and output cannot exclude more than 1 frame, otherwise the image will shake and blurry text. It is preferable to use the HD 720 P 25 sincerely Mikhail Osipov

  • The radial and the graduated filter and filters spots do nothing but cast a shadow over the region. the settings do not work on them.

    CC in Lightroom

    27 "iMac

    Yosemite running

    just loaded CC in lightroom

    The radial and the graduated filter and filters spots do nothing but cast a shadow over the region. the settings do not work on them.

    A few suggestions

    Try to disable the GPU in preferences > performance.

    For filters, try to press O to see if it's the mask you are viewing rather than adjustments.

  • I created an interactive navigation along the animated and imported and that the muse. Animations works very well, but does not have the interactivity. ((par exemple si je clique sur le "bouton à la maison", que le site ne s'ouvre pas dans mon navigateur

    I created an interactive navigation along the animated and imported and that the muse.
    Animations works very well, but does not have the interactivity.
    ((par exemple si je clique sur le "bouton à la maison", que le site ne s'ouvre pas dans mon navigateur comme il se doit),)
    Anyone have an idea how I can fix this problem?

    Hello

    As you use the edge with muse file you do not put the full URL.

    Please try the code below.

    Window.Open("..) /.. /arbeiten.html","_top");

    Concerning

    ViveK

  • Problems in animation and the actions in epub

    Hi, I have problems to view animations and background of my epub actions, when I view all works with indesign, but in content adobe Viewer, I did not not if I forgot something in the settings of the document, does anyone know what happened?

    Native InDesign animations are not supported in DPS. Use border animate.

Maybe you are looking for

  • Firefox crashes when you click Tools - Options and trying to download images.

    On a website that I visit when I try to upload an image, Firefox hangs and must be restarted. I did some research and tried all solutions but none worked. When I open Internet Explorer, the download works fine. It's only Firefox that has this problem

  • Equium P300 - 16t power problems

    My laptop Equium P300-16 t has suddenly stopped working. When it is connected, the power icon is always on view, but the battery icon has disappeared, and the battery icon when you press the power button flashes red for a few seconds before disappear

  • It is legal to buy iphone Moldavian customs

    It is legal to buy the iphone 6 or 6 s customs

  • Check help for virus

    The other day, I clicked on a risky link who brought up a JavaScript message in my chrome window, with an option to click to go somewhere to "scan my computer a virus. I clicked immediately outside, but I have to think if you could download viruses a

  • WAP4400N "Wrong file Format" Solution 1.2.17

    I just bought a WAP4400N AP and through all of this again, like most of the posts is old so I thought I would put this to the top again incase anyone needs. There are 2 versions of the WAP4400N, one for the Canada / NA and the other for EU/UK/AP etc.