Class Item2DView<T extends Item>
java.lang.Object
games.stendhal.client.gui.j2d.entity.Entity2DView<T>
games.stendhal.client.gui.j2d.entity.Item2DView<T>
- Type Parameters:
T- item type
- All Implemented Interfaces:
Inspectable,EntityView<T>
The 2D view of an item.
-
Field Summary
Fields inherited from class games.stendhal.client.gui.j2d.entity.Entity2DView
animatedChanged, entity, representationChanged, visibilityChanged -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidbuildRepresentation(T entity) Build the visual representation of this entity.protected voiddraw(Graphics2D g2d, int x, int y, int width, int height) Draw the entity.gets the mouse cursor image to use for this entity.intDetermines on top of which other entities this entity should be drawn.voidinitialize(T entity) booleanDetermine if this entity can be moved (e.g.voidonAction()Perform the default action.voidonAction(ActionType at) Perform an action.booleanPerform the default action unless it is not safe.voidrelease()Release any view resources.voidsetContained(boolean contained) Set whether this view is contained, and should render in a compressed (it's defined) area without clipping anything important.voidsetInspector(Inspector inspector) Set the content inspector for this entity.voidsetShowQuantity(boolean showQuantity) Set whether to show the quantity value.protected StringTranslate a resource name into it's sprite image path.protected voidupdate()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
-
Item2DView
public Item2DView()
-
-
Method Details
-
initialize
- Specified by:
initializein interfaceEntityView<T extends Item>- Overrides:
initializein classEntity2DView<T extends Item>
-
buildRepresentation
Build the visual representation of this entity.- Overrides:
buildRepresentationin 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:
getZIndexin interfaceEntityView<T extends Item>- Overrides:
getZIndexin classEntity2DView<T extends Item>- Returns:
- The drawing index.
-
translate
Translate a resource name into it's sprite image path.- Overrides:
translatein classEntity2DView<T extends Item>- Parameters:
name- The resource name.- Returns:
- The full resource name.
-
draw
Description copied from class:Entity2DViewDraw the entity.- Overrides:
drawin classEntity2DView<T extends Item>- 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:
setContainedin interfaceEntityView<T extends Item>- Overrides:
setContainedin classEntity2DView<T extends Item>- Parameters:
contained-trueif contained.
-
update
protected void update()Update representation.- Overrides:
updatein classEntity2DView<T extends Item>
-
isMovable
public boolean isMovable()Determine if this entity can be moved (e.g. via dragging).- Specified by:
isMovablein interfaceEntityView<T extends Item>- Overrides:
isMovablein classEntity2DView<T extends Item>- Returns:
trueif the entity is movable.
-
onAction
public void onAction()Perform the default action.- Specified by:
onActionin interfaceEntityView<T extends Item>- Overrides:
onActionin classEntity2DView<T extends Item>
-
onHarmlessAction
public boolean onHarmlessAction()Description copied from class:Entity2DViewPerform the default action unless it is not safe.- Specified by:
onHarmlessActionin interfaceEntityView<T extends Item>- Overrides:
onHarmlessActionin classEntity2DView<T extends Item>- Returns:
trueif the action was performed,falseif nothing was done
-
setInspector
Set the content inspector for this entity.- Specified by:
setInspectorin interfaceInspectable- Overrides:
setInspectorin classEntity2DView<T extends Item>- Parameters:
inspector- The inspector.
-
onAction
Perform an action.- Specified by:
onActionin interfaceEntityView<T extends Item>- Overrides:
onActionin classEntity2DView<T extends Item>- Parameters:
at- The action.
-
release
public void release()Description copied from class:Entity2DViewRelease any view resources. This view should not be used after this is called.- Specified by:
releasein interfaceEntityView<T extends Item>- Overrides:
releasein classEntity2DView<T extends Item>
-
getCursor
Description copied from class:Entity2DViewgets the mouse cursor image to use for this entity.- Specified by:
getCursorin interfaceEntityView<T extends Item>- Overrides:
getCursorin classEntity2DView<T extends Item>- Returns:
- StendhalCursor
-
setShowQuantity
public void setShowQuantity(boolean showQuantity) Set whether to show the quantity value.- Parameters:
showQuantity- Whether to show the quantity.
-