Class PSGr
- java.lang.Object
-
- java.awt.Graphics
-
- com.cosylab.vdct.print.postscript.PSGr
-
public class PSGr extends Graphics
PSGr is a awt.Graphics subclass that images to PostScript. (C) 1996 E.J. Friedman-Hill and Sandia National Labs- Version:
- 1.0
- Author:
- Ernest Friedman-Hill, ejfried@ca.sandia.gov, http://herzberg.ca.sandia.gov IMPORTANT! Changes for Java 1.1 by Morris Hirsch mhirsch@ipdinc.com All thanks to Ernest Friedman-Hill. Any complaints or bugs to Morris Hirsch.
-
-
Field Summary
Fields Modifier and Type Field Description protected Color
backClr
protected Rectangle
clippingRect
static int
CLONE
protected Color
clr
protected boolean
disposed
protected Font
font
protected PrintStream
os
protected int
Page_Height
protected int
Page_MarginX
protected int
Page_MarginY
protected boolean
Page_Portrait
protected int
Page_Width
protected static int
PAGEHEIGHT
protected static int
PAGEMARGINX
protected static int
PAGEMARGINY
protected static boolean
PAGEPORTRAIT
protected static int
PAGEWIDTH
-
Constructor Summary
Constructors Modifier Constructor Description PSGr(OutputStream o)
Constructs a new PSGr Object.protected
PSGr(OutputStream o, int what)
PSGr(OutputStream o, int marginX, int marginY, int width, int height, boolean portrait)
Constructor for non-default page dimensions and orientation.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description 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.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.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(Image img, int x, int y, int width, int height, ImageObserver observer, 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.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(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer)
Scaling and translating versions not supported -- BUT COULD BEboolean
drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer)
Scaling and translating versions not supported -- BUT WE COULDboolean
drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer)
Draws the specified image inside the specified rectangle.boolean
drawImage(Image img, int x, int y, int width, int height, ImageObserver observer)
Draws the specified image inside the specified rectangle.boolean
drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer)
Draws the specified image at the specified top left (x, y), with width and height determined by the image.boolean
drawImage(Image img, int x, int y, ImageObserver observer)
Draws the specified image at the specified top left (x, y), with width and height determined by the image.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(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 APIvoid
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(String str, int x, int y)
void
drawString(AttributedCharacterIterator iterator, 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(String s)
void
emitThisNext(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(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.Shape
getClip()
MGH added Shape getClip () per 1.1 API.Rectangle
getClipBounds()
Rectangle
getClipRect()
Deprecated.in 1.1Color
getColor()
Gets the current color.Font
getFont()
Gets the current font.FontMetrics
getFontMetrics()
PSGr does not implement getFontMetrics(*)FontMetrics
getFontMetrics(Font f)
"Warning: PSGr does not implement getFontMetrics(*)int
getPageHeight()
int
getPageMarginX()
Printing dimensions default or set at construct time.int
getPageMarginY()
int
getPageWidth()
protected void
grestore()
protected void
gsave()
Save and restore the PostScript state, SHOULD ALSO any Java mirror stateprotected void
myBasicPaint(Component comp, boolean edge)
protected String
myHexString(int n)
protected void
scale(float sx, float sy)
Scales the graphics context.void
scalePaint(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(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(Shape s)
MGH added setClip (Shape s) hacked over Rectangle.void
setColor(Color c)
Sets the current color to the specified color.void
setFont(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(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 String
strunc(double d)
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
-
-
-
-
Field Detail
-
CLONE
public static final int CLONE
- See Also:
- Constant Field Values
-
PAGEMARGINX
protected static final int PAGEMARGINX
- See Also:
- Constant Field Values
-
PAGEMARGINY
protected static final int PAGEMARGINY
- See Also:
- Constant Field Values
-
PAGEHEIGHT
protected static final int PAGEHEIGHT
- See Also:
- Constant Field Values
-
PAGEWIDTH
protected static final int PAGEWIDTH
- See Also:
- Constant Field Values
-
PAGEPORTRAIT
protected static final boolean PAGEPORTRAIT
- See Also:
- Constant Field Values
-
Page_MarginX
protected int Page_MarginX
-
Page_MarginY
protected int Page_MarginY
-
Page_Height
protected int Page_Height
-
Page_Width
protected int Page_Width
-
Page_Portrait
protected boolean Page_Portrait
-
os
protected PrintStream os
-
clr
protected Color clr
-
backClr
protected Color backClr
-
font
protected Font font
-
clippingRect
protected Rectangle clippingRect
-
disposed
protected boolean disposed
-
-
Constructor Detail
-
PSGr
public PSGr(OutputStream o)
Constructs a new PSGr Object. Unlike regular Graphics objects, PSGr contexts can be created directly.- Parameters:
o
- Output stream for PostScript output- See Also:
create()
-
PSGr
protected PSGr(OutputStream o, int what)
- Parameters:
o
- owhat
- what
-
PSGr
public PSGr(OutputStream o, int marginX, int marginY, int width, int height, boolean portrait)
Constructor for non-default page dimensions and orientation.- Parameters:
o
- Output stream for PostScript outputmarginX
- Page_MarginX (left side) in points.marginY
- Page_MarginY (bottom side) in points.width
- Page_Width in points.height
- Page_Height in points.portrait
- Portrait if true, otherwise landscape.
-
-
Method Detail
-
create
public 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. We have our own Container painting code, which works the same way. This simulates the context stack in PostScript, and works fine as long as each g is used as described, that is by using only the most recently created g.
-
create
public 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. This method translates the origin to the specified x and y, and then clips to the area with specified width and height. The resulting clipping area is the intersection of the current clipping area and the specified rectangle. We first "gsave" the PostScript context here, and we "grestore" it when dispose () is called, so if create () and dispose () are used in pairs, the earlier and larger clip should be preserved, and what the old g thinks is the clip should be so. NOT TESTED YET! Compiler won't let this one be PSGr only Graphics I think because it is part of the interface spec.- Overrides:
create
in classGraphics
- Parameters:
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 area- Returns:
- something
- See Also:
translate(int, int)
-
getPageMarginX
public int getPageMarginX()
Printing dimensions default or set at construct time. These are methods of the PSGr extension of Graphics.- Returns:
- something
-
getPageMarginY
public int getPageMarginY()
- Returns:
- something
-
getPageHeight
public int getPageHeight()
- Returns:
- something
-
getPageWidth
public int getPageWidth()
- Returns:
- something
-
translate
public void translate(int x, int y)
Translates the origin of the graphics context to the specified parameters. All subsequent operations on this graphics context will be relative to this origin.- Specified by:
translate
in classGraphics
- Parameters:
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).- See Also:
scale(float, float)
-
scale
protected void scale(float sx, float sy)
Scales the graphics context. All subsequent operations on this graphics context will be affected.- Parameters:
sx
- the scaled x coordinatesy
- the scaled y coordinate- See Also:
This 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.
-
getColor
public Color getColor()
Gets the current color.- Specified by:
getColor
in classGraphics
- Returns:
- something
- See Also:
setColor(java.awt.Color)
-
setBackground
protected void setBackground(Color c)
Gets the current color. This is NOT part of the Graphics API.- Parameters:
c
- c- See Also:
setColor(java.awt.Color)
-
setColor
public void setColor(Color c)
Sets the current color to the specified color. All subsequent graphics operations will use this specified color.- Specified by:
setColor
in classGraphics
- Parameters:
c
- the color to be set- See Also:
Color
,getColor()
-
strunc
protected String strunc(double d)
- Parameters:
d
- d- Returns:
- something
-
setPaintMode
public void setPaintMode()
Sets the default paint mode to overwrite the destination with the current color. PostScript has only paint mode.- Specified by:
setPaintMode
in classGraphics
-
setXORMode
public void setXORMode(Color c1)
Sets the paint mode to alternate between the current color and the new specified color. PostScript does not support XOR mode.- Specified by:
setXORMode
in classGraphics
- Parameters:
c1
- the second color
-
getFont
public Font getFont()
Gets the current font.- Specified by:
getFont
in classGraphics
- Returns:
- something
- See Also:
setFont(java.awt.Font)
-
setFont
public void setFont(Font f)
Sets the font for all subsequent text-drawing operations.- Specified by:
setFont
in classGraphics
- Parameters:
f
- the specified font- See Also:
Font
,getFont()
,drawString(java.text.AttributedCharacterIterator, int, int)
,drawBytes(byte[], int, int, int, int)
,drawChars(char[], int, int, int, int)
-
getFontMetrics
public FontMetrics getFontMetrics()
PSGr does not implement getFontMetrics(*)- Overrides:
getFontMetrics
in classGraphics
- Returns:
- something
-
getFontMetrics
public FontMetrics getFontMetrics(Font f)
"Warning: PSGr does not implement getFontMetrics(*)- Specified by:
getFontMetrics
in classGraphics
- Returns:
- something
- See Also:
getFont()
-
getClipRect
public Rectangle getClipRect()
Deprecated.in 1.1Returns the bounding Rectangle of the current clipping area.- Overrides:
getClipRect
in classGraphics
- Returns:
- something
- See Also:
clipRect(int, int, int, int)
,getClipBounds()
-
getClipBounds
public Rectangle getClipBounds()
- Specified by:
getClipBounds
in classGraphics
-
getClip
public Shape getClip()
MGH added Shape getClip () per 1.1 API. Rectangle implements Shape.
-
setClip
public void setClip(Shape s)
MGH added setClip (Shape s) hacked over Rectangle. Really nothing to do for Shape as yet...
-
setClip
public 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.. Easy to make the new clippingRect, but that is only the Java book keeping version. The actual PostScript clip is the intersection, unless we use initclip to reset it, which I could do... But my PostScript book says to "almost never" do initclip. Instead we should grestore but WHEN WAS THE GSAVE? Use grestoreall, it pops all gsaves until the one that was done to start us, uses that one and leaves it on the stack, so it can be done again and again. NOT TESTED YET!
-
clipRect
public void clipRect(int x, int y, int width, int height)
Clips to a rectangle. The resulting clipping area is the intersection of the current clipping area and the specified rectangle. Graphic operations have no effect outside of the clipping area. MGH made clippingRect = clippingRect.intersection, MGH commented out // emitThis ("initclip"); MGH added the starting emitThis ("newpath");- Specified by:
clipRect
in classGraphics
- Parameters:
x
- the x coordinatey
- the y coordinatewidth
- the width of the rectangleheight
- the height of the rectangle- See Also:
getClipRect()
-
copyArea
public void copyArea(int x, int y, int width, int height, int dx, int dy)
Copies an area of the screen.
-
drawLine
public void drawLine(int x1, int y1, int x2, int y2)
Draws a line between the coordinates (x1,y1) and (x2,y2). The line is drawn below and to the left of the logical coordinates.
-
drawPolyline
public void drawPolyline(int[] x, int[] y, int np)
Polyline MGH added to satisfy 1.1 API- Specified by:
drawPolyline
in classGraphics
- Parameters:
x
- xy
- ynp
- np
-
doRect
protected void doRect(int x, int y, int width, int height, boolean fill)
- Parameters:
x
- xy
- ywidth
- widthheight
- heightfill
- fill
-
fillRect
public void fillRect(int x, int y, int width, int height)
Fills the specified rectangle with the current color.- Specified by:
fillRect
in classGraphics
- Parameters:
x
- the x coordinatey
- the y coordinatewidth
- the width of the rectangleheight
- the height of the rectangle- See Also:
drawRect(int, int, int, int)
,clearRect(int, int, int, int)
-
drawRect
public void drawRect(int x, int y, int width, int height)
Draws the outline of the specified rectangle using the current color. Use drawRect (x, y, width-1, height-1) to draw the outline inside the specified rectangle.- Overrides:
drawRect
in classGraphics
- Parameters:
x
- the x coordinatey
- the y coordinatewidth
- the width of the rectangleheight
- the height of the rectangle- See Also:
fillRect(int, int, int, int)
,clearRect(int, int, int, int)
-
clearRect
public 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. Which drawing surface it selects depends on how the graphics context was created.- Specified by:
clearRect
in classGraphics
- Parameters:
x
- the x coordinatey
- the y coordinatewidth
- the width of the rectangleheight
- the height of the rectangle- See Also:
fillRect(int, int, int, int)
,drawRect(int, int, int, int)
-
drawRoundRect
public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
Draws an outlined rounded corner rectangle using the current color.- Specified by:
drawRoundRect
in classGraphics
- Parameters:
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 arc- See Also:
fillRoundRect(int, int, int, int, int, int)
-
fillRoundRect
public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
Draws a rounded rectangle filled in with the current color.- Specified by:
fillRoundRect
in classGraphics
- Parameters:
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 arc- See Also:
drawRoundRect(int, int, int, int, int, int)
-
draw3DRect
public void draw3DRect(int x, int y, int width, int height, boolean raised)
Draws a highlighted 3-D rectangle. Two edges brighter and two darker.- Overrides:
draw3DRect
in classGraphics
- Parameters:
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 not
-
fill3DRect
public void fill3DRect(int x, int y, int width, int height, boolean raised)
Paints a highlighted 3-D rectangle using the current color. Two edges brighter and two darker.- Overrides:
fill3DRect
in classGraphics
- Parameters:
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 not
-
drawOval
public void drawOval(int x, int y, int width, int height)
Draws an oval inside the specified rectangle using the current color.- Specified by:
drawOval
in classGraphics
- Parameters:
x
- the x coordinatey
- the y coordinatewidth
- the width of the rectangleheight
- the height of the rectangle- See Also:
fillOval(int, int, int, int)
-
fillOval
public void fillOval(int x, int y, int width, int height)
Fills an oval inside the specified rectangle using the current color.- Specified by:
fillOval
in classGraphics
- Parameters:
x
- the x coordinatey
- the y coordinatewidth
- the width of the rectangleheight
- the height of the rectangle- See Also:
drawOval(int, int, int, int)
-
drawArc
public 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.- Specified by:
drawArc
in classGraphics
- Parameters:
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).- See Also:
fillArc(int, int, int, int, int, int)
-
fillArc
public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
Fills an arc using the current color. This generates a pie shape.- Specified by:
fillArc
in classGraphics
- Parameters:
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).- See Also:
drawArc(int, int, int, int, int, int)
-
drawPolygon
public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
Draws a polygon defined by an array of x points and y points.- Specified by:
drawPolygon
in classGraphics
- Parameters:
xPoints
- an array of x pointsyPoints
- an array of y pointsnPoints
- the total number of points- See Also:
fillPolygon(int[], int[], int)
-
drawPolygon
public void drawPolygon(Polygon p)
Draws a polygon defined by the specified point.- Overrides:
drawPolygon
in classGraphics
- Parameters:
p
- the specified polygon- See Also:
fillPolygon(int[], int[], int)
-
fillPolygon
public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
Fills a polygon with the current color.- Specified by:
fillPolygon
in classGraphics
- Parameters:
xPoints
- an array of x pointsyPoints
- an array of y pointsnPoints
- the total number of points- See Also:
drawPolygon(int[], int[], int)
-
fillPolygon
public void fillPolygon(Polygon p)
Fills the specified polygon with the current color.- Overrides:
fillPolygon
in classGraphics
- Parameters:
p
- the polygon- See Also:
drawPolygon(int[], int[], int)
-
drawString
public void drawString(AttributedCharacterIterator iterator, int x, int y)
Draws the specified String using the current font and color. The x,y position is the starting point of the baseline of the String.- Specified by:
drawString
in classGraphics
- Parameters:
iterator
- the String to be drawnx
- the x coordinatey
- the y coordinate- See Also:
drawChars(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?
-
drawString
public void drawString(String str, int x, int y)
- Specified by:
drawString
in classGraphics
-
drawChars
public void drawChars(char[] data, int offset, int length, int x, int y)
Draws the specified characters using the current font and color.- Overrides:
drawChars
in classGraphics
- Parameters:
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 coordinate- See Also:
drawString(java.text.AttributedCharacterIterator, int, int)
,drawBytes(byte[], int, int, int, int)
-
drawBytes
public void drawBytes(byte[] data, int offset, int length, int x, int y)
Draws the specified bytes using the current font and color.- Overrides:
drawBytes
in classGraphics
- Parameters:
data
- the data to be drawnoffset
- the start offset in the datalength
- the number of bytes that are drawnx
- the x coordinatey
- the y coordinate- See Also:
drawString(java.text.AttributedCharacterIterator, int, int)
,drawChars(char[], int, int, int, int)
-
myHexString
protected String myHexString(int n)
- Parameters:
n
- n- Returns:
- something
-
doImage
protected boolean doImage(Image img, int x, int y, int width, int height, ImageObserver observer, Color bgcolor)
- Parameters:
img
- imgx
- xy
- ywidth
- widthheight
- heightobserver
- observerbgcolor
- bgcolor- Returns:
- something
-
drawImage
public boolean drawImage(Image img, int x, int y, ImageObserver observer)
Draws the specified image at the specified top left (x, y), with width and height determined by the image. If the image is incomplete return false. The image observer will be notified later.- Specified by:
drawImage
in classGraphics
- Parameters:
img
- the specified image to be drawnx
- the x coordinatey
- the y coordinateobserver
- notifies if the image is complete or not- Returns:
- something
- See Also:
Image
,ImageObserver
-
drawImage
public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer)
Draws the specified image inside the specified rectangle. The image is scaled if necessary. If the image is incomplete return false. The image observer will be notified later.- Specified by:
drawImage
in classGraphics
- Parameters:
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 not- Returns:
- something
- See Also:
Image
,ImageObserver
-
drawImage
public boolean drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer)
Draws the specified image at the specified top left (x, y), with width and height determined by the image. If the image is incomplete return false. The image observer will be notified later.- Specified by:
drawImage
in classGraphics
- Parameters:
img
- the specified image to be drawnx
- the x coordinatey
- the y coordinatebgcolor
- the background colorobserver
- notifies if the image is complete or not- Returns:
- something
- See Also:
Image
,ImageObserver
-
drawImage
public boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer)
Draws the specified image inside the specified rectangle. The image is scaled if necessary. If the image is incomplete the image observer will be notified later.- Specified by:
drawImage
in classGraphics
- Parameters:
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 not- Returns:
- something
- See Also:
Image
,NOTE: PSGr ignores the background color.
-
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)
Scaling and translating versions not supported -- BUT COULD BE- Specified by:
drawImage
in classGraphics
- Parameters:
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.- Returns:
- something
- See Also:
Image
,ImageObserver
-
drawImage
public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer)
Scaling and translating versions not supported -- BUT WE COULD- Specified by:
drawImage
in classGraphics
- Parameters:
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 converted- Returns:
- something
- See Also:
Image
,ImageObserver
-
dispose
public void dispose()
Disposes of this Graphics context, which cannot be used after being disposed of.- Specified by:
dispose
in classGraphics
- See Also:
finalize()
-
showpage
public void showpage()
Needed unless the file is intended as part of a larger one. As best I understand the conventions, we are expected to say showpage, but any "wrapped" code may disable it, and scale this as part of a larger page. The grestore and gsave seem to be needed, otherwise all but first page came out blank, I don't see why that should be.
-
finalize
public void finalize()
Disposes of this graphics context once it is no longer referenced.
-
toString
public String toString()
Returns a String object representing this Graphic's value.
-
yTrans
protected int yTrans(int y)
- Parameters:
y
- y- Returns:
- something
-
xTrans
protected int xTrans(int x)
- Parameters:
x
- x- Returns:
- something
-
dTrans
protected int dTrans(int d)
- Parameters:
d
- d- Returns:
- something
-
emitProlog
protected void emitProlog()
Top of every PS file needs this. It must be the first thing in the file. The first line is a "magic number" to invoke PostScript. There are other standard %% comments that could be added.
-
gsave
protected void gsave()
Save and restore the PostScript state, SHOULD ALSO any Java mirror state
-
grestore
protected void grestore()
-
emitThisNext
public void emitThisNext(String s)
- Parameters:
s
- s
-
emitThis
public void emitThis(String s)
- Parameters:
s
- s
-
myBasicPaint
protected void myBasicPaint(Component comp, boolean edge)
- Parameters:
comp
- compedge
- edge
-
scalePaint
public void scalePaint(Component top)
Find scale factor that will fit the page, use smaller of x and y for both, to convert all pixels to points. Only reduce scale if needed -- do not ever magnify. PostScript scale operator also changes text sizes. Must allow for non-printing margins all around.- Parameters:
top
- top
-
-