/* File: GesturesRenderer.java * Copyright (C) 2002-2003 The University of Iowa * Created by: Jeremy Faden * Jessica Swanner * Edward E. West * * This file is part of the das2 library. * * das2 is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package org.das2.event; import org.das2.graph.DasCanvasComponent; import java.awt.*; /** * * @author jbf */ public class GesturesRenderer implements DragRenderer { DasCanvasComponent parent; Rectangle dirtyBounds; /** Creates a new instance of GesturesRenderer */ public GesturesRenderer(DasCanvasComponent parent) { this.parent= parent; dirtyBounds= new Rectangle(); } public MouseDragEvent getMouseDragEvent(Object source, Point p1, Point p2, boolean isModified) { Gesture g=null; double dx= p2.x-p1.x; double dy= -1* ( p2.y-p1.y ); double angle= Math.atan2(dy, dx) * 180 / Math.PI; double radius= Math.sqrt(dy*dy+dx*dx); int width= ((Component)source).getWidth(); int xOffset= ((Component)source).getLocation().x; if ( radius<20 && radius>4) { if ( (p1.x-xOffset<10) && (p1.x-xOffset)>=0 && (p2.x-xOffset)<0 ) { g= Gesture.SCANPREV; } else if ((p1.x-xOffset)>(width-10) && (p1.x-xOffset)=width ) { g= Gesture.SCANNEXT; } else if (Math.abs(angle)>160) { g= Gesture.BACK; } else if (-1104) { Color color0= g.getColor(); for (int i=0; i<2; i++) { if (i==0) { g.setColor(new Color(255,255,255,100)); g.setStroke(new BasicStroke( 3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND )); } else { g.setColor(color0); g.setStroke(new BasicStroke()); } if (Math.abs(angle)>160) { g.drawLine(p1.x,p1.y,p1.x-5,p1.y); g.drawLine(p1.x-5,p1.y,p1.x-3,p1.y-2); g.drawLine(p1.x-5,p1.y,p1.x-3,p1.y+2); } else if (-110