diva.canvas.toolbox
Class TypedDecorator

java.lang.Object
  extended by diva.canvas.AbstractFigure
      extended by diva.canvas.AbstractFigureContainer
          extended by diva.canvas.FigureDecorator
              extended by diva.canvas.toolbox.TypedDecorator
All Implemented Interfaces:
CanvasComponent, Figure, FigureContainer, FigureSet, VisibleComponent, UserObjectContainer

public class TypedDecorator
extends FigureDecorator

A FigureDecorator implementation which simply acts as a set of prototypes which can be instantiated according to the type of object the decorator is applied to. Instances of this class will throw an exception if they are actually placed into a figure hierarchy. They can, however, be passed to methods that expect a decorator instance that is to be used as a prototype for other instances.

Version:
$Revision: 1.3 $
Author:
John Reekie (johnr@eecs.berkeley.edu), Michael Shilman (michaels@eecs.berkeley.edu)

Constructor Summary
TypedDecorator()
          A typed decorator that uses a BasicHighlighter as its default.
TypedDecorator(FigureDecorator defaultDecorator)
          A typed decorator with the given decorator as its default.
 
Method Summary
 void addDecorator(Class c, FigureDecorator d)
          Add a decorator which is duplicated when an object of the given class is passed to the newInstance() method.
 FigureDecorator newInstance(Figure f)
          Return a new decorator, according to the type of the figure.
 void removeDecorator(Class c)
          Remove a decorator.
 void setParent(CanvasComponent fc)
          Throw an exception.
 
Methods inherited from class diva.canvas.FigureDecorator
add, contains, figures, figuresFromBack, figuresFromFront, getBounds, getChild, getContainer, getDecoratedFigure, getFigureCount, getShape, hit, paint, remove, replaceChild, setChild, transform
 
Methods inherited from class diva.canvas.AbstractFigureContainer
decorate, pick, pick, repaint, translate, undecorate
 
Methods inherited from class diva.canvas.AbstractFigure
contains, getInteractor, getLayer, getOrigin, getParent, getToolTipText, getTransformContext, getUserObject, intersects, isVisible, paint, repaint, setInteractor, setToolTipText, setUserObject, setVisible
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface diva.canvas.VisibleComponent
isVisible, paint, setVisible
 
Methods inherited from interface diva.canvas.CanvasComponent
getParent, getTransformContext, repaint
 

Constructor Detail

TypedDecorator

public TypedDecorator()
A typed decorator that uses a BasicHighlighter as its default.


TypedDecorator

public TypedDecorator(FigureDecorator defaultDecorator)
A typed decorator with the given decorator as its default.

Method Detail

addDecorator

public void addDecorator(Class c,
                         FigureDecorator d)
Add a decorator which is duplicated when an object of the given class is passed to the newInstance() method.


newInstance

public FigureDecorator newInstance(Figure f)
Return a new decorator, according to the type of the figure.

Specified by:
newInstance in class FigureDecorator

removeDecorator

public void removeDecorator(Class c)
Remove a decorator.


setParent

public void setParent(CanvasComponent fc)
Throw an exception. The exception is thrown to ensure that instances of this class are not inserted into the figure hierarchy. This is a bit clumsy, as this object is really a factory masquerading as a figure.

Specified by:
setParent in interface Figure
Overrides:
setParent in class AbstractFigure


Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.