FreeHEP API
Version current

org.freehep.graphics2d
Class AbstractVectorGraphics

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

public abstract class AbstractVectorGraphics
extends VectorGraphics

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.

Version:
$Id: AbstractVectorGraphics.java,v 1.19 2004/07/13 22:39:46 duns Exp $
Author:
Simon Fischer, Mark Donszelmann
Source Code:
AbstractVectorGraphics.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
  AbstractVectorGraphics()
           
protected AbstractVectorGraphics(AbstractVectorGraphics graphics)
           
 
Method Summary
 void clearRect(int x, int y, int width, int height)
           
protected abstract  Shape createShape(double[] xPoints, double[] yPoints, int nPoints, boolean close)
          Creates a polyline/polygon shape from a set of points.
protected  Shape createShape(int[] xPoints, int[] yPoints, int nPoints, boolean close)
          Creates a polyline/polygon shape from a set of points.
 void drawArc(double x, double y, double width, double height, double startAngle, double arcAngle)
          Draws an arc.
 void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
           
 void drawLine(double x1, double y1, double x2, double y2)
          Draws a straight line.
 void drawLine(int x1, int y1, int x2, int y2)
           
 void drawOval(double x, double y, double width, double height)
          Draws an oval.
 void drawOval(int x, int y, int width, int height)
           
 void drawPolygon(double[] xPoints, double[] yPoints, int nPoints)
          Draws a polygon.
 void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
           
 void drawPolyline(double[] xPoints, double[] yPoints, int nPoints)
          Draws a polyline.
 void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
           
 void drawRect(double x, double y, double width, double height)
          Draws a rectangle.
 void drawRect(int x, int y, int width, int height)
           
 void drawRoundRect(double x, double y, double width, double height, double arcWidth, double arcHeight)
          Draws a rounded rectangle.
 void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
           
 void drawString(AttributedCharacterIterator iterator, int x, int y)
           
 void drawString(String str, double x, double y, int horizontal, int vertical)
           
 void drawString(String s, float x, float y)
           
 void drawString(String str, int x, int y)
           
 void drawString(TagString str, double x, double y)
           
 void drawString(TagString str, double x, double y, int horizontal, int vertical)
           
 void drawSymbol(double x, double y, double size, int symbol)
           
 void drawSymbol(int x, int y, int size, int symbol)
           
protected  void drawSymbol(VectorGraphics g, double x, double y, double size, int symbol)
           
 void fillAndDraw(Shape s, Color fillColor)
           
 void fillAndDrawSymbol(double x, double y, double size, int symbol, Color fillColor)
           
 void fillAndDrawSymbol(int x, int y, int size, int symbol, Color fillColor)
           
 void fillArc(double x, double y, double width, double height, double startAngle, double arcAngle)
          Fills an arc.
 void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
           
 void fillOval(double x, double y, double width, double height)
          Fills an oval.
 void fillOval(int x, int y, int width, int height)
           
 void fillPolygon(double[] xPoints, double[] yPoints, int nPoints)
          Fills a polygon.
 void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
           
 void fillRect(double x, double y, double width, double height)
          Fills a rectangle.
 void fillRect(int x, int y, int width, int height)
           
 void fillRoundRect(double x, double y, double width, double height, double arcWidth, double arcHeight)
          Fills a rounded rectangle.
 void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
           
 void fillSymbol(double x, double y, double size, int symbol)
           
 void fillSymbol(int x, int y, int size, int symbol)
           
protected  void fillSymbol(VectorGraphics g, double x, double y, double size, int symbol)
           
 Color getBackground()
          Gets the background color.
 Color getColor()
          Gets the current color.
 int getColorMode()
           
 String getCreator()
           
 Font getFont()
          Gets the current font.
 Paint getPaint()
          Gets the current paint.
protected  Color getPrintColor(Color color)
          Returns a printColor created from the original printColor, based on the ColorMode.
protected  Properties getProperties()
           
 String getProperty(String key)
           
 Color getPropertyColor(String key)
           
 Dimension getPropertyDimension(String key)
           
 double getPropertyDouble(String key)
           
 Insets getPropertyInsets(String key)
           
 int getPropertyInt(String key)
           
 Rectangle getPropertyRectangle(String key)
           
