Class StackableItem2DView<T extends StackableItem>

java.lang.Object
games.stendhal.client.gui.j2d.entity.Entity2DView<T>
games.stendhal.client.gui.j2d.entity.StackableItem2DView<T>
Type Parameters:
T - stackable item type
All Implemented Interfaces:
Inspectable, EntityView<T>

public class StackableItem2DView<T extends StackableItem> extends Entity2DView<T>
The 2D view of a stackable item.
  • Constructor Details

    • StackableItem2DView

      public StackableItem2DView()
  • Method Details

    • initialize

      public void initialize(T entity)
      Specified by:
      initialize in interface EntityView<T extends StackableItem>
      Overrides:
      initialize in class Entity2DView<T extends StackableItem>
    • setShowQuantity

      public void setShowQuantity(boolean showQuantity)
      Set whether to show the quantity value.
      Parameters:
      showQuantity - Whether to show the quantity.
    • draw

      protected void draw(Graphics2D g2d, int x, int y, int width, int height)
      Description copied from class: Entity2DView
      Draw the entity.
      Overrides:
      draw in class Entity2DView<T extends StackableItem>
      Parameters:
      g2d - The graphics context.
      x - The drawn X coordinate.
      y - The drawn Y coordinate.
      width - The drawn entity width.
      height - The drawn entity height.
    • setContained

      public void setContained(boolean contained)
      Set whether this view is contained, and should render in a compressed (it's defined) area without clipping anything important.
      Specified by:
      setContained in interface EntityView<T extends StackableItem>
      Overrides:
      setContained in class Entity2DView<T extends StackableItem>
      Parameters:
      contained - true if contained.
    • update

      protected void update()
      Update representation.
      Overrides:
      update in class Entity2DView<T extends StackableItem>
    • buildRepresentation

      protected void buildRepresentation(T entity)
      Build the visual representation of this entity.
      Overrides:
      buildRepresentation in class Entity2DView<T extends Item>
      Parameters:
      entity - the eEntity to build the representation for
    • getZIndex

      public int getZIndex()
      Determines on top of which other entities this entity should be drawn. Entities with a high Z index will be drawn on top of ones with a lower Z index. Also, players can only interact with the topmost entity.
      Specified by:
      getZIndex in interface EntityView<T extends Item>
      Overrides:
      getZIndex in class Entity2DView<T extends Item>
      Returns:
      The drawing index.
    • translate

      protected String translate(String name)
      Translate a resource name into it's sprite image path.
      Overrides:
      translate in class Entity2DView<T extends Item>
      Parameters:
      name - The resource name.
      Returns:
      The full resource name.
    • isMovable

      public boolean isMovable()
      Determine if this entity can be moved (e.g. via dragging).
      Specified by:
      isMovable in interface EntityView<T extends Item>
      Overrides:
      isMovable in class Entity2DView<T extends Item>
      Returns:
      true if the entity is movable.
    • onAction

      public void onAction()
      Perform the default action.
      Specified by:
      onAction in interface EntityView<T extends Item>
      Overrides:
      onAction in class Entity2DView<T extends Item>
    • onHarmlessAction

      public boolean onHarmlessAction()
      Description copied from class: Entity2DView
      Perform the default action unless it is not safe.
      Specified by:
      onHarmlessAction in interface EntityView<T extends Item>
      Overrides:
      onHarmlessAction in class Entity2DView<T extends Item>
      Returns:
      true if the action was performed, false if nothing was done
    • setInspector

      public void setInspector(Inspector inspector)
      Set the content inspector for this entity.
      Specified by:
      setInspector in interface Inspectable
      Overrides:
      setInspector in class Entity2DView<T extends Item>
      Parameters:
      inspector - The inspector.
    • onAction

      public void onAction(ActionType at)
      Perform an action.
      Specified by:
      onAction in interface EntityView<T extends Item>
      Overrides:
      onAction in class Entity2DView<T extends Item>
      Parameters:
      at - The action.
    • release

      public void release()
      Description copied from class: Entity2DView
      Release any view resources. This view should not be used after this is called.
      Specified by:
      release in interface EntityView<T extends Item>
      Overrides:
      release in class Entity2DView<T extends Item>
    • getCursor

      public StendhalCursor getCursor()
      Description copied from class: Entity2DView
      gets the mouse cursor image to use for this entity.
      Specified by:
      getCursor in interface EntityView<T extends Item>
      Overrides:
      getCursor in class Entity2DView<T extends Item>
      Returns:
      StendhalCursor