package jas.hist; import jas.plot.CoordinateTransformation; import jas.plot.DateCoordinateTransformation; import jas.plot.DoubleCoordinateTransformation; import jas.plot.Overlay; import jas.plot.OverlayContainer; import jas.plot.PlotGraphics; import jas.plot.PrintHelper; import java.awt.Color; import java.awt.Cursor; import java.awt.Point; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; public abstract class OverlayWithHandles implements Overlay, MouseListener, MouseMotionListener { private Cursor defaultCursor = null; private static MouseEvent mouseEvent = null; private static boolean changeCursor; private boolean handlesPainted = false; protected OverlayWithHandles(DataSource ds) { if (ds instanceof HasHandles) { hasHandles = (HasHandles) ds; } } public void paint(PlotGraphics g) { if (handles != null && !PrintHelper.isPrinting()) { CoordinateTransformation xt = container.getXTransformation(); CoordinateTransformation yt = container.getYTransformation(); g.clearTransformation(); for (int i=0; i= x && p.x <= x+2*handleSize && p.y >= y && p.y > y && p.y <= y+2*handleSize); } void moveTo(Point p) { CoordinateTransformation xt = (CoordinateTransformation) container.getXTransformation(); CoordinateTransformation yt = (CoordinateTransformation) container.getYTransformation(); DoubleCoordinateTransformation xp; DoubleCoordinateTransformation yp; if ( xt instanceof DateCoordinateTransformation ) xp = new DateTransformationConverter( (DateCoordinateTransformation) xt ); else xp = (DoubleCoordinateTransformation) xt; if ( yt instanceof DateCoordinateTransformation ) yp = new DateTransformationConverter( (DateCoordinateTransformation) yt ); else yp = (DoubleCoordinateTransformation) yt; handle.moveTo(xp.unConvert(p.x),yp.unConvert(p.y)); } Cursor cursor() { return handle.cursor(); } private Handle handle; } private static final double handleSize = 2.5; private HandleWrapper[] handles = null; private HandleWrapper currentHandle = null; private HandleWrapper capturedHandle = null; private HasHandles hasHandles; protected OverlayContainer container; }