JAL-3438 spotless for 2.11.2.0
[jalview.git] / src / org / jibble / epsgraphics / EpsGraphics2D.java
old mode 100755 (executable)
new mode 100644 (file)
index 931f6dc..b8ac5bd
@@ -22,15 +22,55 @@ package org.jibble.epsgraphics;
 
 import jalview.util.MessageManager;
 
-import java.io.*;
-import java.text.*;
-import java.util.*;
-
-import java.awt.*;
-import java.awt.font.*;
-import java.awt.geom.*;
-import java.awt.image.*;
-import java.awt.image.renderable.*;
+import java.awt.AlphaComposite;
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Composite;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
+import java.awt.Image;
+import java.awt.Paint;
+import java.awt.Polygon;
+import java.awt.Rectangle;
+import java.awt.RenderingHints;
+import java.awt.Shape;
+import java.awt.Stroke;
+import java.awt.font.FontRenderContext;
+import java.awt.font.GlyphVector;
+import java.awt.font.TextAttribute;
+import java.awt.font.TextLayout;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Arc2D;
+import java.awt.geom.Area;
+import java.awt.geom.Ellipse2D;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.Line2D;
+import java.awt.geom.PathIterator;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.awt.geom.RoundRectangle2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.BufferedImageOp;
+import java.awt.image.ColorModel;
+import java.awt.image.ImageObserver;
+import java.awt.image.PixelGrabber;
+import java.awt.image.RenderedImage;
+import java.awt.image.WritableRaster;
+import java.awt.image.renderable.RenderableImage;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.StringWriter;
+import java.text.AttributedCharacterIterator;
+import java.text.AttributedString;
+import java.text.CharacterIterator;
+import java.util.Hashtable;
+import java.util.Map;
 
 /**
  * EpsGraphics2D is suitable for creating high quality EPS graphics for use in
@@ -74,11 +114,12 @@ import java.awt.image.renderable.*;
  * <p>
  * Not all methods are implemented yet. Those that are not are clearly labelled.
  * <p>
- * Copyright Paul Mutton, <a
- * href="http://www.jibble.org/">http://www.jibble.org/</a>
+ * Copyright Paul Mutton,
+ * <a href="http://www.jibble.org/">http://www.jibble.org/</a>
  * 
  */
 public class EpsGraphics2D extends java.awt.Graphics2D
+        implements AutoCloseable
 {
 
   public static final String VERSION = "0.8.8";
@@ -135,7 +176,8 @@ public class EpsGraphics2D extends java.awt.Graphics2D
           int minY, int maxX, int maxY) throws IOException
   {
     this(title);
-    _document = new EpsDocument(title, outputStream, minX, minY, maxX, maxY);
+    _document = new EpsDocument(title, outputStream, minX, minY, maxX,
+            maxY);
   }
 
   /**
@@ -163,7 +205,9 @@ public class EpsGraphics2D extends java.awt.Graphics2D
    */
   private void methodNotSupported()
   {
-    EpsException e = new EpsException(MessageManager.formatMessage("exception.eps_method_not_supported", new String[]{VERSION}));
+    EpsException e = new EpsException(MessageManager.formatMessage(
+            "exception.eps_method_not_supported", new String[]
+            { VERSION }));
     e.printStackTrace(System.err);
   }
 
@@ -209,6 +253,7 @@ 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();
@@ -361,7 +406,9 @@ public class EpsGraphics2D extends java.awt.Graphics2D
    * Draws a 3D rectangle outline. If it is raised, light appears to come from
    * the top left.
    */
