List of usage examples for java.awt Graphics fillRoundRect
public abstract void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight);
From source file:Main.java
public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); BufferedImage image = new BufferedImage(400, 300, BufferedImage.TYPE_INT_RGB); Graphics2D imageGraphics = image.createGraphics(); GradientPaint gp = new GradientPaint(20f, 20f, Color.red, 380f, 280f, Color.orange); imageGraphics.setPaint(gp);/*from w w w .jav a 2 s. com*/ imageGraphics.fillRect(0, 0, 400, 300); JLabel textLabel = new JLabel("java2s.com"); textLabel.setSize(textLabel.getPreferredSize()); Dimension d = textLabel.getPreferredSize(); BufferedImage bi = new BufferedImage(d.width, d.height, BufferedImage.TYPE_INT_ARGB); Graphics g = bi.createGraphics(); g.setColor(new Color(255, 200, 255, 128)); g.fillRoundRect(0, 0, bi.getWidth(f), bi.getHeight(f), 15, 10); g.setColor(Color.black); textLabel.paint(g); Graphics g2 = image.getGraphics(); g2.drawImage(bi, 20, 20, f); ImageIcon ii = new ImageIcon(image); JLabel imageLabel = new JLabel(ii); f.getContentPane().add(imageLabel); f.pack(); f.setVisible(true); } }); }
From source file:MainClass.java
public void paint(Graphics g) { g.fillRoundRect(150, 50, 100, 100, 50, 25); }
From source file:Main.java
public void paint(Graphics g) { g.fillRoundRect(150, 50, 100, 100, 50, 25); }
From source file:MainClass.java
public void paint(Graphics g) { g.drawRect(10, 10, 60, 50);// w w w. j a va 2 s .c o m g.fillRect(100, 10, 60, 50); g.drawRoundRect(190, 10, 60, 50, 15, 15); g.fillRoundRect(70, 90, 140, 100, 30, 40); }
From source file:FillRectPanel.java
public void paintComponent(Graphics g) { super.paintComponent(g); g.drawRect(10, 10, 80, 30);/* w ww . j a va2 s . c o m*/ g.drawRoundRect(100, 10, 80, 30, 15, 15); g.drawOval(10, 100, 80, 30); g.setColor(Color.red); g.fillRect(10, 10, 80, 30); g.fillRoundRect(100, 10, 80, 30, 15, 15); int thickness = 4; g.fill3DRect(200, 10, 80, 30, true); for (int i = 1; i <= thickness; i++) g.draw3DRect(200 - i, 10 - i, 80 + 2 * i - 1, 30 + 2 * i - 1, true); g.fill3DRect(200, 50, 80, 30, false); for (int i = 1; i <= thickness; i++) g.draw3DRect(200 - i, 50 - i, 80 + 2 * i - 1, 30 + 2 * i - 1, true); g.fillOval(10, 100, 80, 30); }
From source file:ImageLabel.java
public void paint(Graphics g) { /*//from ww w . j av a 2 s . com * Draw the image stretched to exactly cover the size of the drawing area. */ Dimension size = getSize(); g.drawImage(img, 0, 0, size.width, size.height, 0, 0, img.getWidth(null), img.getHeight(null), null); /* * Fill a rounded rectangle centered in the drawing area. Calculate the size * of the rectangle from the size of the text */ g.setFont(font); FontRenderContext frc = ((Graphics2D) g).getFontRenderContext(); Rectangle2D bounds = font.getStringBounds(text, frc); int wText = (int) bounds.getWidth(); int hText = (int) bounds.getHeight(); int rX = (size.width - wText) / 2; int rY = (size.height - hText) / 2; g.setColor(Color.yellow); g.fillRoundRect(rX, rY, wText, hText, hText / 2, hText / 2); /* * Draw text positioned in the rectangle. Since the rectangle is sized based * on the bounds of the String we can position it using those bounds. */ int xText = rX - (int) bounds.getX(); int yText = rY - (int) bounds.getY(); g.setColor(Color.black); g.setFont(font); g.drawString(text, xText, yText); }
From source file:FancyCaret.java
public void paint(Graphics g) { JTextComponent comp = getComponent(); if (comp == null) return;/* w w w . j a v a2s . c o m*/ int dot = getDot(); Rectangle r = null; char dotChar; try { r = comp.modelToView(dot); if (r == null) return; dotChar = comp.getText(dot, 1).charAt(0); } catch (BadLocationException e) { return; } if ((x != r.x) || (y != r.y)) { repaint(); x = r.x; y = r.y; height = r.height; } g.setColor(comp.getCaretColor()); g.setXORMode(comp.getBackground()); if (dotChar == '\n') { int diam = r.height; if (isVisible()) g.fillArc(r.x - diam / 2, r.y, diam, diam, 270, 180); // half circle width = diam / 2 + 2; return; } if (dotChar == '\t') try { Rectangle nextr = comp.modelToView(dot + 1); if ((r.y == nextr.y) && (r.x < nextr.x)) { width = nextr.x - r.x; if (isVisible()) g.fillRoundRect(r.x, r.y, width, r.height, 12, 12); return; } else dotChar = ' '; } catch (BadLocationException e) { dotChar = ' '; } width = g.getFontMetrics().charWidth(dotChar); if (isVisible()) g.fillRect(r.x, r.y, width, r.height); }
From source file:org.processmining.analysis.performance.dottedchart.ui.DottedChartPanel.java
/** * convenience method for internal use. paints a log item handle * visualization./* ww w . j av a2s . c om*/ * * @param x * horizontal anchor coordinate of the handle * @param y * vertical anchor coordinate of the handle * @param g * the Graphics object used for painting */ protected void paintItem(int x, int y, Graphics g, String shape) { if (shape.equals(STR_NONE)) { return; } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DOT)) { g.fillOval(x - 2, y - 2, 4, 4); } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_BOX)) { g.fill3DRect(x - 5, y - 5, 10, 10, false); } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_CIRCLE)) { g.fillOval(x - 5, y - 5, 11, 11); } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_RHOMBUS)) { int rhombX[] = { x, x - 5, x, x + 5 }; int rhombY[] = { y - 5, y, y + 5, y }; g.fillPolygon(rhombX, rhombY, 4); } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_TRIANGLE)) { int triX[] = { x, x - 5, x + 5 }; int triY[] = { y + 5, y - 5, y - 5 }; g.fillPolygon(triX, triY, 3); } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_ROUND_BOX)) { g.fillRoundRect(x - 5, y - 5, 10, 10, 2, 2); } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DRAW_BOX)) { g.drawRect(x - 5, y - 5, 10, 10); } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DRAW_CIRCLE)) { g.drawOval(x - 5, y - 5, 11, 11); } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DRAW_RHOMBUS)) { int rhombX[] = { x, x - 5, x, x + 5 }; int rhombY[] = { y - 5, y, y + 5, y }; g.drawPolygon(rhombX, rhombY, 4); } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DRAW_TRIANGLE)) { int triX[] = { x, x - 5, x + 5 }; int triY[] = { y + 5, y - 5, y - 5 }; g.drawPolygon(triX, triY, 3); } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DRAW_ROUND_BOX)) { g.drawRoundRect(x - 5, y - 5, 10, 10, 2, 2); } }
From source file:org.processmining.analysis.performance.dottedchart.ui.DottedChartPanel.java
/** * convenience method for internal use. paints a log item handle * visualization.// ww w .ja va2s . c o m * * @param x * horizontal anchor coordinate of the handle * @param y * vertical anchor coordinate of the handle * @param g * the Graphics object used for painting */ protected void paintHighligtedItem(int x, int y, Graphics g, String shape) { Color color = g.getColor(); if (shape.equals(STR_NONE)) { return; } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DOT)) { if (!color.equals(Color.red)) g.setColor(Color.red); else g.setColor(Color.black); g.fillOval(x - 3, y - 3, 6, 6); g.setColor(color); g.fillOval(x - 2, y - 2, 4, 4); } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_BOX)) { if (!color.equals(Color.black)) g.setColor(Color.black); else g.setColor(Color.red); g.fillRect(x - 6, y - 6, 12, 12); g.setColor(color); g.fill3DRect(x - 5, y - 5, 10, 10, false); } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_CIRCLE)) { if (!color.equals(Color.black)) g.setColor(Color.black); else g.setColor(Color.red); g.fillOval(x - 6, y - 6, 13, 13); g.setColor(color); g.fillOval(x - 5, y - 5, 11, 11); } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_RHOMBUS)) { int rhombX[] = { x, x - 5, x, x + 5 }; int rhombY[] = { y - 5, y, y + 5, y }; g.fillPolygon(rhombX, rhombY, 4); } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_TRIANGLE)) { int triX[] = { x, x - 5, x + 5 }; int triY[] = { y + 5, y - 5, y - 5 }; g.fillPolygon(triX, triY, 3); } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_ROUND_BOX)) { if (!color.equals(Color.black)) g.setColor(Color.black); else g.setColor(Color.red); g.fillRoundRect(x - 6, y - 6, 13, 13, 2, 2); g.setColor(color); g.fillRoundRect(x - 5, y - 5, 10, 10, 2, 2); } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DRAW_BOX)) { g.drawRect(x - 5, y - 5, 10, 10); } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DRAW_CIRCLE)) { if (!color.equals(Color.black)) g.setColor(Color.black); else g.setColor(Color.red); g.fillOval(x - 6, y - 6, 13, 13); g.setColor(color); g.drawOval(x - 5, y - 5, 11, 11); } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DRAW_RHOMBUS)) { int rhombX[] = { x, x - 5, x, x + 5 }; int rhombY[] = { y - 5, y, y + 5, y }; g.drawPolygon(rhombX, rhombY, 4); } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DRAW_TRIANGLE)) { int triX[] = { x, x - 5, x + 5 }; int triY[] = { y + 5, y - 5, y - 5 }; g.drawPolygon(triX, triY, 3); } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DRAW_ROUND_BOX)) { g.drawRoundRect(x - 5, y - 5, 10, 10, 2, 2); } }
From source file:org.processmining.analysis.performance.dottedchart.ui.DottedChartPanel.java
/** * convenience method for internal use. paints a log item handle * visualization./*from w ww . j ava 2 s . c o m*/ * * @param x * horizontal anchor coordinate of the handle * @param y * vertical anchor coordinate of the handle * @param g * the Graphics object used for painting */ protected void paintItem_buffer(int x, int y, Graphics g, String shape) { if (shape.equals(STR_NONE)) { return; } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DOT)) { g.fillOval(x - 2, y - 2, 7, 7); } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_BOX)) { g.fill3DRect(x - 3, y - 3, 6, 6, false); } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_CIRCLE)) { g.fillOval(x - 2, y - 2, 7, 7); } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_RHOMBUS)) { int rhombX[] = { x, x - 3, x, x + 3 }; int rhombY[] = { y - 3, y, y + 3, y }; g.fillPolygon(rhombX, rhombY, 4); } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_TRIANGLE)) { int triX[] = { x, x - 3, x + 3 }; int triY[] = { y + 3, y - 3, y - 3 }; g.fillPolygon(triX, triY, 3); } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_ROUND_BOX)) { g.fillRoundRect(x - 3, y - 3, 6, 6, 2, 2); } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DRAW_BOX)) { g.drawRect(x - 3, y - 3, 6, 6); } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DRAW_CIRCLE)) { g.drawOval(x - 2, y - 2, 7, 7); } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DRAW_RHOMBUS)) { int rhombX[] = { x, x - 3, x, x + 3 }; int rhombY[] = { y - 3, y, y + 3, y }; g.drawPolygon(rhombX, rhombY, 4); } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DRAW_TRIANGLE)) { int triX[] = { x, x - 3, x + 3 }; int triY[] = { y + 3, y - 3, y - 3 }; g.drawPolygon(triX, triY, 3); } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DRAW_ROUND_BOX)) { g.drawRoundRect(x - 3, y - 3, 6, 6, 2, 2); } }