Package weka.gui.visualize
Class PostscriptGraphics
java.lang.Object
java.awt.Graphics
java.awt.Graphics2D
weka.gui.visualize.PostscriptGraphics
The PostscriptGraphics class extends the Graphics2D class to produce an
encapsulated postscript file rather than on-screen display.
Currently only a small (but useful) subset of Graphics methods have been implemented. To handle the ability to Clone a Graphics object, the graphics state of the eps is set from the graphics state of the local PostscriptGraphics before output. To use, create a PostscriptGraphics object, and pass it to the PaintComponent method of a JComponent.
If necessary additional font replacements can be inserted, since some fonts might be displayed incorrectly.
- Version:
- $Revision: 10222 $
- Author:
- Dale Fletcher (dale@cs.waikato.ac.nz), FracPete (fracpete at waikato dot ac dot nz)
- See Also:
-
addPSFontReplacement(String, String)
m_PSFontReplacement
-
Constructor Summary
ConstructorDescriptionPostscriptGraphics
(int width, int height, OutputStream os) Constructor Creates a new PostscriptGraphics object, given dimensions and output file. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
addPSFontReplacement
(String replace, String with) adds the PS font name to replace and its replacement in the replacement hashtablevoid
addRenderingHints
(Map<?, ?> m) void
clearRect
(int x, int y, int width, int height) Draw a filled rectangle with the background color.void
void
clipRect
(int x, int y, int width, int height) Not implementedvoid
copyArea
(int x, int y, int width, int height, int dx, int dy) Not implementedcreate()
Clone a PostscriptGraphics objectvoid
dispose()
Not implementedvoid
void
draw3DRect
(int x, int y, int width, int height, boolean raised) Draw an outlined rectangle with 3D effect in current pen color.void
drawArc
(int x, int y, int width, int height, int startAngle, int arcAngle) Not implementedvoid
drawBytes
(byte[] data, int offset, int length, int x, int y) simply calls drawString(String,int,int)void
drawChars
(char[] data, int offset, int length, int x, int y) simply calls drawString(String,int,int)void
drawGlyphVector
(GlyphVector gv, float f1, float f2) void
drawImage
(BufferedImage bi, BufferedImageOp bio, int i1, int i2) boolean
drawImage
(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer) Not implementedboolean
drawImage
(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer) calls drawImage(Image,int,int,int,int,int,int,int,int,Color,ImageObserver) with Color.WHITE as background colorboolean
drawImage
(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer) PS see http://astronomy.swin.edu.au/~pbourke/geomformats/postscript/ Java http ://show.docjava.com:8086/book/cgij/doc/ip/graphics/SimpleImageFrame.java .htmlboolean
drawImage
(Image img, int x, int y, int width, int height, ImageObserver observer) calls drawImage(Image,int,int,int,int,Color,ImageObserver) with the color WHITE as backgroundboolean
drawImage
(Image img, int x, int y, Color bgcolor, ImageObserver observer) calls drawImage(Image,int,int,int,int,Color,ImageObserver)boolean
drawImage
(Image img, int x, int y, ImageObserver observer) calls drawImage(Image,int,int,Color,ImageObserver) with Color.WHITE as background colorboolean
drawImage
(Image im, AffineTransform at, ImageObserver io) void
drawLine
(int x1, int y1, int x2, int y2) Draw a line in current pen color.void
drawOval
(int x, int y, int width, int height) Draw an Oval outline in current pen color.void
drawPolygon
(int[] xPoints, int[] yPoints, int nPoints) Not implementedvoid
drawPolyline
(int[] xPoints, int[] yPoints, int nPoints) Not implementedvoid
drawRect
(int x, int y, int width, int height) Draw an outlined rectangle in current pen color.void
void
void
drawRoundRect
(int x, int y, int width, int height, int arcWidth, int arcHeight) Not implementedvoid
drawString
(String str, float x, float y) void
drawString
(String str, int x, int y) Draw text in current pen color.void
drawString
(AttributedCharacterIterator aci, float f1, float f2) void
drawString
(AttributedCharacterIterator iterator, int x, int y) Not implementedvoid
void
fill3DRect
(int x, int y, int width, int height, boolean raised) Draw a filled rectangle with 3D effect in current pen color.void
fillArc
(int x, int y, int width, int height, int startAngle, int arcAngle) Not implementedvoid
fillOval
(int x, int y, int width, int height) Draw a filled Oval in current pen color.void
fillPolygon
(int[] xPoints, int[] yPoints, int nPoints) Not implementedvoid
Not implementedvoid
fillRect
(int x, int y, int width, int height) Draw a filled rectangle in current pen color.void
fillRoundRect
(int x, int y, int width, int height, int arcWidth, int arcHeight) Not implementedvoid
finalize()
Not implementedvoid
finished()
Finalizes output file.getClip()
Not implementedThis returns the full current drawing areaThis returns the full current drawing areaNot implementedgetColor()
Get current pen color.getFont()
Get current font.Get Font metricsSTART overridden Graphics2D methodsgetPaint()
boolean
void
rotate
(double d1) void
rotate
(double d1, double d2, double d3) void
scale
(double d1, double d2) void
void
setClip
(int x, int y, int width, int height) Not implementedvoid
Not implementedvoid
Set current pen color.void
void
Set current font.void
void
Not implementedvoid
setRenderingHint
(RenderingHints.Key key, Object o) void
setRenderingHints
(Map<?, ?> m) void
void
void
setXORMode
(Color c1) Not implementedvoid
shear
(double d1, double d2) void
void
translate
(double d1, double d2) void
translate
(int x, int y) Translates the origin of the graphics context to the point (x, y) in the current coordinate system.Methods inherited from class java.awt.Graphics
create, drawPolygon, getFontMetrics, hitClip, toString
-
Constructor Details
-
PostscriptGraphics
Constructor Creates a new PostscriptGraphics object, given dimensions and output file.- Parameters:
width
- The width of eps in points.height
- The height of eps in points.os
- File to send postscript to.
-
-
Method Details
-
finished
public void finished()Finalizes output file. -
addPSFontReplacement
adds the PS font name to replace and its replacement in the replacement hashtable- Parameters:
replace
- the PS font name to replacewith
- the PS font name to replace the font with
-
clearRect
public void clearRect(int x, int y, int width, int height) Draw a filled rectangle with the background color. -
clipRect
public void clipRect(int x, int y, int width, int height) Not implemented -
copyArea
public void copyArea(int x, int y, int width, int height, int dx, int dy) Not implemented -
create
Clone a PostscriptGraphics object -
dispose
public void dispose()Not implemented -
draw3DRect
public void draw3DRect(int x, int y, int width, int height, boolean raised) Draw an outlined rectangle with 3D effect in current pen color. (Current implementation: draw simple outlined rectangle)- Overrides:
draw3DRect
in classGraphics2D
- Parameters:
x
- starting x coordy
- starting y coordwidth
- rectangle widthheight
- rectangle heightraised
- True: appear raised, False: appear etched
-
drawArc
public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) Not implemented -
drawBytes
public void drawBytes(byte[] data, int offset, int length, int x, int y) simply calls drawString(String,int,int) -
drawChars
public void drawChars(char[] data, int offset, int length, int x, int y) simply calls drawString(String,int,int) -
drawImage
calls drawImage(Image,int,int,int,int,Color,ImageObserver) -
drawImage
calls drawImage(Image,int,int,Color,ImageObserver) with Color.WHITE as background color -
drawImage
public boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer) PS see http://astronomy.swin.edu.au/~pbourke/geomformats/postscript/ Java http ://show.docjava.com:8086/book/cgij/doc/ip/graphics/SimpleImageFrame.java .html -
drawImage
calls drawImage(Image,int,int,int,int,Color,ImageObserver) with the color WHITE as background -
drawImage
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) Not implemented -
drawImage
public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer) calls drawImage(Image,int,int,int,int,int,int,int,int,Color,ImageObserver) with Color.WHITE as background color -
drawLine
public void drawLine(int x1, int y1, int x2, int y2) Draw a line in current pen color. -
drawOval
public void drawOval(int x, int y, int width, int height) Draw an Oval outline in current pen color. -
drawPolygon
public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints) Not implemented- Specified by:
drawPolygon
in classGraphics
-
drawPolyline
public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints) Not implemented- Specified by:
drawPolyline
in classGraphics
-
drawRect
public void drawRect(int x, int y, int width, int height) Draw an outlined rectangle in current pen color. -
drawRoundRect
public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) Not implemented- Specified by:
drawRoundRect
in classGraphics
-
drawString
Not implemented- Specified by:
drawString
in classGraphics2D
-
drawString
Draw text in current pen color.- Specified by:
drawString
in classGraphics2D
- Parameters:
str
- Text to outputx
- starting x coordy
- starting y coord
-
fill3DRect
public void fill3DRect(int x, int y, int width, int height, boolean raised) Draw a filled rectangle with 3D effect in current pen color. (Current implementation: draw simple filled rectangle)- Overrides:
fill3DRect
in classGraphics2D
- Parameters:
x
- starting x coordy
- starting y coordwidth
- rectangle widthheight
- rectangle heightraised
- True: appear raised, False: appear etched
-
fillArc
public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) Not implemented -
fillOval
public void fillOval(int x, int y, int width, int height) Draw a filled Oval in current pen color. -
fillPolygon
public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) Not implemented- Specified by:
fillPolygon
in classGraphics
-
fillPolygon
Not implemented- Overrides:
fillPolygon
in classGraphics
-
fillRect
public void fillRect(int x, int y, int width, int height) Draw a filled rectangle in current pen color. -
fillRoundRect
public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) Not implemented- Specified by:
fillRoundRect
in classGraphics
-
finalize
public void finalize()Not implemented -
getClip
Not implemented -
getClipBounds
This returns the full current drawing area- Specified by:
getClipBounds
in classGraphics
- Returns:
- full drawing area
-
getClipBounds
This returns the full current drawing area- Overrides:
getClipBounds
in classGraphics
- Returns:
- full drawing area
-
getClipRect
Not implemented- Overrides:
getClipRect
in classGraphics
-
getColor
Get current pen color. -
getFont
Get current font. -
getFontMetrics
Get Font metrics- Specified by:
getFontMetrics
in classGraphics
- Parameters:
f
- Font- Returns:
- Font metrics.
-
setClip
public void setClip(int x, int y, int width, int height) Not implemented -
setClip
Not implemented -
setColor
Set current pen color. Default to black if null. -
setFont
Set current font. Default to Plain Courier 11 if null. -
setPaintMode
public void setPaintMode()Not implemented- Specified by:
setPaintMode
in classGraphics
-
setXORMode
Not implemented- Specified by:
setXORMode
in classGraphics
-
translate
public void translate(int x, int y) Translates the origin of the graphics context to the point (x, y) in the current coordinate system. Modifies this graphics context so that its new origin corresponds to the point (x, y) in this graphics context's original coordinate system. All coordinates used in subsequent rendering operations on this graphics context will be relative to this new origin.- Specified by:
translate
in classGraphics2D
- Parameters:
x
- the x coordinate.y
- the y coordinate.
-
getFontRenderContext
START overridden Graphics2D methods- Specified by:
getFontRenderContext
in classGraphics2D
-
clip
- Specified by:
clip
in classGraphics2D
-
getStroke
- Specified by:
getStroke
in classGraphics2D
-
getBackground
- Specified by:
getBackground
in classGraphics2D
-
setBackground
- Specified by:
setBackground
in classGraphics2D
-
getComposite
- Specified by:
getComposite
in classGraphics2D
-
getPaint
- Specified by:
getPaint
in classGraphics2D
-
getTransform
- Specified by:
getTransform
in classGraphics2D
-
setTransform
- Specified by:
setTransform
in classGraphics2D
-
transform
- Specified by:
transform
in classGraphics2D
-
shear
public void shear(double d1, double d2) - Specified by:
shear
in classGraphics2D
-
scale
public void scale(double d1, double d2) - Specified by:
scale
in classGraphics2D
-
rotate
public void rotate(double d1, double d2, double d3) - Specified by:
rotate
in classGraphics2D
-
rotate
public void rotate(double d1) - Specified by:
rotate
in classGraphics2D
-
translate
public void translate(double d1, double d2) - Specified by:
translate
in classGraphics2D
-
getRenderingHints
- Specified by:
getRenderingHints
in classGraphics2D
-
addRenderingHints
- Specified by:
addRenderingHints
in classGraphics2D
-
setRenderingHints
- Specified by:
setRenderingHints
in classGraphics2D
-
getRenderingHint
- Specified by:
getRenderingHint
in classGraphics2D
-
setRenderingHint
- Specified by:
setRenderingHint
in classGraphics2D
-
setStroke
- Specified by:
setStroke
in classGraphics2D
-
setPaint
- Specified by:
setPaint
in classGraphics2D
-
setComposite
- Specified by:
setComposite
in classGraphics2D
-
getDeviceConfiguration
- Specified by:
getDeviceConfiguration
in classGraphics2D
-
hit
- Specified by:
hit
in classGraphics2D
-
fill
- Specified by:
fill
in classGraphics2D
-
drawGlyphVector
- Specified by:
drawGlyphVector
in classGraphics2D
-
drawString
- Specified by:
drawString
in classGraphics2D
-
drawString
- Specified by:
drawString
in classGraphics2D
-
drawRenderableImage
- Specified by:
drawRenderableImage
in classGraphics2D
-
drawRenderedImage
- Specified by:
drawRenderedImage
in classGraphics2D
-
drawImage
- Specified by:
drawImage
in classGraphics2D
-
drawImage
- Specified by:
drawImage
in classGraphics2D
-
draw
- Specified by:
draw
in classGraphics2D
-