ptolemy.moml.filter
Class GRColorChanges

java.lang.Object
  extended by ptolemy.moml.filter.GRColorChanges
All Implemented Interfaces:
MoMLFilter

public class GRColorChanges
extends java.lang.Object
implements MoMLFilter

This class filters MoML files for backward compatibility between GR models constructed in version 4.0 or earlier. In particular, it handles the switch to using ColorAttribute for all colors, plus some parameter renaming. It also handles some conversions from matrix parameters to arrays.

Since:
Ptolemy II 4.1
Version:
$Id: GRColorChanges.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Edward A. Lee
Accepted Rating:
Red (cxh)
Proposed Rating:
Yellow (eal)

Field Summary
private static java.util.HashSet _actorsWithRGBColor
          Set of actors with parameter named "RGB color"
private  boolean _foundOne
          Flag indicating that we found one whose name needed changing.
 
Constructor Summary
GRColorChanges()
           
 
Method Summary
 java.lang.String filterAttributeValue(NamedObj container, java.lang.String element, java.lang.String attributeName, java.lang.String attributeValue, java.lang.String xmlFile)
          Handle parameter name changes.
 void filterEndElement(NamedObj container, java.lang.String elementName, java.lang.StringBuffer currentCharData, java.lang.String xmlFile)
          If the container is a property named "diffuseColor" contained by one of the GR actors, then check the format of its parameter to change it, if necessary, from matrix format to array format.
 java.lang.String toString()
          Return a string that describes what the filter does.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_actorsWithRGBColor

private static java.util.HashSet _actorsWithRGBColor
Set of actors with parameter named "RGB color"


_foundOne

private boolean _foundOne
Flag indicating that we found one whose name needed changing.

Constructor Detail

GRColorChanges

public GRColorChanges()
Method Detail

filterAttributeValue

public java.lang.String filterAttributeValue(NamedObj container,
                                             java.lang.String element,
                                             java.lang.String attributeName,
                                             java.lang.String attributeValue,
                                             java.lang.String xmlFile)
Handle parameter name changes.

Specified by:
filterAttributeValue in interface MoMLFilter
Parameters:
container - The container for XML element.
element - The XML element name.
attributeName - The name of the attribute.
attributeValue - The value of the attribute.
xmlFile - The file currently being parsed.
Returns:
A new value for the attribute, or the same value to leave it unchanged, or null to cause the current element to be ignored (unless the attributeValue argument is null).

filterEndElement

public void filterEndElement(NamedObj container,
                             java.lang.String elementName,
                             java.lang.StringBuffer currentCharData,
                             java.lang.String xmlFile)
                      throws java.lang.Exception
If the container is a property named "diffuseColor" contained by one of the GR actors, then check the format of its parameter to change it, if necessary, from matrix format to array format. Also fix the background color of ViewScreen3D. If the property name is "polygon" contained by an instance of PolyCylinder3D, perform a similar change from matrix to array.

Specified by:
filterEndElement in interface MoMLFilter
Parameters:
container - The object defined by the element that this is the end of.
elementName - The element name.
currentCharData - The character data, which appears only in the doc and configure elements
xmlFile - The file currently being parsed.
Throws:
java.lang.Exception - if there is a problem substituting in the new value.

toString

public java.lang.String toString()
Return a string that describes what the filter does.

Specified by:
toString in interface MoMLFilter
Overrides:
toString in class java.lang.Object
Returns:
A description of the filter (ending with a newline).