Package gov.nasa.worldwind.util
Class AbstractResizeHotSpot
- java.lang.Object
-
- gov.nasa.worldwind.avlist.AVListImpl
-
- gov.nasa.worldwind.util.AbstractHotSpot
-
- gov.nasa.worldwind.util.AbstractResizeHotSpot
-
- All Implemented Interfaces:
AVList,SelectListener,HotSpot,java.awt.event.KeyListener,java.awt.event.MouseListener,java.awt.event.MouseMotionListener,java.awt.event.MouseWheelListener,java.util.EventListener
- Direct Known Subclasses:
BalloonResizeController,FrameResizeControl
public abstract class AbstractResizeHotSpot extends AbstractHotSpot
A HotSpot for resizing a frame or window. This class handles the resize input events, but does does not actually draw the resize controls. The HotSpot is defined by a direction, for example,AVKey.NORTHindicates that the HotSpot resizes the frame vertically from the north edge (the user clicks the top edge of the frame and drags vertically).An instance of this class should be added to the picked object when the edge or corner of the frame is picked.
Subclasses must the implement {#getSize}, {#setSize}, {#getScreenPoint}, and {#setScreenPoint} to manipulate the frame that they want to resize.
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanadjustLocationXTrue if the window needs to be moved in the X direction as it is resized.protected booleanadjustLocationYTrue if the window needs to be moved in the Y direction as it is resized.protected booleanallowHorizontalResizeprotected booleanallowVerticalResizeprotected intcursorprotected booleandraggingprotected java.awt.PointdragRefPointprotected static intEASTprotected static intNORTHprotected static intNORTHEASTprotected static intNORTHWESTprotected java.awt.PointrefLocationprotected java.awt.DimensionrefSizeprotected static intSOUTHprotected static intSOUTHEASTprotected static intSOUTHWESTprotected static intWESTprotected intxSignprotected intySign-
Fields inherited from class gov.nasa.worldwind.util.AbstractHotSpot
active
-
-
Constructor Summary
Constructors Constructor Description AbstractResizeHotSpot()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidbeginDrag(java.awt.Point point)voiddrag(java.awt.Point point)protected voidendDrag()Called when a drag action ends.java.awt.CursorgetCursor()Get a cursor for the type of resize that this hotspot handles.protected java.awt.DimensiongetMinimumSize()Get the minimum size of the frame.protected abstract java.awt.PointgetScreenPoint()Get the screen point of the upper left corner of the frame.protected abstract java.awt.DimensiongetSize()Get the size of the frame.booleanisDragging()Is the control currently dragging?protected booleanisValidSize(int width, int height)Is a frame size valid? This method is called before attempting to resize the frame.voidmouseMoved(java.awt.event.MouseEvent e)Update the resize cursor when the mouse moves.voidselected(SelectEvent event)Handle aSelectEventand callbeginDrag(java.awt.Point),drag(java.awt.Point),endDrag()as appropriate.voidsetActive(boolean active)Called when this HotSpot is activated or deactivated.protected voidsetDirection(int direction)protected voidsetDirection(java.lang.String direction)protected voidsetDirectionFromPoint(java.awt.Point pickPoint)Set the resize direction based on which point on the frame was picked (if a point on the left of the frame is picked, the resize direction is west, if a point on the top edge is picked the resize direction is north, etc).protected abstract voidsetScreenPoint(java.awt.Point newPoint)Set the screen point of the upper left corner of the frame.protected abstract voidsetSize(java.awt.Dimension newSize)Set the size of the frame.-
Methods inherited from class gov.nasa.worldwind.util.AbstractHotSpot
isActive, isConsumed, keyPressed, keyReleased, keyTyped, mouseClicked, mouseDragged, mouseEntered, mouseExited, mousePressed, mouseReleased, mouseWheelMoved
-
Methods inherited from class gov.nasa.worldwind.avlist.AVListImpl
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getBooleanValue, getBooleanValue, getChangeSupport, getDoubleValue, getDoubleValue, getEntries, getIntegerValue, getIntegerValue, getLongValue, getLongValue, getRestorableStateForAVPair, getStringValue, getStringValue, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
-
-
-
-
Field Detail
-
NORTH
protected static final int NORTH
- See Also:
- Constant Field Values
-
SOUTH
protected static final int SOUTH
- See Also:
- Constant Field Values
-
EAST
protected static final int EAST
- See Also:
- Constant Field Values
-
WEST
protected static final int WEST
- See Also:
- Constant Field Values
-
NORTHWEST
protected static final int NORTHWEST
- See Also:
- Constant Field Values
-
NORTHEAST
protected static final int NORTHEAST
- See Also:
- Constant Field Values
-
SOUTHWEST
protected static final int SOUTHWEST
- See Also:
- Constant Field Values
-
SOUTHEAST
protected static final int SOUTHEAST
- See Also:
- Constant Field Values
-
dragging
protected boolean dragging
-
dragRefPoint
protected java.awt.Point dragRefPoint
-
refSize
protected java.awt.Dimension refSize
-
refLocation
protected java.awt.Point refLocation
-
allowVerticalResize
protected boolean allowVerticalResize
-
allowHorizontalResize
protected boolean allowHorizontalResize
-
adjustLocationX
protected boolean adjustLocationX
True if the window needs to be moved in the X direction as it is resized. For example, if the upper left corner is being dragged, the window should move to keep that corner under the cursor.
-
adjustLocationY
protected boolean adjustLocationY
True if the window needs to be moved in the Y direction as it is resized.
-
xSign
protected int xSign
-
ySign
protected int ySign
-
cursor
protected int cursor
-
-
Method Detail
-
setDirection
protected void setDirection(java.lang.String direction)
-
setDirection
protected void setDirection(int direction)
-
setDirectionFromPoint
protected void setDirectionFromPoint(java.awt.Point pickPoint)
Set the resize direction based on which point on the frame was picked (if a point on the left of the frame is picked, the resize direction is west, if a point on the top edge is picked the resize direction is north, etc).- Parameters:
pickPoint- The point on the frame that was picked.
-
isDragging
public boolean isDragging()
Is the control currently dragging?- Returns:
- True if the control is dragging.
-
selected
public void selected(SelectEvent event)
Handle aSelectEventand callbeginDrag(java.awt.Point),drag(java.awt.Point),endDrag()as appropriate. Subclasses may override this method if they need to handle events other than drag events.- Specified by:
selectedin interfaceHotSpot- Specified by:
selectedin interfaceSelectListener- Overrides:
selectedin classAbstractHotSpot- Parameters:
event- Select event.
-
mouseMoved
public void mouseMoved(java.awt.event.MouseEvent e)
Update the resize cursor when the mouse moves.- Specified by:
mouseMovedin interfaceHotSpot- Specified by:
mouseMovedin interfacejava.awt.event.MouseMotionListener- Overrides:
mouseMovedin classAbstractHotSpot- Parameters:
e- Mouse event.
-
beginDrag
protected void beginDrag(java.awt.Point point)
-
drag
public void drag(java.awt.Point point)
-
endDrag
protected void endDrag()
Called when a drag action ends. This implementation setsdragRefPointto null.
-
getCursor
public java.awt.Cursor getCursor()
Get a cursor for the type of resize that this hotspot handles.- Specified by:
getCursorin interfaceHotSpot- Overrides:
getCursorin classAbstractHotSpot- Returns:
- New cursor.
-
setActive
public void setActive(boolean active)
Called when this HotSpot is activated or deactivated. The HotSpot only receives input events when it is active. Overridden to reset state when the mouse leaves the resize area.- Specified by:
setActivein interfaceHotSpot- Overrides:
setActivein classAbstractHotSpot- Parameters:
active-trueif the HotSpot is being activated,falseif it is being deactivated.
-
isValidSize
protected boolean isValidSize(int width, int height)Is a frame size valid? This method is called before attempting to resize the frame. If this method returns false, the resize operation is not attempted. This implementation ensures that the proposed frame size is greater than or equal to the minimum frame size.- Parameters:
width- Frame width.height- Frame height.- Returns:
- True if this frame size is valid.
- See Also:
getMinimumSize()
-
getMinimumSize
protected java.awt.Dimension getMinimumSize()
Get the minimum size of the frame. The user is not allowed to resize the frame to be smaller than this size. This implementation returns 0, 0.- Returns:
- Minimum frame size.
- See Also:
isValidSize(int, int)
-
getSize
protected abstract java.awt.Dimension getSize()
Get the size of the frame.- Returns:
- Frame size in pixels.
-
setSize
protected abstract void setSize(java.awt.Dimension newSize)
Set the size of the frame.- Parameters:
newSize- New frame size in pixels.
-
getScreenPoint
protected abstract java.awt.Point getScreenPoint()
Get the screen point of the upper left corner of the frame.- Returns:
- Screen point measured from upper left corner of the screen (AWT coordinates).
-
setScreenPoint
protected abstract void setScreenPoint(java.awt.Point newPoint)
Set the screen point of the upper left corner of the frame.- Parameters:
newPoint- New screen point measured from upper left corner of the screen (AWT coordinates).
-
-