Packagecom.yworks.graph.model
Classpublic class TableUtils
InheritanceTableUtils Inheritance Object

A set of static helper Methods to work with ITable or IStripe instances.



Public Methods
 MethodDefined By
  
clear(table:ITable):void
[static] Convenience method that clears all stripes from a table.
TableUtils
  
createGrid(table:ITable, columns:int, rows:int):void
[static] Convenience method that creates the given number of columns and rows in the given table.
TableUtils
  
findStripe(x:Number, y:Number, stripeTypes:uint, canvas:CanvasComponent, subregions:StripeSubregion = null, predicate:Function = null):StripeSubregionDescriptor
[static] Convenience method to find the item at certain coordinates.
TableUtils
  
findStripes(x:Number, y:Number, stripeTypes:uint, canvas:CanvasComponent, subregions:StripeSubregion = null, predicate:Function = null):Iterable
[static] Convenience method to find the items at certain coordinates.
TableUtils
  
[static] Returns the layout of the stripe in absolute coordinates.
TableUtils
  
[static] Return the accumulated insets for the table.
TableUtils
  
getActualSize(item:IStripe):Number
[static] The current actual dimension of the stripe.
TableUtils
  
[static] Returns the number of children of the given stripe.
TableUtils
  
[static] Gets the direct children of the given stripe in a table hierarchy.
TableUtils
  
getColumnAtPosition(canvas:CanvasComponent, x:Number, y:Number):IColumn
[static] Returns the IColumn at the given view coordinates if there is any or null otherwise.
TableUtils
  
[static] Returns a collection of all descendants of the given stripe.
TableUtils
  
[static] Returns the actual minimum size a stripe can acquire.
TableUtils
  
getIndex(stripe:IStripe):int
[static] Gets the index of the given stripe in its parent's collection of children.
TableUtils
  
[static] Gets a list with the leaves of the given stripe.
TableUtils
  
[static] Gets the parent of the given stripe in a table hierarchy.
TableUtils
  
[static] Gets the root stripe of the given stripe.
TableUtils
  
getRowAtPosition(canvas:CanvasComponent, x:Number, y:Number):IRow
[static] Returns the IRow at the given view coordinates if there is any or null otherwise.
TableUtils
  
[static] Tries to get the node which is related to the given table.
TableUtils
  
getTableNodeAtPosition(canvas:CanvasComponent, x:Number, y:Number):INode
[static] Returns the INode with a table at the given view coordinates if there is any or null otherwise.
TableUtils
  
isRoot(stripe:IStripe):Boolean
[static] Whether the given stripe is a root stripe.
TableUtils
  
placeInCell(graph:IGraph, tableNode:INode, nodeToPlace:INode, column:IColumn, row:IRow):void
[static] Convenience method to place the given node inside the table cell which is specified by the given row and column.
TableUtils
  
removeRecursively(table:ITable, stripe:IStripe):void
[static] Removes the given stripe and all of its descendants from the given table.
TableUtils
  
removeWithResize(table:ITable, stripe:IStripe):void
[static] Removes the given stripe from the table and resizes all affected stripes so that the table size does not change if possible.
TableUtils
Public Constants
 ConstantDefined By
  TABLE_MAPPER_ID : String = com.yworks.graph.model.TableUtils.TableMapperId
[static] Constants which defines a well known mapper key to store tables in.
TableUtils
Method Detail
clear()method
public static function clear(table:ITable):void

Convenience method that clears all stripes from a table.

All existing rows and columns are cleared from the table.

Parameters

table:ITable — The table to use.

createGrid()method 
public static function createGrid(table:ITable, columns:int, rows:int):void

Convenience method that creates the given number of columns and rows in the given table.

All existing rows and columns are cleared from the table.

Parameters

table:ITable — The table to use.
 
columns:int — The number of columns to test.
 
rows:int — The number of rows to test.

findStripe()method 
public static function findStripe(x:Number, y:Number, stripeTypes:uint, canvas:CanvasComponent, subregions:StripeSubregion = null, predicate:Function = null):StripeSubregionDescriptor

Convenience method to find the item at certain coordinates.

Parameters

x:Number — The x coordinate to test.
 
y:Number — The y coordinate to test.
 
stripeTypes:uint — One of the StripeType constants to specify the stripe type.
 
canvas:CanvasComponent — The canvas that provides necessary context for hit determination, such as ICanvasContext.hitTestRadius.
 
