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>
The 2D view of a stackable item.
-
Field Summary
Fields inherited from class games.stendhal.client.gui.j2d.entity.Entity2DView
animatedChanged, entity, representationChanged, visibilityChanged
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
buildRepresentation(T entity)
Build the visual representation of this entity.protected void
draw(Graphics2D g2d, int x, int y, int width, int height)
Draw the entity.gets the mouse cursor image to use for this entity.int
Determines on top of which other entities this entity should be drawn.void
initialize(T entity)
boolean
Determine if this entity can be moved (e.g.void
onAction()
Perform the default action.void
onAction(ActionType at)
Perform an action.boolean
Perform the default action unless it is not safe.void
release()
Release any view resources.void
setContained(boolean contained)
Set whether this view is contained, and should render in a compressed (it's defined) area without clipping anything important.void
setInspector(Inspector inspector)
Set the content inspector for this entity.void
setShowQuantity(boolean showQuantity)
Set whether to show the quantity value.protected String
Translate a resource name into it's sprite image path.protected void
update()
Update representation.Methods inherited from class games.stendhal.client.gui.j2d.entity.Entity2DView
applyChanges, attachSprite, buildActions, calculateOffset, detachSprite, draw, drawEntity, drawTop, drawTop, getActions, getArea, getClassResourcePath, getComposite, getDrawingArea, getEntity, getHeight, getSprite, getVisibility, getWidth, getX, getXOffset, getY, getYOffset, isAnimating, isContained, isInteractive, isReleased, reorderActions, setSprite, setVisibleScreenArea
-
Constructor Details
-
StackableItem2DView
public StackableItem2DView()
-
-
Method Details
-
initialize
- Specified by:
initialize
in interfaceEntityView<T extends StackableItem>
- Overrides:
initialize
in classEntity2DView<T extends StackableItem>
-
setShowQuantity
public void setShowQuantity(boolean showQuantity)Set whether to show the quantity value.- Parameters:
showQuantity
- Whether to show the quantity.
-
draw
Description copied from class:Entity2DView
Draw the entity.- Overrides:
draw
in classEntity2DView<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 interfaceEntityView<T extends StackableItem>
- Overrides:
setContained
in classEntity2DView<T extends StackableItem>
- Parameters:
contained
-true
if contained.
-
update
protected void update()Update representation.- Overrides:
update
in classEntity2DView<T extends StackableItem>
-
buildRepresentation
Build the visual representation of this entity.- Overrides:
buildRepresentation
in classEntity2DView<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 interfaceEntityView<T extends Item>
- Overrides:
getZIndex
in classEntity2DView<T extends Item>
- Returns:
- The drawing index.
-
translate
Translate a resource name into it's sprite image path.- Overrides:
translate
in classEntity2DView<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 interfaceEntityView<T extends Item>
- Overrides:
isMovable
in classEntity2DView<T extends Item>
- Returns:
true
if the entity is movable.
-
onAction
public void onAction()Perform the default action.- Specified by:
onAction
in interfaceEntityView<T extends Item>
- Overrides:
onAction
in classEntity2DView<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 interfaceEntityView<T extends Item>
- Overrides:
onHarmlessAction
in classEntity2DView<T extends Item>
- Returns:
true
if the action was performed,false
if nothing was done
-
setInspector
Set the content inspector for this entity.- Specified by:
setInspector
in interfaceInspectable
- Overrides:
setInspector
in classEntity2DView<T extends Item>
- Parameters:
inspector
- The inspector.
-
onAction
Perform an action.- Specified by:
onAction
in interfaceEntityView<T extends Item>
- Overrides:
onAction
in classEntity2DView<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 interfaceEntityView<T extends Item>
- Overrides:
release
in classEntity2DView<T extends Item>
-
getCursor
Description copied from class:Entity2DView
gets the mouse cursor image to use for this entity.- Specified by:
getCursor
in interfaceEntityView<T extends Item>
- Overrides:
getCursor
in classEntity2DView<T extends Item>
- Returns:
- StendhalCursor
-