FreeHEP API
Version current

org.freehep.graphics2d
Class VectorGraphics

java.lang.Object
  extended byjava.awt.Graphics
      extended byjava.awt.Graphics2D
          extended byorg.freehep.graphics2d.VectorGraphics
All Implemented Interfaces:
VectorGraphicsConstants
Direct Known Subclasses:
AbstractVectorGraphics, JAVAGraphics2D

public abstract class VectorGraphics
extends Graphics2D
implements VectorGraphicsConstants

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.

Version:
$Id: VectorGraphics.java,v 1.31 2004/07/13 22:39:47 duns Exp $
Author:
Charles Loomis, Mark Donszelmann
Source Code:
VectorGraphics.java

Field Summary
 
Fields inherited from interface org.freehep.graphics2d.VectorGraphicsConstants
NUMBER_OF_HORIZ_ALIGNMENTS, NUMBER_OF_SYMBOLS, NUMBER_OF_VERTICAL_ALIGNMENTS, SYMBOL_BOX, SYMBOL_CIRCLE, SYMBOL_CROSS, SYMBOL_DIAMOND, SYMBOL_DN_TRIANGLE, SYMBOL_HLINE, SYMBOL_PLUS, SYMBOL_STAR, SYMBOL_UP_TRIANGLE, SYMBOL_VLINE, TEXT_BASELINE, TEXT_BOTTOM, TEXT_CENTER, TEXT_LEFT, TEXT_RIGHT, TEXT_TOP
 
Constructor Summary
VectorGraphics()
           
 
Method Summary
abstract  void addRenderingHints(Map hints)
           
abstract  void clearRect(double x, double y, double width, double height)
           
abstract  void clearRect(int x, int y, int width, int height)
           
abstract  void clip(Shape s)
           
abstract  void clipRect(double x, double y, double width, double height)
           
abstract  void clipRect(int x, int y, int width, int height)
           
abstract  void copyArea(int x, int y, int width, int height, int dx, int dy)
           
abstract  Graphics create()
           
abstract  Graphics create(double x, double y, double width, double height)
           
static VectorGraphics create(Graphics g)
           
 Graphics create(int x, int y, int width, int height)
           
abstract  void dispose()
           
abstract  void draw(Shape s)
           
abstract  void drawArc(double x, double y, double width, double height, double startAngle, double arcAngle)
          Draws an arc.
abstract  void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
           
abstract  void drawGlyphVector(GlyphVector g, float x, float y)
           
abstract  void drawImage(BufferedImage img, BufferedImageOp op, int x, int y)
           
abstract  boolean drawImage(Image img, AffineTransform xform, ImageObserver obs)
           
abstract  boolean drawImage(Image image, int x, int y, Color bgColor, ImageObserver observer)
           
abstract  boolean drawImage(Image image, int x, int y, ImageObserver observer)
           
abstract  boolean drawImage(Image image, int x, int y, int width, int height, Color bgColor, ImageObserver observer)
           
abstract  boolean drawImage(Image image, int x, int y, int width, int height, ImageObserver observer)
           
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)
           
abstract  boolean drawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer)
           
abstract  void drawLine(double x1, double y1, double x2, double y2)
          Draws a straight line.
abstract  void drawLine(int x1, int y1, int x2, int y2)
           
abstract  void drawOval(double x, double y, double width, double height)
          Draws an oval.
abstract  void drawOval(int x, int y, int width, int height)
           
abstract  void drawPolygon(double[] xPoints, double[] yPoints, int nPoints)
          Draws a polygon.
abstract  void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
           
abstract  void drawPolyline(double[] xPoints, double[] yPoints, int nPoints)
          Draws a polyline.
abstract  void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
           
abstract  void drawRect(double x, double y, double width, double height)
          Draws a rectangle.
abstract  void drawRect(int x, int y, int width, int height)
           
abstract  void drawRenderableImage(RenderableImage img, AffineTransform xform)
           
abstract  void drawRenderedImage(RenderedImage img, AffineTransform xform)
           
abstract  void drawRoundRect(double x, double y, double width, double height, double arcWidth, double arcHeight)
          Draws a rounded rectangle.
abstract  void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
           
abstract  void drawString(AttributedCharacterIterator iterator, float x, float y)
           
abstract  void drawString(AttributedCharacterIterator iterator, int x, int y)
           
abstract  void drawString(String str, double x, double y)
          Draws a string.
