public class BasicProgressBarUI extends ProgressBarUI
| Modifier and Type | Class and Description |
|---|---|
class |
BasicProgressBarUI
This class should be treated as a "protected" inner class.
|
| Modifier and Type | Field and Description |
|---|---|
protected Rectangle |
boxRect
Used to hold the location and size of the bouncing box (returned by getBox) to be painted.
|
protected ChangeListener |
changeListener
|
protected JProgressBar |
progressBar
|
| Constructor and Description |
|---|
BasicProgressBarUI()
|
| Modifier and Type | Method and Description |
|---|---|
static ComponentUI |
createUI(JComponent
|
protected int |
getAmountFull(Insets
This determines the amount of the progress bar that should be filled based on the percent done gathered from the model.
|
protected int |
getAnimationIndex()
Gets the index of the current animation frame.
|
int |
getBaseline(JComponent
Returns the baseline.
|
Component |
getBaselineResizeBehavior(JComponent
Returns an enum indicating how the baseline of the component changes as the size changes.
|
protected Rectangle |
getBox(Rectangle
Stores the position and size of the bouncing box that would be painted for the current animation index in
r and returns
r.
|
protected int |
getBoxLength(int availableLength, int otherDimension)
Returns the length of the "bouncing box" to be painted.
|
protected int |
getCellLength()
Returns the width (if HORIZONTAL) or height (if VERTICAL) of each of the individual cells/units to be rendered in the progress bar.
|
protected int |
getCellSpacing()
Returns the spacing between each of the cells/units in the progress bar.
|
protected int |
getFrameCount()
Returns the number of frames for the complete animation loop used by an indeterminate JProgessBar.
|
Dimension |
getMaximumSize(JComponent
Returns the specified component's maximum size appropriate for the look and feel.
|
Dimension |
getMinimumSize(JComponent
The Minimum size for this component is 10.
|
protected Dimension |
getPreferredInnerHorizontal()
|
protected Dimension |
getPreferredInnerVertical()
|
Dimension |
getPreferredSize(JComponent
Returns the specified component's preferred size appropriate for the look and feel.
|
protected Color |
getSelectionBackground()
The "selectionBackground" is the color of the text when it is painted over an unfilled area of the progress bar.
|
protected Color |
getSelectionForeground()
The "selectionForeground" is the color of the text when it is painted over a filled area of the progress bar.
|
protected Point |
getStringPlacement(Graphics
Designate the place where the progress string will be painted.
|
protected void |
incrementAnimationIndex()
Sets the index of the current animation frame, to the next valid value, which results in the progress bar being repainted.
|
protected void |
installDefaults()
|
protected void |
installListeners()
|
void |
installUI(JComponent
Configures the specified component appropriately for the look and feel.
|
void |
paint(Graphics
Delegates painting to one of two methods: paintDeterminate or paintIndeterminate.
|
protected void |
paintDeterminate(Graphics
All purpose paint method that should do the right thing for almost all linear, determinate progress bars.
|
protected void |
paintIndeterminate(Graphics
All purpose paint method that should do the right thing for all linear bouncing-box progress bars.
|
protected void |
paintString(Graphics
|
protected void |
setAnimationIndex(int newValue)
Sets the index of the current animation frame to the specified value and requests that the progress bar be repainted.
|
protected void |
setCellLength(int cellLen)
|
protected void |
setCellSpacing(int cellSpace)
|
protected void |
startAnimationTimer()
Starts the animation thread, creating and initializing it if necessary.
|
protected void |
stopAnimationTimer()
Stops the animation thread.
|
protected void |
uninstallDefaults()
|
protected void |
uninstallListeners()
Removes all listeners installed by this object.
|
void |
uninstallUI(JComponent
Reverses configuration which was done on the specified component during
installUI.
|
contains, getAccessibleChild, getAccessibleChildrenCount, updateprotected JProgressBarprogressBar
protected ChangeListenerchangeListener
protected RectangleboxRect
public static ComponentUIcreateUI(JComponent x)
public void installUI(JComponentc)
ComponentUI
ComponentUI instance is being installed as the UI delegate on the specified component. This method should completely configure the component for the look and feel, including the following:
LayoutManager on the component if necessary. PropertyChangeListener on the component in order to detect and respond to component property changes appropriately. installUI in class
ComponentUI
c - the component where this UI delegate is being installed
ComponentUI.uninstallUI(javax.swing.JComponent) ,
JComponent.setUI(javax.swing.plaf.ComponentUI) ,
JComponent.updateUI()
public void uninstallUI(JComponentc)
ComponentUI
installUI. This method is invoked when this
UIComponent instance is being removed as the UI delegate for the specified component. This method should undo the configuration performed in
installUI, being careful to leave the
JComponent instance in a clean state (no extraneous listeners, look-and-feel-specific property objects, etc.). This should include the following:
uninstallUI in class
ComponentUI
c - the component from which this UI delegate is being removed; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple components
ComponentUI.installUI(javax.swing.JComponent) ,
JComponent.updateUI()
protected void installDefaults()
protected void uninstallDefaults()
protected void installListeners()
protected void startAnimationTimer()
stopAnimationTimer()
protected void stopAnimationTimer()
startAnimationTimer()
protected void uninstallListeners()
public int getBaseline(JComponentc, int width, int height)
getBaseline in class
ComponentUI
c -
JComponent baseline is being requested for
width - the width to get the baseline for
height - the height to get the baseline for
NullPointerException - if
c is
null
IllegalArgumentException - if width or height is < 0
JComponent.getBaseline(int, int)
public Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c)
getBaselineResizeBehavior in class
ComponentUI
c -
JComponent to return baseline resize behavior for
NullPointerException - if
c is
null
JComponent.getBaseline(int, int)
protected DimensiongetPreferredInnerHorizontal()
protected DimensiongetPreferredInnerVertical()
protected ColorgetSelectionForeground()
protected ColorgetSelectionBackground()
protected int getCellLength()
setCellLength(int),
JProgressBar.isStringPainted()
protected void setCellLength(int cellLen)
protected int getCellSpacing()
setCellSpacing(int),
JProgressBar.isStringPainted()
protected void setCellSpacing(int cellSpace)
protected int getAmountFull(Insetsb, int width, int height)
public void paint(Graphicsg, JComponent c)
paint in class
ComponentUI
g - the
Graphics context in which to paint
c - the component being painted; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple components
ComponentUI.update(java.awt.Graphics, javax.swing.JComponent)
protected RectanglegetBox(Rectangle r)
r and returns
r. Subclasses that add to the painting performed in this class's implementation of
paintIndeterminate -- to draw an outline around the bouncing box, for example -- can use this method to get the location of the bouncing box that was just painted. By overriding this method, you have complete control over the size and position of the bouncing box, without having to reimplement
paintIndeterminate.
r - the Rectangle instance to be modified; may be
null
null if no box should be drawn; otherwise, returns the passed-in rectangle (if non-null) or a new rectangle
setAnimationIndex(int)
protected int getBoxLength(int availableLength,
int otherDimension)
paintIndeterminate to get the width (if the progress bar is horizontal) or height (if vertical) of the box. For example:
boxRect.width = getBoxLength(componentInnards.width,
componentInnards.height);
availableLength - the amount of space available for the bouncing box to move in; for a horizontal progress bar, for example, this should be the inside width of the progress bar (the component width minus borders)
otherDimension - for a horizontal progress bar, this should be the inside height of the progress bar; this value might be used to constrain or determine the return value
availableLength
SwingUtilities.calculateInnerArea(javax.swing.JComponent, java.awt.Rectangle)
protected void paintIndeterminate(Graphicsg, JComponent c)
paintDeterminate(java.awt.Graphics, javax.swing.JComponent)
protected void paintDeterminate(Graphicsg, JComponent c)
paintIndeterminate(java.awt.Graphics, javax.swing.JComponent)
protected void paintString(Graphicsg, int x, int y, int width, int height, int amountFull, Insets b)
protected PointgetStringPlacement(Graphics g, String progressString, int x, int y, int width, int height)
public DimensiongetPreferredSize(JComponent c)
ComponentUI
null is returned, the preferred size will be calculated by the component's layout manager instead (this is the preferred approach for any component with a specific layout manager installed). The default implementation of this method returns
null.
getPreferredSize in class
ComponentUI
c - the component whose preferred size is being queried; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple components
JComponent.getPreferredSize() ,
LayoutManager.preferredLayoutSize(java.awt.Container)
public DimensiongetMinimumSize(JComponent c)
getMinimumSize in class
ComponentUI
c - the component whose minimum size is being queried; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple components
Dimension object or
null
JComponent.getMinimumSize() ,
LayoutManager.minimumLayoutSize(java.awt.Container) ,
ComponentUI.getPreferredSize(javax.swing.JComponent)
public DimensiongetMaximumSize(JComponent c)
ComponentUI
null is returned, the maximum size will be calculated by the component's layout manager instead (this is the preferred approach for any component with a specific layout manager installed). The default implementation of this method invokes
getPreferredSize and returns that value.
getMaximumSize in class
ComponentUI
c - the component whose maximum size is being queried; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple components
Dimension object or
null
JComponent.getMaximumSize() ,
LayoutManager2.maximumLayoutSize(java.awt.Container)
protected int getAnimationIndex()
protected final int getFrameCount()
protected void setAnimationIndex(int newValue)
repaint method is invoked.
newValue - the new animation index; no checking is performed on its value
incrementAnimationIndex()
protected void incrementAnimationIndex()
setAnimationIndex(int)