@Override protected void paintComponent(Graphics g) { super.paintComponent(g); Area area = new Area(new Rectangle(0, 0, getWidth(), getHeight())); area.subtract(new Area(new RoundRectangle2D.Float(10, 10, getWidth() - 20, getHeight() - 20, 20, 20))); Graphics2D g2d = (Graphics2D) g.create(); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setColor(Color.BLACK); g2d.fill(area); g2d.dispose(); }
this.color = color; stroke = new BasicStroke(thickness); strokePad = thickness / 2; Area area = new Area(bubble); area.add(new Area(pointer)); g2.setRenderingHints(hints); if (parent!=null) { Color bg = parent.getBackground(); Rectangle rect = new Rectangle(0,0,width, height); Area borderRegion = new Area(rect); borderRegion.subtract(area); g2.setClip(borderRegion); g2.setColor(bg); g2.fillRect(0, 0, width, height); g2.setClip(null); g2.setColor(color); g2.setStroke(stroke); g2.draw(area);
@Implementation protected boolean isRect(RectF rect) { // create an Area that can test if the path is a rect Area area = new Area(mPath); if (area.isRectangular()) { if (rect != null) { fillBounds(rect); } return true; } return false; }
int getGradientSteps(Shape gradientShape) { Rectangle rect = gradientShape.getBounds(); int lower = 1; int upper = (int)(Math.max(rect.getWidth(),rect.getHeight())/2.0); while (lower < upper-1) { int mid = lower + (upper - lower) / 2; BasicStroke bs = new BasicStroke(mid, capStyle, joinStyle); Area area = new Area(bs.createStrokedShape(gradientShape)); if (area.isSingular()) { upper = mid; } else { lower = mid; } } return upper; }
@Override protected void paintComponent(Graphics g1D) { if (theImage == null || theRectangle == null) return; Graphics2D g = (Graphics2D) g1D.create(); Insets insets = getInsets(); int xOffset = insets.left; int yOffset = insets.top; int availableWidth = getWidth() - insets.left - insets.right; int availableHeight = getHeight() - insets.top - insets.bottom; g.drawImage(theImage, xOffset, yOffset, null); Color tmpColor = g.getColor(); Area area = new Area(new Rectangle(xOffset, yOffset, availableWidth, availableHeight)); area.subtract(new Area(theRectangle)); g.setColor(new Color(200, 200, 200, 128)); g.fill(area); g.setColor(Color.BLACK); g.draw(theRectangle); g.setColor(tmpColor); g.dispose(); }
} else if (pathSegmentType == PathIterator.SEG_CLOSE) { gp.closePath(); regions.add(new Area(gp)); } else { System.err.println("Unexpected value! " + pathSegmentType); Shape shapeCentered = trans.createTransformedShape(shape1); Shape imageShape = new Rectangle2D.Double(0, 0, sz, sz); Area imageShapeArea = new Area(imageShape); Area shapeArea = new Area(shapeCentered); imageShapeArea.subtract(shapeArea); ArrayList<Shape> regions = separateShapeIntoRegions(imageShapeArea); g.setStroke(new BasicStroke(1)); for (Shape region : regions) { Rectangle r1 = region.getBounds(); if (r1.getX() < 0.001 && r1.getY() < 0.001) { } else { g.setColor(bgColor); g.setColor(outlineColor); g.fill(shapeArea); g.dispose();
Area area = new Area(); for (int x=0; x<image.getWidth(); x++) { for (int y=0; y<image.getHeight(); y++) { Color pixel = new Color(image.getRGB(x,y)); if (include) { if (isIncluded(color, pixel, tolerance)) { Rectangle r = new Rectangle(x,y,1,1); area.add(new Area(r)); Rectangle r = new Rectangle(x,y,1,1); area.add(new Area(r)); int rT = target.getRed(); int gT = target.getGreen(); int bT = target.getBlue(); int rP = pixel.getRed(); Graphics2D g = result.createGraphics(); g.setColor(Color.white); g.fillRect(0,0,w,h); g.setClip(area); g.setColor(Color.red); g.fillRect(0,0,w,h);
@Override public void paint(Graphics2D graphics) { Separator separator = (Separator)getComponent(); int width = getWidth(); int separatorY = padding.top; String heading = separator.getHeading(); if (heading != null && heading.length() > 0) { FontRenderContext fontRenderContext = Platform.getFontRenderContext(); LineMetrics lm = font.getLineMetrics(heading, fontRenderContext); graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, fontRenderContext.getAntiAliasingHint()); graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, fontRenderContext.getFractionalMetricsHint()); graphics.setFont(font); graphics.setPaint(headingColor); graphics.drawString(heading, padding.left, lm.getAscent() + padding.top); Rectangle2D headingBounds = font.getStringBounds(heading, fontRenderContext); Area titleClip = new Area(graphics.getClip()); titleClip.subtract(new Area(new Rectangle2D.Double(padding.left, padding.top, headingBounds.getWidth() + padding.right, headingBounds.getHeight()))); graphics.clip(titleClip); separatorY += (lm.getAscent() + lm.getDescent()) / 2 + 1; } graphics.setStroke(new BasicStroke(thickness)); graphics.setColor(color); graphics.drawLine(0, separatorY, width, separatorY); }
Graphics2D nodeViewGraphics = (Graphics2D)graphics.create(); Area fillArea = new Area(new Rectangle(nodeViewBounds.x, nodeViewBounds.y, nodeViewBounds.width, nodeViewBounds.height)); selection = selection.createTransformedArea(AffineTransform.getTranslateInstance(-skinX, -skinY)); fillArea.subtract(selection); nodeViewGraphics.setColor(styledBackgroundColor); nodeViewGraphics.fill(fillArea); } else { nodeViewGraphics.setColor(styledBackgroundColor);
public void paint(Graphics2D g2d) { g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Color gradientColorStart = Color.WHITE; Color gradientColorEnd = new Color(this.getHeaderBackgroundColor()); Rectangle2D inSquare = new Rectangle2D.Double(2, 2, DIMENSIONS.getWidth() - 4, DIMENSIONS.getHeight() - 4); GradientPaint paint = new GradientPaint((float) 2, (float) 2, gradientColorStart, (float) DIMENSIONS.getWidth() - 2, (float) DIMENSIONS.getHeight() - 2, gradientColorEnd); g2d.setPaint(paint); g2d.fill(inSquare); RoundRectangle2D outSquare = new RoundRectangle2D.Double(0, 0, DIMENSIONS.getWidth(), DIMENSIONS.getHeight(), 4, 4); Rectangle2D midSquare = new Rectangle2D.Double(1, 1, DIMENSIONS.getWidth() - 2, DIMENSIONS.getHeight() - 2); g2d.setColor(new Color(this.getHeaderBackgroundColor())); Area area2 = new Area(outSquare); area2.subtract(new Area(midSquare)); g2d.fill(area2); g2d.setColor(new Color(this.getHeaderGradientColor())); Area area = new Area(midSquare); area.subtract(new Area(inSquare)); g2d.fill(area); } }
public void paintBorder( Component c, Graphics g, int x, int y, int width, int height ) { Graphics2D g2 = (Graphics2D)g.create(); g2.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON ); int r = DEF_DIAMETER; g2.translate( x, y ); g2.setColor( _color ); g2.fillRect( r/2, 0, width - r - 1, _insets.top ); g2.fillRect( 0, r/2, _insets.left, height - r - 1 ); g2.fillRect( r/2 , height - _insets.bottom - 1, width - r - 1, _insets.bottom ); g2.fillRect( width - _insets.right - 1, r/2, _insets.right, height - r - 1 ); RoundRectangle2D round = new RoundRectangle2D.Float( 0, 0, width - 1, height - 1, r, r ); Container parent = c.getParent(); if( parent != null ) { g2.setColor( parent.getBackground() ); Area corner = new Area( new Rectangle2D.Float( 0, 0, width, height ) ); corner.subtract( new Area( round ) ); g2.fill( corner ); } BasicStroke stroke = new BasicStroke( 1.0f ); g2.setStroke( stroke ); g2.setColor( _color ); g2.draw( new Arc2D.Double( 0, 0, r, r, 90, 90, Arc2D.OPEN ) ); g2.draw( new Arc2D.Double( width - r - 2, 0, r, r, 90, -90, Arc2D.OPEN ) ); g2.draw( new Arc2D.Double( width - r - 2, height - r - 2, r, r, 0, -90, Arc2D.OPEN ) ); g2.draw( new Arc2D.Double( 0, height - r - 2, r, r, 180, 90, Arc2D.OPEN ) ); g2.dispose(); }
@Override protected void paintComponent(Graphics g) { if (_image == null || _rectangle == null) return; Graphics2D g2d = (Graphics2D) g; Insets insets = getInsets(); int xOffset = insets.left; int yOffset = insets.top; g.setColor(_scrollPane.getViewport().getView().getBackground()); g.fillRect(0, 0, getWidth(), getHeight()); g.drawImage(_image, xOffset, yOffset, null); int availableWidth = getWidth() - insets.left - insets.right; int availableHeight = getHeight() - insets.top - insets.bottom; Area area = new Area(new Rectangle(xOffset, yOffset, availableWidth, availableHeight)); area.subtract(new Area(_rectangle)); g.setColor(new Color(255, 255, 255, 128)); g2d.fill(area); Color oldcolor = g.getColor(); g.setColor(_selectionBorder); g.drawRect(_rectangle.x, _rectangle.y, _rectangle.width, _rectangle.height); g.setColor(oldcolor); }
float alpha = bgalpha; Component c = (Component)o; Composite composite = g2.getComposite(); if (composite instanceof AlphaComposite) { alpha *= ((AlphaComposite) composite).getAlpha(); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha)); g2.setColor(bgColor); c.getHeight() * 2.0); Area area = new Area(new Rectangle(0, 0, c.getWidth(), c.getHeight())); area.subtract(new Area(ellipse)); area.intersect(new Area(rect)); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha)); g2.setColor(new Color(1.0f, 1.0f, 1.0f)); g2.fill(area); g2.setComposite(composite);
boolean collide = false; Area collide1 = new Area(area1); collide1.subtract(area2); if (!collide1.equals(area1)) { collide = true; Area collide2 = new Area(area2); collide2.subtract(area1); if (!collide2.equals(area2)) { collide = true; obstacles[0] = new Area(new Ellipse2D.Double(40, 40, 30, 30)); obstacles[1] = new Area(new Polygon(xTriangle, yTriangle, 3)); obstacles[2] = new Area(new Polygon(xDiamond, yDiamond, 4)); obstacles[3] = new Area(new Polygon(xOther, yOther, 4)); walls = new Area(new Rectangle(0,0,w,h)); g.setColor(Color.BLUE); g.fillRect(0, 0, img.getWidth(), img.getHeight()); x+=xDelta; y+=yDelta; int s = 15; Area player = new Area(new Ellipse2D.Double(x, y, s, s));
Area clip = (Area)getGraphicsState().getCurrentClippingPath().clone(); clip.intersect(new Area(transformedBox)); Rectangle2D clipRect = clip.getBounds2D(); if (clipRect.isEmpty()) AffineTransform dpiTransform = AffineTransform.getScaleInstance(Math.abs(m.getScalingFactorX()), Math.abs(m.getScalingFactorY())); Rectangle2D bounds = dpiTransform.createTransformedShape(clip.getBounds2D()).getBounds2D(); g.drawImage(backdropImage, 0, 0, width, height, backdropX, backdropY, backdropX + width, backdropY + height, null); g = new GroupGraphics(image, g); g.setBackground(new Color(backdropColor.toRGB())); g.clearRect(0, 0, width, height); xform = AffineTransform.getScaleInstance(Math.abs(m.getScalingFactorX()), Math.abs(m.getScalingFactorY())); PDRectangle pageSizeOriginal = pageSize; pageSize = new PDRectangle(minX / Math.abs(m.getScalingFactorX()),
@Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Graphics2D g2d = (Graphics2D) g; g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); RoundRectangle2D.Double rectangle = new RoundRectangle2D.Double(x, y, width - 1, height - 1, radius, radius); Area rectangleArea = new Area(rectangle); Area area = new Area(new Rectangle(0, 0, width, height)); area.subtract(rectangleArea); g2d.setClip(area); g2d.setColor(c.getParent().getBackground()); g2d.fillRect(0, 0, width, height); g2d.setClip(null); if (color == null) { g2d.setColor(c.getBackground()); } else { g2d.setColor(color); } g2d.setStroke(stroke); g2d.draw(rectangleArea); }
private void paintControlPoint(Graphics2D g2, Point2D control) { double origin_x = xPositionToPixel(control.getX()); double origin_y = yPositionToPixel(control.getY()); double pos = control == control1 ? 0.0 : 1.0; Ellipse2D outer = getDraggableArea(control); Ellipse2D inner = new Ellipse2D.Double(origin_x + 2.0 - CONTROL_POINT_SIZE / 2.0, origin_y + 2.0 - CONTROL_POINT_SIZE / 2.0, 8.0, 8.0); Area circle = new Area(outer); circle.subtract(new Area(inner)); Stroke stroke = g2.getStroke(); g2.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 5, new float[]{5, 5}, 0)); g2.setColor(new Color(1.0f, 0.0f, 0.0f, 0.4f)); g2.drawLine(0, (int) origin_y, (int) origin_x, (int) origin_y); g2.drawLine((int) origin_x, (int) origin_y, (int) origin_x, getHeight()); g2.setStroke(stroke); if (selected == control) { g2.setColor(new Color(1.0f, 1.0f, 1.0f, 1.0f)); } else { g2.setColor(new Color(0.8f, 0.8f, 0.8f, 0.6f)); } g2.fill(inner); g2.setColor(new Color(0.0f, 0.0f, 0.5f, 0.5f)); g2.fill(circle); g2.drawLine((int) origin_x, (int) origin_y, (int) xPositionToPixel(pos), (int) yPositionToPixel(pos)); }
G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); G2.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY); G2.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY); G2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); final int IMAGE_HEIGHT = IMAGE.getHeight(); G2.setStroke(new BasicStroke(0.75f)); POINTER_WHITE_RIGHT.closePath(); final Area POINTER_FRAME_WHITE = new Area(POINTER_WHITE_LEFT); POINTER_FRAME_WHITE.add(new Area(POINTER_WHITE_RIGHT)); final Color STROKE_COLOR = getBackgroundColor().SYMBOL_COLOR.darker(); final Color FILL_COLOR = getBackgroundColor().SYMBOL_COLOR;