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
An abstract class for state-dependent image renderables.
Copyright (c) 2002-2024 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:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final short
CENTER-BOTTOM location.static final short
CENTER-CENTER location.static final short
CENTER-TOP location.protected ImageIcon[]
the imageIcons to be used.protected URL[]
the imageIcons to use.static final short
LEFT-BOTTOM location.static final short
LEFT-CENTER location.static final short
LEFT-TOP location.protected short
the origin of the image.static final short
RIGHT-BOTTOM location.static final short
RIGHT-CENTER location.static final short
RIGHT-TOP location. -
Constructor Summary
ConstructorDescriptionImageRenderable
(L source, Contextualized contextProvider, URL[] images) constructs a new ImageRenderable.ImageRenderable
(org.djutils.draw.point.OrientedPoint3d staticLocation, org.djutils.draw.bounds.Bounds3d size, Contextualized contextProvider, URL[] images) constructs a new ImageRenderable.ImageRenderable
(org.djutils.draw.point.Point3d staticLocation, org.djutils.draw.bounds.Bounds3d size, Contextualized contextProvider, URL[] images) constructs a new ImageRenderable. -
Method Summary
Modifier and TypeMethodDescriptionshort
Returns the orientation of this image to the point [0,0].void
paint
(Graphics2D graphics, ImageObserver observer) Draws an animation on a world coordinate around [x,y] = [0,0].protected Point2D
resolveOrigin
(short forOrientation, org.djutils.draw.bounds.Bounds2d size) resolves the origin of the image.abstract int
selects the image.void
setOrientation
(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 Details
-
LB
public static final short LBLEFT-BOTTOM location.- See Also:
-
CB
public static final short CBCENTER-BOTTOM location.- See Also:
-
RB
public static final short RBRIGHT-BOTTOM location.- See Also:
-
LC
public static final short LCLEFT-CENTER location.- See Also:
-
CC
public static final short CCCENTER-CENTER location.- See Also:
-
RC
public static final short RCRIGHT-CENTER location.- See Also:
-
LT
public static final short LTLEFT-TOP location.- See Also:
-
CT
public static final short CTCENTER-TOP location.- See Also:
-
RT
public static final short RTRIGHT-TOP location.- See Also:
-
imageUrls
the imageIcons to use. -
imageIcons
the imageIcons to be used. -
orientation
protected short orientationthe origin of the image.
-
-
Constructor Details
-
ImageRenderable
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(org.djutils.draw.point.OrientedPoint3d staticLocation, org.djutils.draw.bounds.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(org.djutils.draw.point.Point3d staticLocation, org.djutils.draw.bounds.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 Details
-
paint
Draws an animation on a world coordinate around [x,y] = [0,0].- Specified by:
paint
in 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
- Returns:
- Returns the imageIcons.
-
resolveOrigin
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
-