Class 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 Detail

      • 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
    • Constructor Detail

      • AbstractResizeHotSpot

        public AbstractResizeHotSpot()
    • 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.
      • mouseMoved

        public void mouseMoved​(java.awt.event.MouseEvent e)
        Update the resize cursor when the mouse moves.
        Specified by:
        mouseMoved in interface HotSpot
        Specified by:
        mouseMoved in interface java.awt.event.MouseMotionListener
        Overrides:
        mouseMoved in class AbstractHotSpot
        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 sets dragRefPoint to null.
      • getCursor

        public java.awt.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.
      • 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.
      • 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).