subregions:StripeSubregion (default = null) — An enumeration value of StripeSubregion to further restrict the stripe region. If none is provided the first hit stripe will be returned, regardless of its sub region.
 
predicate:Function (default = null) — A function with the signature function(descriptor:StripeSubregionDescriptor):Boolean which returns true if the given descriptor describes a valid hit.

Returns
StripeSubregionDescriptor — The stripe subregions that have been found for the location or null.

See also

findStripes()method 
public static function findStripes(x:Number, y:Number, stripeTypes:uint, canvas:CanvasComponent, subregions:StripeSubregion = null, predicate:Function = null):Iterable

Convenience method to find the items at certain coordinates.

Parameters

x:Number — The x coordinate to test.
 
y:Number — The y coordinate to test.
 
stripeTypes:uint — One of the StripeType constants to specify the stripe type.
 
canvas:CanvasComponent — The canvas that provides necessary context for hit determination, such as ICanvasContext.hitTestRadius.
 
subregions:StripeSubregion (default = null) — An enumeration value of StripeSubregion to further restrict the stripe region. If none is provided the first hit stripe will be returned, regardless of its sub region.
 
predicate:Function (default = null) — A function with the signature function(descriptor:StripeSubregionDescriptor):Boolean which returns true if the given descriptor describes a valid hit.

Returns
Iterable — The stripe subregions that have been found for the location or an empty Iterable.

See also

getAbsoluteLayout()method 
public static function getAbsoluteLayout(item:IStripe, owner:INode):YRectangle

Returns the layout of the stripe in absolute coordinates.

Since IStripe.layout is relative to the owning node's left corner, you need to provide an owner node to calculate the absolute layout.

Parameters

item:IStripe — The stripe to calculate the layout for.
 
owner:INode — The node relative to which the stripe layout is calculated. This should be the same node where IStripe.table for the given stripe is associated to.

Returns
YRectangle — The absolute layout of the stripe.
getAccumulatedInsets()method 
public static function getAccumulatedInsets(table:ITable):IRectangle

Return the accumulated insets for the table.

Parameters

table:ITable — The table to get the insets for.

Returns
IRectangle — The accumulated insets for the table.
getActualSize()method 
public static function getActualSize(item:IStripe):Number

The current actual dimension of the stripe.

This is always the stripe size which is actually used for the stripe. For leaf stripes, this is the same as IStripe.size, otherwise, it is the accumulated size of all descendants with taking nested insets into account.

Parameters

item:IStripe — The stripe to calculate the actual size for.

Returns
Number — The actual size of the stripe.
getChildCount()method 
public static function getChildCount(stripe:IStripe):int

Returns the number of children of the given stripe.

Parameters

stripe:IStripe — The stripe.

Returns
int — The number of children of the given stripe.
getChildren()method 
public static function getChildren(stripe:IStripe):Iterable

Gets the direct children of the given stripe in a table hierarchy.

For IColumn instances, this returns IColumn.columns, for IRow instances, this returns IRow.rows

Parameters

stripe:IStripe — The item to query.

Returns
Iterable — The children of the given stripe

See also

getColumnAtPosition()method 
public static function getColumnAtPosition(canvas:CanvasComponent, x:Number, y:Number):IColumn

Returns the IColumn at the given view coordinates if there is any or null otherwise.

Parameters

canvas:CanvasComponent — The graphCanvas to search in.
 
x:Number — horizontal coordinate.
 
y:Number — vertical coordinate.

Returns
IColumn — Returns the IColumn at the given view coordinates if there is any or null otherwise.
getDescendants()method 
public static function getDescendants(stripe:IStripe):Iterable

Returns a collection of all descendants of the given stripe.

The descendants are returned in top to bottom order.

Parameters

stripe:IStripe — The stripe to query.

Returns
Iterable — A collection of all descendants of the stripe.
getEffectiveMinSize()method 
public static function getEffectiveMinSize(item:IStripe):Number

Returns the actual minimum size a stripe can acquire.

This is the maximum of IStripe.minimumSize and the horizontal or vertical IStripe.insets.

Parameters

item:IStripe — The stripe to get the minimum size for.

Returns
Number — The minimum size of the given stripe.
getIndex()method 
public static function getIndex(stripe:IStripe):int

Gets the index of the given stripe in its parent's collection of children.

