Search this API

y.view.tabular
Class TableSelectionEditor

java.lang.Object
  extended by y.view.AbstractMouseInputEditor
      extended by y.view.tabular.TableSelectionEditor
All Implemented Interfaces:
java.util.EventListener, Graph2DSelectionListener, MouseInputEditor, MultiplexingNodeEditor.NodeEditor

public class TableSelectionEditor
extends AbstractMouseInputEditor
implements Graph2DSelectionListener

This MultiplexingNodeEditor.NodeEditor can be used to change the selection status of rows and columns of a TableGroupNodeRealizer.

A row (column) can be selected by clicking somewhere inside it's left (top) inset area. If isSelectionModifierPressed(y.view.Mouse2DEvent) returns false, this also results in an unselection of all selected graph elements as well as all other selected rows and columns of this TableGroupNodeRealizer.

The selection status of the rows and columns of a TableGroupNodeRealizer can be connected to the selection status of this realizer if selectionPolicy is set to RELATE_TO_NODE_SELECTION. In this case the selection of a row or column results in the selection of the realizer and on deselecting the realizer its rows and columns are deselected as well.

 
Your browser does not support SVG content.

Field Summary
static byte IGNORE_NODE_SELECTION
          Using this selection policy the selection states of rows/columns and their TableGroupNodeRealizer are not related to each other.
static byte RELATE_TO_NODE_SELECTION
          Using this selection policy the selection states of rows/columns and their TableGroupNodeRealizer are related to each other.
 
Constructor Summary
TableSelectionEditor()
          The default constructor of this class.
 
Method Summary
protected  void columnEventHappened(Graph2D graph, TableGroupNodeRealizer.Column column, boolean modifierPressed)
          Handles (non-cyclic) selection state changes for the specified column.
protected  void columnEventHappened(Graph2D graph, TableGroupNodeRealizer.Column column, Mouse2DEvent event)
          Handles selection state changes for the specified column.
protected  boolean columnSelectionHit(TableGroupNodeRealizer.Column column, double x, double y)
          Determines whether a mouse click at the specified hit location should change the selection state of the specified column.
 java.awt.Cursor getCursor(Mouse2DEvent event)
          Returns a mouse cursor to indicate what action this event could trigger or null if the editor does not want to initiate a cursor change.
 byte getSelectionPolicy()
          Return the current selection policy.
 boolean isCyclicSelectionEnabled()
          Determines whether or not selection cycling is enabled.
protected  boolean isCyclicSelectionModifierPressed(Mouse2DEvent event)
          Determines whether or not the specified event should result in cycling the selection through the elements at the current mouse position (if selection cycling is enabled).
 boolean isExtendedSelectionHitEnabled()
          Returns true if the editor should change the selection state of columns and rows that have no children upon hits outside of the column's top inset area or the row's left inset area and false otherwise.
 boolean isMixedSelectionEnabled()
          Returns true if the editor allows mixed multi-selections of columns and rows in a table and false otherwise.
protected  boolean isSelectionModifierPressed(Mouse2DEvent event)
          Determines whether or not the specified event should result in expanding the current selection to include the clicked element instead of changing the selection to the clicked element.
 boolean isUnselectOnTableBorderEnabled()
          Returns true if clicking on the table border will unselect all selected columns and rows and false otherwise.
 boolean isValidStartPosition(double x, double y)
          The given position is considered to be valid if it is inside the left inset of a TableGroupNodeRealizer.Row or the top inset of a TableGroupNodeRealizer.Column.
 void mouse2DEventHappened(Mouse2DEvent event)
          Listener-like interface that will be notified of Mouse2DEvents.
 void onGraph2DSelectionEvent(Graph2DSelectionEvent event)
          Sets the selection state of all columns and rows of a TableGroupNodeRealizer's table model to false whenever said realizer's selection state is changed to false and the current selectionPolicy is RELATE_TO_NODE_SELECTION.
