PulpCore

pulpcore.sprite
Class Viewport

java.lang.Object
  extended by pulpcore.sprite.Sprite
      extended by pulpcore.sprite.Group
          extended by pulpcore.sprite.Viewport
All Implemented Interfaces:
PropertyListener

public class Viewport
extends Group

A Viewport is a Group whose contents can scroll, and the contents outside the bounds of the Group are not visible.


Field Summary
 Bool scrollPixelSnapping
          The flag to indicate pixel snapping for scroll location.
 Fixed scrollX
          The scroll x location, relative to the origin of this Viewport.
 Fixed scrollY
          The scroll y location, relative to the origin of this Viewport.
 
Fields inherited from class pulpcore.sprite.Sprite
alpha, anchorX, anchorY, angle, CENTER, DEFAULT, EAST, enabled, height, NORTH, NORTH_EAST, NORTH_WEST, pixelSnapping, SOUTH, SOUTH_EAST, SOUTH_WEST, visible, WEST, width, x, y
 
Constructor Summary
Viewport(int x, int y, int w, int h)
           
 
Method Summary
 void add(int index, Sprite sprite)
          Calls getContentPane().add(index, sprite);.
 void add(Sprite sprite)
          Calls getContentPane().add(sprite);.
 int getContentHeight()
           
 Group getContentPane()
           
 int getContentWidth()
           
protected  int getNaturalHeight()
          Gets the fixed-point value of the Sprite's natural height.
protected  int getNaturalWidth()
          Gets the fixed-point value of the Sprite's natural width.
 boolean isOverflowClipped()
          Returns true.
 void moveDown(Sprite sprite)
          Calls getContentPane().moveDown(sprite);.
 void moveToBottom(Sprite sprite)
          Calls getContentPane().moveToBottom(sprite);.
 void moveToTop(Sprite sprite)
          Calls getContentPane().moveToTop(sprite);.
 void moveUp(Sprite sprite)
          Calls getContentPane().moveUp(sprite);.
 void remove(Sprite sprite)
          Calls getContentPane().remove(sprite);.
 void removeAll()
          Calls getContentPane().removeAll();.
 void update(int elapsedTime)
          Updates all of this Sprite's properties.
 
Methods inherited from class pulpcore.sprite.Group
contains, createBackBuffer, createBackBuffer, drawSprite, findWithTag, get, getBackBuffer, getBackBufferBlendMode, getNumSprites, getNumVisibleSprites, getRemovedSprites, hasBackBuffer, isAncestorOf, iterator, pack, pick, pickEnabledAndVisible, propertyChange, removeBackBuffer, setBackBufferBlendMode, size
 
Methods inherited from class pulpcore.sprite.Sprite
bindLocationTo, bindSizeTo, clearCursor, clearDirtyRect, contains, draw, getBlendMode, getCursor, getDirtyRect, getFilter, getLocalX, getLocalY, getParent, getPixelLevelChecks, getRoot, getScene2D, getTag, getViewX, getViewX, getViewY, getViewY, intersects, isDirty, isEnabled, isEnabledAndVisible, isMouseDoubleClicked, isMouseDown, isMouseHover, isMouseOver, isMousePressed, isMouseReleased, isMouseTripleClicked, isMouseWheelRotated, isOpaque, isPick, isPickEnabledAndVisible, isTransparent, move, move, move, move, move, move, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, removeFromParent, scale, scale, scale, scale, scale, scale, scaleTo, scaleTo, scaleTo, scaleTo, scaleTo, scaleTo, setAnchor, setAnchor, setBlendMode, setCursor, setDirty, setFilter, setLocation, setLocation, setSize, setSize, setTag, translate, translate, updateDirtyRect
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

scrollX

public final Fixed scrollX
The scroll x location, relative to the origin of this Viewport. Identical to getContentPane().x.


scrollY

public final Fixed scrollY
The scroll y location, relative to the origin of this Viewport. Identical to getContentPane().y.


