java - Add touch gestures to legacy swing application -
i have legacy swing application need add touch gestures to,specifically pinch zoom , touch , drag.
i tried swingnode of jdk 8 , can run swing application there, display performance cut more 50% won't work. swingtexturerenderer in mt4j has same issue , without trying redispatch touch events mouse events.
i thought glass pane approach using javafx layer on top , capturing touch events , attempting dispatch them mouse events swing app underneath.
does have alternative approach? target platform windows 8.
bounty coming stackoverflow opens up. need 1 pretty rapidly.
edit:
here tried swingnode (the mouse redispatch didn't work). swingnode stuff might distraction best solution ignore if have better idea getting touch swing:
@override public void start(stage stage) { final swingnode swingnode = new swingnode(); createandsetswingcontent(swingnode); stackpane pane = new stackpane(); pane.getchildren().add(swingnode); stage.setscene(new scene(pane, 640, 480)); stage.show(); } private void createandsetswingcontent(final swingnode swingnode) { swingutilities.invokelater(new runnable() { @override public void run() { uilib.setplatformlookandfeel(); // create graphviewtouch string datafile = null; string label = "label"; final jpanel frame = graphview.demoframeless(datafile, label); swingnode.setcontent(frame); swingnode.setonzoom(new eventhandler<zoomevent>() { @override public void handle(zoomevent event) { mousewheelevent me = new mousewheelevent(frame, 1, system.currenttimemillis(), 0, (int)math.round(event.getscenex()), (int)math.round(event.getsceney()), (int)math.round(event.getscreenx()), (int)math.round(event.getscreeny()), (int)math.round(event.getzoomfactor()), false, mousewheelevent.wheel_unit_scroll, (int)math.round(event.getzoomfactor()), (int)math.round(event.getzoomfactor()), event.getzoomfactor()); frame.dispatchevent(me); system.out.println("graphview: zoom event" + ", inertia: " + event.isinertia() + ", direct: " + event.isdirect()); event.consume(); } }); } }); }
hmm... tough one, there chance.
what make multiple mouselistener
classes (relative number of mouse events want pick up), , create sort of system detect adjustments, eg. (zoom)
1st listener:
public void mousepressed(mouseevent e){ //set click true clk = true; //set first mouse position firstpos = window.getmouseposition(); } public void mousereleased(mouseevent e){ //set second mouse position secondpos = window.getmouseposition(); }
second listener
public void mousepressed(mouseevent e){ //set clicked true clk = true; //set first mouse position (listener 2) firstpos = window.getmouseposition(); } public void mousereleased(mouseevent e){ //set second mouse position secondpos = window.getmouseposition(); }
main handler
if(listener1.get1stmousepos() < listener1.get2ndmousepos() && listener2.get1stmousepos() < listener2.get2ndmousepos() && listener1.clk && listener2.clk){ zoommethod((listener1.get1stmousepos - listener1.get2ndmousepos()) + (listener1.get1stlistener2.get2ndmousepos()); }
and add window:
window.addmouselistener(listener1); window.addmouselistener(listener2);
hope find way.
Comments
Post a Comment