From 6db03515c3c7b2e17105200fc90c25525890bd4a Mon Sep 17 00:00:00 2001 From: Emmeran Seehuber Date: Sun, 19 Feb 2017 16:50:00 +0100 Subject: [PATCH] #23: Delete the old obsolte PDFGraphics2DOutputDeviceAdapter. --- .../PDFGraphics2DOutputDeviceAdapter.java | 248 ------------------ 1 file changed, 248 deletions(-) delete mode 100644 openhtmltopdf-svg-support/src/main/java/com/openhtmltopdf/svgsupport/PDFGraphics2DOutputDeviceAdapter.java diff --git a/openhtmltopdf-svg-support/src/main/java/com/openhtmltopdf/svgsupport/PDFGraphics2DOutputDeviceAdapter.java b/openhtmltopdf-svg-support/src/main/java/com/openhtmltopdf/svgsupport/PDFGraphics2DOutputDeviceAdapter.java deleted file mode 100644 index 3c179fa87..000000000 --- a/openhtmltopdf-svg-support/src/main/java/com/openhtmltopdf/svgsupport/PDFGraphics2DOutputDeviceAdapter.java +++ /dev/null @@ -1,248 +0,0 @@ -package com.openhtmltopdf.svgsupport; - -import com.openhtmltopdf.css.parser.FSRGBColor; -import com.openhtmltopdf.extend.OutputDevice; -import com.openhtmltopdf.render.RenderingContext; -import org.apache.batik.ext.awt.g2d.AbstractGraphics2D; -import org.apache.batik.ext.awt.g2d.GraphicContext; - -import java.awt.*; -import java.awt.geom.AffineTransform; -import java.awt.image.BufferedImage; -import java.awt.image.ColorModel; -import java.awt.image.ImageObserver; -import java.awt.image.RenderedImage; -import java.awt.image.renderable.RenderableImage; -import java.text.AttributedCharacterIterator; - -@Deprecated -public class PDFGraphics2DOutputDeviceAdapter extends AbstractGraphics2D { - - private final RenderingContext ctx; - private final OutputDevice od; - private final Graphics2D g2d2; - private final double x; - private final double y; - private final AffineTransform defaultTransform; - private final float dotsPerPoint; - - private Color _c = Color.BLACK; - private Stroke _stroke; - private Paint _paint = Color.BLACK; - private Composite _composite = AlphaComposite.getInstance(AlphaComposite.SRC); - private Color _background = Color.WHITE; - - public PDFGraphics2DOutputDeviceAdapter(RenderingContext ctx, OutputDevice od, double x, double y, float dotsPerInch) { - super(false); - - this.od = od; - this.ctx = ctx; - this.x = x; - this.y = y; - this.dotsPerPoint = dotsPerInch / 96f; - - AffineTransform scale = AffineTransform.getScaleInstance(dotsPerPoint, dotsPerPoint); - defaultTransform = scale; - - BufferedImage img = new BufferedImage(BufferedImage.TYPE_INT_ARGB, 1, 1); - g2d2 = img.createGraphics(); - - this.gc = new GraphicContext(); - } - - @Override - public Shape getClip() { - return od.getRawClip(); - } - - @Override - public void setClip(Shape arg0) { - od.setRawClip(arg0); - } - - @Override - public void clip(Shape arg0) { - od.rawClip(arg0); - } - - @Override - public Composite getComposite() { - return _composite; - } - - @Override - public void setBackground(Color arg0) { - _background = arg0; - } - - @Override - public Color getBackground() { - return _background; - } - - @Override - public void setColor(Color arg0) { - _c = arg0; - } - - @Override - public Color getColor() { - return _c; - } - - @Override - public void setPaint(Paint in) { - if (in instanceof org.apache.batik.ext.awt.LinearGradientPaint) { - org.apache.batik.ext.awt.LinearGradientPaint lg = (org.apache.batik.ext.awt.LinearGradientPaint) in; - in = lg.getColors()[0]; - // TODO: Proper handling of linear gradients - } - - _paint = in; - } - - @Override - public Rectangle getClipBounds() { - return getClip().getBounds(); - } - @Override - public Paint getPaint() { - return _paint; - } - - @Override - public void setComposite(Composite arg0) { - _composite = arg0; - } - - @Override - public void setStroke(Stroke arg0) { - _stroke = arg0; - } - - @Override - public Stroke getStroke() { - return _stroke; - } - - @Override - public void drawRenderedImage(RenderedImage img, AffineTransform xform) { - // TODO: Images - } - - @Override - public void drawRenderableImage(RenderableImage img, AffineTransform xform) { - // TODO: Images - } - - @Override - public void drawString(String str, float x, float y) { - throw new UnsupportedOperationException(); - } - - @Override - public void drawString(AttributedCharacterIterator iterator, float x, float y) { - throw new UnsupportedOperationException(); - } - - @Override - public void draw(Shape s) { - Color c = getColor(); - - od.setColor(new FSRGBColor(c.getRed(), c.getGreen(), c.getBlue())); - od.setAlpha(c.getAlpha()); - od.setStroke(getStroke()); - od.setPaint(getPaint()); - - AffineTransform offsetTransform = new AffineTransform(defaultTransform); - offsetTransform.translate(this.x / this.dotsPerPoint, this.y / this.dotsPerPoint); - offsetTransform.concatenate(getTransform()); - - od.saveState(); - od.draw(offsetTransform.createTransformedShape(s)); - od.restoreState(); - } - - @Override - public void fill(Shape s) { - Color c = getColor(); - - od.setColor(new FSRGBColor(c.getRed(), c.getGreen(), c.getBlue())); - od.setAlpha(c.getAlpha()); - od.setPaint(getPaint()); - - AffineTransform offsetTransform = new AffineTransform(defaultTransform); - offsetTransform.translate(this.x / this.dotsPerPoint, this.y / this.dotsPerPoint); - offsetTransform.concatenate(getTransform()); - - od.saveState(); - od.fill(offsetTransform.createTransformedShape(s)); - od.restoreState(); - } - - @Override - public GraphicsConfiguration getDeviceConfiguration() { - return new GraphicsConfiguration() { - - @Override - public AffineTransform getNormalizingTransform() { - return null; - } - - @Override - public GraphicsDevice getDevice() { - return null; - } - - @Override - public AffineTransform getDefaultTransform() { - return null; - } - - @Override - public ColorModel getColorModel(int transparency) { - return ColorModel.getRGBdefault(); - } - - @Override - public ColorModel getColorModel() { - return ColorModel.getRGBdefault(); - } - - @Override - public Rectangle getBounds() { - return null; - } - }; - } - - @Override - public Graphics create() { - return new PDFGraphics2DOutputDeviceAdapter(ctx, od, x, y, this.dotsPerPoint * 96f); - } - - @Override - public void setXORMode(Color c1) { - } - - @Override - public FontMetrics getFontMetrics(Font f) { - return g2d2.getFontMetrics(f); - } - - @Override - public void copyArea(int x, int y, int width, int height, int dx, int dy) { } - - @Override - public boolean drawImage(Image img, int x, int y, ImageObserver observer) { - return false; - } - - @Override - public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer) { - return false; - } - - @Override - public void dispose() { } -}