javafx drawing lines and text -
javafx drawing lines and text -
i've got problem drawing lines in javafx. we're making application simulating traffic - there 16 streets, , every street has different color dependent on traffic. there simple picture: http://img546.imageshack.us/img546/9949/uliceu.jpg
my first thought on how draw streets lines , alter colors. cant set text on line (i want text street name). tried set line , text on stackpane. added stackpanes on borderpane center... didnt work. seems stackpane doesn't respect line's start x, start y... lines overlapped each other.
main pane of app borderpane , want set map on center. doesn't need resized dynamically, have 1 map can positioned in static way.
i need that: http://img834.imageshack.us/img834/1157/ulicac.jpg streets need connect each other... on first picture
have suggestions on how that? tips appreciated :)
like that:
group gr = new group(); text text = new text("1st street"); text.setfill(color.web("fabbff")); line line = new line(0, 150, 200,150); line.setstrokewidth(20); line.setstroke(color.web("000000")); gr.getchildren().addall(line, text); group.getchildren().addall(gr, //and every other street);
the stackpane using default center in center of stackpane, won't want.
instead of stackpane, utilize plain pane (if need css style pane or have controls in pane resize when resize pane), otherwise utilize group. state map drawing doesn't need resized dynamically, perhaps grouping fine.
the order in items placed within grouping or pane's children list determine order in items rendered. items added first list rendered first , items added lastly list rendered on top of items added first. add together street lines pane or grouping first, , add together text (or labels) on top of streets.
another alternative utilize direct draw canvas, but, application, using scene graph objects in pane or grouping improve approach.
use either 1 pane/group of streets added first, followed of names or 1 pane/group streets , street names. separate panes might nice because toggle visibility on street names needed setting visible flag on street name group. don't utilize 1 grouping both street , it's name, seek layer multiple street+streetname groups on top of each other, otherwise @ intersections of street names obscured streets running of top of them.
in add-on positioning lines providing co-ordinates them on line creation, need position text displayed on top of lines. can utilize text.relocate(x, y) method locate text @ given location.
text line javafx-2 lines
Comments
Post a Comment