ptolemy.actor.gt
Class GTEntityUtils

java.lang.Object
  extended by ptolemy.actor.gt.GTEntityUtils

public class GTEntityUtils
extends java.lang.Object

A set of utilities for handling GTEntities (instances of GTEntity).

Since:
Ptolemy II 7.1
Version:
$Id: GTEntityUtils.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Thomas Huining Feng
Accepted Rating:
Red (tfeng)
Proposed Rating:
Yellow (tfeng)

Nested Class Summary
private static class GTEntityUtils.LoadActorIconChangeRequest
          A change request to copy the icon of a newly created entity within a container to a given GTEntity.
private static class GTEntityUtils.RestoreAppearanceChangeRequest
          A change request to restore the default icon of an entity.
 
Constructor Summary
GTEntityUtils()
           
 
Method Summary
private static void _loadActorIcon(GTEntity entity, java.lang.String actorClassName)
          Load the default icon of the actor specified in the class with name actorClassName, and set the entity with that icon.
private static boolean _removeEditorIcons(GTEntity entity)
          Remove the EditorIcons defined for the entity.
private static void _setIconDescription(GTEntity entity, java.lang.String iconDescription)
          Set the icon description for the entity.
static void exportPortProperties(GTEntity entity, java.io.Writer output, int depth)
          For each port of the given entity, if the port's derived level is greater than 0 (i.e., it is created automatically by the entity), store the persistent attributes of the port in a "port" XML element.
static void updateAppearance(GTEntity entity, GTIngredientsAttribute attribute)
          Update the appearance (icons and ports) of the entity with the change in a GTIngredientAttribute, such as a criterion or an operation.
static void valueChanged(GTEntity entity, Settable settable)
          React to change of a settable contained in the entity and update the entity's appearance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GTEntityUtils

public GTEntityUtils()
Method Detail

exportPortProperties

public static void exportPortProperties(GTEntity entity,
                                        java.io.Writer output,
                                        int depth)
                                 throws java.io.IOException
For each port of the given entity, if the port's derived level is greater than 0 (i.e., it is created automatically by the entity), store the persistent attributes of the port in a "port" XML element.

Parameters:
entity - The entity whose ports are looked at.
output - The output writer.
depth - The depth for the MoML output.
Throws:
java.io.IOException - If the output writer cannot be written to.

updateAppearance

public static void updateAppearance(GTEntity entity,
                                    GTIngredientsAttribute attribute)
Update the appearance (icons and ports) of the entity with the change in a GTIngredientAttribute, such as a criterion or an operation.

Parameters:
entity - The entity.
attribute - The attribute whose recent change leads to an update of the entity.

valueChanged

public static void valueChanged(GTEntity entity,
                                Settable settable)
React to change of a settable contained in the entity and update the entity's appearance.

Parameters:
entity - The entity that contains the settable.
settable - The settable whose value is changed.
See Also:
ValueListener.valueChanged(Settable)

_loadActorIcon

private static void _loadActorIcon(GTEntity entity,
                                   java.lang.String actorClassName)
                            throws java.lang.Exception
Load the default icon of the actor specified in the class with name actorClassName, and set the entity with that icon.

Parameters:
entity - The entity whose icon is to be set.
actorClassName - The class name of the actor for loading the default icon.
Throws:
java.lang.Exception - If the icon cannot be set for the entity.

_removeEditorIcons

private static boolean _removeEditorIcons(GTEntity entity)
                                   throws KernelException
Remove the EditorIcons defined for the entity.

Parameters:
entity - The entity.
Returns:
true if at least one EditorIcon is found and removed; false otherwise.
Throws:
KernelException - If error occurs while removing the EditorIcons.

_setIconDescription

private static void _setIconDescription(GTEntity entity,
                                        java.lang.String iconDescription)
                                 throws java.lang.Exception
Set the icon description for the entity.

Parameters:
entity - The entity.
iconDescription - The icon description.
Throws:
java.lang.Exception - If an icon description cannot be created, or it cannot be associated with the entity.