How to resize WorldWind Panel?
Asked Answered
F

1

13

I want to put a WorldWindowGLJPanel into a Pane, and I want to make it resizable, but I can't, even when I call resize or setSize method.

Here's what I'm doing :

wwd = new WorldWindowGLJPanel();
wwd.setPreferredSize(new java.awt.Dimension(300, 300));
wwd.setModel(new BasicModel()); 

swingNode = new SwingNode(); 
swingNode.setContent(wwd); 

wwdPane = new Pane();
wwdPane.getChildren().add(swingNode); 

Then I use this wwdPane to display World Wind.

I want my world wind panel to have the size of the pane which contains it, and I want to make this world wind panel resizable.

I thought about give the size to my world wind panel of my pane with a setSize(PaneDimenson) and then bind the size of my worldwindpanel with my pane , but the setSize function doesn't work.

EDIT : I found an alternative solution by not using a pane, but directly the swingNode, the resize is now automatic. But if you want to use a pane there's still a problem, and you're force to use a group.

Filmore answered 29/4, 2015 at 14:49 Comment(0)
F
0

The setSize is working, try this code:

scene.widthProperty().addListener(new ChangeListener<Number>() {
   @Override public void changed( ObservableValue<? extends Number> o, Number b, Number a ) {
      Platform.runLater(new Runnable() {
         public void run() {
            wwd.setSize((int)(a.intValue()*0.5), wwd.getHeight());
         }
      });

or with Java8

scene.widthProperty().addListener((o,b,a)->Platform.runLater(()->
   wwd.setSize((int)(a.intValue()*0.5), wwd.getHeight())));

But I couldn't make the resize work in my sample code, because the SwingNode somehow mess up the resizing, I think you should try the solution advised here.

Frogmouth answered 8/5, 2015 at 14:40 Comment(3)
The problem comes from the swingNode, but the solution in the other topic does not work for me ...Filmore
If I use a group the solution of the other topic work.Filmore
I'm glad that you solved it, I didn't have any other idea. This SwingNode feature is just for backward compatibility and I believe it is always risky to connect with a swing based library if you didn't write that library.Frogmouth

© 2022 - 2024 — McMap. All rights reserved.