Package furbelow

Class GhostedDragImage


public class GhostedDragImage extends AbstractComponentDecorator
Provide a ghosted drag image which will appear on any instances of RootPaneContainer in the current VM. Its location in screen coordinates may be set via move(java.awt.Point).

When the image is no longer needed, invoke dispose(), which hides the graphic immediately, or returnToOrigin(), which moves the image to its original location prior to invoking dispose().

  • Constructor Details

    • GhostedDragImage

      public GhostedDragImage(JComponent dragSource, Point screenLocation, Icon icon, Point imageOffset)
      Create a ghosted drag image, using the given icon.
      Parameters:
      dragSource - source of the drag
      screenLocation - screen location where the drag started
      icon - image to be drawn
      imageOffset - offset of the image from the cursor
    • GhostedDragImage

      protected GhostedDragImage(JComponent dragSource, JLayeredPane root, Point screenLocation, Icon icon, Point imageOffset, boolean trackFrames)
      Create a ghosted drag image.
      Parameters:
      dragSource - source of the drag
      root - layered pane on which ghosted image is drawn
      screenLocation - initial location of image, in screen coordinates
      icon - icon to use for the ghost image
      imageOffset - offset of the image within the drag source
      trackFrames - if true, creates additional ghosts for all extant frames which contain a JLayeredPane where the image can be painted.
  • Method Details

    • setAlpha

      public void setAlpha(float alpha)
      Set the transparency of the ghosted image.
    • setCursor

      public void setCursor(Cursor cursor)
      Ensure the decorator cursor matches the drag cursor, or we get cursor flicker when autoscrolling.
      Overrides:
      setCursor in class AbstractComponentDecorator
    • dispose

      public void dispose()
      Make all ghosted images go away.
      Overrides:
      dispose in class AbstractComponentDecorator
    • clipDecorationBounds

      protected Rectangle clipDecorationBounds(Rectangle decorated)
      Adjust the bounds of the painting component to allow some buffer to avoid cursor flicker when moving.
      Overrides:
      clipDecorationBounds in class AbstractComponentDecorator
    • move

      public void move(Point screen)
      Move the ghosted image to the requested location.
      Parameters:
      screen - Where to draw the image, in screen coordinates
    • paint

      public void paint(Graphics graphics)
      Paint the supplied image with transparency.
      Specified by:
      paint in class AbstractComponentDecorator
    • returnToOrigin

      public void returnToOrigin()
      Animate the ghosted image returning to its origin.