-  public void draw3DRect(int x, int y, int width, int height, boolean raised)
+  @Override
+  public void draw3DRect(int x, int y, int width, int height,
+          boolean raised)
   {
     Color originalColor = getColor();
     Stroke originalStroke = getStroke();
@@ -400,7 +447,9 @@ 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.
    */
-  public void fill3DRect(int x, int y, int width, int height, boolean raised)
+  @Override
+  public void fill3DRect(int x, int y, int width, int height,
+          boolean raised)
   {
     Color originalColor = getColor();
 
@@ -420,6 +469,7 @@ public class EpsGraphics2D extends java.awt.Graphics2D
   /**
    * Draws a Shape on the EPS document.
    */
+  @Override
   public void draw(Shape s)
   {
     draw(s, "stroke");
@@ -428,6 +478,7 @@ public class EpsGraphics2D extends java.awt.Graphics2D
   /**
    * Draws an Image on the EPS document.
    */
+  @Override
   public boolean drawImage(Image img, AffineTransform xform,
           ImageObserver obs)
   {
@@ -441,6 +492,7 @@ 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);
@@ -450,6 +502,7 @@ 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();
@@ -461,10 +514,10 @@ public class EpsGraphics2D extends java.awt.Graphics2D
 
     ColorModel cm = img.getColorModel();
     WritableRaster wr = img.copyData(null);
-    BufferedImage img1 = new BufferedImage(cm, wr, cm
-            .isAlphaPremultiplied(), properties);
-    AffineTransform at = AffineTransform.getTranslateInstance(
-            img.getMinX(), img.getMinY());
+    BufferedImage img1 = new BufferedImage(cm, wr,
+            cm.isAlphaPremultiplied(), properties);
+    AffineTransform at = AffineTransform.getTranslateInstance(img.getMinX(),
+            img.getMinY());
     at.preConcatenate(xform);
     drawImage(img1, at, null);
   }
@@ -472,7 +525,9 @@ public class EpsGraphics2D extends java.awt.Graphics2D
   /**
    * Draws a RenderableImage by invoking its createDefaultRendering method.
    */
-  public void drawRenderableImage(RenderableImage img, AffineTransform xform)
+  @Override
+  public void drawRenderableImage(RenderableImage img,
+          AffineTransform xform)
   {
     drawRenderedImage(img.createDefaultRendering(), xform);
   }
@@ -480,6 +535,7 @@ 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);
@@ -488,6 +544,7 @@ 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)
@@ -502,6 +559,7 @@ 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);
@@ -511,14 +569,15 @@ 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)
   {
     if (getAccurateTextMode())
     {
       TextLayout layout = new TextLayout(iterator, getFontRenderContext());
-      Shape shape = layout.getOutline(AffineTransform.getTranslateInstance(
-              x, y));
+      Shape shape = layout
+              .getOutline(AffineTransform.getTranslateInstance(x, y));
       draw(shape, "fill");
     }
     else
@@ -527,8 +586,8 @@ public class EpsGraphics2D extends java.awt.Graphics2D
       Point2D location = transform(x, y);
       append(location.getX() + " " + location.getY() + " moveto");
       StringBuffer buffer = new StringBuffer();
-      for (char ch = iterator.first(); ch != CharacterIterator.DONE; ch = iterator
-              .next())
+      for (char ch = iterator
+              .first(); ch != CharacterIterator.DONE; ch = iterator.next())
       {
         if (ch == '(' || ch == ')')
         {
@@ -543,6 +602,7 @@ 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);
@@ -552,6 +612,7 @@ public class EpsGraphics2D extends java.awt.Graphics2D
   /**
    * Fills a Shape on the EPS document.
    */
+  @Override
   public void fill(Shape s)
   {
     draw(s, "fill");
@@ -561,6 +622,7 @@ 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);
@@ -569,6 +631,7 @@ public class EpsGraphics2D extends java.awt.Graphics2D
   /**
    * Returns the device configuration associated with this EpsGraphics2D object.
    */
+  @Override
   public GraphicsConfiguration getDeviceConfiguration()
   {
     GraphicsConfiguration gc = null;
@@ -591,6 +654,7 @@ 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;
@@ -600,6 +664,7 @@ 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;
@@ -613,6 +678,7 @@ 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)
@@ -647,6 +713,7 @@ 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.
@@ -656,6 +723,7 @@ 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;
@@ -664,6 +732,7 @@ public class EpsGraphics2D extends java.awt.Graphics2D
   /**
    * Sets the rendering hints. These are ignored by EpsGraphics2D.
    */
+  @Override
   public void setRenderingHints(Map hints)
   {
     // Do nothing.
@@ -672,6 +741,7 @@ public class EpsGraphics2D extends java.awt.Graphics2D
   /**
    * Adds rendering hints. These are ignored by EpsGraphics2D.
    */
+  @Override
   public void addRenderingHints(Map hints)
   {
     // Do nothing.
@@ -680,6 +750,7 @@ public class EpsGraphics2D extends java.awt.Graphics2D
   /**
    * Returns the preferences for the rendering algorithms.
    */
+  @Override
   public RenderingHints getRenderingHints()
   {
     return new RenderingHints(null);
@@ -689,6 +760,7 @@ 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);
@@ -698,6 +770,7 @@ 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));
@@ -706,6 +779,7 @@ 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);
@@ -715,6 +789,7 @@ 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));
@@ -724,6 +799,7 @@ 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));
@@ -732,6 +808,7 @@ 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));
@@ -741,6 +818,7 @@ 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);
@@ -750,6 +828,7 @@ 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)
@@ -768,6 +847,7 @@ public class EpsGraphics2D extends java.awt.Graphics2D
   /**
    * Gets the AffineTransform used by this EpsGraphics2D.
    */