abstract  void drawString(String str, double x, double y, int horizontal, int vertical)
           
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 string with a lot of parameters.
abstract  void drawString(String str, float x, float y)
           
abstract  void drawString(String str, int x, int y)
           
abstract  void drawString(TagString str, double x, double y)
           
abstract  void drawString(TagString str, double x, double y, int horizontal, int vertical)
           
abstract  void drawString(TagString 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.
abstract  void drawSymbol(double x, double y, double size, int symbol)
           
abstract  void drawSymbol(int x, int y, int size, int symbol)
           
abstract  void endExport()
           
abstract  void fill(Shape s)
           
abstract  void fillAndDraw(Shape s, Color fillColor)
           
abstract  void fillAndDrawSymbol(double x, double y, double size, int symbol, Color fillColor)
           
abstract  void fillAndDrawSymbol(int x, int y, int size, int symbol, Color fillColor)
           
abstract  void fillArc(double x, double y, double width, double height, double startAngle, double arcAngle)
          Fills an arc.
abstract  void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
           
abstract  void fillOval(double x, double y, double width, double height)
          Fills an oval.
abstract  void fillOval(int x, int y, int width, int height)
           
abstract  void fillPolygon(double[] xPoints, double[] yPoints, int nPoints)
          Fills a polygon.
abstract  void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
           
abstract  void fillRect(double x, double y, double width, double height)
          Fills a rectangle.
abstract  void fillRect(int x, int y, int width, int height)
           
abstract  void fillRoundRect(double x, double y, double width, double height, double arcWidth, double arcHeight)
          Fills a rounded rectangle.
abstract  void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
           
abstract  void fillSymbol(double x, double y, double size, int symbol)
           
abstract  void fillSymbol(int x, int y, int size, int symbol)
           
abstract  Color getBackground()
           
abstract  Shape getClip()
           
abstract  Rectangle getClipBounds()
           
abstract  Rectangle getClipBounds(Rectangle r)
           
abstract  Color getColor()
           
abstract  int getColorMode()
           
abstract  Composite getComposite()
           
abstract  String getCreator()
           
abstract  GraphicsConfiguration getDeviceConfiguration()
           
abstract  Font getFont()
           
abstract  FontMetrics getFontMetrics(Font font)
           
abstract  FontRenderContext getFontRenderContext()
           
abstract  Paint getPaint()
           
protected abstract  Properties getProperties()
           
abstract  String getProperty(String key)
           
abstract  Color getPropertyColor(String key)
           
abstract  Dimension getPropertyDimension(String key)
           
abstract  double getPropertyDouble(String key)
           
abstract  int getPropertyInt(String key)
           
abstract  Rectangle getPropertyRectangle(String key)
           
abstract  Object getRenderingHint(RenderingHints.Key inteKey)
           
abstract  RenderingHints getRenderingHints()
           
abstract  Stroke getStroke()
           
static int getSymbol(String name)
           
static int getTextAlignment(String name)
           
abstract  AffineTransform getTransform()
           
static double getXalignment(double x, double width, int alignment)
           
static double getYalignment(double y, double ascent, double descent, int alignment)
           
abstract  boolean hit(Rectangle rect, Shape s, boolean onStroke)
           
protected abstract  void initProperties(Properties defaults)
           
abstract  boolean isDeviceIndependent()
           
abstract  boolean isProperty(String key)
           
abstract  void printComment(String comment)
           
abstract  void rotate(double theta)
           
abstract  void rotate(double theta, double x, double y)
           
abstract  void scale(double sx, double sy)
           
abstract  void setBackground(Color color)
           
abstract  void setClip(double x, double y, double width, double height)
           
abstract  void setClip(int x, int y, int width, int height)
           
abstract  void setClip(Shape clip)
           
abstract  void setColor(Color c)
           
abstract  void setColorMode(int colorMode)
           
abstract  void setComposite(Composite comp)
           
abstract  void setCreator(String creator)
           
abstract  void setDeviceIndependent(boolean isDeviceIndependent)
           
abstract  void setFont(Font font)
           
abstract  void setLineWidth(double width)
           
abstract  void setLineWidth(int width)
           
abstract  void setPaint(Paint paint)
           
abstract  void setPaintMode()
           
abstract  void setProperties(Properties newProperties)
           
abstract  void setRenderingHint(RenderingHints.Key hintKey, Object hintValue)
           
abstract  void setRenderingHints(Map hints)
           
abstract  void setStroke(Stroke s)
           
abstract  void setTransform(AffineTransform xform)
           
abstract  void setXORMode(Color c1)
           
abstract  void shear(double shx, double shy)
           
abstract  void startExport()
           
abstract  String toString()
           
abstract  void transform(AffineTransform xform)
           
abstract  void translate(double tx, double ty)
           
abstract  void translate(int x, int y)
           
 
Methods inherited from class java.awt.Graphics2D
draw3DRect, fill3DRect
 
Methods inherited from class java.awt.Graphics
drawBytes, drawChars, drawPolygon, fillPolygon, finalize, getClipRect, getFontMetrics, hitClip
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VectorGraphics

public VectorGraphics()
Method Detail

setProperties

public abstract void setProperties(Properties newProperties)

initProperties

protected abstract void initProperties(Properties defaults)

getProperties

protected abstract Properties getProperties()

getProperty

public abstract String getProperty(String key)

getPropertyColor

public abstract Color getPropertyColor(String key)

getPropertyRectangle

public abstract Rectangle getPropertyRectangle(String key)

getPropertyDimension

public abstract Dimension getPropertyDimension(String key)

getPropertyInt

public abstract int getPropertyInt(String key)

getPropertyDouble

public abstract double getPropertyDouble(String key)

isProperty

public abstract boolean isProperty(String key)

clearRect

public abstract void clearRect(int x,
                               int y,
                               int width,
                               int height)

clipRect

public abstract void clipRect(int x,
                              int y,
                              int width,
                              int height)

copyArea

public abstract void copyArea(int x,
                              int y,
                              int width,
                              int height,
                              int dx,
                              int dy)

create

public abstract Graphics create()

create

public Graphics create(int x,
                       int y,
                       int width,
                       int height)

dispose

public abstract void dispose()

drawArc

public abstract void drawArc(int x,
                             int y,
                             int width,
                             int height,
                             int startAngle,
                             int arcAngle)

drawImage

public abstract boolean drawImage(Image image,
                                  int x,
                                  int y,
                                  ImageObserver observer)

drawImage

public abstract boolean drawImage(Image image,
                                  int x,
                                  int y,
                                  int width,
                                  int height,
                                  ImageObserver observer)

drawImage

public abstract boolean drawImage(Image image,
                                  int x,
                                  int y,
                                  Color bgColor,
                                  ImageObserver observer)

drawImage

public abstract boolean drawImage(Image image,
                                  int x,
                                  int y,
                                  int width,
                                  int height,
                                  Color bgColor,
                                  ImageObserver observer)

drawImage

public abstract boolean drawImage(Image image,
                                  int dx1,
                                  int dy1,
                                  int dx2,
                                  int dy2,
                                  int sx1,
                                  int sy1,
                                  int sx2,
                                  int sy2,
                                  ImageObserver observer)

drawImage

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)

