List of usage examples for java.awt Graphics2D fill
public abstract void fill(Shape s);
From source file:dbseer.gui.panel.DBSeerExplainChartPanel.java
@Override public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; selectRectangle = new Rectangle2D.Double(x, y, width, height); g2d.setPaint(Color.black);//from www. j a v a 2 s. com Composite c = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .4f); g2d.setComposite(c); g2d.fill(selectRectangle); }
From source file:ArrowPanel.java
/** * Paints the arrow panel.// w ww . j a va 2 s .c om * * @param g * the graphics device for drawing on. */ public void paintComponent(final Graphics g) { super.paintComponent(g); final Graphics2D g2 = (Graphics2D) g; // first determine the size of the drawing area... final Dimension size = getSize(); final Insets insets = getInsets(); this.available.setRect(insets.left, insets.top, size.getWidth() - insets.left - insets.right, size.getHeight() - insets.top - insets.bottom); g2.translate(insets.left, insets.top); g2.fill(getArrow(this.type)); }
From source file:Composite.java
public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D) g; Dimension d = getSize();// ww w. j ava2 s . c o m int w = d.width; int h = d.height; // Creates the buffered image. BufferedImage buffImg = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); Graphics2D gbi = buffImg.createGraphics(); // Clears the previously drawn image. g2.setColor(Color.white); g2.fillRect(0, 0, d.width, d.height); int rectx = w / 4; int recty = h / 4; // Draws the rectangle and ellipse into the buffered image. gbi.setColor(new Color(0.0f, 0.0f, 1.0f, 1.0f)); gbi.fill(new Rectangle2D.Double(rectx, recty, 150, 100)); gbi.setColor(new Color(1.0f, 0.0f, 0.0f, 1.0f)); gbi.setComposite(ac); gbi.fill(new Ellipse2D.Double(rectx + rectx / 2, recty + recty / 2, 150, 100)); // Draws the buffered image. g2.drawImage(buffImg, null, 0, 0); }
From source file:net.sourceforge.processdash.ui.lib.chart.StandardDiscItemRenderer.java
protected void drawDisc(Graphics2D g2, Ellipse2D shape, Paint discPaint, int item) { g2.setPaint(discPaint); g2.fill(shape); }
From source file:org.fhcrc.cpl.viewer.mrm.utilities.MRMerMouseListener.java
/** * Draws zoom rectangle (if present).// w w w.java 2 s . co m * The drawing is performed in XOR mode, therefore * when this method is called twice in a row, * the second call will completely restore the state * of the canvas. * * @param g2 the graphics device. */ private void drawCoElutionRegion(Graphics2D g2) { // Set XOR mode to draw the zoom rectangle if (g2 == null) return; Paint origColor = g2.getPaint(); // g2.setXORMode(Color.gray); g2.setXORMode(new Color(30, 10, 30, 5)); if (this.coElutionRegion != null) { g2.fill(this.coElutionRegion); g2.setPaint(Color.white); g2.setStroke(new BasicStroke(3.0f)); g2.draw(this.coElutionRegion); } g2.setPaintMode(); g2.setPaint(origColor); }
From source file:PaintSample.java
/** * Fills the component with the current Paint. * * @param g the graphics device.//ww w. ja va 2 s.c o m */ public void paintComponent(final Graphics g) { final Graphics2D g2 = (Graphics2D) g; final Dimension size = getSize(); final Insets insets = getInsets(); final double xx = insets.left; final double yy = insets.top; final double ww = size.getWidth() - insets.left - insets.right - 1; final double hh = size.getHeight() - insets.top - insets.bottom - 1; final Rectangle2D area = new Rectangle2D.Double(xx, yy, ww, hh); g2.setPaint(this.paint); g2.fill(area); g2.setPaint(Color.black); g2.draw(area); }
From source file:org.jax.maanova.plot.MaanovaChartPanel.java
/** * Render the selection rectangle//from ww w. j a v a 2 s .c om * @param graphics2D * the graphics context to render to */ protected synchronized void renderDragRectangle(Graphics2D graphics2D) { Rectangle2D nonNegativeSelectionRectangle = MaanovaChartPanel .toNonNegativeWidthHeightRectangle(this.dragRectangle); graphics2D.setColor(this.getSelectionRectangleFillColor()); graphics2D.fill(nonNegativeSelectionRectangle); graphics2D.setColor(this.getSelectionRectangleColor()); graphics2D.draw(nonNegativeSelectionRectangle); }
From source file:ShowOff.java
protected float drawBoxedString(Graphics2D g2, String s, Color c1, Color c2, double x) { FontRenderContext frc = g2.getFontRenderContext(); TextLayout subLayout = new TextLayout(s, mFont, frc); float advance = subLayout.getAdvance(); GradientPaint gradient = new GradientPaint((float) x, 0, c1, (float) (x + advance), 0, c2); g2.setPaint(gradient);// ww w. ja v a 2 s . c o m Rectangle2D bounds = mLayout.getBounds(); Rectangle2D back = new Rectangle2D.Double(x, 0, advance, bounds.getHeight()); g2.fill(back); g2.setPaint(Color.white); g2.setFont(mFont); g2.drawString(s, (float) x, (float) -bounds.getY()); return advance; }
From source file:edu.jhuapl.graphs.jfreechart.CategoryGraphBarPainter.java
@Override public void paintBar(Graphics2D g2, BarRenderer renderer, int row, int column, RectangularShape bar, RectangleEdge base) {/*from www . ja v a 2s . c om*/ Paint itemPaint = itemProperty.get(row, column, Paint.class, renderer.getItemPaint(row, column), GraphSource.ITEM_COLOR); GradientPaintTransformer t = renderer.getGradientPaintTransformer(); if (t != null && itemPaint instanceof GradientPaint) { itemPaint = t.transform((GradientPaint) itemPaint, bar); } g2.setPaint(itemPaint); g2.fill(bar); // draw the outline if (renderer.isDrawBarOutline()) { Stroke stroke = renderer.getItemOutlineStroke(row, column); Paint paint = renderer.getItemOutlinePaint(row, column); if (stroke != null && paint != null) { g2.setStroke(stroke); g2.setPaint(paint); g2.draw(bar); } } }
From source file:com.controlj.addon.gwttree.server.OpaqueBarRenderer3D.java
private void drawMarker(Point2D.Double point, Graphics2D g2, Color color) { Stroke oldStroke = g2.getStroke(); Paint oldPaint = g2.getPaint(); g2.setPaint(color);//from w ww . j a v a2 s. co m //Shape line = new Line2D.Double(point, point); Shape marker = new Ellipse2D.Double(point.getX() - 1.5, point.getY() - 1.5, 3, 3); g2.fill(marker); g2.setPaint(oldPaint); }