< prev index next >

src/java.desktop/share/classes/javax/swing/plaf/basic/BasicProgressBarUI.java

Print this page

        

*** 131,140 **** --- 131,142 ---- /** For bouncing-box animation, the change in position per frame. */ private double delta = 0.0; private int maxPosition = 0; //maximum X (horiz) or Y box location + private TextUIDrawing textUIDrawing; + /** * Returns a new instance of {@code BasicProgressBarUI}. * * @param x a component * @return a new instance of {@code BasicProgressBarUI}
*** 174,190 **** --- 176,197 ---- cellLength = UIManager.getInt("ProgressBar.cellLength"); if (cellLength == 0) cellLength = 1; cellSpacing = UIManager.getInt("ProgressBar.cellSpacing"); selectionForeground = UIManager.getColor("ProgressBar.selectionForeground"); selectionBackground = UIManager.getColor("ProgressBar.selectionBackground"); + textUIDrawing = SwingUtilities2.getTextUIDrawing(textUIDrawing); } /** * Unintalls default properties. */ protected void uninstallDefaults() { LookAndFeel.uninstallBorder(progressBar); + if (textUIDrawing != SwingUtilities2.DEFAULT_UI_TEXT_DRAWING + && textUIDrawing instanceof UIResource) { + textUIDrawing = SwingUtilities2.DEFAULT_UI_TEXT_DRAWING; + } } /** * Registers listeners. */
*** 825,852 **** x, y, width, height); Rectangle oldClip = g2.getClipBounds(); if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) { g2.setColor(getSelectionBackground()); ! SwingUtilities2.drawString(progressBar, g2, progressString, renderLocation.x, renderLocation.y); g2.setColor(getSelectionForeground()); g2.clipRect(fillStart, y, amountFull, height); ! SwingUtilities2.drawString(progressBar, g2, progressString, renderLocation.x, renderLocation.y); } else { // VERTICAL g2.setColor(getSelectionBackground()); AffineTransform rotate = AffineTransform.getRotateInstance(Math.PI/2); g2.setFont(progressBar.getFont().deriveFont(rotate)); renderLocation = getStringPlacement(g2, progressString, x, y, width, height); ! SwingUtilities2.drawString(progressBar, g2, progressString, renderLocation.x, renderLocation.y); g2.setColor(getSelectionForeground()); g2.clipRect(x, fillStart, width, amountFull); ! SwingUtilities2.drawString(progressBar, g2, progressString, renderLocation.x, renderLocation.y); } g2.setClip(oldClip); } --- 832,859 ---- x, y, width, height); Rectangle oldClip = g2.getClipBounds(); if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) { g2.setColor(getSelectionBackground()); ! textUIDrawing.drawString(progressBar, g2, progressString, renderLocation.x, renderLocation.y); g2.setColor(getSelectionForeground()); g2.clipRect(fillStart, y, amountFull, height); ! textUIDrawing.drawString(progressBar, g2, progressString, renderLocation.x, renderLocation.y); } else { // VERTICAL g2.setColor(getSelectionBackground()); AffineTransform rotate = AffineTransform.getRotateInstance(Math.PI/2); g2.setFont(progressBar.getFont().deriveFont(rotate)); renderLocation = getStringPlacement(g2, progressString, x, y, width, height); ! textUIDrawing.drawString(progressBar, g2, progressString, renderLocation.x, renderLocation.y); g2.setColor(getSelectionForeground()); g2.clipRect(x, fillStart, width, amountFull); ! textUIDrawing.drawString(progressBar, g2, progressString, renderLocation.x, renderLocation.y); } g2.setClip(oldClip); }
*** 868,878 **** */ protected Point getStringPlacement(Graphics g, String progressString, int x,int y,int width,int height) { FontMetrics fontSizer = SwingUtilities2.getFontMetrics(progressBar, g, progressBar.getFont()); ! int stringWidth = SwingUtilities2.stringWidth(progressBar, fontSizer, progressString); if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) { return new Point(x + Math.round(width/2 - stringWidth/2), y + ((height + --- 875,885 ---- */ protected Point getStringPlacement(Graphics g, String progressString, int x,int y,int width,int height) { FontMetrics fontSizer = SwingUtilities2.getFontMetrics(progressBar, g, progressBar.getFont()); ! int stringWidth = textUIDrawing.getStringWidth(progressBar, fontSizer, progressString); if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) { return new Point(x + Math.round(width/2 - stringWidth/2), y + ((height +
*** 897,907 **** size = new Dimension(getPreferredInnerHorizontal()); // Ensure that the progress string will fit if (progressBar.isStringPainted()) { // I'm doing this for completeness. String progString = progressBar.getString(); ! int stringWidth = SwingUtilities2.stringWidth( progressBar, fontSizer, progString); if (stringWidth > size.width) { size.width = stringWidth; } // This uses both Height and Descent to be sure that --- 904,914 ---- size = new Dimension(getPreferredInnerHorizontal()); // Ensure that the progress string will fit if (progressBar.isStringPainted()) { // I'm doing this for completeness. String progString = progressBar.getString(); ! int stringWidth = textUIDrawing.getStringWidth( progressBar, fontSizer, progString); if (stringWidth > size.width) { size.width = stringWidth; } // This uses both Height and Descent to be sure that
*** 924,934 **** fontSizer.getDescent(); if (stringHeight > size.width) { size.width = stringHeight; } // This is also for completeness. ! int stringWidth = SwingUtilities2.stringWidth( progressBar, fontSizer, progString); if (stringWidth > size.height) { size.height = stringWidth; } } --- 931,941 ---- fontSizer.getDescent(); if (stringHeight > size.width) { size.width = stringHeight; } // This is also for completeness. ! int stringWidth = textUIDrawing.getStringWidth( progressBar, fontSizer, progString); if (stringWidth > size.height) { size.height = stringWidth; } }
< prev index next >