scrollPixelSnapping

public final Bool scrollPixelSnapping
The flag to indicate pixel snapping for scroll location. Initially set to true. Identical to getContentPane().pixelSnapping.

Constructor Detail

Viewport

public Viewport(int x,
                int y,
                int w,
                int h)
Method Detail

getContentPane

public Group getContentPane()

getContentWidth

public int getContentWidth()

getContentHeight

public int getContentHeight()

getNaturalWidth

protected int getNaturalWidth()
Description copied from class: Sprite
Gets the fixed-point value of the Sprite's natural width. Subclasses will override this method to specify the natural width. The natural width is the width of the Sprite if no scaling is applied - for an ImageSprite, the natural width is the width of the image.

Overrides:
getNaturalWidth in class Group

getNaturalHeight

protected int getNaturalHeight()
Description copied from class: Sprite
Gets the fixed-point value of the Sprite's natural height. Subclasses will override this method to specify the natural height. The natural height is the height of the Sprite if no scaling is applied - for an ImageSprite, the natural height is the height of the image.

Overrides:
getNaturalHeight in class Group

isOverflowClipped

public boolean isOverflowClipped()
Returns true.

Overrides:
isOverflowClipped in class Group
See Also:
Group.getNaturalWidth(), Group.getNaturalHeight()

update

public void update(int elapsedTime)
Description copied from class: Sprite
Updates all of this Sprite's properties. Subclasses that override this method should call super.update().

Overrides:
update in class Group

add

public void add(Sprite sprite)
Calls getContentPane().add(sprite);.

Adds a Sprite to this Group. The Sprite is added so it appears above all other sprites in this Group. If this Sprite already belongs to a Group, it is first removed from that Group before added to this one.

Overrides:
add in class Group

add

public void add(int index,
                Sprite sprite)
Calls getContentPane().add(index, sprite);.

Inserts a Sprite to this Group at the specified position. The Sprite at the current position (if any) and any subsequent Sprites are moved up in the z-order (adds one to their indices).

If the index is less than zero, the sprite is inserted at position zero (the bottom in the z-order). If the index is greater than or equal to Group.size(), the sprite is inserted at position Group.size() (the top in the z-order).

Overrides:
add in class Group

remove

public void remove(Sprite sprite)
Calls getContentPane().remove(sprite);.

Removes a Sprite from this Group.

Overrides:
remove in class Group

removeAll

public void removeAll()
Calls getContentPane().removeAll();.

Removes all Sprites from this Group.

Overrides:
removeAll in class Group

moveToTop

public void moveToTop(Sprite sprite)
Calls getContentPane().moveToTop(sprite);.

Moves the specified Sprite to the top of the z-order, so that all the other Sprites currently in this Group appear underneath it. If the specified Sprite is not in this Group, or the Sprite is already at the top, this method does nothing.

Overrides:
moveToTop in class Group

moveToBottom

public void moveToBottom(Sprite sprite)
Calls getContentPane().moveToBottom(sprite);.

Moves the specified Sprite to the bottom of the z-order, so that all the other Sprites currently in this Group appear above it. If the specified Sprite is not in this Group, or the Sprite is already at the bottom, this method does nothing.

Overrides:
moveToBottom in class Group

moveUp

public void moveUp(Sprite sprite)
Calls getContentPane().moveUp(sprite);.

Moves the specified Sprite up in z-order, swapping places with the first Sprite that appears above it. If the specified Sprite is not in this Group, or the Sprite is already at the top, this method does nothing.

Overrides:
moveUp in class Group

moveDown

public void moveDown(Sprite sprite)
Calls getContentPane().moveDown(sprite);.

Moves the specified Sprite down in z-order, swapping places with the first Sprite that appears below it. If the specified Sprite is not in this Group, or the Sprite is already at the bottom, this method does nothing.

Overrides:
moveDown in class Group

PulpCore

Copyright © 2007-2009 Interactive Pulp, LLC.