fdda.graphics.java2d
Class Component

java.lang.Object
  |
  +--fdda.graphics.java2d.Component
All Implemented Interfaces:
Cloneable, Component
Direct Known Subclasses:
Container, LineSegment, Message, Node, Point

public abstract class Component
extends Object
implements Component

Implementation of the component interface. Provides several standard implementations of abstract methods. Most notably implements a mechanism for the calculation of the shape: calcShape() is _only_ called by getShape(), and _only_ if the shape has changed. A change of the shape is signalled by the attribute dirtyShape.

Author:
Jörg Rüdenauer

Field Summary
protected static Color COLOR_NORMAL
          normal drawing color
protected static Color COLOR_SELECTED
          color for selected elements
protected  boolean dirtyShape
          must the shape be recalculated?
protected  boolean selected
          whether the component is selected
protected  Shape shape
          the shape of the component
protected  double x
          the x coordinate
protected  double y
          the y coordinate
 
Fields inherited from interface fdda.graphics.Component
SEL_ALL, SEL_EQUALS, SEL_MOVABLES, SEL_NOTHING
 
Constructor Summary
Component(double x, double y)
          Default constructor.
Component(double x, double y, boolean selected)
          Constructor.
 
Method Summary
protected abstract  void calcShape()
          Recalculates the shape.
 Object clone()
          Clones the component
 void deselect()
          Unsets the selected flag.
abstract  void draw(Graphics2D graphContext)
          Draws the component, using the given graphics.
 GraphicalSystem getGraphicalSystem()
          Returns the system which includes the component.
 Shape getShape()
          Returns the shape of the component.
 double getX()
          Returns the x coordinate of the component (or its most prominent point).
 double getY()
          Returns the y coordinate of the component (or its most prominent point).
 boolean isSelected()
          Returns whether the component is currently selected.
 void recalculateShape()
          Recalculates the shape of the component.
 void select()
          Sets the selected flag.
 void setGraphicalSystem(GraphicalSystem graphicalSystem)
          Sets the system which includes the component
 void setXY(double x, double y)
          Sets the coordinates of the component (or of its most prominent point).
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface fdda.graphics.Component
isMovable, move, selectableWith, visit
 

Field Detail

x

protected double x
the x coordinate


y

protected double y
the y coordinate


shape

protected Shape shape
the shape of the component


selected

protected boolean selected
whether the component is selected


COLOR_NORMAL

protected static final Color COLOR_NORMAL
normal drawing color


COLOR_SELECTED

protected static final Color COLOR_SELECTED
color for selected elements


dirtyShape

protected boolean dirtyShape
must the shape be recalculated?

Constructor Detail

Component

public Component(double x,
                 double y)
Default constructor. Component is not selected.

Parameters:
x - the x coordinate
y - the y coordinate

Component

public Component(double x,
                 double y,
                 boolean selected)
Constructor.

Parameters:
x - the x coordinate
y - the y coordinate
selected - whether the component is selected
Method Detail

clone

public Object clone()
Description copied from interface: Component
Clones the component

Specified by:
clone in interface Component
Overrides:
clone in class Object
Returns:
the clone

select

public void select()
Sets the selected flag. Doesn't repaint the component. This method should be overriden by subclasses if the shape changes.

Specified by:
select in interface Component
See Also:
Component.select()

deselect

public void deselect()
Unsets the selected flag. Doesn't repaint the component. This method should be overriden by subclasses if the shape changes.

Specified by:
deselect in interface Component
See Also:
Component.deselect()

getX

public double getX()
Description copied from interface: Component
Returns the x coordinate of the component (or its most prominent point).

Specified by:
getX in interface Component
Returns:
the x coordinate

getY

public double getY()
Description copied from interface: Component
Returns the y coordinate of the component (or its most prominent point).

Specified by:
getY in interface Component
Returns:
the y coordinate

setXY

public void setXY(double x,
                  double y)
Description copied from interface: Component
Sets the coordinates of the component (or of its most prominent point).

Specified by:
setXY in interface Component
Parameters:
x - the x coordinate
y - the y coordinate

getShape

public Shape getShape()
Description copied from interface: Component
Returns the shape of the component. This may actually be bigger than the shape seen on screen. It is the shape that is redrawn by the graphic system.

Specified by:
getShape in interface Component
Returns:
the shape of the component

recalculateShape

public void recalculateShape()
Description copied from interface: Component
Recalculates the shape of the component. Needs not be called explicitly if the change of the shape is made by other member functions.

Specified by:
recalculateShape in interface Component

calcShape

protected abstract void calcShape()
Recalculates the shape. Is called by getShape if the flag dirtyShape is set. Must unset the flag after calculation.


isSelected

public boolean isSelected()
Description copied from interface: Component
Returns whether the component is currently selected.

Specified by:
isSelected in interface Component
Returns:
the selection state.

draw

public abstract void draw(Graphics2D graphContext)
Draws the component, using the given graphics. The graphics should have the same attributes (color, pen, etc.) after the call as before the call.

Parameters:
graphContext - the graphics

getGraphicalSystem

public GraphicalSystem getGraphicalSystem()
Description copied from interface: Component
Returns the system which includes the component.

Specified by:
getGraphicalSystem in interface Component
Returns:
the graphical system

setGraphicalSystem

public void setGraphicalSystem(GraphicalSystem graphicalSystem)
Description copied from interface: Component
Sets the system which includes the component

Specified by:
setGraphicalSystem in interface Component
Parameters:
graphicalSystem - the graphical system


API documentation for FDDA version 0.9. Generated on 17/02/2004 14:12.