Groovy Documentation

eu.hansolo.custom
[Java] Class AnimatedProgress

java.lang.Object
  java.awt.Component
      java.awt.Container
          javax.swing.JComponent
              eu.hansolo.custom.AnimatedProgress
All Implemented Interfaces:
ActionListener

public class AnimatedProgress
extends JComponent

Authors:
hansolo


Field Summary
private Color[] COLORS_BOTTOM_LIGHTS

private Color[] COLORS_CENTER_SHADOW

private Color[] COLORS_TOP_LIGHTS

private ComponentAdapter COMPONENT_LISTENER

private Timer CYCLE_TIMER

private float[] DIST_BOTTOM_LIGHTS

private float[] DIST_CENTER_SHADOW

private float[] DIST_FINISHED

private float[] DIST_STANDARD

private float[] DIST_TILTED

private float[] DIST_TOP_LIGHTS

private Color FRAME_COLOR

private Color OUTER_SHADOW_1_COLOR

private float PERIOD

private Font STD_FONT

private int alpha

private int barHeight

private int barWidth

private Area bottomLightArea

private LinearGradientPaint bottomLightGradient

private LinearGradientPaint centerShadowGradient

private Shape centerShadowRoundedRect

private Color color

private int cornerRadius

private Color[] cycleColors

private Color cycleFirstColor

private double cycleLimit

private float cyclePosX

private Color cycleSecondColor

private LinearGradientPaint cyclicJava6

private Point2D endPoint

private double factor

private boolean fadeOut

private Area fixedBar

private Color foregroundColor

private boolean infinite

private String infiniteText

private Color infiniteTextColor

private boolean infiniteTextVisible

private double maxValue

private FontMetrics metrics

private double percentage

private boolean percentageVisible

private float posX

private float posY

private Shape roundRectFixedBar

private Shape roundRectVariableBar

private boolean roundedCorners

private Point2D startPoint

private Rectangle2D textBoundary

private boolean tilted

private Area topLightArea

private LinearGradientPaint topLightGradient

private Line2D upperDarkLine

private double value

private boolean valueVisible

private Area variableBar

private int x

 
Fields inherited from class JComponent
WHEN_FOCUSED, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_IN_FOCUSED_WINDOW, UNDEFINED_CONDITION, TOOL_TIP_TEXT_KEY, TOP_ALIGNMENT, CENTER_ALIGNMENT, BOTTOM_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, WIDTH, HEIGHT, PROPERTIES, SOMEBITS, FRAMEBITS, ALLBITS, ERROR, ABORT
 
Fields inherited from class Container
TOP_ALIGNMENT, CENTER_ALIGNMENT, BOTTOM_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, WIDTH, HEIGHT, PROPERTIES, SOMEBITS, FRAMEBITS, ALLBITS, ERROR, ABORT
 
Constructor Summary
AnimatedProgress()

Creates new form AnimatedProgressBar

 
Method Summary
void actionPerformed(ActionEvent EVENT)

private double calcFactor()

Color getColor()

int getCornerRadius()

Get the radius of the rounded rectangle which is used for the bar.

Color getCycleFirstColor()

Color getCycleSecondColor()

Color getForegroundColor()

private int getGrayScaleIntensity(Color COLOR)

String getInfiniteText()

Color getInfiniteTextColor()

double getMaxValue()

Dimension getMinimumSize()

double getPercentage()

double getValue()

Get the current value of the bar @return

private void initComponents()

boolean isInfinite()

boolean isInfiniteTextVisible()

boolean isPercentageVisible()

boolean isRoundedCorners()

boolean isTilted()

boolean isValueVisible()

protected void paintComponent(Graphics g)

private void prepareForms()

Prepare all forms for the given width

private void recalc()

void reset()

Reset the bar so that you can restart it with different parameters again.

private void setBarWidth(int BAR_WIDTH)

Set the width of the bar in pixels

void setColor(Color COLOR)

Set the color of the gradient by using the given color as cycleSecondColor and a darkened version of the given color as cycleFirstColor.

void setCornerRadius(int CORNER_RADIUS)

Set the radius of the rounded rectangle which is used for the bar

void setCycleFirstColor(Color CYCLE_FIRST_COLOR)

Set the first color of the gradient.

void setCycleSecondColor(Color CYCLE_SECOND_COLOR)

Set the second color of the gradient.

private void setCyclicStart(float CYCLE_POS_X)

Redefine the start position of the gradient paint and repaint the bar in dependence of showValue and showPercent variable.