+  @Override
   public AffineTransform getTransform()
   {
     return new AffineTransform(_transform);
@@ -776,6 +856,7 @@ public class EpsGraphics2D extends java.awt.Graphics2D
   /**
    * Returns the current Paint of the EpsGraphics2D object.
    */
+  @Override
   public Paint getPaint()
   {
     return _paint;
@@ -784,6 +865,7 @@ public class EpsGraphics2D extends java.awt.Graphics2D
   /**
    * returns the current Composite of the EpsGraphics2D object.
    */
+  @Override
   public Composite getComposite()
   {
     return _composite;
@@ -792,6 +874,7 @@ 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)
@@ -804,6 +887,7 @@ public class EpsGraphics2D extends java.awt.Graphics2D
   /**
    * Gets the background color that is used by the clearRect method.
    */
+  @Override
   public Color getBackground()
   {
     return _backgroundColor;
@@ -813,6 +897,7 @@ 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;
@@ -822,6 +907,7 @@ 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)
@@ -839,6 +925,7 @@ public class EpsGraphics2D extends java.awt.Graphics2D
   /**
    * Returns the FontRenderContext.
    */
+  @Override
   public FontRenderContext getFontRenderContext()
   {
     return _fontRenderContext;
@@ -849,6 +936,7 @@ 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);
@@ -858,6 +946,7 @@ 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();
@@ -870,6 +959,7 @@ 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;
@@ -878,6 +968,7 @@ 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)
@@ -893,6 +984,7 @@ 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.
@@ -902,6 +994,7 @@ public class EpsGraphics2D extends java.awt.Graphics2D
    * <b><i><font color="red">Not implemented</font></i></b> - performs no
    * action.
    */
+  @Override
   public void setXORMode(Color c1)
   {
     methodNotSupported();
@@ -910,6 +1003,7 @@ public class EpsGraphics2D extends java.awt.Graphics2D
   /**
    * Returns the Font currently being used.
    */
+  @Override
   public Font getFont()
   {
     return _font;
@@ -918,6 +1012,7 @@ 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)
@@ -925,13 +1020,14 @@ public class EpsGraphics2D extends java.awt.Graphics2D
       font = Font.decode(null);
     }
     _font = font;
-    append("/" + _font.getPSName() + " findfont " + ((int) _font.getSize())
+    append("/" + _font.getPSName() + " findfont " + (_font.getSize())
             + " scalefont setfont");
   }
 
   /**
    * Gets the font metrics of the current font.
    */
+  @Override
   public FontMetrics getFontMetrics()
   {
     return getFontMetrics(getFont());
@@ -940,6 +1036,7 @@ 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,
@@ -951,6 +1048,7 @@ public class EpsGraphics2D extends java.awt.Graphics2D
   /**
    * Returns the bounding rectangle of the current clipping area.
    */
+  @Override
   public Rectangle getClipBounds()
   {
     if (_clip == null)
@@ -964,6 +1062,7 @@ 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));
@@ -972,6 +1071,7 @@ 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));
@@ -980,6 +1080,7 @@ public class EpsGraphics2D extends java.awt.Graphics2D
   /**
    * Gets the current clipping area.
    */
+  @Override
   public Shape getClip()
   {
     if (_clip == null)
@@ -995,7 +1096,9 @@ public class EpsGraphics2D extends java.awt.Graphics2D
         return t.createTransformedShape(_clip);
       } catch (Exception e)
       {
-        throw new EpsException(MessageManager.formatMessage("exception.eps_unable_to_get_inverse_matrix", new String[]{_transform.toString()}));
+        throw new EpsException(MessageManager.formatMessage(
+                "exception.eps_unable_to_get_inverse_matrix", new String[]
+                { _transform.toString() }));
       }
     }
   }
