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
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 AbstractCursorTool
AbstractCursorTool.Listener -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intMeasure mode area.static final intMeasure mode distance.Fields inherited from class MultiClickTool
mouseLastLocFields inherited from class AbstractCursorTool
isLinuxOS, panel -
Constructor Summary
ConstructorsConstructorDescriptionAdvancedMeasureTool(WorkbenchContext context) Build a new AdvancedMeasureTool instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidActionListener for the JMenuItems.protected voidGesture is finished, now do the work, paint the measurement.Returns the Cursor depending on the measureMode.getIcon()Returns the Icon depending on the measureMode.Returns the popup menu for this tool.Returns the toolbar button for this tool.protected booleanFor the possibility to start a gesture (measurement) with a double click, only finish, if we have more then one click previously done (coordinates > 1).voidClickhandler for the measuretool.voidHandle mouse location changes.Methods inherited from class PolygonTool
checkPolygon, getPolygonMethods inherited from class MultiClickTool
activate, add, cancelGesture, deactivate, finishGesture, getCoordinates, getMetrics, getShape, mouseDragged, mouseMoved, mousePressed, mouseReleased, setCloseRing, setMetricsDisplay, toArrayMethods inherited from class 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 Details
-
MEASURE_MODE_DISTANCE
public static final int MEASURE_MODE_DISTANCEMeasure mode distance.- See Also:
-
MEASURE_MODE_AREA
public static final int MEASURE_MODE_AREAMeasure mode area.- See Also:
-
-
Constructor Details
-
AdvancedMeasureTool
Build a new AdvancedMeasureTool instance.- Parameters:
context- the workbench context
-
-
Method Details
-
getIcon
Returns the Icon depending on the measureMode.- Specified by:
getIconin interfaceCursorTool- Returns:
- null to use a default icon
-
getCursor
Returns the Cursor depending on the measureMode.- Specified by:
getCursorin interfaceCursorTool- Overrides:
getCursorin classAbstractCursorTool- Returns:
- the Cursor
-
mouseLocationChanged
Handle mouse location changes.- Overrides:
mouseLocationChangedin classMultiClickTool- Parameters:
e- a MouseEvent
-
mouseClicked
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
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
Gesture is finished, now do the work, paint the measurement.- Specified by:
gestureFinishedin classAbstractCursorTool- Throws:
NoninvertibleTransformException
-
getPopupMenu
-
getToolbarButton
Returns the toolbar button for this tool.- Returns:
- the toolbarButton
-
actionPerformed
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
-