diff options
Diffstat (limited to 'src/GraphEventHandler.java')
| -rw-r--r-- | src/GraphEventHandler.java | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/GraphEventHandler.java b/src/GraphEventHandler.java new file mode 100644 index 0000000..ff56fb9 --- /dev/null +++ b/src/GraphEventHandler.java @@ -0,0 +1,66 @@ +/* */ import java.awt.Point; +/* */ import java.awt.event.MouseEvent; +/* */ import java.awt.event.MouseListener; +/* */ import java.awt.event.MouseMotionListener; +/* */ import java.awt.event.MouseWheelEvent; +/* */ import java.awt.event.MouseWheelListener; +/* */ +/* */ public class GraphEventHandler +/* */ implements MouseListener, MouseMotionListener, MouseWheelListener +/* */ { +/* */ private Point lastClick; +/* */ private Graph2D graph; +/* */ +/* */ public GraphEventHandler(Graph2D target) +/* */ { +/* 19 */ this.graph = target; +/* */ } +/* */ +/* */ public void mouseClicked(MouseEvent e) { +/* 23 */ this.lastClick = e.getPoint(); +/* */ } +/* */ +/* */ public void mouseEntered(MouseEvent e) +/* */ { +/* */ } +/* */ +/* */ public void mouseExited(MouseEvent e) +/* */ { +/* */ } +/* */ +/* */ public void mousePressed(MouseEvent e) +/* */ { +/* 38 */ this.lastClick = e.getPoint(); +/* */ } +/* */ +/* */ public void mouseReleased(MouseEvent e) +/* */ { +/* 44 */ this.lastClick = e.getPoint(); +/* */ } +/* */ +/* */ public void mouseDragged(MouseEvent e) +/* */ { +/* 50 */ Point move = e.getPoint(); +/* */ +/* 52 */ double difx = (move.x - this.lastClick.x) * this.graph.getXRes(); +/* 53 */ double dify = (move.y - this.lastClick.y) * this.graph.getYRes(); +/* 54 */ this.graph.setWindowRange(this.graph.getWindowRange().getTranslatedInstance(difx, dify)); +/* 55 */ this.graph.recreate(); +/* 56 */ this.graph.repaint(); +/* 57 */ this.lastClick = e.getPoint(); +/* */ } +/* */ +/* */ public void mouseMoved(MouseEvent e) +/* */ { +/* */ } +/* */ +/* */ public void mouseWheelMoved(MouseWheelEvent e) +/* */ { +/* 67 */ this.graph.zoom(Math.min(Math.pow(1.2D, e.getWheelRotation()), 1.728D)); +/* */ } +/* */ } + +/* Location: Modulus.jar + * Qualified Name: GraphEventHandler + * JD-Core Version: 0.6.2 + */
\ No newline at end of file |