Search this API

y.view.tabular
Class ColumnDropTargetListener

java.lang.Object
  extended by y.view.tabular.ColumnDropTargetListener
All Implemented Interfaces:
java.awt.dnd.DropTargetListener, java.util.EventListener

public class ColumnDropTargetListener
extends java.lang.Object
implements java.awt.dnd.DropTargetListener

This DropTargetListener can be used to create new columns in a TableGroupNodeRealizer via drag'n'drop.

It can be configured to use the default settings for the column size, minimum size and inset of the new column's table or those set at this listener.

A maximum level for nested column structures can be set so that no new column with a deeper nesting level can be created.

While dragging, a drawable indicates possible positions of the new column.

 

Constructor Summary
ColumnDropTargetListener(Graph2DView view)
          Constructs a new listener that works on the given view.
 
Method Summary
protected  Drawable createDrawable(java.awt.geom.Rectangle2D bounds, YInsets insets)
          Creates a new drawable used to indicate the possible bounds of the new column.
 void dragEnter(java.awt.dnd.DropTargetDragEvent event)
          On entering a new drawable is created via createDrawable(java.awt.geom.Rectangle2D,y.geom.YInsets) and added to the view.
 void dragExit(java.awt.dnd.DropTargetEvent event)
          Ends the drag gesture and does some clean ups.
 void dragOver(java.awt.dnd.DropTargetDragEvent event)
          The new possible position for the column at the event's location is determined and the drawable is updated.
 void drop(java.awt.dnd.DropTargetDropEvent event)
          If a possible position for a new column can be determined, a column is created.
 void dropActionChanged(java.awt.dnd.DropTargetDragEvent event)
          This implementation doesn't react to a drop action change.
 YInsets getDefaultInsets()
          Returns the insets of columns created by this listener.
 double getDefaultMinimumWidth()
          Returns the minimum width of columns created by this listener.
 double getDefaultWidth()
          Returns the initial width of columns created by this listener.
 double getDrawableHeight()
          Returns the height assigned to the drawable while no valid position for a new column can be found at the cursor position.
 int getMaxLevel()
          Returns the maximum level the new column may lie in.
 TableSupport getTableSupport()
          Returns the TableSupport used to create new columns.
 boolean isUsingTableDefaults()
          Returns true if default settings for width, minimum width, and insets are taken from the target table or false if the default settings of the listener are used when creating a new column in a table.
 void setDefaultInsets(YInsets defaultInsets)
          Specifies the insets of columns created by this listener.
 void setDefaultMinimumWidth(double defaultMinimumWidth)
          Specifies the minimum width of columns created by this listener.
 void setDefaultWidth(double defaultWidth)
          Specifies the initial width of columns created by this listener.
 void setDrawableHeight(double drawableHeight)
          Specifies the height assigned to the drawable while no valid position for a new column can be found at the cursor position.
 void setMaxLevel(int maxLevel)
          Specifies the maximum level the new column may lie in.
 void setTableSupport(TableSupport support)
          Specifies the TableSupport used to create new columns.
 void setUsingTableDefaults(boolean usingTableDefaults)
          Specifies whether default settings for width, minimum width, and insets are taken from the target table or whether the default settings of the listener are used when creating a new column in a table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColumnDropTargetListener

public ColumnDropTargetListener(Graph2DView view)
Constructs a new listener that works on the given view.

Parameters:
view - The Graph2DView to work on.
Method Detail

getTableSupport

public TableSupport getTableSupport()
Returns the TableSupport used to create new columns.

Returns:
the TableSupport used to create new columns.
See Also:
setTableSupport(TableSupport)

setTableSupport

public void setTableSupport(TableSupport support)
Specifies the TableSupport used to create new columns.

Parameters:
support - the TableSupport instance to be used.
See Also:
getTableSupport()

createDrawable

protected Drawable createDrawable(java.awt.geom.Rectangle2D bounds,
                                  YInsets insets)
Creates a new drawable used to indicate the possible bounds of the new column. The insets can be used to indicate the possible insets of the new column.

Parameters:
bounds - The possible bounds of the new column.
insets - The possible insets of the new column.

dragEnter

public void dragEnter(java.awt.dnd.DropTargetDragEvent event)
On entering a new drawable is created via createDrawable(java.awt.geom.Rectangle2D,y.geom.YInsets) and added to the view.

Specified by:
dragEnter in interface java.awt.dnd.DropTargetListener

