org.dishevelled.piccolo.ribbon
Class HorizontalRibbon

java.lang.Object
  extended by org.piccolo2d.PNode
      extended by org.dishevelled.piccolo.ribbon.HorizontalRibbon
All Implemented Interfaces:
Printable, Serializable, Cloneable

public final class HorizontalRibbon
extends org.piccolo2d.PNode

Horizontal ribbon.

Displays an image textured/repeated horizontally for the entire width of a Piccolo2D camera view. The anchor for the textured image can be moved left or right using a cursor position and distance unit to indicate scrolling or movement.

Animate the ribbon by calling the advance() method at regular intervals, using either the Swing timer

 final HorizontalRibbon ribbon = new HorizontalRibbon(...);
 Timer t = new Timer(100, new ActionListener()
   {
     public void actionPerformed(final ActionEvent event)
     {
       ribbon.advance();
     }
   });
 t.setRepeats(true);
 t.start();
 
or the Piccolo2D activity framework
 final PRoot root = ...;
 final HorizontalRibbon ribbon = new HorizontalRibbon(...);
 PActivity activity = new PActivity()
   {
    protected void activityStep(final long elapsedTime)
    {
      ribbon.advance();
    }
   };
 root.addActivity(activity);
 

Version:
$Revision$ $Date$
Author:
Michael Heuer
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.piccolo2d.PNode
org.piccolo2d.PNode.PSceneGraphDelegate
 
Field Summary
(package private) static double DEFAULT_CURSOR
          Default cursor.
(package private) static double DEFAULT_DISTANCE
          Default distance unit.
 
Fields inherited from class org.piccolo2d.PNode
FILL_STRATEGY_ASPECT_COVER, FILL_STRATEGY_ASPECT_FIT, FILL_STRATEGY_EXACT_FIT, PROPERTY_BOUNDS, PROPERTY_CHILDREN, PROPERTY_CHILDREN_PICKABLE, PROPERTY_CLIENT_PROPERTIES, PROPERTY_CODE_BOUNDS, PROPERTY_CODE_CHILDREN, PROPERTY_CODE_CHILDREN_PICKABLE, PROPERTY_CODE_CLIENT_PROPERTIES, PROPERTY_CODE_FULL_BOUNDS, PROPERTY_CODE_PAINT, PROPERTY_CODE_PARENT, PROPERTY_CODE_PICKABLE, PROPERTY_CODE_TRANSFORM, PROPERTY_CODE_TRANSPARENCY, PROPERTY_CODE_VISIBLE, PROPERTY_FULL_BOUNDS, PROPERTY_PAINT, PROPERTY_PARENT, PROPERTY_PICKABLE, PROPERTY_TRANSFORM, PROPERTY_TRANSPARENCY, PROPERTY_VISIBLE, SCENE_GRAPH_DELEGATE
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Constructor Summary
HorizontalRibbon(BufferedImage image)
          Create a new horizontal ribbon for the specified image.
HorizontalRibbon(BufferedImage image, double cursor, double distance)
          Create a new horizontal ribbon for the specified image with the specified cursor and distance unit.
 
Method Summary
 void advance()
          Advance this horizontal ribbon one animation frame.
(package private)  double getCursor()
          Return the cursor for this horizontal ribbon.
 double getDistance()
          Return the distance unit in user space coordinates for this horizontal ribbon.
 boolean isMovingLeft()
          Return true if this horizontal ribbon is moving left when animating.
 boolean isMovingRight()
          Return true if this horizontal ribbon is moving right when animating.
 boolean isNotMoving()
          Return true if this horizontal ribbon is not moving when animating.
 void moveLeft()
          Set this horizontal ribbon to move left when animating.
 void moveRight()
          Set this horizontal ribbon to move right when animating.
protected  void paint(org.piccolo2d.util.PPaintContext paintContext)
          
 void pause()
          Set this horizontal ribbon not to move when animating.
 void setDistance(double distance)
          Set the distance unit in user space coordinates for this horizontal ribbon to distance.
 