void setForegroundColor(Color FOREGROUND_COLOR)

Set the color of the text to the given value

void setInfinite(boolean INFINITE)

Enable or disable the infinite progress which means it is tilted, there is no value and it is only a 100%

void setInfiniteText(String INFINITE_TEXT)

void setInfiniteTextColor(Color INFINITE_TEXT_COLOR)

void setInfiniteTextVisible(boolean INFINITE_TEXT_VISIBLE)

void setMaxValue(double MAX_VALUE)

Set the maximum value for the bar

void setPercentage(double PERCENTAGE)

Set the current value of the bar as a percentage value (0 - 100).

void setPercentageVisible(boolean PERCENTAGE_VISIBLE)

Enable or disable the visibility of the value as a percentage value in the center of the bar.

void setRoundedCorners(boolean ROUNDED_CORNERS)

void setTilted(boolean tilted)

Enable or disable a tilted gradient

void setValue(double VALUE)

Set the current value of the bar

void setValueVisible(boolean VALUE_VISIBLE)

Enable or disable the visibility of the value as a number in the center of the bar.

String toString()

 
Methods inherited from class JComponent
contains, getLocation, print, getSize, isOpaque, enable, disable, update, getY, getX, getInsets, getInsets, setFont, getPreferredSize, getMinimumSize, getMaximumSize, getAlignmentX, getAlignmentY, paint, getListeners, addNotify, removeNotify, setFocusTraversalKeys, requestFocus, requestFocus, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, setEnabled, isDoubleBuffered, setVisible, setForeground, setBackground, getBounds, reshape, getWidth, getHeight, setPreferredSize, setMinimumSize, setMaximumSize, getBaseline, getBaselineResizeBehavior, getGraphics, getFontMetrics, repaint, repaint, printAll, requestFocusInWindow, updateUI, getUIClassID, addAncestorListener, setInheritsPopupMenu, getInheritsPopupMenu, setComponentPopupMenu, getComponentPopupMenu, isPaintingTile, isPaintingForPrint, isManagingFocus, setNextFocusableComponent, getNextFocusableComponent, setRequestFocusEnabled, isRequestFocusEnabled, grabFocus, setVerifyInputWhenFocusTarget, getVerifyInputWhenFocusTarget, setBorder, getBorder, setAlignmentY, setAlignmentX, setInputVerifier, getInputVerifier, setDebugGraphicsOptions, getDebugGraphicsOptions, registerKeyboardAction, registerKeyboardAction, unregisterKeyboardAction, getRegisteredKeyStrokes, getConditionForKeyStroke, getActionForKeyStroke, resetKeyboardActions, setInputMap, getInputMap, getInputMap, setActionMap, getActionMap, requestDefaultFocus, getDefaultLocale, setDefaultLocale, setToolTipText, getToolTipText, getToolTipText, getToolTipLocation, getPopupLocation, createToolTip, scrollRectToVisible, setAutoscrolls, getAutoscrolls, setTransferHandler, getTransferHandler, getClientProperty, putClientProperty, isLightweightComponent, setOpaque, computeVisibleRect, getVisibleRect, addVetoableChangeListener, removeVetoableChangeListener, getVetoableChangeListeners, getTopLevelAncestor, removeAncestorListener, getAncestorListeners, revalidate, isValidateRoot, isOptimizedDrawingEnabled, paintImmediately, paintImmediately, setDoubleBuffered, getRootPane, add, add, add, add, add, remove, remove, list, list, removeAll, getComponent, invalidate, validate, getComponentCount, countComponents, getComponents, insets, setComponentZOrder, getComponentZOrder, getLayout, setLayout, doLayout, layout, preferredSize, minimumSize, paintComponents, printComponents, addContainerListener, removeContainerListener, getContainerListeners, deliverEvent, getComponentAt, getComponentAt, locate, getMousePosition, findComponentAt, findComponentAt, isAncestorOf, getFocusTraversalKeys, areFocusTraversalKeysSet, isFocusCycleRoot, isFocusCycleRoot, transferFocusBackward, setFocusTraversalPolicy, getFocusTraversalPolicy, isFocusTraversalPolicySet, setFocusCycleRoot, setFocusTraversalPolicyProvider, isFocusTraversalPolicyProvider, transferFocusDownCycle, applyComponentOrientation, addPropertyChangeListener, addPropertyChangeListener, add, toString, getName, contains, size, getParent, getLocation, remove, setName, list, list, list, getSize, resize, resize, setSize, setSize, enable, location, isValid, setLocale, action, getMousePosition, getGraphicsConfiguration, dispatchEvent, isVisible, isEnabled, isDisplayable, isFocusable, getTreeLock, isLightweight, getPeer, isFocusOwner, transferFocus, getFont, isPreferredSizeSet, isMinimumSizeSet, isMaximumSizeSet, isShowing, handleEvent, postEvent, getFocusCycleRootAncestor, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, setDropTarget, getDropTarget, getToolkit, enableInputMethods, show, show, hide, getForeground, isForegroundSet, getBackground, isBackgroundSet, isFontSet, getLocale, getColorModel, getLocationOnScreen, setLocation, setLocation, move, getBounds, bounds, setBounds, setBounds, setCursor, getCursor, isCursorSet, paintAll, repaint, repaint, repaint, imageUpdate, createImage, createImage, createVolatileImage, createVolatileImage, prepareImage, prepareImage, checkImage, checkImage, setIgnoreRepaint, getIgnoreRepaint, inside, addComponentListener, removeComponentListener, getComponentListeners, addFocusListener, removeFocusListener, getFocusListeners, addHierarchyListener, removeHierarchyListener, getHierarchyListeners, addHierarchyBoundsListener, removeHierarchyBoundsListener, getHierarchyBoundsListeners, addKeyListener, removeKeyListener, getKeyListeners, addMouseListener, removeMouseListener, getMouseListeners, addMouseMotionListener, removeMouseMotionListener, getMouseMotionListeners, addMouseWheelListener, removeMouseWheelListener, getMouseWheelListeners, addInputMethodListener, removeInputMethodListener, getInputMethodListeners, getInputMethodRequests, getInputContext, mouseDown, mouseDrag, mouseUp, mouseMove, mouseEnter, mouseExit, keyDown, keyUp, gotFocus, lostFocus, isFocusTraversable, setFocusable, setFocusTraversalKeysEnabled, getFocusTraversalKeysEnabled, nextFocus, transferFocusUpCycle, hasFocus, removePropertyChangeListener, removePropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, setComponentOrientation, getComponentOrientation, wait, wait, wait, equals, hashCode, getClass, notify, notifyAll
 
