Search this API

y.view.tabular
Class RowDropTargetListener

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

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

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

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

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

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

 

Constructor Summary
RowDropTargetListener(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 row.
 void dragEnter(java.awt.dnd.DropTargetDragEvent event)
          On entering the drawable returned by createDrawable(java.awt.geom.Rectangle2D,y.geom.YInsets) is 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 row 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 row can be determined, a row is created.
 void dropActionChanged(java.awt.dnd.DropTargetDragEvent event)
          This implementation doesn't react to a drop action change.
 double getDefaultHeight()
          Returns the initial height of rows created by this listener.
 YInsets getDefaultInsets()
          Returns the insets of rows created by this listener.
 double getDefaultMinimumHeight()
          Returns the minimum height of rows created by this listener.
 double getDrawableWidth()
          Returns the width assigned to the drawable while no valid position for a new row can be found at the cursor position.
 int getMaxLevel()
          Returns the maximum level the new row may lie in.
 TableSupport getTableSupport()
          Returns the TableSupport used to create new rows.
 boolean isUsingTableDefaults()
          Returns true if default settings for height, minimum height, and insets are taken from the target table or false if the default settings of the listener are used when creating a new row in a table.
 void setDefaultHeight(double defaultHeight)
          Specifies the initial height of rows created by this listener.
 void setDefaultInsets(YInsets defaultInsets)
          Specifies the insets of rows created by this listener.
 void setDefaultMinimumHeight(double defaultMinimumHeight)
          Specifies the minimum height of rows created by this listener.
 void setDrawableWidth(double drawableWidth)
          Specifies the width assigned to the drawable while no valid position for a new row can be found at the cursor position.
 void setMaxLevel(int maxLevel)
          Specifies the maximum level the new row may lie in.
 void setTableSupport(TableSupport support)
          Specifies the TableSupport used to create new rows.
 void setUsingTableDefaults(boolean usingTableDefaults)
          Specifies whether default settings for height, minimum height, and insets are taken from the target table or whether the default settings of the listener are used when creating a new row in a table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RowDropTargetListener

public RowDropTargetListener(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 rows.

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

setTableSupport

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

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 row. The insets can be used to indicate the possible insets of the new row.

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

dragEnter

public void dragEnter(java.awt.dnd.DropTargetDragEvent event)
On entering the drawable returned by createDrawable(java.awt.geom.Rectangle2D,y.geom.YInsets) is 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 row 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 row can be determined, a row is created. Depending on usingTableDefaults the default settings for rows of the TableGroupNodeRealizer the row is created in or the settings of this listener are used for the new row.

Specified by:
drop in interface java.awt.dnd.DropTargetListener
Parameters:
event - The drop event to handle.

getDefaultHeight

public double getDefaultHeight()
Returns the initial height of rows created by this listener.

The default value of this property is 10.

Returns:
the initial height of rows created by this listener.
See Also:
setDefaultHeight(double)

setDefaultHeight

public void setDefaultHeight(double defaultHeight)
Specifies the initial height of rows created by this listener.

The default value of this property is 10.

Parameters:
defaultHeight - the initial height of rows.
See Also:
getDefaultHeight()

getDefaultMinimumHeight

public double getDefaultMinimumHeight()
Returns the minimum height of rows created by this listener.

The default value of this property is 10.

Returns:
the minimum height of rows created by this listener.
See Also:
setDefaultMinimumHeight(double)

setDefaultMinimumHeight

public void setDefaultMinimumHeight(double defaultMinimumHeight)
Specifies the minimum height of rows created by this listener.

The default value of this property is 10.

Parameters:
defaultMinimumHeight - the default minimum height of rows.
See Also:
getDefaultMinimumHeight()

getDefaultInsets

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

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

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

setDefaultInsets

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

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

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

getMaxLevel

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

The default value of this property is Integer.MAX_VALUE.

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

setMaxLevel

public void setMaxLevel(int maxLevel)
Specifies the maximum level the new row 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 row.
See Also:
getMaxLevel()

isUsingTableDefaults

public boolean isUsingTableDefaults()
Returns true if default settings for height, minimum height, and insets are taken from the target table or false if the default settings of the listener are used when creating a new row 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 height, minimum height, and insets are taken from the target table or whether the default settings of the listener are used when creating a new row 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()

getDrawableWidth

public double getDrawableWidth()
Returns the width assigned to the drawable while no valid position for a new row can be found at the cursor position.

The default value of this property is 100.

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

setDrawableWidth

public void setDrawableWidth(double drawableWidth)
Specifies the width assigned to the drawable while no valid position for a new row can be found at the cursor position.

The default value of this property is 100.

Parameters:
drawableWidth - the width assigned to the drawable.
See Also:
getDrawableWidth()

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