protected  void rowEventHappened(Graph2D graph, TableGroupNodeRealizer.Row row, boolean modifierPressed)
          Handles (non-cyclic) selection state changes for the specified row.
protected  void rowEventHappened(Graph2D graph, TableGroupNodeRealizer.Row row, Mouse2DEvent event)
          Handles selection state changes for the specified row.
protected  boolean rowSelectionHit(TableGroupNodeRealizer.Row row, double x, double y)
          Determines whether a mouse click at the specified hit location should change the selection state of the specified row.
protected  void setColumnSelectionState(TableGroupNodeRealizer.Column column, boolean newState)
          Sets the selection state of the given column.
 void setContext(Graph2DView view, MultiplexingNodeEditor parent, NodeRealizer realizer)
          Provides context information for the editor.
 void setCyclicSelectionEnabled(boolean enabled)
          Specifies whether or not selection cycling should be enabled.
 void setExtendedSelectionHitEnabled(boolean enabled)
          Specifies whether the editor may change the selection state of columns and rows that have no children upon hits outside of the column's top inset area or the row's left inset area.
 void setMixedSelectionEnabled(boolean enabled)
          Specifies whether or not the editor should allow mixed multi-selections of columns and rows in a table.
protected  void setRealizerSelectionState(TableGroupNodeRealizer realizer, boolean newState)
          Sets the selection state of the given table node realizer.
protected  void setRowSelectionState(TableGroupNodeRealizer.Row row, boolean newState)
          Sets the selection state of the given row.
 void setSelectionPolicy(byte selectionPolicy)
          Specifies the selection policy of the editor.
 void setUnselectOnTableBorderEnabled(boolean enabled)
          Specifies whether clicking on the table border should unselect selected columns and rows.
 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.
protected  void tableEventHappened(Graph2D graph, TableGroupNodeRealizer.Table table, boolean modifierPressed)
          Handles (non-cyclic) selection state changes for the realizer associated to the specified table.
protected  void tableEventHappened(Graph2D graph, TableGroupNodeRealizer.Table table, Mouse2DEvent event)
          Handles selection state changes for the realizer associated to the specified table.
 
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

IGNORE_NODE_SELECTION

public static final byte IGNORE_NODE_SELECTION
Using this selection policy the selection states of rows/columns and their TableGroupNodeRealizer are not related to each other.

See Also:
getSelectionPolicy(), setSelectionPolicy(byte), Constant Field Values

RELATE_TO_NODE_SELECTION

public static final byte RELATE_TO_NODE_SELECTION
Using this selection policy the selection states of rows/columns and their TableGroupNodeRealizer are related to each other. The selection of a row or column results in the selection of the realizer and on deselecting the realizer it's rows and columns are deselected as well.

See Also:
getSelectionPolicy(), setSelectionPolicy(byte), Constant Field Values
Constructor Detail

TableSelectionEditor

public TableSelectionEditor()
The default constructor of this class.

Method Detail

isValidStartPosition

public boolean isValidStartPosition(double x,
                                    double y)
The given position is considered to be valid if it is inside the left inset of a TableGroupNodeRealizer.Row or the top inset of a TableGroupNodeRealizer.Column.

Specified by:
isValidStartPosition in interface MultiplexingNodeEditor.NodeEditor
Parameters:
x - The horizontal position to check.
y - The vertical position to check.
Returns:
true, if the given position is inside the left inset of a TableGroupNodeRealizer.Row or the top inset of a TableGroupNodeRealizer.Column; false otherwise.

columnSelectionHit

protected boolean columnSelectionHit(TableGroupNodeRealizer.Column column,
                                     double x,
                                     double y)
Determines whether a mouse click at the specified hit location should change the selection state of the specified column.

Parameters:
column - the Column to check.
x - the x-coordinate of the hit location.
y - the y-coordinate of the hit location.
Returns:
true if the selection state of specified column should change; false otherwise.

rowSelectionHit

