static Rectangle2D move(Rectangle2D rect, double dx, double dy) { return new Rectangle2D.Double(rect.getX() + dx, rect.getY() + dy, rect.getWidth(), rect.getHeight()); }
private void drawRect(Graphics2D g2d, final Point2D pos, final Dimension2D dim) { final Rectangle2D rect = new Rectangle2D.Double(pos.getX(), pos.getY(), dim.getWidth(), dim.getHeight()); g2d.draw(rect); } }
private void renderWidgetOverlay(Graphics2D graphics, Portal portal, String text, Color color) { Widget shield = client.getWidget(portal.getShield()); Widget icon = client.getWidget(portal.getIcon()); Widget hp = client.getWidget(portal.getHitpoints()); Widget bar = client.getWidget(WidgetInfo.PEST_CONTROL_ACTIVITY_BAR).getChild(0); Rectangle2D barBounds = bar.getBounds().getBounds2D(); // create one rectangle from two different widget bounds Rectangle2D bounds = union(shield.getBounds().getBounds2D(), icon.getBounds().getBounds2D()); bounds = union(bounds, hp.getBounds().getBounds2D()); graphics.setColor(color); graphics.draw(new Rectangle2D.Double(bounds.getX(), bounds.getY() - 2, bounds.getWidth(), bounds.getHeight() - 3)); FontMetrics fm = graphics.getFontMetrics(); Rectangle2D textBounds = fm.getStringBounds(text, graphics); int x = (int) (bounds.getX() + (bounds.getWidth() / 2) - (textBounds.getWidth() / 2)); int y = (int) (bounds.getY() + bounds.getHeight() + textBounds.getHeight() + barBounds.getHeight()); graphics.setColor(Color.BLACK); graphics.drawString(text, x + 1, y + 5); graphics.setColor(color); graphics.drawString(text, x, y + 4); }
if (transformedShape != null) { if (ms2d.getFill() != null) { graphics.setPaint(ms2d.getFill()); graphics.fill(transformedShape); graphics.setPaint(ms2d.getContour()); graphics.setStroke(ms2d.getStroke()); graphics.draw(transformedShape); new Rectangle2D.Double( x + dx, y + dy, icon.getIconWidth(), icon.getIconHeight()));
Rectangle2D applyMargins(int[] margin, Rectangle2D bounds) { if (bounds != null) { double xmin = bounds.getMinX() - margin[3]; double ymin = bounds.getMinY() - margin[0]; double width = bounds.getWidth() + margin[1] + margin[3]; double height = bounds.getHeight() + margin[0] + margin[2]; return new Rectangle2D.Double(xmin, ymin, width, height); } else { return bounds; } }
imageTransform.translate(0, -1); Paint awtPaint = new TexturePaint(image, new Rectangle2D.Double(imageTransform.getTranslateX(), imageTransform.getTranslateY(), imageTransform.getScaleX(), imageTransform.getScaleY())); awtPaint = applySoftMaskToPaint(awtPaint, softMask); graphics.setPaint(awtPaint); Rectangle2D unitRect = new Rectangle2D.Float(0, 0, 1, 1); if (isContentRendered()) graphics.fill(at.createTransformedShape(unitRect));
final HtmlColor extended = fontConfiguration.getExtendedColor(); if (fontConfiguration.containsStyle(FontStyle.BACKCOLOR)) { final Rectangle2D.Double area = new Rectangle2D.Double(x, y - dimBack.getHeight() + 1.5, dimBack.getWidth(), dimBack.getHeight()); if (extended instanceof HtmlColorGradient) { final GradientPaint paint = DriverRectangleG2d.getPaintGradient(x, y, mapper, dimBack.getWidth(), dimBack.getHeight(), extended); g2d.setPaint(paint); g2d.fill(area); } else { final Color backColor = mapper.getMappedColor(extended); g2d.setColor(backColor); g2d.setBackground(backColor); g2d.fill(area); g2d.setStroke(new BasicStroke((float) 1)); g2d.drawLine((int) x, ypos, (int) (x + dim.getWidth()), ypos); g2d.setStroke(new BasicStroke()); g2d.setColor(mapper.getMappedColor(extended)); g2d.setStroke(new BasicStroke((float) 1.5)); g2d.drawLine((int) x, ypos, (int) (x + dim.getWidth()), ypos); g2d.setStroke(new BasicStroke());
g.setStroke(styler.getAxisTickMarksStroke()); double yOffset = yAxisBounds.getY(); new Rectangle2D.Double( xOffset, yOffset, chart.getStyler().getAxisTickMarkLength(), yAxis.getBounds().getHeight()); double flippedTickLocation = yOffset + yAxisBounds.getHeight() - tickLocation; if (flippedTickLocation > bounds.getY() && flippedTickLocation < bounds.getY() + bounds.getHeight()) { g.draw(line); double xOffset = chart.getXAxis().getBounds().getX(); new Rectangle2D.Double( xOffset, yOffset - axisTickMarkLength, chart.getXAxis().getBounds().getWidth(), axisTickMarkLength); && shiftedTickLocation < bounds.getX() + bounds.getWidth()) { bounds = new Rectangle2D.Double();
@SuppressWarnings("rawtypes") public void draw(Graphics2D graphics) { Dimension pg = shape.getSheet().getSlideShow().getPageSize(); final Rectangle2D anchor = new Rectangle2D.Double(0, 0, pg.getWidth(), pg.getHeight()); PlaceableShape<?,?> ps = new PlaceableShape(){ public ShapeContainer<?,?> getParent() { return null; } public Rectangle2D getAnchor() { return anchor; } public void setAnchor(Rectangle2D newAnchor) {} public double getRotation() { return 0; } public void setRotation(double theta) {} public void setFlipHorizontal(boolean flip) {} public void setFlipVertical(boolean flip) {} public boolean getFlipHorizontal() { return false; } public boolean getFlipVertical() { return false; } public Sheet<?,?> getSheet() { return shape.getSheet(); } }; DrawFactory drawFact = DrawFactory.getInstance(graphics); DrawPaint dp = drawFact.getPaint(ps); Paint fill = dp.getPaint(graphics, getShape().getFillStyle().getPaint()); Rectangle2D anchor2 = getAnchor(graphics, anchor); if(fill != null) { graphics.setRenderingHint(Drawable.GRADIENT_SHAPE, anchor); graphics.setPaint(fill); graphics.fill(anchor2); } }
/** * Fills the component with the current Paint. * * @param g the graphics device. */ 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); }
public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, Graphics2D g2d) { g2d.setStroke(new BasicStroke((float) param.getStroke().getThickness())); final URectangle rect = (URectangle) ushape; final double rx = rect.getRx(); final Shape shape; if (rx == 0 && ry == 0) { shape = new Rectangle2D.Double(x, y, rect.getWidth(), rect.getHeight()); } else { shape = new RoundRectangle2D.Double(x, y, rect.getWidth(), rect.getHeight(), rx, ry); if (back instanceof HtmlColorGradient) { final GradientPaint paint = getPaintGradient(x, y, mapper, rect.getWidth(), rect.getHeight(), back); g2d.setPaint(paint); g2d.fill(shape); drawBorder(param, color, mapper, rect, shape, g2d, x, y); } else { DriverLineG2d.manageStroke(param, g2d); managePattern(param, g2d); g2d.fill(shape);
case 0: g2d.fill(new Ellipse2D.Double(currX, currY, SHAPE_SIZE, SHAPE_SIZE)); break; case 1: g2d.fill(new Rectangle2D.Double(currX, currY, SHAPE_SIZE, SHAPE_SIZE)); break; case 2: g2d.fill(new Arc2D.Double(currX,currY,SHAPE_SIZE,SHAPE_SIZE,315,225,Arc2D.PIE)); break; case 3: g2d.setStroke(lineStroke); g2d.draw(new Line2D.Double(currX,currY,currX+SHAPE_SIZE,currY+SHAPE_SIZE)); break; default: break; case 1: g2d.fill(new Rectangle2D.Double(distractorX, distractorY, SHAPE_SIZE, SHAPE_SIZE)); break; case 2:
final JLabel label = new JLabel(new ImageIcon(image)); int pad = 5; final Shape rectangle = new Rectangle2D.Double( (double)pad,(double)pad, (double)(width-2*pad), g.setStroke(dashedStroke); g.draw(rectangle);
g2.setPaint(getTickLabelPaint(tick.getCategory())); x1 = x0 - state.getMax(); Rectangle2D area = new Rectangle2D.Double(x0, y0, (x1 - x0), (y1 - y0)); if(r==null || !r.intersects(area)) { r.add(r.getMaxX() + r.getWidth()/2, r.getCenterY()); r.add(r.getMinX() - r.getWidth()/2, r.getCenterY()); r.add(r.getCenterX(), r.getMinY() - r.getHeight()/2); r.add(r.getCenterX(), r.getMaxX() + r.getHeight()/2);
protected void drawRangeArea( final Rectangle2D area, final Graphics2D g2 ) { final Number rangeUpperBound = getRangeUpperBound(); final Number rangeLowerBound = getRangeLowerBound(); if ( rangeLowerBound == null || rangeUpperBound == null ) { return; } final double x0 = valueToJava2D( rangeLowerBound.doubleValue(), area ); final double x1 = valueToJava2D( rangeUpperBound.doubleValue(), area ); final Rectangle2D rangeArea = new Rectangle2D.Double( x0, area.getY(), ( x1 - x0 ), area.getHeight() ); g2.setPaint( getRangePaint() ); g2.fill( rangeArea ); }
g2d.setColor(extended); g2d.setBackground(extended); g2d.fill(new Rectangle2D.Double(x, y - dimBack.getHeight() + 1.5, dimBack.getWidth(), dimBack .getHeight())); final TextLayout t = new TextLayout(shape.getText(), font.getFont(), fontRenderContext); g2d.translate(x, y); g2d.fill(t.getOutline(null)); g2d.translate(-x, -y); g2d.setStroke(new BasicStroke((float) 1)); g2d.drawLine((int) x, ypos, (int) (x + dim.getWidth()), ypos); g2d.setStroke(new BasicStroke()); g2d.setColor(mapper.getMappedColor(extended)); g2d.setStroke(new BasicStroke((float) 1.5)); g2d.drawLine((int) x, ypos, (int) (x + dim.getWidth()), ypos); g2d.setStroke(new BasicStroke());
@Override public void paint(Graphics2D g, double xOffset, double yOffset, int markerSize) { g.setStroke(stroke); double halfSize = (double) markerSize / 2; Shape square = new Rectangle2D.Double(xOffset - halfSize, yOffset - halfSize, markerSize, markerSize); g.fill(square); } }
public void paintCirclesInSquare(Graphics2D g2d, int count, int x, int y, int width, int height, Color squareStroke, Color squareFill, Color circleStroke, Color circleFill) { int centerX = x + (width / 2); int centerY = y + (height / 2); int radius = Math.min(centerX, centerY); Rectangle2D box = new Rectangle2D.Double(x, y, width, height); g2d.setColor(squareFill); g2d.fill(box); g2d.setColor(squareStroke); g2d.draw(box); paintCirclesIn(g2d, count, radius, centerX, centerY, circleStroke, circleFill); g2d.drawLine(centerX, y, centerX, y + height); g2d.drawLine(x, centerY, x + width, centerY); }
Rectangle2D rect = new Rectangle2D.Double(x, y, width, height); g2d.draw(rect); g2d.draw(line); for (Point2D p : ps) { if (p != null) { g2d.fill(new Ellipse2D.Double(p.getX() - 4, p.getY() - 4, 8, 8));
Arc2D innerarc = new Arc2D.Double(x + 1, y - 197 * eh / 700 + 1, ew - 2, eh - 2, 0, 360, Arc2D.OPEN); curve.append(new Rectangle2D.Double(x, y, x2 - x, y2 - y), false); g2.setClip(new Rectangle2D.Double(x, y, x2 - x, y2 - y)); g2.setClip(arc); g2.drawImage(artToUse, x, y, x2 - x, y2 - y, null); g2.setClip(null); g2.setClip(new Rectangle2D.Double(x, y, x2 - x, y2 - y)); g2.draw(arc); g2.setColor(Color.black); g2.draw(innerarc);