From: amwaterhouse Date: Mon, 21 Mar 2005 09:55:42 +0000 (+0000) Subject: Created by jalview X-Git-Tag: Release_2_0~542 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=f139e72b51f3cb38994cc106130547eee94d2cd8;p=jalview.git Created by jalview --- diff --git a/src/org/jibble/epsgraphics/EpsDocument.java b/src/org/jibble/epsgraphics/EpsDocument.java index cae9835..56ad32f 100755 --- a/src/org/jibble/epsgraphics/EpsDocument.java +++ b/src/org/jibble/epsgraphics/EpsDocument.java @@ -1,4 +1,4 @@ -/* +/* Copyright Paul James Mutton, 2001-2004, http://www.jibble.org/ This file is part of EpsGraphics2D. @@ -26,11 +26,11 @@ import java.io.*; *

* Copyright Paul Mutton, * http://www.jibble.org/ - * + * */ public class EpsDocument { - - + + /** * Constructs an empty EpsDevice. */ @@ -43,7 +43,7 @@ public class EpsDocument { _stringWriter = new StringWriter(); _bufferedWriter = new BufferedWriter(_stringWriter); } - + /** * Constructs an empty EpsDevice that writes directly to a file. * Bounds must be set before use. @@ -57,16 +57,16 @@ public class EpsDocument { _bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream)); write(_bufferedWriter); } - - + + /** * Returns the title of the EPS document. */ public synchronized String getTitle() { return _title; } - - + + /** * Updates the bounds of the current EPS document. */ @@ -84,8 +84,8 @@ public class EpsDocument { minY = (float) y; } } - - + + /** * Appends a line to the EpsDocument. A new line character is added * to the end of the line when it is added. @@ -130,7 +130,7 @@ public class EpsDocument { } } _lastG = g; - + try { _bufferedWriter.write(line + "\n"); } @@ -138,8 +138,8 @@ public class EpsDocument { throw new EpsException("Could not write to the output file: " + e); } } - - + + /** * Outputs the contents of the EPS document to the specified * Writer, complete with headers and bounding box. @@ -147,9 +147,9 @@ public class EpsDocument { public synchronized void write(Writer writer) throws IOException { float offsetX = -minX; float offsetY = -minY; - + writer.write("%!PS-Adobe-3.0 EPSF-3.0\n"); - writer.write("%%Creator: EpsGraphics2D " + EpsGraphics2D.VERSION + " by Paul Mutton, http://www.jibble.org/\n"); + writer.write("%%Creator: Jalview " + jalview.bin.Cache.VERSION + " \n"); writer.write("%%Title: " + _title + "\n"); writer.write("%%CreationDate: " + new Date() + "\n"); writer.write("%%BoundingBox: 0 0 " + ((int) Math.ceil(maxX + offsetX)) + " " + ((int) Math.ceil(maxY + offsetY)) + "\n"); @@ -160,28 +160,28 @@ public class EpsDocument { writer.write("%%Pages: 1\n"); writer.write("%%Page: 1 1\n"); writer.write("%%EndComments\n\n"); - + writer.write("gsave\n"); - + if (_stringWriter != null) { writer.write(offsetX + " " + (offsetY) + " translate\n"); - + _bufferedWriter.flush(); StringBuffer buffer = _stringWriter.getBuffer(); for (int i = 0; i < buffer.length(); i++) { writer.write(buffer.charAt(i)); } - + writeFooter(writer); } else { writer.write(offsetX + " " + ((maxY - minY) - offsetY) + " translate\n"); } - + writer.flush(); } - - + + private void writeFooter(Writer writer) throws IOException { writer.write("grestore\n"); if (isClipSet()) { @@ -192,12 +192,12 @@ public class EpsDocument { writer.write("%%EOF"); writer.flush(); } - - + + public synchronized void flush() throws IOException { _bufferedWriter.flush(); } - + public synchronized void close() throws IOException { if (_stringWriter == null) { writeFooter(_bufferedWriter); @@ -205,31 +205,31 @@ public class EpsDocument { _bufferedWriter.close(); } } - - + + public boolean isClipSet() { return _isClipSet; } - + public void setClipSet(boolean isClipSet) { _isClipSet = isClipSet; } - - + + private float minX; private float minY; private float maxX; private float maxY; - + private boolean _isClipSet = false; private String _title; private StringWriter _stringWriter; private BufferedWriter _bufferedWriter = null; - + // We need to remember which was the last EpsGraphics2D object to use // us, as we need to replace the clipping region if another EpsGraphics2D // object tries to use us. private EpsGraphics2D _lastG = null; - -} \ No newline at end of file + +}