@Override public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g.create(); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f)); super.paint(g2); g2.dispose(); }
public void paint(Graphics gg) { int faceSize = Math.min(getWidth() - 4, getHeight() - 4); if (face == null) face = new PADFaceMapped( Math.max(2, (getWidth() - faceSize) / 2), Math.max(2, (getHeight() - faceSize) / 2), faceSize); if (buffer == null) { im = this.createImage(getWidth(), getHeight()); buffer = im.getGraphics(); } super.paint(buffer); buffer.setColor(new Color(255, 255, 255, 0)); buffer.fillRect(0, 0, im.getWidth(null), im.getHeight(null)); face.setDimensions( Math.max(2, (getWidth() - faceSize) / 2), Math.max(2, (getHeight() - faceSize) / 2), faceSize); face.paint(buffer); // draw buffer to screen gg.drawImage(im, 0, 0, null, null); }
/** * Create a image according to the current state, simple and silly ... * * @param event the report event. */ public void pageStarted(final ReportEvent event) { final BufferedImage image = new BufferedImage(150, 50, BufferedImage.TYPE_INT_ARGB); final Graphics2D g2 = image.createGraphics(); final JButton bt = new JButton("A Button"); bt.setSize(90, 20); final JRadioButton radio = new JRadioButton("A radio button"); radio.setSize(100, 20); g2.setColor(Color.darkGray); bt.paint(g2); g2.setColor(Color.blue); g2.setTransform(AffineTransform.getTranslateInstance(20, 20)); radio.paint(g2); g2.setTransform(AffineTransform.getTranslateInstance(0, 0)); g2.setPaint(Color.green); g2.setFont(new Font("Serif", Font.PLAIN, 10)); g2.drawString( "You are viewing a graphics of JFreeReport on index " + event.getState().getCurrentRow(), 10, 10); g2.dispose(); try { functionValue = new DefaultImageReference(image); } catch (IOException e) { functionValue = null; } }
public void paint(Graphics g) { super.paint(g); Graphics2D g2D = (Graphics2D) g; int x = this.getWidth(); int y = this.getHeight(); int z = 4; if (orientation.equals(DesktopBar.WEST)) { int[] X = {x - z, x - z, 2 * x / 5, x / 2, z, x / 2, 2 * x / 5}; int[] Y = {2 * y / 5, 3 * y / 5, 3 * y / 5, y - z, y / 2, z, 2 * y / 5}; g2D.draw(new Polygon(X, Y, 7)); } if (orientation.equals(DesktopBar.EAST)) { int[] X = {z, z, 2 * x / 3, x / 2, x - z, x / 2, 2 * x / 3}; int[] Y = {2 * y / 5, 3 * y / 5, 3 * y / 5, y - z, y / 2, z, 2 * y / 5}; g2D.draw(new Polygon(X, Y, 7)); } if (orientation.equals(DesktopBar.NORTH)) { int[] X = {2 * x / 5, 3 * x / 5, 3 * x / 5, x - z, x / 2, z, 2 * x / 5}; int[] Y = {y - z, y - z, 2 * y / 5, y / 2, z, y / 2, 2 * y / 5}; g2D.draw(new Polygon(X, Y, 7)); } if (orientation.equals(DesktopBar.SOUTH)) { int[] X = {2 * x / 5, 3 * x / 5, 3 * x / 5, x - z, x / 2, z, 2 * x / 5}; int[] Y = {z, z, 2 * y / 3, y / 2, y - z, y / 2, 2 * y / 3}; g2D.draw(new Polygon(X, Y, 7)); } }
public void paint(Graphics g) { super.paint(g); // if (isSelected()) if (this == selComp) g.setColor(vLightBlue); else g.setColor(Color.WHITE); setOpaque(false); setFocusPainted(false); }
public void paint(Graphics g) { if (preparado) { int width, height; super.paint(g); if (textura.getWidth(this) < 0) width = 0; else width = textura.getWidth(this); if (textura.getHeight(this) < 0) height = 0; else height = textura.getHeight(this); buffer = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Graphics2D gdos = buffer.createGraphics(); gdos.drawImage(textura, 0, 0, null); Graphics2D g2 = (Graphics2D) g; g2.setPaint( new TexturePaint(buffer, new Rectangle(textura.getWidth(this), textura.getHeight(this)))); g2.fillRect(5, 5, this.getWidth() - 10, this.getHeight() - 10); } else super.paint(g); }
protected void paintActionButton( Graphics g, int dx, int dy, int status, boolean isOver, JButton button, BufferedImage image) { button.setBorder(null); if (isOver) { switch (status) { case OVER: button.setBorder(OVERBORDER); break; case PRESSED: button.setBorder(PRESSEDBORDER); break; } } button.setBackground(tabScroller.tabPanel.getBackground()); button.paint(image.getGraphics()); g.drawImage(image, dx, dy, null); }
public void paint(Graphics gg) { if (osStyle) { int faceSize = Math.min(getWidth() - 4, getHeight() - 4); if (face == null) face = new PADFaceMapped( Math.max(2, (getWidth() - faceSize) / 2), Math.max(2, (getHeight() - faceSize) / 2), faceSize); if (buffer == null) { im = this.createImage(getWidth(), getHeight()); buffer = im.getGraphics(); } super.paint(buffer); buffer.setColor(new Color(255, 255, 255, 0)); buffer.fillRect(0, 0, im.getWidth(null), im.getHeight(null)); face.setDimensions( Math.max(2, (getWidth() - faceSize) / 2), Math.max(2, (getHeight() - faceSize) / 2), faceSize); face.paint(buffer); // draw buffer to screen gg.drawImage(im, 0, 0, null, null); } else { // this is the CUSTOM way of drawing the AffectButton int faceSize = Math.min(getWidth() - 4, getHeight() - 4); if (face == null) face = new PADFaceMapped( Math.max(2, (getWidth() - faceSize) / 2), Math.max(2, (getHeight() - faceSize) / 2), faceSize); if (buffer == null) { im = this.createImage(getWidth(), getHeight()); buffer = im.getGraphics(); } buffer.setColor(this.getBackground()); buffer.fillRect(0, 0, getWidth(), getHeight()); buffer.setColor(Color.gray); buffer.drawRect(0, 0, getWidth() - 1, getHeight() - 1); if (in) { buffer.setColor(new Color(200, 200, 200)); buffer.drawLine(0, 0, getWidth() - 1, 0); buffer.drawLine(0, 0, 0, getHeight() - 1); buffer.setColor(Color.darkGray); buffer.drawLine(getWidth() - 1, getHeight() - 1, getWidth() - 1, 0); buffer.drawLine(getWidth() - 1, getHeight() - 1, 0, getHeight() - 1); } if (down) { buffer.setColor(Color.darkGray); buffer.drawLine(0, 0, getWidth() - 1, 0); buffer.drawLine(0, 0, 0, getHeight() - 1); buffer.setColor(new Color(200, 200, 200)); buffer.drawLine(getWidth() - 1, getHeight() - 1, getWidth() - 1, 0); buffer.drawLine(getWidth() - 1, getHeight() - 1, 0, getHeight() - 1); } face.setDimensions( Math.max(2, (getWidth() - faceSize) / 2), Math.max(2, (getHeight() - faceSize) / 2), faceSize); face.paint(buffer); // draw buffer to screen gg.drawImage(im, 0, 0, null, null); } }
@Override public void paint(Graphics g) { super.paint(g); g.drawString(content, 20, 20); }