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.NORTH
indicates 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 boolean
adjustLocationX
True if the window needs to be moved in the X direction as it is resized.protected boolean
adjustLocationY
True if the window needs to be moved in the Y direction as it is resized.protected boolean
allowHorizontalResize
protected boolean
allowVerticalResize
protected int
cursor
protected boolean
dragging
protected java.awt.Point
dragRefPoint
protected static int
EAST
protected static int
NORTH
protected static int
NORTHEAST
protected static int
NORTHWEST
protected java.awt.Point
refLocation
protected java.awt.Dimension
refSize
protected static int
SOUTH
protected static int
SOUTHEAST
protected static int
SOUTHWEST
protected static int
WEST
protected int
xSign
protected int
ySign
-
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 void
beginDrag(java.awt.Point point)
void
drag(java.awt.Point point)
protected void
endDrag()
Called when a drag action ends.java.awt.Cursor
getCursor()
Get a cursor for the type of resize that this hotspot handles.protected java.awt.Dimension
getMinimumSize()
Get the minimum size of the frame.protected abstract java.awt.Point
getScreenPoint()
Get the screen point of the upper left corner of the frame.protected abstract java.awt.Dimension
getSize()
Get the size of the frame.boolean
isDragging()
Is the control currently dragging?protected boolean
isValidSize(int width, int height)
Is a frame size valid? This method is called before attempting to resize the frame.void
mouseMoved(java.awt.event.MouseEvent e)
Update the resize cursor when the mouse moves.void
selected(SelectEvent event)
Handle aSelectEvent
and callbeginDrag(java.awt.Point)
,drag(java.awt.Point)
,endDrag()
as appropriate.void
setActive(boolean active)
Called when this HotSpot is activated or deactivated.protected void
setDirection(int direction)
protected void
setDirection(java.lang.String direction)
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).protected abstract void
setScreenPoint(java.awt.Point newPoint)
Set the screen point of the upper left corner of the frame.protected abstract void
setSize(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 aSelectEvent
and 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:
selected
in interfaceHotSpot
- Specified by:
selected
in interfaceSelectListener
- Overrides:
selected
in classAbstractHotSpot
- Parameters:
event
- Select event.
-
mouseMoved
public void mouseMoved(java.awt.event.MouseEvent e)
Update the resize cursor when the mouse moves.- Specified by:
mouseMoved
in interfaceHotSpot
- Specified by:
mouseMoved
in interfacejava.awt.event.MouseMotionListener
- Overrides:
mouseMoved
in 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 setsdragRefPoint
to null.
-
getCursor
public java.awt.Cursor getCursor()
Get a cursor for the type of resize that this hotspot handles.- Specified by:
getCursor
in interfaceHotSpot
- Overrides:
getCursor
in 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:
setActive
in interfaceHotSpot
- Overrides:
setActive
in classAbstractHotSpot
- Parameters:
active
-true
if the HotSpot is being activated,false
if 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).
-
-