uk.ac.starlink.diva
Class DrawCompositeFigure

java.lang.Object
  extended by diva.canvas.AbstractFigure
      extended by diva.canvas.AbstractFigureContainer
          extended by diva.canvas.CompositeFigure
              extended by diva.canvas.toolbox.BackgroundedCompositeFigure
                  extended by uk.ac.starlink.diva.DrawCompositeFigure
All Implemented Interfaces:
CanvasComponent, Figure, FigureContainer, FigureSet, VisibleComponent, UserObjectContainer, DrawFigure

public class DrawCompositeFigure
extends BackgroundedCompositeFigure
implements DrawFigure

DrawCompositeFigure extends the Diva BackgroundedCompositeFigure class to add support for events that allow users of any derived figures to be made aware of any changes, i.e. composite figure creation, removal and transformations.

All composite figures used on a Draw implementation should be derived classes of this class, or implement the necessary code to support the FigureListener class. They should also invoke fireChanged in their translate and transform methods (but not if calling super) and respect the transformFreely state.

Version:
$Id$
Author:
Peter W. Draper
See Also:
Draw, BackgroundedCompositeFigure, DrawFigure

Field Summary
protected  EventListenerList listeners
           
protected static boolean transformFreely
          Hint that figures should ignore any transformation constraints
 
Constructor Summary
DrawCompositeFigure()
          Construct a backgrounded composite figure with no background and no children.
DrawCompositeFigure(Figure background)
          Construct a backgrounded composite figure with the given background and no children.
 
Method Summary
 void addListener(FigureListener l)
          Registers a listener for to be informed when figure changes occur.
protected  void fireChanged()
          Send a FigureChangedEvent object specifying that this figure has changed.
protected  void fireCreated()
          Send a FigureChangedEvent object specifying that this figure has created to all listeners.
protected  void fireRemoved()
          Send a FigureChangedEvent object specifying that this figure has been removed.
 Composite getComposite()
          Get the composite of the background figure.
 Paint getFillPaint()
          Get the fill paint of the background figure.
 float getLineWidth()
          Get line width
 Paint getStrokePaint()
          Get the outline paint of the background figure.
