Class AbstractFigure

java.lang.Object
com.bc.ceres.swing.figure.AbstractFigure
All Implemented Interfaces:
Figure, Restorable, Cloneable
Direct Known Subclasses:
AbstractHandle, AbstractPointFigure, AbstractShapeFigure, DefaultFigureCollection

public abstract class AbstractFigure extends Object implements Figure
Base class for all Figure implementations.

Provides support for the following properties: selectable, selected, normalStyle, selectedStyle.

Since:
Ceres 0.10
  • Field Details

    • NO_FIGURES

      protected static final Figure[] NO_FIGURES
    • NO_HANDLES

      protected static final Handle[] NO_HANDLES
  • Constructor Details

    • AbstractFigure

      protected AbstractFigure()
    • AbstractFigure

      protected AbstractFigure(FigureStyle normalStyle, FigureStyle selectedStyle)
  • Method Details

    • isSelectable

      public boolean isSelectable()
      The default implementation returns false.
      Specified by:
      isSelectable in interface Figure
      Returns:
      Always false.
    • setSelectable

      public void setSelectable(boolean selectable)
    • isSelected

      public boolean isSelected()
      Description copied from interface: Figure
      Tests if the figure is selected.
      Specified by:
      isSelected in interface Figure
      Returns:
      true, if so.
    • setSelected

      public void setSelected(boolean selected)
      Description copied from interface: Figure
      Sets the selected state.
      Specified by:
      setSelected in interface Figure
      Parameters:
      selected - The selected state.
    • getNormalStyle

      public FigureStyle getNormalStyle()
      Specified by:
      getNormalStyle in interface Figure
      Returns:
      The style used for the "normal" state of the figure.
    • setNormalStyle

      public void setNormalStyle(FigureStyle normalStyle)
      Description copied from interface: Figure
      Sets the style used for the "normal" state of the figure.
      Specified by:
      setNormalStyle in interface Figure
      Parameters:
      normalStyle - The style used for the "normal" state of the figure.
    • getSelectedStyle

      public FigureStyle getSelectedStyle()
      Specified by:
      getSelectedStyle in interface Figure
      Returns:
      The style used for the "selected" state of the figure.
    • setSelectedStyle

      public void setSelectedStyle(FigureStyle selectedStyle)
      Description copied from interface: Figure
      Sets the style used for the "selected" state of the figure.
      Specified by:
      setSelectedStyle in interface Figure
      Parameters:
      selectedStyle - The style used for the "selected" state of the figure.
    • getEffectiveStyle

      public FigureStyle getEffectiveStyle()
      Specified by:
      getEffectiveStyle in interface Figure
      Returns:
      The effective style used for the current state of the figure.
    • contains

      public boolean contains(Figure figure)
      The default implementation returns false.
      Specified by:
      contains in interface Figure
      Parameters:
      figure - A figure.
      Returns:
      Always false.
    • getFigureCount

      public int getFigureCount()
      The default implementation returns 0.
      Specified by:
      getFigureCount in interface Figure
      Returns:
      Always 0.
    • getFigureIndex

      public int getFigureIndex(Figure figure)
      The default implementation returns 0.
      Specified by:
      getFigureIndex in interface Figure
      Parameters:
      figure - The child figure to look up.
      Returns:
      Always 0.
    • getFigure

      public Figure getFigure(Point2D p, AffineTransform m2v)
      The default implementation returns null.
      Specified by:
      getFigure in interface Figure
      Parameters:
      p - Point in model coordinates.
      m2v - Current model-to-view transformation.
      Returns:
      Always null.
    • getFigures

      public Figure[] getFigures(Shape shape)
      The default implementation returns an empty array.
      Specified by:
      getFigures in interface Figure
      Parameters:
      shape - The shape defining the area in which the figures must be contained.
      Returns:
      Always an empty array.
    • getFigures

      public Figure[] getFigures()
      The default implementation returns an empty array.
      Specified by:
      getFigures in interface Figure
      Returns:
      Always an empty array.
    • addFigure

      public boolean addFigure(Figure figure)
      Description copied from interface: Figure
      Adds a child figure to this figure.
      Specified by:
      addFigure in interface Figure
      Parameters:
      figure - The new child figure.
      Returns:
      true, if the child has been added.
    • addFigure

      public boolean addFigure(int index, Figure figure)
      Description copied from interface: Figure
      Adds a child figure at the given index to this figure.
      Specified by:
      addFigure in interface Figure
      Parameters:
      index - The index.
      figure - The new child figure.
      Returns:
      true, if the child has been added.
    • addFigures

      public Figure[] addFigures(Figure... figures)
      Description copied from interface: Figure
      Adds a child figure at the given index to this figure.
      Specified by:
      addFigures in interface Figure
      Parameters:
      figures - The array of new child figures.
      Returns:
      The array of child figures that actually have been added.
    • removeFigure

      public boolean removeFigure(Figure figure)
      Description copied from interface: Figure
      Removes a child figure from this figure.
      Specified by:
      removeFigure in interface Figure
      Parameters:
      figure - The new child figure.
      Returns:
      true, if the child has been removed.
    • removeFigures

      public Figure[] removeFigures(Figure... figures)
      Description copied from interface: Figure
      Removes the given child figures from this figure.
      Specified by:
      removeFigures in interface Figure
      Parameters:
      figures - The array of child figures to remove.
      Returns:
      The array of child figures that actually have been removed.
    • removeAllFigures

      public Figure[] removeAllFigures()
      Description copied from interface: Figure
      Removes all child figures from this figure.
      Specified by:
      removeAllFigures in interface Figure
      Returns:
      The array of child figures that actually have been removed.
    • getFigure

      public Figure getFigure(int index)
      The default implementation throws an [@code IllegalStateException}.
      Specified by:
      getFigure in interface Figure
      Parameters:
      index - The child index.
      Returns:
      Does never return normally.
    • addFigureImpl

      protected boolean addFigureImpl(int index, Figure figure)
      The default implementation throws an [@code IllegalStateException}.
      Parameters:
      index - The index.
      figure - The figure.
      Returns:
      Does never return normally.
    • addFigureImpl

      protected boolean addFigureImpl(Figure figure)
    • addFiguresImpl

      protected Figure[] addFiguresImpl(Figure[] figures)
    • removeFigureImpl

      protected boolean removeFigureImpl(Figure figure)
      The default implementation throws an [@code IllegalStateException}.
      Parameters:
      figure - The figure.
      Returns:
      Does never return normally.
    • removeFiguresImpl

      protected Figure[] removeFiguresImpl(Figure[] figures)
    • removeFiguresImpl

      protected Figure[] removeFiguresImpl()
    • move

      public void move(double dx, double dy)
      Description copied from interface: Figure
      Moves the figure by the given delta in model coordinates.
      Specified by:
      move in interface Figure
      Parameters:
      dx - Delta X in model coordinates.
      dy - Delta Y in model coordinates.
    • scale

      public void scale(Point2D point, double sx, double sy)
      Description copied from interface: Figure
      Scales the figure by the given scale factors.
      Specified by:
      scale in interface Figure
      Parameters:
      point - The reference point in model coordinates.
      sx - Scale X factor.
      sy - Scale Y factor.
    • rotate

      public void rotate(Point2D point, double theta)
      Description copied from interface: Figure
      Rotates the figure by the given angle.
      Specified by:
      rotate in interface Figure
      Parameters:
      point - The reference point in model coordinates.
      theta - The rotation angle in degree.
    • getSegment

      public double[] getSegment(int index)
      Description copied from interface: Figure
      Gets the segment at the given vertex index.
      Specified by:
      getSegment in interface Figure
      Parameters:
      index - The vertex index.
      Returns:
      The segment coordinates. X is the first element, Y the second.
    • setSegment

      public void setSegment(int index, double[] segment)
      Description copied from interface: Figure
      Sets the segment at the given vertex index.
      Specified by:
      setSegment in interface Figure
      Parameters:
      index - The vertex index.
      segment - The segment coordinates. X is the first element, Y the second.
    • addSegment

      public void addSegment(int index, double[] segment)
      Description copied from interface: Figure
      Adds the segment at the given vertex index.
      Specified by:
      addSegment in interface Figure
      Parameters:
      index - The vertex index.
      segment - The segment coordinates. X is the first element, Y the second.
    • removeSegment

      public void removeSegment(int index)
      Description copied from interface: Figure
      Removes the segment at the given vertex index.
      Specified by:
      removeSegment in interface Figure
      Parameters:
      index - The vertex index.
    • getMaxSelectionStage

      public int getMaxSelectionStage()
      The default implementation returns zero.
      Specified by:
      getMaxSelectionStage in interface Figure
      Returns:
      Always 0.
    • createHandles

      public Handle[] createHandles(int selectionStage)
      The default implementation returns an empty array. Clients should override in order to create an array of handles suitable for the given selection stage.
      Specified by:
      createHandles in interface Figure
      Parameters:
      selectionStage - The selection stage. 1 <= selectionLevel <= getMaxSelectionStage()
      Returns:
      The array of handles.
    • createMemento

      public Object createMemento()
      The default implementation returns [@code null}. Clients should override in order to produce something more meaningful.
      Specified by:
      createMemento in interface Restorable
      Returns:
      Always null.
    • setMemento

      public void setMemento(Object memento)
      The default implementation does nothing. Clients should override in order to evaluate the passed in memento. object.
      Specified by:
      setMemento in interface Restorable
      Parameters:
      memento - A memento object.
    • addChangeListener

      public void addChangeListener(FigureChangeListener listener)
      Description copied from interface: Figure
      Adds a new change listener to this figure.
      Specified by:
      addChangeListener in interface Figure
      Parameters:
      listener - The listener.
    • removeChangeListener

      public void removeChangeListener(FigureChangeListener listener)
      Description copied from interface: Figure
      Removes a change listener from this figure.
      Specified by:
      removeChangeListener in interface Figure
      Parameters:
      listener - The listener.
    • getChangeListeners

      public FigureChangeListener[] getChangeListeners()
      Specified by:
      getChangeListeners in interface Figure
      Returns:
      The array of all change listeners registered with this figure.
    • dispose

      public void dispose()
      Description copied from interface: Figure
      Disposes this figure. Indicates that it will no longer be used.
      Specified by:
      dispose in interface Figure
    • clone

      public Object clone()
      Specified by:
      clone in interface Figure
      Overrides:
      clone in class Object
      Returns:
      A clone of this figure.
    • fireFiguresAdded

      protected void fireFiguresAdded(Figure... figures)
    • fireFiguresRemoved

      protected void fireFiguresRemoved(Figure... figures)
    • fireFigureChanged

      protected void fireFigureChanged()
    • fireFigureChanged

      protected void fireFigureChanged(FigureChangeEvent event)
    • createScaleHandles

      protected Handle[] createScaleHandles(double distance)
    • getHandleStyle

      protected FigureStyle getHandleStyle()
    • getSelectedHandleStyle

      protected FigureStyle getSelectedHandleStyle()