Class AnimationRenderer

  • All Implemented Interfaces:
    SelectionRenderer
    Direct Known Subclasses:
    DebugRenderer, ShadowRenderer

    public class AnimationRenderer
    extends java.lang.Object
    implements SelectionRenderer
    An implementation of a selection renderer that is used for animation. It highlights specified figures by wrapping them in an instance of a FigureDecorator. The figure decorator is obtained by cloning a prototype decorator, accessible through the get/setFigureDecorator() methods. The default prototype is an instance of BasicHighlighter that highlights in red.

    This class is fashioned after BasicSelectionRenderer, but differs in that it ensures that selection and deselection occurs in the event thread. Also, it highlights objects in red rather than yellow.

    Since:
    Ptolemy II 2.0
    Version:
    $Id$
    Author:
    Edward A. Lee
    Pt.AcceptedRating:
    Red (johnr)
    Pt.ProposedRating:
    Red (eal)
    • Constructor Summary

      Constructors 
      Constructor Description
      AnimationRenderer()
      Create a new selection renderer with the default prototype decorator.
      AnimationRenderer​(FigureDecorator decorator)
      Create a new renderer with the given prototype decorator.
      AnimationRenderer​(java.awt.Color color)
      Create a new selection renderer with the default prototype decorator using the specified color.
      AnimationRenderer​(java.awt.Color color, float halo)
      Create a new selection renderer with the default prototype decorator using the specified color and halo size.
      AnimationRenderer​(java.awt.Color color, java.awt.Stroke stroke)
      Create a new selection renderer with the default prototype decorator using the specified color and stroke.
    • Field Detail

      • _prototypeDecorator

        protected FigureDecorator _prototypeDecorator
        The prototype decorator.
    • Constructor Detail

      • AnimationRenderer

        public AnimationRenderer()
        Create a new selection renderer with the default prototype decorator.
      • AnimationRenderer

        public AnimationRenderer​(java.awt.Color color)
        Create a new selection renderer with the default prototype decorator using the specified color.
        Parameters:
        color - The color for the highlight.
      • AnimationRenderer

        public AnimationRenderer​(java.awt.Color color,
                                 float halo)
        Create a new selection renderer with the default prototype decorator using the specified color and halo size.
        Parameters:
        color - The color for the highlight.
        halo - The halo size.
      • AnimationRenderer

        public AnimationRenderer​(java.awt.Color color,
                                 java.awt.Stroke stroke)
        Create a new selection renderer with the default prototype decorator using the specified color and stroke. This draws an outline rather than a filled shape.
        Parameters:
        color - The color for the highlight.
        stroke - The stroke for the highlight.
      • AnimationRenderer

        public AnimationRenderer​(FigureDecorator decorator)
        Create a new renderer with the given prototype decorator.
        Parameters:
        decorator - The prototype decorator.
    • Method Detail

      • isRenderedSelected

        public boolean isRenderedSelected​(Figure figure)
        Test whether the given figure is currently rendered highlighted.
        Specified by:
        isRenderedSelected in interface SelectionRenderer
        Parameters:
        figure - The figure that may be highlighted.
        Returns:
        True if the figure is highlighted.
      • renderDeselected

        public void renderDeselected​(Figure figure)
        Set the rendering of the figure to not be highlighted. The figure has the decorator unwrapped off it and is inserted back into its parent figure container, if there is one. If the figure is not rendered highlighted, do nothing. The rendering is performed later in the event thread, and the calling thread is suspended by calling Thread.yield(), to give the event thread a chance to catch up.
        Specified by:
        renderDeselected in interface SelectionRenderer
        Parameters:
        figure - The figure to deselect.
      • renderSelected

        public void renderSelected​(Figure figure)
        Set the rendering of the figure as highlighted. If the figure is already rendered highlighted, just repaint. Otherwise create a new BasicHighlighter, and wrap the figure in the decorator, inserting the decorator into the figure's parent. The rendering is performed later in the event thread, and the calling thread is suspended by calling Thread.yield(), to give the event thread a chance to catch up.
        Specified by:
        renderSelected in interface SelectionRenderer
        Parameters:
        figure - The figure to highlight.
      • setDecorator

        public void setDecorator​(FigureDecorator decorator)
        Set the prototype decorator.
        Parameters:
        decorator - The prototype decorator.
        See Also:
        getDecorator()