Methods inherited from class org.piccolo2d.PNode
addActivity, addAttribute, addChild, addChild, addChildren, addInputEventListener, addPropertyChangeListener, addPropertyChangeListener, animateToBounds, animateToColor, animateToPositionScaleRotation, animateToRelativePosition, animateToTransform, animateToTransparency, animateTransformToBounds, centerBoundsOnPoint, centerFullBoundsOnPoint, clone, computeFullBounds, endResizeBounds, findIntersectingNodes, fireChildPropertyChange, firePropertyChange, fullIntersects, fullPaint, fullPick, getAllNodes, getAllNodes, getAttribute, getAttribute, getBooleanAttribute, getBounds, getBoundsChanged, getBoundsReference, getBoundsVolatile, getChild, getChildBoundsInvalid, getChildBoundsVolatile, getChildPaintInvalid, getChildrenCount, getChildrenIterator, getChildrenPickable, getChildrenReference, getClientProperties, getClientPropertyKeysEnumeration, getDoubleAttribute, getFullBounds, getFullBoundsInvalid, getFullBoundsReference, getGlobalBounds, getGlobalFullBounds, getGlobalRotation, getGlobalScale, getGlobalToLocalTransform, getGlobalTranslation, getHeight, getInputEventListeners, getIntegerAttribute, getInverseTransform, getListenerList, getLocalToGlobalTransform, getName, getOccluded, getOffset, getPaint, getPaintInvalid, getParent, getPickable, getPropertyChangeParentMask, getRoot, getRotation, getScale, getTransform, getTransformReference, getTransparency, getUnionOfChildrenBounds, getVisible, getWidth, getX, getXOffset, getY, getYOffset, globalToLocal, globalToLocal, globalToLocal, indexOfChild, internalUpdateBounds, intersects, invalidateFullBounds, invalidateLayout, invalidatePaint, isAncestorOf, isDescendentOf, isDescendentOfRoot, isOpaque, layoutChildren, lerp, localToGlobal, localToGlobal, localToGlobal, localToParent, localToParent, localToParent, moveInBackOf, moveInFrontOf, moveToBack, moveToFront, offset, paintAfterChildren, parentBoundsChanged, parentToLocal, parentToLocal, parentToLocal, pick, pickAfterChildren, print, print, removeAllChildren, removeChild, removeChild, removeChildren, removeFromParent, removeInputEventListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaintFrom, reparent, replaceWith, resetBounds, rotate, rotateAboutPoint, rotateAboutPoint, rotateInPlace, scale, scaleAboutPoint, scaleAboutPoint, setBounds, setBounds, setBoundsChanged, setChildBoundsInvalid, setChildBoundsVolatile, setChildPaintInvalid, setChildrenPickable, setFullBoundsInvalid, setGlobalRotation, setGlobalScale, setGlobalTranslation, setHeight, setName, setOccluded, setOffset, setOffset, setPaint, setPaintInvalid, setParent, setPickable, setPropertyChangeParentMask, setRotation, setScale, setTransform, setTransparency, setVisible, setWidth, setX, setY, signalBoundsChanged, startResizeBounds, toImage, toImage, toImage, toImage, transformBy, translate, validateFullBounds, validateFullPaint
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CURSOR

static final double DEFAULT_CURSOR
Default cursor.

See Also:
Constant Field Values

DEFAULT_DISTANCE

static final double DEFAULT_DISTANCE
Default distance unit.

See Also:
Constant Field Values
Constructor Detail

HorizontalRibbon

public HorizontalRibbon(BufferedImage image)
Create a new horizontal ribbon for the specified image.

Parameters:
image - image for this horizontal ribbon, must not be null

HorizontalRibbon

public HorizontalRibbon(BufferedImage image,
                        double cursor,
                        double distance)
Create a new horizontal ribbon for the specified image with the specified cursor and distance unit.

Parameters:
image - image for this horizontal ribbon, must not be null
cursor - cursor position for this horizontal ribbon
distance - distance unit for this horizontal ribbon
Method Detail

pause

public void pause()
Set this horizontal ribbon not to move when animating.


isNotMoving

public boolean isNotMoving()
Return true if this horizontal ribbon is not moving when animating.

Returns:
true if this horizontal ribbon is not moving when animating

moveLeft

public void moveLeft()
Set this horizontal ribbon to move left when animating.


isMovingLeft

public boolean isMovingLeft()
Return true if this horizontal ribbon is moving left when animating.

Returns:
true if this horizontal ribbon is moving left when animating

moveRight

public void moveRight()
Set this horizontal ribbon to move right when animating.


isMovingRight

public boolean isMovingRight()
Return true if this horizontal ribbon is moving right when animating.

Returns:
true if this horizontal ribbon is moving right when animating

advance

public void advance()
Advance this horizontal ribbon one animation frame.


getDistance

public double getDistance()
Return the distance unit in user space coordinates for this horizontal ribbon. Each call to advance() will increment or decrement the cursor position for this horizontal ribbon by the factor of this distance unit and the last scale factor recorded by the paint(PPaintContext) method.

Returns:
the distance unit for this horizontal ribbon
See Also:
advance()

setDistance

public void setDistance(double distance)
Set the distance unit in user space coordinates for this horizontal ribbon to distance.

This is a bound property.

Parameters:
distance - distance unit for this horizontal ribbon

getCursor

double getCursor()
Return the cursor for this horizontal ribbon.

Returns:
the cursor for this horizontal ribbon

paint

protected void paint(org.piccolo2d.util.PPaintContext paintContext)

Overrides:
paint in class org.piccolo2d.PNode


Copyright (c) 2006-2011 held jointly by the individual authors. Licensed under the GNU Lesser General Public License (LGPL).