Methods inherited from class Container
add, add, add, add, add, remove, remove, list, list, print, removeAll, update, getComponent, invalidate, validate, getComponentCount, countComponents, getComponents, getInsets, insets, setComponentZOrder, getComponentZOrder, getLayout, setLayout, doLayout, layout, setFont, getPreferredSize, preferredSize, getMinimumSize, minimumSize, getMaximumSize, getAlignmentX, getAlignmentY, paint, paintComponents, printComponents, addContainerListener, removeContainerListener, getContainerListeners, getListeners, deliverEvent, getComponentAt, getComponentAt, locate, getMousePosition, findComponentAt, findComponentAt, addNotify, removeNotify, isAncestorOf, setFocusTraversalKeys, getFocusTraversalKeys, areFocusTraversalKeysSet, isFocusCycleRoot, isFocusCycleRoot, transferFocusBackward, setFocusTraversalPolicy, getFocusTraversalPolicy, isFocusTraversalPolicySet, setFocusCycleRoot, setFocusTraversalPolicyProvider, isFocusTraversalPolicyProvider, transferFocusDownCycle, applyComponentOrientation, addPropertyChangeListener, addPropertyChangeListener, add, toString, getName, contains, contains, size, getParent, getLocation, getLocation, remove, setName, list, list, list, getSize, getSize, resize, resize, setSize, setSize, isOpaque, enable, enable, disable, location, isValid, setLocale, getY, getX, action, getMousePosition, getGraphicsConfiguration, dispatchEvent, isVisible, isEnabled, isDisplayable, isFocusable, getTreeLock, isLightweight, getPeer, isFocusOwner, transferFocus, getFont, isPreferredSizeSet, isMinimumSizeSet, isMaximumSizeSet, isShowing, handleEvent, postEvent, getFocusCycleRootAncestor, requestFocus, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, setDropTarget, getDropTarget, getToolkit, setEnabled, isDoubleBuffered, enableInputMethods, setVisible, show, show, hide, getForeground, setForeground, isForegroundSet, getBackground, setBackground, isBackgroundSet, isFontSet, getLocale, getColorModel, getLocationOnScreen, setLocation, setLocation, move, getBounds, getBounds, bounds, setBounds, setBounds, reshape, getWidth, getHeight, setPreferredSize, setMinimumSize, setMaximumSize, getBaseline, getBaselineResizeBehavior, getGraphics, getFontMetrics, setCursor, getCursor, isCursorSet, paintAll, repaint, repaint, repaint, repaint, printAll, imageUpdate, createImage, createImage, createVolatileImage, createVolatileImage, prepareImage, prepareImage, checkImage, checkImage, setIgnoreRepaint, getIgnoreRepaint, inside, addComponentListener, removeComponentListener, getComponentListeners, addFocusListener, removeFocusListener, getFocusListeners, addHierarchyListener, removeHierarchyListener, getHierarchyListeners, addHierarchyBoundsListener, removeHierarchyBoundsListener, getHierarchyBoundsListeners, addKeyListener, removeKeyListener, getKeyListeners, addMouseListener, removeMouseListener, getMouseListeners, addMouseMotionListener, removeMouseMotionListener, getMouseMotionListeners, addMouseWheelListener, removeMouseWheelListener, getMouseWheelListeners, addInputMethodListener, removeInputMethodListener, getInputMethodListeners, getInputMethodRequests, getInputContext, mouseDown, mouseDrag, mouseUp, mouseMove, mouseEnter, mouseExit, keyDown, keyUp, gotFocus, lostFocus, isFocusTraversable, setFocusable, setFocusTraversalKeysEnabled, getFocusTraversalKeysEnabled, requestFocusInWindow, nextFocus, transferFocusUpCycle, hasFocus, removePropertyChangeListener, removePropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, setComponentOrientation, getComponentOrientation, wait, wait, wait, equals, hashCode, getClass, notify, notifyAll
 