protected boolean rowSelectionHit(TableGroupNodeRealizer.Row row,
                                  double x,
                                  double y)
Determines whether a mouse click at the specified hit location should change the selection state of the specified row.

Parameters:
row - the Row to check.
x - the x-coordinate of the hit location.
y - the y-coordinate of the hit location.
Returns:
true if the selection state of specified column should change; false otherwise.

isSelectionModifierPressed

protected boolean isSelectionModifierPressed(Mouse2DEvent event)
Determines whether or not the specified event should result in expanding the current selection to include the clicked element instead of changing the selection to the clicked element.

The default implementation checks if SHIFT is pressed.

Parameters:
event - The mouse event to check.
Returns:
true, if SHIFT was pressed in the event; false otherwise.

isCyclicSelectionModifierPressed

protected boolean isCyclicSelectionModifierPressed(Mouse2DEvent event)
Determines whether or not the specified event should result in cycling the selection through the elements at the current mouse position (if selection cycling is enabled).

The default implementation checks if CTRL is pressed.

Parameters:
event - the triggering event.
Returns:
true if the specified event should result in selection cycling and false otherwise.
See Also:
isCyclicSelectionEnabled(), setCyclicSelectionEnabled(boolean)

onGraph2DSelectionEvent

public void onGraph2DSelectionEvent(Graph2DSelectionEvent event)
Sets the selection state of all columns and rows of a TableGroupNodeRealizer's table model to false whenever said realizer's selection state is changed to false and the current selectionPolicy is RELATE_TO_NODE_SELECTION.

Specified by:
onGraph2DSelectionEvent in interface Graph2DSelectionListener
Parameters:
event - The selection event to check.

getSelectionPolicy

public byte getSelectionPolicy()
Return the current selection policy.

The selection policy determines if the selection states of TableGroupNodeRealizer.Rows and TableGroupNodeRealizer.Columns are related to the selection state of their TableGroupNodeRealizer.

The default setting of this policy is IGNORE_NODE_SELECTION.

Returns:
either IGNORE_NODE_SELECTION or RELATE_TO_NODE_SELECTION.
See Also:
setSelectionPolicy(byte)

setSelectionPolicy

public void setSelectionPolicy(byte selectionPolicy)
Specifies the selection policy of the editor.

Parameters:
selectionPolicy - one of
Throws:
java.lang.IllegalArgumentException - if selectionPolicy does not equal on of the selection policy constants.
See Also:
getSelectionPolicy()

isUnselectOnTableBorderEnabled

public boolean isUnselectOnTableBorderEnabled()
Returns true if clicking on the table border will unselect all selected columns and rows and false otherwise. In this context the table border is defined as the area that does not belong to any column or row.

By default, this property is set to true.

Returns:
true if clicking on the table border will unselect all selected columns and rows and false otherwise.
See Also:
setUnselectOnTableBorderEnabled(boolean)

setUnselectOnTableBorderEnabled

public void setUnselectOnTableBorderEnabled(boolean enabled)
Specifies whether clicking on the table border should unselect selected columns and rows. In this context the table border is defined as the area that does not belong to any column or row.

By default, this property is set to true.

Parameters:
enabled - true if clicking on the table border should unselect all selected columns and rows and false otherwise.
See Also:
isUnselectOnTableBorderEnabled()

isMixedSelectionEnabled

public boolean isMixedSelectionEnabled()
Returns true if the editor allows mixed multi-selections of columns and rows in a table and false otherwise.

Returns:
true if the editor allows mixed multi-selections of columns and rows in a table and false otherwise.

setMixedSelectionEnabled

public void setMixedSelectionEnabled(boolean enabled)
Specifies whether or not the editor should allow mixed multi-selections of columns and rows in a table.

Parameters:
enabled - true if the editor should allow mixed multi-selections of columns and rows in a table and false otherwise.

isCyclicSelectionEnabled

public boolean isCyclicSelectionEnabled()
Determines whether or not selection cycling is enabled.

