Sharkysoft home

lava.gui
Class DragSprite

java.lang.Object
  |
  +--lava.gui.DragSprite
All Implemented Interfaces:
javax.swing.Icon

public class DragSprite
extends java.lang.Object
implements javax.swing.Icon

Icon dragged across DragFrame.

Details: A DragSprite is an image that is dragged across the surface of a DragFrame or DragPanel. It encapsulates the image data, the image's grip point, and methods for rendering the image.

Since:
1998.10.17
Version:
1998.10.22
See Also:
DragFrame, DragPanel

Constructor Summary
DragSprite(javax.swing.Icon icon)
          Initializes using the given Icon and a centered grip point.
DragSprite(javax.swing.Icon icon, java.awt.Point grip)
          Initializes using the given Icon and grip point.
 
Method Summary
 java.awt.Rectangle getFootprint(int x, int y)
          Computes rectangular region affected by calling paintIcon.
 java.awt.Rectangle getFootprint(java.awt.Point p)
          Computes rectangular region affected by calling paintIcon.
 int getIconHeight()
          Returns this icon's height.
 int getIconWidth()
          Returns this icon's width.
 void paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y)
          Paints the icon at the given point.
 void paintIcon(java.awt.Component c, java.awt.Graphics g, java.awt.Point p)
          Paints the icon at the given point.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DragSprite

public DragSprite(javax.swing.Icon icon,
                  java.awt.Point grip)
Initializes using the given Icon and grip point.

Details: This constructor intializes a new DragSprite to display the given Icon offset by the given grip position. Future calls to paintIcon will cause the icon to be displayed in a translated coordinate system, according to the grip position.

When creating a DragSprite in response to the beginning of a drag session, the grip position should be set to the mouse coordinates of the beginning of the drag, relative to the upper-left pixel of the icon at the time the drag was initiated.

Parameters:
the - Icon to display
the - grip point of this sprite
Since:
1988.10.22

DragSprite

public DragSprite(javax.swing.Icon icon)
Initializes using the given Icon and a centered grip point.

Details: This constructor intializes a new DragSprite to display the given Icon offset by a grip point at its center. Future calls to paintIcon will cause the icon to be displayed in a translated coordinate system, according to the grip position.

When creating a DragSprite in response to the beginning of a drag session, the grip position should be set to the mouse coordinates of the beginning of the drag, relative to the upper-left pixel of the icon at the time the drag was initiated.

Parameters:
the - Icon to display
the - grip point of this sprite
Since:
1988.11.14
Method Detail

paintIcon

public void paintIcon(java.awt.Component c,
                      java.awt.Graphics g,
                      int x,
                      int y)
Paints the icon at the given point.

Details: paintIcon renders the icon at the given point, translated by the icon's grip point.

Specified by:
paintIcon in interface javax.swing.Icon
Parameters:
g - the graphics context
c - the Component to which g draws
x - the x draw coordinate
y - the y draw coordinate
Since:
1988.10.22

paintIcon

public void paintIcon(java.awt.Component c,
                      java.awt.Graphics g,
                      java.awt.Point p)
Paints the icon at the given point.

Details: paintIcon renders the icon at the given point, translated by the icon's grip point.

Parameters:
g - the graphics context
c - the Component to which g draws
p - the draw coordinate
Since:
1988.10.22

getIconWidth

public int getIconWidth()
Returns this icon's width.
Specified by:
getIconWidth in interface javax.swing.Icon
Returns:
the width
Since:
1988.10.22

getIconHeight

public int getIconHeight()
Returns this icon's height.
Specified by:
getIconHeight in interface javax.swing.Icon
Returns:
the height
Since:
1988.10.22

getFootprint

public java.awt.Rectangle getFootprint(int x,
                                       int y)
Computes rectangular region affected by calling paintIcon.

Details: getFootprint determines the rectangular region that would be potentially affected if the icon were drawn at the given point. The rectangular region returned is the bounding rectangle of the icon, translated by the grip point.

When moving the icon from one point to another, the old icon region and the new icon region should be invalidated. getFootprint facilitates this step.

Parameters:
x - the x draw coordinate
y - the y draw coordinate
Returns:
the rectangular region affected by calling paintIcon
Since:
1988.10.22

getFootprint

public java.awt.Rectangle getFootprint(java.awt.Point p)
Computes rectangular region affected by calling paintIcon.

Details: getFootprint determines the rectangular region that would be potentially affected if the icon were drawn at the given point. The rectangular region returned is the bounding rectangle of the icon, translated by the grip point.

When moving the icon from one point to another, the old icon region and the new icon region should be invalidated. getFootprint facilitates this step.

Parameters:
p - the draw coordinate
Returns:
the rectangular region affected by calling paintIcon
Since:
1988.10.22

Sharkysoft home