@Override protected Rectangle getBox(Rectangle r) { // Insets b = this.getInsets(); // area for border int barRectWidth = progressBar.getWidth() - 2 * margin; int barRectHeight = progressBar.getHeight() - 2 * margin; return new Rectangle(margin, margin, barRectWidth, barRectHeight); }
public void actionPerformed(ActionEvent ae) { // style1 if (x == 0) delta = +1; else if (x == progressBar.getWidth()) delta = -1; x += delta; progressBar.repaint(); }
public void actionPerformed(ActionEvent ae) { // style1 if (x == 0) delta = +1; else if (x == progressBar.getWidth()) delta = -1; x += delta; progressBar.repaint(); }
@Override protected Rectangle getBox(Rectangle r) { // Insets b = this.getInsets(); // area for border int barRectWidth = progressBar.getWidth() - 2 * margin; int barRectHeight = progressBar.getHeight() - 2 * margin; return new Rectangle(margin, margin, barRectWidth, barRectHeight); }
public void actionPerformed(ActionEvent ae) { // style1 if (x == 0) delta = +1; else if (x == progressBar.getWidth()) delta = -1; x += delta; progressBar.repaint(); }
public void repaintOnEDT() { assert EventQueue.isDispatchThread() : "not EDT thread"; // this code, together with the tracked code, // is supposed to run on the EDT, therefore // paintImmediately() instead of repaint() progressBar.paintImmediately(0, 0, progressBar.getWidth(), progressBar.getHeight()); } }
private Rectangle calcBounds(JProgressBar pBar) { boundsRect.x = 0; boundsRect.y = 0; boundsRect.width = pBar.getWidth(); boundsRect.height = pBar.getHeight(); if (pBar.getOrientation() == JProgressBar.HORIZONTAL) { boundsRect.y = (boundsRect.height - trackThickness) / 2; boundsRect.height = Math.min(boundsRect.height, trackThickness); } else { boundsRect.x = (boundsRect.width - trackThickness) / 2; boundsRect.width = Math.min(boundsRect.width, trackThickness); } return boundsRect; }
private void refreshProgressBar(JProgressBar pProgressBar, int piValue, int piCount) { pProgressBar.setString(piValue + "/" + piCount); pProgressBar.setValue(piValue); pProgressBar.paintImmediately(0, 0, pProgressBar.getWidth(), pProgressBar.getHeight()); }
int barRectWidth = progressBar.getWidth() - b.right - b.left; int barRectHeight = progressBar.getHeight() - b.top - b.bottom; if (barRectWidth <= 0 || barRectHeight <= 0) {
@Override protected void drawOnTop(Graphics2D g2d) { super.drawOnTop(g2d); final JProgressBar bar = progressBar; if (bar != null && bar.isVisible()) { int shiftx = getWidth() / 2 - progressBar.getWidth() / 2; int shifty = getHeight() / 2 - progressBar.getHeight() / 2; g2d.translate(shiftx, shifty); progressBar.paint(g2d); g2d.translate(-shiftx, -shifty); } }
protected final void paintBackBar(Graphics g, JProgressBar progress) { if (JProgressBar.VERTICAL == progress.getOrientation()) { if (progressBarBackVertical != null) { progressBarBackVertical.paint( g, 0, 0, progress.getWidth(), progress.getHeight(), progress); } } else { if (progressBarBackHorizontal != null) { progressBarBackHorizontal.paint( g, 0, 0, progress.getWidth(), progress.getHeight(), progress); } } }
@Override protected void paintIndeterminate( Graphics g, JComponent c ) { Insets insets = this.progressBar.getInsets( ); int x = insets.left; int y = insets.top; int w = this.progressBar.getWidth( ) - ( insets.right + insets.left ); int h = this.progressBar.getHeight( ) - ( insets.top + insets.bottom ); // Background if ( !this.progressBar.isOpaque( ) ) { g.setColor( this.progressBar.getBackground( ) ); g.fillRect( x, y, w, h ); } // Bar this.boxRect = this.getBox( this.boxRect ); if ( this.boxRect != null ) { g.setColor( this.progressBar.getForeground( ) ); g.fillRect( this.boxRect.x, this.boxRect.y, this.boxRect.width, this.boxRect.height ); } // Text if ( progressBar.isStringPainted( ) ) { g.setFont( c.getFont( ) ); this.paintString( g, x, y, w, h, -1, insets ); } }
@Override public void paintDeterminate(Graphics g, JComponent c) { if (!(g instanceof Graphics2D)) { return; } Insets b = progressBar.getInsets(); // area for border int barRectWidth = progressBar.getWidth() - (b.right + b.left); int barRectHeight = progressBar.getHeight() - (b.top + b.bottom); if (barRectWidth <= 0 || barRectHeight <= 0) { return; } int amountFull = getAmountFull(b, barRectWidth, barRectHeight); if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) { g.setColor(progressBar.getForeground()); g.fillRect(b.left, b.top, amountFull, barRectHeight); } else { // VERTICAL } if (progressBar.isStringPainted()) { paintString(g, b.left, b.top, barRectWidth, barRectHeight, amountFull, b); } } }
int barRectWidth = progressBar.getWidth() - (b.right + b.left); int barRectHeight = progressBar.getHeight() - (b.top + b.bottom); boxRect = new Rectangle(x, 0, progressBar.getWidth() - x, progressBar.getHeight() - 1); JideSwingUtilities.fillNormalGradient(g2d, boxRect, startColor, endColor, isVertical);
int barRectWidth = progressBar.getWidth() - (b.right + b.left); int barRectHeight = progressBar.getHeight() - (b.top + b.bottom); boxRect = new Rectangle(x, 0, progressBar.getWidth() - x, progressBar.getHeight() - 1); JideSwingUtilities.fillNormalGradient(g2d, boxRect, startColor, endColor, isVertical);
protected void paintString( Graphics g, int x, int y, int width, int height, int amountFull, Insets b) { if ( !progressBar.isStringPainted()) { return; } String text = progressBar.getString(); Point point = getStringPlacement( g, text, b.left, b.top, progressBar.getWidth() - b.left - b.right, progressBar.getHeight() - b.top - b.bottom); g.setFont( progressBar.getFont().deriveFont( Font.BOLD)); if ( progressBar.getOrientation() == JProgressBar.HORIZONTAL ) { if ( !progressBar.getComponentOrientation().isLeftToRight() ) { point.x += progressBar.getFontMetrics( g.getFont()).stringWidth( text); } } NimRODUtils.paintShadowTitle( g, text, point.x, point.y, Color.white, Color.black, 1, NimRODUtils.FAT, progressBar.getOrientation()); }
@Override protected void paintDeterminate(Graphics g, JComponent c) { Insets b = progressBar.getInsets(); // area for border int barRectWidth = progressBar.getWidth() - (b.right + b.left); int barRectHeight = progressBar.getHeight() - (b.top + b.bottom); // amount of progress to draw int amountFull = getAmountFull(b, barRectWidth, barRectHeight); c.getBounds(sz); int orientation = progressBar.getOrientation(); boolean backwards = !NapkinUtil.isLeftToRight(c); if (scribble.shapeUpToDate(c, sz, orientation, amountFull, backwards)) { NapkinTheme theme = NapkinUtil.currentTheme(c); curImage = new BufferedImage(sz.x + sz.width, sz.y + sz.height, BufferedImage.TYPE_INT_ARGB); Graphics imgG = curImage.getGraphics(); selectionForeground = theme.getRadioColor(); selectionBackground = theme.getCheckColor(); imgG.setColor(theme.getCheckColor()); scribble.draw(imgG); } g.drawImage(curImage, 0, 0, c); if (progressBar.isStringPainted()) { paintString(g, b.left, b.top, barRectWidth, barRectHeight, amountFull, b); } }
@Override protected void paintIndeterminate(Graphics g, JComponent c) { Insets b = progressBar.getInsets(); // area for border int barRectWidth = progressBar.getWidth() - (b.right + b.left); int barRectHeight = progressBar.getHeight() - (b.top + b.bottom); // Paint the bouncing box. boxRect = getBox(boxRect); if (boxRect == null) { return; } if (box == null) { box = new DrawnBoxHolder(); box.setWidth(2.0f); } box.shapeUpToDate(boxRect); Graphics2D lineG = NapkinUtil.copy(g); lineG.setColor(NapkinUtil.currentTheme(c).getCheckColor()); lineG.translate(boxRect.x, boxRect.y); box.draw(lineG); // Deal with possible text painting if (progressBar.isStringPainted()) { if (progressBar.getOrientation() == SwingConstants.HORIZONTAL) { paintString(g, b.left, b.top, barRectWidth, barRectHeight, boxRect.width, b); } else { paintString(g, b.left, b.top, barRectWidth, barRectHeight, boxRect.height, b); } } }
int barRectWidth = progressBar.getWidth(); int barRectHeight = progressBar.getHeight(); Insets b = progressBar.getInsets();