Class AdvancedMeasureTool
- java.lang.Object
-
- com.vividsolutions.jump.workbench.ui.cursortool.AbstractCursorTool
-
- com.vividsolutions.jump.workbench.ui.cursortool.MultiClickTool
-
- com.vividsolutions.jump.workbench.ui.cursortool.PolygonTool
-
- org.openjump.core.ui.plugin.tools.AdvancedMeasureTool
-
- All Implemented Interfaces:
CursorTool,ActionListener,MouseListener,MouseMotionListener,EventListener
public class AdvancedMeasureTool extends PolygonTool implements ActionListener
A tool for measurment of distance or area.- Version:
- 0.1
- Author:
- Matthias Scholz <ms@jammerhund.de>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.vividsolutions.jump.workbench.ui.cursortool.AbstractCursorTool
AbstractCursorTool.Listener
-
-
Field Summary
Fields Modifier and Type Field Description static intMEASURE_MODE_AREAMeasure mode area.static intMEASURE_MODE_DISTANCEMeasure mode distance.-
Fields inherited from class com.vividsolutions.jump.workbench.ui.cursortool.MultiClickTool
mouseLastLoc
-
Fields inherited from class com.vividsolutions.jump.workbench.ui.cursortool.AbstractCursorTool
isLinuxOS, panel
-
-
Constructor Summary
Constructors Constructor Description AdvancedMeasureTool(WorkbenchContext context)Build a new AdvancedMeasureTool instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactionPerformed(ActionEvent e)ActionListener for the JMenuItems.protected voidgestureFinished()Gesture is finished, now do the work, paint the measurement.CursorgetCursor()Returns the Cursor depending on the measureMode.IcongetIcon()Returns the Icon depending on the measureMode.JPopupMenugetPopupMenu()Returns the popup menu for this tool.JToggleButtongetToolbarButton()Returns the toolbar button for this tool.protected booleanisFinishingRelease(MouseEvent e)For the possibility to start a gesture (measurement) with a double click, only finish, if we have more then one click previously done (coordinates > 1).voidmouseClicked(MouseEvent e)Clickhandler for the measuretool.voidmouseLocationChanged(MouseEvent e)Handle mouse location changes.-
Methods inherited from class com.vividsolutions.jump.workbench.ui.cursortool.PolygonTool
checkPolygon, getPolygon
-
Methods inherited from class com.vividsolutions.jump.workbench.ui.cursortool.MultiClickTool
activate, add, cancelGesture, deactivate, finishGesture, getCoordinates, getMetrics, getShape, mouseDragged, mouseMoved, mousePressed, mouseReleased, setCloseRing, setMetricsDisplay, toArray
-
Methods inherited from class com.vividsolutions.jump.workbench.ui.cursortool.AbstractCursorTool
add, allowSnapping, check, cleanup, clearImage, clearShape, componentWithFocusIsHandledByCursorTools, createCursor, createCursor, createCursor, createStandardSnappingPolicies, drawImageXOR, drawImageXOR, drawShapeXOR, drawShapeXOR, execute, execute, fireGestureFinished, getColor, getImage, getImagePosition, getName, getPanel, getPanel, getSnapManager, getStroke, getTaskFrame, getWorkbench, getWorkbenchContext, isGestureInProgress, isRightMouseButtonUsed, isRollingBackInvalidEdits, isShapeOnScreen, mouseEntered, mouseExited, name, prohibitSnapping, redrawImage, redrawShape, reportNothingToUndoYet, setColor, setControlPressed, setFilling, setPanel, setShiftPressed, setStroke, setup, snap, snap, supportsSnapping, toString, wasControlPressed, wasShiftPressed
-
-
-
-
Field Detail
-
MEASURE_MODE_DISTANCE
public static final int MEASURE_MODE_DISTANCE
Measure mode distance.- See Also:
- Constant Field Values
-
MEASURE_MODE_AREA
public static final int MEASURE_MODE_AREA
Measure mode area.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AdvancedMeasureTool
public AdvancedMeasureTool(WorkbenchContext context)
Build a new AdvancedMeasureTool instance.- Parameters:
context- the workbench context
-
-
Method Detail
-
getIcon
public Icon getIcon()
Returns the Icon depending on the measureMode.- Specified by:
getIconin interfaceCursorTool- Returns:
- null to use a default icon
-
getCursor
public Cursor getCursor()
Returns the Cursor depending on the measureMode.- Specified by:
getCursorin interfaceCursorTool- Overrides:
getCursorin classAbstractCursorTool- Returns:
- the Cursor
-
mouseLocationChanged
public void mouseLocationChanged(MouseEvent e)
Handle mouse location changes.- Overrides:
mouseLocationChangedin classMultiClickTool- Parameters:
e- a MouseEvent
-
mouseClicked
public void mouseClicked(MouseEvent e)
Clickhandler for the measuretool. If the user starts a new measure with a sinle click, then all old mesurements (features on the mesure layer) will be deleted. But if the user starts with a double click, then this measuremt will be added! Because of the event behaviour during a double click, this code is a little bit tricky. During a double click you get first a single click (getClickCount()=1) and after them the double click (getClickCount()=2). So we must check after the first click if later comes the double click. This is done by a Timer. The maximum time to detect a double click we can get through the desktop property "awt.multiClickInterval". Second is the overridden method MultiClickTool.isFinishingRelease() important.- Specified by:
mouseClickedin interfaceMouseListener- Overrides:
mouseClickedin classAbstractCursorTool- Parameters:
e- a MouseEvent
-
isFinishingRelease
protected boolean isFinishingRelease(MouseEvent e)
For the possibility to start a gesture (measurement) with a double click, only finish, if we have more then one click previously done (coordinates > 1). See mouseClicked() method.- Overrides:
isFinishingReleasein classMultiClickTool- Parameters:
e- a MouseEvent- Returns:
- true if double clicked and more the one click
-
gestureFinished
protected void gestureFinished() throws NoninvertibleTransformExceptionGesture is finished, now do the work, paint the measurement.- Specified by:
gestureFinishedin classAbstractCursorTool- Throws:
NoninvertibleTransformException
-
getPopupMenu
public JPopupMenu getPopupMenu()
Returns the popup menu for this tool.- Returns:
- the popup menu
-
getToolbarButton
public JToggleButton getToolbarButton()
Returns the toolbar button for this tool.- Returns:
- the toolbarButton
-
actionPerformed
public void actionPerformed(ActionEvent e)
ActionListener for the JMenuItems. We must set the Icon, the TooltipText, Cursor and the CloseRing Mode. Second the tool will be activated through a JMenuItem ActionEvent. So you do not need a second click ;-)- Specified by:
actionPerformedin interfaceActionListener- Parameters:
e- an ActionEvent
-
-