Class NameIcon

  • All Implemented Interfaces:
    java.lang.Cloneable, Changeable, Debuggable, DebugListener, Derivable, IconAttribute, ModelErrorHandler, MoMLExportable, Moveable, Nameable
    Direct Known Subclasses:
    ConceptIcon, DesignPatternIcon, OctagonEventIcon, StateIcon, TestIcon

    public class NameIcon
    extends EditorIcon
    An icon that displays the name of the container in an appropriately sized box. Put this into a composite actor or in any actor to convert the icon for that actor into a simple box with the name of the actor instance. You will probably also want to set the actor instance to not display its name above its icon. You can do that via the Customize Name dialog (obtained by right clicking on the icon) or by creating a parameter named "_hideName" with value true.
    Since:
    Ptolemy II 5.2
    Version:
    $Id$
    Author:
    Edward A. Lee
    Pt.AcceptedRating:
    Red (johnr)
    Pt.ProposedRating:
    Yellow (eal)
    • Field Detail

      • color

        public ColorAttribute color
        The background color to use in the box. This defaults to white.
      • rounding

        public Parameter rounding
        The amount of rounding of the corners. This is a double that defaults to 0.0, which indicates no rounding.
      • spacing

        public Parameter spacing
        If greater than zero, then use a double box where the outside one is the specified size larger than the inside one. This is a double that defaults to 0.0, which indicates a single box.
      • _labelFont

        protected static final java.awt.Font _labelFont
        The font used.
      • _roundingValue

        protected double _roundingValue
        Most recent value of the rounding parameter.
      • _spacingValue

        protected double _spacingValue
        Most recent value of the spacing parameter.
      • _xPadding

        protected double _xPadding
        The horizontal padding on the left and right sides of the name.
      • _yPadding

        protected double _yPadding
        The vertical padding above and below the name.
    • Constructor Detail

      • NameIcon

        public NameIcon​(NamedObj container,
                        java.lang.String name)
                 throws NameDuplicationException,
                        IllegalActionException
        Create a new icon with the given name in the given container. The container is required to implement Settable, or an exception will be thrown.
        Parameters:
        container - The container for this attribute.
        name - The name of this attribute.
        Throws:
        IllegalActionException - If thrown by the parent class or while setting an attribute.
        NameDuplicationException - If the name coincides with an attribute already in the container.
    • Method Detail

      • createBackgroundFigure

        public Figure createBackgroundFigure()
        Create a new background figure. This overrides the base class to draw a box around the value display, where the width of the box depends on the value.
        Overrides:
        createBackgroundFigure in class EditorIcon
        Returns:
        A new figure.
      • createFigure

        public Figure createFigure()
        Create a new Diva figure that visually represents this icon. The figure will be an instance of LabelFigure that renders the name of the container.
        Overrides:
        createFigure in class EditorIcon
        Returns:
        A new CompositeFigure consisting of the label.
      • createIcon

        public javax.swing.Icon createIcon()
        Create an icon.
        Overrides:
        createIcon in class EditorIcon
        Returns:
        The icon.
      • _getBackgroundSize

        protected java.awt.geom.Point2D _getBackgroundSize()
        Return the background size.
        Returns:
        the background size.
      • _getFill

        protected java.awt.Paint _getFill()
        Return the paint to use to fill the icon. This base class returns the value of the color attribute.
        Returns:
        The paint to use to fill the icon.
      • _getLabel

        protected LabelFigure _getLabel​(CompositeFigure background,
                                        java.lang.String name)
        Get the label to put on the specified background figure based on the specified name.
        Parameters:
        background - The background figure on which to put the label.
        name - The name on which to base the label.
        Returns:
        The label figure.
      • _getLineWidth

        protected float _getLineWidth()
        Return the line width to use in rendering the box. This base class returns 1.0f.
        Returns:
        The line width to use in rendering the box.