Returns:
true if selection cycling is enabled and false otherwise.
See Also:
setCyclicSelectionEnabled(boolean), isCyclicSelectionEvent(y.view.Mouse2DEvent)

setCyclicSelectionEnabled

public void setCyclicSelectionEnabled(boolean enabled)
Specifies whether or not selection cycling should be enabled.

Parameters:
enabled - if true, selection cycling is enabled.
See Also:
isCyclicSelectionEnabled(), isCyclicSelectionEvent(y.view.Mouse2DEvent)

isExtendedSelectionHitEnabled

public boolean isExtendedSelectionHitEnabled()
Returns true if the editor should change the selection state of columns and rows that have no children upon hits outside of the column's top inset area or the row's left inset area and false otherwise. Note, that even if this property is true a column selection state change is only triggered outside of any rows and a row selection state change is only triggered outside of any columns.

By default, this property is true.

Returns:
true if the editor should change the selection state of columns and rows that have no children upon hits outside of the column's top inset area or the row's left inset area and false otherwise.
See Also:
setExtendedSelectionHitEnabled(boolean), columnSelectionHit(y.view.tabular.TableGroupNodeRealizer.Column, double, double), rowSelectionHit(y.view.tabular.TableGroupNodeRealizer.Row, double, double)

setExtendedSelectionHitEnabled

public void setExtendedSelectionHitEnabled(boolean enabled)
Specifies whether the editor may change the selection state of columns and rows that have no children upon hits outside of the column's top inset area or the row's left inset area.

By default, this property is true.

Parameters:
enabled - if true the editor may change the selection state upon hits outside of the column's top inset area or the row's left inset area; if false only hits inside a column's top inset area or a row's left inset area will trigger selection state changes.
See Also:
isExtendedSelectionHitEnabled(), columnSelectionHit(y.view.tabular.TableGroupNodeRealizer.Column, double, double), rowSelectionHit(y.view.tabular.TableGroupNodeRealizer.Row, double, double)

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.

Specified by:
startsEditing in interface MouseInputEditor
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.

Specified by:
mouse2DEventHappened in interface MouseInputEditor
Parameters:
event - the event that happened
See Also:
MouseInputEditor.isInterestedInEvents()

columnEventHappened

protected void columnEventHappened(Graph2D graph,
                                   TableGroupNodeRealizer.Column column,
                                   Mouse2DEvent event)
Handles selection state changes for the specified column.

Calls columnEventHappened(y.view.Graph2D, y.view.tabular.TableGroupNodeRealizer.Column, boolean) if no cyclic selection change is required.

Parameters:
graph - the Graph2D that holds the table node to which the specified column belongs.
column - the Column whose selection state should be changed.
event - the event that triggered the selection state change.
See Also:
isCyclicSelectionEnabled(), isCyclicSelectionEvent(y.view.Mouse2DEvent)

columnEventHappened

protected void columnEventHappened(Graph2D graph,
                                   TableGroupNodeRealizer.Column column,
                                   boolean modifierPressed)
Handles (non-cyclic) selection state changes for the specified column.

Called from columnEventHappened(y.view.Graph2D, y.view.tabular.TableGroupNodeRealizer.Column, y.view.Mouse2DEvent) if no cyclic selection change is required.

Parameters:
graph - the Graph2D that holds the table node to which the specified column belongs.
column - the Column whose selection state should be changed.
modifierPressed - the result of isSelectionModifierPressed(y.view.Mouse2DEvent) for the event that triggered the selection state change of the specified column.

rowEventHappened

protected void rowEventHappened(Graph2D graph,
                                TableGroupNodeRealizer.Row row,
                                Mouse2DEvent event)
Handles selection state changes for the specified row.

Calls rowEventHappened(y.view.Graph2D, y.view.tabular.TableGroupNodeRealizer.Row, boolean) if no cyclic selection change is required.

