com.javadocking.drag.painter
Class ImageDockableDragPainter

java.lang.Object
  extended by com.javadocking.drag.painter.ImageDockableDragPainter
All Implemented Interfaces:
DockableDragPainter

public class ImageDockableDragPainter
extends java.lang.Object
implements DockableDragPainter

This dockable drag painter shows a window with the image of the dockable at the current mouse position, when the dockable is dragged.

This window is also visible outside the owner window.

The dock cursor or cannotdock cursor is shown on the window.

Several properties define the size of the image of the dockable:

Author:
Heidi Rakels.

Constructor Summary
ImageDockableDragPainter()
           
 
Method Summary
protected  float calculateActualReduceFactor(java.awt.Dimension componentSize)
          Calculates the actual reduce factor to calculate the image size.
 void clear()
          Clears everything what was painted by this painter before.
 java.awt.Dimension getMaxImageSize()
          Gets the maximum image size.
 java.awt.Dimension getMinImageSize()
          Gets the minimum image size.
 float getMinReduceFactor()
          Gets how much the image of the dockable is at least made smaller.
 float getPreferredReduceFactor()
          Gets how much the image of the dockable is made smaller.
 int getVerticalShift()
          Gets how much the image is shifted from the mouse in the vertical direction.
 void paintDockableDrag(Dockable newDockable, Dock dock, java.awt.Rectangle rectangle, java.awt.Point locationInDestinationDock)
           Paints a dockable during dragging.
 void setMaxImageSize(java.awt.Dimension maxImageSize)
          Sets the maximum image size.
 void setMinImageSize(java.awt.Dimension minImageSize)
          sets the minimum image size.
 void setMinReduceFactor(float minReduceFactor)
          Sets how much the image of the dockable is at least made smaller.
 void setPreferredReduceFactor(float factor)
          Sets how much the image of the dockable is made smaller.
 void setVerticalShift(int verticalShift)
          Sets how much the image is shifted from the mouse in the vertical direction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageDockableDragPainter

public ImageDockableDragPainter()
Method Detail

clear

public void clear()
Description copied from interface: DockableDragPainter
Clears everything what was painted by this painter before.

Specified by:
clear in interface DockableDragPainter

paintDockableDrag

public void paintDockableDrag(Dockable newDockable,
                              Dock dock,
                              java.awt.Rectangle rectangle,
                              java.awt.Point locationInDestinationDock)
Description copied from interface: DockableDragPainter

Paints a dockable during dragging.

Usually a rectangle is painted. It shows where the dockable will be docked in the dock, if the mouse would be released at the current mouse position.

Specified by:
paintDockableDrag in interface DockableDragPainter
Parameters:
newDockable - The dockable that will be painted.
dock - The dock in which the dockable can be docked.
rectangle - The rectangle that defines, where the given dockable will be docked, if the mouse is released at the current mouse position. The position of the rectangle is relative to the given dock.
locationInDestinationDock - The position of the mouse relative to the given dock.

getPreferredReduceFactor

public float getPreferredReduceFactor()
Gets how much the image of the dockable is made smaller. The default value is (float)(1.0 / 3.0).

Returns:
How much the image of the dockable is made smaller.

setPreferredReduceFactor

public void setPreferredReduceFactor(float factor)
Sets how much the image of the dockable is made smaller.

Parameters:
factor - How much the image of the dockable is made smaller.

getMinReduceFactor

public float getMinReduceFactor()
Gets how much the image of the dockable is at least made smaller. The default value is (float)(1.0 / 1.3).

Returns:
How much the image of the dockable is at least made smaller.

setMinReduceFactor

public void setMinReduceFactor(float minReduceFactor)
Sets how much the image of the dockable is at least made smaller.

Parameters:
minReduceFactor - How much the image of the dockable is at least made smaller.

getMaxImageSize

public java.awt.Dimension getMaxImageSize()
Gets the maximum image size. The default value is (200, 200).

Returns:
The size of the image is not bigger than this size.

setMaxImageSize

public void setMaxImageSize(java.awt.Dimension maxImageSize)
Sets the maximum image size.

Parameters:
maxImageSize - The size of the image is not bigger than this size.

getMinImageSize

public java.awt.Dimension getMinImageSize()
Gets the minimum image size. The default value is (50, 50).

Returns:
The size of the image is not smaller than this size.

setMinImageSize

public void setMinImageSize(java.awt.Dimension minImageSize)
sets the minimum image size.

Parameters:
minImageSize - The size of the image is not bigger than this size. The width or height may not be 0.

getVerticalShift

public int getVerticalShift()
Gets how much the image is shifted from the mouse in the vertical direction. The default value is 5.

Returns:
How much the image is shifted from the mouse in the vertical direction.

setVerticalShift

public void setVerticalShift(int verticalShift)
Sets how much the image is shifted from the mouse in the vertical direction.

Parameters:
verticalShift - How much the image is shifted from the mouse in the vertical direction.

calculateActualReduceFactor

protected float calculateActualReduceFactor(java.awt.Dimension componentSize)
Calculates the actual reduce factor to calculate the image size.

Parameters:
componentSize - The size of the component of which an image has to be made. The image size will be this size multiplied with the actual reduce factor.
Returns:
The actual reduce factor to calculate the image size.