javafx - How to automatically resize anchor pane if element change LayoutX -


i have problem when set layoutx child element in anchorpane. element exceed border of parentanchor pane? there way set listener on each child's width property?

code example of usage:

relation.heightproperty().addlistener((observable, oldvalue, newvalue) -> {     if (relationtypeelement != null) {         relationtypeelement.settranslatey((newvalue.doublevalue() - relationtypeelement.getheight() - margin_bottom - padding_top) / 2);     } });  relationtypeelement.heightproperty().addlistener((observable, oldvalue, newvalue) -> {     relationtypeelement.settranslatey((relation.getheight() - newvalue.doublevalue() - margin_bottom - padding_top) / 2); });   childrenbox.widthproperty().addlistener(observable -> {     relationtypeelement.settranslatex(childrenbox.getwidth()/2);     spousecard.settranslatex(relationtypeelement.gettranslatex() + 200); }); 

@edit...
thing bizzare... when use code :

double dd = relationtypeelement.getlayoutx +200; spousecard.setlayoutx(dd); 

the element exceeds border of parent pane.

but when use :

spousecard.setlayoutx(1400); 

the element placed correctly, , parent pane resizing.


after many tries, tasting code:

private void calculaterelationelementsposition() {     if (children.size() > 0) {         line line = childrenconnector.getline();         double offset = line.getendx() + relationtypeelement.getwidth()/2 -5;         anchorpane.setrightanchor(relationtypeelement, offset);         anchorpane.setrightanchor(spousecard, offset + 200);         childrenconnector.connectrelationtochildren(relationtypeelement);     } else {        // relationtypeelement.setlayoutx(100);     } } 

but result still not satisfying.

@edit @fabian project kind of genealogy tree.. more precise graph/map of relations structure in sims. after profound research, other program doesn't show in 1 picture relations (also ex-spouse , asc/desc).

so.. map divided module class. in 1 mode draw tree 1 family starting root. main parent.

class: childpanel extend borderpane { left: hbox panelrelationex center: anchorpane panelsingle right: anchorpane panelrelationcurrent } 

in hbox put:

   class : panelrelationex extends borderpane {     top: anchorpane relation (contain graphical representation of spouse , relationtype)     center: hbox children ( containnign objects of class childpanel)     }      class: panelrelationcurrent extends borderpane {     top: anchorpane relation (contain graphical representation of spouse , relationtype)     center: hbox children ( containnign objects of class childpanel)     } 

panelex , panelcurrent similar. difference in alignment items.

when add children hbox draw line connecting them, , @ next deplace elements in anchorpane relation. first, last child or on center of connecting line.

function displaced objects works fine. layoutx , y property correctly set. have problem sizing pane. example. when add new element hbox ( children) hbox grow cause growing of parent , tree. when set layoutx elements in anchorpane relation , there 1 child in hbox. elements out of bord of anchorpane relation

enter image description here

when use function

relation.resize(newwidth, newheight)  

in trigger, anchor pane relation resized, time, out of bord of hisparent (borderpane.gettop)

the case of relationex little bit more complicated because layoutx of spouse card negative.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -