Search this API

y.view.tabular
Class TableSizeEditor

java.lang.Object
  extended by y.view.AbstractMouseInputEditor
      extended by y.view.tabular.TableSizeEditor
All Implemented Interfaces:
MouseInputEditor, MultiplexingNodeEditor.NodeEditor

public class TableSizeEditor
extends AbstractMouseInputEditor

This MultiplexingNodeEditor.NodeEditor can be used to resize rows and columns of a TableGroupNodeRealizer. During the resize gesture the new bounds of the row or column as well as the new bounds of the realizer are indicated by a drawable.

As this resizing can cause other rows or columns to change their position, nodes residing in these rows or columns are moved accordingly by use of tableSupport.

A reduction of a row's or column's size is restricted to respect the following criteria:

If isModifierPressed(y.view.Mouse2DEvent) returns true at the start of the resize gesture, the sizes of the two adjacent rows or columns can be redistributed instead of in- or decreasing only one row's or column's size. This is indicated by one drawable for each of the two rows or columns as well as a drawable for the realizer (whose bounds stay the same).

 

Field Summary
protected  TableGroupNodeRealizer.Column activeColumn
          The column that gets resized or null if there is none.
protected  TableGroupNodeRealizer.Row activeRow
          The row that gets resized or null if there is none.
protected  double dx
          The last recent delta of a horizontal resizing.
protected  double dy
          The last recent delta of a vertical resizing.
static byte RESIZE_POLICY_CONSIDER_BOUNDS
          Using this resize policy the bounds of the content nodes are used to determine if a row's or column's size may be reduced further.
static byte RESIZE_POLICY_CONSIDER_CENTER
          Using this resize policy the center coordinates of the content nodes are used to determine if a row's or column's size may be reduced further.
static byte RESIZE_POLICY_IGNORE_CONTENT
          Using this resize policy content elements are completely ignored, that is content nodes do no restrict minimum column or row size and neither nodes nor bends are moved due to column or row size changes.
protected  TableGroupNodeRealizer.Column secondActiveColumn
          The second column that gets resized if this is a column size redistribution gesture or null otherwise.
protected  TableGroupNodeRealizer.Row secondActiveRow
          The second row that gets resized if this is a row size redistribution gesture or null otherwise.
protected  TableGroupNodeRealizer.Table table
          The table whose rows or columns get resized.
 
Constructor Summary
TableSizeEditor()
          Default constructor of this class.
 
Method Summary
protected  void assignNewBounds()
          Assigns the new sizes of the rows/columns.
protected  Drawable createColumnResizeDrawable(TableGroupNodeRealizer.Column column, java.awt.geom.Rectangle2D bounds)
          Creates a new drawable with the specified bounds indicating the new size of the given column.
protected  Drawable createRowResizeDrawable(TableGroupNodeRealizer.Row row, java.awt.geom.Rectangle2D bounds)
          Creates a new drawable with the specified bounds indicating the new size of the given row.
protected  Drawable createTableResizeDrawable(TableGroupNodeRealizer.Table table, java.awt.geom.Rectangle2D bounds)
          Creates a new drawable with the specified bounds indicating the new size of the given table.
 java.awt.Cursor getCursor(Mouse2DEvent event)
          If the position of the event is valid to start a row (column) resize gesture, Cursor.W_RESIZE_CURSOR (Cursor.N_RESIZE_CURSOR) is returned.
 double getEpsilon()
          Returns the maximal distance the mouse cursor may have to the realizer's bounding box, a column's right border or a row's bottom border so that a resize gesture still may start there.
 byte getResizePolicy()
          Returns the current resize policy.
 TableSupport getTableSupport()
          Returns the TableSupport used to resize the columns and rows.
protected  boolean isModifierPressed(Mouse2DEvent event)
          Returns true if SHIFT was pressed during the specified event.
 boolean isTableResizeDrawableEnabled()
          Determines if a drawable shall indicate the new bounds of the TableGroupNodeRealizer.Table.
 boolean isValidStartPosition(double x, double y)
          Determines whether the editor may start editing at the specified position.
 void mouse2DEventHappened(Mouse2DEvent event)
          Listener-like interface that will be notified of Mouse2DEvents.
protected  void mouseDragged(double x, double y)
          Updates the bounds of the drawables indicating the new size(s) of the rows/columns.
protected  void mousePressed(double x, double y, boolean modifierPressed)
          Initializes a drag gesture starting at the specified coordinates.
protected  void mouseReleased(double x, double y)
          Calls assignNewBounds() and finally ends the resize gesture.
 void setContext(Graph2DView view, MultiplexingNodeEditor parent, NodeRealizer realizer)
          Provides context information for the editor.
 void setEpsilon(double epsilon)
          Specifies the maximal distance the mouse cursor may have to the realizer's bounding box, a column's right border or a row's bottom border so that a resize gesture still may start there.
 void setResizePolicy(byte resizePolicy)
          Specifies the resize policy to use.
 void setTableResizeDrawableEnabled(boolean enabled)
          Specifies whether a resize preview should be displayed or not.
 void setTableSupport(TableSupport support)
          Specifies the support class to handle content (nodes and bends) moving during resize operations.
 boolean startsEditing(Mouse2DEvent event)
          This method is used by clients to query whether the given event is deemed as a starting gesture.
 void stopEditing()
          Called by clients to stop the editing process cleanly.
 