drawLine

public abstract void drawLine(int x1,
                              int y1,
                              int x2,
                              int y2)

drawOval

public abstract void drawOval(int x,
                              int y,
                              int width,
                              int height)

drawPolygon

public abstract void drawPolygon(int[] xPoints,
                                 int[] yPoints,
                                 int nPoints)

drawPolyline

public abstract void drawPolyline(int[] xPoints,
                                  int[] yPoints,
                                  int nPoints)

drawRect

public abstract void drawRect(int x,
                              int y,
                              int width,
                              int height)

drawRoundRect

public abstract void drawRoundRect(int x,
                                   int y,
                                   int width,
                                   int height,
                                   int arcWidth,
                                   int arcHeight)

drawString

public abstract void drawString(AttributedCharacterIterator iterator,
                                int x,
                                int y)

drawString

public abstract void drawString(String str,
                                int x,
                                int y)

fillArc

public abstract void fillArc(int x,
                             int y,
                             int width,
                             int height,
                             int startAngle,
                             int arcAngle)

fillOval

public abstract void fillOval(int x,
                              int y,
                              int width,
                              int height)

fillPolygon

public abstract void fillPolygon(int[] xPoints,
                                 int[] yPoints,
                                 int nPoints)

fillRect

public abstract void fillRect(int x,
                              int y,
                              int width,
                              int height)

fillRoundRect

public abstract void fillRoundRect(int x,
                                   int y,
                                   int width,
                                   int height,
                                   int arcWidth,
                                   int arcHeight)

getClip

public abstract Shape getClip()

getClipBounds

public abstract Rectangle getClipBounds()

