jsky.image.graphics
Class MeasureBand

java.lang.Object
  extended by diva.canvas.interactor.AbstractInteractor
      extended by diva.canvas.interactor.DragInteractor
          extended by jsky.image.graphics.MeasureBand
All Implemented Interfaces:
diva.canvas.event.LayerListener, diva.canvas.event.LayerMotionListener, diva.canvas.interactor.Interactor, java.util.EventListener

public class MeasureBand
extends diva.canvas.interactor.DragInteractor

Class to display a "measure band" showing the distance between 2 points in world coordinates.

Version:
$Revision: 1.1 $
Author:
Allan Brighton

Field Summary
protected  diva.canvas.event.MouseFilter dragFilter
          Used to filter mouse events
protected  diva.canvas.event.EventLayer eventLayer
           
protected  diva.canvas.FigureLayer figureLayer
           
protected  DivaGraphicsImageDisplay imageDisplay
          The image display that we are drawing on
protected  diva.canvas.CompositeFigure mband
           
protected  diva.canvas.toolbox.BasicFigure mbandAngle
          Angle lines (horizontal and vertical)
protected  diva.canvas.toolbox.BasicFigure mbandDiagRect
          box around diagonal label
protected  diva.canvas.toolbox.LabelFigure mbandDiagText
          The diagonal label
protected  diva.canvas.toolbox.BasicFigure mbandHeightRect
          box around height label
protected  diva.canvas.toolbox.LabelFigure mbandHeightText
          The height label
protected  diva.canvas.toolbox.BasicFigure mbandLine
          Diagonal line with arrows
protected  diva.canvas.toolbox.BasicFigure mbandWidthRect
          box around width label
protected  diva.canvas.toolbox.LabelFigure mbandWidthText
          The width label
protected  java.text.NumberFormat nf
          Used to format values as strings.
protected  double originX
           
protected  double originY
           
 
Constructor Summary
MeasureBand(DivaGraphicsImageDisplay imageDisplay)
          Create a new MeasureBand attached to the given graphics pane.
 
Method Summary
 java.lang.String formatHM(double val)
           
protected  java.awt.geom.Rectangle2D getBoundsWithPadding(diva.canvas.toolbox.LabelFigure fig)
          Return the bounds of the given label with padding
 diva.canvas.event.EventLayer getEventLayer()
          Get the layer that drag events are listened on
 diva.canvas.FigureLayer getFigureLayer()
          Get the layer that figures are selected on
static void main(java.lang.String[] args)
          test main: usage: java GraphicsImageDisplay .
 void mouseDragged(diva.canvas.event.LayerEvent event)
          Reshape the rubber-band, swapping coordinates if necessary.
 void mousePressed(diva.canvas.event.LayerEvent event)
          Clear the selection, and create the rubber-band
 void mouseReleased(diva.canvas.event.LayerEvent event)
          Delete the rubber-band
 void setEnabled(boolean enabled)
          Set the enabled state.
 void setEventLayer(diva.canvas.event.EventLayer l)
          Set the layer that drag events are listened on
 void setFigureLayer(diva.canvas.FigureLayer l)
          Set the layer that figures are selected on
protected  void updateMBand(double x0, double y0, double x1, double y1, boolean showAngle)
          Update the measure band.
 
Methods inherited from class diva.canvas.interactor.DragInteractor
addLayerListener, appendConstraint, constrainPoint, fireLayerEvent, getSelectiveEnabled, getTargetArray, getX, getY, prependConstraint, removeLayerListener, setSelectiveEnabled, setTargetArray, setup, targets, translate
 
Methods inherited from class diva.canvas.interactor.AbstractInteractor
accept, getMouseFilter, isConsuming, isEnabled, isMotionEnabled, mouseClicked, mouseEntered, mouseExited, mouseMoved, setConsuming, setMotionEnabled, setMouseFilter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

imageDisplay