Parameters:
graph - the Graph2D that holds the table node to which the specified row belongs.
row - the Row whose selection state should be changed.
event - the event that triggered the selection state change.
See Also:
isCyclicSelectionEnabled(), isCyclicSelectionEvent(y.view.Mouse2DEvent)

rowEventHappened

protected void rowEventHappened(Graph2D graph,
                                TableGroupNodeRealizer.Row row,
                                boolean modifierPressed)
Handles (non-cyclic) selection state changes for the specified row.

Called from rowEventHappened(y.view.Graph2D, y.view.tabular.TableGroupNodeRealizer.Row, y.view.Mouse2DEvent) if no cyclic selection change is required.

Parameters:
graph - the Graph2D that holds the table node to which the specified row belongs.
row - the Row whose selection state should be changed.
modifierPressed - the result of isSelectionModifierPressed(y.view.Mouse2DEvent) for the event that triggered the selection state change of the specified row.

tableEventHappened

protected void tableEventHappened(Graph2D graph,
                                  TableGroupNodeRealizer.Table table,
                                  Mouse2DEvent event)
Handles selection state changes for the realizer associated to the specified table.

Calls tableEventHappened(y.view.Graph2D, y.view.tabular.TableGroupNodeRealizer.Table, boolean) if no cyclic selection change is required.

Parameters:
graph - the Graph2D that holds the table node.
table - the Table whose associated realizer's selection state should be changed.
event - the event that triggered the selection state change.
See Also:
isCyclicSelectionEnabled(), isCyclicSelectionEvent(y.view.Mouse2DEvent)

tableEventHappened

protected void tableEventHappened(Graph2D graph,
                                  TableGroupNodeRealizer.Table table,
                                  boolean modifierPressed)
Handles (non-cyclic) selection state changes for the realizer associated to the specified table.

Called from tableEventHappened(y.view.Graph2D, y.view.tabular.TableGroupNodeRealizer.Table, y.view.Mouse2DEvent) if no cyclic selection change is required.

Parameters:
graph - the Graph2D that holds the table node.
table - the Table whose associated realizer's selection state should be changed.
modifierPressed - the result of isSelectionModifierPressed(y.view.Mouse2DEvent) for the event that triggered the selection state change.

setRealizerSelectionState

protected void setRealizerSelectionState(TableGroupNodeRealizer realizer,
                                         boolean newState)
Sets the selection state of the given table node realizer. This method is used by this editor and can be customized in subclasses. The default implementation selects the node represented by the specified realizer as well as all selfloops that are incident to said node if the specified selection state is true.

Parameters:
realizer - a table node realizer
newState - the new selection state for the realizer

setColumnSelectionState

protected void setColumnSelectionState(TableGroupNodeRealizer.Column column,
                                       boolean newState)
Sets the selection state of the given column. This method is used by this editor and can be customized in subclasses. The default implementation just uses TableGroupNodeRealizer.Column.setSelected(boolean).

Parameters:
column - a column
newState - the new selection state for the column

setRowSelectionState

protected void setRowSelectionState(TableGroupNodeRealizer.Row row,
                                    boolean newState)
Sets the selection state of the given row. This method is used by this editor and can be customized in subclasses. The default implementation just uses TableGroupNodeRealizer.Row.setSelected(boolean).

Parameters:
row - a row
newState - the new selection state for the row

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.

getCursor

public java.awt.Cursor getCursor(Mouse2DEvent event)
Description copied from interface: MultiplexingNodeEditor.NodeEditor
Returns a mouse cursor to indicate what action this event could trigger or null if the editor does not want to initiate a cursor change.

Specified by:
getCursor in interface MultiplexingNodeEditor.NodeEditor
Parameters:
event - The mouse event a cursor can be returned for.
Returns:
A Cursor if a possible action for this mouse event shall be indicated or null.

stopEditing

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

Specified by:
stopEditing in interface MouseInputEditor
Overrides:
stopEditing in class AbstractMouseInputEditor

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