tooltip - JavaFX Area Chart: Set Mouse transparency on XYChart Area but not it's child Data Node -



tooltip - JavaFX Area Chart: Set Mouse transparency on XYChart Area but not it's child Data Node -

been scratching head , researching awhile no luck.

i have javafx project in have created areachart 4 sets of series lastly of has points visible (black xs):

i have implemented ability drill downwards chart highlighting area. downwards via various mouse handlers, translucent yellowish rectangle (highlight) re-sizes mouse dragged:

private void setmousehandler() { final axis<date> xaxis = gcchart.getxaxis(); final axis<number> yaxis = gcchart.getyaxis(); final node chartbackground = gcchart.lookup(".chart-plot-background"); (node n: chartbackground.getparent().getchildrenunmodifiable()) { if (n != chartbackground && n != xaxis && n != yaxis && n != highlight) { n.setmousetransparent(true); } } chartbackground.setonmouseentered(new eventhandler<mouseevent>() { @override public void handle(mouseevent mouseevent) { if (mouseevent.isprimarybuttondown()){ exitedchart = false; } } }); //grab initial values if dragged have them chartbackground.setonmousepressed(new eventhandler<mouseevent>() { @override public void handle(mouseevent mouseevent) { if (mouseevent.isprimarybuttondown()){ bounds chartareabounds = yaxis.localtoparent(yaxis.getboundsinparent()); //chartbackground.localtoscene(chartbackground.getboundsinlocal()); xshift = chartareabounds.getmaxx() -10; //account y axis area on chart , side tabs origx = mouseevent.getx() + xshift; highlight.setvisible(true); highlight.setx(origx); highlight.sety(chartareabounds.getminy()+xaxis.getheight()); highlight.setheight(chartareabounds.getmaxy()-xaxis.getheight()); // don't want re-render chart if zoomed out. firstseldate = xaxis.getvaluefordisplay(mouseevent.getx()); } else{ // zoomed in? if (seriescache.size() >= 2){ logger.info("zooming out of chart"); platform.runlater(new runnable() { @override public void run() { removechartfromscene(); // homecoming lastly series in cache new thread(new generatedatatask(null, null, true)).start(); } }); firstseldate = null; } } } }); //must enable fulldrag observe drag entering nodes other chart ie. highlight chartbackground.setondragdetected(new eventhandler<mouseevent>() { @override public void handle(mouseevent mouseevent) { if (mouseevent.isprimarybuttondown()){ chartbackground.startfulldrag(); } } }); chartbackground.setonmousedragged(new eventhandler<mouseevent>() { @override public void handle(mouseevent mouseevent) { if (mouseevent.isprimarybuttondown()){ //only set drag values if in bounds of yaxis if (!exitedchart){ double position = mouseevent.getx() + xshift; highlight.setx(origx <= position? origx : position); highlight.setwidth(origx <= position? position-origx: origx-position); // may whats causing slow drag.. lastseldate = xaxis.getvaluefordisplay(mouseevent.getx()); } } } }); chartbackground.setonmousereleased(new eventhandler<mouseevent>() { public void handle(mouseevent mouseevent) { //check if drag backwards , if swap dates if (lastseldate!=null && firstseldate.compareto(lastseldate)>0){ date tempdate = firstseldate; firstseldate=lastseldate; lastseldate=tempdate; } //mouse has been released cleanup highlight highlight.setx(0); highlight.setwidth(0); highlight.setvisible(false); //set both sets of series in chart subset selected if (lastseldate != null && firstseldate.compareto(lastseldate) != 0) { logger.info("zooming chart"); removechartfromscene(); // show subset of info new thread(new generatedatatask(firstseldate, lastseldate, false)).start(); } lastseldate = null; } }); yaxis.setonmousedragentered(new eventhandler<mousedragevent>() { @override public void handle(mousedragevent mouseevent) { if (mouseevent.isprimarybuttondown()){ exitedchart = true; //account lag in listener when hitting yaxis - pull highlight rigt border highlight.setx(yaxis.getboundsinparent().getmaxx()); highlight.setwidth(origx-yaxis.getboundsinparent().getmaxx()); } } }); //detect drag if pulled highlight area highlight.setonmousedragentered(new eventhandler<mouseevent>() { @override public void handle(mouseevent mouseevent) { if (mouseevent.isprimarybuttondown()){ exitedchart = false; } } }); }

in order highlight functionality working without lot of headaches set nodes in chart transparent mouse:

(node n: chartbackground.getparent().getchildrenunmodifiable()) { if (n != chartbackground && n != xaxis && n != yaxis && n != highlight) { n.setmousetransparent(true); } }

my problem i'm trying set tooltips on top chart series (the black x points) way able them work setting nodes parent (group) , grandparent (xychart) not transparent. in doing bust highlight functionality.

i have experimented setpickonbounds, understand controls whether or not mouse "sees" invisible portions of given node. if understanding right won't work in case drag routine needs ignore visible area(s) of series(falling through chart background) not ignore black xs (xychart.data nodes).

is there anyway (short of rewriting mouse handling) create set of series visible mouse without making else visible?

the mousetranparent property makes "node (together children) transparent mouse events.", cannot utilize property behavior desire.

instead, seek setting event filter on chart selectively ignore events depending on event target. event filter mouse events can query source , target of event , take consume event (to ignore it), or not consume event (to allow default mouse handlers nodes take effect).

if need help viewing events occurring can decide consume or allow through, utilize event logging capabilities of scenicview.

charts tooltip mouseevent nodes javafx-8

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

java - Parsing XML, skip certain tags -

c# - ASP.NET MVC Sequence contains no matching element -