@@ -1003,6 +1106,7 @@ 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)
@@ -1036,6 +1140,7 @@ public class EpsGraphics2D extends java.awt.Graphics2D
    * <b><i><font color="red">Not implemented</font></i></b> - performs no
    * action.
    */
+  @Override
   public void copyArea(int x, int y, int width, int height, int dx, int dy)
   {
     methodNotSupported();
@@ -1044,6 +1149,7 @@ 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);
@@ -1053,6 +1159,7 @@ 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);
@@ -1062,6 +1169,7 @@ 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);
@@ -1072,6 +1180,7 @@ 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();
@@ -1086,6 +1195,7 @@ 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)
   {
@@ -1097,6 +1207,7 @@ 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)
   {
@@ -1108,6 +1219,7 @@ 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);
@@ -1117,6 +1229,7 @@ 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);
@@ -1126,28 +1239,31 @@ 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)
   {
-    Shape shape = new Arc2D.Float(x, y, width, height, startAngle,
-            arcAngle, Arc2D.OPEN);
+    Shape shape = new Arc2D.Float(x, y, width, height, startAngle, arcAngle,
+            Arc2D.OPEN);
     draw(shape);
   }
 
   /**
    * Fills an arc.
    */
+  @Override
   public void fillArc(int x, int y, int width, int height, int startAngle,
           int arcAngle)
   {
-    Shape shape = new Arc2D.Float(x, y, width, height, startAngle,
-            arcAngle, Arc2D.PIE);
+    Shape shape = new Arc2D.Float(x, y, width, height, startAngle, arcAngle,
+            Arc2D.PIE);
     draw(shape, "fill");
   }
 
   /**
    * Draws a polyline.
    */
+  @Override
   public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
   {
     if (nPoints > 0)
@@ -1165,6 +1281,7 @@ 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);
@@ -1174,6 +1291,7 @@ public class EpsGraphics2D extends java.awt.Graphics2D
   /**
    * Draws a polygon.
    */
+  @Override
   public void drawPolygon(Polygon p)
   {
     draw(p);
@@ -1182,6 +1300,7 @@ 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);
@@ -1191,6 +1310,7 @@ public class EpsGraphics2D extends java.awt.Graphics2D
   /**
    * Fills a polygon.
    */
+  @Override
   public void fillPolygon(Polygon p)
   {
     draw(p, "fill");
@@ -1199,6 +1319,7 @@ 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);
@@ -1208,6 +1329,7 @@ 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);
@@ -1217,6 +1339,7 @@ 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);
@@ -1225,6 +1348,7 @@ 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)
   {
@@ -1234,6 +1358,7 @@ public class EpsGraphics2D extends java.awt.Graphics2D
   /**
    * Draws an image.
    */
+  @Override
   public boolean drawImage(Image img, int x, int y, Color bgcolor,
           ImageObserver observer)
   {
@@ -1245,6 +1370,7 @@ 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)
   {
@@ -1255,6 +1381,7 @@ 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)
   {
@@ -1265,6 +1392,7 @@ 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)
@@ -1313,7 +1441,9 @@ public class EpsGraphics2D extends java.awt.Graphics2D
       matrix = matrix.createInverse();
     } catch (Exception e)
     {
-        throw new EpsException(MessageManager.formatMessage("exception.eps_unable_to_get_inverse_matrix", new String[]{matrix.toString()}));
+      throw new EpsException(MessageManager.formatMessage(
+              "exception.eps_unable_to_get_inverse_matrix", new String[]
+              { matrix.toString() }));
     }
     matrix.scale(1, -1);
     matrix.getMatrix(m);
@@ -1333,9 +1463,9 @@ public class EpsGraphics2D extends java.awt.Graphics2D
       for (int x = 0; x < width; x++)
       {
         Color color = new Color(pixels[x + width * y]);
-        line.append(toHexString(color.getRed())
-                + toHexString(color.getGreen())
-                + toHexString(color.getBlue()));
+        line.append(
+                toHexString(color.getRed()) + toHexString(color.getGreen())
+                        + toHexString(color.getBlue()));
         if (line.length() > 64)
         {
           append(line.toString());
@@ -1358,24 +1488,29 @@ 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();
@@ -1395,6 +1530,7 @@ 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)
@@ -1408,6 +1544,7 @@ 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)