/* * PointSlopeDragRenderer.java * * Created on February 19, 2004, 11:31 PM */ package org.das2.event; import org.das2.graph.DasCanvasComponent; import org.das2.graph.DasAxis; import org.das2.graph.DasPlot; import org.das2.datum.Units; import org.das2.datum.Datum; import org.das2.datum.DatumUtil; import org.das2.datum.UnitsUtil; import java.awt.*; import java.awt.geom.Ellipse2D; import java.awt.geom.Line2D; import java.awt.geom.Point2D; import java.text.*; /** * Indicate the length and the slope of the line. * @author Owner */ public class LengthDragRenderer extends LabelDragRenderer { private final DasAxis xaxis; private final DasAxis yaxis; private final DasPlot plot; /** Creates a new instance of PointSlopeDragRenderer * @param parent * @param xaxis * @param yaxis */ public LengthDragRenderer(DasCanvasComponent parent, DasAxis xaxis, DasAxis yaxis) { super( parent ); this.plot= (DasPlot)parent; this.xaxis= xaxis; this.yaxis= yaxis; } /** * number of cycles or devisor for length */ int ncycles = 20; @Override public Rectangle[] renderDrag(java.awt.Graphics g1, java.awt.Point p1, java.awt.Point p2) { Graphics2D g= ( Graphics2D ) g1; g.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON ); double atan= Math.atan2( p2.y-p1.y, p2.x-p1.x ); Line2D line= new Line2D.Double( p1.x + (int)(4.0 * Math.cos(atan)), (int)(p1.y + 4.0*Math.sin(atan)), p2.x, p2.y ); Line2D line2= new Line2D.Double( p1.x + (int)(6.0 * Math.cos(atan)), (int)(p1.y + 6.0*Math.sin(atan)), p2.x, p2.y ); Color color0= g.getColor(); g.setColor(new Color(255,255,255,100)); g.setStroke(new BasicStroke( 3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND )); g.draw( line2 ); g.draw( new Ellipse2D.Double( p1.x-4, p1.y-4, 8, 8 ) ); g.setStroke(new BasicStroke()); g.setColor(color0); for ( int i=1; i