Package org.openjump.core.ui.plugin.view
Class SuperZoomPanTool
- java.lang.Object
-
- com.vividsolutions.jump.workbench.ui.cursortool.AbstractCursorTool
-
- com.vividsolutions.jump.workbench.ui.cursortool.DragTool
-
- org.openjump.core.ui.plugin.view.SuperZoomPanTool
-
- All Implemented Interfaces:
CursorTool,MouseListener,MouseMotionListener,MouseWheelListener,EventListener
public class SuperZoomPanTool extends DragTool implements MouseWheelListener
This tool have the following functions: - zoom in/out with left/right mouse click - pan with mouse drag - zoom in/out with mousewheel and then left click for zoom or right click for cancel In wheelMode you can see the new area after zooming. Also known as "Area of interest".- 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 CursorCURSOR_PANstatic CursorCURSOR_WHEELstatic CursorCURSOR_ZOOMstatic intINDICATOR_MODE_IMAGEThe visual indicator (area of interest) is painted as an Image.static intINDICATOR_MODE_SHAPEThe visual indicator (area of interest) is painted as a Shape.static doubleWHEEL_ZOOM_FACTORstatic doubleZOOM_IN_FACTOR-
Fields inherited from class com.vividsolutions.jump.workbench.ui.cursortool.DragTool
DEFAULT_VIEW_CLICK_BUFFER, modelDestination, modelSource
-
Fields inherited from class com.vividsolutions.jump.workbench.ui.cursortool.AbstractCursorTool
isLinuxOS, panel
-
-
Constructor Summary
Constructors Constructor Description SuperZoomPanTool(WorkbenchContext context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactivate(LayerViewPanel layerViewPanel)voidcacheImage()ImagecreateImageIfNeeded(Image currImage)Creates a new Image if currImage doesn't exist or is the wrong size for the panel.voiddeactivate()protected voidgestureFinished()booleangetAnimatingZoom()CursorgetCursor()IcongetIcon()protected ImagegetImage()This method have to return an Image as a visual indicator.protected PointgetImagePosition()This method have to return the position for the Image.intgetIndicatorMode()StringgetName()Returns a very brief description of this CursorTool.protected ShapegetShape()protected ShapegetShape(Point2D source, Point2D destination)booleanisRightMouseButtonUsed()voidmouseClicked(MouseEvent e)voidmouseDragged(MouseEvent e)voidmouseMoved(MouseEvent e)voidmousePressed(MouseEvent e)Begins handling of the drag.voidmouseReleased(MouseEvent e)voidmouseWheelMoved(MouseWheelEvent e)voidredrawIndicator()Redraws the visual indicator.booleansetAnimatingZoom(boolean animating)voidsetIndicatorMode(int indicatorMode)Sets the indicatorMode.protected voidzoomAt(Point2D p, double zoomFactor, boolean animatingZoom)-
Methods inherited from class com.vividsolutions.jump.workbench.ui.cursortool.DragTool
getBoxInModelCoordinates, getModelDestination, getModelSource, getViewDestination, getViewSource, modelClickBuffer, setModelDestination, setModelSource, setViewClickBuffer, setViewDestination, setViewSource, wasClick
-
Methods inherited from class com.vividsolutions.jump.workbench.ui.cursortool.AbstractCursorTool
add, allowSnapping, cancelGesture, check, cleanup, clearImage, clearShape, componentWithFocusIsHandledByCursorTools, createCursor, createCursor, createCursor, createStandardSnappingPolicies, drawImageXOR, drawImageXOR, drawShapeXOR, drawShapeXOR, execute, execute, fireGestureFinished, getColor, getPanel, getPanel, getSnapManager, getStroke, getTaskFrame, getWorkbench, getWorkbenchContext, isGestureInProgress, isRollingBackInvalidEdits, isShapeOnScreen, mouseEntered, mouseExited, name, prohibitSnapping, redrawImage, redrawShape, reportNothingToUndoYet, setColor, setControlPressed, setFilling, setPanel, setShiftPressed, setStroke, setup, snap, snap, supportsSnapping, toString, wasControlPressed, wasShiftPressed
-
-
-
-
Field Detail
-
WHEEL_ZOOM_FACTOR
public static final double WHEEL_ZOOM_FACTOR
- See Also:
- Constant Field Values
-
ZOOM_IN_FACTOR
public static final double ZOOM_IN_FACTOR
- See Also:
- Constant Field Values
-
CURSOR_ZOOM
public static Cursor CURSOR_ZOOM
-
CURSOR_PAN
public static Cursor CURSOR_PAN
-
CURSOR_WHEEL
public static Cursor CURSOR_WHEEL
-
INDICATOR_MODE_SHAPE
public static final int INDICATOR_MODE_SHAPE
The visual indicator (area of interest) is painted as a Shape.- See Also:
- Constant Field Values
-
INDICATOR_MODE_IMAGE
public static final int INDICATOR_MODE_IMAGE
The visual indicator (area of interest) is painted as an Image.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SuperZoomPanTool
public SuperZoomPanTool(WorkbenchContext context)
-
-
Method Detail
-
activate
public void activate(LayerViewPanel layerViewPanel)
- Specified by:
activatein interfaceCursorTool- Overrides:
activatein classAbstractCursorTool
-
deactivate
public void deactivate()
- Specified by:
deactivatein interfaceCursorTool- Overrides:
deactivatein classDragTool
-
mouseWheelMoved
public void mouseWheelMoved(MouseWheelEvent e)
- Specified by:
mouseWheelMovedin interfaceMouseWheelListener
-
getImage
protected Image getImage()
Description copied from class:AbstractCursorToolThis method have to return an Image as a visual indicator. Usually this method should to be abstract. But if we do this here, many other derived classes have to implement this method. Thereby we would break the compatibility for many other classes in OJ and 3rd party plugins.- Overrides:
getImagein classAbstractCursorTool- Returns:
- a Image or null if nothing should be drawn.
-
getImagePosition
protected Point getImagePosition()
Description copied from class:AbstractCursorToolThis method have to return the position for the Image. The position is the top left corner of the image for the Graphics2D.drawImage() method. This method is called after theAbstractCursorTool.getImage()method. For the abstract problematic please seeAbstractCursorTool.getImage().- Overrides:
getImagePositionin classAbstractCursorTool- Returns:
- the position for the Image
-
mouseMoved
public void mouseMoved(MouseEvent e)
- Specified by:
mouseMovedin interfaceMouseMotionListener- Overrides:
mouseMovedin classAbstractCursorTool
-
mouseClicked
public void mouseClicked(MouseEvent e)
- Specified by:
mouseClickedin interfaceMouseListener- Overrides:
mouseClickedin classAbstractCursorTool
-
mousePressed
public void mousePressed(MouseEvent e)
Description copied from class:DragToolBegins handling of the drag. Subclasses can prevent handling of the drag by overriding this method and not calling it.- Specified by:
mousePressedin interfaceMouseListener- Overrides:
mousePressedin classDragTool
-
isRightMouseButtonUsed
public boolean isRightMouseButtonUsed()
- Specified by:
isRightMouseButtonUsedin interfaceCursorTool- Overrides:
isRightMouseButtonUsedin classAbstractCursorTool- Returns:
- true if this CursorTool uses the right mouse button; false to allow the panel to show a popup-menu on right-clicks
-
getCursor
public Cursor getCursor()
- Specified by:
getCursorin interfaceCursorTool- Overrides:
getCursorin classAbstractCursorTool
-
getIcon
public Icon getIcon()
- Specified by:
getIconin interfaceCursorTool- Returns:
- null to use a default icon
-
getName
public String getName()
Description copied from interface:CursorToolReturns a very brief description of this CursorTool.- Specified by:
getNamein interfaceCursorTool- Overrides:
getNamein classAbstractCursorTool- Returns:
- the name of this CursorTool
-
mouseDragged
public void mouseDragged(MouseEvent e)
- Specified by:
mouseDraggedin interfaceMouseMotionListener- Overrides:
mouseDraggedin classDragTool
-
mouseReleased
public void mouseReleased(MouseEvent e)
- Specified by:
mouseReleasedin interfaceMouseListener- Overrides:
mouseReleasedin classDragTool
-
gestureFinished
protected void gestureFinished() throws NoninvertibleTransformException- Specified by:
gestureFinishedin classAbstractCursorTool- Throws:
NoninvertibleTransformException
-
createImageIfNeeded
public Image createImageIfNeeded(Image currImage)
Creates a new Image if currImage doesn't exist or is the wrong size for the panel.- Parameters:
currImage- an image buffer- Returns:
- a new image, or the existing one if it's compatible
-
cacheImage
public void cacheImage()
-
setAnimatingZoom
public boolean setAnimatingZoom(boolean animating)
-
getAnimatingZoom
public boolean getAnimatingZoom()
-
zoomAt
protected void zoomAt(Point2D p, double zoomFactor, boolean animatingZoom) throws NoninvertibleTransformException
- Throws:
NoninvertibleTransformException
-
redrawIndicator
public void redrawIndicator()
Redraws the visual indicator. This can be a Shape or an Image. It depends of the indicatorMode value.
-
getIndicatorMode
public int getIndicatorMode()
- Returns:
- the indicatorMode
-
setIndicatorMode
public void setIndicatorMode(int indicatorMode)
Sets the indicatorMode. Valid values areINDICATOR_MODE_SHAPE,INDICATOR_MODE_IMAGE.- Parameters:
indicatorMode- the indicatorMode to set
-
-