org.vizzini.ui.graphics
Class AbstractShapeCanvas

java.lang.Object
  extended by org.vizzini.ui.graphics.AbstractShapeCanvas
All Implemented Interfaces:
IStateful, IShapeCanvas
Direct Known Subclasses:
ShapeCanvasAWT, ShapeCanvasJava3D, ShapeCanvasSwing

abstract class AbstractShapeCanvas
extends Object
implements IShapeCanvas

Provides a base class for a canvas for drawing 3D shapes.

Since:
v0.2
Version:
v0.3
Author:
Jeffrey M. Thompson

Field Summary
protected  Component _canvas
          The GUI component.
protected  Point _canvasCenter
          The center of the canvas.
protected  boolean _isDrawn
          Flag indicating the image is already draw to the buffer.
 
Constructor Summary
AbstractShapeCanvas()
          Construct this object.
 
Method Summary
 void add(IShape shape)
          Add the given shape.
 void clear()
          Clear all the shapes.
protected  void computeQuaternion()
          Compute a quaternion from the rotations.
protected abstract  Component createCanvas()
          Create the appropriate canvas.
 IState getAbsoluteState()
          Return the absolute state.
protected  AnchorShape getAnchor()
           
 Iterator getAnchorShapeGroupIterator()
          Return an iterator over the anchor shape group.
 Component getComponent()
          Return the GUI component.
 double getMagnify()
          Return the magnification.
 double getPerspectiveConstant()
          Return the perspective constant.
 IState getState()
          Return the state.
 IStateful getStatefulParent()
          Return the parent.
protected  double getXRotation()
           
protected  double getYRotation()
           
protected  double getZRotation()
           
 boolean isViewPointLightUsed()
           
protected  void myPaint(Graphics g)
          Paint the shapes.
protected  void orientationChanged()
          The shapes have moved.
 void remove(IShape shape)
          Remove the given shape.
 void setBackground(Color color)
          Set the background color.
 void setBounds(int x, int y, int w, int h)
          Set the bounds.
 void setBounds(Rectangle r)
          Set the bounds.
 void setMagnify(double magnify)
          Set the magnification.
 void setPerspectiveConstant(double d)
          Set the perspective constant.
protected  void setQuaternion(Quaternion q)
          Set the current rotation quaternion.
 void setStatefulParent(IStateful parent)
          Set the parent.
 void setViewPointLightUsed(boolean isViewPointLightUsed)
           
 void setXRotation(double rotation)
          Set the rotation around the X axis in radians.
 void setYRotation(double rotation)
          Set the rotation around the Y axis in radians.
 void setZRotation(double rotation)
          Set the rotation around the Z axis in radians.
protected  void sizeChanged()
          The canvas size changed.
 void update()
          Update the shapes on this canvas.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_canvas

protected Component _canvas
The GUI component.


_canvasCenter

protected Point _canvasCenter
The center of the canvas.


_isDrawn

protected boolean _isDrawn
Flag indicating the image is already draw to the buffer.

Constructor Detail

AbstractShapeCanvas

public AbstractShapeCanvas()
Construct this object.

Since:
v0.2
Method Detail

add

public void add(IShape shape)
Add the given shape.

Specified by:
add in interface IShapeCanvas
Parameters:
shape - The shape to add.
Since:
v0.2

clear

public void clear()
Clear all the shapes.

Specified by:
clear in interface IShapeCanvas
Since:
v0.2

getAbsoluteState

public IState getAbsoluteState()
Return the absolute state.

Specified by:
getAbsoluteState in interface IStateful
Since:
v0.2

getAnchorShapeGroupIterator

public Iterator getAnchorShapeGroupIterator()
Return an iterator over the anchor shape group.

Specified by:
getAnchorShapeGroupIterator in interface IShapeCanvas
Since:
v0.3

getComponent

public Component getComponent()
Return the GUI component.

Specified by:
getComponent in interface IShapeCanvas
Since:
v0.2

getMagnify

public double getMagnify()
Return the magnification.

