com.alee.managers.drag
Class ComponentDragViewHandler<T extends javax.swing.JComponent>

java.lang.Object
  extended by com.alee.managers.drag.ComponentDragViewHandler<T>
All Implemented Interfaces:
DragViewHandler<T>

public abstract class ComponentDragViewHandler<T extends javax.swing.JComponent>
extends java.lang.Object
implements DragViewHandler<T>

Author:
Mikle Garin

Field Summary
protected  java.awt.Point location
          Initial mouse location on dragged component.
protected  java.lang.ref.WeakReference<T> reference
          Dragged object reference.
 
Constructor Summary
ComponentDragViewHandler()
           
 
Method Summary
 void dragEnded(T object, java.awt.dnd.DragSourceDropEvent event)
          Notifies about drag operation end.
 float getSnapshotTransparency()
          Returns component snapshot transparency.
 java.awt.image.BufferedImage getView(T object, java.awt.dnd.DragSourceDragEvent event)
          Returns image object representation.
 java.awt.Point getViewRelativeLocation(T object, java.awt.dnd.DragSourceDragEvent event)
          Returns image object representation location relative to mouse location.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.alee.managers.drag.DragViewHandler
getObjectFlavor
 

Field Detail

location

protected java.awt.Point location
Initial mouse location on dragged component. Used to position component snapshot correctly under the mouse.


reference

protected java.lang.ref.WeakReference<T extends javax.swing.JComponent> reference
Dragged object reference.

Constructor Detail

ComponentDragViewHandler

public ComponentDragViewHandler()
Method Detail

getView

public java.awt.image.BufferedImage getView(T object,
                                            java.awt.dnd.DragSourceDragEvent event)
Returns image object representation. This method is called once per drag operation to initialize dragged object view.

Specified by:
getView in interface DragViewHandler<T extends javax.swing.JComponent>
Parameters:
object - object to create image representation for
event - drag source drag event
Returns:
image object representation

getSnapshotTransparency

public float getSnapshotTransparency()
Returns component snapshot transparency. By default snapshot is semi-transparent for usability purposes.

Returns:
component snapshot transparency

getViewRelativeLocation

public java.awt.Point getViewRelativeLocation(T object,
                                              java.awt.dnd.DragSourceDragEvent event)
Returns image object representation location relative to mouse location. This method is called each time image location should be updated.

Specified by:
getViewRelativeLocation in interface DragViewHandler<T extends javax.swing.JComponent>
Parameters:
object - object return image representation location for
event - drag source drag event
Returns:
image object representation location relative to mouse location

dragEnded

public void dragEnded(T object,
                      java.awt.dnd.DragSourceDropEvent event)
Notifies about drag operation end. This method is called once per drag operation.

Specified by:
dragEnded in interface DragViewHandler<T extends javax.swing.JComponent>
Parameters:
object - dragged object
event - drag source drop event