Class GRColorChanges

  • All Implemented Interfaces:
    MoMLFilter

    public class GRColorChanges
    extends MoMLFilterSimple
    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$
    Author:
    Edward A. Lee
    Pt.AcceptedRating:
    Red (cxh)
    Pt.ProposedRating:
    Yellow (eal)
    • Constructor Summary

      Constructors 
      Constructor Description
      GRColorChanges()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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
    • 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.
        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.
        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).