stripe is the getIndexth child of its parent.

Parameters

stripe:IStripe — The item to query.

Returns
int — The index of the given stripe in the stripe's parent's collection of children.
getLeaves()method 
public static function getLeaves(container:IStripe):ArrayList

Gets a list with the leaves of the given stripe.

Parameters

container:IStripe — The stripe to get the leaves for.

Returns
ArrayList — A list with the leaves.
getParent()method 
public static function getParent(stripe:IStripe):IStripe

Gets the parent of the given stripe in a table hierarchy.

For IColumn or IRow instances, this returns the owner

Parameters

stripe:IStripe — The item to query.

Returns
IStripe — The parent of the given stripe.
getRoot()method 
public static function getRoot(stripe:IStripe):IStripe

Gets the root stripe of the given stripe.

Parameters

stripe:IStripe — The stripe to search the root for.

Returns
IStripe — The root of the given stripe.
getRowAtPosition()method 
public static function getRowAtPosition(canvas:CanvasComponent, x:Number, y:Number):IRow

Returns the IRow at the given view coordinates if there is any or null otherwise.

Parameters

canvas:CanvasComponent — The canvas to search in.
 
x:Number — horizontal coordinate.
 
y:Number — vertical coordinate.

Returns
IRow — Returns the IRow at the given view coordinates if there is any or null otherwise.
getTableNode()method 
public static function getTableNode(table:ITable, graph:IGraph):INode

Tries to get the node which is related to the given table.

Parameters

table:ITable — The table to look up the node.
 
graph:IGraph — The graph to look for the node.

Returns
INode — The node which is associated with the table. May be null.
getTableNodeAtPosition()method 
public static function getTableNodeAtPosition(canvas:CanvasComponent, x:Number, y:Number):INode

Returns the INode with a table at the given view coordinates if there is any or null otherwise.

Parameters

canvas:CanvasComponent — The canvas component to search in.
 
x:Number — horizontal coordinate.
 
y:Number — vertical coordinate.

Returns
INode — Returns the INode at the given view coordinates if there is any or null otherwise.
isRoot()method 
public static function isRoot(stripe:IStripe):Boolean

Whether the given stripe is a root stripe.

Parameters

stripe:IStripe — The stripe.

Returns
Booleantrue if the stripe is the root stripe of a table.
placeInCell()method 
public static function placeInCell(graph:IGraph, tableNode:INode, nodeToPlace:INode, column:IColumn, row:IRow):void

Convenience method to place the given node inside the table cell which is specified by the given row and column. The node will be placed at the center of the given column and row.

This may be done in preparation for an automatic layout to specify the table cell the layouter places the nodes in.

The row and column must be part of the table which is represented by the tableNode, otherwise an IllegalOperationError will be thrown.

Parameters

graph:IGraph — The graph the nodes belong to.
 
tableNode:INode — The node which is bound to the table the column and row belong to.
 
nodeToPlace:INode — The node to place.
 
column:IColumn — The column to place the node in.
 
row:IRow — The row to place the node in.


Throws
IllegalOperationError — if
  • The tableNode represents a different table than the table column and row are in.
  • nodeToPlace is not in graph
  • graph is not grouped.
removeRecursively()method 
public static function removeRecursively(table:ITable, stripe:IStripe):void

Removes the given stripe and all of its descendants from the given table.

This method does not resize any stripes, use removeRecursivelyWithResize instead.

Parameters

table:ITable — The table to use.
 
stripe:IStripe — The stripe to remove.

removeWithResize()method 
public static function removeWithResize(table:ITable, stripe:IStripe):void

Removes the given stripe from the table and resizes all affected stripes so that the table size does not change if possible.

Parameters

table:ITable — The table to use.
 
stripe:IStripe — The stripe to remove.

Constant Detail
TABLE_MAPPER_IDConstant
public static const TABLE_MAPPER_ID:String = com.yworks.graph.model.TableUtils.TableMapperId

Constants which defines a well known mapper key to store tables in.

A GraphMLIOHandler will automatically create a mapper with this key if readTables is enabled. When the read graph is morphed to a canvas's graph using GraphCanvasComponent.morphGraph() the contents of this mapper are automatically transferred to the correct table holder, e.g. a TableNodeStyle's table. If morphGraph() is not invoked it is up to the developer to transfer the contents of this mapper to a meaningful table holder.

See also