Package weka.gui.visualize
Class PostscriptGraphics
- java.lang.Object
-
- java.awt.Graphics
-
- java.awt.Graphics2D
-
- weka.gui.visualize.PostscriptGraphics
-
public class PostscriptGraphics extends java.awt.Graphics2DThe 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: 7059 $
- 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
Constructors Constructor Description PostscriptGraphics(int width, int height, java.io.OutputStream os)Constructor Creates a new PostscriptGraphics object, given dimensions and output file.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidaddPSFontReplacement(java.lang.String replace, java.lang.String with)adds the PS font name to replace and its replacement in the replacement hashtablevoidaddRenderingHints(java.util.Map m)voidclearRect(int x, int y, int width, int height)Draw a filled rectangle with the background color.voidclip(java.awt.Shape s)voidclipRect(int x, int y, int width, int height)Not implementedvoidcopyArea(int x, int y, int width, int height, int dx, int dy)Not implementedjava.awt.Graphicscreate()Clone a PostscriptGraphics objectvoiddispose()Not implementedvoiddraw(java.awt.Shape s)voiddraw3DRect(int x, int y, int width, int height, boolean raised)Draw an outlined rectangle with 3D effect in current pen color.voiddrawArc(int x, int y, int width, int height, int startAngle, int arcAngle)Not implementedvoiddrawBytes(byte[] data, int offset, int length, int x, int y)simply calls drawString(String,int,int)voiddrawChars(char[] data, int offset, int length, int x, int y)simply calls drawString(String,int,int)voiddrawGlyphVector(java.awt.font.GlyphVector gv, float f1, float f2)voiddrawImage(java.awt.image.BufferedImage bi, java.awt.image.BufferedImageOp bio, int i1, int i2)booleandrawImage(java.awt.Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)Not implementedbooleandrawImage(java.awt.Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.image.ImageObserver observer)calls drawImage(Image,int,int,int,int,int,int,int,int,Color,ImageObserver) with Color.WHITE as background colorbooleandrawImage(java.awt.Image img, int x, int y, int width, int height, java.awt.Color bgcolor, java.awt.image.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.htmlbooleandrawImage(java.awt.Image img, int x, int y, int width, int height, java.awt.image.ImageObserver observer)calls drawImage(Image,int,int,int,int,Color,ImageObserver) with the color WHITE as backgroundbooleandrawImage(java.awt.Image img, int x, int y, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)calls drawImage(Image,int,int,int,int,Color,ImageObserver)booleandrawImage(java.awt.Image img, int x, int y, java.awt.image.ImageObserver observer)calls drawImage(Image,int,int,Color,ImageObserver) with Color.WHITE as background colorbooleandrawImage(java.awt.Image im, java.awt.geom.AffineTransform at, java.awt.image.ImageObserver io)voiddrawLine(int x1, int y1, int x2, int y2)Draw a line in current pen color.voiddrawOval(int x, int y, int width, int height)Draw an Oval outline in current pen color.voiddrawPolygon(int[] xPoints, int[] yPoints, int nPoints)Not implementedvoiddrawPolyline(int[] xPoints, int[] yPoints, int nPoints)Not implementedvoiddrawRect(int x, int y, int width, int height)Draw an outlined rectangle in current pen color.voiddrawRenderableImage(java.awt.image.renderable.RenderableImage ri, java.awt.geom.AffineTransform at)voiddrawRenderedImage(java.awt.image.RenderedImage ri, java.awt.geom.AffineTransform af)voiddrawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)Not implementedvoiddrawString(java.lang.String str, float x, float y)voiddrawString(java.lang.String str, int x, int y)Draw text in current pen color.voiddrawString(java.text.AttributedCharacterIterator aci, float f1, float f2)voiddrawString(java.text.AttributedCharacterIterator iterator, int x, int y)Not implementedvoidfill(java.awt.Shape s)voidfill3DRect(int x, int y, int width, int height, boolean raised)Draw a filled rectangle with 3D effect in current pen color.voidfillArc(int x, int y, int width, int height, int startAngle, int arcAngle)Not implementedvoidfillOval(int x, int y, int width, int height)Draw a filled Oval in current pen color.voidfillPolygon(int[] xPoints, int[] yPoints, int nPoints)Not implementedvoidfillPolygon(java.awt.Polygon p)Not implementedvoidfillRect(int x, int y, int width, int height)Draw a filled rectangle in current pen color.voidfillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)Not implementedvoidfinalize()Not implementedvoidfinished()Finalizes output file.java.awt.ColorgetBackground()java.awt.ShapegetClip()Not implementedjava.awt.RectanglegetClipBounds()This returns the full current drawing areajava.awt.RectanglegetClipBounds(java.awt.Rectangle r)This returns the full current drawing areajava.awt.RectanglegetClipRect()Not implementedjava.awt.ColorgetColor()Get current pen color.java.awt.CompositegetComposite()java.awt.GraphicsConfigurationgetDeviceConfiguration()java.awt.FontgetFont()Get current font.java.awt.FontMetricsgetFontMetrics(java.awt.Font f)Get Font metricsjava.awt.font.FontRenderContextgetFontRenderContext()START overridden Graphics2D methodsjava.awt.PaintgetPaint()java.lang.ObjectgetRenderingHint(java.awt.RenderingHints.Key key)java.awt.RenderingHintsgetRenderingHints()java.awt.StrokegetStroke()java.awt.geom.AffineTransformgetTransform()booleanhit(java.awt.Rectangle r, java.awt.Shape s, boolean onstroke)voidrotate(double d1)voidrotate(double d1, double d2, double d3)voidscale(double d1, double d2)voidsetBackground(java.awt.Color c)voidsetClip(int x, int y, int width, int height)Not implementedvoidsetClip(java.awt.Shape clip)Not implementedvoidsetColor(java.awt.Color c)Set current pen color.voidsetComposite(java.awt.Composite c)voidsetFont(java.awt.Font font)Set current font.voidsetPaint(java.awt.Paint p)voidsetPaintMode()Not implementedvoidsetRenderingHint(java.awt.RenderingHints.Key key, java.lang.Object o)voidsetRenderingHints(java.util.Map m)voidsetStroke(java.awt.Stroke s)voidsetTransform(java.awt.geom.AffineTransform at)voidsetXORMode(java.awt.Color c1)Not implementedvoidshear(double d1, double d2)voidtransform(java.awt.geom.AffineTransform at)voidtranslate(double d1, double d2)voidtranslate(int x, int y)Translates the origin of the graphics context to the point (x, y) in the current coordinate system.
-
-
-
Constructor Detail
-
PostscriptGraphics
public PostscriptGraphics(int width, int height, java.io.OutputStream os)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 Detail
-
finished
public void finished()
Finalizes output file.
-
addPSFontReplacement
public static void addPSFontReplacement(java.lang.String replace, java.lang.String with)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.- Specified by:
clearRectin classjava.awt.Graphics- Parameters:
x- starting x coordy- starting y coordwidth- rectangle widthheight- rectangle height
-
clipRect
public void clipRect(int x, int y, int width, int height)Not implemented- Specified by:
clipRectin classjava.awt.Graphics
-
copyArea
public void copyArea(int x, int y, int width, int height, int dx, int dy)Not implemented- Specified by:
copyAreain classjava.awt.Graphics
-
create
public java.awt.Graphics create()
Clone a PostscriptGraphics object- Specified by:
createin classjava.awt.Graphics
-
dispose
public void dispose()
Not implemented- Specified by:
disposein classjava.awt.Graphics
-
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:
draw3DRectin classjava.awt.Graphics2D- 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- Specified by:
drawArcin classjava.awt.Graphics
-
drawBytes
public void drawBytes(byte[] data, int offset, int length, int x, int y)simply calls drawString(String,int,int)- Overrides:
drawBytesin classjava.awt.Graphics- See Also:
drawString(String,int,int)
-
drawChars
public void drawChars(char[] data, int offset, int length, int x, int y)simply calls drawString(String,int,int)- Overrides:
drawCharsin classjava.awt.Graphics- See Also:
drawString(String,int,int)
-
drawImage
public boolean drawImage(java.awt.Image img, int x, int y, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)calls drawImage(Image,int,int,int,int,Color,ImageObserver)- Specified by:
drawImagein classjava.awt.Graphics- See Also:
drawImage(Image,int,int,int,int,Color,ImageObserver)
-
drawImage
public boolean drawImage(java.awt.Image img, int x, int y, java.awt.image.ImageObserver observer)calls drawImage(Image,int,int,Color,ImageObserver) with Color.WHITE as background color- Specified by:
drawImagein classjava.awt.Graphics- See Also:
drawImage(Image,int,int,Color,ImageObserver),Color.WHITE
-
drawImage
public boolean drawImage(java.awt.Image img, int x, int y, int width, int height, java.awt.Color bgcolor, java.awt.image.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- Specified by:
drawImagein classjava.awt.Graphics
-
drawImage
public boolean drawImage(java.awt.Image img, int x, int y, int width, int height, java.awt.image.ImageObserver observer)calls drawImage(Image,int,int,int,int,Color,ImageObserver) with the color WHITE as background- Specified by:
drawImagein classjava.awt.Graphics- See Also:
drawImage(Image,int,int,int,int,Color,ImageObserver),Color.WHITE
-
drawImage
public boolean drawImage(java.awt.Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)Not implemented- Specified by:
drawImagein classjava.awt.Graphics
-
drawImage
public boolean drawImage(java.awt.Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.image.ImageObserver observer)calls drawImage(Image,int,int,int,int,int,int,int,int,Color,ImageObserver) with Color.WHITE as background color- Specified by:
drawImagein classjava.awt.Graphics- See Also:
drawImage(Image,int,int,int,int,int,int,int,int,Color,ImageObserver)
-
drawLine
public void drawLine(int x1, int y1, int x2, int y2)Draw a line in current pen color.- Specified by:
drawLinein classjava.awt.Graphics- Parameters:
x1- starting x coordy1- starting y coordx2- ending x coordy2- ending y coord
-
drawOval
public void drawOval(int x, int y, int width, int height)Draw an Oval outline in current pen color.- Specified by:
drawOvalin classjava.awt.Graphics- Parameters:
x- x-axis center of ovaly- y-axis center of ovalwidth- oval widthheight- oval height
-
drawPolygon
public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)Not implemented- Specified by:
drawPolygonin classjava.awt.Graphics
-
drawPolyline
public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)Not implemented- Specified by:
drawPolylinein classjava.awt.Graphics
-
drawRect
public void drawRect(int x, int y, int width, int height)Draw an outlined rectangle in current pen color.- Overrides:
drawRectin classjava.awt.Graphics- Parameters:
x- starting x coordy- starting y coordwidth- rectangle widthheight- rectangle height
-
drawRoundRect
public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)Not implemented- Specified by:
drawRoundRectin classjava.awt.Graphics
-
drawString
public void drawString(java.text.AttributedCharacterIterator iterator, int x, int y)Not implemented- Specified by:
drawStringin classjava.awt.Graphics2D
-
drawString
public void drawString(java.lang.String str, int x, int y)Draw text in current pen color.- Specified by:
drawStringin classjava.awt.Graphics2D- 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:
fill3DRectin classjava.awt.Graphics2D- 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- Specified by:
fillArcin classjava.awt.Graphics
-
fillOval
public void fillOval(int x, int y, int width, int height)Draw a filled Oval in current pen color.- Specified by:
fillOvalin classjava.awt.Graphics- Parameters:
x- x-axis center of ovaly- y-axis center of ovalwidth- oval widthheight- oval height
-
fillPolygon
public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)Not implemented- Specified by:
fillPolygonin classjava.awt.Graphics
-
fillPolygon
public void fillPolygon(java.awt.Polygon p)
Not implemented- Overrides:
fillPolygonin classjava.awt.Graphics
-
fillRect
public void fillRect(int x, int y, int width, int height)Draw a filled rectangle in current pen color.- Specified by:
fillRectin classjava.awt.Graphics- Parameters:
x- starting x coordy- starting y coordwidth- rectangle widthheight- rectangle height
-
fillRoundRect
public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)Not implemented- Specified by:
fillRoundRectin classjava.awt.Graphics
-
finalize
public void finalize()
Not implemented- Overrides:
finalizein classjava.awt.Graphics
-
getClip
public java.awt.Shape getClip()
Not implemented- Specified by:
getClipin classjava.awt.Graphics
-
getClipBounds
public java.awt.Rectangle getClipBounds()
This returns the full current drawing area- Specified by:
getClipBoundsin classjava.awt.Graphics- Returns:
- full drawing area
-
getClipBounds
public java.awt.Rectangle getClipBounds(java.awt.Rectangle r)
This returns the full current drawing area- Overrides:
getClipBoundsin classjava.awt.Graphics- Returns:
- full drawing area
-
getClipRect
public java.awt.Rectangle getClipRect()
Not implemented- Overrides:
getClipRectin classjava.awt.Graphics
-
getColor
public java.awt.Color getColor()
Get current pen color.- Specified by:
getColorin classjava.awt.Graphics- Returns:
- current pen color.
-
getFont
public java.awt.Font getFont()
Get current font.- Specified by:
getFontin classjava.awt.Graphics- Returns:
- current font.
-
getFontMetrics
public java.awt.FontMetrics getFontMetrics(java.awt.Font f)
Get Font metrics- Specified by:
getFontMetricsin classjava.awt.Graphics- Parameters:
f- Font- Returns:
- Font metrics.
-
setClip
public void setClip(int x, int y, int width, int height)Not implemented- Specified by:
setClipin classjava.awt.Graphics
-
setClip
public void setClip(java.awt.Shape clip)
Not implemented- Specified by:
setClipin classjava.awt.Graphics
-
setColor
public void setColor(java.awt.Color c)
Set current pen color. Default to black if null.- Specified by:
setColorin classjava.awt.Graphics- Parameters:
c- new pen color.
-
setFont
public void setFont(java.awt.Font font)
Set current font. Default to Plain Courier 11 if null.- Specified by:
setFontin classjava.awt.Graphics- Parameters:
font- new font.
-
setPaintMode
public void setPaintMode()
Not implemented- Specified by:
setPaintModein classjava.awt.Graphics
-
setXORMode
public void setXORMode(java.awt.Color c1)
Not implemented- Specified by:
setXORModein classjava.awt.Graphics
-
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:
translatein classjava.awt.Graphics2D- Parameters:
x- the x coordinate.y- the y coordinate.
-
getFontRenderContext
public java.awt.font.FontRenderContext getFontRenderContext()
START overridden Graphics2D methods- Specified by:
getFontRenderContextin classjava.awt.Graphics2D
-
clip
public void clip(java.awt.Shape s)
- Specified by:
clipin classjava.awt.Graphics2D
-
getStroke
public java.awt.Stroke getStroke()
- Specified by:
getStrokein classjava.awt.Graphics2D
-
getBackground
public java.awt.Color getBackground()
- Specified by:
getBackgroundin classjava.awt.Graphics2D
-
setBackground
public void setBackground(java.awt.Color c)
- Specified by:
setBackgroundin classjava.awt.Graphics2D
-
getComposite
public java.awt.Composite getComposite()
- Specified by:
getCompositein classjava.awt.Graphics2D
-
getPaint
public java.awt.Paint getPaint()
- Specified by:
getPaintin classjava.awt.Graphics2D
-
getTransform
public java.awt.geom.AffineTransform getTransform()
- Specified by:
getTransformin classjava.awt.Graphics2D
-
setTransform
public void setTransform(java.awt.geom.AffineTransform at)
- Specified by:
setTransformin classjava.awt.Graphics2D
-
transform
public void transform(java.awt.geom.AffineTransform at)
- Specified by:
transformin classjava.awt.Graphics2D
-
shear
public void shear(double d1, double d2)- Specified by:
shearin classjava.awt.Graphics2D
-
scale
public void scale(double d1, double d2)- Specified by:
scalein classjava.awt.Graphics2D
-
rotate
public void rotate(double d1, double d2, double d3)- Specified by:
rotatein classjava.awt.Graphics2D
-
rotate
public void rotate(double d1)
- Specified by:
rotatein classjava.awt.Graphics2D
-
translate
public void translate(double d1, double d2)- Specified by:
translatein classjava.awt.Graphics2D
-
getRenderingHints
public java.awt.RenderingHints getRenderingHints()
- Specified by:
getRenderingHintsin classjava.awt.Graphics2D
-
addRenderingHints
public void addRenderingHints(java.util.Map m)
- Specified by:
addRenderingHintsin classjava.awt.Graphics2D
-
setRenderingHints
public void setRenderingHints(java.util.Map m)
- Specified by:
setRenderingHintsin classjava.awt.Graphics2D
-
getRenderingHint
public java.lang.Object getRenderingHint(java.awt.RenderingHints.Key key)
- Specified by:
getRenderingHintin classjava.awt.Graphics2D
-
setRenderingHint
public void setRenderingHint(java.awt.RenderingHints.Key key, java.lang.Object o)- Specified by:
setRenderingHintin classjava.awt.Graphics2D
-
setStroke
public void setStroke(java.awt.Stroke s)
- Specified by:
setStrokein classjava.awt.Graphics2D
-
setPaint
public void setPaint(java.awt.Paint p)
- Specified by:
setPaintin classjava.awt.Graphics2D
-
setComposite
public void setComposite(java.awt.Composite c)
- Specified by:
setCompositein classjava.awt.Graphics2D
-
getDeviceConfiguration
public java.awt.GraphicsConfiguration getDeviceConfiguration()
- Specified by:
getDeviceConfigurationin classjava.awt.Graphics2D
-
hit
public boolean hit(java.awt.Rectangle r, java.awt.Shape s, boolean onstroke)- Specified by:
hitin classjava.awt.Graphics2D
-
fill
public void fill(java.awt.Shape s)
- Specified by:
fillin classjava.awt.Graphics2D
-
drawGlyphVector
public void drawGlyphVector(java.awt.font.GlyphVector gv, float f1, float f2)- Specified by:
drawGlyphVectorin classjava.awt.Graphics2D
-
drawString
public void drawString(java.text.AttributedCharacterIterator aci, float f1, float f2)- Specified by:
drawStringin classjava.awt.Graphics2D
-
drawString
public void drawString(java.lang.String str, float x, float y)- Specified by:
drawStringin classjava.awt.Graphics2D
-
drawRenderableImage
public void drawRenderableImage(java.awt.image.renderable.RenderableImage ri, java.awt.geom.AffineTransform at)- Specified by:
drawRenderableImagein classjava.awt.Graphics2D
-
drawRenderedImage
public void drawRenderedImage(java.awt.image.RenderedImage ri, java.awt.geom.AffineTransform af)- Specified by:
drawRenderedImagein classjava.awt.Graphics2D
-
drawImage
public void drawImage(java.awt.image.BufferedImage bi, java.awt.image.BufferedImageOp bio, int i1, int i2)- Specified by:
drawImagein classjava.awt.Graphics2D
-
drawImage
public boolean drawImage(java.awt.Image im, java.awt.geom.AffineTransform at, java.awt.image.ImageObserver io)- Specified by:
drawImagein classjava.awt.Graphics2D
-
draw
public void draw(java.awt.Shape s)
- Specified by:
drawin classjava.awt.Graphics2D
-
-