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-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 Details

  • Constructor Details

    • 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 objects
      images - 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 imageIcons
      size - Bounds3; the size of the imageIcons in world coordinates.
      contextProvider - Contextualized; the object that can provide the context to store the animation objects
      images - 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 imageIcons
      size - Bounds3d; the size of the imageIcons in world coordinates.
      contextProvider - Contextualized; the object that can provide the context to store the animation objects
      images - URL[]; the imageIcons to display.
  • Method Details

    • paint

      public void paint(Graphics2D graphics, ImageObserver observer)
      Draws an animation on a world coordinate around [x,y] = [0,0].
      Specified by:
      paint in class Renderable2d<L extends Locatable>
      Parameters:
      graphics - Graphics2D; the graphics object
      observer - 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, org.djutils.draw.bounds.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