ptolemy.vergil.icon
Class TableIcon

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.util.Attribute
          extended by ptolemy.vergil.icon.EditorIcon
              extended by ptolemy.vergil.icon.DynamicEditorIcon
                  extended by ptolemy.vergil.icon.TableIcon
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

public class TableIcon
extends DynamicEditorIcon

An icon that displays the value of a variable of the container in a table. The attribute is assumed to be an instance of Variable, and its name is given by the parameter variableName. Its value must be an array of records. A subset of the fields in the records given by the fields parameter is displayed in the icon.

Since:
Ptolemy II 8.0
Version:
$Id: TableIcon.java 57044 2010-01-27 22:41:05Z cxh $
Author:
Edward A. Lee
See Also:
Serialized Form
Accepted Rating:
Red (johnr)
Proposed Rating:
Yellow (eal)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
 
Field Summary
protected static double _HORIZONTAL_PADDING
          The amount of padding to use around the edges.
protected static java.awt.Font _labelFont
          The font used.
protected static double _VERTICAL_PADDING
          The amount of padding to use around the edges.
 ColorAttribute boxColor
          Color of the box.
 StringParameter colorKey
          A column name to use as a color key.
 Parameter fields
          The fields to display in the table.
 Parameter maxRows
          The maximum number of rows to display.
 StringParameter variableName
          The name of the variable in the container whose value should be displayed in the icon.
 
Fields inherited from class ptolemy.vergil.icon.EditorIcon
_containerToBe, _iconCache
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Constructor Summary
TableIcon(NamedObj container, java.lang.String name)
          Create a new icon with the given name in the given container.
 
Method Summary
private  LabelFigure _labelFigure(RecordToken row, java.lang.String column)
          Return a label figure for the specified token.
private  java.awt.Color _uniqueColor(java.lang.Object object)
           
 Figure createBackgroundFigure()
          Create a new background figure.
 
Methods inherited from class ptolemy.vergil.icon.DynamicEditorIcon
_addLiveFigure, _liveFigureIterator, _trimLiveFigures, clone
 
Methods inherited from class ptolemy.vergil.icon.EditorIcon
_createDefaultBackgroundFigure, _isPropertySet, _recreateFigure, createFigure, createIcon, getContainerOrContainerToBe, setContainerToBe
 
Methods inherited from class ptolemy.kernel.util.Attribute
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setContainer, setName, updateContent
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _description, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, propagateExistence, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

boxColor

public ColorAttribute boxColor
Color of the box. This defaults to white.


colorKey

public StringParameter colorKey
A column name to use as a color key. If this string is non-empty, then it specifies a column name that is used to determine a color for each row. The value in that row and column determines the color via a hash function, so that if two rows are identical in that column, then they are also identical in color. This is a string that defaults to empty, indicating that all rows should be displayed in black.


fields

public Parameter fields
The fields to display in the table. This is an array of strings specifying the field names to display. It defaults to ALL, which indicates that all fields should be displayed.


maxRows

public Parameter maxRows
The maximum number of rows to display. This is an integer, with default value UNBOUNDED.


variableName

public StringParameter variableName
The name of the variable in the container whose value should be displayed in the icon. The variable value must be an array of records. This is a string that defaults to the empty string.


_labelFont

protected static final java.awt.Font _labelFont
The font used.


_HORIZONTAL_PADDING

protected static final double _HORIZONTAL_PADDING
The amount of padding to use around the edges.

See Also:
Constant Field Values

_VERTICAL_PADDING

protected static final double _VERTICAL_PADDING
The amount of padding to use around the edges.

See Also:
Constant Field Values
Constructor Detail

TableIcon

public TableIcon(NamedObj container,
                 java.lang.String name)
          throws NameDuplicationException,
                 IllegalActionException
Create a new icon with the given name in the given container. The container is required to implement Settable, or an exception will be thrown.

Parameters:
container - The container for this attribute.
name - The name of this attribute.
Throws:
IllegalActionException - If thrown by the parent class or while setting an attribute
NameDuplicationException - If the name coincides with an attribute already in the container.
Method Detail

createBackgroundFigure

public Figure createBackgroundFigure()
Create a new background figure. This overrides the base class to draw a box around the value display, where the width of the box depends on the value.

Overrides:
createBackgroundFigure in class EditorIcon
Returns:
A new figure.

_labelFigure

private LabelFigure _labelFigure(RecordToken row,
                                 java.lang.String column)
Return a label figure for the specified token.

Parameters:
row - The row.
column - The column.
Returns:
A label figure.

_uniqueColor

private java.awt.Color _uniqueColor(java.lang.Object object)