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:
LayerListener, LayerMotionListener, Interactor, EventListener

public class MeasureBand
extends DragInteractor

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

Version:
$Revision: 1.9 $
Author:
Allan Brighton

Field Summary
protected  MouseFilter dragFilter
          Used to filter mouse events
protected  EventLayer eventLayer
           
protected  FigureLayer figureLayer
           
protected  DivaGraphicsImageDisplay imageDisplay
          The image display that we are drawing on
protected  CompositeFigure mband
           
protected  BasicFigure mbandAngle
          Angle lines (horizontal and vertical)
protected  BasicFigure mbandDiagRect
          box around diagonal label
protected  LabelFigure mbandDiagText
          The diagonal label
protected  BasicFigure mbandHeightRect
          box around height label
protected  LabelFigure mbandHeightText
          The height label
protected  BasicFigure mbandLine
          Diagonal line with arrows
protected  BasicFigure mbandWidthRect
          box around width label
protected  LabelFigure mbandWidthText
          The width label
protected  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
 String formatHM(double val)
           
protected  Rectangle2D getBoundsWithPadding(LabelFigure fig)
          Return the bounds of the given label with padding
 EventLayer getEventLayer()
          Get the layer that drag events are listened on
 FigureLayer getFigureLayer()
          Get the layer that figures are selected on
static void main(String[] args)
          test main: usage: java GraphicsImageDisplay .
 void mouseDragged(LayerEvent event)
          Reshape the rubber-band, swapping coordinates if necessary.
 void mousePressed(LayerEvent event)
          Clear the selection, and create the rubber-band
 void mouseReleased(LayerEvent event)
          Delete the rubber-band
 void setEnabled(boolean enabled)
          Set the enabled state.
 void setEventLayer(EventLayer l)
          Set the layer that drag events are listened on
 void setFigureLayer(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 FigureLayer figureLayer

eventLayer

protected EventLayer eventLayer

mband

protected CompositeFigure mband

mbandLine

protected BasicFigure mbandLine
Diagonal line with arrows


mbandAngle

protected BasicFigure mbandAngle
Angle lines (horizontal and vertical)


mbandWidthRect

protected BasicFigure mbandWidthRect
box around width label


mbandHeightRect

protected BasicFigure mbandHeightRect
box around height label


mbandDiagRect

protected BasicFigure mbandDiagRect
box around diagonal label


mbandWidthText

protected LabelFigure mbandWidthText
The width label


mbandHeightText

protected LabelFigure mbandHeightText
The height label


mbandDiagText

protected LabelFigure mbandDiagText
The diagonal label


originX

protected double originX

originY

protected double originY

dragFilter

protected MouseFilter dragFilter
Used to filter mouse events


nf

protected 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 FigureLayer getFigureLayer()
Get the layer that figures are selected on


getEventLayer

public EventLayer getEventLayer()
Get the layer that drag events are listened on


setFigureLayer

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


setEventLayer

public void setEventLayer(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 Interactor
Overrides:
setEnabled in class AbstractInteractor

mousePressed

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

Specified by:
mousePressed in interface LayerListener
Overrides:
mousePressed in class DragInteractor

mouseDragged

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

Specified by:
mouseDragged in interface LayerListener
Overrides:
mouseDragged in class DragInteractor

mouseReleased

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

Specified by:
mouseReleased in interface LayerListener
Overrides:
mouseReleased in class DragInteractor

formatHM

public 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 Rectangle2D getBoundsWithPadding(LabelFigure fig)
Return the bounds of the given label with padding


main

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



Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.