Methods inherited from class y.view.AbstractMouseInputEditor
addChangeListener, fireStateChanged, isEditing, isEnabled, isInterestedInEvents, removeChangeListener, setEnabled, startEditing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface y.view.MouseInputEditor
addChangeListener, isEditing, isInterestedInEvents, removeChangeListener, startEditing
 

Field Detail

RESIZE_POLICY_CONSIDER_CENTER

public static final byte RESIZE_POLICY_CONSIDER_CENTER
Using this resize policy the center coordinates of the content nodes are used to determine if a row's or column's size may be reduced further.

See Also:
getResizePolicy(), setResizePolicy(byte), Constant Field Values

RESIZE_POLICY_CONSIDER_BOUNDS

public static final byte RESIZE_POLICY_CONSIDER_BOUNDS
Using this resize policy the bounds of the content nodes are used to determine if a row's or column's size may be reduced further.

See Also:
getResizePolicy(), setResizePolicy(byte), Constant Field Values

RESIZE_POLICY_IGNORE_CONTENT

public static final byte RESIZE_POLICY_IGNORE_CONTENT
Using this resize policy content elements are completely ignored, that is content nodes do no restrict minimum column or row size and neither nodes nor bends are moved due to column or row size changes.

See Also:
getResizePolicy(), setResizePolicy(byte), Constant Field Values

table

protected TableGroupNodeRealizer.Table table
The table whose rows or columns get resized.


activeRow

protected TableGroupNodeRealizer.Row activeRow
The row that gets resized or null if there is none.


secondActiveRow

protected TableGroupNodeRealizer.Row secondActiveRow
The second row that gets resized if this is a row size redistribution gesture or null otherwise.


activeColumn

protected TableGroupNodeRealizer.Column activeColumn
The column that gets resized or null if there is none.


secondActiveColumn

protected TableGroupNodeRealizer.Column secondActiveColumn
The second column that gets resized if this is a column size redistribution gesture or null otherwise.


dx

protected double dx
The last recent delta of a horizontal resizing.


dy

protected double dy
The last recent delta of a vertical resizing.

Constructor Detail

TableSizeEditor

public TableSizeEditor()
Default constructor of this class.

Method Detail

getTableSupport

public TableSupport getTableSupport()
Returns the TableSupport used to resize the columns and rows.

Returns:
the TableSupport used to resize the columns and rows.
See Also:
getTableSupport()

setTableSupport

public void setTableSupport(TableSupport support)
Specifies the support class to handle content (nodes and bends) moving during resize operations.

Parameters:
support - the support class to handle content (nodes and bends) moving.
See Also:
getTableSupport()

isValidStartPosition

public boolean isValidStartPosition(double x,
                                    double y)
Determines whether the editor may start editing at the specified position. The given position is considered to be valid if it is close to the bounding box of the realizer, close to the right border of a column or close to the bottom border of a row.

In this context close means, that the distance is less than the return value of getEpsilon().

Parameters:
x - The horizontal position to check.
y - The vertical position to check.
Returns:
true if the editor may start editing at the specified position and false otherwise.

isModifierPressed

protected boolean isModifierPressed(Mouse2DEvent event)
Returns true if SHIFT was pressed during the specified event.

Parameters:
event - The mouse event to check.
Returns:
True, if SHIFT was pressed during the given mouse event.

mousePressed

protected void mousePressed(double x,
                            double y,
                            boolean modifierPressed)
Initializes a drag gesture starting at the specified coordinates.

Parameters:
x - The horizontal start position of the gesture.
y - The vertical start position of the gesture.
modifierPressed - If isModifierPressed(y.view.Mouse2DEvent) had returned true for the initial mouse gesture.

mouseDragged

protected void mouseDragged(double x,
                            double y)
Updates the bounds of the drawables indicating the new size(s) of the rows/columns.

Parameters:
x - The current horizontal position of the dragged mouse.
y - The current vertical position of the dragged mouse.

mouseReleased

protected void mouseReleased(double x,
                             double y)
Calls assignNewBounds() and finally ends the resize gesture.

Parameters:
x - the x-coordinate of the mouse release event.
y - the y-coordinate of the mouse release event.

assignNewBounds

protected void assignNewBounds()
Assigns the new sizes of the rows/columns.


createTableResizeDrawable

protected Drawable createTableResizeDrawable(TableGroupNodeRealizer.Table table,
                                             java.awt.geom.Rectangle2D bounds)
Creates a new drawable with the specified bounds indicating the new size of the given table.

Parameters:
table - The TableGroupNodeRealizer.Table to create a drawable for.
bounds - The new table bounds that shall be indicated.

createRowResizeDrawable