Specified by:
getMagnify in interface IShapeCanvas
Since:
v0.2

getPerspectiveConstant

public double getPerspectiveConstant()
Return the perspective constant.

Specified by:
getPerspectiveConstant in interface IShapeCanvas
Since:
v0.2

getState

public IState getState()
Return the state.

Specified by:
getState in interface IStateful
Since:
v0.2

getStatefulParent

public IStateful getStatefulParent()
Return the parent.

Specified by:
getStatefulParent in interface IStateful
Since:
v0.2

isViewPointLightUsed

public boolean isViewPointLightUsed()
Specified by:
isViewPointLightUsed in interface IShapeCanvas
Returns:
Return isViewPointLightUsed.
Since:
v0.3

remove

public void remove(IShape shape)
Remove the given shape.

Specified by:
remove in interface IShapeCanvas
Since:
v0.2

setBackground

public void setBackground(Color color)
Set the background color.

Specified by:
setBackground in interface IShapeCanvas
Parameters:
color - The new color.
Since:
v0.2

setBounds

public void setBounds(Rectangle r)
Set the bounds.

Specified by:
setBounds in interface IShapeCanvas
Since:
v0.2

setBounds

public void setBounds(int x,
                      int y,
                      int w,
                      int h)
Set the bounds.

Specified by:
setBounds in interface IShapeCanvas
Since:
v0.2

setMagnify

public void setMagnify(double magnify)
Set the magnification.

Specified by:
setMagnify in interface IShapeCanvas
Parameters:
magnify - The new magnification.
Since:
v0.2

setPerspectiveConstant

public void setPerspectiveConstant(double d)
Set the perspective constant.

Specified by:
setPerspectiveConstant in interface IShapeCanvas
Since:
v0.2

setStatefulParent

public void setStatefulParent(IStateful parent)
Set the parent.

Specified by:
setStatefulParent in interface IStateful
Since:
v0.2

setViewPointLightUsed

public void setViewPointLightUsed(boolean isViewPointLightUsed)
Specified by:
setViewPointLightUsed in interface IShapeCanvas
Parameters:
isViewPointLightUsed - the isViewPointLightUsed to set
Since:
v0.3

setXRotation

public void setXRotation(double rotation)
Set the rotation around the X axis in radians.

Specified by:
setXRotation in interface IShapeCanvas
Parameters:
rotation - The new rotation in radians.
Since:
v0.2

setYRotation

public void setYRotation(double rotation)
Set the rotation around the Y axis in radians.

Specified by:
setYRotation in interface IShapeCanvas
Parameters:
rotation - The new rotation in radians.
Since:
v0.2

setZRotation

public void setZRotation(double rotation)
Set the rotation around the Z axis in radians.

Specified by:
setZRotation in interface IShapeCanvas
Parameters:
rotation - The new rotation in radians.
Since:
v0.2

update

public void update()
Update the shapes on this canvas.

Specified by:
update in interface IShapeCanvas
Since:
v0.3

createCanvas

protected abstract Component createCanvas()
Create the appropriate canvas.

Since:
v0.2

computeQuaternion

protected void computeQuaternion()
Compute a quaternion from the rotations.

Since:
v0.2

getAnchor

protected AnchorShape getAnchor()
Returns:
Return anchor.

getXRotation

protected double getXRotation()
Returns:
Return xRotation.

getYRotation

protected double getYRotation()
Returns:
Return yRotation.

getZRotation

protected double getZRotation()
Returns:
Return zRotation.

myPaint

protected void myPaint(Graphics g)
Paint the shapes. The magnification is scaled to fit the canvas, so that if the canvas size is changed, the shape sizes are scaled too.

Since:
v0.2

orientationChanged

protected void orientationChanged()
The shapes have moved.

Since:
v0.2

setQuaternion

protected void setQuaternion(Quaternion q)
Set the current rotation quaternion.

Parameters:
q - Quaternion.
Since:
v0.3

sizeChanged

protected void sizeChanged()
The canvas size changed.

Since:
v0.2


Copyright © 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02