jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java
changeset 33856 875f59862274
parent 25859 3317bb8137f4
child 37698 4d798c873df0
equal deleted inserted replaced
33855:2450e37e84dd 33856:875f59862274
     1 /*
     1 /*
     2  * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    47     private int progressPadding;
    47     private int progressPadding;
    48     private boolean rotateText; // added for Nimbus LAF
    48     private boolean rotateText; // added for Nimbus LAF
    49     private boolean paintOutsideClip;
    49     private boolean paintOutsideClip;
    50     private boolean tileWhenIndeterminate; //whether to tile indeterminate painting
    50     private boolean tileWhenIndeterminate; //whether to tile indeterminate painting
    51     private int tileWidth; //the width of each tile
    51     private int tileWidth; //the width of each tile
       
    52     private Dimension minBarSize; // minimal visible bar size
       
    53     private int glowWidth; // Glow around the bar foreground
    52 
    54 
    53     /**
    55     /**
    54      * Creates a new UI object for the given component.
    56      * Creates a new UI object for the given component.
    55      *
    57      *
    56      * @param x component to create UI object for
    58      * @param x component to create UI object for
   112                 tileWidth *= 0.857;
   114                 tileWidth *= 0.857;
   113             } else if ("mini".equals(scaleKey)){
   115             } else if ("mini".equals(scaleKey)){
   114                 tileWidth *= 0.784;
   116                 tileWidth *= 0.784;
   115             }
   117             }
   116         }
   118         }
       
   119         minBarSize = (Dimension)style.get(context, "ProgressBar.minBarSize");
       
   120         glowWidth = style.getInt(context, "ProgressBar.glowWidth", 0);
   117         context.dispose();
   121         context.dispose();
   118     }
   122     }
   119 
   123 
   120     /**
   124     /**
   121      * {@inheritDoc}
   125      * {@inheritDoc}
   256                             - (pBarInsets.top + progressPadding
   260                             - (pBarInsets.top + progressPadding
   257                              + pBarInsets.bottom + progressPadding);
   261                              + pBarInsets.bottom + progressPadding);
   258 
   262 
   259                     if (!SynthLookAndFeel.isLeftToRight(pBar)) {
   263                     if (!SynthLookAndFeel.isLeftToRight(pBar)) {
   260                         x = pBar.getWidth() - pBarInsets.right - width
   264                         x = pBar.getWidth() - pBarInsets.right - width
   261                                 - progressPadding;
   265                                 - progressPadding - glowWidth;
   262                     }
   266                     }
   263                 } else {  // JProgressBar.VERTICAL
   267                 } else {  // JProgressBar.VERTICAL
   264                     x = pBarInsets.left + progressPadding;
   268                     x = pBarInsets.left + progressPadding;
   265                     width = pBar.getWidth()
   269                     width = pBar.getWidth()
   266                             - (pBarInsets.left + progressPadding
   270                             - (pBarInsets.left + progressPadding
   269                             - (pBarInsets.top + progressPadding
   273                             - (pBarInsets.top + progressPadding
   270                              + pBarInsets.bottom + progressPadding)));
   274                              + pBarInsets.bottom + progressPadding)));
   271                     y = pBar.getHeight() - pBarInsets.bottom - height
   275                     y = pBar.getHeight() - pBarInsets.bottom - height
   272                             - progressPadding;
   276                             - progressPadding;
   273 
   277 
   274                     // When the progress bar is vertical we always paint
   278                     if (SynthLookAndFeel.isLeftToRight(pBar)) {
   275                     // from bottom to top, not matter what the component
   279                         y -= glowWidth;
   276                     // orientation is.
   280                     }
   277                 }
   281                 }
   278             }
   282             }
   279         } else {
   283         } else {
   280             boxRect = getBox(boxRect);
   284             boxRect = getBox(boxRect);
   281             x = boxRect.x + progressPadding;
   285             x = boxRect.x + progressPadding;
   305                             context, g, x, i, width, tileWidth, pBar.getOrientation());
   309                             context, g, x, i, width, tileWidth, pBar.getOrientation());
   306                 }
   310                 }
   307             }
   311             }
   308             g.setClip(clip);
   312             g.setClip(clip);
   309         } else {
   313         } else {
   310             context.getPainter().paintProgressBarForeground(context, g,
   314             if (minBarSize == null || (width >= minBarSize.width
   311                     x, y, width, height, pBar.getOrientation());
   315                     && height >= minBarSize.height)) {
       
   316                 context.getPainter().paintProgressBarForeground(context, g,
       
   317                         x, y, width, height, pBar.getOrientation());
       
   318             }
   312         }
   319         }
   313 
   320 
   314         if (pBar.isStringPainted()) {
   321         if (pBar.isStringPainted()) {
   315             paintText(context, g, pBar.getString());
   322             paintText(context, g, pBar.getString());
   316         }
   323         }