Class ImageRenderable<L extends Locatable>
- java.lang.Object
-
- nl.tudelft.simulation.dsol.animation.d2.Renderable2d<L>
-
- nl.tudelft.simulation.dsol.animation.d2.ImageRenderable<L>
-
- Type Parameters:
L- the Locatable class of the source that indicates the location of the Renderable on the screen
- All Implemented Interfaces:
Serializable,Renderable2dInterface<L>
- Direct Known Subclasses:
SingleImageRenderable
public abstract class ImageRenderable<L extends Locatable> extends Renderable2d<L>
An abstract class for state-dependent image renderables.Copyright (c) 2002-2023 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://simulation.tudelft.nl. The DSOL project is distributed under a three-clause BSD-style license, which can be found at https://https://simulation.tudelft.nl/dsol/docs/latest/license.html.
- Since:
- 1.5
- Author:
- Peter Jacobs
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static shortCBCENTER-BOTTOM location.static shortCCCENTER-CENTER location.static shortCTCENTER-TOP location.protected ImageIcon[]imageIconsthe imageIcons to be used.protected URL[]imageUrlsthe imageIcons to use.static shortLBLEFT-BOTTOM location.static shortLCLEFT-CENTER location.static shortLTLEFT-TOP location.protected shortorientationthe origin of the image.static shortRBRIGHT-BOTTOM location.static shortRCRIGHT-CENTER location.static shortRTRIGHT-TOP location.
-
Constructor Summary
Constructors Constructor Description ImageRenderable(L source, Contextualized contextProvider, URL[] images)constructs a new ImageRenderable.ImageRenderable(OrientedPoint3d staticLocation, Bounds3d size, Contextualized contextProvider, URL[] images)constructs a new ImageRenderable.ImageRenderable(Point3d staticLocation, Bounds3d size, Contextualized contextProvider, URL[] images)constructs a new ImageRenderable.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description ImageIcon[]getImages()shortgetOrientation()Returns the orientation of this image to the point [0,0].voidpaint(Graphics2D graphics, ImageObserver observer)Draws an animation on a world coordinate around [x,y] = [0,0].protected Point2DresolveOrigin(short forOrientation, Bounds2d size)resolves the origin of the image.abstract intselectImage()selects the image.voidsetOrientation(short orientation)-
Methods inherited from class nl.tudelft.simulation.dsol.animation.d2.Renderable2d
bind2Context, contains, destroy, getId, getSource, isFlip, isRotate, isScale, isScaleObject, isScaleY, isTranslate, paint, paintComponent, setFlip, setRotate, setScale, setScaleObject, setScaleY, setTranslate, toString
-
-
-
-
Field Detail
-
LB
public static final short LB
LEFT-BOTTOM location.- See Also:
- Constant Field Values
-
CB
public static final short CB
CENTER-BOTTOM location.- See Also:
- Constant Field Values
-
RB
public static final short RB
RIGHT-BOTTOM location.- See Also:
- Constant Field Values
-
LC
public static final short LC
LEFT-CENTER location.- See Also:
- Constant Field Values
-
CC
public static final short CC
CENTER-CENTER location.- See Also:
- Constant Field Values
-
RC
public static final short RC
RIGHT-CENTER location.- See Also:
- Constant Field Values
-
LT
public static final short LT
LEFT-TOP location.- See Also:
- Constant Field Values
-
CT
public static final short CT
CENTER-TOP location.- See Also:
- Constant Field Values
-
RT
public static final short RT
RIGHT-TOP location.- See Also:
- Constant Field Values
-
imageUrls
protected URL[] imageUrls
the imageIcons to use.
-
imageIcons
protected transient ImageIcon[] imageIcons
the imageIcons to be used.
-
orientation
protected short orientation
the origin of the image.
-
-
Constructor Detail
-
ImageRenderable
public ImageRenderable(L source, Contextualized contextProvider, URL[] images)
constructs a new ImageRenderable.- Parameters:
source- T; the source to be animated.contextProvider- Contextualized; the object that can provide the context to store the animation objectsimages- URL[]; the image urls.
-
ImageRenderable
public ImageRenderable(OrientedPoint3d staticLocation, Bounds3d size, Contextualized contextProvider, URL[] images)
constructs a new ImageRenderable.- Parameters:
staticLocation- OrientedPoint3d; the static location of the set of imageIconssize- Bounds3; the size of the imageIcons in world coordinates.contextProvider- Contextualized; the object that can provide the context to store the animation objectsimages- URL[]; the imageIcons to display.
-
ImageRenderable
public ImageRenderable(Point3d staticLocation, Bounds3d size, Contextualized contextProvider, URL[] images)
constructs a new ImageRenderable.- Parameters:
staticLocation- Point3d; the static location of the set of imageIconssize- Bounds3d; the size of the imageIcons in world coordinates.contextProvider- Contextualized; the object that can provide the context to store the animation objectsimages- URL[]; the imageIcons to display.
-
-
Method Detail
-
paint
public void paint(Graphics2D graphics, ImageObserver observer)
Draws an animation on a world coordinate around [x,y] = [0,0].- Specified by:
paintin classRenderable2d<L extends Locatable>- Parameters:
graphics- Graphics2D; the graphics objectobserver- ImageObserver; the observer
-
selectImage
public abstract int selectImage()
selects the image. This methods makes the ImageRenderable state dependent. One is required to return the index number of the imageIcons[] which has to be drawn.- Returns:
- int the current (state-dependent) image.
-
setOrientation
public void setOrientation(short orientation)
- Parameters:
orientation- short; The orientation to set.
-
getImages
public ImageIcon[] getImages()
- Returns:
- Returns the imageIcons.
-
resolveOrigin
protected Point2D resolveOrigin(short forOrientation, Bounds2d size)
resolves the origin of the image.- Parameters:
forOrientation- short; the orientation (CC,..)size- Dimension; the size of the image.- Returns:
- Bounds2d the location
-
getOrientation
public short getOrientation()
Returns the orientation of this image to the point [0,0]. Orientations are either LEFT, CENTER, RIGHT and TOP, CENTER, or BOTTOM. An example is thus ImageRenderable.RT.- Returns:
- the orientation of this image
-
-