freehep-graphics2d-2.1.1/0000755012010301201030000000000011300042227016132 5ustar mascellanimascellanifreehep-graphics2d-2.1.1/src/0000755012010301201030000000000011300042227016721 5ustar mascellanimascellanifreehep-graphics2d-2.1.1/src/test/0000755012010301201030000000000011300042227017700 5ustar mascellanimascellanifreehep-graphics2d-2.1.1/src/test/java/0000755012010301201030000000000011300042227020621 5ustar mascellanimascellanifreehep-graphics2d-2.1.1/src/test/java/org/0000755012010301201030000000000011300042227021410 5ustar mascellanimascellanifreehep-graphics2d-2.1.1/src/test/java/org/freehep/0000755012010301201030000000000011300042227023026 5ustar mascellanimascellanifreehep-graphics2d-2.1.1/src/test/java/org/freehep/graphics2d/0000755012010301201030000000000011300042227025054 5ustar mascellanimascellanifreehep-graphics2d-2.1.1/src/test/java/org/freehep/graphics2d/font/0000755012010301201030000000000011300042227026022 5ustar mascellanimascellanifreehep-graphics2d-2.1.1/src/test/java/org/freehep/graphics2d/font/test/0000755012010301201030000000000011300042227027001 5ustar mascellanimascellanifreehep-graphics2d-2.1.1/src/test/java/org/freehep/graphics2d/font/test/TestLookup.java0000644012010301201030000000341010466735775032010 0ustar mascellanimascellani// Copyright 2005, FreeHEP. package org.freehep.graphics2d.font.test; import org.freehep.graphics2d.font.CharTable; import org.freehep.graphics2d.font.Lookup; /** * Test class to test the generated Encoding Tables. * * @author Sami Lama * @version $Id: TestLookup.java 8584 2006-08-10 23:06:37Z duns $ */ public class TestLookup { public static void main(String[] args) { Lookup lookAtIt = null; CharTable aTable = null; lookAtIt = Lookup.getInstance(); aTable = lookAtIt.getTable("PDFLatin"); for (int i = 0; i < 256; i++) { System.out.println(aTable.toName(i)); } aTable = lookAtIt.getTable("STDLatin"); for (int i = 0; i < 256; i++) { System.out.println(aTable.toName(i)); } aTable = lookAtIt.getTable("MACLatin"); for (int i = 0; i < 256; i++) { System.out.println(aTable.toName(i)); } aTable = lookAtIt.getTable("WINLatin"); for (int i = 0; i < 256; i++) { System.out.println(aTable.toName(i)); } aTable = lookAtIt.getTable("ISOLatin"); for (int i = 0; i < 256; i++) { System.out.println(aTable.toName(i)); } aTable = lookAtIt.getTable("Symbol"); for (int i = 0; i < 256; i++) { System.out.println(aTable.toName(i)); } aTable = lookAtIt.getTable("ZapfDingbats"); for (int i = 0; i < 256; i++) { System.out.println(aTable.toName(i)); } aTable = lookAtIt.getTable("Expert"); for (int i = 0; i < 256; i++) { System.out.println(aTable.toName(i)); } System.out.println(aTable.toEncoding("Aacutesmall")); System.out.println(lookAtIt.toName('\uF8E8')); } }freehep-graphics2d-2.1.1/src/test/java/org/freehep/graphics2d/font/test/package.html0000644012010301201030000000006210470545640031276 0ustar mascellanimascellani Tests for the font encoding tables. freehep-graphics2d-2.1.1/src/test/java/org/freehep/graphics2d/test/0000755012010301201030000000000011300042227026033 5ustar mascellanimascellanifreehep-graphics2d-2.1.1/src/test/java/org/freehep/graphics2d/test/TestPerformance.java0000644012010301201030000001011510466735775032032 0ustar mascellanimascellani// University of California, Santa Cruz, USA and // CERN, Geneva, Switzerland, Copyright (c) 2000 package org.freehep.graphics2d.test; import java.awt.Color; import java.awt.Dimension; import java.awt.Insets; import javax.swing.JFrame; import org.freehep.graphics2d.BufferedPanel; import org.freehep.graphics2d.VectorGraphics; /** * @author Mark Donszelmann * @version $Id: TestPerformance.java 8584 2006-08-10 23:06:37Z duns $ */ public class TestPerformance extends BufferedPanel { private static final int n = 100; private static final int m = 50; private int[][] xip = new int[n][m]; private int[][] yip = new int[n][m]; private double[][] xdp = new double[n][m]; private double[][] ydp = new double[n][m]; private double[] xs = new double[n]; private double[] ys = new double[n]; public void paintComponent(VectorGraphics g) { Dimension dim = getSize(); Insets insets = getInsets(); int width = dim.width; int height = dim.height; for (int i = 0; i < xip.length; i++) { for (int j = 0; j < xip[0].length; j++) { xip[i][j] = (int) (Math.random() * width); yip[i][j] = (int) (Math.random() * height); } } for (int i = 0; i < xdp.length; i++) { for (int j = 0; j < xdp[0].length; j++) { xdp[i][j] = Math.random() * width; ydp[i][j] = Math.random() * height; } } for (int i = 0; i < xs.length; i++) { xs[i] = Math.random() * width; ys[i] = Math.random() * height; } System.out.print("Waiting 4 seconds... "); try { Thread.sleep(4000); } catch (InterruptedException e) { } System.out.println("done"); // g.setLineWidth(1.5); g.setColor(Color.black); g.fillRect(insets.left, insets.top, dim.width - insets.left - insets.right, dim.height - insets.top - insets.bottom); g.setColor(Color.orange); drawIntPolylines(g); g.setColor(Color.cyan); drawDoublePolylines(g); g.setColor(Color.red); // drawSymbols(g, VectorGraphicsConstants.SYMBOL_STAR, false); g.setColor(Color.blue); // drawSymbols(g, VectorGraphicsConstants.SYMBOL_CIRCLE, true); } public void drawIntPolylines(VectorGraphics g) { long start, end; start = System.currentTimeMillis(); for (int i = 0; i < xip.length; i++) { g.drawPolyline(xip[i], yip[i], xip[i].length); } end = System.currentTimeMillis(); System.out.println("VG2D:" + xip.length + " IntPolys[" + xip[0].length + "] " + (end - start) + " ms"); } public void drawDoublePolylines(VectorGraphics g) { long start, end; start = System.currentTimeMillis(); for (int i = 0; i < xdp.length; i++) { g.drawPolyline(xdp[i], ydp[i], xdp[i].length); } end = System.currentTimeMillis(); System.out.println("VG2D:" + xdp.length + " DoublePolys[" + xdp[0].length + "] " + (end - start) + " ms"); } public void drawSymbols(VectorGraphics g, int type, boolean fill) { long start = System.currentTimeMillis(); for (int i = 0; i < xs.length; i++) { if (fill) { g.fillSymbol(xs[i], ys[i], 6, type); } else { g.drawSymbol(xs[i], ys[i], 6, type); } } long end = System.currentTimeMillis(); System.out.println("VG2D:" + xs.length + " symbols[" + type + "] " + (end - start) + " ms"); } public static void main(String[] args) { // Create a new frame to hold everything. JFrame frame = new JFrame("Test PixelGraphics2D Performance"); // Create a new instance of this class and add it to the frame. frame.getContentPane().add(new TestPerformance()); // Give the frame a size and make it visible. frame.setSize(new Dimension(1024, 768)); frame.setVisible(true); } } freehep-graphics2d-2.1.1/src/test/resources/0000755012010301201030000000000011300042227021712 5ustar mascellanimascellanifreehep-graphics2d-2.1.1/src/test/resources/org/0000755012010301201030000000000011300042227022501 5ustar mascellanimascellanifreehep-graphics2d-2.1.1/src/test/resources/org/freehep/0000755012010301201030000000000011300042227024117 5ustar mascellanimascellanifreehep-graphics2d-2.1.1/src/test/resources/org/freehep/graphics2d/0000755012010301201030000000000011300042227026145 5ustar mascellanimascellanifreehep-graphics2d-2.1.1/src/test/resources/org/freehep/graphics2d/test/0000755012010301201030000000000011300042227027124 5ustar mascellanimascellanifreehep-graphics2d-2.1.1/src/test/resources/org/freehep/graphics2d/test/TestPerformance.ois0000644012010301201030000000157010341714743032761 0ustar mascellanimascellanined!Wnetscape.util.HashtableDkeysHelementsTnetscape.util.VectorEarrayPjava.lang.StringEvalue  !"$'#%&#VextraProgramParametersKopenConsoleHhostnameJportNumberUdisableMemoryProfilerJappletPathTautoStartCPUProfilerSextraJavaParametersIAppletCWDWpauseProgramAfterLaunchFVMPropNApplicationCWDKprogramTypeIclasspathLvmCannotExitJsourcepathNenableAuditAPIPapplicationClassAtIlocalhostD1470AfGruntimeEauditJJITEnabledGdefaultCjniDTRUENc:\cvs\freehepKapplicationA.rC:\java\jdk1.4.2\javasrc\j2se\src\windows\classes\pC:\java\jdk1.4.2\javasrc\j2se\src\share\classes\korg.freehep.graphics2d.test.TestPerformance(      !"freehep-graphics2d-2.1.1/src/site/0000755012010301201030000000000011300042227017665 5ustar mascellanimascellanifreehep-graphics2d-2.1.1/src/site/site.xml0000644012010301201030000000174710536063277021406 0ustar mascellanimascellani FreeHEP Graphics2D http://java.freehep.org/mvn/freehep-graphics2d FreeHEP http://java.freehep.org/images/sm-freehep.gif http://java.freehep.org/ freehep-graphics2d-2.1.1/src/site/apt/0000755012010301201030000000000011300042227020451 5ustar mascellanimascellanifreehep-graphics2d-2.1.1/src/main/0000755012010301201030000000000011300042227017645 5ustar mascellanimascellanifreehep-graphics2d-2.1.1/src/main/java/0000755012010301201030000000000011300042227020566 5ustar mascellanimascellanifreehep-graphics2d-2.1.1/src/main/java/org/0000755012010301201030000000000011300042227021355 5ustar mascellanimascellanifreehep-graphics2d-2.1.1/src/main/java/org/freehep/0000755012010301201030000000000011300042227022773 5ustar mascellanimascellanifreehep-graphics2d-2.1.1/src/main/java/org/freehep/graphics2d/0000755012010301201030000000000011300042227025021 5ustar mascellanimascellanifreehep-graphics2d-2.1.1/src/main/java/org/freehep/graphics2d/VectorGraphics.java0000644012010301201030000005001310547553217030630 0ustar mascellanimascellani// Copyright 2000-2007, FreeHEP. package org.freehep.graphics2d; import java.awt.AlphaComposite; import java.awt.Color; import java.awt.Composite; import java.awt.Dimension; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.GraphicsConfiguration; import java.awt.Image; import java.awt.Paint; 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.geom.AffineTransform; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.awt.image.BufferedImageOp; import java.awt.image.ImageObserver; import java.awt.image.RenderedImage; import java.awt.image.renderable.RenderableImage; import java.text.AttributedCharacterIterator; import java.util.Hashtable; import java.util.Map; import java.util.Properties; /** * The drawing methods which are guaranteed to work for the various output * formats of the VectorGraphics system on the Java 2 platform. All methods are * re-declared abstract, since this class inherits from Graphics2D and we would * not want to actually or accidentally use any of those methods, except for the * ones noted. * * Some int methods need to call their super.methods otherwise the compiler * cannot make a distinction if it needs to convert int to doubles or call the * super int method. * * Note that many of these routines modify the current transformation matrix. To * guard against unintended side effects the following method should be used: * *

 *  Graphics2D tempGraphics = (Graphics2D) originalGraphics.create();
 *  tempGraphics.setStroke(originalGraphics.getStroke());
 *  tempGraphics.rotate(...);
 *  tempGraphics.translate(...);
 *  ...drawing methods on tempGraphics...
 *  tempGraphics.dispose();
 * 