dragOver

public void dragOver(java.awt.dnd.DropTargetDragEvent event)
The new possible position for the column at the event's location is determined and the drawable is updated.

Specified by:
dragOver in interface java.awt.dnd.DropTargetListener

dropActionChanged

public void dropActionChanged(java.awt.dnd.DropTargetDragEvent event)
This implementation doesn't react to a drop action change.

Specified by:
dropActionChanged in interface java.awt.dnd.DropTargetListener

dragExit

public void dragExit(java.awt.dnd.DropTargetEvent event)
Ends the drag gesture and does some clean ups.

Specified by:
dragExit in interface java.awt.dnd.DropTargetListener

drop

public void drop(java.awt.dnd.DropTargetDropEvent event)
If a possible position for a new column can be determined, a column is created. Depending on usingTableDefaults the default settings for columns of the TableGroupNodeRealizer the column is created in or the settings of this listener are used for the new column.

Specified by:
drop in interface java.awt.dnd.DropTargetListener

getDefaultWidth

public double getDefaultWidth()
Returns the initial width of columns created by this listener.

The default value of this property is 10.

Returns:
the initial width of columns created by this listener.
See Also:
setDefaultWidth(double)

setDefaultWidth

public void setDefaultWidth(double defaultWidth)
Specifies the initial width of columns created by this listener.

The default value of this property is 10.

Parameters:
defaultWidth - the initial width of columns.
See Also:
getDefaultWidth()

getDefaultMinimumWidth

public double getDefaultMinimumWidth()
Returns the minimum width of columns created by this listener.

The default value of this property is 10.

Returns:
the minimum width of columns created by this listener.
See Also:
setDefaultMinimumWidth(double)

setDefaultMinimumWidth

public void setDefaultMinimumWidth(double defaultMinimumWidth)
Specifies the minimum width of columns created by this listener.

The default value of this property is 10.

Parameters:
defaultMinimumWidth - the default minimum width of columns.
See Also:
getDefaultMinimumWidth()

getDefaultInsets

public YInsets getDefaultInsets()
Returns the insets of columns created by this listener.

The default insets are top = 10, left = 0, bottom = 0, right = 0.

Returns:
the insets of columns created by this listener.
See Also:
setDefaultInsets(y.geom.YInsets)

setDefaultInsets

public void setDefaultInsets(YInsets defaultInsets)
Specifies the insets of columns created by this listener.

The default insets are top = 10, left = 0, bottom = 0, right = 0.

Parameters:
defaultInsets - the insets of columns created by this listener.
See Also:
getDefaultInsets()

getMaxLevel

public int getMaxLevel()
Returns the maximum level the new column may lie in.

The default value of this property is Integer.MAX_VALUE.

Returns:
the maximum level the new column may lie in.
See Also:
setMaxLevel(int)

setMaxLevel

public void setMaxLevel(int maxLevel)
Specifies the maximum level the new column may lie in. Non-positive values are ignored.

The default value of this property is Integer.MAX_VALUE.

Parameters:
maxLevel - the maximum level of a new column.
See Also:
getMaxLevel()

isUsingTableDefaults

public boolean isUsingTableDefaults()
Returns true if default settings for width, minimum width, and insets are taken from the target table or false if the default settings of the listener are used when creating a new column in a table.

The default value of this property is false.

See Also:
setUsingTableDefaults(boolean)

setUsingTableDefaults

public void setUsingTableDefaults(boolean usingTableDefaults)
Specifies whether default settings for width, minimum width, and insets are taken from the target table or whether the default settings of the listener are used when creating a new column in a table.

The default value of this property is false.

Parameters:
usingTableDefaults - if true the default settings of the target table are used; otherwise the default settings from the listener are used.
See Also:
isUsingTableDefaults()

getDrawableHeight

public double getDrawableHeight()
Returns the height assigned to the drawable while no valid position for a new column can be found at the cursor position.

The default value of this property is 100.

Returns:
the height assigned to the drawable while no valid position for a new column can be found at the cursor position.
See Also:
setDrawableHeight(double)

setDrawableHeight

public void setDrawableHeight(double drawableHeight)
Specifies the height assigned to the drawable while no valid position for a new column can be found at the cursor position.

The default value of this property is 100.

Parameters:
drawableHeight - the height assigned to the drawable.
See Also:
getDrawableHeight()

© Copyright 2000-2022,
yWorks GmbH.
All rights reserved.