diff -r 4e81657271ba -r 92a8ec883f5d jdk/src/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java Wed Dec 09 11:38:30 2009 +0300 +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java Thu Dec 10 12:08:58 2009 +0300 @@ -32,16 +32,17 @@ import javax.swing.plaf.basic.BasicProgressBarUI; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeEvent; -import sun.swing.plaf.synth.SynthUI; import sun.swing.SwingUtilities2; /** - * Synth's ProgressBarUI. + * Provides the Synth L&F UI delegate for + * {@link javax.swing.JProgressBar}. * * @author Joshua Outwater + * @since 1.7 */ -class SynthProgressBarUI extends BasicProgressBarUI implements SynthUI, - PropertyChangeListener { +public class SynthProgressBarUI extends BasicProgressBarUI + implements SynthUI, PropertyChangeListener { private SynthStyle style; private int progressPadding; private boolean rotateText; // added for Nimbus LAF @@ -49,22 +50,37 @@ private boolean tileWhenIndeterminate; //whether to tile indeterminate painting private int tileWidth; //the width of each tile + /** + * Creates a new UI object for the given component. + * + * @param x component to create UI object for + * @return the UI object + */ public static ComponentUI createUI(JComponent x) { return new SynthProgressBarUI(); } + /** + * @inheritDoc + */ @Override protected void installListeners() { super.installListeners(); progressBar.addPropertyChangeListener(this); } + /** + * @inheritDoc + */ @Override protected void uninstallListeners() { super.uninstallListeners(); progressBar.removePropertyChangeListener(this); } + /** + * @inheritDoc + */ @Override protected void installDefaults() { updateStyle(progressBar); @@ -101,6 +117,9 @@ context.dispose(); } + /** + * @inheritDoc + */ @Override protected void uninstallDefaults() { SynthContext context = getContext(progressBar, ENABLED); @@ -110,6 +129,10 @@ style = null; } + /** + * @inheritDoc + */ + @Override public SynthContext getContext(JComponent c) { return getContext(c, getComponentState(c)); } @@ -119,14 +142,13 @@ SynthLookAndFeel.getRegion(c), style, state); } - private Region getRegion(JComponent c) { - return SynthLookAndFeel.getRegion(c); - } - private int getComponentState(JComponent c) { return SynthLookAndFeel.getComponentState(c); } + /** + * @inheritDoc + */ @Override public int getBaseline(JComponent c, int width, int height) { super.getBaseline(c, width, height); @@ -142,6 +164,9 @@ return -1; } + /** + * @inheritDoc + */ @Override protected Rectangle getBox(Rectangle r) { if (tileWhenIndeterminate) { @@ -151,6 +176,9 @@ } } + /** + * @inheritDoc + */ @Override protected void setAnimationIndex(int newValue) { if (paintOutsideClip) { @@ -164,6 +192,9 @@ } } + /** + * @inheritDoc + */ @Override public void update(Graphics g, JComponent c) { SynthContext context = getContext(c); @@ -176,6 +207,9 @@ context.dispose(); } + /** + * @inheritDoc + */ @Override public void paint(Graphics g, JComponent c) { SynthContext context = getContext(c); @@ -184,6 +218,12 @@ context.dispose(); } + /** + * Paints the specified component. + * + * @param context context for the component being painted + * @param g {@code Graphics} object used for painting + */ protected void paint(SynthContext context, Graphics g) { JProgressBar pBar = (JProgressBar)context.getComponent(); int x = 0, y = 0, width = 0, height = 0; @@ -261,8 +301,14 @@ } } - protected void paintText(SynthContext context, Graphics g, - String title) { + /** + * Paints the component's text. + * + * @param context context for the component being painted + * @param g {@code Graphics} object used for painting + * @param title the text to paint + */ + protected void paintText(SynthContext context, Graphics g, String title) { if (progressBar.isStringPainted()) { SynthStyle style = context.getStyle(); Font font = style.getFont(context); @@ -323,12 +369,20 @@ } } + /** + * @inheritDoc + */ + @Override public void paintBorder(SynthContext context, Graphics g, int x, int y, int w, int h) { context.getPainter().paintProgressBarBorder(context, g, x, y, w, h, progressBar.getOrientation()); } + /** + * @inheritDoc + */ + @Override public void propertyChange(PropertyChangeEvent e) { if (SynthLookAndFeel.shouldUpdateStyle(e) || "indeterminate".equals(e.getPropertyName())) { @@ -336,6 +390,9 @@ } } + /** + * @inheritDoc + */ @Override public Dimension getPreferredSize(JComponent c) { Dimension size = null; @@ -398,5 +455,5 @@ size.height += border.top + border.bottom; return size; - } + } }