protected DivaGraphicsImageDisplay imageDisplay
The image display that we are drawing on


figureLayer

protected diva.canvas.FigureLayer figureLayer

eventLayer

protected diva.canvas.event.EventLayer eventLayer

mband

protected diva.canvas.CompositeFigure mband

mbandLine

protected diva.canvas.toolbox.BasicFigure mbandLine
Diagonal line with arrows


mbandAngle

protected diva.canvas.toolbox.BasicFigure mbandAngle
Angle lines (horizontal and vertical)


mbandWidthRect

protected diva.canvas.toolbox.BasicFigure mbandWidthRect
box around width label


mbandHeightRect

protected diva.canvas.toolbox.BasicFigure mbandHeightRect
box around height label


mbandDiagRect

protected diva.canvas.toolbox.BasicFigure mbandDiagRect
box around diagonal label


mbandWidthText

protected diva.canvas.toolbox.LabelFigure mbandWidthText
The width label


mbandHeightText

protected diva.canvas.toolbox.LabelFigure mbandHeightText
The height label


mbandDiagText

protected diva.canvas.toolbox.LabelFigure mbandDiagText
The diagonal label


originX

protected double originX

originY

protected double originY

dragFilter

protected diva.canvas.event.MouseFilter dragFilter
Used to filter mouse events


nf

protected java.text.NumberFormat nf
Used to format values as strings.

Constructor Detail

MeasureBand

public MeasureBand(DivaGraphicsImageDisplay imageDisplay)
Create a new MeasureBand attached to the given graphics pane.

Method Detail

getFigureLayer

public diva.canvas.FigureLayer getFigureLayer()
Get the layer that figures are selected on


getEventLayer

public diva.canvas.event.EventLayer getEventLayer()
Get the layer that drag events are listened on


setFigureLayer

public void setFigureLayer(diva.canvas.FigureLayer l)
Set the layer that figures are selected on


setEventLayer

public void setEventLayer(diva.canvas.event.EventLayer l)
Set the layer that drag events are listened on


setEnabled

public void setEnabled(boolean enabled)
Set the enabled state.

Specified by:
setEnabled in interface diva.canvas.interactor.Interactor
Overrides:
setEnabled in class diva.canvas.interactor.AbstractInteractor

mousePressed

public void mousePressed(diva.canvas.event.LayerEvent event)
Clear the selection, and create the rubber-band

Specified by:
mousePressed in interface diva.canvas.event.LayerListener
Overrides:
mousePressed in class diva.canvas.interactor.DragInteractor

mouseDragged

public void mouseDragged(diva.canvas.event.LayerEvent event)
Reshape the rubber-band, swapping coordinates if necessary.

Specified by:
mouseDragged in interface diva.canvas.event.LayerListener
Overrides:
mouseDragged in class diva.canvas.interactor.DragInteractor

mouseReleased

public void mouseReleased(diva.canvas.event.LayerEvent event)
Delete the rubber-band

Specified by:
mouseReleased in interface diva.canvas.event.LayerListener
Overrides:
mouseReleased in class diva.canvas.interactor.DragInteractor

formatHM

public java.lang.String formatHM(double val)

updateMBand

protected void updateMBand(double x0,
                           double y0,
                           double x1,
                           double y1,
                           boolean showAngle)
Update the measure band.

Parameters:
x0 - the X screen coordinate of the starting point of the drag
y0 - the Y screen coordinate of the starting point of the drag
x1 - the X screen coordinate of the mouse pointer
y1 - the Y screen coordinate of the mouse pointer
showAngle - if true, show the mbandAngle item, otherwise only the diagonal line.

getBoundsWithPadding

protected java.awt.geom.Rectangle2D getBoundsWithPadding(diva.canvas.toolbox.LabelFigure fig)
Return the bounds of the given label with padding


main

public static void main(java.lang.String[] args)
test main: usage: java GraphicsImageDisplay .