NASA World Wind

gov.nasa.worldwind.util
Class AbstractResizeHotSpot

java.lang.Object
  extended by gov.nasa.worldwind.avlist.AVListImpl
      extended by gov.nasa.worldwind.util.AbstractHotSpot
          extended by gov.nasa.worldwind.util.AbstractResizeHotSpot
All Implemented Interfaces:
AVList, SelectListener, HotSpot, KeyListener, MouseListener, MouseMotionListener, MouseWheelListener, 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
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  Point dragRefPoint
           
protected static int EAST
           
protected static int NORTH
           
protected static int NORTHEAST
           
protected static int NORTHWEST
           
protected  Point refLocation
           
protected  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
AbstractResizeHotSpot()
           
 
Method Summary
protected  void beginDrag(Point point)
           
 void drag(Point point)
           
protected  void endDrag()
          Called when a drag action ends.
 Cursor getCursor()
          Get a cursor for the type of resize that this hotspot handles.
protected  Dimension getMinimumSize()
          Get the minimum size of the frame.
protected abstract  Point getScreenPoint()
          Get the screen point of the upper left corner of the frame.
protected abstract  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(MouseEvent e)
          Update the resize cursor when the mouse moves.
 void selected(SelectEvent event)
          Handle a SelectEvent and call beginDrag(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(String direction)
           
protected  void setDirectionFromPoint(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(Point newPoint)
          Set the screen point of the upper left corner of the frame.
protected abstract  void setSize(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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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.


allowHorizontalResize

protected boolean allowHorizontalResize

allowVerticalResize

protected boolean allowVerticalResize

cursor

protected int cursor

dragging

protected boolean dragging

dragRefPoint

protected Point dragRefPoint

EAST

protected static final int EAST
See Also:
Constant Field Values

NORTH

protected static final int NORTH
See Also:
Constant Field Values

NORTHEAST

protected static final int NORTHEAST
See Also:
Constant Field Values

NORTHWEST

protected static final int NORTHWEST
See Also:
Constant Field Values

refLocation

protected Point refLocation

refSize

protected Dimension refSize

SOUTH

protected static final int SOUTH
See Also:
Constant Field Values

SOUTHEAST

protected static final int SOUTHEAST
See Also:
Constant Field Values

SOUTHWEST

protected static final int SOUTHWEST
See Also:
Constant Field Values

WEST

protected static final int WEST
See Also:
Constant Field Values

xSign

protected int xSign

ySign

protected int ySign
Constructor Detail

AbstractResizeHotSpot

public AbstractResizeHotSpot()
Method Detail

beginDrag

protected void beginDrag(Point point)

drag

public void drag(Point point)

endDrag

protected void endDrag()
Called when a drag action ends. This implementation sets dragRefPoint to null.


getCursor

public Cursor getCursor()
Get a cursor for the type of resize that this hotspot handles.

Specified by:
getCursor in interface HotSpot
Overrides:
getCursor in class AbstractHotSpot
Returns:
New cursor.

getMinimumSize

protected 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)

getScreenPoint

protected abstract 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).

getSize

protected abstract Dimension getSize()
Get the size of the frame.

Returns:
Frame size in pixels.

isDragging

public boolean isDragging()
Is the control currently dragging?

Returns:
True if the control is dragging.

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()

mouseMoved

public void mouseMoved(MouseEvent e)
Update the resize cursor when the mouse moves.

Specified by:
mouseMoved in interface HotSpot
Specified by:
mouseMoved in interface MouseMotionListener
Overrides:
mouseMoved in class AbstractHotSpot
Parameters:
e - Mouse event.

selected

public void selected(SelectEvent event)
Handle a SelectEvent and call beginDrag(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 interface SelectListener
Specified by:
selected in interface HotSpot
Overrides:
selected in class AbstractHotSpot
Parameters:
event - Select event.

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 interface HotSpot
Overrides:
setActive in class AbstractHotSpot
Parameters:
active - true if the HotSpot is being activated, false if it is being deactivated.

setDirection

protected void setDirection(int direction)

setDirection

protected void setDirection(String direction)

setDirectionFromPoint

protected void setDirectionFromPoint(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.

setScreenPoint

protected abstract void setScreenPoint(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).

setSize

protected abstract void setSize(Dimension newSize)
Set the size of the frame.

Parameters:
newSize - New frame size in pixels.

NASA World Wind