protected  void initProperties(Properties defaults)
           
 boolean isDeviceIndependent()
           
 boolean isProperty(String key)
           
 void rotate(double theta, double x, double y)
           
 void setBackground(Color color)
          Sets the background color.
 void setColor(Color color)
          Sets the current color and the current paint.
 void setColorMode(int colorMode)
           
 void setCreator(String creator)
           
 void setDeviceIndependent(boolean isDeviceIndependent)
           
 void setFont(Font font)
          Sets the current font.
 void setLineWidth(double width)
           
 void setLineWidth(int width)
           
 void setPaint(Paint paint)
          Sets the current paint.
 void setProperties(Properties newProperties)
           
 void translate(int x, int y)
           
 
Methods inherited from class org.freehep.graphics2d.VectorGraphics
addRenderingHints, clearRect, clip, clipRect, clipRect, copyArea, create, create, create, create, dispose, draw, drawGlyphVector, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawRenderableImage, drawRenderedImage, drawString, drawString, drawString, drawString, endExport, fill, getClip, getClipBounds, getClipBounds, getComposite, getDeviceConfiguration, getFontMetrics, getFontRenderContext, getRenderingHint, getRenderingHints, getStroke, getSymbol, getTextAlignment, getTransform, getXalignment, getYalignment, hit, printComment, rotate, scale, setClip, setClip, setClip, setComposite, setPaintMode, setRenderingHint, setRenderingHints, setStroke, setTransform, setXORMode, shear, startExport, toString, transform, translate
 
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

AbstractVectorGraphics

public AbstractVectorGraphics()

AbstractVectorGraphics

protected AbstractVectorGraphics(AbstractVectorGraphics graphics)
Method Detail

setProperties

public void setProperties(Properties newProperties)
Specified by:
setProperties in class VectorGraphics

initProperties

protected void initProperties(Properties defaults)
Specified by:
initProperties in class VectorGraphics

getProperties

protected Properties getProperties()
Specified by:
getProperties in class VectorGraphics

getProperty

public String getProperty(String key)
Specified by:
getProperty in class VectorGraphics

getPropertyColor

public Color getPropertyColor(String key)
Specified by:
getPropertyColor in class VectorGraphics

getPropertyRectangle

public Rectangle getPropertyRectangle(String key)
Specified by:
getPropertyRectangle in class VectorGraphics

getPropertyInsets

public Insets getPropertyInsets(String key)

getPropertyDimension

public Dimension getPropertyDimension(String key)
Specified by:
getPropertyDimension in class VectorGraphics

getPropertyInt

public int getPropertyInt(String key)
Specified by:
getPropertyInt in class VectorGraphics

getPropertyDouble

public double getPropertyDouble(String key)
Specified by:
getPropertyDouble in class VectorGraphics

isProperty

public boolean isProperty(String key)
Specified by:
isProperty in class VectorGraphics

getCreator

public String getCreator()
Specified by:
getCreator in class VectorGraphics

setCreator

public void setCreator(String creator)
Specified by:
setCreator in class VectorGraphics

isDeviceIndependent

public boolean isDeviceIndependent()
Specified by:
isDeviceIndependent in class VectorGraphics

setDeviceIndependent

public void setDeviceIndependent(boolean isDeviceIndependent)
Specified by:
setDeviceIndependent in class VectorGraphics

getFont

public Font getFont()
Gets the current font.

Specified by:
getFont in class VectorGraphics
Returns:
current font

setFont

public void setFont(Font font)
Sets the current font.

Specified by:
setFont in class VectorGraphics
Parameters:
font - to be set

drawSymbol

public void drawSymbol(int x,
                       int y,
                       int size,
                       int symbol)
Specified by:
drawSymbol in class VectorGraphics

fillSymbol

public void fillSymbol(int x,
                       int y,
                       int size,
                       int symbol)
Specified by:
fillSymbol in class VectorGraphics

fillAndDrawSymbol

public void fillAndDrawSymbol(int x,
                              int y,
                              int size,
                              int symbol,
                              Color fillColor)
Specified by:
fillAndDrawSymbol in class VectorGraphics

drawSymbol

public void drawSymbol(double x,
                       double y,
                       double size,
                       int symbol)
Specified by:
drawSymbol in class VectorGraphics

drawSymbol

protected void drawSymbol(VectorGraphics g,
                          double x,
                          double y,
                          double size,
                          int symbol)

fillSymbol

public void fillSymbol(double x,
                       double y,
                       double size,
                       int symbol)
Specified by:
fillSymbol in class VectorGraphics

fillSymbol

protected void fillSymbol(VectorGraphics g,
                          double x,
                          double y,
                          double size,
                          int symbol)