getClipBounds

public abstract Rectangle getClipBounds(Rectangle r)

getColor

public abstract Color getColor()

getFont

public abstract Font getFont()

getFontMetrics

public abstract FontMetrics getFontMetrics(Font font)

setClip

public abstract void setClip(int x,
                             int y,
                             int width,
                             int height)

setClip

public abstract void setClip(Shape clip)

setColor

public abstract void setColor(Color c)

setFont

public abstract void setFont(Font font)

setPaintMode

public abstract void setPaintMode()

setXORMode

public abstract void setXORMode(Color c1)

toString

public abstract String toString()

translate

public abstract void translate(int x,
                               int y)

addRenderingHints

public abstract void addRenderingHints(Map hints)

clip

public abstract void clip(Shape s)

draw

public abstract void draw(Shape s)

drawGlyphVector

public abstract void drawGlyphVector(GlyphVector g,
                                     float x,
                                     float y)

drawImage

public abstract void drawImage(BufferedImage img,
                               BufferedImageOp op,
                               int x,
                               int y)

drawImage

public abstract boolean drawImage(Image img,
                                  AffineTransform xform,
                                  ImageObserver obs)

drawRenderableImage

public abstract void drawRenderableImage(RenderableImage img,
                                         AffineTransform xform)

drawRenderedImage

public abstract void drawRenderedImage(RenderedImage img,
                                       AffineTransform xform)

drawString

public abstract void drawString(AttributedCharacterIterator iterator,
                                float x,
                                float y)

drawString

public abstract void drawString(String str,
                                float x,
                                float y)

fill

public abstract void fill(Shape s)

getBackground

public abstract Color getBackground()

getComposite

public abstract Composite getComposite()

getDeviceConfiguration

public abstract GraphicsConfiguration getDeviceConfiguration()

getFontRenderContext

public abstract FontRenderContext getFontRenderContext()

getPaint

public abstract Paint getPaint()

getRenderingHint

public abstract Object getRenderingHint(RenderingHints.Key inteKey)

getRenderingHints

public abstract RenderingHints getRenderingHints()

getStroke

public abstract Stroke getStroke()

getTransform

public abstract AffineTransform getTransform()

hit

public abstract boolean hit(Rectangle rect,
                            Shape s,
                            boolean onStroke)

rotate

public abstract void rotate(double theta)

rotate

public abstract void rotate(double theta,
                            double x,
                            double y)

scale

public abstract void scale(double sx,
                           double sy)

setBackground

public abstract void setBackground(Color color)

setComposite

public abstract void setComposite(Composite comp)

setPaint

public abstract void setPaint(Paint paint)

setRenderingHint

public abstract void setRenderingHint(RenderingHints.Key hintKey,
                                      Object hintValue)

setRenderingHints

public abstract void setRenderingHints(Map hints)

setStroke

public abstract void setStroke(Stroke s)

setTransform

public abstract void setTransform(AffineTransform xform)

shear

public abstract void shear(double shx,
                           double shy)

transform

public abstract void transform(AffineTransform xform)

translate

public abstract void translate(double tx,
                               double ty)

clearRect

public abstract void clearRect(double x,
                               double y,
                               double width,
                               double height)

clipRect

public abstract void clipRect(double x,
                              double y,
                              double width,
                              double height)

create

public abstract Graphics create(double x,
                                double y,
                                double width,
                                double height)

drawArc

public abstract void drawArc(double x,
                             double y,
                             double width,
                             double height,
                             double startAngle,
                             double arcAngle)
Draws an arc. Uses Arc2D to call draw(Shape).


drawLine

public abstract void drawLine(double x1,
                              double y1,
                              double x2,
                              double y2)
Draws a straight line. Uses Line2D to call draw(Shape).


drawOval

public abstract void drawOval(double x,
                              double y,
                              double width,
                              double height)
Draws an oval. Uses Ellipse2D to call draw(Shape).


drawPolygon

public abstract void drawPolygon(double[] xPoints,
                                 double[] yPoints,
                                 int nPoints)
Draws a polygon. Uses createShape(...) to call draw(Shape).


drawPolyline

public abstract void drawPolyline(double[] xPoints,
                                  double[] yPoints,
                                  int nPoints)
Draws a polyline. Uses createShape(...) to call draw(Shape).


drawRect

public abstract void drawRect(double x,
                              double y,
                              double width,
                              double height)
Draws a rectangle. Uses Rectangle2D to call draw(Shape).


drawRoundRect

public abstract void drawRoundRect(double x,
                                   double y,
                                   double width,
                                   double height,
                                   double arcWidth,
                                   double arcHeight)
Draws a rounded rectangle. Uses RoundRectangle2D to call draw(Shape).


drawSymbol

public abstract void drawSymbol(int x,
                                int y,
                                int size,
                                int symbol)

drawSymbol

public abstract void drawSymbol(double x,
                                double y,
                                double size,
                                int symbol)

fillSymbol

public abstract void fillSymbol(int x,
                                int y,
                                int size,
                                int symbol)

fillSymbol

public abstract void fillSymbol(double x,
                                double y,
                                double size,
                                int symbol)

fillAndDrawSymbol

public abstract void fillAndDrawSymbol(int x,
                                       int y,
                                       int size,
                                       int symbol,
                                       Color fillColor)

fillAndDrawSymbol

public abstract void fillAndDrawSymbol(double x,
                                       double y,
                                       double size,
                                       int symbol,
                                       Color fillColor)

drawString

public abstract void drawString(String str,
                                double x,
                                double y)
Draws a string.


drawString

public abstract void drawString(TagString str,
                                double x,
                                double y)

drawString

public abstract void drawString(String str,
                                double x,
                                double y,
                                int horizontal,
                                int vertical)

drawString

public abstract void drawString(TagString str,
                                double x,
                                double y,
                                int horizontal,
                                int vertical)

drawString

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 string with a lot of parameters.

Parameters:
str - text to be drawn
x - coordinate to draw string
y - coordinate to draw string
horizontal - alignment of the text
vertical - alignment of the text
framed - true if text is surrounded by a frame
frameColor - color of the frame
frameWidth - witdh of the frame
banner - true if the frame is filled by a banner
bannerColor - color of the banner

drawString

public abstract void drawString(TagString 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.

Parameters:
str - Tagged text to be drawn
x - coordinate to draw string
y - coordinate to draw string
horizontal - alignment of the text
vertical - alignment of the text
framed - true if text is surrounded by a frame
frameColor - color of the frame
frameWidth - witdh of the frame
banner - true if the frame is filled by a banner
bannerColor - color of the banner

endExport

public abstract void endExport()

fillAndDraw

public abstract void fillAndDraw(Shape s,
                                 Color fillColor)

fillArc

public abstract void fillArc(double x,
                             double y,
                             double width,
                             double height,
                             double startAngle,
                             double arcAngle)
Fills an arc. Uses Arc2D to call fill(Shape).


fillOval

public abstract void fillOval(double x,
                              double y,
                              double width,
                              double height)
Fills an oval. Uses Ellipse2D to call fill(Shape).


fillPolygon

public abstract void fillPolygon(double[] xPoints,
                                 double[] yPoints,
                                 int nPoints)
Fills a polygon. Uses createShape(...) to call fill(Shape).


fillRect

public abstract void fillRect(double x,
                              double y,
                              double width,
                              double height)
Fills a rectangle. Uses Rectangle2D to call fill(Shape).


fillRoundRect

public abstract void fillRoundRect(double x,
                                   double y,
                                   double width,
                                   double height,
                                   double arcWidth,
                                   double arcHeight)
Fills a rounded rectangle. Uses RoundRectangle2D to call fill(Shape).


getColorMode

public abstract int getColorMode()

getCreator

public abstract String getCreator()

isDeviceIndependent

public abstract boolean isDeviceIndependent()

printComment

public abstract void printComment(String comment)

setClip

public abstract void setClip(double x,
                             double y,
                             double width,
                             double height)

setColorMode

public abstract void setColorMode(int colorMode)

setCreator

public abstract void setCreator(String creator)

setDeviceIndependent

public abstract void setDeviceIndependent(boolean isDeviceIndependent)

setLineWidth

public abstract void setLineWidth(int width)

setLineWidth

public abstract void setLineWidth(double width)

startExport

public abstract void startExport()

create

public static VectorGraphics create(Graphics g)

getTextAlignment

public static int getTextAlignment(String name)

getSymbol

public static int getSymbol(String name)

getYalignment

public static double getYalignment(double y,
                                   double ascent,
                                   double descent,
                                   int alignment)

getXalignment

public static double getXalignment(double x,
                                   double width,
                                   int alignment)

FreeHEP API
Version current

Copyright © 2000-2004 FreeHEP, All Rights Reserved.