org.formaria.swing
Class ProgressIndicator

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by org.formaria.swing.animation.AnimationSurface
                  extended by org.formaria.swing.ProgressIndicator
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.print.Printable, java.io.Serializable, TextHolder

public class ProgressIndicator
extends AnimationSurface

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.2 $

See Also:
Serialized Form

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  int alphaLevel
          Alpha level of the veil, used for fade in/out.
protected  int barsCount
          Amount of bars composing the circular shape.
protected  float fps
          Amount of frames per seconde.
protected  java.awt.RenderingHints hints
          Rendering hints to set anti aliasing.
protected  double prevHeight
           
protected  double prevWidth
           
protected  int rampDelay
          Duration of the veil's fade in/out.
protected  float scale
           
protected  float shield
          Alpha level of the veil.
protected  java.awt.geom.Area[] ticker
          Contains the bars composing the circular shape.
 
Fields inherited from class org.formaria.swing.animation.AnimationSurface
animationContext, animator, antiAlias, ascent, autoStart, bimg, composite, currentProject, finished, imageType, increment, label, loopTime, oH, oldH, oldW, oW, oX, oY, position, rendering, sleepTime, startTime, texture, 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
ProgressIndicator()
          Creates a new progress panel with default values:
No message 14 bars Veil's alpha level is 70% 15 frames per second Fade in/out last 300 ms
 
Method Summary
 void drawObjects(int w, int h, java.awt.Graphics2D g2)
          Draw the tick objects to the passed graphics context
 void drawTicker(java.awt.Graphics2D g2, int width, int height)
          Draw the indicator to the passed graphics context
 int getAlphaLevel()
          Get alpha level of the veil, used for fade in/out
 int getBarsCount()
          Get amount of bars composing the circular shape
 float getFps()
          Get amount of frames per second
 int getRampDelay()
          Get duration of the veil's fade in/out
 float getScale()
          Get the scaled size of the indicator
 float getShield()
          Get alpha level of the veil
 void init()
          Intializes the progress indicator
 void setAlphaLevel(int a)
          Set alpha level of the veil, used for fade in/out
 void setBarsCount(int b)
          Set amount of bars composing the circular shape
 void setFps(float f)
          Set amount of frames per second.
 void setRampDelay(int r)
          Set duration of the veil's fade in/out
 void setScale(float s)
          Set the scaled size of the indicator
 void setShield(float s)
          Set alpha level of the veil
 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 org.formaria.swing.animation.AnimationSurface
autoStart, begin, createBufferedImage, createGraphics2D, end, getAnimator, getAntiAlias, getAutoStart, getComposite, getImageType, getIncrement, getLoopTime, getRendering, getSleepTime, getText, isAnimated, isFinished, isStarted, paintComponent, print, quoteReplacement, render, repeat, replace, reset, setAnimator, setAntiAlias, setAutoStart, setComposite, setImageType, setIncrement, setLoopTime, setRendering, setSleepTime, setText, setTexture, start
 
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

ticker

protected java.awt.geom.Area[] ticker
Contains the bars composing the circular shape.


alphaLevel

protected int alphaLevel
Alpha level of the veil, used for fade in/out.


rampDelay

protected int rampDelay
Duration of the veil's fade in/out.


shield

protected float shield
Alpha level of the veil.


barsCount

protected int barsCount
Amount of bars composing the circular shape.


fps

protected float fps
Amount of frames per seconde. Lowers this to save CPU.


hints

protected java.awt.RenderingHints hints
Rendering hints to set anti aliasing.


prevWidth

protected double prevWidth

prevHeight

protected double prevHeight

scale

protected float scale
Constructor Detail

ProgressIndicator

public ProgressIndicator()
Creates a new progress panel with default values:

Method Detail

init

public void init()
Intializes the progress indicator

Overrides:
init in class AnimationSurface

timingEvent

public void timingEvent(float fraction)
This method will receive all of the timing events from an Animator during an animation. The fraction is the percent elapsed (0 to 1) of the current animation cycle.

Overrides:
timingEvent in class AnimationSurface
Parameters:
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.
See Also:
Animator.Direction

drawObjects

public void drawObjects(int w,
                        int h,
                        java.awt.Graphics2D g2)
Draw the tick objects to the passed graphics context

Specified by:
drawObjects in class AnimationSurface
Parameters:
w - int specifying the width of the component
h - int specifying the width of the component
g2 - Graphics2D

drawTicker

public void drawTicker(java.awt.Graphics2D g2,
                       int width,
                       int height)
Draw the indicator to the passed graphics context

Parameters:
g2 - Graphics2D
width - int specifying the width of the component
height - int specifying the width of the component

stop

public void stop()
End the animation

Overrides:
stop in class AnimationSurface

getScale

public float getScale()
Get the scaled size of the indicator

Returns:
float - the scale

setScale

public void setScale(float s)
Set the scaled size of the indicator

Parameters:
float - - the scale

getRampDelay

public int getRampDelay()
Get duration of the veil's fade in/out


setRampDelay

public void setRampDelay(int r)
Set duration of the veil's fade in/out

Parameters:
int - - the duration

getShield

public float getShield()
Get alpha level of the veil


setShield

public void setShield(float s)
Set alpha level of the veil

Parameters:
float - - the alpha level

getAlphaLevel

public int getAlphaLevel()
Get alpha level of the veil, used for fade in/out

Returns:
int the alpha level

setAlphaLevel

public void setAlphaLevel(int a)
Set alpha level of the veil, used for fade in/out

Parameters:
a - int - the alpha level

getBarsCount

public int getBarsCount()
Get amount of bars composing the circular shape

Returns:
int specifying the amount of bars

setBarsCount

public void setBarsCount(int b)
Set amount of bars composing the circular shape

Parameters:
b - int - amount of bars

getFps

public float getFps()
Get amount of frames per second

Returns:
float - frames per second

setFps

public void setFps(float f)
Set amount of frames per second. Lower this to save CPU

Parameters:
f - float - frames per second