protected Drawable createRowResizeDrawable(TableGroupNodeRealizer.Row row,
                                           java.awt.geom.Rectangle2D bounds)
Creates a new drawable with the specified bounds indicating the new size of the given row.

Parameters:
row - The TableGroupNodeRealizer.Row to create a drawable for.
bounds - The new bounds of the row that shall be indicated.

createColumnResizeDrawable

protected Drawable createColumnResizeDrawable(TableGroupNodeRealizer.Column column,
                                              java.awt.geom.Rectangle2D bounds)
Creates a new drawable with the specified bounds indicating the new size of the given column.

Parameters:
column - The TableGroupNodeRealizer.Column to create a drawable for.
bounds - The new bounds of the column that shall be indicated.

getResizePolicy

public byte getResizePolicy()
Returns the current resize policy. The policy determines whether resizing of a row/column stops if the new content bounds (the row/columns bounds reduced by it's insets) are hitting a content node's bounds (RESIZE_POLICY_CONSIDER_BOUNDS) or center coordinates (RESIZE_POLICY_CONSIDER_CENTER).

The default setting for this policy is RESIZE_POLICY_CONSIDER_BOUNDS.

Returns:
either RESIZE_POLICY_CONSIDER_BOUNDS or RESIZE_POLICY_CONSIDER_CENTER.
See Also:
setResizePolicy(byte)

setResizePolicy

public void setResizePolicy(byte resizePolicy)
Specifies the resize policy to use.

The default setting for this policy is RESIZE_POLICY_CONSIDER_BOUNDS.

Parameters:
resizePolicy - one of
Throws:
java.lang.IllegalArgumentException - if resizePolicy does not equal one of the resize policy constants.
See Also:
getResizePolicy()

isTableResizeDrawableEnabled

public boolean isTableResizeDrawableEnabled()
Determines if a drawable shall indicate the new bounds of the TableGroupNodeRealizer.Table.

The default setting of this property is true.

Returns:
true if a resize preview is displayed and false otherwise.
See Also:
setTableResizeDrawableEnabled(boolean), createTableResizeDrawable(y.view.tabular.TableGroupNodeRealizer.Table, java.awt.geom.Rectangle2D)

setTableResizeDrawableEnabled

public void setTableResizeDrawableEnabled(boolean enabled)
Specifies whether a resize preview should be displayed or not.

Parameters:
enabled - if true a drawable is displayed as a preview for the new bounds.
See Also:
isTableResizeDrawableEnabled(), createTableResizeDrawable(y.view.tabular.TableGroupNodeRealizer.Table, java.awt.geom.Rectangle2D)

getEpsilon

public double getEpsilon()
Returns the maximal distance the mouse cursor may have to the realizer's bounding box, a column's right border or a row's bottom border so that a resize gesture still may start there.

The default value of this property is 5.

Returns:
the maximal distance the mouse cursor may have to the realizer's bounding box, a column's right border or a row's bottom border so that a resize gesture still may start there.
See Also:
setEpsilon(double)

setEpsilon

public void setEpsilon(double epsilon)
Specifies the maximal distance the mouse cursor may have to the realizer's bounding box, a column's right border or a row's bottom border so that a resize gesture still may start there.

Parameters:
epsilon - the distance.
See Also:
getEpsilon()

stopEditing

public void stopEditing()
Description copied from interface: MouseInputEditor
Called by clients to stop the editing process cleanly.

Specified by:
stopEditing in interface MouseInputEditor

startsEditing

public boolean startsEditing(Mouse2DEvent event)
Description copied from interface: MouseInputEditor
This method is used by clients to query whether the given event is deemed as a starting gesture.

Parameters:
event - the event that happened
Returns:
whether the given gesture can be used to start the editing
See Also:
MouseInputEditor.isInterestedInEvents()

mouse2DEventHappened

public void mouse2DEventHappened(Mouse2DEvent event)
Description copied from interface: MouseInputEditor
Listener-like interface that will be notified of Mouse2DEvents.

Parameters:
event - the event that happened
See Also:
MouseInputEditor.isInterestedInEvents()

getCursor

public java.awt.Cursor getCursor(Mouse2DEvent event)
If the position of the event is valid to start a row (column) resize gesture, Cursor.W_RESIZE_CURSOR (Cursor.N_RESIZE_CURSOR) is returned.

Specified by:
getCursor in interface MultiplexingNodeEditor.NodeEditor
Parameters:
event - the Mouse2DEvent that determines which Cursor to return.
Returns:
Cursor.W_RESIZE_CURSOR or Cursor.N_RESIZE_CURSOR if a resize gesture may start at the location of the event or null otherwise.

setContext

public void setContext(Graph2DView view,
                       MultiplexingNodeEditor parent,
                       NodeRealizer realizer)
Description copied from interface: MultiplexingNodeEditor.NodeEditor
Provides context information for the editor.

Specified by:
setContext in interface MultiplexingNodeEditor.NodeEditor
Parameters:
view - the current view in which the editing is done.
parent - the multiplexing editor that delegates to the node editor.
realizer - the realizer representing the node to edit.

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