|
||||||||||
| 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
net.java.swingfx.waitwithstyle.InfiniteProgressPanel
public class InfiniteProgressPanel
An infinite progress panel displays a rotating figure and a message to notice the user of a long, duration unknown task. The shape and the text are drawn upon a white veil which alpha level (or shield value) lets the underlying component shine through. This panel is meant to be used asa glass pane in the window performing the long operation.
Contrary to regular glass panes, you don't need to set it visible or not by yourself. Once you've started the animation all the mouse events are intercepted by this panel, preventing them from being forwared to the underlying components.
The panel can be controlled by the start(), stop() and interrupt() methods.
Example:
InfiniteProgressPanel pane = new InfiniteProgressPanel(); frame.setGlassPane(pane); ... later in some other EDT event (otherwise the panel doesn't know the size and draws real funky) pane.start()
Several properties can be configured at creation time. The message and its font can be changed at
runtime. Changing the font can be done using setFont() and setForeground().
If you experience performance issues, prefer the PerformanceInfiniteProgressPanel.
For cancelable progress use the CancelableProgressPanel or the CancelableProgressAdapter
with a Panel.
| Nested Class Summary | |
|---|---|
private class |
InfiniteProgressPanel.Animator
Animation thread. |
private class |
InfiniteProgressPanel.Ticker
|
| 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 java.lang.Thread |
animation
The animation thread is responsible for fade in/out and rotation. |
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 InfiniteProgressAdapter |
infiniteProgressAdapter
An infiniteProgressAdapter to performa special drawing, ex: a cancel button. |
protected int |
rampDelay
Duration of the veil's fade in/out. |
private static long |
serialVersionUID
|
protected float |
shield
Alpha level of the veil. |
protected boolean |
started
Notifies whether the animation is running or not. |
protected java.lang.String |
text
Message displayed below the circular shape. |
protected InfiniteProgressPanel.Ticker |
ticker
Contains the bars composing the circular shape. |
| 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.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
InfiniteProgressPanel()
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 |
|
InfiniteProgressPanel(java.lang.String text)
Creates a new progress panel with default values: 14 bars Veil's alpha level is 70% 15 frames per second Fade in/out last 300 ms |
|
InfiniteProgressPanel(java.lang.String text,
int barsCount)
Creates a new progress panel with default values: Veil's alpha level is 70% 15 frames per second Fade in/out last 300 ms |
|
InfiniteProgressPanel(java.lang.String text,
int barsCount,
float shield)
Creates a new progress panel with default values: 15 frames per second Fade in/out last 300 ms |
|
InfiniteProgressPanel(java.lang.String text,
int barsCount,
float shield,
float fps)
Creates a new progress panel with default values: Fade in/out last 300 ms |
|
InfiniteProgressPanel(java.lang.String text,
int barsCount,
float shield,
float fps,
int rampDelay)
Creates a new progress panel. |
|
| Method Summary | |
|---|---|
void |
addCancelListener(java.awt.event.ActionListener listener)
Adds a listener to the cancel button in this progress panel. |
private java.awt.geom.Area |
buildPrimitive()
Builds a bar. |
private void |
buildTicker()
Builds the circular shape and returns the result as an array of Area. |
static double |
drawTextAt(java.lang.String text,
java.awt.Font font,
java.awt.Graphics2D g2,
int width,
double y,
java.awt.Color foreGround)
Draw text in a Graphics2D. |
javax.swing.JComponent |
getComponent()
Gets the interface as a JComponent (usually returns "this") |
java.lang.String |
getText()
Returns the current displayed message. |
private InfiniteProgressPanel.Ticker |
getTicker()
Ticker is not built until set bounds is called (or our width and height are > 0). |
void |
interrupt()
Interrupts the animation, whatever its state is. |
void |
mouseClicked(java.awt.event.MouseEvent e)
|
void |
mouseEntered(java.awt.event.MouseEvent e)
|
void |
mouseExited(java.awt.event.MouseEvent e)
|
void |
mousePressed(java.awt.event.MouseEvent e)
|
void |
mouseReleased(java.awt.event.MouseEvent e)
|
void |
paintComponent(java.awt.Graphics g)
|
void |
removeCancelListener(java.awt.event.ActionListener listener)
Removes a listener to the cancel button in this progress panel. |
void |
setInfiniteProgressAdapter(InfiniteProgressAdapter infiniteProgressAdapter)
|
void |
setText(java.lang.String text)
Changes the displayed message at runtime. |
void |
start()
Starts the waiting animation by fading the veil in, then rotating the shapes. |
void |
stop()
Stops the waiting animation by stopping the rotation of the circular shape and then by fading out the veil. |
| 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 |
|---|
private static final long serialVersionUID
protected InfiniteProgressPanel.Ticker ticker
protected java.lang.Thread animation
protected boolean started
protected int alphaLevel
protected int rampDelay
protected float shield
protected java.lang.String text
protected int barsCount
protected float fps
protected java.awt.RenderingHints hints
protected InfiniteProgressAdapter infiniteProgressAdapter
| Constructor Detail |
|---|
public InfiniteProgressPanel()
public InfiniteProgressPanel(java.lang.String text)
text - The message to be displayed. Can be null or empty.
public InfiniteProgressPanel(java.lang.String text,
int barsCount)
text - The message to be displayed. Can be null or empty.barsCount - The amount of bars composing the circular shape
public InfiniteProgressPanel(java.lang.String text,
int barsCount,
float shield)
text - The message to be displayed. Can be null or empty.barsCount - The amount of bars composing the circular shape.shield - The alpha level between 0.0 and 1.0 of the colored shield (or veil).
public InfiniteProgressPanel(java.lang.String text,
int barsCount,
float shield,
float fps)
text - The message to be displayed. Can be null or empty.barsCount - The amount of bars composing the circular shape.shield - The alpha level between 0.0 and 1.0 of the colored shield (or veil).fps - The number of frames per second. Lower this value to decrease CPU usage.
public InfiniteProgressPanel(java.lang.String text,
int barsCount,
float shield,
float fps,
int rampDelay)
text - The message to be displayed. Can be null or empty.barsCount - The amount of bars composing the circular shape.shield - The alpha level between 0.0 and 1.0 of the colored shield (or veil).fps - The number of frames per second. Lower this value to decrease CPU usage.rampDelay - The duration, in milli seconds, of the fade in and the fade out of the veil.| Method Detail |
|---|
public void setText(java.lang.String text)
setText in interface CancelableAdapteetext - The message to be displayed. Can be null or empty.public java.lang.String getText()
public void setInfiniteProgressAdapter(InfiniteProgressAdapter infiniteProgressAdapter)
infiniteProgressAdapter - an infiniteProgressAdapter to perform special drawing (ex: a cancel button)public void addCancelListener(java.awt.event.ActionListener listener)
addCancelListener in interface CancelableAdapteelistener -
java.lang.RuntimeException - if the infiniteProgressAdapter is null or is not a CancelableProgessAdapterpublic void removeCancelListener(java.awt.event.ActionListener listener)
removeCancelListener in interface CancelableAdapteelistener -
java.lang.RuntimeException - if the infiniteProgressAdapter is null or is not a CancelableProgessAdapterpublic void start()
start in interface CancelableAdapteepublic void stop()
stop in interface CancelableAdapteepublic javax.swing.JComponent getComponent()
CancelableAdaptee
getComponent in interface CancelableAdapteepublic void interrupt()
public void paintComponent(java.awt.Graphics g)
paintComponent in class javax.swing.JComponent
public static double drawTextAt(java.lang.String text,
java.awt.Font font,
java.awt.Graphics2D g2,
int width,
double y,
java.awt.Color foreGround)
text - the text to drawfont - the font to useg2 - the graphics context to draw inwidth - the width of the parent, so it can be centeredy - the height at which to drawforeGround - the foreground color to draw in
private InfiniteProgressPanel.Ticker getTicker()
private void buildTicker()
Area. Each Area is one
of the bars composing the shape.
private java.awt.geom.Area buildPrimitive()
public void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked in interface java.awt.event.MouseListenerpublic void mousePressed(java.awt.event.MouseEvent e)
mousePressed in interface java.awt.event.MouseListenerpublic void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased in interface java.awt.event.MouseListenerpublic void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered in interface java.awt.event.MouseListenerpublic void mouseExited(java.awt.event.MouseEvent e)
mouseExited in interface java.awt.event.MouseListener
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||