|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Graphics | +--PSGr
PSGr is a awt.Graphics subclass that images to PostScript. (C) 1996 E.J. Friedman-Hill and Sandia National Labs
Field Summary | |
protected java.awt.Color |
backClr
|
protected java.awt.Rectangle |
clippingRect
|
static int |
CLONE
|
protected java.awt.Color |
clr
|
protected boolean |
disposed
|
protected java.awt.Font |
font
|
protected java.io.PrintStream |
os
|
protected int |
Page_Height
|
protected int |
Page_Margin
|
protected int |
Page_Width
|
protected static int |
PAGEHEIGHT
|
protected static int |
PAGEMARGIN
|
protected static int |
PAGEWIDTH
|
protected java.awt.Graphics |
realg
|
Constructor Summary | |
|
PSGr(java.io.OutputStream o,
java.awt.Graphics g)
Constructs a new PSGr Object. |
protected |
PSGr(java.io.OutputStream o,
java.awt.Graphics g,
int what)
|
|
PSGr(java.io.OutputStream o,
java.awt.Graphics g,
int margin,
int width,
int height)
Constructor for non-default page dimensions. |
Method Summary | |
void |
clearRect(int x,
int y,
int width,
int height)
Clears the specified rectangle by filling it with the current background color of the current drawing surface. |
void |
clipRect(int x,
int y,
int width,
int height)
Clips to a rectangle. |
void |
copyArea(int x,
int y,
int width,
int height,
int dx,
int dy)
Copies an area of the screen. |
java.awt.Graphics |
create()
Container.paint calls create and dispose, for a separate g to clip and position each child and then restore larger clip and original coordinates by disposing of the smaller g and using the original g. |
java.awt.Graphics |
create(int x,
int y,
int width,
int height)
Creates a new PSGr Object with the specified parameters, based on the original PSGr Object. |
void |
dispose()
Disposes of this Graphics context, which cannot be used after being disposed of. |
protected boolean |
doImage(java.awt.Image img,
int x,
int y,
int width,
int height,
java.awt.image.ImageObserver observer,
java.awt.Color bgcolor)
|
protected void |
doRect(int x,
int y,
int width,
int height,
boolean fill)
|
void |
draw3DRect(int x,
int y,
int width,
int height,
boolean raised)
Draws a highlighted 3-D rectangle. |
void |
drawArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)
Draws an arc bounded by the specified rectangle from startAngle to endAngle. 0 degrees is at the 3-o'clock position.Positive arc angles indicate counter-clockwise rotations, negative arc angles are drawn clockwise. |
void |
drawBytes(byte[] data,
int offset,
int length,
int x,
int y)
Draws the specified bytes using the current font and color. |
void |
drawChars(char[] data,
int offset,
int length,
int x,
int y)
Draws the specified characters using the current font and color. |
boolean |
drawImage(java.awt.Image img,
int x,
int y,
java.awt.Color bgcolor,
java.awt.image.ImageObserver observer)
Draws the specified image at the specified top left (x, y), with width and height determined by the image. |
boolean |
drawImage(java.awt.Image img,
int x,
int y,
java.awt.image.ImageObserver observer)
Draws the specified image at the specified top left (x, y), with width and height determined by the image. |
boolean |
drawImage(java.awt.Image img,
int x,
int y,
int width,
int height,
java.awt.Color bgcolor,
java.awt.image.ImageObserver observer)
Draws the specified image inside the specified rectangle. |
boolean |
drawImage(java.awt.Image img,
int x,
int y,
int width,
int height,
java.awt.image.ImageObserver observer)
Draws the specified image inside the specified rectangle. |
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)
Scaling and translating versions not supported -- BUT COULD BE |
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)
Scaling and translating versions not supported -- BUT WE COULD |
void |
drawLine(int x1,
int y1,
int x2,
int y2)
Draws a line between the coordinates (x1,y1) and (x2,y2). |
void |
drawOval(int x,
int y,
int width,
int height)
Draws an oval inside the specified rectangle using the current color. |
void |
drawPolygon(int[] xPoints,
int[] yPoints,
int nPoints)
Draws a polygon defined by an array of x points and y points. |
void |
drawPolygon(java.awt.Polygon p)
Draws a polygon defined by the specified point. |
void |
drawPolyline(int[] x,
int[] y,
int np)
Polyline MGH added to satisfy 1.1 API |
void |
drawRect(int x,
int y,
int width,
int height)
Draws the outline of the specified rectangle using the current color. |
void |
drawRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
Draws an outlined rounded corner rectangle using the current color. |
void |
drawString(java.text.AttributedCharacterIterator a,
int x,
int y)
|
void |
drawString(java.lang.String str,
int x,
int y)
Draws the specified String using the current font and color. |
protected int |
dTrans(int d)
|
protected void |
emitProlog()
Top of every PS file needs this. |
void |
emitThis(java.lang.String s)
|
void |
emitThisNext(java.lang.String s)
|
void |
fill3DRect(int x,
int y,
int width,
int height,
boolean raised)
Paints a highlighted 3-D rectangle using the current color. |
void |
fillArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)
Fills an arc using the current color. |
void |
fillOval(int x,
int y,
int width,
int height)
Fills an oval inside the specified rectangle using the current color. |
void |
fillPolygon(int[] xPoints,
int[] yPoints,
int nPoints)
Fills a polygon with the current color. |
void |
fillPolygon(java.awt.Polygon p)
Fills the specified polygon with the current color. |
void |
fillRect(int x,
int y,
int width,
int height)
Fills the specified rectangle with the current color. |
void |
fillRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
Draws a rounded rectangle filled in with the current color. |
void |
finalize()
Disposes of this graphics context once it is no longer referenced. |
java.awt.Shape |
getClip()
MGH added Shape getClip () per 1.1 API. |
java.awt.Rectangle |
getClipBounds()
|
java.awt.Rectangle |
getClipRect()
Deprecated. in 1.1 |
java.awt.Color |
getColor()
Gets the current color. |
java.awt.Font |
getFont()
Gets the current font. |
java.awt.FontMetrics |
getFontMetrics()
Gets the current font metrics. |
java.awt.FontMetrics |
getFontMetrics(java.awt.Font f)
Gets the current font metrics for the specified font. |
int |
getPageHeight()
|
int |
getPageMargin()
Printing dimensions default or set at construct time. |
int |
getPageWidth()
|
protected void |
grestore()
|
protected void |
gsave()
Save and restore the PostScript state, SHOULD ALSO any Java mirror state |
protected void |
myBasicPaint(java.awt.Component comp,
boolean edge)
|
protected java.lang.String |
myHexString(int n)
|
protected void |
scale(float sx,
float sy)
Scales the graphics context. |
void |
scalePaint(java.awt.Component top)
Find scale factor that will fit the page, use smaller of x and y for both, to convert all pixels to points. |
protected void |
setBackground(java.awt.Color c)
Gets the current color. |
void |
setClip(int x,
int y,
int width,
int height)
MGH added setClip (x y w h) per 1.1 API, this is supposed to be **NEW** Clip, rather than intersection with existing Clip, but that may not be correct yet.. |
void |
setClip(java.awt.Shape s)
MGH added setClip (Shape s) hacked over Rectangle. |
void |
setColor(java.awt.Color c)
Sets the current color to the specified color. |
void |
setFont(java.awt.Font f)
Sets the font for all subsequent text-drawing operations. |
void |
setPaintMode()
Sets the default paint mode to overwrite the destination with the current color. |
void |
setXORMode(java.awt.Color c1)
Sets the paint mode to alternate between the current color and the new specified color. |
void |
showpage()
Needed unless the file is intended as part of a larger one. |
protected java.lang.String |
strunc(double d)
|
java.lang.String |
toString()
Returns a String object representing this Graphic's value. |
void |
translate(int x,
int y)
Translates the origin of the graphics context to the specified parameters. |
protected int |
xTrans(int x)
|
protected int |
yTrans(int y)
|
Methods inherited from class java.awt.Graphics |
getClipBounds, hitClip |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int CLONE
protected static final int PAGEMARGIN
protected static final int PAGEHEIGHT
protected static final int PAGEWIDTH
protected int Page_Margin
protected int Page_Height
protected int Page_Width
protected java.io.PrintStream os
protected java.awt.Color clr
protected java.awt.Color backClr
protected java.awt.Font font
protected java.awt.Rectangle clippingRect
protected java.awt.Graphics realg
protected boolean disposed
Constructor Detail |
public PSGr(java.io.OutputStream o, java.awt.Graphics g)
o
- Output stream for PostScript outputg
- The "real g" from AWTcreate()
protected PSGr(java.io.OutputStream o, java.awt.Graphics g, int what)
public PSGr(java.io.OutputStream o, java.awt.Graphics g, int margin, int width, int height)
o
- Output stream for PostScript outputg
- The "real g" from AWTmargin
- Page_Margin (all four sides) in points.width
- Page_Width in points.height
- Page_Height in points.Method Detail |
public void drawString(java.text.AttributedCharacterIterator a, int x, int y)
drawString
in class java.awt.Graphics
public java.awt.Graphics create()
create
in class java.awt.Graphics
public java.awt.Graphics create(int x, int y, int width, int height)
create
in class java.awt.Graphics
x
- the x coordinate, pixels positive right from left.y
- the y coordinate, pixels positive down from top.width
- the width of the areaheight
- the height of the areatranslate(int, int)
public int getPageMargin()
public int getPageHeight()
public int getPageWidth()
public void translate(int x, int y)
translate
in class java.awt.Graphics
x
- the x coordinate, pixels positive right from left.y
- the y coordinate, pixels positive down from top.
Note: PostScript y coordinate is positive up from bottom.
Note: PostScript default units are points (1/72 inch).scale(float, float)
protected void scale(float sx, float sy)
sx
- the scaled x coordinatesy
- the scaled y coordinateThis is NOT part of the graphics API (although translate is).
It is used internally to map from pixels to points,
such that the entire top-level object will fit the page.
public java.awt.Color getColor()
getColor
in class java.awt.Graphics
setColor(java.awt.Color)
protected void setBackground(java.awt.Color c)
setColor(java.awt.Color)
public void setColor(java.awt.Color c)
setColor
in class java.awt.Graphics
c
- the color to be setColor
,
getColor()
protected java.lang.String strunc(double d)
public void setPaintMode()
setPaintMode
in class java.awt.Graphics
public void setXORMode(java.awt.Color c1)
setXORMode
in class java.awt.Graphics
c1
- the second colorpublic java.awt.Font getFont()
getFont
in class java.awt.Graphics
setFont(java.awt.Font)
public void setFont(java.awt.Font f)
setFont
in class java.awt.Graphics
font
- the specified fontFont
,
getFont()
,
drawString(java.text.AttributedCharacterIterator, int, int)
,
drawBytes(byte[], int, int, int, int)
,
drawChars(char[], int, int, int, int)
public java.awt.FontMetrics getFontMetrics()
getFontMetrics
in class java.awt.Graphics
getFont()
public java.awt.FontMetrics getFontMetrics(java.awt.Font f)
getFontMetrics
in class java.awt.Graphics
f
- the specified fontgetFont()
,
getFontMetrics()
public java.awt.Rectangle getClipRect()
getClipRect
in class java.awt.Graphics
clipRect(int, int, int, int)
,
getClipBounds
public java.awt.Rectangle getClipBounds()
getClipBounds
in class java.awt.Graphics
public java.awt.Shape getClip()
getClip
in class java.awt.Graphics
public void setClip(java.awt.Shape s)
setClip
in class java.awt.Graphics
public void setClip(int x, int y, int width, int height)
setClip
in class java.awt.Graphics
public void clipRect(int x, int y, int width, int height)
clipRect
in class java.awt.Graphics
x
- the x coordinatey
- the y coordinatewidth
- the width of the rectangleheight
- the height of the rectanglegetClipRect()
public void copyArea(int x, int y, int width, int height, int dx, int dy)
copyArea
in class java.awt.Graphics
x
- the x-coordinate of the sourcey
- the y-coordinate of the sourcewidth
- the widthheight
- the heightdx
- the horizontal distancedy
- the vertical distance
Note: copyArea not supported by PostScriptpublic void drawLine(int x1, int y1, int x2, int y2)
drawLine
in class java.awt.Graphics
x1
- the first point's x coordinatey1
- the first point's y coordinatex2
- the second point's x coordinatey2
- the second point's y coordinatepublic void drawPolyline(int[] x, int[] y, int np)
drawPolyline
in class java.awt.Graphics
protected void doRect(int x, int y, int width, int height, boolean fill)
public void fillRect(int x, int y, int width, int height)
fillRect
in class java.awt.Graphics
x
- the x coordinatey
- the y coordinatewidth
- the width of the rectangleheight
- the height of the rectangledrawRect(int, int, int, int)
,
clearRect(int, int, int, int)
public void drawRect(int x, int y, int width, int height)
drawRect
in class java.awt.Graphics
x
- the x coordinatey
- the y coordinatewidth
- the width of the rectangleheight
- the height of the rectanglefillRect(int, int, int, int)
,
clearRect(int, int, int, int)
public void clearRect(int x, int y, int width, int height)
clearRect
in class java.awt.Graphics
x
- the x coordinatey
- the y coordinatewidth
- the width of the rectangleheight
- the height of the rectanglefillRect(int, int, int, int)
,
drawRect(int, int, int, int)
public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
drawRoundRect
in class java.awt.Graphics
x
- the x coordinatey
- the y coordinatewidth
- the width of the rectangleheight
- the height of the rectanglearcWidth
- the diameter of the arcarcHeight
- the radius of the arcfillRoundRect(int, int, int, int, int, int)
public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
fillRoundRect
in class java.awt.Graphics
x
- the x coordinatey
- the y coordinatewidth
- the width of the rectangleheight
- the height of the rectanglearcWidth
- the diameter of the arcarcHeight
- the radius of the arcdrawRoundRect(int, int, int, int, int, int)
public void draw3DRect(int x, int y, int width, int height, boolean raised)
draw3DRect
in class java.awt.Graphics
x
- the x coordinatey
- the y coordinatewidth
- the width of the rectangleheight
- the height of the rectangleraised
- a boolean that states whether the rectangle is raised or notpublic void fill3DRect(int x, int y, int width, int height, boolean raised)
fill3DRect
in class java.awt.Graphics
x
- the x coordinatey
- the y coordinatewidth
- the width of the rectangleheight
- the height of the rectangleraised
- a boolean that states whether the rectangle is raised or notpublic void drawOval(int x, int y, int width, int height)
drawOval
in class java.awt.Graphics
x
- the x coordinatey
- the y coordinatewidth
- the width of the rectangleheight
- the height of the rectanglefillOval(int, int, int, int)
public void fillOval(int x, int y, int width, int height)
fillOval
in class java.awt.Graphics
x
- the x coordinatey
- the y coordinatewidth
- the width of the rectangleheight
- the height of the rectangledrawOval(int, int, int, int)
public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
drawArc
in class java.awt.Graphics
x
- the x coordinatey
- the y coordinatewidth
- the width of the rectangleheight
- the height of the rectanglestartAngle
- the beginning anglearcAngle
- the angle of the arc (relative to startAngle).fillArc(int, int, int, int, int, int)
public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
fillArc
in class java.awt.Graphics
x
- the x coordinatey
- the y coordinatewidth
- the width of the archeight
- the height of the arcstartAngle
- the beginning anglearcAngle
- the angle of the arc (relative to startAngle).drawArc(int, int, int, int, int, int)
public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
drawPolygon
in class java.awt.Graphics
xPoints
- an array of x pointsyPoints
- an array of y pointsnPoints
- the total number of pointsfillPolygon(int[], int[], int)
public void drawPolygon(java.awt.Polygon p)
drawPolygon
in class java.awt.Graphics
p
- the specified polygonfillPolygon(int[], int[], int)
public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
fillPolygon
in class java.awt.Graphics
xPoints
- an array of x pointsyPoints
- an array of y pointsnPoints
- the total number of pointsdrawPolygon(int[], int[], int)
public void fillPolygon(java.awt.Polygon p)
fillPolygon
in class java.awt.Graphics
p
- the polygondrawPolygon(int[], int[], int)
public void drawString(java.lang.String str, int x, int y)
drawString
in class java.awt.Graphics
str
- the String to be drawnx
- the x coordinatey
- the y coordinatedrawChars(char[], int, int, int, int)
,
WE CAN CORRECT FOR MINOR FONT DIFFERENCES
USE JAVA METRICS FOR EXPECTED STRINGWIDTH
TELL POSTSCRIPT TO KSHOW AND EXACTLY FILL THAT WIDTH
BUG!
Any backslashes (e.g. separators in file names) show on screen,
at least if they are not a legitimate escape sequence,
I HAVE NOT TRIED YET To see what they do on screen,
but must be doubled (\ to \\) to show in the PostScript output.
So first see what AWT does for a legitimate escape sequence,
then do what we can for the PostScript string.
According to the PostScript LRF "File Input and Output"
PostScript recognizes \ddd for octal character codes,
\n newline
\r return
\t tab
\b backspace
\f feed (top-of-form)
\ ( lpar
\) rpar
\\ backslash itself
\newline eats the backslash and the newline
\X any other character eats the backslash
I wonder what they do for top-of-form?
public void drawChars(char[] data, int offset, int length, int x, int y)
drawChars
in class java.awt.Graphics
data
- the array of characters to be drawnoffset
- the start offset in the datalength
- the number of characters to be drawnx
- the x coordinatey
- the y coordinatedrawString(java.text.AttributedCharacterIterator, int, int)
,
drawBytes(byte[], int, int, int, int)
public void drawBytes(byte[] data, int offset, int length, int x, int y)
drawBytes
in class java.awt.Graphics
data
- the data to be drawnoffset
- the start offset in the datalength
- the number of bytes that are drawnx
- the x coordinatey
- the y coordinatedrawString(java.text.AttributedCharacterIterator, int, int)
,
drawChars(char[], int, int, int, int)
protected java.lang.String myHexString(int n)
protected boolean doImage(java.awt.Image img, int x, int y, int width, int height, java.awt.image.ImageObserver observer, java.awt.Color bgcolor)
public boolean drawImage(java.awt.Image img, int x, int y, java.awt.image.ImageObserver observer)
drawImage
in class java.awt.Graphics
img
- the specified image to be drawnx
- the x coordinatey
- the y coordinateobserver
- notifies if the image is complete or notImage
,
ImageObserver
public boolean drawImage(java.awt.Image img, int x, int y, int width, int height, java.awt.image.ImageObserver observer)
drawImage
in class java.awt.Graphics
img
- the specified image to be drawnx
- the x coordinatey
- the y coordinatewidth
- the width of the rectangleheight
- the height of the rectangleobserver
- notifies if the image is complete or notImage
,
ImageObserver
public boolean drawImage(java.awt.Image img, int x, int y, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)
drawImage
in class java.awt.Graphics
img
- the specified image to be drawnx
- the x coordinatey
- the y coordinatebgcolor
- the background colorobserver
- notifies if the image is complete or notImage
,
ImageObserver
public boolean drawImage(java.awt.Image img, int x, int y, int width, int height, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)
drawImage
in class java.awt.Graphics
img
- the specified image to be drawnx
- the x coordinatey
- the y coordinatewidth
- the width of the rectangleheight
- the height of the rectanglebgcolor
- the background colorobserver
- notifies if the image is complete or notImage
,
NOTE: PSGr ignores the background color.
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)
drawImage
in class java.awt.Graphics
img
- - the specified image to be drawndx1
- - the x coordinate of the first corner of the destination rectangle.dy1
- - the y coordinate of the first corner of the destination rectangle.dx2
- - the x coordinate of the second corner of the destination rectangle.dy2
- - the y coordinate of the second corner of the destination rectangle.sx1
- - the x coordinate of the first corner of the source rectangle.sy1
- - the y coordinate of the first corner of the source rectangle.sx2
- - the x coordinate of the second corner of the source rectangle.sy2
- - the y coordinate of the second corner of the source rectangle.bgcolor
- the background colorobserver
- - object to be notified as more of the image is scaled and converted
NOTE: PSGr ignores the background color.Image
,
ImageObserver
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)
drawImage
in class java.awt.Graphics
img
- - the specified image to be drawndx1
- - the x coordinate of the first corner of the destination rectangle.dy1
- - the y coordinate of the first corner of the destination rectangle.dx2
- - the x coordinate of the second corner of the destination rectangle.dy2
- - the y coordinate of the second corner of the destination rectangle.sx1
- - the x coordinate of the first corner of the source rectangle.sy1
- - the y coordinate of the first corner of the source rectangle.sx2
- - the x coordinate of the second corner of the source rectangle.sy2
- - the y coordinate of the second corner of the source rectangle.observer
- - object to be notified as more of the image is scaled and convertedImage
,
ImageObserver
public void dispose()
dispose
in class java.awt.Graphics
finalize()
public void showpage()
public void finalize()
finalize
in class java.awt.Graphics
dispose()
public java.lang.String toString()
toString
in class java.awt.Graphics
protected int yTrans(int y)
protected int xTrans(int x)
protected int dTrans(int d)
protected void emitProlog()
protected void gsave()
protected void grestore()
public void emitThisNext(java.lang.String s)
public void emitThis(java.lang.String s)
protected void myBasicPaint(java.awt.Component comp, boolean edge)
public void scalePaint(java.awt.Component top)
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |