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); if (backColor != null) { 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());
Rectangle2D annotationRectangle = textLayout.getBounds(); double x = dataPoint.x + dataPoint.w / 2 - annotationRectangle.getWidth() / 2 - MARGIN; double y = dataPoint.y - 3 * MARGIN - annotationRectangle.getHeight(); double w = annotationRectangle.getWidth() + 2 * MARGIN; double h = annotationRectangle.getHeight() + 2 * MARGIN; double halfHeight = h / 2; g.setColor(styler.getToolTipHighlightColor()); g.fill(dataPoint.shape); y = Math.max(y, topEdge); y = Math.min(y, bottomEdge - h); Rectangle2D rectangle = new Rectangle2D.Double(x, y, w, h); g.setColor(styler.getToolTipBackgroundColor()); g.fill(rectangle); g.setFont(styler.getToolTipFont()); AffineTransform orig = g.getTransform(); AffineTransform at = new AffineTransform(); at.translate(x + MARGIN - 1, y + MARGIN - 1 + halfHeight); g.transform(at); g.fill(shape);
@Override public void paint(Graphics2D g) { Rectangle2D bounds = getBounds(); // paint plot background Shape rect = new Rectangle2D.Double(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight()); g.setColor(styler.getPlotBackgroundColor()); g.fill(rect); // paint plot border if (styler.isPlotBorderVisible()) { g.setColor(styler.getPlotBorderColor()); // g.setStroke(getChartPainter().getstyler().getAxisTickMarksStroke()); g.draw(rect); } } }
@Override public void paint(Graphics2D g) { bounds = new Rectangle2D.Double(); g.setColor(chart.getStyler().getChartFontColor()); g.setFont(chart.getStyler().getAxisTitleFont()); && chart.getStyler().isYAxisTitleVisible()) { AffineTransform rot = AffineTransform.getRotateInstance(-1 * Math.PI / 2, 0, 0); Shape shape = nonRotatedTextLayout.getOutline(rot); AffineTransform at = new AffineTransform(); at.translate(xOffset, yOffset); new Rectangle2D.Double( new Rectangle2D.Double( new Rectangle2D.Double( xOffset, yOffset - chart.getStyler().getAxisTitlePadding(), new Rectangle2D.Double(
@Override public void paint(Graphics2D g) { g.setFont(chart.getStyler().getChartTitleFont()); Object oldHint = g.getRenderingHint(RenderingHints.KEY_ANTIALIASING); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Rectangle2D textBounds = textLayout.getBounds(); double xOffset = chart.getPlot().getBounds().getX(); // of plot left edge double yOffset = chart.getStyler().getChartPadding(); double chartTitleBoxWidth = chart.getPlot().getBounds().getWidth(); double chartTitleBoxHeight = textBounds.getHeight() + 2 * chart.getStyler().getChartTitlePadding(); g.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); Shape rect = new Rectangle2D.Double(xOffset, yOffset, chartTitleBoxWidth, chartTitleBoxHeight); g.setColor(chart.getStyler().getChartTitleBoxBackgroundColor()); g.fill(rect); double height = 2 * chart.getStyler().getChartTitlePadding() + textBounds.getHeight(); bounds = new Rectangle2D.Double( xOffset - chart.getStyler().getChartTitlePadding(), yOffset - textBounds.getHeight() - chart.getStyler().getChartTitlePadding(),
Rectangle2D dataArea, double value, Paint paint, Stroke stroke) { Range range = axis.getRange(); if (!range.contains(value)) { return; Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX(), dataArea.getY() + getYOffset(), dataArea.getWidth() - getXOffset(), dataArea.getHeight() - getYOffset()); double y1 = y0 - getYOffset(); double y2 = dataArea.getMinY(); line1 = new Line2D.Double(x0, y0, x1, y1); line2 = new Line2D.Double(x1, y1, x1, y2); double y0 = axis.valueToJava2D(value, adjusted, plot.getRangeAxisEdge()); double y1 = y0 - getYOffset(); double x1 = x0 + getXOffset(); double x2 = dataArea.getMaxX(); line1 = new Line2D.Double(x0, y0, x1, y1); line2 = new Line2D.Double(x1, y1, x2, y1); g2.setPaint(paint); g2.setStroke(stroke); g2.draw(line1); g2.draw(line2);
at.translate(x, y); -(icon.getIconWidth() * icoStyle.getAnchorPointX()), (icon.getIconHeight() * (icoStyle.getAnchorPointY() - 1))); graphics.setTransform(at); new Rectangle2D.Double( x, y, icon.getIconWidth(), icon.getIconHeight())); labelCache.put(transformedShape.getBounds2D()); if (anchorPoint != null) { alignedRect = new Rectangle2D.Double( Math.round(anchorPoint.getX()), Math.round(anchorPoint.getY()), cornerRect.getWidth(), cornerRect.getHeight()); } else { alignedRect = new Rectangle2D.Double( 0.0, 0.0, cornerRect.getWidth(),
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON); g2d.setBackground(Color.BLACK); g2d.setColor(color[currShape]); case 1: g2d.fill(new Rectangle2D.Double(currX, currY, SHAPE_SIZE, SHAPE_SIZE)); break; case 2: 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: case 3: g2d.setStroke(lineStroke); g2d.draw(new Line2D.Double(distractorX,distractorY,distractorX+SHAPE_SIZE,distractorY+SHAPE_SIZE)); break; default:
final Color extended = mapper.getMappedColor(fontConfiguration.getExtendedColor()); if (extended != null) { g2d.setColor(extended); g2d.setBackground(extended); g2d.fill(new Rectangle2D.Double(x, y - dimBack.getHeight() + 1.5, dimBack.getWidth(), dimBack .getHeight())); 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());
double starty = yOffset + chart.getStyler().getLegendPadding(); Object oldHint = g.getRenderingHint(RenderingHints.KEY_ANTIALIASING); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(series.getLineColor()); g.setStroke(series.getLineStyle()); Shape line = new Line2D.Double( startx, starty + legendEntryHeight / 2.0, Shape rectSmall = new Rectangle2D.Double(startx, starty, BOX_SIZE, BOX_SIZE); g.setColor(series.getFillColor()); g.fill(rectSmall); new BasicStroke( existingLineStyle.getLineWidth() > BOX_OUTLINE_WIDTH * 0.5f ? BOX_OUTLINE_WIDTH * 0.5f : existingLineStyle.getLineWidth(), existingLineStyle.getEndCap(), existingLineStyle.getLineJoin(),
Rectangle2D dataArea, double start, double end) { double y1 = axis.valueToJava2D(start, dataArea, plot.getRangeAxisEdge()); double y2 = axis.valueToJava2D(end, dataArea, plot.getRangeAxisEdge()); Rectangle2D band; if (plot.getOrientation() == PlotOrientation.VERTICAL) { band = new Rectangle2D.Double(dataArea.getMinX(), Math.min(y1, y2), dataArea.getWidth(), Math.abs(y2 - y1)); band = new Rectangle2D.Double(Math.min(y1, y2), dataArea.getMinY(), Math.abs(y2 - y1), dataArea.getHeight()); g2.setPaint(paint); g2.fill(band);
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); }
g2.setFont(getTickLabelFont(tick.getCategory())); 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)) { Point2D anchorPoint = RectangleAnchor.coordinates(area, position.getCategoryAnchor()); TextBlock block = tick.getLabel(); block.draw(g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(), position.getLabelAnchor(), (float) anchorPoint.getX(), (float) anchorPoint.getY(), position.getAngle()); Shape bounds = block.calculateBounds(g2, r = bounds.getBounds2D(); 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);
BufferedImage image = tp.getImage(); Rectangle2D rect = tp.getAnchorRect(); AffineTransform at = graphics.getTransform(); double width = rect.getWidth() * at.getScaleX(); double height = rect.getHeight() * at.getScaleY(); Rectangle2D scaledRect = new Rectangle2D.Double(0, 0, width, height); paint = new TexturePaint(image, scaledRect); if (graphics.getRenderingHint(RenderingHints.KEY_ANTIALIASING) == RenderingHints.VALUE_ANTIALIAS_ON) { if (stroke instanceof BasicStroke && strokeWidthAdjustment > 0) { BasicStroke bs = (BasicStroke) stroke; stroke = new BasicStroke( bs.getLineWidth() + strokeWidthAdjustment, bs.getEndCap(), bs.getLineJoin(), bs.getMiterLimit(), graphics.setPaint(paint); graphics.setStroke(stroke); graphics.setComposite(ls2d.getContourComposite());
graphics.setComposite(composite); if (transformedShape != null) { if (ms2d.getFill() != null) { graphics.setPaint(ms2d.getFill()); graphics.fill(transformedShape); labelCache.put(transformedShape.getBounds2D()); Icon icon = icons.getIcon(); AffineTransform markAT = new AffineTransform(graphics.getTransform()); markAT.translate(x, y); markAT.rotate(rotation); new Rectangle2D.Double( x + dx, y + dy, icon.getIconWidth(), icon.getIconHeight()));
private void drawBufferedImage(BufferedImage image, AffineTransform at) throws IOException graphics.setComposite(getGraphicsState().getNonStrokingJavaComposite()); setClip(); AffineTransform imageTransform = new AffineTransform(at); PDSoftMask softMask = getGraphicsState().getSoftMask(); if( softMask != null ) imageTransform.scale(1, -1); 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));
g.setColor(styler.getAxisTickMarksColor()); g.setStroke(styler.getAxisTickMarksStroke()); new Rectangle2D.Double( xOffset, yOffset, new Line2D.Double( xOffset, flippedTickLocation, xOffset + axisTickMarkLength, flippedTickLocation); g.draw(line); new Line2D.Double(lineXOffset, yOffset, lineXOffset, yOffset + yAxisBounds.getHeight()); g.draw(line); new Rectangle2D.Double( xOffset, yOffset - axisTickMarkLength, new Line2D.Double( shiftedTickLocation, yOffset, bounds = new Rectangle2D.Double();
ArrayList<Shape> regions = new ArrayList<Shape>(); PathIterator pi = shape.getPathIterator(null); int ii = 0; GeneralPath gp = new GeneralPath(); Rectangle r = shape1.getBounds(); System.out.println("shape rect: " + r); int spaceX = sz - r.width; int spaceY = sz - r.height; AffineTransform trans = AffineTransform.getTranslateInstance( -r.x + (spaceX / 2), -r.y + (spaceY / 2)); System.out.println("Box2D " + trans); 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 {
Graphics2D graphics, Shape shape, Style2D graphicFill, double scale) { Rectangle2D boundsShape = shape.getBounds2D(); final Shape markShape = ms2d.getShape(); double size = ms2d.getSize(); Rectangle2D boundsFill = markShape.getBounds2D(); double aspect = (boundsFill.getHeight() > 0 && boundsFill.getWidth() > 0) ? boundsFill.getWidth() / boundsFill.getHeight() : 1.0; stippleSize = new Rectangle2D.Double(0, 0, size * aspect, size); clippedGraphics.clip(shape); LineStyle2D lineStyle = new LineStyle2D(); lineStyle.setStroke(ms2d.getStroke()); stippleSize = new Rectangle2D.Double(0, 0, icon.getIconWidth(), icon.getIconHeight()); } else if (graphicFill instanceof GraphicStyle2D) { BufferedImage image = ((GraphicStyle2D) graphicFill).getImage(); stippleSize = new Rectangle2D.Double(0, 0, image.getWidth(), image.getHeight()); } else { Graphics2D g = (Graphics2D) graphics.create(); AffineTransform2D identityTransf = new AffineTransform2D(new AffineTransform()); Decimator nullDecimator = new Decimator(-1, -1);
public boolean drawImage(Image img, int x, int y, ImageObserver observer) { Image image = null; if(transformer instanceof ShapeFlatnessTransformer) { Rectangle2D r = new Rectangle2D.Double(x,y,img.getWidth(observer),img.getHeight(observer)); Rectangle2D s = ((ShapeTransformer)transformer).transform(r).getBounds2D(); image = img.getScaledInstance((int)s.getWidth(), (int)s.getHeight(), Image.SCALE_SMOOTH); x = (int) s.getMinX(); y = (int) s.getMinY(); } else { image = img; } return delegate.drawImage(image, x, y, observer); }