X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=bundles%2Forg.simantics.g2d%2Fsrc%2Forg%2Fsimantics%2Fg2d%2Fparticipant%2FHandPainter.java;h=76929c5e39e4af35fb6a14b5be946a026b430f66;hb=refs%2Fchanges%2F38%2F238%2F2;hp=95b9ddeed402837f73b84821874f44207e35f023;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/participant/HandPainter.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/participant/HandPainter.java index 95b9ddeed..76929c5e3 100644 --- a/bundles/org.simantics.g2d/src/org/simantics/g2d/participant/HandPainter.java +++ b/bundles/org.simantics.g2d/src/org/simantics/g2d/participant/HandPainter.java @@ -1,74 +1,74 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.g2d.participant; - -import org.simantics.g2d.canvas.impl.AbstractCanvasParticipant; -import org.simantics.g2d.canvas.impl.DependencyReflection.Dependency; -import org.simantics.scenegraph.g2d.events.MouseEvent; -import org.simantics.scenegraph.g2d.events.EventHandlerReflection.EventHandler; -import org.simantics.scenegraph.g2d.events.MouseEvent.MouseButtonEvent; -import org.simantics.scenegraph.g2d.events.MouseEvent.MouseMovedEvent; - -/** - * Paints a grabbed hand when canvas is grabbed. - * - * TODO: out of order for now, needs to be adapted to scene graph - * - * @author Toni Kalajainen - */ -public class HandPainter extends AbstractCanvasParticipant { - - @Dependency CanvasGrab grab; - @Dependency SymbolUtil symbols; - @Dependency TransformUtil util; - @Dependency MouseUtil mice; - -// @Painter(priority=PointerPainter.CURSOR_PAINT_PRIORITY+10) -// public void paint(GraphicsContext gc) { -// assertDependencies(); -// Map pis = grab.getGrabInfo(); -// Collection mis = mice.getMiceInfo().values(); -// if (mis.isEmpty()) return; -// -// // Symbol -// Image grab = symbols.get(DefaultImages.GRAB32, gc.getGraphics2D().getDeviceConfiguration()); -// double gcx = grab.getBounds().getCenterX(); -// double gcy = grab.getBounds().getCenterY(); -// Image hand = symbols.get(DefaultImages.HAND32, gc.getGraphics2D().getDeviceConfiguration()); -// double hcx = hand.getBounds().getCenterX(); -// double hcy = hand.getBounds().getCenterY(); -// -// for (MouseInfo mi : mis) { -// GraphicsContext g = gc.clone(); -// PointerInfo pi = pis.get(mi.mouseId); -// if (pi!=null) { -// Point2D pos = util.canvasToControl(pi.anchorPos, null); -// g.getGraphics2D().translate(pos.getX(), pos.getY()); -// g.getGraphics2D().translate(-gcx, -gcy); -// grab.paint(g); -// } else { -// Point2D pos = mi.controlPosition; -// g.getGraphics2D().translate(pos.getX(), pos.getY()); -// g.getGraphics2D().translate(-gcx, -gcy); -// hand.paint(g); -// } -// g.dispose(); -// } -// } - - @EventHandler(priority = Integer.MAX_VALUE) - public boolean handleMouseEvent(MouseEvent e) { - if (e instanceof MouseMovedEvent || e instanceof MouseButtonEvent) - setDirty(); - return false; - } -} +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.g2d.participant; + +import org.simantics.g2d.canvas.impl.AbstractCanvasParticipant; +import org.simantics.g2d.canvas.impl.DependencyReflection.Dependency; +import org.simantics.scenegraph.g2d.events.MouseEvent; +import org.simantics.scenegraph.g2d.events.EventHandlerReflection.EventHandler; +import org.simantics.scenegraph.g2d.events.MouseEvent.MouseButtonEvent; +import org.simantics.scenegraph.g2d.events.MouseEvent.MouseMovedEvent; + +/** + * Paints a grabbed hand when canvas is grabbed. + * + * TODO: out of order for now, needs to be adapted to scene graph + * + * @author Toni Kalajainen + */ +public class HandPainter extends AbstractCanvasParticipant { + + @Dependency CanvasGrab grab; + @Dependency SymbolUtil symbols; + @Dependency TransformUtil util; + @Dependency MouseUtil mice; + +// @Painter(priority=PointerPainter.CURSOR_PAINT_PRIORITY+10) +// public void paint(GraphicsContext gc) { +// assertDependencies(); +// Map pis = grab.getGrabInfo(); +// Collection mis = mice.getMiceInfo().values(); +// if (mis.isEmpty()) return; +// +// // Symbol +// Image grab = symbols.get(DefaultImages.GRAB32, gc.getGraphics2D().getDeviceConfiguration()); +// double gcx = grab.getBounds().getCenterX(); +// double gcy = grab.getBounds().getCenterY(); +// Image hand = symbols.get(DefaultImages.HAND32, gc.getGraphics2D().getDeviceConfiguration()); +// double hcx = hand.getBounds().getCenterX(); +// double hcy = hand.getBounds().getCenterY(); +// +// for (MouseInfo mi : mis) { +// GraphicsContext g = gc.clone(); +// PointerInfo pi = pis.get(mi.mouseId); +// if (pi!=null) { +// Point2D pos = util.canvasToControl(pi.anchorPos, null); +// g.getGraphics2D().translate(pos.getX(), pos.getY()); +// g.getGraphics2D().translate(-gcx, -gcy); +// grab.paint(g); +// } else { +// Point2D pos = mi.controlPosition; +// g.getGraphics2D().translate(pos.getX(), pos.getY()); +// g.getGraphics2D().translate(-gcx, -gcy); +// hand.paint(g); +// } +// g.dispose(); +// } +// } + + @EventHandler(priority = Integer.MAX_VALUE) + public boolean handleMouseEvent(MouseEvent e) { + if (e instanceof MouseMovedEvent || e instanceof MouseButtonEvent) + setDirty(); + return false; + } +}