fillAndDrawSymbol

public void fillAndDrawSymbol(double x,
                              double y,
                              double size,
                              int symbol,
                              Color fillColor)
Specified by:
fillAndDrawSymbol in class VectorGraphics

fillAndDraw

public void fillAndDraw(Shape s,
                        Color fillColor)
Specified by:
fillAndDraw in class VectorGraphics

clearRect

public void clearRect(int x,
                      int y,
                      int width,
                      int height)
Specified by:
clearRect in class VectorGraphics

drawLine

public void drawLine(int x1,
                     int y1,
                     int x2,
                     int y2)
Specified by:
drawLine in class VectorGraphics

drawRect

public void drawRect(int x,
                     int y,
                     int width,
                     int height)
Specified by:
drawRect in class VectorGraphics

fillRect

public void fillRect(int x,
                     int y,
                     int width,
                     int height)
Specified by:
fillRect in class VectorGraphics

drawArc

public void drawArc(int x,
                    int y,
                    int width,
                    int height,
                    int startAngle,
                    int arcAngle)
Specified by:
drawArc in class VectorGraphics

fillArc

public void fillArc(int x,
                    int y,
                    int width,
                    int height,
                    int startAngle,
                    int arcAngle)
Specified by:
fillArc in class VectorGraphics

drawOval

public void drawOval(int x,
                     int y,
                     int width,
                     int height)
Specified by:
drawOval in class VectorGraphics

fillOval

public void fillOval(int x,
                     int y,
                     int width,
                     int height)
Specified by:
fillOval in class VectorGraphics

drawRoundRect

public void drawRoundRect(int x,
                          int y,
                          int width,
                          int height,
                          int arcWidth,
                          int arcHeight)
Specified by:
drawRoundRect in class VectorGraphics

fillRoundRect

public void fillRoundRect(int x,
                          int y,
                          int width,
                          int height,
                          int arcWidth,
                          int arcHeight)
Specified by:
fillRoundRect in class VectorGraphics

translate

public void translate(int x,
                      int y)
Specified by:
translate in class VectorGraphics

setLineWidth

public void setLineWidth(int width)
Specified by:
setLineWidth in class VectorGraphics

setLineWidth

public void setLineWidth(double width)
Specified by:
setLineWidth in class VectorGraphics

drawString

public void drawString(String str,
                       int x,
                       int y)
Specified by:
drawString in class VectorGraphics

drawString

public void drawString(String s,
                       float x,
                       float y)
Specified by:
drawString in class VectorGraphics

drawString

public void drawString(AttributedCharacterIterator iterator,
                       int x,
                       int y)
Specified by:
drawString in class VectorGraphics

drawString

public void drawString(String str,
                       double x,
                       double y,
                       int horizontal,
                       int vertical)
Specified by:
drawString in class VectorGraphics

drawString

public void drawString(TagString str,
                       double x,
                       double y)
Specified by:
drawString in class VectorGraphics

drawString

public void drawString(TagString str,
                       double x,
                       double y,
                       int horizontal,
                       int vertical)
Specified by:
drawString in class VectorGraphics

getColorMode

public int getColorMode()
Specified by:
getColorMode in class VectorGraphics

setColorMode

public void setColorMode(int colorMode)
Specified by:
setColorMode in class VectorGraphics

getBackground

public Color getBackground()
Gets the background color.

Specified by:
getBackground in class VectorGraphics
Returns:
background color

setBackground

public void setBackground(Color color)
Sets the background color.

Specified by:
setBackground in class VectorGraphics
Parameters:
color - background color to be set

setColor

public void setColor(Color color)
Sets the current color and the current paint. Calls writePaint(Color).

Specified by:
setColor in class VectorGraphics
Parameters:
color - to be set

getColor

public Color getColor()
Gets the current color.

Specified by:
getColor in class VectorGraphics
Returns:
the current color

setPaint

public void setPaint(Paint paint)
Sets the current paint.

Specified by:
setPaint in class VectorGraphics
Returns:
current paint

getPaint

public Paint getPaint()
Gets the current paint.

Specified by:
getPaint in class VectorGraphics
Returns:
current paint

getPrintColor

protected Color getPrintColor(Color color)
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.


rotate

public void rotate(double theta,
                   double x,
                   double y)
Specified by:
rotate in class VectorGraphics

drawArc

public void drawArc(double x,
                    double y,
                    double width,
                    double height,
                    double startAngle,
                    double arcAngle)
