Viewport of a scene region in Java Fx - javafx-2

i have a JavaFx scene with a Region element as ist parent element. Lets say I want this region to have a defined size of 20.000x20.000 Pixels, but Only a window of the size 1024x768.
How can I make my scene display the region area from x-pixel 5.000 and y-pixel 3.000, just similar to a Viewport of the ImageView class? Is this even possible?

Place your Region in a ScrollPane.

Related

What is the exact meaning of match_parent?

I just want to check my understanding is right. In android studio, layout attributes there are layout_width, layout_height. I know both of them as Widget / Layout 's width and height. and we can assign match_parent there. According to my understanding, match_parent always means the widget's height/width is same as the Activity's.
Is my understanding correct??
Match parent means. The widget you're assigning let's suppose height then it'll require the same height as the parent widget /layout
For example if i give 420dp height to my linearlayout and then inside it i provide an imagview as match parent then it's gonna have the same height as linear layout
match_parent is a constant value for views to stretch according to their parents or.
let's say there is a RelativeLayout in your layout XML, whatever widget (View) you put in your root view would stretch according to the parent (which is root view or RelativeLayout in our case).

cytoscape: How to set a rectangle or ellipse other than square layout

To layout a network in cytoscape, the layout appearance is always a square. If I need to arrange the layout with a ellipse or rectangle appearance, I have to move the nodes manually. For exampke, the "yFiles Organic Layout" produces a layout in a round appearance. How can I change the default appearance to rectangle or ellipse?
Thank you!
Pengcheng Yang
Unfortunately, there really isn't a way to do that. It's specific to each layout algorithm how it handles the boundary. There will be a new layout algorithm that allows you to associate nodes to a drawn annotation, but it's not released yet (hopefully very soon).
-- scooter

Codename one - scrollable layout restrictions

I have done my own version of the PropertyCross Demo (provided in their demo section).
The problem I currently face is the size of the "Recent Search" area. While I have a non-scrollable container, I can easily define the preferred height. As the Box Layout adheres to the preferred size, all is well, with the little issue of not being able to scroll it and see more than one result:
recentSearchContainer = new Container(new BoxLayout(BoxLayout.Y_AXIS)); recentSearchContainer.setPreferredH((int)(this.getContentP‌​ane().getHeight() * 0.1f));
Once I set the container to scrollable, the preferred height gets overwritten and takes up as much space as it needs, taking too much space from the BorderLayout Center piece above it.
How to manipulate the preferred size of scrollable components?
You don't manipulate the preferred size. Scrollables take up more space so if you need them to take up a specific amount of space you need to use the right type of layout which in this case might not be border layout...
Border layout gives NORTH/SOUTH elements their preferred height which might not be what you want. You might want a grid layout which will divide the height 50/50. You might want a table layout where you can define the height in percentages etc.
For those who are interested, here is the solution:
Setup a table layout with a single column and as many rows as you need (similar to box layout y axis or border layout which only north, center and south).
Set the table layout to non-scrollable so it defaults to 100% of your screen.
add the components with height % of the screen they should take up.
those components can be scrollable and will still stick to the height constraint!
// inside a form object, setup the layout
TableLayout tl = new TableLayout(3, 1);
tl.setGrowHorizontally(true);
setScrollable(false);
setLayout(tl);
...
// and add stuff to it
add(tl.createConstraint().heightPercentage(15), labelDesc);
add(tl.createConstraint().heightPercentage(50), compGroup);
add(tl.createConstraint().heightPercentage(35), recentSearchContainer);
Works like a charm!

ScrollPane with preferedViewportWidth matching preferedWidth of content

I have a bunch of regions which have a specific preferedWidth set. These Regions are reused visual components in a drag and drop UI.
I want to create a conatainer of these regions and tried to accomplish this with a ScrollPane with an embedded VBox. I want the scrollpane to be wide enough to hold the VBox without horizontal scrolling.
I could figure out the width of the VBox by hand and hardcode the scrollbars width but i would prefere a dynamic solution so that i can style the vbox later. Unfortunately the vbox preferred width is -1 even though its children have a prefered width set.
Also if i try to set the scrollpanes preferedViewportWidth to the width of my regions i get mixed results dependent on the hbarPolicy. If the policy is set to AS_NEEDED the width of the scrollbar is ignored and the scrollbar appears over my regions when it appears.
Any ideas how i get a SrollPane which is wide enough for my regions with and without a vertical scrollbar and possible styling of paddings etc.
Solved my problem by binding the ScrollPane's prefViewportWidthProperty() to the width property of the child.

How to ensure graphics size change with change in window size?

I am drawing a rectangle in a picturebox. when the user manually changes the window size the rectangle size does not change. how do i make it resize?. i am drawing in the Paint event Thanks a lot

Resources