Field Detail

COLORS_BOTTOM_LIGHTS

private Color[] COLORS_BOTTOM_LIGHTS


COLORS_CENTER_SHADOW

private Color[] COLORS_CENTER_SHADOW


COLORS_TOP_LIGHTS

private Color[] COLORS_TOP_LIGHTS


COMPONENT_LISTENER

private final ComponentAdapter COMPONENT_LISTENER


CYCLE_TIMER

private final Timer CYCLE_TIMER


DIST_BOTTOM_LIGHTS

private float[] DIST_BOTTOM_LIGHTS


DIST_CENTER_SHADOW

private float[] DIST_CENTER_SHADOW


DIST_FINISHED

private float[] DIST_FINISHED


DIST_STANDARD

private float[] DIST_STANDARD


DIST_TILTED

private float[] DIST_TILTED


DIST_TOP_LIGHTS

private float[] DIST_TOP_LIGHTS


FRAME_COLOR

private Color FRAME_COLOR


OUTER_SHADOW_1_COLOR

private Color OUTER_SHADOW_1_COLOR


PERIOD

private float PERIOD


STD_FONT

private Font STD_FONT


alpha

private int alpha


barHeight

private int barHeight


barWidth

private int barWidth


bottomLightArea

private Area bottomLightArea


bottomLightGradient

private LinearGradientPaint bottomLightGradient


centerShadowGradient

private LinearGradientPaint centerShadowGradient


centerShadowRoundedRect

private Shape centerShadowRoundedRect


color

private Color color


cornerRadius

private int cornerRadius


cycleColors

private Color[] cycleColors


cycleFirstColor

private Color cycleFirstColor


cycleLimit

private double cycleLimit


cyclePosX

private float cyclePosX


cycleSecondColor

private Color cycleSecondColor


cyclicJava6

private LinearGradientPaint cyclicJava6


endPoint

private Point2D endPoint


factor

private double factor


fadeOut

private boolean fadeOut


fixedBar

private Area fixedBar


foregroundColor

private Color foregroundColor


infinite

private boolean infinite


infiniteText

private String infiniteText


infiniteTextColor

private Color infiniteTextColor


infiniteTextVisible

private boolean infiniteTextVisible


maxValue

private double maxValue


metrics

private FontMetrics metrics


percentage

private double percentage


percentageVisible

private boolean percentageVisible


posX

private float posX


posY

private float posY


roundRectFixedBar

private Shape roundRectFixedBar


roundRectVariableBar

private Shape roundRectVariableBar


roundedCorners

private boolean roundedCorners


startPoint

private Point2D startPoint


textBoundary

private Rectangle2D textBoundary


tilted

private boolean tilted


topLightArea

private Area topLightArea


topLightGradient

private LinearGradientPaint topLightGradient


upperDarkLine

private Line2D upperDarkLine


value

private double value


valueVisible

private boolean valueVisible


variableBar

private Area variableBar


x

private int x


 
Constructor Detail

AnimatedProgress

