|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
org.formaria.swing.animation.AnimationSurface
public abstract class AnimationSurface
All demos extend this JAnimationSurface Abstract class. From this class demos must implement the drawObjects method. This class handles animated demos, the demo must implement the JAnimationContext interface.
Copyright (c) Formaria Ltd., 2008, This software is licensed under the GNU Public License (GPL), please see license.txt for more details. If you make commercial use of this software you must purchase a commercial license from Formaria.
$Revision: 1.27 $
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javax.swing.JComponent |
|---|
javax.swing.JComponent.AccessibleJComponent |
| Nested classes/interfaces inherited from class java.awt.Container |
|---|
java.awt.Container.AccessibleAWTContainer |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
| Field Summary | |
|---|---|
protected AnimationContext |
animationContext
|
protected Animator |
animator
|
protected java.lang.Object |
antiAlias
|
protected float |
ascent
|
protected boolean |
autoStart
|
protected java.awt.image.BufferedImage |
bimg
|
protected java.awt.AlphaComposite |
composite
|
protected Project |
currentProject
The owner project and the context in which this object operates. |
protected boolean |
finished
|
protected int |
imageType
|
protected int |
increment
|
protected java.lang.String |
label
|
protected int |
loopTime
|
protected int |
oH
|
protected int |
oldH
|
protected int |
oldW
|
protected int |
oW
|
protected int |
oX
|
protected int |
oY
|
protected int |
position
|
protected java.lang.Object |
rendering
|
protected long |
sleepTime
|
protected long |
startTime
|
protected java.awt.Paint |
texture
|
protected float |
timingFraction
|
| Fields inherited from class javax.swing.JComponent |
|---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Component |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface java.awt.print.Printable |
|---|
NO_SUCH_PAGE, PAGE_EXISTS |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
protected |
AnimationSurface()
|
| Method Summary | |
|---|---|
protected void |
autoStart()
Start an autostart animation if it hassn't started already |
void |
begin()
Called when the Animator's animation begins. |
java.awt.image.BufferedImage |
createBufferedImage(int w,
int h,
int imgType)
Create a buffer for the animation |
java.awt.Graphics2D |
createGraphics2D(int width,
int height,
java.awt.image.BufferedImage bi,
java.awt.Graphics g)
Create a graphics context for an image buffer and prepare that buffer for use. |
abstract void |
drawObjects(int w,
int h,
java.awt.Graphics2D g2)
All classes that extend JAnimationSurface must implement this routine... |
void |
end()
Called when the Animator's animation ends |
Animator |
getAnimator()
Get the animation thread. |
boolean |
getAntiAlias()
Get the value anti-aliasing value |
boolean |
getAutoStart()
Get the autostart parameter |
boolean |
getComposite()
Get the composite setup state |
int |
getImageType()
Get the iamge type used for buffering the animation |
int |
getIncrement()
Get the update increment |
int |
getLoopTime()
Get the animation loop time |
boolean |
getRendering()
Get the rendering hint |
long |
getSleepTime()
Get the sleep time in milliseconds |
java.lang.String |
getText()
Get the text of the control |
void |
init()
Initialize the animation surface and prepare the starting point/setup |
boolean |
isAnimated(Animator at)
Should the object be animated in this step? |
boolean |
isFinished(Animator at)
Are there more steps to come? |
boolean |
isStarted()
Has the animation begun |
void |
paintComponent(java.awt.Graphics g)
Paint the component, buffering the image in the process if necessary |
int |
print(java.awt.Graphics g,
java.awt.print.PageFormat pf,
int pi)
Print this component |
static java.lang.String |
quoteReplacement(java.lang.String s)
Returns a literal replacement String for the specified
String. |
void |
render(Animator at)
Do the rendering of the animation object |
void |
repeat()
Called when the Animator repeats the animation cycle |
static java.lang.String |
replace(java.lang.String source,
java.lang.CharSequence target,
java.lang.CharSequence replacement)
Replaces each substring of this string that matches the literal target sequence with the specified literal replacement sequence. |
void |
reset()
|
void |
setAnimator(Animator thread)
Set the animation thread. |
void |
setAntiAlias(boolean aa)
Turn the value anti-aliasing on or off. |
void |
setAutoStart(boolean as)
Flag the animation to automatically start on first display |
void |
setComposite(boolean cp)
Set the composite instance |
void |
setImageType(int imgType)
Set the way in which the image is presented. |
void |
setIncrement(int incr)
Sets the update increment. |
void |
setLoopTime(int lt)
Set the animation loop time in milliseconds |
void |
setRendering(boolean rd)
Set the rendering hint for quality or speed |
void |
setSleepTime(long st)
Set the sleep time for the animation thread |
void |
setText(java.lang.String newText)
Set the label/text of the component. |
void |
setTexture(java.lang.Object obj)
Set a texture for paints |
void |
start()
Begin the animation |
void |
stop()
End the animation |
void |
timingEvent(float fraction)
This method will receive all of the timing events from an Animator during an animation. |
| Methods inherited from class javax.swing.JComponent |
|---|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI |
| Methods inherited from class java.awt.Container |
|---|
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
| Methods inherited from class java.awt.Component |
|---|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected java.lang.Object antiAlias
protected java.lang.Object rendering
protected java.awt.Paint texture
protected java.awt.AlphaComposite composite
protected java.awt.image.BufferedImage bimg
protected int imageType
protected Animator animator
protected long sleepTime
protected long startTime
protected AnimationContext animationContext
protected int oldW
protected int oldH
protected int oX
protected int oY
protected int oW
protected int oH
protected java.lang.String label
protected boolean finished
protected boolean autoStart
protected float ascent
protected int position
protected int increment
protected int loopTime
protected float timingFraction
protected Project currentProject
| Constructor Detail |
|---|
protected AnimationSurface()
| Method Detail |
|---|
public void init()
public void reset()
public void timingEvent(float fraction)
fraction - the fraction of completion between the start and
end of the current cycle. Note that on reversing cycles
(Animator.Direction#BACKWARD) the fraction decreases
from 1.0 to 0 on backwards-running cycles. Note also that animations
with a duration of INFINITE will call
timingEvent with an undefined value for fraction, since there is
no fraction that makes sense if the animation has no defined length.Animator.Directionpublic void begin()
public void end()
public void repeat()
public boolean isFinished(Animator at)
at - the animation thread
public boolean isAnimated(Animator at)
at - the animation thread
public boolean isStarted()
at - the animation thread
public void render(Animator at)
at - the animation threadpublic void setIncrement(int incr)
incr - the increment for animation steps in millisecondspublic int getIncrement()
public void setText(java.lang.String newText)
setText in interface TextHoldernewText - the new textpublic java.lang.String getText()
getText in interface TextHolder
public static java.lang.String replace(java.lang.String source,
java.lang.CharSequence target,
java.lang.CharSequence replacement)
source - the source text/stringtarget - The sequence of char values to be replacedreplacement - The replacement sequence of char values
public static java.lang.String quoteReplacement(java.lang.String s)
String for the specified
String.
This method produces a String that will work
use as a literal replacement s in the
appendReplacement method of the Matcher class.
The String produced will match the sequence of characters
in s treated as a literal sequence. Slashes ('\') and
dollar signs ('$') will be given no special meaning.
s - The string to be literalized
public void setImageType(int imgType)
imgType - = 0 to create a buffered image of TYPE_INT_ARGB,public int getImageType()
the - image type flagpublic void setAntiAlias(boolean aa)
aa - true to turn the anti-aliasing onpublic boolean getAntiAlias()
aa - true if anti-aliasing is onpublic void setRendering(boolean rd)
rd - true for quality, false for speedpublic boolean getRendering()
public void setTexture(java.lang.Object obj)
obj - the Paint object, for example a GradientPaintpublic void setComposite(boolean cp)
cp - the composite e.g. AlphaCompositepublic boolean getComposite()
public void setLoopTime(int lt)
lt - the animation timepublic int getLoopTime()
public java.awt.image.BufferedImage createBufferedImage(int w,
int h,
int imgType)
w - the image widthh - the image heightimgType - the image type e.g. BufferedImage.TYPE_INT_ARGB
public java.awt.Graphics2D createGraphics2D(int width,
int height,
java.awt.image.BufferedImage bi,
java.awt.Graphics g)
width - the widthheight - the heightbi - the buffered imageg - the graphics context
public abstract void drawObjects(int w,
int h,
java.awt.Graphics2D g2)
w - the widthh - the heightg2 - the graphics contextpublic void paintComponent(java.awt.Graphics g)
paintComponent in class javax.swing.JComponentg - the graphics context
public int print(java.awt.Graphics g,
java.awt.print.PageFormat pf,
int pi)
throws java.awt.print.PrinterException
print in interface java.awt.print.Printableg - the graphics contextpf - the page formatpi - the page index
java.awt.print.PrinterException - Problems!public void setAnimator(Animator thread)
thread - the animation threadpublic Animator getAnimator()
public void start()
public void stop()
public void setAutoStart(boolean as)
as - true to automatically start, false to wait for a start signalpublic boolean getAutoStart()
protected void autoStart()
public void setSleepTime(long st)
st - defaults to 100 millisecondspublic long getSleepTime()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||