static boolean isTransformFreely()
          Find out if this is an occasion when a figure should give up any constraints and traneform freely.
 void removeListener(FigureListener l)
          Remove a listener.
 void setComposite(AlphaComposite composite)
          Set the composite of the background figure.
 void setFillPaint(Paint fill)
          Set the fill paint of the background figure.
 void setLineWidth(float width)
          Set line width
 void setShape(Shape shape)
          Set the background Figure using a Shape.
 void setStrokePaint(Paint outline)
          Set the outline paint of the background figure.
 void setTransformFreely(boolean state)
          Enable the hint that a figure should allow itself to transform freely, rather than obey any constraints (this is meant for figures that could not otherwise redraw themselves to fit a resized Draw, given their normal constraints, e.g.
 void setVisible(boolean flag)
          Set the visibility flag of this figure.
 void transform(AffineTransform at)
          Transform the figure.
 void translate(double x, double y)
          Translate the figure the given distance, but only in X.
 
Methods inherited from class diva.canvas.toolbox.BackgroundedCompositeFigure
getBackgroundFigure, getBounds, paint, paint, pick, setBackgroundFigure
 
Methods inherited from class diva.canvas.CompositeFigure
add, add, contains, figures, figuresFromBack, figuresFromFront, get, getChildren, getFigureCount, getOrigin, getShape, getTransformContext, indexOf, intersects, invalidateCachedBounds, pick, remove, remove, repaint, replaceChild, setIndex, toString
 
Methods inherited from class diva.canvas.AbstractFigureContainer
decorate, undecorate
 
Methods inherited from class diva.canvas.AbstractFigure
contains, getInteractor, getLayer, getParent, getToolTipText, getUserObject, hit, isVisible, repaint, setInteractor, setParent, setToolTipText, setUserObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface diva.canvas.Figure
contains, getBounds, getInteractor, getLayer, getOrigin, getParent, getShape, getToolTipText, hit, intersects, setInteractor, setParent, setToolTipText
 
Methods inherited from interface diva.canvas.VisibleComponent
isVisible, paint, paint
 
Methods inherited from interface diva.canvas.CanvasComponent
getTransformContext, repaint, repaint
 
Methods inherited from interface diva.util.UserObjectContainer
getUserObject, setUserObject
 

Field Detail

listeners

protected EventListenerList listeners

transformFreely

protected static boolean transformFreely
Hint that figures should ignore any transformation constraints

Constructor Detail

DrawCompositeFigure

public DrawCompositeFigure()
Construct a backgrounded composite figure with no background and no children.


DrawCompositeFigure

public DrawCompositeFigure(Figure background)
Construct a backgrounded composite figure with the given background and no children.

Method Detail

translate

public void translate(double x,
                      double y)
Translate the figure the given distance, but only in X.

Specified by:
translate in interface Figure
Overrides:
translate in class BackgroundedCompositeFigure

transform

public void transform(AffineTransform at)
Transform the figure. Just allow transforms of X scale.

Specified by:
transform in interface Figure
Overrides:
transform in class BackgroundedCompositeFigure

setShape

public void setShape(Shape shape)
Set the background Figure using a Shape.

Specified by:
setShape in interface DrawFigure

setFillPaint

public void setFillPaint(Paint fill)
Set the fill paint of the background figure.

Specified by:
setFillPaint in interface DrawFigure

getFillPaint

public Paint getFillPaint()
Get the fill paint of the background figure.

Specified by:
getFillPaint in interface DrawFigure

setStrokePaint

public void setStrokePaint(Paint outline)
Set the outline paint of the background figure.

Specified by:
setStrokePaint in interface DrawFigure

getStrokePaint

public Paint getStrokePaint()
Get the outline paint of the background figure.

Specified by:
getStrokePaint in interface DrawFigure

setComposite

public void setComposite(AlphaComposite composite)
Set the composite of the background figure.

Specified by:
setComposite in interface DrawFigure

getComposite

public Composite getComposite()
Get the composite of the background figure.

Specified by:
getComposite in interface DrawFigure

setLineWidth

public void setLineWidth(float width)
Set line width

Specified by:
setLineWidth in interface DrawFigure

getLineWidth

public float getLineWidth()
Get line width

Specified by:
getLineWidth in interface DrawFigure

setVisible

public void setVisible(boolean flag)
Description copied from class: AbstractFigure
Set the visibility flag of this figure. If the flag is false, then the figure will not be drawn on the screen and it will not respond to user input events.

Specified by:
setVisible in interface VisibleComponent
Specified by:
setVisible in interface DrawFigure
Overrides:
setVisible in class AbstractFigure

addListener

public void addListener(FigureListener l)
Registers a listener for to be informed when figure changes occur.

Specified by:
addListener in interface DrawFigure
Parameters:
l - the FigureListener

removeListener

public void removeListener(FigureListener l)
Remove a listener.

Specified by:
removeListener in interface DrawFigure
Parameters:
l - the FigureListener

fireCreated

protected void fireCreated()
Send a FigureChangedEvent object specifying that this figure has created to all listeners.


fireRemoved

protected void fireRemoved()
Send a FigureChangedEvent object specifying that this figure has been removed.


fireChanged

protected void fireChanged()
Send a FigureChangedEvent object specifying that this figure has changed.


setTransformFreely

public void setTransformFreely(boolean state)
Enable the hint that a figure should allow itself to transform freely, rather than obey any constraints (this is meant for figures that could not otherwise redraw themselves to fit a resized Draw, given their normal constraints, e.g. XRangeFigure).

Specified by:
setTransformFreely in interface DrawFigure

isTransformFreely

public static boolean isTransformFreely()
Find out if this is an occasion when a figure should give up any constraints and traneform freely.



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