187 } 188 } 189 190 protected State getState(final JComponent c) { 191 if (!c.isEnabled()) return State.INACTIVE; 192 if (!AquaFocusHandler.isActive(c)) return State.INACTIVE; 193 return State.ACTIVE; 194 } 195 196 protected void paintString(final Graphics g, final int x, final int y, final int width, final int height) { 197 if (!(g instanceof Graphics2D)) return; 198 199 final Graphics2D g2 = (Graphics2D)g; 200 final String progressString = progressBar.getString(); 201 g2.setFont(progressBar.getFont()); 202 final Point renderLocation = getStringPlacement(g2, progressString, x, y, width, height); 203 final Rectangle oldClip = g2.getClipBounds(); 204 205 if (isHorizontal()) { 206 g2.setColor(selectionForeground); 207 SwingUtilities2.drawString(progressBar, g2, progressString, renderLocation.x, renderLocation.y); 208 } else { // VERTICAL 209 // We rotate it -90 degrees, then translate it down since we are going to be bottom up. 210 final AffineTransform savedAT = g2.getTransform(); 211 g2.transform(AffineTransform.getRotateInstance(0.0f - (Math.PI / 2.0f), 0, 0)); 212 g2.translate(-progressBar.getHeight(), 0); 213 214 // 0,0 is now the bottom left of the viewable area, so we just draw our image at 215 // the render location since that calculation knows about rotation. 216 g2.setColor(selectionForeground); 217 SwingUtilities2.drawString(progressBar, g2, progressString, renderLocation.x, renderLocation.y); 218 219 g2.setTransform(savedAT); 220 } 221 222 g2.setClip(oldClip); 223 } 224 225 /** 226 * Designate the place where the progress string will be painted. This implementation places it at the center of the 227 * progress bar (in both x and y). Override this if you want to right, left, top, or bottom align the progress 228 * string or if you need to nudge it around for any reason. 229 */ 230 protected Point getStringPlacement(final Graphics g, final String progressString, int x, int y, int width, int height) { 231 final FontMetrics fontSizer = progressBar.getFontMetrics(progressBar.getFont()); 232 final int stringWidth = fontSizer.stringWidth(progressString); 233 234 if (!isHorizontal()) { 235 // Calculate the location for the rotated text in real component coordinates. 236 // swapping x & y and width & height 237 final int oldH = height; | 187 } 188 } 189 190 protected State getState(final JComponent c) { 191 if (!c.isEnabled()) return State.INACTIVE; 192 if (!AquaFocusHandler.isActive(c)) return State.INACTIVE; 193 return State.ACTIVE; 194 } 195 196 protected void paintString(final Graphics g, final int x, final int y, final int width, final int height) { 197 if (!(g instanceof Graphics2D)) return; 198 199 final Graphics2D g2 = (Graphics2D)g; 200 final String progressString = progressBar.getString(); 201 g2.setFont(progressBar.getFont()); 202 final Point renderLocation = getStringPlacement(g2, progressString, x, y, width, height); 203 final Rectangle oldClip = g2.getClipBounds(); 204 205 if (isHorizontal()) { 206 g2.setColor(selectionForeground); 207 getTextUIDrawing().drawString(progressBar, g2, progressString, renderLocation.x, renderLocation.y); 208 } else { // VERTICAL 209 // We rotate it -90 degrees, then translate it down since we are going to be bottom up. 210 final AffineTransform savedAT = g2.getTransform(); 211 g2.transform(AffineTransform.getRotateInstance(0.0f - (Math.PI / 2.0f), 0, 0)); 212 g2.translate(-progressBar.getHeight(), 0); 213 214 // 0,0 is now the bottom left of the viewable area, so we just draw our image at 215 // the render location since that calculation knows about rotation. 216 g2.setColor(selectionForeground); 217 getTextUIDrawing().drawString(progressBar, g2, progressString, renderLocation.x, renderLocation.y); 218 219 g2.setTransform(savedAT); 220 } 221 222 g2.setClip(oldClip); 223 } 224 225 /** 226 * Designate the place where the progress string will be painted. This implementation places it at the center of the 227 * progress bar (in both x and y). Override this if you want to right, left, top, or bottom align the progress 228 * string or if you need to nudge it around for any reason. 229 */ 230 protected Point getStringPlacement(final Graphics g, final String progressString, int x, int y, int width, int height) { 231 final FontMetrics fontSizer = progressBar.getFontMetrics(progressBar.getFont()); 232 final int stringWidth = fontSizer.stringWidth(progressString); 233 234 if (!isHorizontal()) { 235 // Calculate the location for the rotated text in real component coordinates. 236 // swapping x & y and width & height 237 final int oldH = height; |