List of usage examples for java.awt Graphics2D setPaint
public abstract void setPaint(Paint paint);
From source file:Main.java
public void paint(Graphics g) { super.paint(g); Graphics2D g2d = (Graphics2D) g; GradientPaint gp1 = new GradientPaint(5, 5, Color.red, 20, 20, Color.yellow, true); System.out.println(gp1.getColor1()); g2d.setPaint(gp1); g2d.fillRect(20, 20, 300, 40);//from w w w. j a va 2 s . c o m }
From source file:Main.java
public void paint(Graphics g) { super.paint(g); Graphics2D g2d = (Graphics2D) g; GradientPaint gp1 = new GradientPaint(5, 5, Color.red, 20, 20, Color.yellow, true); System.out.println(gp1.getPoint2()); g2d.setPaint(gp1); g2d.fillRect(20, 20, 300, 40);// w ww . jav a 2s. c o m }
From source file:Main.java
public void paint(Graphics g) { super.paint(g); Graphics2D g2d = (Graphics2D) g; GradientPaint gp1 = new GradientPaint(5, 5, Color.red, 20, 20, Color.yellow, true); System.out.println(gp1.getPoint1()); g2d.setPaint(gp1); g2d.fillRect(20, 20, 300, 40);//from www . ja v a 2 s . c o m }
From source file:GeneralPathDemo2D.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setPaint(Color.gray); int x = 5;/*from ww w . j a va2s . c om*/ int y = 7; // draw GeneralPath (polygon) int xPoints[] = { x, 200, x, 200 }; int yPoints[] = { y, 200, 200, y }; GeneralPath polygon = new GeneralPath(GeneralPath.WIND_EVEN_ODD, xPoints.length); polygon.moveTo(xPoints[0], yPoints[0]); for (int index = 1; index < xPoints.length; index++) { polygon.lineTo(xPoints[index], yPoints[index]); } polygon.closePath(); g2.draw(polygon); g2.drawString("GeneralPath", x, 250); }
From source file:Main.java
public void paintImage() { Graphics2D g = createGraphics(); if (frame == frameGradient.length - 1) frame = 0;/* ww w . j a va 2 s . c om*/ else frame++; g.setPaint(frameGradient[frame]); g.fillRect(0, 0, getWidth(), getHeight()); g.dispose(); }
From source file:org.apache.xmlgraphics.ps.ImageEncodingHelperTestCase.java
private BufferedImage prepareImage(final BufferedImage image) { final Graphics2D ig = image.createGraphics(); ig.scale(.5, .5);/*from w w w.j a v a 2s . c o m*/ ig.setPaint(new Color(128, 0, 0)); ig.fillRect(0, 0, 100, 50); ig.setPaint(Color.orange); ig.fillRect(100, 0, 100, 50); ig.setPaint(Color.yellow); ig.fillRect(0, 50, 100, 50); ig.setPaint(Color.red); ig.fillRect(100, 50, 100, 50); ig.setPaint(new Color(255, 127, 127)); ig.fillRect(0, 100, 100, 50); ig.setPaint(Color.black); ig.draw(new Rectangle2D.Double(0.5, 0.5, 199, 149)); ig.dispose(); return image; }
From source file:TexturedText.java
/** Construct the object */ public TexturedText() { super();//from www.j a v a2s . c o m setBackground(Color.white); int width = 8, height = 8; bim = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = bim.createGraphics(); for (int i = 0; i < width; i++) { g2.setPaint(colors[(i / 2) % colors.length]); g2.drawLine(0, i, i, 0); g2.drawLine(width - i, height, width, height - i); } Rectangle r = new Rectangle(0, 0, bim.getWidth(), bim.getHeight()); tp = new TexturePaint(bim, r); }
From source file:Main.java
public void paint(Graphics g) { super.paint(g); Graphics2D g2d = (Graphics2D) g; GradientPaint gp1 = new GradientPaint(5, 5, Color.red, 20, 20, Color.yellow, true); System.out.println(gp1.getTransparency()); g2d.setPaint(gp1); g2d.fillRect(20, 20, 300, 40);//from w w w. j av a2 s.c o m }
From source file:MainClass.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Ellipse2D e = new Ellipse2D.Float(40, 40, 120, 120); GradientPaint gp = new GradientPaint(75, 75, Color.white, 95, 95, Color.gray, true); g2.setPaint(gp); g2.fill(e);// www.ja v a 2 s . c o m }
From source file:probe.com.model.util.vaadintoimageutil.HeatmapSwingComponent.java
public String generateHeatmap(String[] rows, String[] columns, String[][] data) { JPanel heatmapPanelLayout = new JPanel(); heatmapPanelLayout.setLayout(null);//from w w w . j ava2s . c o m heatmapPanelLayout.setVisible(true); heatmapPanelLayout.setBorder(new LineBorder(Color.BLACK)); int width = (columns.length + 1) * 50; int height = (rows.length + 1) * 50; heatmapPanelLayout.setSize(width, height); JPanel cornerCell = initCell("#ffffff", 0, 0); int x = 50; int y = 0; heatmapPanelLayout.add(cornerCell); for (String headerCell : columns) { JPanel cell = initCell(headerCell, x, y); x += 50; heatmapPanelLayout.add(cell); } y = 50; for (String headerCell : rows) { JPanel cell = initCell(headerCell, 0, y); y += 50; heatmapPanelLayout.add(cell); } x = 50; y = 50; for (String[] row : data) { for (String color : row) { JPanel cell = initCell(color, x, y); heatmapPanelLayout.add(cell); x += 50; } x = 50; y += 50; } BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics2D graphics = image.createGraphics(); graphics.setPaint(Color.WHITE); heatmapPanelLayout.paint(graphics); // super.paint(graphics); byte[] imageData = null; try { ImageEncoder in = ImageEncoderFactory.newInstance(ImageFormat.PNG, new Float(0.084666f)); imageData = in.encode(image); } catch (Exception e) { System.out.println(e.getLocalizedMessage()); } String base64 = Base64.encodeBytes(imageData); base64 = "data:image/png;base64," + base64; return base64; // // JFrame frame = new JFrame(); // frame.setSize(1000, 1000); // frame.add(heatmapPanelLayout); // frame.setVisible(true); // return ""; }