nl.tudelft.simulation.dsol.animation.D2
Class Renderable2D

java.lang.Object
  extended by nl.tudelft.simulation.dsol.animation.D2.Renderable2D
All Implemented Interfaces:
Renderable2DInterface
Direct Known Subclasses:
EditableRenderable2D, ImageRenderable

public abstract class Renderable2D
extends Object
implements Renderable2DInterface

The Renderable2D provides an easy accessible renderable object.

(c) copyright 2002-2005 Delft University of Technology , the Netherlands.
See for project information www.simulation.tudelft.nl
License of use: Lesser General Public License (LGPL) , no warranty.

Version:
$Revision: 1.1 $ $Date: 2007/01/06 13:21:28 $
Author:
Peter Jacobs

Nested Class Summary
 
Nested classes/interfaces inherited from interface nl.tudelft.simulation.dsol.animation.D2.Renderable2DInterface
Renderable2DInterface.Util
 
Field Summary
protected  boolean flip
          whether to flip the renderable after rotating 180 degrees
protected  boolean rotate
          whether to rotate the renderable
protected  boolean scale
          whether to scale the renderable when zooming in or out
protected  SimulatorInterface simulator
          simulator
protected  LocatableInterface source
          the source of the renderable
protected  boolean translate
          whether to translate the renderable when panning
 
Constructor Summary
Renderable2D(LocatableInterface source, SimulatorInterface simulator)
          constructs a new Renderable2D
 
Method Summary
protected  void bind2Context(SimulatorInterface simulator)
          binds a renderable2D to the context.
 boolean contains(Point2D pointWorldCoordinates, Rectangle2D extent, Dimension screen)
          does the shape contain the point
 void destroy()
          destroys an RenderableObject by unsubscribing it from the context.
 LocatableInterface getSource()
          gets the source of this renderable
 boolean isFlip()
           
 boolean isRotate()
           
 boolean isScale()
           
 boolean isTranslate()
           
abstract  void paint(Graphics2D graphics, ImageObserver observer)
          draws an animation on a worldcoordinates around [x,y=0,0]
 void paint(Graphics2D graphics, Rectangle2D extent, Dimension screen, ImageObserver observer)
          paints the object on a 2D graphics object
 void setFlip(boolean flip)
           
 void setRotate(boolean rotate)
           
 void setScale(boolean scale)
           
 void setTranslate(boolean translate)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

rotate

protected boolean rotate
whether to rotate the renderable


flip

protected boolean flip
whether to flip the renderable after rotating 180 degrees


scale

protected boolean scale
whether to scale the renderable when zooming in or out


translate

protected boolean translate
whether to translate the renderable when panning


simulator

protected SimulatorInterface simulator
simulator


source

protected LocatableInterface source
the source of the renderable

Constructor Detail

Renderable2D

public Renderable2D(LocatableInterface source,
                    SimulatorInterface simulator)
constructs a new Renderable2D

Parameters:
source - the source
simulator - the simulator
Method Detail

bind2Context

protected void bind2Context(SimulatorInterface simulator)
binds a renderable2D to the context. The reason for specifying this in an independent method instead of adding the code in the constructor is related to the RFE submitted by van Houten that in specific distributed context, such binding must be overwritten.

Parameters:
simulator - the simulator used for binding the object.

isFlip

public boolean isFlip()
Returns:
Returns the flip.

setFlip

public void setFlip(boolean flip)
Parameters:
flip - The flip to set.

isRotate

public boolean isRotate()
Returns:
Returns the rotate.

setRotate

public void setRotate(boolean rotate)
Parameters:
rotate - The rotate to set.

isScale

public boolean isScale()
Returns:
Returns the scale.

setScale

public void setScale(boolean scale)
Parameters:
scale - The scale to set.

getSource

public LocatableInterface getSource()
Description copied from interface: Renderable2DInterface
gets the source of this renderable

Specified by:
getSource in interface Renderable2DInterface
Returns:
Locatable the source
See Also:
Renderable2DInterface.getSource()

isTranslate

public boolean isTranslate()
Returns:
Returns the translate.

setTranslate

public void setTranslate(boolean translate)
Parameters:
translate - The translate to set.

paint

public void paint(Graphics2D graphics,
                  Rectangle2D extent,
                  Dimension screen,
                  ImageObserver observer)
Description copied from interface: Renderable2DInterface
paints the object on a 2D graphics object

Specified by:
paint in interface Renderable2DInterface
Parameters:
graphics - the graphics object
extent - the extent of the panel
screen - the screen of the panel
observer - the observer of the renderableInterface
See Also:
#paint(Graphics2D, Rectangle2D, Dimension,ImageObserver)

contains

public boolean contains(Point2D pointWorldCoordinates,
                        Rectangle2D extent,
                        Dimension screen)
Description copied from interface: Renderable2DInterface
does the shape contain the point

Specified by:
contains in interface Renderable2DInterface
Parameters:
pointWorldCoordinates - the point in world coordinates. Default implementation is to intersect the 3D bounds on location.z and to return the bounds2D of this intersect.
extent - the extent of the panel.
screen - the screen of the panel.
Returns:
whether the point is in the shape
See Also:
#contains(java.awt.geom.Point2D, java.awt.geom.Rectangle2D, java.awt.Dimension)

destroy

public void destroy()
destroys an RenderableObject by unsubscribing it from the context.

Specified by:
destroy in interface Renderable2DInterface

toString

public String toString()
Overrides:
toString in class Object
See Also:
Object.toString()

paint

public abstract void paint(Graphics2D graphics,
                           ImageObserver observer)
                    throws RemoteException
draws an animation on a worldcoordinates around [x,y=0,0]

Parameters:
graphics - the graphics object
observer - the observer
Throws:
RemoteException - on network exception


Copyright © 2002-2010 Delft University of Technology, the Netherlands. All Rights Reserved.