Class MirrorTransformerStrategy

  • All Implemented Interfaces:
    Analyzer, GraphAnalyzer, MirrorTransformer, Transformer

    public class MirrorTransformerStrategy
    extends CachedStrategy
    implements MirrorTransformer
    A mirror transformer for graphs.

    In the cloneWeight(boolean) method, users can also specify whether to clone node and edge weights. For non cloneable weights a CloneNotSupportedException will be thrown by the virtual machine.

    Since:
    Ptolemy II 4.0
    Version:
    $Id$
    Author:
    Shahrooz Shahparnia based on a method by Ming Yung Ko.
    Pt.AcceptedRating:
    Red (ssb)
    Pt.ProposedRating:
    Red (shahrooz)
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.lang.Object _compute()
      The computation associated with this strategy.
      void cloneWeight​(boolean status)
      Changes the status of the graph returned by the mirror() method.
      boolean hasBackwardMapping()
      Specify if this transformation has a mapping from the transformed version to the original version or not.
      boolean hasForwardMapping()
      Specify if this transformation has a mapping from the original version to the transformed version or not.
      Graph mirror()
      Create a mirror of the graph associated with this analyzer with the same runtime class.
      Graph mirror​(Graph graph, boolean cloneWeights)
      Return a mirror of this graph in the form of the argument graph type (i.e., the run-time type of the returned graph is that of the argument graph).
      java.lang.Object originalVersionOf​(java.lang.Object transformedObject)
      Return the original version of given object in the transformed graph.
      java.lang.Object transformedVersionOf​(java.lang.Object originalObject)
      Return the transformed version of a given object in the original graph.
      boolean valid()
      Always valid.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface ptolemy.graph.analysis.analyzer.Analyzer

        toString
    • Constructor Detail

      • MirrorTransformerStrategy

        public MirrorTransformerStrategy​(Graph graph)
        Construct a transformer for a given graph.
        Parameters:
        graph - The given graph.
    • Method Detail

      • cloneWeight

        public void cloneWeight​(boolean status)
        Changes the status of the graph returned by the mirror() method. If true, the weights will also be cloned in the next calls to the mirror() method.
        Specified by:
        cloneWeight in interface MirrorTransformer
        Parameters:
        status - If true, the weights will also be cloned.
      • hasBackwardMapping

        public boolean hasBackwardMapping()
        Specify if this transformation has a mapping from the transformed version to the original version or not.
        Specified by:
        hasBackwardMapping in interface Transformer
        Returns:
        True If the implementation of the transformer supports backward mapping.
      • hasForwardMapping

        public boolean hasForwardMapping()
        Specify if this transformation has a mapping from the original version to the transformed version or not.
        Specified by:
        hasForwardMapping in interface Transformer
        Returns:
        True If the implementation of the transformer supports forward mapping.
      • mirror

        public Graph mirror()
        Create a mirror of the graph associated with this analyzer with the same runtime class.
        Specified by:
        mirror in interface MirrorTransformer
        Returns:
        The mirror graph.
      • mirror

        public Graph mirror​(Graph graph,
                            boolean cloneWeights)
        Return a mirror of this graph in the form of the argument graph type (i.e., the run-time type of the returned graph is that of the argument graph). The mirror and original graphs are isomorphic (of same topology). However, nodes and edges of the mirror are newly created and therefore not equal to those of the original graph.

        The returned mirror graph has the same ordering(integer labeling) of nodes(edges) as the original graph. Therefore, correspondent nodes(edges) pairs in both graphs can be gotten through same labels. In other words, labels can also be used to relate mirror and original nodes(edges).

        Specified by:
        mirror in interface MirrorTransformer
        Parameters:
        graph - The type of the graph which the graph associated with this analyzer is being mirrored to.
        cloneWeights - If true, the weights will also be cloned.
        Returns:
        The mirror graph.
      • originalVersionOf

        public java.lang.Object originalVersionOf​(java.lang.Object transformedObject)
        Return the original version of given object in the transformed graph.
        Specified by:
        originalVersionOf in interface Transformer
        Parameters:
        transformedObject - The given object in the transformed graph.
        Returns:
        Return the original version the given object.
      • transformedVersionOf

        public java.lang.Object transformedVersionOf​(java.lang.Object originalObject)
        Return the transformed version of a given object in the original graph.
        Specified by:
        transformedVersionOf in interface Transformer
        Parameters:
        originalObject - The given object in the original graph.
        Returns:
        Return the transformed version the given object.
      • valid

        public boolean valid()
        Always valid.
        Specified by:
        valid in interface Analyzer
        Returns:
        True always.
      • _compute

        protected java.lang.Object _compute()
        The computation associated with this strategy.
        Overrides:
        _compute in class CachedStrategy
        Returns:
        The mirror graph as an Object.