@Override public void drawSVG(OutputDevice outputDevice, RenderingContext ctx, double x, double y) { outputDevice.drawWithGraphics((float) x, (float) y, (float) this._scaledWidthInOutputDeviceDots, (float) this._scaledHeightInOutputDeviceDots, new OutputDeviceGraphicsDrawer() { @Override public void render(Graphics2D g2d) { g2d.scale(_sx, _sy); _view.draw(g2d, 0, _view.getAscentHeight()); } }); }
final BorderPropertySet color, final float[] pattern, final int sides, final int currentSide, int xOffset) { Stroke old_stroke = outputDevice.getStroke(); if (!outputDevice.isFastRenderer()) { old_clip = outputDevice.getClip(); if(old_clip != null) { outputDevice.setClip(clip); } else { outputDevice.pushClip(clip); outputDevice.setColor(color.topColor()); outputDevice.setStroke(new BasicStroke(2*(int) border.top(), BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, pattern, xOffset)); outputDevice.drawBorderLine( path, BorderPainter.TOP, (int)border.top(), false); } else if (currentSide == BorderPainter.LEFT) { outputDevice.setColor(color.leftColor()); outputDevice.setStroke(new BasicStroke(2*(int) border.left(), BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, pattern, 0)); outputDevice.drawBorderLine( path, BorderPainter.LEFT, (int)border.left(), false); } else if (currentSide == BorderPainter.RIGHT) { outputDevice.setColor(color.rightColor()); outputDevice.setStroke(new BasicStroke(2*(int) border.right(), BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, pattern, 0)); outputDevice.drawBorderLine( path, BorderPainter.RIGHT, (int)border.right(), false); } else if (currentSide == BorderPainter.BOTTOM) { outputDevice.setColor(color.bottomColor()); outputDevice.setStroke(new BasicStroke(2*(int) border.bottom(), BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, pattern, xOffset));
public void paintDebugOutline(RenderingContext c) { c.getOutputDevice().drawDebugOutline(c, this, FSRGBColor.BLUE); }
private static void drawGlyph(RenderingContext c, BlockBox box, CalculatedStyle style, IdentValue listStyle) { // save the old AntiAliasing setting, then force it on Object aa_key = c.getOutputDevice().getRenderingHint(RenderingHints.KEY_ANTIALIASING); c.getOutputDevice().setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // calculations for bullets StrutMetrics strutMetrics = box.getMarkerData().getStructMetrics(); MarkerData.GlyphMarker marker = box.getMarkerData().getGlyphMarker(); int x = getReferenceX(c, box); if (style.getDirection() == IdentValue.LTR) { x += -marker.getLayoutWidth(); } if (style.getDirection() == IdentValue.RTL){ x += box.getMarkerData().getReferenceLine().getWidth() + marker.getLayoutWidth(); } int y = getReferenceBaseline(c, box) - (int)strutMetrics.getAscent() / 2 - marker.getDiameter() / 2; if (listStyle == IdentValue.DISC) { c.getOutputDevice().fillOval(x, y, marker.getDiameter(), marker.getDiameter()); } else if (listStyle == IdentValue.SQUARE) { c.getOutputDevice().fillRect(x, y, marker.getDiameter(), marker.getDiameter()); } else if (listStyle == IdentValue.CIRCLE) { c.getOutputDevice().drawOval(x, y, marker.getDiameter(), marker.getDiameter()); } // restore the old AntiAliasing setting c.getOutputDevice().setRenderingHint(RenderingHints.KEY_ANTIALIASING, aa_key == null ? RenderingHints.VALUE_ANTIALIAS_DEFAULT : aa_key); }
outputDevice.setColor(border.topColor()); outputDevice.draw(line); } else { Shape line = generateBorderShape(bounds, currentSide, border, true, offset, scale); outputDevice.fill(line); outputDevice.setColor(border.bottomColor()); if ((int) border.bottom() == 1) { Shape line = generateBorderShape(bounds, currentSide, border, false, offset, scale); outputDevice.draw(line); } else { Shape line = generateBorderShape(bounds, currentSide, border, true, offset, scale); outputDevice.fill(line); outputDevice.setColor(border.rightColor()); if ((int) border.right() == 1) { Shape line = generateBorderShape(bounds, currentSide, border, false, offset, scale); outputDevice.draw(line); } else { Shape line = generateBorderShape(bounds, currentSide, border, true, offset, scale); outputDevice.fill(line); outputDevice.setColor(border.leftColor()); if ((int) border.left() == 1) { Shape line = generateBorderShape(bounds, currentSide, border, false, offset, scale);
public void pushClipRegion(RenderingContext c, int contentIndex) { while (_current != null && _current.getRange().getStart() == contentIndex) { _current.setClip(_outputDevice.getClip()); _clipRegionStack.add(_current); _outputDevice.clip(_current.getBox().getChildrenClipEdge(c)); if (_rangeIndex == _rangeList.size() - 1) { _current = null; } else { _current = (BoxRangeData)_rangeList.get(++_rangeIndex); } } }
public void paintInline(RenderingContext c) { if (! getParent().getStyle().isVisible(c, this)) { return; } if (isContainsDynamicFunction()) { lookForDynamicFunctions(c); int totalLineWidth; if (direction == BidiSplitter.RTL) { totalLineWidth = InlineBoxing.positionHorizontallyRTL(c, this, 0, 0); } else { totalLineWidth = InlineBoxing.positionHorizontally(c, this, 0); } setContentWidth(totalLineWidth); calcChildLocations(); align(true, c); calcPaintingInfo(c, false); } if (_textDecorations != null) { c.getOutputDevice().drawTextDecoration(c, this); } if (c.debugDrawLineBoxes()) { c.getOutputDevice().drawDebugOutline(c, this, FSRGBColor.GREEN); } }
private static void drawImage(RenderingContext c, BlockBox box, MarkerData markerData) { FSImage img = null; MarkerData.ImageMarker marker = markerData.getImageMarker(); img = marker.getImage(); if (img != null) { StrutMetrics strutMetrics = box.getMarkerData().getStructMetrics(); int x = getReferenceX(c, box); // FIXME: findbugs possible loss of precision, cf. int / (float)2 x += -marker.getLayoutWidth() + (marker.getLayoutWidth() / 2 - img.getWidth() / 2); c.getOutputDevice().drawImage(img, x, (int)(getReferenceBaseline(c, box) - strutMetrics.getAscent() / 2 - img.getHeight() / 2), box.getStyle().isImageRenderingInterpolate()); } }
@Override public void drawSVG(OutputDevice outputDevice, RenderingContext ctx, double x, double y) { outputDevice.drawWithGraphics((float) x, (float) y, (float) this._scaledWidthInOutputDeviceDots, (float) this._scaledHeightInOutputDeviceDots, new OutputDeviceGraphicsDrawer() { @Override public void render(Graphics2D g2d) { g2d.scale(_sx, _sy); _view.draw(g2d, 0, _view.getAscentHeight()); } }); }
public void paintDebugOutline(RenderingContext c) { c.getOutputDevice().drawDebugOutline(c, this, FSRGBColor.RED); }
angle = Integer.parseInt(e.getAttribute("data-angle")); outputDevice.drawWithGraphics((float) x, (float) y, (float) width / dotsPerPixel, (float) height / dotsPerPixel, new OutputDeviceGraphicsDrawer() { @Override
@Override protected void transcode(Document svg, String uri, TranscoderOutput out) throws TranscoderException { // Note: We have to initialize user agent here and not in ::createUserAgent() as method // is called before our constructor is called in the super constructor. this.userAgent = new OpenHtmlUserAgent(this.fontResolver); super.transcode(svg, uri, out); outputDevice.drawWithGraphics((float)x, (float)y, width, height, new OutputDeviceGraphicsDrawer() { @Override public void render(Graphics2D graphics2D) { /* * Do the real paint */ PDFTranscoder.this.root.paint(graphics2D); } }); }
outputDevice.drawWithGraphics((float) x, (float) y, (float) width / dotsPerPixel, (float) height / dotsPerPixel, new OutputDeviceGraphicsDrawer() { @Override
outputDevice.drawWithGraphics((float) x, (float) y, (float) width / dotsPerPixel, (float) height / dotsPerPixel, new OutputDeviceGraphicsDrawer() { @Override