* * where originalGraphics is the original Graphics2D * object. Note that dispose must be called when the drawing * finishes on tempGraphics and that no drawing should be done on * originalGraphics until dispose has been called. * * @author Charles Loomis * @author Mark Donszelmann * @version $Id: VectorGraphics.java 10258 2007-01-05 22:51:59Z duns $ */ public abstract class VectorGraphics extends Graphics2D implements VectorGraphicsConstants { public abstract void setProperties(Properties newProperties); protected abstract void initProperties(Properties defaults); protected abstract Properties getProperties(); public abstract String getProperty(String key); public abstract Color getPropertyColor(String key); public abstract Rectangle getPropertyRectangle(String key); public abstract Dimension getPropertyDimension(String key); public abstract int getPropertyInt(String key); public abstract double getPropertyDouble(String key); public abstract boolean isProperty(String key); // // // Methods defined in java.awt.Graphics (alphabetical) // // public abstract void clearRect(int x, int y, int width, int height); public abstract void clipRect(int x, int y, int width, int height); public abstract void copyArea(int x, int y, int width, int height, int dx, int dy); public abstract Graphics create(); // NOTE: implemented in Graphics, must be implemented here otherwise the // compiler // cannot choose between converting ints to doubles or calling the // superclass. public Graphics create(int x, int y, int width, int height) { return super.create(x, y, width, height); } public abstract void dispose(); // NOTE: implemented in Graphics // public abstract void draw3DRect(int x, int y, // int width, int height, // boolean raised); public abstract void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle); // NOTE: implemented in Graphics // public abstract void drawBytes(byte[] data, int offset, // int length, // int x, int y); // NOTE: implemented in Graphics // public abstract void drawChars(char[] data, int offset, // int length, // int x, int y); public abstract boolean drawImage(Image image, int x, int y, ImageObserver observer); public abstract boolean drawImage(Image image, int x, int y, int width, int height, ImageObserver observer); public abstract boolean drawImage(Image image, int x, int y, Color bgColor, ImageObserver observer); public abstract boolean drawImage(Image image, int x, int y, int width, int height, Color bgColor, ImageObserver observer); public abstract boolean drawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer); public abstract boolean drawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgColor, ImageObserver observer); public abstract void drawLine(int x1, int y1, int x2, int y2); public abstract void drawOval(int x, int y, int width, int height); public abstract void drawPolygon(int[] xPoints, int[] yPoints, int nPoints); // NOTE implemented in Graphics // public abstract void drawPolygon(Polygon p); public abstract void drawPolyline(int[] xPoints, int[] yPoints, int nPoints); public abstract void drawRect(int x, int y, int width, int height); public abstract void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight); public abstract void drawString(AttributedCharacterIterator iterator, int x, int y); public abstract void drawString(String str, int x, int y); // NOTE: implemented in Graphics // public abstract void fill3DRect(int x, int y, // int width, int height, // boolean raised); public abstract void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle); public abstract void fillOval(int x, int y, int width, int height); public abstract void fillPolygon(int[] xPoints, int[] yPoints, int nPoints); // NOTE: implemented in Graphics // public abstract void fillPolygon(Polygon p); public abstract void fillRect(int x, int y, int width, int height); public abstract void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight); // NOTE: implemented in Graphics // public abstract void finalize(); public abstract Shape getClip(); public abstract Rectangle getClipBounds(); public abstract Rectangle getClipBounds(Rectangle r); // NOTE: implemented in Graphics // public abstract Rectangle getClipRect(); public abstract Color getColor(); public abstract Font getFont(); // NOTE: implemented in Graphics // public abstract FontMetrics getFontMetrics(); public abstract FontMetrics getFontMetrics(Font font); // NOTE: implemented in Graphics // public abstract boolean hitClip(int x, int y, int width, int height); public abstract void setClip(int x, int y, int width, int height); public abstract void setClip(Shape clip); public abstract void setColor(Color c); public abstract void setFont(Font font); public abstract void setPaintMode(); public abstract void setXORMode(Color c1); public abstract String toString(); public abstract void translate(int x, int y); // // // Methods from java.awt.Graphics2D (alphabetical) // // public abstract void addRenderingHints(Map hints); public abstract void clip(Shape s); public abstract void draw(Shape s); // NOTE: overridden in Graphics2D // public abstract void draw3DRect(int x, int y, int width, int height, // boolean raised); public abstract void drawGlyphVector(GlyphVector g, float x, float y); public abstract void drawImage(BufferedImage img, BufferedImageOp op, int x, int y); public abstract boolean drawImage(Image img, AffineTransform xform, ImageObserver obs); public abstract void drawRenderableImage(RenderableImage img, AffineTransform xform); public abstract void drawRenderedImage(RenderedImage img, AffineTransform xform); public abstract void drawString(AttributedCharacterIterator iterator, float x, float y); // NOTE: overridden in Graphics2D // public abstract void drawString(AttributedCharacterIterator iterator, int // x, int y); // NOTE: redefined in Graphics2D // public abstract void drawString(String str, int x, int y); public abstract void drawString(String str, float x, float y); public abstract void fill(Shape s); /** * Fills an are with the given paint using in offscreen BufferedImage. * Used for drawing GradientPaint or image * @param shape Shape usede as clipping area * @param paint Paint used */ protected void fill(Shape shape, Paint paint) { Rectangle2D bounds = shape.getBounds2D(); // create image BufferedImage image = new BufferedImage( (int)Math.ceil(bounds.getWidth()) + 1, (int)Math.ceil(bounds.getHeight()) + 1, BufferedImage.TYPE_INT_ARGB); // fill background Graphics2D graphics = image.createGraphics(); graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR, 0.0f)); graphics.fill(graphics.getDeviceConfiguration().getBounds()); graphics.setComposite(AlphaComposite.SrcOver); // draw paint graphics.setPaint(paint); graphics.translate(- bounds.getMinX(), - bounds.getMinY()); graphics.fill(shape); graphics.dispose(); // draw image Shape clip = getClip(); clip(shape); drawImage(image, (int)bounds.getX(), (int)bounds.getY(), null); setClip(clip); } // NOTE: overridden in Graphics2D // public abstract void fill3DRect(int x, int y, // int width, int height, // boolean raised); public abstract Color getBackground(); public abstract Composite getComposite(); public abstract GraphicsConfiguration getDeviceConfiguration(); public abstract FontRenderContext getFontRenderContext(); public abstract Paint getPaint(); public abstract Object getRenderingHint(RenderingHints.Key inteKey); public abstract RenderingHints getRenderingHints(); public abstract Stroke getStroke(); public abstract AffineTransform getTransform(); public abstract boolean hit(Rectangle rect, Shape s, boolean onStroke); public abstract void rotate(double theta); public abstract void rotate(double theta, double x, double y); public abstract void scale(double sx, double sy); public abstract void setBackground(Color color); public abstract void setComposite(Composite comp); public abstract void setPaint(Paint paint); public abstract void setRenderingHint(RenderingHints.Key hintKey, Object hintValue); public abstract void setRenderingHints(Map hints); public abstract void setStroke(Stroke s); public abstract void setTransform(AffineTransform xform); public abstract void shear(double shx, double shy); public abstract void transform(AffineTransform xform); public abstract void translate(double tx, double ty); // NOTE: redefines in Graphics2D // public abstract void translate(int x, int y); /* * ===================================================================================== * * Methods added to VectorGraphics (alphabetical) * * ===================================================================================== */ public abstract void clearRect(double x, double y, double width, double height); public abstract void clipRect(double x, double y, double width, double height); public abstract Graphics create(double x, double y, double width, double height); /** * Draws an arc. Uses Arc2D to call draw(Shape). * */ public abstract void drawArc(double x, double y, double width, double height, double startAngle, double arcAngle); /** * Draws a straight line. Uses Line2D to call draw(Shape). * */ public abstract void drawLine(double x1, double y1, double x2, double y2); /** * Draws an oval. Uses Ellipse2D to call draw(Shape). * */ public abstract void drawOval(double x, double y, double width, double height); /** * Draws a polygon. Uses createShape(...) to call draw(Shape). * */ public abstract void drawPolygon(double[] xPoints, double[] yPoints, int nPoints); /** * Draws a polyline. Uses createShape(...) to call draw(Shape). * */ public abstract void drawPolyline(double[] xPoints, double[] yPoints, int nPoints); /** * Draws a rectangle. Uses Rectangle2D to call draw(Shape). * */ public abstract void drawRect(double x, double y, double width, double height); /** * Draws a rounded rectangle. Uses RoundRectangle2D to call draw(Shape). * */ public abstract void drawRoundRect(double x, double y, double width, double height, double arcWidth, double arcHeight); public abstract void drawSymbol(int x, int y, int size, int symbol); public abstract void drawSymbol(double x, double y, double size, int symbol); public abstract void fillSymbol(int x, int y, int size, int symbol); public abstract void fillSymbol(double x, double y, double size, int symbol); public abstract void fillAndDrawSymbol(int x, int y, int size, int symbol, Color fillColor); public abstract void fillAndDrawSymbol(double x, double y, double size, int symbol, Color fillColor); /** * Draws a string. * */ public abstract void drawString(String str, double x, double y); public abstract void drawString(TagString str, double x, double y); public abstract void drawString(String str, double x, double y, int horizontal, int vertical); public abstract void drawString(TagString str, double x, double y, int horizontal, int vertical); /** * Draws a string with a lot of parameters. * * @param str text to be drawn * @param x coordinate to draw string * @param y coordinate to draw string * @param horizontal alignment of the text * @param vertical alignment of the text * @param framed true if text is surrounded by a frame * @param frameColor color of the frame * @param frameWidth witdh of the frame * @param banner true if the frame is filled by a banner * @param bannerColor color of the banner */ public abstract void drawString(String str, double x, double y, int horizontal, int vertical, boolean framed, Color frameColor, double frameWidth, boolean banner, Color bannerColor); /** * Draws a TagString with a lot of parameters. * * @param str Tagged text to be drawn * @param x coordinate to draw string * @param y coordinate to draw string * @param horizontal alignment of the text * @param vertical alignment of the text * @param framed true if text is surrounded by a frame * @param frameColor color of the frame * @param frameWidth witdh of the frame * @param banner true if the frame is filled by a banner * @param bannerColor color of the banner */ public abstract void drawString(TagString str, double x, double y, int horizontal, int vertical, boolean framed, Color frameColor, double frameWidth, boolean banner, Color bannerColor); public abstract void endExport(); public abstract void fillAndDraw(Shape s, Color fillColor); /** * Fills an arc. Uses Arc2D to call fill(Shape). * */ public abstract void fillArc(double x, double y, double width, double height, double startAngle, double arcAngle); /** * Fills an oval. Uses Ellipse2D to call fill(Shape). * */ public abstract void fillOval(double x, double y, double width, double height); /** * Fills a polygon. Uses createShape(...) to call fill(Shape). * */ public abstract void fillPolygon(double[] xPoints, double[] yPoints, int nPoints); /** * Fills a rectangle. Uses Rectangle2D to call fill(Shape). * */ public abstract void fillRect(double x, double y, double width, double height); /** * Fills a rounded rectangle. Uses RoundRectangle2D to call fill(Shape). * */ public abstract void fillRoundRect(double x, double y, double width, double height, double arcWidth, double arcHeight); public abstract int getColorMode(); public abstract String getCreator(); public abstract boolean isDeviceIndependent(); public abstract void printComment(String comment); public abstract void setClip(double x, double y, double width, double height); public abstract void setColorMode(int colorMode); public abstract void setCreator(String creator); public abstract void setDeviceIndependent(boolean isDeviceIndependent); public abstract void setLineWidth(int width); public abstract void setLineWidth(double width); public abstract void startExport(); // STATIC stuff below public static VectorGraphics create(Graphics g) { if ((g != null) && !(g instanceof VectorGraphics)) { return new PixelGraphics2D(g); } return (VectorGraphics) g; } // STATIC stuff below private static Hashtable symbols = new Hashtable(15); static { symbols.put("vline", new Integer(SYMBOL_VLINE)); symbols.put("hline", new Integer(SYMBOL_HLINE)); symbols.put("plus", new Integer(SYMBOL_PLUS)); symbols.put("cross", new Integer(SYMBOL_CROSS)); symbols.put("star", new Integer(SYMBOL_STAR)); symbols.put("circle", new Integer(SYMBOL_CIRCLE)); symbols.put("box", new Integer(SYMBOL_BOX)); symbols.put("up_triangle", new Integer(SYMBOL_UP_TRIANGLE)); symbols.put("dn_triangle", new Integer(SYMBOL_DN_TRIANGLE)); symbols.put("diamond", new Integer(SYMBOL_DIAMOND)); } private static Hashtable alignments = new Hashtable(6); static { alignments.put("baseline", new Integer(TEXT_BASELINE)); alignments.put("left", new Integer(TEXT_LEFT)); alignments.put("top", new Integer(TEXT_TOP)); alignments.put("middle", new Integer(TEXT_CENTER)); alignments.put("center", new Integer(TEXT_CENTER)); alignments.put("right", new Integer(TEXT_RIGHT)); alignments.put("bottom", new Integer(TEXT_BOTTOM)); } public static int getTextAlignment(String name) { Integer i = (Integer) alignments.get(name.toLowerCase()); return (i != null) ? i.intValue() : TEXT_CENTER; } public static int getSymbol(String name) { Integer i = (Integer) symbols.get(name.toLowerCase()); return (i != null) ? i.intValue() : SYMBOL_PLUS; } public static double getYalignment(double y, double ascent, double descent, int alignment) { // vertical alignment switch (alignment) { case TEXT_TOP: y = y + ascent - descent; break; case TEXT_CENTER: y = y + ((ascent + descent) / 2) - descent; break; case TEXT_BOTTOM: y = y - descent; break; case TEXT_BASELINE: default: break; } return y; } public static double getXalignment(double x, double width, int alignment) { // horizontal alignment switch (alignment) { case TEXT_CENTER: x = x - (width / 2); break; case TEXT_RIGHT: x = x - width; break; case TEXT_LEFT: default: break; } return x; } } freehep-graphics2d-2.1.1/src/main/java/org/freehep/graphics2d/WebColor.java0000644012010301201030000000551410466735775027442 0ustar mascellanimascellani// Copyright 2002, FreeHEP. package org.freehep.graphics2d; import java.awt.Color; /** * WebColor which adheres to the web color set consisting of 216 equally spaced * colors, which include black and white. The spacing is 0x33, which makes the * smallest value 0x00 and the largest 0xFF. These colors are guaranteed to work * in browsers without dithering. WebColors are opaque. * * @author Mark Donszelmann * @version $Id: WebColor.java 8584 2006-08-10 23:06:37Z duns $ */ public class WebColor extends Color { private final static int space = 0x33; private final static int space2 = space / 2; // redefine all java colors in terms of WebColors public final static WebColor white = new WebColor(Color.WHITE); public final static WebColor WHITE = white; public final static WebColor lightGray = new WebColor(Color.LIGHT_GRAY); public final static WebColor LIGHT_GRAY = lightGray; public final static WebColor gray = new WebColor(Color.GRAY); public final static WebColor GRAY = gray; public final static WebColor darkGray = new WebColor(Color.DARK_GRAY); public final static WebColor DARK_GRAY = darkGray; public final static WebColor black = new WebColor(Color.BLACK); public final static WebColor BLACK = black; public final static WebColor red = new WebColor(Color.RED); public final static WebColor RED = red; public final static WebColor pink = new WebColor(Color.PINK); public final static WebColor PINK = pink; public final static WebColor orange = new WebColor(Color.ORANGE); public final static WebColor ORANGE = orange; public final static WebColor yellow = new WebColor(Color.YELLOW); public final static WebColor YELLOW = yellow; public final static WebColor green = new WebColor(Color.GREEN); public final static WebColor GREEN = green; public final static WebColor magenta = new WebColor(Color.MAGENTA); public final static WebColor MAGENTA = magenta; public final static WebColor cyan = new WebColor(Color.CYAN); public final static WebColor CYAN = cyan; public final static WebColor blue = new WebColor(Color.BLUE); public final static WebColor BLUE = blue; public WebColor(int red, int green, int blue) { super(((red + space2) / space) * space, ((green + space2) / space) * space, ((blue + space2) / space) * space); } public WebColor(Color color) { this(color.getRed(), color.getGreen(), color.getBlue()); } public WebColor(float red, float green, float blue) { this((int) (red * 255), (int) (green * 255), (int) (blue * 255)); } public static WebColor create(Color color) { if (color == null) return null; if (color instanceof WebColor) return (WebColor) color; return new WebColor(color); } } freehep-graphics2d-2.1.1/src/main/java/org/freehep/graphics2d/TagHandler.java0000644012010301201030000001162710466735775027741 0ustar mascellanimascellani// Copyright 2000, CERN, Geneva, Switzerland and University of Santa Cruz, California, U.S.A. package org.freehep.graphics2d; /** * * @author Mark Donszelmann * @version $Id: TagHandler.java 8584 2006-08-10 23:06:37Z duns $ */ public class TagHandler { public TagHandler() { } /** * parses string and calls methods for every tag and every not recognized * entity The characters < and > have to be written as < and > while * the & is written as & * * The following three methods are called: defaultEntity(entity) for & * < > " ' entity(entity) for all other entities * openTag(tag) for all endTag(tag) for all text(text) for * all text * * The startTag, endTag and text methods returns a string which is added to * the fully parsed string. * * Strings returned from the entity methods will show up in the text methods * parameter. * * It returns the fully parsed string, including any additions made by the * three methods above. */ public String parse(TagString string) { String src = string.toString(); StringBuffer parsedString = new StringBuffer(); StringBuffer textString = new StringBuffer(); int i = 0; int p = 0; try { while (i < src.length()) { switch (src.charAt(i)) { case '&': // handle entities // look for closing ';' i++; p = i; while (src.charAt(i) != ';') { i++; } String ent = src.substring(p, i); if (ent.equals("amp") || ent.equals("gt") || ent.equals("lt") || ent.equals("quot") || ent.equals("apos")) { textString.append(defaultEntity(ent)); } else { textString.append(entity(ent)); } break; case '<': // handle tags // handle any outstanding text if (textString.length() > 0) { parsedString.append(text(textString.toString())); textString = new StringBuffer(); } // look for closing '>' i++; p = i; while (src.charAt(i) != '>') { i++; } if (src.charAt(p) == '/') { parsedString.append(closeTag(src.substring(p + 1, i))); } else { parsedString.append(openTag(src.substring(p, i))); } break; default: // just move the pointer textString.append(src.charAt(i)); break; } // switch i++; } // while } catch (ArrayIndexOutOfBoundsException aoobe) { // just abort, but give most of the string parsedString.append("!PARSEERROR!"); } // final part if (textString.length() > 0) { parsedString.append(text(textString.toString())); } return parsedString.toString(); } protected String defaultEntity(String entity) { StringBuffer dst = new StringBuffer(); if (entity.equals("amp")) { dst.append('&'); } else if (entity.equals("gt")) { dst.append('>'); } else if (entity.equals("lt")) { dst.append('<'); } else if (entity.equals("quot")) { dst.append('"'); } else if (entity.equals("apos")) { dst.append('\''); } return dst.toString(); } protected String entity(String entity) { StringBuffer dst = new StringBuffer(); dst.append('&'); dst.append(entity); dst.append(';'); return dst.toString(); } protected String openTag(String tag) { StringBuffer dst = new StringBuffer(); dst.append('<'); dst.append(tag); dst.append('>'); return dst.toString(); } protected String closeTag(String tag) { StringBuffer dst = new StringBuffer(); dst.append("'); return dst.toString(); } protected String text(String text) { return text; } public static void main(String[] args) { String text = "<VectorGraphics & CardAdapter>"; TagString s = new TagString(text); TagHandler handler = new TagHandler(); System.out.println("\"" + s + "\""); System.out.println(handler.parse(s)); } } freehep-graphics2d-2.1.1/src/main/java/org/freehep/graphics2d/font/0000755012010301201030000000000011300042227025767 5ustar mascellanimascellanifreehep-graphics2d-2.1.1/src/main/java/org/freehep/graphics2d/font/Lookup.java0000644012010301201030000000620510466735775030143 0ustar mascellanimascellani//Copyright 2001-2005 FreeHEP. package org.freehep.graphics2d.font; /** * Lookup class provides conversion between different encodings and character * tables using character name, encoding index, and unicode. In order to add new * tables original code should be modified. * * @author Sami Kama * @version $Id: Lookup.java 8584 2006-08-10 23:06:37Z duns $ */ public class Lookup { private static Lookup instance; private CharTable[] tables; public static Lookup getInstance() { if (instance == null) { instance = new Lookup(); } return (instance); } private int ntables = 8; private Lookup() { tables = new CharTable[ntables]; tables[0] = new Symbol(); tables[1] = new Expert(); tables[2] = new Zapfdingbats(); tables[3] = new STDLatin(); tables[4] = new MACLatin(); tables[5] = new WINLatin(); tables[6] = new PDFLatin(); tables[7] = new ISOLatin(); } /** * Converts a name to unicode. This method takes name of the character and * returns character as a unicode character. * * @return requested unicode character. */ public char toUnicode(String name) { for (int i = 0; i < ntables; i++) { char uc = tables[i].toUnicode(name); if (uc != '\uffff') return (uc); } return ('\uffff'); } /** * Converts a unicode character to name. * * @return requested character name. */ public String toName(char uc) { for (int i = 0; i < ntables; i++) { String name = tables[i].toName(uc); if (name != null) return (name); } return (null); } /** * Converts a unicode character to name. * * @return requested character name. */ public String toName(Character uc) { for (int i = 0; i < ntables; i++) { String name = tables[i].toName(uc); if (name != null) return (name); } return (null); } /** * Gives the requested encoding table Valid table names can be requested * with a call to * * @see #getTableNames(). * * @return requested encoding. */ public CharTable getTable(String tableName) { for (int i = 0; i < ntables; i++) { String tblName = tables[i].getEncoding() + tables[i].getName(); if (tblName.equalsIgnoreCase(tableName)) return (tables[i]); } return (null); } /** * Gives the total number of tables included in the file * * @return number of tables */ public int getNumberOfTables() { return (ntables); } /** * Gives the names of tables that can be used in a string array. * * @return An array of String[] containing the table names */ public String[] getTableNames() { String[] tblnames = new String[ntables]; for (int i = 0; i < ntables; i++) { tblnames[i] = tables[i].getEncoding() + tables[i].getName(); } return tblnames; } }freehep-graphics2d-2.1.1/src/main/java/org/freehep/graphics2d/font/AbstractCharTable.java0000644012010301201030000000171510466735775032204 0ustar mascellanimascellani//Copyright 2001-2005 FreeHep package org.freehep.graphics2d.font; /** * Abstract Character Table, inherited by all the Generated Encoding Tables * * @author Simon Fischer * @version $Id: AbstractCharTable.java 8584 2006-08-10 23:06:37Z duns $ */ public abstract class AbstractCharTable implements CharTable { public int toEncoding(char unicode) { try { String name = toName(unicode); if (name == null) return 0; int enc = toEncoding(name); if (enc > 255) { System.out.println("toEncoding() returned illegal value for '" + name + "': " + enc); return 0; } return enc; } catch (Exception e) { return 0; } } public String toName(char c) { return toName(new Character(c)); } public String toName(Integer enc) { return toName(enc.intValue()); } } freehep-graphics2d-2.1.1/src/main/java/org/freehep/graphics2d/font/FontEncoder.java0000644012010301201030000000161510466735775031100 0ustar mascellanimascellani// Copyright 2005, FreeHEP. package org.freehep.graphics2d.font; public class FontEncoder { private FontEncoder() { } public static String getEncodedString(String string, String tableName) { CharTable charTable = Lookup.getInstance().getTable(tableName); return getEncodedString(string, charTable); } /** * Returns an unicode encoded string from an ascii encoded string, using the * supplied table. */ public static String getEncodedString(String string, CharTable charTable) { if (charTable == null) return string; StringBuffer s = new StringBuffer(); for (int i = 0; i < string.length(); i++) { int enc = string.charAt(i); String name = charTable.toName(enc); s.append((name != null) ? charTable.toUnicode(name) : (char) enc); } return s.toString(); } }freehep-graphics2d-2.1.1/src/main/java/org/freehep/graphics2d/font/CharTable.java0000644012010301201030000000332310466735775030515 0ustar mascellanimascellani//Copyright 2001-2005 FreeHep package org.freehep.graphics2d.font; /** * Provides conversions between unicodes, names, and encodings for any * particular encoding. * * @author Sami Kama * @version $Id: CharTable.java 8584 2006-08-10 23:06:37Z duns $ */ public interface CharTable { /** * Converts unicode character to name. * * @param c unicode character * @return name */ public String toName(char c); /** * Converts unicode Character object to name. * * @param c unicode Character object * @return name */ public String toName(Character c); /** * Converts character code into a name. * * @param enc code * @return name */ public String toName(int enc); /** * Converts character code Integer object into a name. * * @param enc code Integer object * @return name */ public String toName(Integer enc); /** * Converts name into character code. * * @param name name of the character * @return character code */ public int toEncoding(String name); /** * Converts a unicode into a character code. * * @param unicode unicode character * @return character code */ public int toEncoding(char unicode); /** * Converts a name to a unicode character. * * @param name of the character * @return unicode character */ public char toUnicode(String name); /** * Returns the name of the table. * * @return table name */ public String getName(); /** * Returns the encoding name of the table. * * @return encoding name */ public String getEncoding(); } freehep-graphics2d-2.1.1/src/main/java/org/freehep/graphics2d/font/FontUtilities.java0000644012010301201030000001454210562167367031470 0ustar mascellanimascellani// Copyright FreeHEP, 2003-2007 package org.freehep.graphics2d.font; import java.awt.Font; import java.awt.GraphicsEnvironment; import java.awt.font.TextAttribute; import java.io.IOException; import java.util.Arrays; import java.util.List; import java.util.Properties; import java.util.Hashtable; /** * * @author Mark Donszelmann * @version $Id$ */ public class FontUtilities { private FontUtilities() { } public static List getAllAvailableFonts() { return Arrays.asList(GraphicsEnvironment.getLocalGraphicsEnvironment() .getAvailableFontFamilyNames()); } private static final Properties windowsFonts = new Properties(); static { // Looks like Unicode MS makes thinner characters // List fontNames = getAllAvailableFonts(); // String arial = fontNames.contains("Arial Unicode MS") ? "Arial // Unicode MS" : "Arial"; String arial = "Arial"; // logical fonts windowsFonts.setProperty("Dialog", arial); windowsFonts.setProperty("DialogInput", "Courier New"); windowsFonts.setProperty("Serif", "Times New Roman"); windowsFonts.setProperty("SansSerif", arial); windowsFonts.setProperty("Monospaced", "Courier New"); // pdf fonts windowsFonts.setProperty("Courier", "Courier New"); windowsFonts.setProperty("Helvetica", arial); windowsFonts.setProperty("Times-Roman", "Times New Roman"); windowsFonts.setProperty("TimesRoman", "Times New Roman"); windowsFonts.setProperty("Times", "Times New Roman"); windowsFonts.setProperty("Symbol", "Arial Unicode MS"); windowsFonts.setProperty("ZapfDingbats", "Arial Unicode MS"); } public static String getWindowsFontName(String fontName) { return windowsFonts.getProperty(fontName, fontName); } /** * @deprecated use * org.freehep.graphics2d.font.FontEncoder.getEncodedString() */ public static String getEncodedString(String string, String tableName) { return FontEncoder.getEncodedString(string, tableName); } /** * Returns an unicode encoded string from an ascii encoded string, using the * supplied table. * * @deprecated use * org.freehep.graphics2d.font.FontEncoder.getEncodedString() */ public static String getEncodedString(String string, CharTable charTable) { return FontEncoder.getEncodedString(string, charTable); } public interface ShowString { public void showString(Font font, String string) throws IOException; } private static final CharTable STANDARD_CHAR_TABLES[] = { null, Lookup.getInstance().getTable("Symbol"), Lookup.getInstance().getTable("Zapfdingbats") }; private static final Font STANDARD_FONT[] = { null, new Font("Symbol", Font.PLAIN, 10), new Font("ZapfDingbats", Font.PLAIN, 10), }; /** * Shows a String and switches the encoding (and font) everytime the unicode * characters leave the range of the curent encoding. Outside the range of * the given latinTable, Symbol and ZapfDingbats are checked. If none of * these three encodings contain the unicode character, an undefined * character is used. */ public static void showString(Font font, String string, CharTable latinTable, ShowString device) throws IOException { if (latinTable == null) throw new RuntimeException("FontUtilities.showString(...): latinTable cannot be 'null'"); STANDARD_FONT[0] = font; STANDARD_FONT[1] = new Font("Symbol", Font.PLAIN, font.getSize()); STANDARD_FONT[2] = new Font("ZapfDingbats", Font.PLAIN, font.getSize()); STANDARD_CHAR_TABLES[0] = latinTable; char[] chars = string.toCharArray(); String out = ""; int lastTable = 0; for (int i = 0; i < chars.length; i++) { // find out suitable table and encoding of this character // try last table first int table = lastTable; char encoding = (char) STANDARD_CHAR_TABLES[table] .toEncoding(chars[i]); // no success -> try all other tables if (encoding == 0) { table = -1; do { table++; if (table != lastTable) { // we already checked that encoding = (char) STANDARD_CHAR_TABLES[table] .toEncoding(chars[i]); } } while ((encoding == 0) && (table < STANDARD_CHAR_TABLES.length - 1)); } if (encoding == 0) table = lastTable; if ((table != lastTable) && (!out.equals(""))) { // if font changes, write the old font and string so far device.showString(STANDARD_FONT[lastTable], out); out = ""; } // append character to out out += encoding; lastTable = table; } device.showString(STANDARD_FONT[lastTable], out); } /** * there is a bug in the jdk 1.6 which makes * Font.getAttributes() not work correctly. The * method does not return all values. What we dow here * is using the old JDK 1.5 method. * * @param font font * @return Attributes of font */ public static Hashtable getAttributes(Font font) { Hashtable result = new Hashtable(7, (float)0.9); result.put( TextAttribute.TRANSFORM, font.getTransform()); result.put( TextAttribute.FAMILY, font.getName()); result.put( TextAttribute.SIZE, new Float(font.getSize2D())); result.put( TextAttribute.WEIGHT, (font.getStyle() & Font.BOLD) != 0 ? TextAttribute.WEIGHT_BOLD : TextAttribute.WEIGHT_REGULAR); result.put( TextAttribute.POSTURE, (font.getStyle() & Font.ITALIC) != 0 ? TextAttribute.POSTURE_OBLIQUE : TextAttribute.POSTURE_REGULAR); result.put( TextAttribute.SUPERSCRIPT, new Integer(0 /* no getter! */)); result.put( TextAttribute.WIDTH, new Float(1 /* no getter */)); return result; } }freehep-graphics2d-2.1.1/src/main/java/org/freehep/graphics2d/font/package.html0000644012010301201030000000020210535660172030260 0ustar mascellanimascellani

Font encoding tables and lookup classes to query the tables.

freehep-graphics2d-2.1.1/src/main/java/org/freehep/graphics2d/SymbolShape.java0000644012010301201030000002553310466735775030157 0ustar mascellanimascellani// Copyright 2001-2004, FreeHEP. package org.freehep.graphics2d; import java.awt.Rectangle; import java.awt.Shape; import java.awt.geom.AffineTransform; import java.awt.geom.PathIterator; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; /** * This class can be used to create and render simple shapes quickly and without * memory allocation. A common point array is used for all created shapes. The * factory methods don't return a new shape, but set the object to the selected * shape. Hence, the class is not thread-safe and only one PathIterator can be * used at the same time.
* * @author Simon Fischer * @version $Id: SymbolShape.java 8584 2006-08-10 23:06:37Z duns $ */ public class SymbolShape implements Shape { private static final double SQRT_2 = Math.sqrt(2.); private static final double SQRT_3 = Math.sqrt(3.); private class ArrayPathIterator implements PathIterator { private int currentPoint = 0; private double[] points; private int[] type; private int numberOfPoints; private ArrayPathIterator(double[] points, int[] type) { this.points = points; this.type = type; } public boolean isDone() { return currentPoint >= numberOfPoints; } public void next() { currentPoint++; } public int currentSegment(double[] coords) { coords[0] = points[2 * currentPoint]; coords[1] = points[2 * currentPoint + 1]; return type[currentPoint]; } public int currentSegment(float[] coords) { coords[0] = (float) points[2 * currentPoint]; coords[1] = (float) points[2 * currentPoint + 1]; return type[currentPoint]; } public int getWindingRule() { return PathIterator.WIND_NON_ZERO; } private void reset() { currentPoint = 0; } private void done() { currentPoint = numberOfPoints; } } private double points[]; private int type[]; private ArrayPathIterator pathIterator; private double x, y; private double size; private int symbol; public SymbolShape() { ensureNumberOfPoints(10); type[0] = PathIterator.SEG_MOVETO; for (int i = 1; i < type.length; i++) { type[i] = PathIterator.SEG_LINETO; } this.pathIterator = new ArrayPathIterator(points, type); } public boolean contains(double x, double y) { return getBounds2D().contains(x, y); } public boolean contains(double x, double y, double w, double h) { return contains(x, y) && contains(x + w, y) && contains(x, y + h) && contains(x + w, y + h); } public boolean contains(Point2D p) { return contains(p.getX(), p.getY()); } public boolean contains(Rectangle2D r) { return contains(r.getX(), r.getY(), r.getWidth(), r.getHeight()); } /** Returns true, if at least one of the points is contained by the shape. */ public boolean intersects(double x, double y, double w, double h) { return contains(x, y) || contains(x + w, y) || contains(x, y + h) || contains(x + w, y + h); } public boolean intersects(Rectangle2D r) { return intersects(r.getX(), r.getY(), r.getWidth(), r.getHeight()); } public PathIterator getPathIterator(AffineTransform at, double flatness) { return getPathIterator(at); } public Rectangle2D getBounds2D() { return new Rectangle2D.Double(x - size / 2, y - size / 2, size, size); } public Rectangle getBounds() { return getBounds2D().getBounds(); } public PathIterator getPathIterator(AffineTransform t) { if (t != null) { t.transform(points, 0, pathIterator.points, 0, points.length / 2); } // if (!pathIterator.isDone()) { // System.err.println("SymbolShape: concurrent PathIterator // requested!"); // } pathIterator.reset(); return pathIterator; } // -------------------- factory methods -------------------- private void createNew(int n) { // if (!pathIterator.isDone()) { // System.err.println("SymbolShape: concurrent modification!"); // } ensureNumberOfPoints(n); pathIterator.numberOfPoints = n; pathIterator.done(); } /** * Type must be one of the symbols defined in VectorGraphicsConstants except * TYPE_CIRCLE. * * @see org.freehep.graphics2d.VectorGraphicsConstants */ public void create(int symbol, double x, double y, double size) { this.symbol = symbol; this.x = x; this.y = y; this.size = size; switch (symbol) { case VectorGraphicsConstants.SYMBOL_VLINE: createVLine(x, y, size); break; case VectorGraphicsConstants.SYMBOL_HLINE: createHLine(x, y, size); break; case VectorGraphicsConstants.SYMBOL_PLUS: createPlus(x, y, size); break; case VectorGraphicsConstants.SYMBOL_CROSS: createCross(x, y, size); break; case VectorGraphicsConstants.SYMBOL_STAR: createStar(x, y, size); break; case VectorGraphicsConstants.SYMBOL_BOX: createBox(x, y, size); break; case VectorGraphicsConstants.SYMBOL_UP_TRIANGLE: createUpTriangle(x, y, size); break; case VectorGraphicsConstants.SYMBOL_DN_TRIANGLE: createDownTriangle(x, y, size); break; case VectorGraphicsConstants.SYMBOL_DIAMOND: createDiamond(x, y, size); break; } } public String toString() { return getClass() + ": " + symbol + " (" + x + ", " + y + ") size: " + size; } private void createHLine(double x, double y, double size) { createNew(2); type[0] = PathIterator.SEG_MOVETO; points[0] = x - size / 2; points[1] = y; type[1] = PathIterator.SEG_LINETO; points[2] = x + size / 2; points[3] = y; } private void createVLine(double x, double y, double size) { createNew(2); type[0] = PathIterator.SEG_MOVETO; points[0] = x; points[1] = y - size / 2; type[1] = PathIterator.SEG_LINETO; points[2] = x; points[3] = y + size / 2; } private void createPlus(double x, double y, double size) { createNew(4); double length = size / 2.; type[0] = PathIterator.SEG_MOVETO; points[0] = x + length; points[1] = y; type[1] = PathIterator.SEG_LINETO; points[2] = x - length; points[3] = y; type[2] = PathIterator.SEG_MOVETO; points[4] = x; points[5] = y + length; type[3] = PathIterator.SEG_LINETO; points[6] = x; points[7] = y - length; } private void createCross(double x, double y, double size) { createNew(4); double side = size / 2. / SQRT_2; type[0] = PathIterator.SEG_MOVETO; points[0] = x - side; points[1] = y - side; type[1] = PathIterator.SEG_LINETO; points[2] = x + side; points[3] = y + side; type[2] = PathIterator.SEG_MOVETO; points[4] = x + side; points[5] = y - side; type[3] = PathIterator.SEG_LINETO; points[6] = x - side; points[7] = y + side; } private void createStar(double x, double y, double size) { createNew(8); double delta = size / 2.; type[0] = PathIterator.SEG_MOVETO; points[0] = x; points[1] = y - delta; type[1] = PathIterator.SEG_LINETO; points[2] = x; points[3] = y + delta; type[2] = PathIterator.SEG_MOVETO; points[4] = x - delta; points[5] = y; type[3] = PathIterator.SEG_LINETO; points[6] = x + delta; points[7] = y; delta = size / 2. / SQRT_2; type[4] = PathIterator.SEG_MOVETO; points[8] = x - delta; points[9] = y - delta; type[5] = PathIterator.SEG_LINETO; points[10] = x + delta; points[11] = y + delta; type[6] = PathIterator.SEG_MOVETO; points[12] = x + delta; points[13] = y - delta; type[7] = PathIterator.SEG_LINETO; points[14] = x - delta; points[15] = y + delta; } private void createUpTriangle(double x, double y, double size) { createNew(4); type[0] = PathIterator.SEG_MOVETO; points[0] = x; points[1] = y - size / SQRT_3; type[1] = PathIterator.SEG_LINETO; points[2] = x - size / 2.; points[3] = y + (-size / SQRT_3 + size * SQRT_3 / 2.); type[2] = PathIterator.SEG_LINETO; points[4] = x + size / 2.; points[5] = y + (-size / SQRT_3 + size * SQRT_3 / 2.); type[3] = PathIterator.SEG_CLOSE; } private void createDownTriangle(double x, double y, double size) { createNew(4); type[0] = PathIterator.SEG_MOVETO; points[0] = x; points[1] = y + size / SQRT_3; type[1] = PathIterator.SEG_LINETO; points[2] = x - size / 2.; points[3] = y - (-size / SQRT_3 + size * SQRT_3 / 2.); type[2] = PathIterator.SEG_LINETO; points[4] = x + size / 2.; points[5] = y - (-size / SQRT_3 + size * SQRT_3 / 2.); type[3] = PathIterator.SEG_CLOSE; } private void createDiamond(double x, double y, double size) { createNew(5); double length = size / 2.; type[0] = PathIterator.SEG_MOVETO; points[0] = x + length; points[1] = y; type[1] = PathIterator.SEG_LINETO; points[2] = x; points[3] = y + length; type[2] = PathIterator.SEG_LINETO; points[4] = x - length; points[5] = y; type[3] = PathIterator.SEG_LINETO; points[6] = x; points[7] = y - length; type[4] = PathIterator.SEG_CLOSE; } private void createBox(double x, double y, double size) { createNew(5); double side = size / SQRT_2 / 2; type[0] = PathIterator.SEG_MOVETO; points[0] = x - side; points[1] = y - side; type[1] = PathIterator.SEG_LINETO; points[2] = x + side + 1; points[3] = y - side; type[2] = PathIterator.SEG_LINETO; points[4] = x + side + 1; points[5] = y + side + 1; type[3] = PathIterator.SEG_LINETO; points[6] = x - side; points[7] = y + side + 1; type[4] = PathIterator.SEG_CLOSE; } private void ensureNumberOfPoints(int n) { if ((type == null) || (type.length < n)) { this.points = new double[n * 2]; this.type = new int[n]; } } } freehep-graphics2d-2.1.1/src/main/java/org/freehep/graphics2d/VectorGraphicsConstants.java0000644012010301201030000000644010466735775032545 0ustar mascellanimascellani// University of Santa Cruz, California, USA and // CERN, Geneva, Switzerland, Copyright (c) 2000 package org.freehep.graphics2d; /** * This interface defines useful constants for users of the VectorGraphics * interface. * * @author Charles Loomis * @version $Id: VectorGraphicsConstants.java 8584 2006-08-10 23:06:37Z duns $ */ public interface VectorGraphicsConstants { // // // Symbol definitions // // /** * Vertical line (|) symbol. */ final public static int SYMBOL_VLINE = 0; /** * Horizontal line (-) symbol. */ final public static int SYMBOL_HLINE = 1; /** * Plus-shaped (+) symbol. */ final public static int SYMBOL_PLUS = 2; /** * An x-shaped (x) symbol. */ final public static int SYMBOL_CROSS = 3; /** * An eight-point star created by combining the plus and cross symbols. */ final public static int SYMBOL_STAR = 4; /** * An open circle (o) symbol. */ final public static int SYMBOL_CIRCLE = 5; /** * An open square symbol. */ final public static int SYMBOL_BOX = 6; /** * An open equilateral triangle pointing up. */ final public static int SYMBOL_UP_TRIANGLE = 7; /** * An open equilateral triangle pointing down. */ final public static int SYMBOL_DN_TRIANGLE = 8; /** * An open square symbol rotated by 45 degrees. */ final public static int SYMBOL_DIAMOND = 9; /** * The number of defined symbols. Used in implementations of the * VectorGraphics interfaces. */ final public static int NUMBER_OF_SYMBOLS = 10; // // // Text alignment definitions // // /** * Constant indicating that a string should be aligned vertically with the * baseline of the text. This is the default in drawString calls which do * not specify an alignment. */ public static final int TEXT_BASELINE = 0; /** * Constant indicating that a string should be aligned vertically with the * top of the text. */ public static final int TEXT_TOP = 1; /** * Constant indicating that a string should be aligned vertically with the * bottom of the text. */ public static final int TEXT_BOTTOM = 3; /** * Constant indicating that a string should be aligned by the center. This * is used for both horizontal and vertical alignment. */ public static final int TEXT_CENTER = 2; /** * Constant indicating that a string should be aligned horizontally with the * left side of the text. This is the default for drawString calls which do * not specify an alignment. */ public static final int TEXT_LEFT = 1; /** * Constant indicating that the string should be aligned horizontally with * the right side of the text. */ public static final int TEXT_RIGHT = 3; /** * Constant indicating the maximum number of vertical alignments. Used in * implementation of the VectorGraphics interfaces. */ public static final int NUMBER_OF_VERTICAL_ALIGNMENTS = 4; /** * Constant indicating the maximum number of horizontal alignments. Used in * implementation of the VectorGraphics interfaces. */ public static final int NUMBER_OF_HORIZ_ALIGNMENTS = 4; } freehep-graphics2d-2.1.1/src/main/java/org/freehep/graphics2d/PrintColor.java0000644012010301201030000001170010557755630030004 0ustar mascellanimascellani// Copyright 2002, FreeHEP. package org.freehep.graphics2d; import java.awt.Color; import java.awt.color.ColorSpace; /** * Print color for printing and display in color, grayscale and black/white. * * @author Mark Donszelmann * @version $Id: PrintColor.java 10510 2007-01-30 23:58:16Z duns $ */ public class PrintColor extends Color { public static final int COLOR = 0; public static final int GRAYSCALE = 1; public static final int BLACK_AND_WHITE = 2; protected static Color[] defaultColors = { Color.RED, Color.GREEN, Color.BLUE, Color.CYAN, Color.MAGENTA, Color.YELLOW, Color.ORANGE, Color.PINK, Color.WHITE, Color.LIGHT_GRAY, Color.GRAY, Color.DARK_GRAY, Color.BLACK }; protected float asGray; protected boolean asBlack; private static void testColorValueRange(float asGray) { boolean rangeError = false; String badComponentString = ""; if (asGray < 0.0f || asGray > 1.0f) { rangeError = true; badComponentString = badComponentString + " asGray"; } if (rangeError) { throw new IllegalArgumentException( "PrintColor parameter outside of expected range:" + badComponentString); } } public PrintColor(float red, float green, float blue, float asGray, boolean asBlack) { this(red, green, blue, 1.0f, asGray, asBlack); } public PrintColor(float red, float green, float blue, float alpha, float asGray, boolean asBlack) { super(red, green, blue, alpha); this.asGray = asGray; this.asBlack = asBlack; testColorValueRange(asGray); } public PrintColor(Color color, float asGray, boolean asBlack) { super(color.getRed(), color.getGreen(), color.getBlue(), color .getAlpha()); this.asGray = asGray; this.asBlack = asBlack; testColorValueRange(asGray); } public float getAsGray() { return asGray; } public boolean getAsBlack() { return asBlack; } public PrintColor getColor(int mode) { // FIXME does not handle invisibility switch (mode) { case COLOR: return this; case GRAYSCALE: return new PrintColor(getAsGray(), getAsGray(), getAsGray(), getAlpha() / 255.0f, getAsGray(), getAsBlack()); case BLACK_AND_WHITE: if (getAsBlack()) { return new PrintColor(Color.black, getAsGray(), getAsBlack()); } else { return new PrintColor(Color.white, getAsGray(), getAsBlack()); } default: throw new IllegalArgumentException( "ColorMode on PrintColor out of range: " + mode); } } public static PrintColor createPrintColor(Color color) { if (color == null) { return null; } if (color instanceof PrintColor) { return (PrintColor) color; } // convert a awt.Color to some reasonable PrintColor. // pure white converts to black, and vice versa. float[] gray = ColorSpace.getInstance( ColorSpace.CS_GRAY).fromRGB( color.getRGBComponents(null)); if (gray[0] == 0.0f) { gray[0] = 1.0f; } else if (gray[0] == 1.0f) { gray[0] = 0.0f; } return new PrintColor(color, gray[0], !color.equals(Color.black)); } /** * @return a color from the standard java colors */ public static Color getDefaultColor(int index) { if ((index < 0) || (index >= defaultColors.length)) throw new IllegalArgumentException( "PrintColor.getDefaultColor index outside of expected range: " + index); return createPrintColor(defaultColors[index]); } // FIXME, should return PrintColor public static Color mixColor(Color c1, Color c2) { int red = (c1.getRed() + c2.getRed()) / 2; int green = (c1.getGreen() + c2.getGreen()) / 2; int blue = (c1.getBlue() + c2.getBlue()) / 2; return new Color(red, green, blue); } public int hashCode() { // FIXME could make something better here return super.hashCode(); } public boolean equals(Object obj) { return super.equals(obj) && obj instanceof PrintColor && ((PrintColor) obj).asGray == this.asGray && ((PrintColor) obj).asBlack == this.asBlack; } public String toString() { return super.toString() + ", asGray: " + asGray + ", asBlack: " + asBlack; } public static PrintColor invert(Color color) { PrintColor printColor = createPrintColor(color); return new PrintColor(new Color(printColor.getRGB() ^ 0x00808080), (printColor.getAsGray() + 0.5f) % 1.0f, !printColor .getAsBlack()); } } freehep-graphics2d-2.1.1/src/main/java/org/freehep/graphics2d/ScreenConstants.java0000644012010301201030000000264410466735775031043 0ustar mascellanimascellani// Copyright 2000, CERN, Geneva, Switzerland and University of Santa Cruz, California, U.S.A. package org.freehep.graphics2d; import java.awt.Dimension; import java.util.HashMap; import java.util.Map; /** * This class defines a set of constants which describe a screen. * * @author Mark Donszelmann * @version $Id: ScreenConstants.java 8584 2006-08-10 23:06:37Z duns $ */ public class ScreenConstants { public final static String VGA = "600x480"; public final static String SVGA = "800x600"; public final static String XGA = "1024x768"; public final static String SXGA = "1280x1024"; public final static String SXGA_PLUS = "1400x1050"; public final static String UXGA = "1600x1200"; public final static String WSXGA_PLUS = "1680x1050"; public final static String WUXGA = "1920x1200"; private static Dimension UNDEFINED = new Dimension(0, 0); private static final Map sizes; static { sizes = new HashMap(); sizes.put(VGA, new Dimension(640, 480)); sizes.put(SVGA, new Dimension(800, 600)); sizes.put(XGA, new Dimension(1024, 768)); sizes.put(SXGA, new Dimension(1280, 1024)); sizes.put(SXGA_PLUS, new Dimension(1400, 1050)); sizes.put(UXGA, new Dimension(1600, 1200)); } public static Dimension getSize(String size) { Dimension d = (Dimension) sizes.get(size); return d != null ? d : UNDEFINED; } } freehep-graphics2d-2.1.1/src/main/java/org/freehep/graphics2d/package.html0000644012010301201030000000140010535660172027313 0ustar mascellanimascellani Base classes for VectorGraphics, useful to implement different output formats.

The VectorGraphics interface allows users to draw in a vector graphics mode. It defines all the methods available in java.awt.Graphics2D and augments this set by some extra methods to draw pre defined symbols and marked-up (tagged) strings.

The VectorGraphics2D class implements this interface and inherits from the standard java.awt.Graphics2D. This allows users who normally draw using java.awt.Graphics2D to use VectorGraphics2D instead. 

PixelGraphics2D implements VectorGraphics on top of the standard java.awt.Graphics2D. 

Other implementations of VectorGraphics for various output formats can be found in org.freehep.graphicsio.

freehep-graphics2d-2.1.1/src/main/java/org/freehep/graphics2d/AbstractVectorGraphics.java0000644012010301201030000006034710562167367032333 0ustar mascellanimascellani// Copyright 2000-2007, FreeHEP package org.freehep.graphics2d; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Dimension; import java.awt.Font; import java.awt.Insets; import java.awt.Paint; import java.awt.Rectangle; import java.awt.Shape; import java.awt.Stroke; 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.Point2D; import java.awt.geom.Rectangle2D; import java.awt.geom.RoundRectangle2D; import java.text.AttributedCharacterIterator; import java.util.Properties; import org.freehep.graphics2d.font.FontUtilities; import org.freehep.util.UserProperties; /** * This class implements all conversions from integer to double as well as a few * other convenience functions. It also handles the different drawSymbol and * fillSymbol methods and print colors. The drawing of framed strings is * broken down to lower level methods. * * @author Simon Fischer * @author Mark Donszelmann * @author Steffen Greiffenberg * @version $Id: AbstractVectorGraphics.java 10516 2007-02-06 21:11:19Z duns $ */ public abstract class AbstractVectorGraphics extends VectorGraphics { private UserProperties properties; private String creator; private boolean isDeviceIndependent; private SymbolShape cachedShape; private int colorMode; private Color backgroundColor; private Color currentColor; private Paint currentPaint; private Font currentFont; public AbstractVectorGraphics() { properties = new UserProperties(); creator = "FreeHEP Graphics2D Driver"; isDeviceIndependent = false; cachedShape = new SymbolShape(); colorMode = PrintColor.COLOR; // all of these have to be set in the subclasses currentFont = null; backgroundColor = null; currentColor = null; currentPaint = null; } protected AbstractVectorGraphics(AbstractVectorGraphics graphics) { super(); properties = graphics.properties; creator = graphics.creator; isDeviceIndependent = graphics.isDeviceIndependent; cachedShape = graphics.cachedShape; backgroundColor = graphics.backgroundColor; currentColor = graphics.currentColor; currentPaint = graphics.currentPaint; colorMode = graphics.colorMode; currentFont = graphics.currentFont; } public void setProperties(Properties newProperties) { if (newProperties == null) return; properties.setProperties(newProperties); } protected void initProperties(Properties defaults) { properties = new UserProperties(); properties.setProperties(defaults); } protected Properties getProperties() { return properties; } public String getProperty(String key) { return properties.getProperty(key); } public Color getPropertyColor(String key) { return properties.getPropertyColor(key); } public Rectangle getPropertyRectangle(String key) { return properties.getPropertyRectangle(key); } public Insets getPropertyInsets(String key) { return properties.getPropertyInsets(key); } public Dimension getPropertyDimension(String key) { return properties.getPropertyDimension(key); } public int getPropertyInt(String key) { return properties.getPropertyInt(key); } public double getPropertyDouble(String key) { return properties.getPropertyDouble(key); } public boolean isProperty(String key) { return properties.isProperty(key); } public String getCreator() { return creator; } public void setCreator(String creator) { if (creator != null) { this.creator = creator; } } public boolean isDeviceIndependent() { return isDeviceIndependent; } public void setDeviceIndependent(boolean isDeviceIndependent) { this.isDeviceIndependent = isDeviceIndependent; } /** * Gets the current font. * * @return current font */ public Font getFont() { return currentFont; } /** * Sets the current font. * * @param font to be set */ public void setFont(Font font) { if (font == null) return; // FIXME: maybe add delayed setting currentFont = font; } public void drawSymbol(int x, int y, int size, int symbol) { drawSymbol((double) x, (double) y, (double) size, symbol); } public void fillSymbol(int x, int y, int size, int symbol) { fillSymbol((double) x, (double) y, (double) size, symbol); } public void fillAndDrawSymbol(int x, int y, int size, int symbol, Color fillColor) { fillAndDrawSymbol((double) x, (double) y, (double) size, symbol, fillColor); } public void drawSymbol(double x, double y, double size, int symbol) { if (size <= 0) return; drawSymbol(this, x, y, size, symbol); } protected void drawSymbol(VectorGraphics g, double x, double y, double size, int symbol) { switch (symbol) { case SYMBOL_VLINE: case SYMBOL_STAR: case SYMBOL_HLINE: case SYMBOL_PLUS: case SYMBOL_CROSS: case SYMBOL_BOX: case SYMBOL_UP_TRIANGLE: case SYMBOL_DN_TRIANGLE: case SYMBOL_DIAMOND: cachedShape.create(symbol, x, y, size); g.draw(cachedShape); break; case SYMBOL_CIRCLE: { double diameter = Math.max(1, size); diameter += (diameter % 2); g.drawOval(x - diameter / 2, y - diameter / 2, diameter, diameter); break; } } } public void fillSymbol(double x, double y, double size, int symbol) { if (size <= 0) return; fillSymbol(this, x, y, size, symbol); } protected void fillSymbol(VectorGraphics g, double x, double y, double size, int symbol) { switch (symbol) { case SYMBOL_VLINE: case SYMBOL_STAR: case SYMBOL_HLINE: case SYMBOL_PLUS: case SYMBOL_CROSS: cachedShape.create(symbol, x, y, size); g.draw(cachedShape); break; case SYMBOL_BOX: case SYMBOL_UP_TRIANGLE: case SYMBOL_DN_TRIANGLE: case SYMBOL_DIAMOND: cachedShape.create(symbol, x, y, size); g.fill(cachedShape); break; case SYMBOL_CIRCLE: { double diameter = Math.max(1, size); diameter += (diameter % 2); g.fillOval(x - diameter / 2, y - diameter / 2, diameter, diameter); break; } } } public void fillAndDrawSymbol(double x, double y, double size, int symbol, Color fillColor) { Color color = getColor(); setColor(fillColor); fillSymbol(x, y, size, symbol); setColor(color); drawSymbol(x, y, size, symbol); } public void fillAndDraw(Shape s, Color fillColor) { Color color = getColor(); setColor(fillColor); fill(s); setColor(color); draw(s); } // --------------------------------------------------------- // -------------------- WRAPPER METHODS -------------------- // -------------------- int -> double -------------------- // needs a bias in some cases // --------------------------------------------------------- private static final double bias = 0.5; public void clearRect(int x, int y, int width, int height) { clearRect((double) x + bias, (double) y + bias, (double) width, (double) height); } public void drawLine(int x1, int y1, int x2, int y2) { drawLine((double) x1 + bias, (double) y1 + bias, (double) x2 + bias, (double) y2 + bias); } public void drawRect(int x, int y, int width, int height) { drawRect((double) x + bias, (double) y + bias, (double) width, (double) height); } public void fillRect(int x, int y, int width, int height) { fillRect((double) x, (double) y, (double) width, (double) height); } public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) { drawArc((double) x + bias, (double) y + bias, (double) width, (double) height, (double) startAngle, (double) arcAngle); } public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) { fillArc((double) x, (double) y, (double) width, (double) height, (double) startAngle, (double) arcAngle); } public void drawOval(int x, int y, int width, int height) { drawOval((double) x + bias, (double) y + bias, (double) width, (double) height); } public void fillOval(int x, int y, int width, int height) { fillOval((double) x, (double) y, (double) width, (double) height); } public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) { drawRoundRect((double)x + bias, (double)y + bias, (double) width, (double) height, (double) arcWidth, (double) arcHeight); } public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) { fillRoundRect((double) x, (double) y, (double) width, (double) height, (double) arcWidth, (double) arcHeight); } public void translate(int x, int y) { translate((double) x, (double) y); } /*-------------------------------------------------------------------------------- | 8.1. stroke/linewidth *--------------------------------------------------------------------------------*/ public void setLineWidth(int width) { setLineWidth((double) width); } public void setLineWidth(double width) { Stroke stroke = getStroke(); if (stroke instanceof BasicStroke) { BasicStroke cs = (BasicStroke) stroke; if (cs.getLineWidth() != width) { stroke = new BasicStroke((float) width, cs.getEndCap(), cs .getLineJoin(), cs.getMiterLimit(), cs.getDashArray(), cs.getDashPhase()); setStroke(stroke); } } else { stroke = new BasicStroke((float) width); setStroke(stroke); } } public void drawString(String str, int x, int y) { drawString(str, (double) x, (double) y); } public void drawString(String s, float x, float y) { drawString(s, (double) x, (double) y); } public void drawString(AttributedCharacterIterator iterator, int x, int y) { drawString(iterator, (float) x, (float) y); } /** * Draws frame and banner for a TextLayout, which is used for * calculation auf ajustment * * @param tl TextLayout for frame calculation * @param x coordinate to draw string * @param y coordinate to draw string * @param horizontal alignment of the text * @param vertical alignment of the text * @param framed true if text is surrounded by a frame * @param frameColor color of the frame * @param frameWidth witdh of the frame * @param banner true if the frame is filled by a banner * @param bannerColor color of the banner * @return Offset for the string inside the frame */ private Point2D drawFrameAndBanner(TextLayout tl, double x, double y, int horizontal, int vertical, boolean framed, Color frameColor, double frameWidth, boolean banner, Color bannerColor) { // calculate string bounds for alignment Rectangle2D bounds = tl.getBounds(); // calculate real bounds bounds.setRect( bounds.getX(), bounds.getY(), // care for Italic fonts too Math.max(tl.getAdvance(), bounds.getWidth()), bounds.getHeight()); // add x and y AffineTransform at = AffineTransform.getTranslateInstance(x, y); // horizontal alignment if (horizontal == TEXT_RIGHT) { at.translate(- bounds.getWidth(), 0); } else if (horizontal == TEXT_CENTER) { at.translate(- bounds.getWidth() / 2, 0); } // vertical alignment if (vertical == TEXT_BASELINE) { // no translation needed } else if (vertical == TEXT_TOP) { at.translate(0, - bounds.getY()); } else if (vertical == TEXT_CENTER) { // the following adds supersript ascent too, // so it does not work // at.translate(0, tl.getAscent() / 2); // this is nearly the same at.translate(0, tl.getDescent()); } else if (vertical == TEXT_BOTTOM) { at.translate(0, - bounds.getHeight() - bounds.getY()); } // transform the bounds bounds = at.createTransformedShape(bounds).getBounds2D(); // create the result with the same transformation Point2D result = at.transform(new Point2D.Double(0, 0), new Point2D.Double()); // space between string and border double adjustment = (getFont().getSize2D() * 2) / 10; // add the adjustment bounds.setRect( bounds.getX() - adjustment, bounds.getY() - adjustment, bounds.getWidth() + 2 * adjustment, bounds.getHeight() + 2 * adjustment); if (banner) { Paint paint = getPaint(); setColor(bannerColor); fill(bounds); setPaint(paint); } if (framed) { Paint paint = getPaint(); Stroke stroke = getStroke(); setColor(frameColor); setLineWidth(frameWidth); draw(bounds); setPaint(paint); setStroke(stroke); } return result; } /** * Draws frame, banner and aligned text inside * * @param str text to be drawn * @param x coordinate to draw string * @param y coordinate to draw string * @param horizontal alignment of the text * @param vertical alignment of the text * @param framed true if text is surrounded by a frame * @param frameColor color of the frame * @param frameWidth witdh of the frame * @param banner true if the frame is filled by a banner * @param bannerColor color of the banner */ public void drawString(String str, double x, double y, int horizontal, int vertical, boolean framed, Color frameColor, double frameWidth, boolean banner, Color bannerColor) { // change the x offset for the next drawing // FIXME: change y offset for vertical text TextLayout tl = new TextLayout( str, FontUtilities.getAttributes(getFont()), getFontRenderContext()); // draw the frame Point2D offset = drawFrameAndBanner( tl, x, y, horizontal, vertical, framed, frameColor, frameWidth, banner, bannerColor); // draw the string drawString(str, offset.getX(), offset.getY()); } /** * Draws the tagged string parsed by a {@link TagHandler} and adds a * border specified by the parameters * * @param str Tagged text to be drawn * @param x coordinate to draw string * @param y coordinate to draw string * @param horizontal alignment of the text * @param vertical alignment of the text * @param framed true if text is surrounded by a frame * @param frameColor color of the frame * @param frameWidth witdh of the frame * @param banner true if the frame is filled by a banner * @param bannerColor color of the banner */ public void drawString(TagString str, double x, double y, int horizontal, int vertical, boolean framed, Color frameColor, double frameWidth, boolean banner, Color bannerColor) { GenericTagHandler tagHandler = new GenericTagHandler(this); TextLayout tl = tagHandler.createTextLayout(str, getFont().getSize2D() / 7.5); // draw the frame Point2D offset = drawFrameAndBanner( tl, x, y, horizontal, vertical, framed, frameColor, frameWidth, banner, bannerColor); // FIXME: not quite clear why correction is needed // see {@link GenericTagHandler#superscriptCorrection tagHandler.print(str, offset.getX(), offset.getY(), getFont().getSize2D() / 7.5); } // ------------------ other wrapper methods ---------------- public void drawString(String str, double x, double y, int horizontal, int vertical) { drawString(str, x, y, horizontal, vertical, false, null, 0, false, null); } public void drawString(TagString str, double x, double y) { drawString(str, x, y, TEXT_LEFT, TEXT_BASELINE); } public void drawString(TagString str, double x, double y, int horizontal, int vertical) { drawString(str, x, y, horizontal, vertical, false, null, 0, false, null); } /* 8.2. paint/color */ public int getColorMode() { return colorMode; } public void setColorMode(int colorMode) { this.colorMode = colorMode; } /** * Gets the background color. * * @return background color */ public Color getBackground() { return backgroundColor; } /** * Sets the background color. * * @param color background color to be set */ public void setBackground(Color color) { backgroundColor = color; } /** * Sets the current color and the current paint. Calls writePaint(Color). * * @param color to be set */ public void setColor(Color color) { if (color == null) return; currentColor = color; currentPaint = color; } /** * Gets the current color. * * @return the current color */ public Color getColor() { return currentColor; } /** * Sets the current paint. * * @param paint to be set */ public void setPaint(Paint paint) { if (paint == null) return; if (!(paint instanceof Color)) currentColor = null; currentPaint = paint; } /** * Gets the current paint. * * @return paint current paint */ public Paint getPaint() { return currentPaint; } /** * Returns a printColor created from the original printColor, based on the * ColorMode. If you run getPrintColor on it again you still get the same * color, so that it does not matter if you convert it more than once. */ protected Color getPrintColor(Color color) { // shortcut if mode is COLOR for speed if (colorMode == PrintColor.COLOR) return color; // otherwise... PrintColor printColor = PrintColor.createPrintColor(color); return printColor.getColor(colorMode); } public void rotate(double theta, double x, double y) { translate(x, y); rotate(theta); translate(-x, -y); } public void drawArc(double x, double y, double width, double height, double startAngle, double arcAngle) { draw(new Arc2D.Double(x, y, width, height, startAngle, arcAngle, Arc2D.OPEN)); } public void drawLine(double x1, double y1, double x2, double y2) { draw(new Line2D.Double(x1, y1, x2, y2)); } public void drawOval(double x, double y, double width, double height) { draw(new Ellipse2D.Double(x, y, width, height)); } public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints) { draw(createShape(xPoints, yPoints, nPoints, false, true)); } public void drawPolyline(double[] xPoints, double[] yPoints, int nPoints) { draw(createShape(xPoints, yPoints, nPoints, false)); } public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints) { draw(createShape(xPoints, yPoints, nPoints, true, true)); } public void drawPolygon(double[] xPoints, double[] yPoints, int nPoints) { draw(createShape(xPoints, yPoints, nPoints, true)); } public void drawRect(double x, double y, double width, double height) { draw(new Rectangle2D.Double(x, y, width, height)); } public void drawRoundRect(double x, double y, double width, double height, double arcWidth, double arcHeight) { draw(new RoundRectangle2D.Double(x, y, width, height, arcWidth, arcHeight)); } public void fillArc(double x, double y, double width, double height, double startAngle, double arcAngle) { fill(new Arc2D.Double(x, y, width, height, startAngle, arcAngle, Arc2D.PIE)); } public void fillOval(double x, double y, double width, double height) { fill(new Ellipse2D.Double(x, y, width, height)); } public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) { fill(createShape(xPoints, yPoints, nPoints, true, false)); } public void fillPolygon(double[] xPoints, double[] yPoints, int nPoints) { fill(createShape(xPoints, yPoints, nPoints, true)); } public void fillRect(double x, double y, double width, double height) { fill(new Rectangle2D.Double(x, y, width, height)); } public void fillRoundRect(double x, double y, double width, double height, double arcWidth, double arcHeight) { fill(new RoundRectangle2D.Double(x, y, width, height, arcWidth, arcHeight)); } /** * Creates a polyline/polygon shape from a set of points. Needs to be * defined in subclass because its implementations could be device specific * * @param xPoints X coordinates of the polyline. * @param yPoints Y coordinates of the polyline. * @param nPoints number of points of the polyline. * @param close is shape closed */ protected abstract Shape createShape(double[] xPoints, double[] yPoints, int nPoints, boolean close); /** * Creates a polyline/polygon shape from a set of points. * Needs a bias! * * @param xPoints X coordinates of the polyline. * @param yPoints Y coordinates of the polyline. * @param nPoints number of points of the polyline. * @param close is shape closed */ protected Shape createShape(int[] xPoints, int[] yPoints, int nPoints, boolean close, boolean biased) { float offset = biased ? (float)bias : 0.0f; GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD); if (nPoints > 0) { path.moveTo(xPoints[0] + offset, yPoints[0] + offset); int lastX = xPoints[0]; int lastY = yPoints[0]; if (close && (Math.abs(xPoints[nPoints - 1] - lastX) < 1) && (Math.abs(yPoints[nPoints - 1] - lastY) < 1)) { nPoints--; } for (int i = 1; i < nPoints; i++) { if ((Math.abs(xPoints[i] - lastX) > 1) || (Math.abs(yPoints[i] - lastY) > 1)) { path.lineTo(xPoints[i] + offset, yPoints[i] + offset); lastX = xPoints[i]; lastY = yPoints[i]; } } if (close) path.closePath(); } return path; } /** * Checks whether or not the specified Shape intersects * the specified {@link Rectangle}, which is in device * space. * * @param rect the area in device space to check for a hit * @param s the Shape to check for a hit * @param onStroke flag used to choose between testing the stroked or the filled shape. * @see java.awt.Graphics2D#hit(Rectangle, Shape, boolean) */ public boolean hit(Rectangle rect, Shape s, boolean onStroke) { if (onStroke && getStroke() != null) { s = getStroke().createStrokedShape(s); } if (getTransform() != null) { s = getTransform().createTransformedShape(s); } Area area = new Area(s); if (getClip() != null) { area.intersect(new Area(getClip())); } return area.intersects(rect); } } freehep-graphics2d-2.1.1/src/main/java/org/freehep/graphics2d/TagString.java0000644012010301201030000000107010466735775027621 0ustar mascellanimascellani// Copyright 2000, CERN, Geneva, Switzerland and University of Santa Cruz, California, U.S.A. package org.freehep.graphics2d; /** * * @author Mark Donszelmann * @version $Id: TagString.java 8584 2006-08-10 23:06:37Z duns $ */ public class TagString { private String string; public TagString(String value) { string = value; } public int hashCode() { return string.hashCode(); } public boolean equals(Object obj) { return string.equals(obj); } public String toString() { return string; } } freehep-graphics2d-2.1.1/src/main/java/org/freehep/graphics2d/GenericTagHandler.java0000644012010301201030000002611710633617377031227 0ustar mascellanimascellani// Copyright FreeHEP, 2000-2007 package org.freehep.graphics2d; import java.awt.Graphics2D; import java.awt.font.TextAttribute; import java.awt.font.TextLayout; import java.awt.geom.AffineTransform; import java.text.AttributedString; import java.util.Hashtable; import java.util.Stack; import java.util.Vector; import org.freehep.graphics2d.font.FontUtilities; /** * The class converts HTML tags like in instances of {@link TextAttribute}. * * @author Mark Donszelmann * @author Steffen Greiffenberg * @version $Id: GenericTagHandler.java 12753 2007-06-12 22:32:31Z duns $ */ public class GenericTagHandler extends TagHandler { /** * TextAttribute for overline, not a standard */ public static Integer UNDERLINE_OVERLINE = new Integer(128); /** * context to draw AttributedString */ private Graphics2D graphics; /** * text without any tags, e.g. "text" would become "text". * filled by {@link #text(String)} */ private StringBuffer clearedText; /** * stores AttributeEntries created by {@link #closeTag(String)} */ private Vector/**/ attributes; /** * stores all open tags, e.g. "" an the position * on which it placed in text. Filled by {@link #openTag(String)}, * emptied and translated into attributes by * {@link #closeTag(String)} */ private Hashtable tags; /** * store the names of font families before they are changed by openTag() */ private Stack/**/ fontFamilyStack; /** * if we aplly TextAttribute.SUPERSCRIPT with correction of * transformation the text is to high / to low by some points */ private double superscriptCorrection; /** * creates a tag handler for printing text and calculating its size * * @param graphics stores the font for calculations */ public GenericTagHandler(Graphics2D graphics) { super(); this.graphics = graphics; this.clearedText = new StringBuffer(); this.tags = new Hashtable(); } /** * prints the tagged string at x:y * * @param s string to print using the stored graphics * @param x coordinate for drawing * @param y coordinate for drawing * @param superscriptCorrection correction for to high / to low text */ public void print(TagString s, double x, double y, double superscriptCorrection) { fontFamilyStack = new Stack(); this.clearedText = new StringBuffer(); this.attributes = new Vector(); this.superscriptCorrection = superscriptCorrection; parse(s); // close all open tags to ensure all // open attributes are applied while (tags.size() > 0) { closeTag((String) tags.keys().nextElement()); } // create attributed string to print // with current font settings AttributedString attributedString = new AttributedString( clearedText.toString(), FontUtilities.getAttributes(graphics.getFont())); // aplly attributes for (int i = 0; i < attributes.size(); i++) { ((AttributeEntry)attributes.elementAt(i)).apply(attributedString); } graphics.drawString(attributedString.getIterator(), (float)x, (float)y); } /** * calculates the string bounds using the current font of {@link #graphics}. * * @param s string to calculate * @return bouding box after parsing s */ public TextLayout createTextLayout(TagString s, double superscriptCorrection) { fontFamilyStack = new Stack(); this.clearedText = new StringBuffer(); this.attributes = new Vector(); this.superscriptCorrection = superscriptCorrection; parse(s); // close all open tags to ensure all // open attributes are applied while (tags.size() > 0) { closeTag((String) tags.keys().nextElement()); } // create attributed string to print // with current font settings AttributedString attributedString = new AttributedString( clearedText.toString(), FontUtilities.getAttributes(graphics.getFont())); // aplly attributes for (int i = 0; i < attributes.size(); i++) { ((AttributeEntry)attributes.elementAt(i)).apply(attributedString); } // create the layout return new TextLayout( attributedString.getIterator(), graphics.getFontRenderContext()); } /** * handles bold , italic , superscript , subscript , * vertical , overline , underline , strikethrough , * underline dashed , underline dotted and typewriter * * @param tag one of the known tags, otherwise the overloaded methode is called * @return empty string or the result of the overloaded method */ // FIXME: check if we can support overline and vertical? protected String openTag(String tag) { // store position of parser for openening tag only if // it the first openened, e.g. texttext2 will draw // text and text2 in bold weight if (!tags.containsKey(tag)) { tags.put(tag, new Integer(clearedText.length())); } return ""; } /** * closes the given html tag. It doesn't matter, if that one was opened, so * closes a too, because the use the same TextAttribute.UNDERLINE. * * @param tag to close * @return empty string or the result of the overloaded method */ protected String closeTag(String tag) { // begin is stored in 'tags' int begin; // do nothing if tag wasn't opened if (!tags.containsKey(tag)) { return super.closeTag(tag); } else { begin = ((Integer)tags.get(tag)).intValue(); tags.remove(tag); } // change attributes if (tag.equalsIgnoreCase("b")) { this.attributes.add(new AttributeEntry( begin, clearedText.length(), TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD)); } else if (tag.equalsIgnoreCase("i")) { this.attributes.add(new AttributeEntry( begin, clearedText.length(), TextAttribute.POSTURE, TextAttribute.POSTURE_OBLIQUE)); } else if (tag.equalsIgnoreCase("s") || tag.equalsIgnoreCase("strike")) { this.attributes.add(new AttributeEntry( begin, clearedText.length(), TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON)); } else if (tag.equalsIgnoreCase("udash")) { this.attributes.add(new AttributeEntry( begin, clearedText.length(), TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_LOW_DASHED)); } else if (tag.equalsIgnoreCase("udot")) { this.attributes.add(new AttributeEntry( begin, clearedText.length(), TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_LOW_DOTTED)); } else if (tag.equalsIgnoreCase("u")) { this.attributes.add(new AttributeEntry( begin, clearedText.length(), TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON)); } else if (tag.equalsIgnoreCase("tt")) { this.attributes.add(new AttributeEntry( begin, clearedText.length(), TextAttribute.FAMILY, fontFamilyStack.pop())); } else if (tag.equalsIgnoreCase("v")) { // vertical = false; } else if (tag.equalsIgnoreCase("over")) { this.attributes.add(new AttributeEntry( begin, clearedText.length(), TextAttribute.UNDERLINE, UNDERLINE_OVERLINE)); } else if (tag.equalsIgnoreCase("sup")) { // FIXME: not quite clear why this is necessary this.attributes.add(new AttributeEntry( begin, clearedText.length(), TextAttribute.TRANSFORM, AffineTransform.getTranslateInstance(0, superscriptCorrection))); this.attributes.add(new AttributeEntry( begin, clearedText.length(), TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUPER)); } else if (tag.equalsIgnoreCase("sub")) { // FIXME: not quite clear why this is necessary this.attributes.add(new AttributeEntry( begin, clearedText.length(), TextAttribute.TRANSFORM, AffineTransform.getTranslateInstance(0, -superscriptCorrection))); this.attributes.add(new AttributeEntry( begin, clearedText.length(), TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUB)); } else { return super.closeTag(tag); } // set the font return ""; } /** * calculates miny und maxy for {@link #createTextLayout(TagString, double)}. If * {@link #print} is set, text is drawed using * {@link Graphics2D#drawString(String, float, float)} of * {@link #graphics} * * @param text text to draw * @return unmodified text parameter */ protected String text(String text) { // appand text as cleared clearedText.append(text); return text; } /** * Helper to store an TextAttribute, its value and the range * it should cover in text. Entries are created * by {@link GenericTagHandler#closeTag(String)} and apllied * in {@link GenericTagHandler#print(TagString, double, double, double)} */ private class AttributeEntry { /** * start offset in text */ private int begin; /** * end position for TextAttribute in text */ private int end; /** * the TextAttribute key to layout the text, * e.g. TextAttribute.WEIGHT */ private TextAttribute textAttribute; /** * the TextAttribute key to layout the text, * e.g. TextAttribute.WEIGHT_BOLD */ private Object value; /** * stores the given parameters * * @param begin * @param end * @param textAttribute * @param value */ protected AttributeEntry(int begin, int end, TextAttribute textAttribute, Object value) { this.begin = begin; this.end = end; this.textAttribute = textAttribute; this.value = value; } /** * apply the stored attributes to as * * @param as */ protected void apply(AttributedString as) { as.addAttribute(textAttribute, value, begin, end); } } } freehep-graphics2d-2.1.1/src/main/java/org/freehep/graphics2d/ArrayPath.java0000644012010301201030000001353310466735775027621 0ustar mascellanimascellani// Copyright 2004, FreeHEP. package org.freehep.graphics2d; import java.awt.Rectangle; import java.awt.Shape; import java.awt.geom.AffineTransform; import java.awt.geom.PathIterator; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; /** * This class can be used in a transient way to deal with the drawing or filling * of an array of double points as a polyline/polygon. The class implements a * shape and comes with an associated iterator. * * @author Mark Donszelmann * @version $Id: ArrayPath.java 8584 2006-08-10 23:06:37Z duns $ */ public class ArrayPath implements Shape { private class ArrayPathIterator implements PathIterator { private double[] xPoints, yPoints; private double lastX, lastY; private int nPoints; private boolean closed; private int resolution; private int currentPoint; private boolean isDone; private ArrayPathIterator(double[] xPoints, double[] yPoints, int nPoints, boolean closed, int resolution) { this.xPoints = xPoints; this.yPoints = yPoints; this.nPoints = nPoints; this.closed = closed; this.resolution = resolution; currentPoint = 0; isDone = nPoints == 0; } public boolean isDone() { return isDone; } public void next() { currentPoint++; while ((currentPoint < nPoints - 1) && (Math.abs(xPoints[currentPoint] - lastX) < resolution) && (Math.abs(yPoints[currentPoint] - lastY) < resolution)) { currentPoint++; } if (closed && (currentPoint == nPoints - 1) && (Math.abs(xPoints[currentPoint] - xPoints[0]) < resolution) && (Math.abs(yPoints[currentPoint] - yPoints[0]) < resolution)) { currentPoint++; // skip last point since it is same as first } isDone = (closed) ? currentPoint > nPoints : currentPoint >= nPoints; } public int currentSegment(double[] coords) { if (closed && (currentPoint == nPoints)) { return PathIterator.SEG_CLOSE; } coords[0] = lastX = xPoints[currentPoint]; coords[1] = lastY = yPoints[currentPoint]; return (currentPoint == 0) ? PathIterator.SEG_MOVETO : PathIterator.SEG_LINETO; } public int currentSegment(float[] coords) { if (closed && (currentPoint == nPoints)) { return PathIterator.SEG_CLOSE; } lastX = xPoints[currentPoint]; lastY = yPoints[currentPoint]; coords[0] = (float) lastX; coords[1] = (float) lastY; return (currentPoint == 0) ? PathIterator.SEG_MOVETO : PathIterator.SEG_LINETO; } public int getWindingRule() { return PathIterator.WIND_NON_ZERO; } } private double[] xPoints, yPoints; private int nPoints; private boolean closed; private int resolution; public ArrayPath(double[] xPoints, double[] yPoints, int nPoints, boolean closed, int resolution) { this.xPoints = xPoints; this.yPoints = yPoints; this.nPoints = nPoints; this.closed = closed; this.resolution = resolution; } public boolean contains(double x, double y) { // conservative guess return false; } public boolean contains(double x, double y, double w, double h) { // conservative guess return false; } public boolean contains(Point2D p) { return contains(p.getX(), p.getY()); } public boolean contains(Rectangle2D r) { return contains(r.getX(), r.getY(), r.getWidth(), r.getHeight()); } public boolean intersects(double x, double y, double w, double h) { // conservative guess return true; } public boolean intersects(Rectangle2D r) { return intersects(r.getX(), r.getY(), r.getWidth(), r.getHeight()); } public PathIterator getPathIterator(AffineTransform at, double flatness) { return getPathIterator(at); } public Rectangle2D getBounds2D() { double x1, y1, x2, y2; int i = nPoints; if (i > 0) { i--; y1 = y2 = yPoints[i]; x1 = x2 = xPoints[i]; while (i > 0) { i--; double y = yPoints[i]; double x = xPoints[i]; if (x < x1) x1 = x; if (y < y1) y1 = y; if (x > x2) x2 = x; if (y > y2) y2 = y; } } else { x1 = y1 = x2 = y2 = 0.0f; } return new Rectangle2D.Double(x1, y1, x2 - x1, y2 - y1); } public Rectangle getBounds() { return getBounds2D().getBounds(); } public PathIterator getPathIterator(AffineTransform t) { double[] transformedXPoints = xPoints; double[] transformedYPoints = yPoints; if (t != null) { // FIXME, this seems a silly slow way to deal with this. transformedXPoints = new double[nPoints]; transformedYPoints = new double[nPoints]; Point2D s = new Point2D.Double(); Point2D d = new Point2D.Double(); for (int i = 0; i < nPoints; i++) { s.setLocation(xPoints[i], yPoints[i]); t.transform(s, d); transformedXPoints[i] = d.getX(); transformedYPoints[i] = d.getY(); } } return new ArrayPathIterator(transformedXPoints, transformedYPoints, nPoints, closed, resolution); } } freehep-graphics2d-2.1.1/src/main/java/org/freehep/graphics2d/PixelGraphics2D.java0000644012010301201030000004631210535120331030624 0ustar mascellanimascellani// Copyright 2000-2006, FreeHEP. package org.freehep.graphics2d; 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.Graphics2D; import java.awt.GraphicsConfiguration; 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.Transparency; import java.awt.font.FontRenderContext; import java.awt.font.GlyphVector; import java.awt.geom.AffineTransform; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.awt.image.BufferedImageOp; import java.awt.image.ImageObserver; import java.awt.image.RenderedImage; import java.awt.image.renderable.RenderableImage; import java.awt.print.PrinterGraphics; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.text.AttributedCharacterIterator; import java.util.HashMap; import java.util.Map; import org.freehep.graphics2d.font.FontEncoder; /** * @author Charles Loomis * @author Mark Donszelmann * @version $Id: PixelGraphics2D.java 10115 2006-12-04 22:27:37Z duns $ */ public class PixelGraphics2D extends AbstractVectorGraphics { public final static RenderingHints.Key KEY_SYMBOL_BLIT = new SymbolBlitKey(); public final static Object VALUE_SYMBOL_BLIT_ON = Boolean.TRUE; public final static Object VALUE_SYMBOL_BLIT_OFF = Boolean.FALSE; static class SymbolBlitKey extends RenderingHints.Key { public SymbolBlitKey() { super(94025); } public boolean isCompatibleValue(Object o) { if (o.equals(VALUE_SYMBOL_BLIT_ON)) return true; if (o.equals(VALUE_SYMBOL_BLIT_OFF)) return true; return false; } public String toString() { return "Symbol Blitting enable key"; } } // The host graphics context. protected Graphics2D hostGraphics; protected double lineWidth; protected int resolution; // tag handler protected GenericTagHandler tagHandler; // fast symbol handling, FIXME: does not work for fillAndDraw private static final int MAX_BLIT_SIZE = 32; private static Map /* */symbols; private WebColor webColor; // graphics environment stuff private static boolean displayX11; private static boolean displayLocal; static { symbols = new HashMap(); displayX11 = false; displayLocal = false; try { Class clazz = Class.forName("sun.awt.X11GraphicsEnvironment"); displayX11 = true; Method method = clazz.getMethod("isDisplayLocal", null); Boolean result = (Boolean) method.invoke(null, null); displayLocal = result.booleanValue(); } catch (ClassNotFoundException e) { // Windows case... displayLocal = true; } catch (IllegalAccessException e) { // ignored } catch (NoSuchMethodException e) { // ignored } catch (InvocationTargetException e) { // ignored } catch (ClassCastException e) { // ignored } catch (SecurityException e) { // ignored } } public PixelGraphics2D(Graphics graphics) { this(); setHostGraphics(graphics); } /** */ protected PixelGraphics2D(PixelGraphics2D graphics) { super(graphics); setHostGraphics(graphics.hostGraphics.create()); } /** * Constructor for the case that you only know the hostgraphics later on. * NOTE: make sure you call setHostGraphics afterwards. */ protected PixelGraphics2D() { super(); } protected void setHostGraphics(Graphics graphics) { hostGraphics = (Graphics2D) graphics; resolution = (graphics instanceof PrinterGraphics) ? 0 : 1; tagHandler = new GenericTagHandler(hostGraphics); super.setBackground(hostGraphics.getBackground()); super.setColor(hostGraphics.getColor()); super.setPaint(hostGraphics.getPaint()); super.setFont(hostGraphics.getFont()); Stroke s = hostGraphics.getStroke(); if (s instanceof BasicStroke) { lineWidth = ((BasicStroke) s).getLineWidth(); } webColor = WebColor.create(getColor()); setRenderingHint(KEY_SYMBOL_BLIT, VALUE_SYMBOL_BLIT_ON); } public void startExport() { } public void endExport() { } public void printComment(String comment) { } public Graphics create(double x, double y, double width, double height) { PixelGraphics2D graphics = new PixelGraphics2D(this); graphics.translate(x, y); graphics.clipRect(0, 0, width, height); return graphics; } // // // The methods which follow are those necessary for the Graphics // and Graphics2D contexts. These simply call the appropriate // method on the underlying graphics context. // // public void clearRect(int x, int y, int width, int height) { hostGraphics.clearRect(x, y, width, height); } public void clipRect(int x, int y, int width, int height) { hostGraphics.clipRect(x, y, width, height); } public void copyArea(int x, int y, int width, int height, int dx, int dy) { hostGraphics.copyArea(x, y, width, height, dx, dy); } public Graphics create() { return new PixelGraphics2D(this); } public void dispose() { hostGraphics.dispose(); } public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) { hostGraphics.drawArc(x, y, width, height, startAngle, arcAngle); } public boolean drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer) { return hostGraphics.drawImage(img, x, y, getPrintColor(bgcolor), observer); } public boolean drawImage(Image img, int x, int y, ImageObserver observer) { return hostGraphics.drawImage(img, x, y, observer); } public boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer) { return hostGraphics.drawImage(img, x, y, width, height, getPrintColor(bgcolor), observer); } public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer) { return hostGraphics.drawImage(img, x, y, width, height, observer); } 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) { return hostGraphics.drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, getPrintColor(bgcolor), observer); } public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer) { return hostGraphics.drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, observer); } public void drawLine(int x1, int y1, int x2, int y2) { hostGraphics.drawLine(x1, y1, x2, y2); } public void drawOval(int x, int y, int width, int height) { hostGraphics.drawOval(x, y, width, height); } public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints) { hostGraphics.drawPolygon(xPoints, yPoints, nPoints); } public void drawPolygon(Polygon p) { hostGraphics.drawPolygon(p); } public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints) { hostGraphics.drawPolyline(xPoints, yPoints, nPoints); } public void drawRect(int x, int y, int width, int height) { hostGraphics.drawRect(x, y, width, height); } public void drawString(String str, int x, int y) { str = FontEncoder.getEncodedString(str, getFont().getName()); hostGraphics.drawString(str, x, y); } public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) { hostGraphics.fillArc(x, y, width, height, startAngle, arcAngle); } public void fillOval(int x, int y, int width, int height) { hostGraphics.fillOval(x, y, width, height); } public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) { hostGraphics.fillPolygon(xPoints, yPoints, nPoints); } public void fillPolygon(Polygon p) { hostGraphics.fillPolygon(p); } public void fillRect(int x, int y, int width, int height) { hostGraphics.fillRect(x, y, width, height); } public void drawSymbol(double x, double y, double size, int symbol) { if (size <= 0) return; int intSize = (int) Math.ceil(size); if ((intSize > MAX_BLIT_SIZE) || (lineWidth != 1.0) || !isDisplayLocal() || (getRenderingHint(RenderingHints.KEY_ANTIALIASING) == RenderingHints.VALUE_ANTIALIAS_ON) || (getRenderingHint(KEY_SYMBOL_BLIT) == VALUE_SYMBOL_BLIT_OFF)) { super.drawSymbol(x, y, size, symbol); return; } blitSymbol(x, y, intSize, symbol, false); } public void fillSymbol(double x, double y, double size, int symbol) { if (size <= 0) return; int intSize = (int) Math.ceil(size); if ((intSize > MAX_BLIT_SIZE) || (lineWidth != 1.0) || !isDisplayLocal() || (getRenderingHint(RenderingHints.KEY_ANTIALIASING) == RenderingHints.VALUE_ANTIALIAS_ON) || (getRenderingHint(KEY_SYMBOL_BLIT) == VALUE_SYMBOL_BLIT_OFF)) { super.fillSymbol(x, y, size, symbol); return; } blitSymbol(x, y, intSize, symbol, true); } // FIXME: overridden to avoid blitting public void fillAndDrawSymbol(double x, double y, double size, int symbol, Color fillColor) { Color color = getColor(); setColor(fillColor); super.fillSymbol(x, y, size, symbol); setColor(color); super.drawSymbol(x, y, size, symbol); } private void blitSymbol(double x, double y, int size, int symbol, boolean fill) { Image[][][] images = (Image[][][]) symbols.get(webColor); if (images == null) { images = new Image[2][NUMBER_OF_SYMBOLS][MAX_BLIT_SIZE]; symbols.put(webColor, images); } Image image = images[fill ? 1 : 0][symbol][size - 1]; int imageSize = size + 1; double imageSize2 = imageSize / 2.0; if (image == null) { image = getDeviceConfiguration().createCompatibleImage( imageSize + 1, imageSize + 1, Transparency.BITMASK); VectorGraphics imageGraphics = VectorGraphics.create(image .getGraphics()); Composite composite = imageGraphics.getComposite(); imageGraphics.setComposite(AlphaComposite.Clear); imageGraphics.fillRect(0, 0, size, size); imageGraphics.setComposite(composite); imageGraphics.setColor(getColor()); if (fill) { fillSymbol(imageGraphics, imageSize2, imageSize2, size, symbol); } else { drawSymbol(imageGraphics, imageSize2, imageSize2, size, symbol); } images[fill ? 1 : 0][symbol][size - 1] = image; } drawImage(image, (int) (x - imageSize2), (int) (y - imageSize2), null); } public void setLineWidth(double width) { super.setLineWidth(width); lineWidth = width; } public Shape getClip() { return hostGraphics.getClip(); } public Rectangle getClipBounds() { return hostGraphics.getClipBounds(); } public Rectangle getClipBounds(Rectangle r) { return hostGraphics.getClipBounds(r); } public FontMetrics getFontMetrics(Font f) { return hostGraphics.getFontMetrics(f); } public void setClip(int x, int y, int width, int height) { hostGraphics.setClip(x, y, width, height); } public void setClip(Shape clip) { hostGraphics.setClip(clip); } public void setFont(Font font) { if (font == null) return; super.setFont(font); if (font.getName().equals("Symbol") || font.getName().equals("ZapfDingbats")) { Font newFont = new Font("Serif", font.getSize(), font.getStyle()); font = newFont.deriveFont(font.getSize2D()); } hostGraphics.setFont(font); } public void setColor(Color color) { if (color == null) return; if (color.equals(getColor())) return; super.setColor(color); hostGraphics.setColor(getPrintColor(color)); webColor = WebColor.create(color); } public void setPaint(Paint paint) { if (paint == null) return; if (paint.equals(getPaint())) return; if (paint instanceof Color) { setColor((Color) paint); } else { super.setPaint(paint); hostGraphics.setPaint(paint); } } public void setPaintMode() { hostGraphics.setPaintMode(); } public void setXORMode(Color c1) { hostGraphics.setXORMode(getPrintColor(c1)); } public void translate(int x, int y) { hostGraphics.translate(x, y); } // // // The ones from the Graphic2D context. This overrides some // methods defined in VectorGraphics2D by simply calling the // underlying host graphics context. // // public void addRenderingHints(Map hints) { hostGraphics.addRenderingHints(hints); } public void clip(Shape clip) { hostGraphics.clip(clip); } public void draw(Shape s) { hostGraphics.draw(s); } public void drawGlyphVector(GlyphVector g, float x, float y) { hostGraphics.drawGlyphVector(g, x, y); } public void drawImage(BufferedImage img, BufferedImageOp op, int x, int y) { hostGraphics.drawImage(img, op, x, y); } public boolean drawImage(Image img, AffineTransform xform, ImageObserver obs) { return hostGraphics.drawImage(img, xform, obs); } public void drawRenderableImage(RenderableImage img, AffineTransform xform) { hostGraphics.drawRenderableImage(img, xform); } public void drawRenderedImage(RenderedImage img, AffineTransform xform) { hostGraphics.drawRenderedImage(img, xform); } public void drawString(AttributedCharacterIterator iterator, float x, float y) { hostGraphics.drawString(iterator, x, y); } public void drawString(AttributedCharacterIterator iterator, int x, int y) { hostGraphics.drawString(iterator, x, y); } public void drawString(String str, float x, float y) { str = FontEncoder.getEncodedString(str, getFont().getName()); hostGraphics.drawString(str, x, y); } public void fill(Shape s) { hostGraphics.fill(s); } public Composite getComposite() { return hostGraphics.getComposite(); } public GraphicsConfiguration getDeviceConfiguration() { return hostGraphics.getDeviceConfiguration(); } public FontRenderContext getFontRenderContext() { return hostGraphics.getFontRenderContext(); } public Object getRenderingHint(RenderingHints.Key hintKey) { return hostGraphics.getRenderingHint(hintKey); } public RenderingHints getRenderingHints() { return hostGraphics.getRenderingHints(); } public Stroke getStroke() { return hostGraphics.getStroke(); } public AffineTransform getTransform() { return hostGraphics.getTransform(); } public boolean hit(Rectangle rect, Shape s, boolean onStroke) { return hostGraphics.hit(rect, s, onStroke); } public void rotate(double theta) { hostGraphics.rotate(theta); } public void rotate(double theta, double x, double y) { hostGraphics.rotate(theta, x, y); } public void scale(double sx, double sy) { hostGraphics.scale(sx, sy); } public void setBackground(Color color) { super.setBackground(color); hostGraphics.setBackground(getPrintColor(color)); } public void setComposite(Composite comp) { hostGraphics.setComposite(comp); } public void setRenderingHint(RenderingHints.Key hintKey, Object hintValue) { hostGraphics.setRenderingHint(hintKey, hintValue); } public void setRenderingHints(Map hints) { hostGraphics.setRenderingHints(hints); } public void setStroke(Stroke s) { hostGraphics.setStroke(s); } public void setTransform(AffineTransform Tx) { hostGraphics.setTransform(Tx); } public void shear(double shx, double shy) { hostGraphics.shear(shx, shy); } public void transform(AffineTransform Tx) { hostGraphics.transform(Tx); } public void translate(double tx, double ty) { hostGraphics.translate(tx, ty); } // // // The following methods are those specific to the VectorGraphics // interfaces, but which are simple extensions of integer method // calls to doubles. // // public void clearRect(double x, double y, double width, double height) { clearRect((int) x, (int) y, (int) width, (int) height); } public void clipRect(double x, double y, double width, double height) { clipRect((int) x, (int) y, (int) width, (int) height); } public void drawString(String str, double x, double y) { drawString(str, (int) Math.round(x), (int) Math.round(y)); } public void setClip(double x, double y, double width, double height) { setClip(new Rectangle2D.Double(x, y, width, height)); } public String toString() { return "PixelGraphics2D[" + hostGraphics.toString() + "]"; } public static boolean isDisplayX11() { return displayX11; } public static boolean isDisplayLocal() { return displayLocal; } /** * Implementation of createShape makes sure that the points are different by * at least one pixel. */ protected Shape createShape(double[] xPoints, double[] yPoints, int nPoints, boolean close) { return new ArrayPath(xPoints, yPoints, nPoints, close, resolution); } /* * protected GeneralPath createShape(double[] xPoints, double[] yPoints, int * nPoints, boolean close) { GeneralPath path = new * GeneralPath(GeneralPath.WIND_EVEN_ODD); if (nPoints > 0) { * path.moveTo((float)xPoints[0], (float)yPoints[0]); double lastX = * xPoints[0]; double lastY = yPoints[0]; if (close && * (Math.abs(xPoints[nPoints-1] - lastX) < resolution) && * (Math.abs(yPoints[nPoints-1] - lastY) < resolution)) { nPoints--; } for * (int i = 1; i < nPoints; i++) { if ((Math.abs(xPoints[i] - lastX) > * resolution) || (Math.abs(yPoints[i] - lastY) > resolution)) { * path.lineTo((float)xPoints[i], (float)yPoints[i]); lastX = xPoints[i]; * lastY = yPoints[i]; } } if (close) path.closePath(); } return path; } */ } freehep-graphics2d-2.1.1/src/main/java/org/freehep/graphics2d/BufferedPanel.java0000644012010301201030000002136110466735775030426 0ustar mascellanimascellani// Copyright (c) 2003-2004, FreeHEP package org.freehep.graphics2d; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Image; import java.awt.image.BufferedImage; import java.awt.print.PrinterGraphics; import javax.swing.JPanel; /** * This class extends JPanel by adding double buffering. This is intended to be * used in situations in which redrawing the contents of the panel is expensive. * * @author Mark Donszelmann * @version $Id: BufferedPanel.java 8584 2006-08-10 23:06:37Z duns $ */ public class BufferedPanel extends JPanel implements java.io.Serializable { private VectorGraphics offScreenGraphics; private Image offScreenImage; private Dimension oldDimension = new Dimension(); private Dimension dim = new Dimension(); // FREEHEP-503 Disabled, since in Linux this made the blitting very // slow. // private Rectangle clip = new Rectangle(); private boolean printing = false; private boolean exporting = false; private boolean repaint = false; public BufferedPanel() { this(true); } /** * Creates a new BufferedPanel with a width and height set to zero. * * @param opaque transparent panel */ public BufferedPanel(boolean opaque) { // First turn off the Swing double buffering. super(false); // Make this either opaque or transparent. setOpaque(opaque); } /** * Triggers a full "user" repaint. If the "system" wants to repaint it will * call the paint(Graphics) method directly, rather than scheduling a * paint(Graphics) through a repaint(). */ public void repaint() { super.repaint(); repaint = true; } /** * Triggers a full repaint, since the component is not valid anymore (size * change, iconized, ...) */ public void invalidate() { super.invalidate(); repaint = true; } /** * Returns if true if paintComponent(VectorGraphics) should be called (was * triggered by a repaint() or invalidate(), and resets the trigger. */ private synchronized boolean shouldRepaint() { boolean result = repaint; repaint = false; return result; } /** * Paint this panel by calling paintComponent(VectorGraphics) if necessary * and flushing the buffered image to the screen. This method also handles * printing and exporting separately. * * @param g Graphics object */ public void paintComponent(Graphics g) { super.paintComponent(g); // do not paint if params are null if ((g == null) || (offScreenImage == null)) return; // decide where we are painting if (g instanceof PrinterGraphics) printing = true; if (g instanceof VectorGraphics) exporting = true; if (!isDisplaying()) { paintComponent(VectorGraphics.create(g)); return; } if (shouldRepaint()) { paintComponent(offScreenGraphics); } // copy buffer to screen //long t0 = System.currentTimeMillis(); /* * FREEHEP-503 Disabled, since in Linux this made the blitting very * slow. * * Despite what the API documentation says, getClipBounds() * returns the current dirty region. This can then be used to speedup * the drawing of the BufferedPanel. */ // clip = g.getClipBounds(clip); // Make sure the clip is not larger than the bounds. // clip = clip.intersection(getBounds()); // BufferedImage bufferedImage = (BufferedImage)offScreenImage; // BufferedImage subimage = bufferedImage.getSubimage(clip.x,clip.y, // clip.width,clip.height); boolean done = // g.drawImage(subimage,clip.x,clip.y,this); /* boolean done = */ g.drawImage(offScreenImage, 0, 0, this); // System.err.println("CopyImage "+done+" took: // "+(System.currentTimeMillis()-t0)+" ms."); } /** * Returns a pointer to the graphics (VectorGraphics) context of the buffer. * The user is NOT allowed to call dispose() on this graphics object. *

* NOTE: this method used to be called getGraphics, however, since the JVM * paint thread may call getGraphics from paintImmediately and fails to work * with our VectorGraphics context (the gc is not longer attached to the * image), we decided to rename the method. */ public Graphics getBufferedGraphics() { return offScreenGraphics; } /** * Allows for custom graphics to be painted. Subclasses should implement * real drawing here. They can ask isPrinting(), isExporting() or * isDisplaying() to see where the output goes. If painting is done to a * display it is done to a buffer which is kept and copied afterwards. * * Note that the parameter here is of class VectorGraphics rather than * Graphics. */ public void paintComponent(VectorGraphics vg) { } /** * Resize and move a component. */ public void setBounds(int x, int y, int w, int h) { // Make sure that the parent's method is called first; // otherwise, the resize never happens and new images are NOT // made. super.setBounds(x, y, w, h); // FREEHEP-503 Disabled, since in Linux this made the blitting very // slow. // clip = new Rectangle(x, y, w, h); // Make the backing image. makeImage(); } /** * Returns true if the drawing is made for a PrinterGraphics context. */ public boolean isPrinting() { return printing; } /** * Returns true if the drawing is made for a VectorGraphics context. */ public boolean isExporting() { return exporting; } /** * Returns true if the drawing is made for a PixelGraphics context, the * display. True if not Printing and not Exporting. */ public boolean isDisplaying() { return ((!isExporting()) && (!isPrinting())); } /** * Make the buffered image for this panel. Check to see if the size has * changed before doing anything. */ private void makeImage() { // Get the full size of the panel. dim = getSize(dim); // Check that the current size is positive and that the new // dimension is not equal to the old one. if (dim.width > 0 && dim.height > 0) { if (!oldDimension.equals(dim)) { // allocate an Image, which from before JDK 1.4 was always in // System Memory, // and from JDK 1.4 is a Managed Buffered Image in System memory // or VRAM (Windows) // or a BufferedImage (getClass always returns BufferedImage) // Real BufferedImages resides in System Memory. // Volatile Images reside in VRAM (Windows), or XServer memory. // Drawing more than ~1000 line segments to system memory (BI) // and // doing a copy to the display is faster than drawing them // to video ram (VI) and using the fast VRAM->display copy. // For us, System Memory is the choice for both Windows and // XWindows, // since we draw more lines that copying. // However, it may be that the acceleration possible on VRAM my // up this // 1000 line limit. // The image created here is a Managed Buffered Image, which can // be moved // from System Memory and copied to VRAM... // Use the flag -Dsun.java2d.ddoffscreen=false to keep the image // in // system memory, or -Dsun.java2d.ddforcevram=true to keep the // image // in VRAM. Using none, seems to affect performance in picking // mode. // There is no programmatic (java) way of keeping the image in // system memory, not even if you create a BufferedImage // explicitly. if (isOpaque()) { offScreenImage = super.createImage(dim.width, dim.height); } else { offScreenImage = new BufferedImage(dim.width, dim.height, BufferedImage.TYPE_INT_ARGB); } offScreenGraphics = VectorGraphics.create(offScreenImage .getGraphics()); // Reset the old size of this panel. oldDimension.setSize(dim); } } else { offScreenImage = null; offScreenGraphics = null; } } } freehep-graphics2d-2.1.1/src/main/java/overview.html0000644012010301201030000000146310535761637023354 0ustar mascellanimascellani This is the API specification of the FreeHEP VectorGraphics package.

The VectorGraphics library is in general split in two layers. The bottom layer implements writing (and in some cases reading) of a specific format, while the top-layer implements writing in terms of java.awt.Graphics2D.

Base classes are provided in the freehep-graphics2d package. This package also includes bitmap formats and the screen driver.

The derived freehep-graphicsio package implements common functionality for vectorgraphics.

Each format is defined in its own freehep-graphicsio-<fmt> package, which also contains the classes to write (and in some cases read) the format.

The freehep-graphicsio-tests package defines a set of standard tests which can be run for each of the formats.

freehep-graphics2d-2.1.1/src/main/resources/0000755012010301201030000000000011300042227021657 5ustar mascellanimascellanifreehep-graphics2d-2.1.1/src/main/encoding/0000755012010301201030000000000011300042227021433 5ustar mascellanimascellanifreehep-graphics2d-2.1.1/src/main/encoding/Expert.utf-160000644012010301201030000001762210341714743023673 0ustar mascellanimascellani## ## ## @author Mark Donszelmann ## @version $Id$ ## ## ## Expert Set ## \uF7E6 AEsmall 0276 \uF7E1 Aacutesmall 0207 \uF7E2 Acircumflexsmall 0211 \uF7B4 Acutesmall 0047 \uF7E4 Adieresissmall 0212 \uF7E0 Agravesmall 0210 \uF7E5 Aringsmall 0214 \uF761 Asmall 0141 \uF7E3 Atildesmall 0213 \uF6F4 Brevesmall 0363 \uF762 Bsmall 0142 \uF6F5 Caronsmall 0256 \uF7E7 Ccedillasmall 0215 \uF7B8 Cedillasmall 0311 \uF6F6 Circumflexsmall 0136 \uF763 Csmall 0143 \uF7A8 Dieresissmall 0254 \uF6F7 Dotaccentsmall 0372 \uF764 Dsmall 0144 \uF7E9 Eacutesmall 0216 \uF7EA Ecircumflexsmall 0220 \uF7EB Edieresissmall 0221 \uF7E8 Egravesmall 0217 \uF765 Esmall 0145 \uF7F0 Ethsmall 0104 \uF766 Fsmall 0146 \uF760 Gravesmall 0140 \uF767 Gsmall 0147 \uF768 Hsmall 0150 \uF6F8 Hungarumlautsmall 0042 \uF7ED Iacutesmall 0222 \uF7EE Icircumflexsmall 0224 \uF7EF Idieresissmall 0225 \uF7EC Igravesmall 0223 \uF769 Ismall 0151 \uF76A Jsmall 0152 \uF76B Ksmall 0153 \uF6F9 Lslashsmall 0302 \uF76C Lsmall 0154 \uF7AF Macronsmall 0364 \uF76D Msmall 0155 \uF76E Nsmall 0156 \uF7F1 Ntildesmall 0226 \uF6FA OEsmall 0317 \uF7F3 Oacutesmall 0227 \uF7F4 Ocircumflexsmall 0231 \uF7F6 Odieresissmall 0232 \uF6FB Ogoneksmall 0362 \uF7F2 Ogravesmall 0230 \uF7F8 Oslashsmall 0277 \uF76F Osmall 0157 \uF7F5 Otildesmall 0233 \uF770 Psmall 0160 \uF771 Qsmall 0161 \uF6FC Ringsmall 0373 \uF772 Rsmall 0162 \uF6FD Scaronsmall 0247 \uF773 Ssmall 0163 \uF7FE Thornsmall 0271 \uF6FE Tildesmall 0176 \uF774 Tsmall 0164 \uF7FA Uacutesmall 0234 \uF7FB Ucircumflexsmall 0236 \uF7FC Udieresissmall 0237 \uF7F9 Ugravesmall 0235 \uF775 Usmall 0165 \uF776 Vsmall 0166 \uF777 Wsmall 0167 \uF778 Xsmall 0170 \uF7FD Yacutesmall 0264 \uF7FF Ydieresissmall 0330 \uF779 Ysmall 0171 \uF6FF Zcaronsmall 0275 \uF77A Zsmall 0172 ` ampersandsmall 0046 \uF6E9 asuperior 0201 \uF6EA bsuperior 0365 \uF6DF centinferior 0251 \uF7A2 centoldstyle 0043 \uF6E0 centsuperior 0202 : colon 0072 colonmonetary 0173 , comma 0054 \uF6E1 commainferior 0262 \uF6E2 commasuperior 0370 \uF6E3 dollarinferior 0266 \uF724 dollaroldstyle 0044 \uF6E4 dollarsuperior 0045 \uF6EB dsuperior 0353 eightinferior 0245 \uF738 eightoldstyle 0070 x eightsuperior 0241 \uF6EC esuperior 0344 \uF7A1 exclamdownsmall 0326 W exclamsmall 0041 ff 0126  ffi 0131  ffl 0132  fi 0127  figuredash 0320 ]! fiveeighths 0114 fiveinferior 0260 \uF735 fiveoldstyle 0065 u fivesuperior 0336  fl 0130 fourinferior 0242 \uF734 fouroldstyle 0064 t foursuperior 0335 D fraction 0057 - hyphen 0055 hypheninferior 0137 { hyphensuperior 0321 \uF6ED isuperior 0351 \uF6EE lsuperior 0361 \uF6EF msuperior 0367 nineinferior 0273 \uF739 nineoldstyle 0071 y ninesuperior 0341  nsuperior 0366 $ onedotenleader 0053 [! oneeight 0112 \uF6DC onefitted 0174 onehalf 0110 oneinferior 0301 \uF731 oneoldstyle 0061 onequarter 0107 onesuperior 0332 S! onethird 0116 \uF6F0 osuperior 0257 parenleftinferior 0133 } parenleftsuperior 0050 parenrightinferior 0135 ~ parenrightsuperior 0051 . period 0056 \uF6E7 periodinferior 0263 \uF6E8 periodsuperior 0371 \uF7BF questiondownsmall 0300 V questionsmall 0077 \uF6F1 rsuperior 0345 \uF6DD rupiah 0175 ; semicolon 0073 ^! seveneighths 0115 seveninferior 0246 \uF737 sevenoldstyle 0067 w sevensuperior 0340 sixinferior 0244 \uF736 sixoldstyle 0066 v sixsuperior 0337 \u0020 space 0040 \uF6F2 ssuperior 0352 \! threeeighths 0113 threeinferior 0243 \uF733 threeoldstyle 0063 threequarters 0111 X threequartersemdash 0075 threesuperior 0334 \uF6F3 tsuperior 0346 % twodotenleader 0052 twoinferior 0252 \uF732 twooldstyle 0062 twosuperior 0333 T! twothirds 0117 zeroinferior 0274 \uF730 zerooldstyle 0060 p zerosuperior 0342 freehep-graphics2d-2.1.1/src/main/encoding/Symbol.utf-160000644012010301201030000001626010341714743023666 0ustar mascellanimascellani## ## @author Mark Donszelmann ## @version $Id$ ## ## ## Symbol Set ##  Alpha 0101  Beta 0102  Chi 0103  Delta 0104  Epsilon 0105  Eta 0110 Euro 0240  Gamma 0107 ! Ifraktur 0301  Iota 0111  Kappa 0113  Lambda 0114  Mu 0115  Nu 0116  Omega 0127  Omicron 0117  Phi 0106  Pi 0120  Psi 0131 ! Rfractur 0302  Rho 0122  Sigma 0123  Tau 0124  Theta 0121 Y Upsilon 0125  Upsilon1 0241  Xi 0130  Zeta 0132 5! aleph 0300  alpha 0141 & ampersand 0046 " angle 0320 )# angleleft 0341 *# angleright 0361 H" approxequal 0273 ! arrowboth 0253 ! arrowdblboth 0333 ! arrowdbldown 0337 ! arrowdblleft 0334 ! arrowdblright 0336 ! arrowdblup 0335 ! arrowdown 0257 \uF8E7 arrowhorizex 0276 ! arrowleft 0254 ! arrowright 0256 ! arrowup 0255 \uF8E8 arrowvertex 0275 " asteriskmath 0052 | bar 0174  beta 0142 { braceleft 0173 } braceright 0175 \uF8F1 bracelefttp 0354 \uF8F2 braceleftmid 0355 \uF8F3 braceleftbt 0356 \uF8FC bracerighttp 0374 \uF8FD bracerightmid 0375 \uF8FE bracerightbt 0376 \uF8F4 braceex 0357 [ bracketleft 0133 ] bracketright 0135 \uF8EE bracketlefttp 0351 \uF8EF bracketleftex 0352 \uF8F0 bracketleftbt 0353 \uF8F9 bracketrighttp 0371 \uF8FA bracketrightex 0372 \uF8FB bracketrightbt 0373 " bullet 0267 ! carriagereturn 0277  chi 0143 " circlemultiply 0304 " circleplus 0305 c& club 0247 : colon 0072 , comma 0054 E" congruent 0100 \uF8E9 copyrightsans 0343 \uF6D9 copyrightserif 0323 degree 0260  delta 0144 f& diamond 0250 divide 0270 " dotmath 0327 8 eight 0070 " element 0316 & ellipsis 0274 " emptyset 0306  epsilon 0145 = equal 0075 a" equivalence 0272  eta 0150 ! exclam 0041 " existential 0044 5 five 0065  florin 0246 4 four 0064 D fraction 0244  gamma 0147 " gradient 0321 > greater 0076 e" greaterequal 0263 `& heart 0251 " infinity 0245 +" integral 0362 # integraltp 0363 \uF8F5 integralex 0364 !# integralbt 0365 )" intersection 0307  iota 0151  kappa 0153  lambda 0154 < less 0074 d" lessequal 0243 '" logicaland 0331 logicalnot 0330 (" logicalor 0332 % lozenge 0340 " minus 0055 2 minute 0242  mu 0155 multiply 0264 9 nine 0071 " notelement 0317 `" notequal 0271 " notsubset 0313  nu 0156 # numbersign 0043  omega 0167  omega1 0166  omicron 0157 1 one 0061 ( parenleft 0050 ) parenright 0051 \uF8EB parenlefttp 0346 \uF8EC parenleftex 0347 \uF8ED parenleftbt 0350 \uF8F6 parenrighttp 0366 \uF8F7 parenrightex 0367 \uF8F8 parenrightbt 0370 " partialdiff 0266 % percent 0045 . period 0056 " perpendicular 0136  phi 0146  phi1 0152  pi 0160 + plus 0053 plusminus 0261 " product 0325 " propersubset 0314 " propersuperset 0311 " proportional 0265  psi 0171 ? question 0077 " radical 0326 \uF8E5 radicalex 0140 " reflexsubset 0315 " reflexsuperset 0312 \uF8E8 registersans 0342 \uF6DA registerserif 0322  rho 0162 3 second 0262 ; semicolon 0073 7 seven 0067  sigma 0163  sigma1 0126 <" similar 0176 6 six 0066 / slash 0057 \u0020 space 0040 `& spade 0252 " suchthat 0047 " summation 0345  tau 0164 4" therefore 0134  theta 0161  theta1 0112 3 three 0063 \uF8EA trademarksans 0344 \uF6DB trademarkserif 0324 2 two 0062 _ underscore 0137 *" union 0310 " universal 0042  upsilon 0165 ! weierstrass 0303  xi 0170 0 zero 0060  zeta 0172 freehep-graphics2d-2.1.1/src/main/encoding/Zapfdingbats.utf-160000644012010301201030000001222010341714743025025 0ustar mascellanimascellani## ## @author Mark Donszelmann ## @version $Id$ ## ## ## ZapfDingbats Set ## \u0020 space 0040 ' a1 0041 ' a2 0042 ' a202 0043 ' a3 0044 & a4 0045 ' a5 0046 ' a119 0047 ' a118 0050 ' a117 0051 & a11 0052 & a12 0053 ' a13 0054 ' a14 0055 ' a15 0056 ' a16 0057 ' a105 0060 ' a17 0061 ' a18 0062 ' a19 0063 ' a20 0064 ' a21 0065 ' a22 0066 ' a23 0067 ' a24 0070 ' a25 0071 ' a26 0072 ' a27 0073 ' a28 0074 ' a6 0075 ' a7 0076 ' a8 0077 ' a9 0100 !' a10 0101 "' a29 0102 #' a30 0103 $' a31 0104 %' a32 0105 &' a33 0106 '' a34 0107 & a35 0110 )' a36 0111 *' a37 0112 +' a38 0113 ,' a39 0114 -' a40 0115 .' a41 0116 /' a42 0117 0' a43 0120 1' a44 0121 2' a45 0122 3' a46 0123 4' a47 0124 5' a48 0125 6' a49 0126 7' a50 0127 8' a51 0130 9' a52 0131 :' a53 0132 ;' a54 0133 <' a55 0134 =' a56 0135 >' a57 0136 ?' a58 0137 @' a59 0140 A' a60 0141 B' a61 0142 C' a62 0143 D' a63 0144 E' a64 0145 F' a65 0146 G' a66 0147 H' a67 0150 I' a68 0151 J' a69 0152 K' a70 0153 % a71 0154 M' a72 0155 % a73 0156 O' a74 0157 P' a203 0160 Q' a75 0161 R' a204 0162 % a76 0163 % a77 0164 % a78 0165 V' a79 0166 % a81 0167 X' a82 0170 Y' a83 0171 Z' a84 0172 [' a97 0173 \' a98 0174 ]' a99 0175 ^' a100 0176 a' a101 0241 b' a102 0242 c' a103 0243 d' a104 0244 e' a106 0245 f' a107 0246 g' a108 0247 c& a112 0250 f& a111 0251 e& a110 0252 `& a109 0253 `$ a120 0254 a$ a121 0255 b$ a122 0256 c$ a123 0257 d$ a124 0260 e$ a125 0261 f$ a126 0262 g$ a127 0263 h$ a128 0264 i$ a129 0265 v' a130 0266 w' a131 0267 x' a132 0270 y' a133 0271 z' a134 0272 {' a135 0273 |' a136 0274 }' a137 0275 ~' a138 0276 ' a139 0277 ' a140 0300 ' a141 0301 ' a142 0302 ' a143 0303 ' a144 0304 ' a145 0305 ' a146 0306 ' a147 0307 ' a148 0310 ' a149 0311 ' a150 0312 ' a151 0313 ' a152 0314 ' a153 0315 ' a154 0316 ' a155 0317 ' a156 0320 ' a157 0321 ' a158 0322 ' a159 0323 ' a160 0324 ! a161 0325 ! a163 0326 ! a164 0327 ' a196 0330 ' a165 0331 ' a192 0332 ' a166 0333 ' a167 0334 ' a168 0335 ' a169 0336 ' a170 0337 ' a171 0340 ' a172 0341 ' a173 0342 ' a162 0343 ' a174 0344 ' a175 0345 ' a176 0346 ' a177 0347 ' a178 0350 ' a179 0351 ' a193 0352 ' a180 0353 ' a199 0354 ' a181 0355 ' a200 0356 ' a182 0357 ' a201 0361 ' a183 0362 ' a184 0363 ' a197 0364 ' a185 0365 ' a194 0366 ' a198 0367 ' a186 0370 ' a195 0371 ' a187 0372 ' a188 0373 ' a189 0374 ' a190 0375 ' a191 0376 freehep-graphics2d-2.1.1/src/main/encoding/Latin.utf-160000644012010301201030000004013610341714743023467 0ustar mascellanimascellani## ## @author Mark Donszelmann ## @version $Id$ ## ## ## Latin Character Set ## ## STD MAC WIN PDF ISO A A 0101 0101 0101 0101 0101 AE 0341 0256 0306 0306 0341 Aacute -1 0347 0301 0301 0301 Acircumflex -1 0345 0302 0302 0302 Adieresis -1 0200 0304 0304 0304 Agrave -1 0313 0300 0300 0300 Aring -1 0201 0305 0305 0305 Atilde -1 0314 0303 0303 0303 B B 0102 0102 0102 0102 0102 C C 0103 0103 0103 0103 0103 Ccedilla -1 0202 0307 0307 0307 D D 0104 0104 0104 0104 0104 E E 0105 0105 0105 0105 0105 Eacute -1 0203 0311 0311 0311 Ecircumflex -1 0346 0312 0312 0312 Edieresis -1 0350 0313 0313 0313 Egrave -1 0351 0310 0310 0310 Eth -1 -1 0320 0320 0320 Euro -1 -1 0200 0240 -1 F F 0106 0106 0106 0106 0106 G G 0107 0107 0107 0107 0107 H H 0110 0110 0110 0110 0110 I I 0111 0111 0111 0111 0111 Iacute -1 0352 0315 0315 0315 Icircumflex -1 0353 0316 0316 0316 Idieresis -1 0354 0317 0317 0317 Igrave -1 0355 0314 0314 0314 J J 0112 0112 0112 0112 0112 K K 0113 0113 0113 0113 0113 L L 0114 0114 0114 0114 0114 A Lslash 0350 -1 -1 0225 -1 M M 0115 0115 0115 0115 0115 N N 0116 0116 0116 0116 0116 Ntilde -1 0204 0321 0321 0321 O O 0117 0117 0117 0117 0117 R OE 0352 0316 0214 0226 -1 Oacute -1 0356 0323 0323 0323 Ocircumflex -1 0357 0324 0324 0324 Odieresis -1 0205 0326 0326 0326 Ograve -1 0361 0322 0322 0322 Oslash 0351 0257 0330 0330 0330 Otilde -1 0315 0325 0325 0325 P P 0120 0120 0120 0120 0120 Q Q 0121 0121 0121 0121 0121 R R 0122 0122 0122 0122 0122 S S 0123 0123 0123 0123 0123 ` Scaron -1 -1 0212 0227 -1 T T 0124 0124 0124 0124 0124 Thorn -1 -1 0336 0336 0336 U U 0125 0125 0125 0125 0125 Uacute -1 0362 0332 0332 0332 Ucircumflex -1 0363 0333 0333 0333 Udieresis -1 0206 0334 0334 0334 Ugrave -1 0364 0331 0331 0331 V V 0126 0126 0126 0126 0126 W W 0127 0127 0127 0127 0127 X X 0130 0130 0130 0130 0130 Y Y 0131 0131 0131 0131 0131 Yacute -1 -1 0335 0335 0335 x Ydieresis -1 0331 0237 0230 -1 Z Z 0132 0132 0132 0132 0132 } Zcaron -1 -1 0216 0231 -1 a a 0141 0141 0141 0141 0141 aacute -1 0207 0341 0341 0341 acircumflex -1 0211 0342 0342 0342 acute 0302 0253 0264 0264 0264 adieresis -1 0212 0344 0344 0344 ae 0361 0276 0346 0346 0346 agrave -1 0210 0340 0340 0340 & ampersand 0046 0046 0046 0046 0046 aring -1 0214 0345 0345 0345 ^ asciicircum 0136 0136 0136 0136 0136 ~ asciitilde 0176 0176 0176 0176 0176 * asterisk 0052 0052 0052 0052 0052 @ at 0100 0100 0100 0100 0100 atilde -1 0213 0343 0343 0343 b b 0142 0142 0142 0142 0142 \ backslash 0134 0134 0134 0134 0134 | bar 0174 0174 0174 0174 0174 { braceleft 0173 0173 0173 0173 0173 } braceright 0175 0175 0175 0175 0175 [ bracketleft 0133 0133 0133 0133 0133 ] bracketright 0135 0135 0135 0135 0135  breve 0306 0371 -1 0030 0226 brokenbar -1 -1 0246 0246 0246 " bullet 0267 0245 0225 0200 -1 c c 0143 0143 0143 0143 0143  caron 0317 0377 -1 0031 0237 ccedilla -1 0215 0347 0347 0347 cedilla 0313 0374 0270 0270 0270 cent 0242 0242 0242 0242 0242  circumflex 0303 0366 0210 0032 0223 : colon 0072 0072 0072 0072 0072 , comma 0054 0054 0054 0054 0054 copyright -1 0251 0251 0251 0251 currency 0250 0333 0244 0244 0244 d d 0144 0144 0144 0144 0144 dagger 0262 0240 0206 0201 -1 ! daggerdbl 0263 0340 0207 0202 -1 degree -1 0241 0260 0260 0260 dieresis 0310 0254 0250 0250 0250 divide -1 0326 0367 0367 0267 $ dollar 0044 0044 0044 0044 0044  dotaccent 0307 0372 -1 0033 0227 1 dotlessi 0365 0365 -1 0232 0220 e e 0145 0145 0145 0145 0145 eacute -1 0216 0351 0351 0351 ecircumflex -1 0220 0352 0352 0352 edieresis -1 0221 0353 0353 0353 egrave -1 0217 0350 0350 0350 8 eight 0070 0070 0070 0070 0070 & ellipsis 0274 0311 0205 0203 -1 - emdash 0320 0321 0227 0204 -1 - endash 0261 0320 0226 0205 -1 = equal 0075 0075 0075 0075 0075 eth -1 -1 0360 0360 0360 ! exclam 0041 0041 0041 0041 0041 exclamdown 0241 0301 0241 0241 0241 f f 0146 0146 0146 0146 0146  fi 0256 0336 -1 0223 -1 5 five 0065 0065 0065 0065 0065  fl 0257 0337 -1 0224 -1  florin 0246 0304 0203 0206 -1 4 four 0064 0064 0064 0064 0064 D fraction 0244 0332 -1 0207 -1 g g 0147 0147 0147 0147 0147 germandbls 0373 0247 0337 0337 0337 ` grave 0301 0140 0140 0140 0221 > greater 0076 0076 0076 0076 0076 guillemotleft 0253 0307 0253 0253 0253 guillemotright 0273 0310 0273 0273 0273 9 guilsinglleft 0254 0334 0213 0210 -1 : guilsinglright 0255 0335 0233 0211 -1 h h 0150 0150 0150 0150 0150  hungarumlaut 0315 0375 -1 0034 0235 - hyphen 0055 0055 0055 0055 0255 i i 0151 0151 0151 0151 0151 iacute -1 0222 0355 0355 0355 icircumflex -1 0224 0356 0356 0356 idieresis -1 0225 0357 0357 0357 igrave -1 0223 0354 0354 0354 j j 0152 0152 0152 0152 0152 k k 0153 0153 0153 0153 0153 l l 0154 0154 0154 0154 0154 < less 0074 0074 0074 0074 0074 logicalnot -1 0302 0254 0254 0254 B lslash 0370 -1 -1 0233 -1 m m 0155 0155 0155 0155 0155 macron 0305 0370 0257 0257 0257 " minus -1 -1 -1 0212 0055  mu -1 0265 0265 0265 0265 multiply -1 -1 0327 0327 0327 n n 0156 0156 0156 0156 0156 9 nine 0071 0071 0071 0071 0071 ntilde -1 0226 0361 0361 0361 # numbersign 0043 0043 0043 0043 0043 o o 0157 0157 0157 0157 0157 oacute -1 0227 0363 0363 0363 ocircumflex -1 0231 0364 0364 0364 odieresis -1 0232 0366 0366 0366 S oe 0372 0317 0234 0234 -1  ogonek 0316 0376 -1 0035 0236 ograve -1 0230 0362 0362 0362 1 one 0061 0061 0061 0061 0061 onehalf -1 -1 0275 0275 0275 onequarter -1 -1 0274 0274 0274 onesuperior -1 -1 0271 0271 0271 ordfeminine 0343 0273 0252 0252 0252 ordmasculine 0353 0274 0272 0272 0272 oslash 0371 0277 0370 0370 0370 otilde -1 0233 0365 0365 0365 p p 0160 0160 0160 0160 0160 paragraph 0266 0246 0266 0266 0266 ( parenleft 0050 0050 0050 0050 0050 ) parenright 0051 0051 0051 0051 0051 % percent 0045 0045 0045 0045 0045 . period 0056 0056 0056 0056 0056 periodcentered 0264 0341 0267 0267 0267 0 perthousand 0275 0344 0211 0213 -1 + plus 0053 0053 0053 0053 0053 plusminus -1 0261 0261 0261 0261 q q 0161 0161 0161 0161 0161 ? question 0077 0077 0077 0077 0077 questiondown 0277 0300 0277 0277 0277 " quotedbl 0042 0042 0042 0042 0042  quotedblbase 0271 0343 0204 0214 -1  quotedblleft 0252 0322 0223 0215 -1  quotedblright 0272 0323 0224 0216 -1 ` quoteleft 0140 0324 0221 0217 0140 ' quoteright 0047 0325 0222 0220 0047  quotesinglbase 0270 0342 0202 0221 -1 ' quotesingle 0251 0047 0047 0047 -1 r r 0162 0162 0162 0162 0162 registered -1 0250 0256 0256 0256  ring 0312 0373 -1 0036 0232 s s 0163 0163 0163 0163 0163 a scaron -1 -1 0232 0235 -1 section 0247 0244 0247 0247 0247 ; semicolon 0073 0073 0073 0073 0073 7 seven 0067 0067 0067 0067 0067 6 six 0066 0066 0066 0066 0066 / slash 0057 0057 0057 0057 0057 \u0020 space 0040 0040 0040 0040 0040 sterling 0243 0243 0243 0243 0243 t t 0164 0164 0164 0164 0164 thorn -1 -1 0376 0376 0376 3 three 0063 0063 0063 0063 0063 threequarters -1 -1 0276 0276 0276 threesuperior -1 -1 0263 0263 0263  tilde 0304 0367 0230 0037 0224 "! trademark -1 0252 0231 0222 -1 2 two 0062 0062 0062 0062 0062 twosuperior -1 -1 0262 0262 0262 u u 0165 0165 0165 0165 0165 uacute -1 0234 0372 0372 0372 ucircumflex -1 0236 0373 0373 0373 udieresis -1 0237 0374 0374 0374 ugrave -1 0235 0371 0371 0371 _ underscore 0137 0137 0137 0137 0137 v v 0166 0166 0166 0166 0166 w w 0167 0167 0167 0167 0167 x x 0170 0170 0170 0170 0170 y y 0171 0171 0171 0171 0171 yacute -1 -1 0375 0375 0375 ydieresis -1 0330 0377 0377 0377 yen 0245 0264 0245 0245 0245 z z 0172 0172 0172 0172 0172 ~ zcaron -1 -1 0236 0236 -1 0 zero 0060 0060 0060 0060 0060 freehep-graphics2d-2.1.1/pom.xml0000644012010301201030000000744510636034657017504 0ustar mascellanimascellani vectorgraphics org.freehep 2.1.1 4.0.0 org.freehep freehep-graphics2d FreeHEP Graphics2D FreeHEP Graphics 2D Library freehep-maven Maven FreeHEP http://java.freehep.org/maven2 org.freehep freehep-util 2.0.2 org.freehep freehep-chartableconverter-plugin Expert generate-sources generate Expert.utf-16 Symbol generate-sources generate Symbol.utf-16 Zapfdingbats generate-sources generate Zapfdingbats.utf-16 ISOLatin generate-sources generate Latin.utf-16 ISO MACLatin generate-sources generate Latin.utf-16 MAC WINLatin generate-sources generate Latin.utf-16 WIN PDFLatin generate-sources generate Latin.utf-16 PDF STDLatin generate-sources generate Latin.utf-16 STD org.freehep.graphics2d.font