X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Forg%2Fjibble%2Fepsgraphics%2FEpsGraphics2D.java;h=313ec1c54c6c540c1c2d342a65549cbc8454d2d7;hb=a83adb45bdf9554e270921b4baad94defd314b36;hp=fe6d9623b7f07bafbeb370fda8b18f8daba74383;hpb=d4ec118f86b5c9dee801e743c46aaacc7bb521d1;p=jalview.git diff --git a/src/org/jibble/epsgraphics/EpsGraphics2D.java b/src/org/jibble/epsgraphics/EpsGraphics2D.java index fe6d962..313ec1c 100644 --- a/src/org/jibble/epsgraphics/EpsGraphics2D.java +++ b/src/org/jibble/epsgraphics/EpsGraphics2D.java @@ -119,7 +119,6 @@ import java.util.Map; * */ public class EpsGraphics2D extends java.awt.Graphics2D - implements AutoCloseable { public static final String VERSION = "0.8.8"; @@ -251,7 +250,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D * OutputStream is automatically flushed before being closed. If you forget to * do this, the file may be incomplete. */ - @Override public void close() throws IOException { flush(); @@ -404,7 +402,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D * Draws a 3D rectangle outline. If it is raised, light appears to come from * the top left. */ - @Override public void draw3DRect(int x, int y, int width, int height, boolean raised) { Color originalColor = getColor(); @@ -444,7 +441,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D * Fills a 3D rectangle. If raised, it has bright fill and light appears to * come from the top left. */ - @Override public void fill3DRect(int x, int y, int width, int height, boolean raised) { Color originalColor = getColor(); @@ -465,7 +461,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Draws a Shape on the EPS document. */ - @Override public void draw(Shape s) { draw(s, "stroke"); @@ -474,7 +469,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Draws an Image on the EPS document. */ - @Override public boolean drawImage(Image img, AffineTransform xform, ImageObserver obs) { @@ -488,7 +482,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Draws a BufferedImage on the EPS document. */ - @Override public void drawImage(BufferedImage img, BufferedImageOp op, int x, int y) { BufferedImage img1 = op.filter(img, null); @@ -498,7 +491,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Draws a RenderedImage on the EPS document. */ - @Override public void drawRenderedImage(RenderedImage img, AffineTransform xform) { Hashtable properties = new Hashtable(); @@ -521,7 +513,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Draws a RenderableImage by invoking its createDefaultRendering method. */ - @Override public void drawRenderableImage(RenderableImage img, AffineTransform xform) { drawRenderedImage(img.createDefaultRendering(), xform); @@ -530,7 +521,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Draws a string at (x,y) */ - @Override public void drawString(String str, int x, int y) { drawString(str, (float) x, (float) y); @@ -539,7 +529,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Draws a string at (x,y) */ - @Override public void drawString(String s, float x, float y) { if (s != null && s.length() > 0) @@ -554,7 +543,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D * Draws the characters of an AttributedCharacterIterator, starting from * (x,y). */ - @Override public void drawString(AttributedCharacterIterator iterator, int x, int y) { drawString(iterator, (float) x, (float) y); @@ -564,7 +552,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D * Draws the characters of an AttributedCharacterIterator, starting from * (x,y). */ - @Override public void drawString(AttributedCharacterIterator iterator, float x, float y) { @@ -597,7 +584,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Draws a GlyphVector at (x,y) */ - @Override public void drawGlyphVector(GlyphVector g, float x, float y) { Shape shape = g.getOutline(x, y); @@ -607,7 +593,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Fills a Shape on the EPS document. */ - @Override public void fill(Shape s) { draw(s, "fill"); @@ -617,7 +602,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D * Checks whether or not the specified Shape intersects the specified * Rectangle, which is in device space. */ - @Override public boolean hit(Rectangle rect, Shape s, boolean onStroke) { return s.intersects(rect); @@ -626,7 +610,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Returns the device configuration associated with this EpsGraphics2D object. */ - @Override public GraphicsConfiguration getDeviceConfiguration() { GraphicsConfiguration gc = null; @@ -649,7 +632,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D * Sets the Composite to be used by this EpsGraphics2D. EpsGraphics2D does not * make use of these. */ - @Override public void setComposite(Composite comp) { _composite = comp; @@ -659,7 +641,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D * Sets the Paint attribute for the EpsGraphics2D object. Only Paint objects * of type Color are respected by EpsGraphics2D. */ - @Override public void setPaint(Paint paint) { _paint = paint; @@ -673,7 +654,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D * Sets the stroke. Only accepts BasicStroke objects (or subclasses of * BasicStroke). */ - @Override public void setStroke(Stroke s) { if (s instanceof BasicStroke) @@ -708,7 +688,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Sets a rendering hint. These are not used by EpsGraphics2D. */ - @Override public void setRenderingHint(RenderingHints.Key hintKey, Object hintValue) { // Do nothing. @@ -718,7 +697,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D * Returns the value of a single preference for the rendering algorithms. * Rendering hints are not used by EpsGraphics2D. */ - @Override public Object getRenderingHint(RenderingHints.Key hintKey) { return null; @@ -727,7 +705,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Sets the rendering hints. These are ignored by EpsGraphics2D. */ - @Override public void setRenderingHints(Map hints) { // Do nothing. @@ -736,7 +713,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Adds rendering hints. These are ignored by EpsGraphics2D. */ - @Override public void addRenderingHints(Map hints) { // Do nothing. @@ -745,7 +721,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Returns the preferences for the rendering algorithms. */ - @Override public RenderingHints getRenderingHints() { return new RenderingHints(null); @@ -755,7 +730,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D * Translates the origin of the EpsGraphics2D context to the point (x,y) in * the current coordinate system. */ - @Override public void translate(int x, int y) { translate((double) x, (double) y); @@ -765,7 +739,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D * Concatenates the current EpsGraphics2D Transformation with a translation * transform. */ - @Override public void translate(double tx, double ty) { transform(AffineTransform.getTranslateInstance(tx, ty)); @@ -774,7 +747,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Concatenates the current EpsGraphics2D Transform with a rotation transform. */ - @Override public void rotate(double theta) { rotate(theta, 0, 0); @@ -784,7 +756,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D * Concatenates the current EpsGraphics2D Transform with a translated rotation * transform. */ - @Override public void rotate(double theta, double x, double y) { transform(AffineTransform.getRotateInstance(theta, x, y)); @@ -794,7 +765,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D * Concatenates the current EpsGraphics2D Transform with a scaling * transformation. */ - @Override public void scale(double sx, double sy) { transform(AffineTransform.getScaleInstance(sx, sy)); @@ -803,7 +773,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Concatenates the current EpsGraphics2D Transform with a shearing transform. */ - @Override public void shear(double shx, double shy) { transform(AffineTransform.getShearInstance(shx, shy)); @@ -813,7 +782,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D * Composes an AffineTransform object with the Transform in this EpsGraphics2D * according to the rule last-specified-first-applied. */ - @Override public void transform(AffineTransform Tx) { _transform.concatenate(Tx); @@ -823,7 +791,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Sets the AffineTransform to be used by this EpsGraphics2D. */ - @Override public void setTransform(AffineTransform Tx) { if (Tx == null) @@ -842,7 +809,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Gets the AffineTransform used by this EpsGraphics2D. */ - @Override public AffineTransform getTransform() { return new AffineTransform(_transform); @@ -851,7 +817,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Returns the current Paint of the EpsGraphics2D object. */ - @Override public Paint getPaint() { return _paint; @@ -860,7 +825,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * returns the current Composite of the EpsGraphics2D object. */ - @Override public Composite getComposite() { return _composite; @@ -869,7 +833,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Sets the background color to be used by the clearRect method. */ - @Override public void setBackground(Color color) { if (color == null) @@ -882,7 +845,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Gets the background color that is used by the clearRect method. */ - @Override public Color getBackground() { return _backgroundColor; @@ -892,7 +854,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D * Returns the Stroke currently used. Guaranteed to be an instance of * BasicStroke. */ - @Override public Stroke getStroke() { return _stroke; @@ -902,7 +863,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D * Intersects the current clip with the interior of the specified Shape and * sets the clip to the resulting intersection. */ - @Override public void clip(Shape s) { if (_clip == null) @@ -920,7 +880,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Returns the FontRenderContext. */ - @Override public FontRenderContext getFontRenderContext() { return _fontRenderContext; @@ -931,7 +890,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Returns a new Graphics object that is identical to this EpsGraphics2D. */ - @Override public Graphics create() { return new EpsGraphics2D(this); @@ -941,7 +899,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D * Returns an EpsGraphics2D object based on this Graphics object, but with a * new translation and clip area. */ - @Override public Graphics create(int x, int y, int width, int height) { Graphics g = create(); @@ -954,7 +911,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D * Returns the current Color. This will be a default value (black) until it is * changed using the setColor method. */ - @Override public Color getColor() { return _color; @@ -963,7 +919,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Sets the Color to be used when drawing all future shapes, text, etc. */ - @Override public void setColor(Color c) { if (c == null) @@ -979,7 +934,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D * Sets the paint mode of this EpsGraphics2D object to overwrite the * destination EpsDocument with the current color. */ - @Override public void setPaintMode() { // Do nothing - paint mode is the only method supported anyway. @@ -989,7 +943,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D * Not implemented - performs no * action. */ - @Override public void setXORMode(Color c1) { methodNotSupported(); @@ -998,7 +951,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Returns the Font currently being used. */ - @Override public Font getFont() { return _font; @@ -1007,7 +959,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Sets the Font to be used in future text. */ - @Override public void setFont(Font font) { if (font == null) @@ -1015,14 +966,13 @@ public class EpsGraphics2D extends java.awt.Graphics2D font = Font.decode(null); } _font = font; - append("/" + _font.getPSName() + " findfont " + (_font.getSize()) + append("/" + _font.getPSName() + " findfont " + ((int) _font.getSize()) + " scalefont setfont"); } /** * Gets the font metrics of the current font. */ - @Override public FontMetrics getFontMetrics() { return getFontMetrics(getFont()); @@ -1031,7 +981,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Gets the font metrics for the specified font. */ - @Override public FontMetrics getFontMetrics(Font f) { BufferedImage image = new BufferedImage(1, 1, @@ -1043,7 +992,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Returns the bounding rectangle of the current clipping area. */ - @Override public Rectangle getClipBounds() { if (_clip == null) @@ -1057,7 +1005,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Intersects the current clip with the specified rectangle. */ - @Override public void clipRect(int x, int y, int width, int height) { clip(new Rectangle(x, y, width, height)); @@ -1066,7 +1013,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Sets the current clip to the rectangle specified by the given coordinates. */ - @Override public void setClip(int x, int y, int width, int height) { setClip(new Rectangle(x, y, width, height)); @@ -1075,7 +1021,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Gets the current clipping area. */ - @Override public Shape getClip() { if (_clip == null) @@ -1101,7 +1046,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Sets the current clipping area to an arbitrary clip shape. */ - @Override public void setClip(Shape clip) { if (clip != null) @@ -1135,7 +1079,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D * Not implemented - performs no * action. */ - @Override public void copyArea(int x, int y, int width, int height, int dx, int dy) { methodNotSupported(); @@ -1144,7 +1087,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Draws a straight line from (x1,y1) to (x2,y2). */ - @Override public void drawLine(int x1, int y1, int x2, int y2) { Shape shape = new Line2D.Float(x1, y1, x2, y2); @@ -1154,7 +1096,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Fills a rectangle with top-left corner placed at (x,y). */ - @Override public void fillRect(int x, int y, int width, int height) { Shape shape = new Rectangle(x, y, width, height); @@ -1164,7 +1105,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Draws a rectangle with top-left corner placed at (x,y). */ - @Override public void drawRect(int x, int y, int width, int height) { Shape shape = new Rectangle(x, y, width, height); @@ -1175,7 +1115,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D * Clears a rectangle with top-left corner placed at (x,y) using the current * background color. */ - @Override public void clearRect(int x, int y, int width, int height) { Color originalColor = getColor(); @@ -1190,7 +1129,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Draws a rounded rectangle. */ - @Override public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) { @@ -1202,7 +1140,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Fills a rounded rectangle. */ - @Override public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) { @@ -1214,7 +1151,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Draws an oval. */ - @Override public void drawOval(int x, int y, int width, int height) { Shape shape = new Ellipse2D.Float(x, y, width, height); @@ -1224,7 +1160,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Fills an oval. */ - @Override public void fillOval(int x, int y, int width, int height) { Shape shape = new Ellipse2D.Float(x, y, width, height); @@ -1234,7 +1169,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Draws an arc. */ - @Override public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) { @@ -1246,7 +1180,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Fills an arc. */ - @Override public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) { @@ -1258,7 +1191,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Draws a polyline. */ - @Override public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints) { if (nPoints > 0) @@ -1276,7 +1208,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Draws a polygon made with the specified points. */ - @Override public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints) { Shape shape = new Polygon(xPoints, yPoints, nPoints); @@ -1286,7 +1217,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Draws a polygon. */ - @Override public void drawPolygon(Polygon p) { draw(p); @@ -1295,7 +1225,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Fills a polygon made with the specified points. */ - @Override public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) { Shape shape = new Polygon(xPoints, yPoints, nPoints); @@ -1305,7 +1234,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Fills a polygon. */ - @Override public void fillPolygon(Polygon p) { draw(p, "fill"); @@ -1314,7 +1242,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Draws the specified characters, starting from (x,y) */ - @Override public void drawChars(char[] data, int offset, int length, int x, int y) { String string = new String(data, offset, length); @@ -1324,7 +1251,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Draws the specified bytes, starting from (x,y) */ - @Override public void drawBytes(byte[] data, int offset, int length, int x, int y) { String string = new String(data, offset, length); @@ -1334,7 +1260,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Draws an image. */ - @Override public boolean drawImage(Image img, int x, int y, ImageObserver observer) { return drawImage(img, x, y, Color.white, observer); @@ -1343,7 +1268,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Draws an image. */ - @Override public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer) { @@ -1353,7 +1277,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Draws an image. */ - @Override public boolean drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer) { @@ -1365,7 +1288,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Draws an image. */ - @Override public boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer) { @@ -1376,7 +1298,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Draws an image. */ - @Override public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer) { @@ -1387,7 +1308,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Draws an image. */ - @Override public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer) @@ -1483,29 +1403,24 @@ public class EpsGraphics2D extends java.awt.Graphics2D * only remaining EpsGraphics2D instance pointing at a EpsDocument object, * then the EpsDocument object shall become eligible for garbage collection. */ - @Override public void dispose() { _document = null; } - /* bsoares 2019-03-20 - * finalize is now deprecated. Implementing AutoCloseable instead /** * Finalizes the object. - @Override + */ public void finalize() { super.finalize(); } - */ /** * Returns the entire contents of the EPS document, complete with headers and * bounding box. The returned String is suitable for being written directly to * disk as an EPS file. */ - @Override public String toString() { StringWriter writer = new StringWriter(); @@ -1525,7 +1440,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D * Returns true if the specified rectangular area might intersect the current * clipping area. */ - @Override public boolean hitClip(int x, int y, int width, int height) { if (_clip == null) @@ -1539,7 +1453,6 @@ public class EpsGraphics2D extends java.awt.Graphics2D /** * Returns the bounding rectangle of the current clipping area. */ - @Override public Rectangle getClipBounds(Rectangle r) { if (_clip == null)