Class LayoutHint

    • Method Detail

      • addValueListener

        public void addValueListener​(ValueListener listener)
        Add a listener to be notified when the value of this attribute changes. If the listener is already on the list of listeners, then do nothing.
        Specified by:
        addValueListener in interface Settable
        Parameters:
        listener - The listener to add.
        See Also:
        removeValueListener(ValueListener)
      • exportMoML

        public void exportMoML​(java.io.Writer output,
                               int depth,
                               java.lang.String name)
                        throws java.io.IOException
        Write a MoML description of this object. MoML is an XML modeling markup language. In this class, the object is identified by the "property" element, with "name", "class", and "value" (XML) attributes. The body of the element, between the "<property>" and "</property>", is written using the _exportMoMLContents() protected method, so that derived classes can override that method alone to alter only how the contents of this object are described. The text that is written is indented according to the specified depth, with each line (including the last one) terminated with a newline. If this object is non-persistent, then nothing is written.
        Specified by:
        exportMoML in interface MoMLExportable
        Overrides:
        exportMoML in class NamedObj
        Parameters:
        output - The output writer to write to.
        depth - The depth in the hierarchy, to determine indenting.
        name - The name to use instead of the current name.
        Throws:
        java.io.IOException - If an I/O error occurs.
        See Also:
        Location.exportMoML(Writer, int, String), NamedObj.isPersistent()
      • getDefaultExpression

        public java.lang.String getDefaultExpression()
        A LayoutHint has no default expression.
        Specified by:
        getDefaultExpression in interface Settable
        Returns:
        always null
      • getExpression

        public java.lang.String getExpression()
        Get the value that has been set by setExpression() or by setLayoutHintItem(), whichever was most recently called, or return an empty string if neither has been called.

        If setExpression(String value) was called, then the return value is exactly what ever was passed in as the argument to setExpression. This means that there is no guarantee that the return value of getExpression() is a well formed Ptolemy array expression.

        If setLayoutHintItem(NamedObj, NamedObj, double[]) was called, then the return value is a well formed Ptolemy array expression that starts with "{" and ends with "}", and contains the expressions of LayoutHint.LayoutHintItems as array elements. Example:

         { item1, item2 }
         
        Specified by:
        getExpression in interface Settable
        Returns:
        The expression.
        See Also:
        Location.getExpression(), setExpression(String)
      • getLayoutHintItem

        public LayoutHint.LayoutHintItem getLayoutHintItem​(java.lang.Object head,
                                                           java.lang.Object tail)
        Get the LayoutHint.LayoutHintItem stored in this LayoutHint that is identified by the head and tail of the link for which it specifies bend points. If no LayoutHint.LayoutHintItem is stored for the given head and tail, null is returned. It works like a map with two keys that have to match. As links in Ptolemy are not directed, it does not matter if head and tail get switched. However, for layout the direction does matter and the bendpoint list is directed from head to tail. So if there is an item available where head and tail are swapped, then this item will be returned but the entries get swapped again to guarantee that head and tail and the bendpoint order are correct.
        Parameters:
        head - The starting point of the link, e.g. a Ptolemy Port or Relation.
        tail - The ending point of the link, e.g. a Ptolemy Port or Relation.
        Returns:
        the LayoutHintItem stored for this link or null
        See Also:
        setLayoutHintItem(NamedObj, NamedObj, double[], Point2D.Double)
      • removeLayoutHintItem

        public void removeLayoutHintItem​(LayoutHint.LayoutHintItem itemToRemove)
        Remove a LayoutHint.LayoutHintItem from this storage. If that is the last item contained in this layout hint, then the layout hint itself is removed from its container.
        Parameters:
        itemToRemove - The layout hint item to remove
      • setExpression

        public void setExpression​(java.lang.String expression)
        Set the value of the attribute by giving some expression. This expression is not parsed until validate() is called, and the container and value listeners are not notified until validate() is called. See the class comment for a description of the format.
        Specified by:
        setExpression in interface Settable
        Parameters:
        expression - The value of the attribute.
        See Also:
        getExpression()
      • setLayoutHintItem

        public void setLayoutHintItem​(NamedObj head,
                                      NamedObj tail,
                                      double[] bendPoints,
                                      java.awt.geom.Point2D.Double labelLocation)
        Set a LayoutHint.LayoutHintItem for a link which is specified by its head and tail, i.e. Ptolemy Ports or Relations. For this link store the given list of bend points. Like in a Map with two keys, a possibly existing item for the given head and tail will be reused and updated with the bend points. If no such item yet exists, a new one is added.
        Parameters:
        head - the head object of the corresponding link
        tail - the tail object of the corresponding link
        bendPoints - an array of double coordinates, where always two correspond to a bend point
        labelLocation - the location of a label if it exists, may be null
        See Also:
        getLayoutHintItem(Object, Object)
      • setVisibility

        public void setVisibility​(Settable.Visibility visibility)
        Set the visibility of this attribute. The argument should be one of the public static instances in Settable.
        Specified by:
        setVisibility in interface Settable
        Parameters:
        visibility - The visibility of this attribute.
        See Also:
        getVisibility()
      • validate

        public java.util.Collection validate()
                                      throws IllegalActionException
        Parse the layout hint specification given by setExpression(), if there has been one, and otherwise do nothing, i.e. keep the list of layout hints empty. Notify the container and any value listeners of the new location, if it has changed. See the class comment for a description of the format.
        Specified by:
        validate in interface Settable
        Returns:
        Null, indicating that no other instances of Settable are validated.
        Throws:
        IllegalActionException - If the expression is invalid.