public AnimatedProgress()
Creates new form AnimatedProgressBar


 
Method Detail

actionPerformed

@Override
public void actionPerformed(ActionEvent EVENT)


calcFactor

private double calcFactor()


getColor

public Color getColor()


getCornerRadius

public int getCornerRadius()
Get the radius of the rounded rectangle which is used for the bar.
Returns:


getCycleFirstColor

public Color getCycleFirstColor()


getCycleSecondColor

public Color getCycleSecondColor()


getForegroundColor

public Color getForegroundColor()


getGrayScaleIntensity

private int getGrayScaleIntensity(Color COLOR)


getInfiniteText

public String getInfiniteText()


getInfiniteTextColor

public Color getInfiniteTextColor()


getMaxValue

public double getMaxValue()


getMinimumSize

@Override
public Dimension getMinimumSize()


getPercentage

public double getPercentage()


getValue

public double getValue()
Get the current value of the bar
Returns:


initComponents

private void initComponents()


isInfinite

public boolean isInfinite()


isInfiniteTextVisible

public boolean isInfiniteTextVisible()


isPercentageVisible

public boolean isPercentageVisible()


isRoundedCorners

public boolean isRoundedCorners()


isTilted

public boolean isTilted()


isValueVisible

public boolean isValueVisible()


paintComponent

@Override
protected void paintComponent(Graphics g)


prepareForms

private void prepareForms()
Prepare all forms for the given width


recalc

private void recalc()


reset

public void reset()
Reset the bar so that you can restart it with different parameters again. Also recreate the forms and the animation thread.


setBarWidth

private void setBarWidth(int BAR_WIDTH)
Set the width of the bar in pixels
Parameters:
BAR_WIDTH


setColor

public void setColor(Color COLOR)
Set the color of the gradient by using the given color as cycleSecondColor and a darkened version of the given color as cycleFirstColor.
Parameters:
COLOR


setCornerRadius

public void setCornerRadius(int CORNER_RADIUS)
Set the radius of the rounded rectangle which is used for the bar
Parameters:
CORNER_RADIUS


setCycleFirstColor

public void setCycleFirstColor(Color CYCLE_FIRST_COLOR)
Set the first color of the gradient.
Parameters:
CYCLE_FIRST_COLOR


setCycleSecondColor

public void setCycleSecondColor(Color CYCLE_SECOND_COLOR)
Set the second color of the gradient.
Parameters:
CYCLE_SECOND_COLOR


setCyclicStart

private void setCyclicStart(float CYCLE_POS_X)
Redefine the start position of the gradient paint and repaint the bar in dependence of showValue and showPercent variable. If no text is shown in the bar we only need to repaint the bar itself without the frame.
Parameters:
CYCLE_POS_X


setForegroundColor

public void setForegroundColor(Color FOREGROUND_COLOR)
Set the color of the text to the given value
Parameters:
FOREGROUND_COLOR


setInfinite

public void setInfinite(boolean INFINITE)
Enable or disable the infinite progress which means it is tilted, there is no value and it is only a 100%
Parameters:
INFINITE


setInfiniteText

public void setInfiniteText(String INFINITE_TEXT)


setInfiniteTextColor

public void setInfiniteTextColor(Color INFINITE_TEXT_COLOR)


setInfiniteTextVisible

public void setInfiniteTextVisible(boolean INFINITE_TEXT_VISIBLE)


setMaxValue

public void setMaxValue(double MAX_VALUE)
Set the maximum value for the bar
Parameters:
MAX_VALUE


setPercentage

public void setPercentage(double PERCENTAGE)
Set the current value of the bar as a percentage value (0 - 100).
Parameters:
PERCENTAGE


setPercentageVisible

public void setPercentageVisible(boolean PERCENTAGE_VISIBLE)
Enable or disable the visibility of the value as a percentage value in the center of the bar. If enabled the showValue variable will be disabled.
Parameters:
PERCENTAGE_VISIBLE


setRoundedCorners

public void setRoundedCorners(boolean ROUNDED_CORNERS)


setTilted

public void setTilted(boolean tilted)
Enable or disable a tilted gradient
Parameters:
tilted


setValue

public void setValue(double VALUE)
Set the current value of the bar
Parameters:
VALUE


setValueVisible

public void setValueVisible(boolean VALUE_VISIBLE)
Enable or disable the visibility of the value as a number in the center of the bar. If enabled the showPercent variable will be disabled.
Parameters:
VALUE_VISIBLE


toString

@Override
public String toString()


 

Groovy Documentation