Description copied from class: VectorGraphics
Draws an arc. Uses Arc2D to call draw(Shape).

Specified by:
drawArc in class VectorGraphics

drawLine

public void drawLine(double x1,
                     double y1,
                     double x2,
                     double y2)
Description copied from class: VectorGraphics
Draws a straight line. Uses Line2D to call draw(Shape).

Specified by:
drawLine in class VectorGraphics

drawOval

public void drawOval(double x,
                     double y,
                     double width,
                     double height)
Description copied from class: VectorGraphics
Draws an oval. Uses Ellipse2D to call draw(Shape).

Specified by:
drawOval in class VectorGraphics

drawPolyline

public void drawPolyline(int[] xPoints,
                         int[] yPoints,
                         int nPoints)
Specified by:
drawPolyline in class VectorGraphics

drawPolyline

public void drawPolyline(double[] xPoints,
                         double[] yPoints,
                         int nPoints)
Description copied from class: VectorGraphics
Draws a polyline. Uses createShape(...) to call draw(Shape).

Specified by:
drawPolyline in class VectorGraphics

drawPolygon

public void drawPolygon(int[] xPoints,
                        int[] yPoints,
                        int nPoints)
Specified by:
drawPolygon in class VectorGraphics

drawPolygon

public void drawPolygon(double[] xPoints,
                        double[] yPoints,
                        int nPoints)
Description copied from class: VectorGraphics
Draws a polygon. Uses createShape(...) to call draw(Shape).

Specified by:
drawPolygon in class VectorGraphics

drawRect

public void drawRect(double x,
                     double y,
                     double width,
                     double height)
Description copied from class: VectorGraphics
Draws a rectangle. Uses Rectangle2D to call draw(Shape).

Specified by:
drawRect in class VectorGraphics

drawRoundRect

public void drawRoundRect(double x,
                          double y,
                          double width,
                          double height,
                          double arcWidth,
                          double arcHeight)
Description copied from class: VectorGraphics
Draws a rounded rectangle. Uses RoundRectangle2D to call draw(Shape).

Specified by:
drawRoundRect in class VectorGraphics

fillArc

public void fillArc(double x,
                    double y,
                    double width,
                    double height,
                    double startAngle,
                    double arcAngle)
Description copied from class: VectorGraphics
Fills an arc. Uses Arc2D to call fill(Shape).

Specified by:
fillArc in class VectorGraphics

fillOval

public void fillOval(double x,
                     double y,
                     double width,
                     double height)
Description copied from class: VectorGraphics
Fills an oval. Uses Ellipse2D to call fill(Shape).

Specified by:
fillOval in class VectorGraphics

fillPolygon

public void fillPolygon(int[] xPoints,
                        int[] yPoints,
                        int nPoints)
Specified by:
fillPolygon in class VectorGraphics

fillPolygon

public void fillPolygon(double[] xPoints,
                        double[] yPoints,
                        int nPoints)
Description copied from class: VectorGraphics
Fills a polygon. Uses createShape(...) to call fill(Shape).

Specified by:
fillPolygon in class VectorGraphics

fillRect

public void fillRect(double x,
                     double y,
                     double width,
                     double height)
Description copied from class: VectorGraphics
Fills a rectangle. Uses Rectangle2D to call fill(Shape).

Specified by:
fillRect in class VectorGraphics

fillRoundRect

public void fillRoundRect(double x,
                          double y,
                          double width,
                          double height,
                          double arcWidth,
                          double arcHeight)
Description copied from class: VectorGraphics
Fills a rounded rectangle. Uses RoundRectangle2D to call fill(Shape).

Specified by:
fillRoundRect in class VectorGraphics

createShape

protected abstract Shape createShape(double[] xPoints,
                                     double[] yPoints,
                                     int nPoints,
                                     boolean close)
Creates a polyline/polygon shape from a set of points. Needs to be defined in subclass because its implementations could be device specific

Parameters:
xPoints - X coordinates of the polyline.
yPoints - Y coordinates of the polyline.
nPoints - number of points of the polyline.
close - is shape closed

createShape

protected Shape createShape(int[] xPoints,
                            int[] yPoints,
                            int nPoints,
                            boolean close)
Creates a polyline/polygon shape from a set of points.

Parameters:
xPoints - X coordinates of the polyline.
yPoints - Y coordinates of the polyline.
nPoints - number of points of the polyline.
close - is shape closed

FreeHEP API
Version current

Copyright © 2000-2004 FreeHEP, All Rights Reserved.