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:
Renderable2dInterface<L>
- Direct Known Subclasses:
SingleImageRenderable
An abstract class for state-dependent image renderables.
Copyright (c) 2002-2025 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information DSOL Manual. The DSOL project is distributed under a three-clause BSD-style license, which can be found at DSOL License.
- Since:
- 1.5
- Author:
- Peter Jacobs
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final shortCENTER-BOTTOM location.static final shortCENTER-CENTER location.static final shortCENTER-TOP location.protected ImageIcon[]the imageIcons to be used.protected URL[]the imageIcons to use.static final shortLEFT-BOTTOM location.static final shortLEFT-CENTER location.static final shortLEFT-TOP location.protected shortthe origin of the image.static final shortRIGHT-BOTTOM location.static final shortRIGHT-CENTER location.static final shortRIGHT-TOP location.Fields inherited from interface nl.tudelft.simulation.dsol.animation.d2.Renderable2dInterface
ANIMATION_OBJECT_COUNTER, FLIP_FLAG, ROTATE_FLAG, SCALE_FLAG, SCALE_OBJECT_FLAG, SCALE_Y_FLAG, TRANSLATE_FLAG -
Constructor Summary
ConstructorsConstructorDescriptionImageRenderable(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 TypeMethodDescriptionshortReturns 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, org.djutils.draw.bounds.Bounds2d size) resolves the origin of the image.abstract intselects the image.voidsetOrientation(short orientation) Methods inherited from class nl.tudelft.simulation.dsol.animation.d2.Renderable2d
bind2Context, contains, contains, 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- the source to be animated.contextProvider- the object that can provide the context to store the animation objectsimages- 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- the static location of the set of imageIconssize- the size of the imageIcons in world coordinates.contextProvider- the object that can provide the context to store the animation objectsimages- 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- the static location of the set of imageIconssize- the size of the imageIcons in world coordinates.contextProvider- the object that can provide the context to store the animation objectsimages- the imageIcons to display.
-
-
Method Details
-
paint
Description copied from class:Renderable2dDraws an animation on a world coordinate around [x,y] = [0,0].- Specified by:
paintin classRenderable2d<L extends Locatable>- Parameters:
graphics- the graphics objectobserver- 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- The orientation to set.
-
getImages
- Returns:
- Returns the imageIcons.
-
resolveOrigin
resolves the origin of the image.- Parameters:
forOrientation- the orientation (CC,..)size- 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
-