fi.faidon.jvg
Class RecorderGraphics

java.lang.Object
  |
  +--java.awt.Graphics
        |
        +--fi.faidon.jvg.RecorderGraphics

public class RecorderGraphics
extends java.awt.Graphics

Class that extends the awt.Graphics class with a recording functionality. It also makes it possible to save the drawing operations into a file, from which they can be re-read in a standardized way. Image passing at least between Java applications through the clipboard also becomes feasible since the comminucating programs just need to implement this class for understanding each other.


Constructor Summary
RecorderGraphics()
          Create a recorder graphics with no draw graphics.
RecorderGraphics(java.awt.Graphics g)
          Create a recorder graphics with a draw graphics.
 
Method Summary
 void clearRect(int x, int y, int width, int height)
          Do operation if we have a graphics object, then record.
 void clipRect(int x, int y, int width, int height)
          Record and pass on if we have a display graphics.
 void copyArea(int x, int y, int width, int height, int dx, int dy)
          Do operation if we have a graphics object, then record.
 java.awt.Graphics create()
          If we have a draw graphics, then let it do the job.
 java.awt.Graphics create(int x, int y, int width, int height)
          Let parent class do the job.
 void dispose()
          Release all memory resources.
 void draw3DRect(int x, int y, int width, int height, boolean raised)
          Do operation if we have a graphics object, then record.
 void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
          Draw an arc if graphics, record operation.
 void drawBytes(byte[] data, int offset, int length, int x, int y)
          Draw bytes if graphics, record operation.
 void drawChars(char[] data, int offset, int length, int x, int y)
          Draw chars if graphics, record operation.
 boolean drawImage(java.awt.Image img, int x, int y, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)
          Draw image if we have a draw graphics, record operation.
 boolean drawImage(java.awt.Image img, int x, int y, java.awt.image.ImageObserver observer)
          Draw image if we have a draw graphics, record operation.
 boolean drawImage(java.awt.Image img, int x, int y, int width, int height, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)
          Draw image if we have a draw graphics, record operation.
 boolean drawImage(java.awt.Image img, int x, int y, int width, int height, java.awt.image.ImageObserver observer)
          Draw image if we have a draw graphics, record operation.
 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)
          Draw image if we have a draw graphics, record operation.
 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)
          Draw image if we have a draw graphics, record operation.
 void drawLine(int x1, int y1, int x2, int y2)
          Draw a line.
 void drawOval(int x, int y, int width, int height)
          Draw an oval.
 void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
          Draw a polygon.
 void drawPolygon(java.awt.Polygon p)
          Draw a polygon.
 void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
          Draw a polyline if graphics, record operation.
 void drawRect(int x, int y, int width, int height)
          Draw a rectangle.
 void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
          Do operation if we have a graphics object, then record.
 void drawString(java.text.AttributedCharacterIterator iterator, int x, int y)
          Draw a string.
 void drawString(java.lang.String str, int x, int y)
          Draw a string.
 void fill3DRect(int x, int y, int width, int height, boolean raised)
          Do operation if we have a graphics object, then record.
 void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
          Fill an arc if graphics, record operation.
 void fillOval(int x, int y, int width, int height)
          Fill an oval if graphics, record operation.
 void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
          Fill a polygon.
 void fillPolygon(java.awt.Polygon p)
          Fill a polygon.
 void fillRect(int x, int y, int width, int height)
          Do operation if we have a graphics object, then record.
 void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
          Do operation if we have a graphics object, then record.
 void finalize()
          Finalize everything.
 java.awt.Shape getClip()
          Return the clip shape set previously if no draw graphics, otherwise return display graphics clip shape.
 java.awt.Rectangle getClipBounds()
          Return null if no draw graphics, return display graphics clip bounds otherwise.
 java.awt.Rectangle getClipRect()
          Return the clip rect that has been set by a previous call if we have no draw graphics, otherwise return that of the draw graphics.
 java.awt.Color getColor()
          Return null if no draw graphics, return display graphics color otherwise.
 java.awt.Font getFont()
          Return null if no draw graphics, return display graphics font otherwise.
 java.awt.FontMetrics getFontMetrics()
          Return null if no draw graphics, return display graphics fotn metrics otherwise.
 java.awt.FontMetrics getFontMetrics(java.awt.Font f)
          Return null if no draw graphics, return display graphics fotn metrics otherwise.
 GraphicsRecording getRecording()
          Returns the graphics recording object.
static void main(java.lang.String[] argv)
          Main function for debugging and test purposes.
 void setClip(int x, int y, int width, int height)
          Set clip rect.
 void setClip(java.awt.Shape clip)
          Set the clip shape.
 void setColor(java.awt.Color c)
          Set foreground color.
 void setFont(java.awt.Font font)
          Set the font used.
 void setPaintMode()
          Record and pass on if we have a display graphics.
 void setXORMode(java.awt.Color c1)
          Record and pass on if we have a display graphics.
 java.lang.String toString()
           
 void translate(int x, int y)
          Record and pass on if we have a display graphics.
 
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
 

Constructor Detail

RecorderGraphics

public RecorderGraphics()
Create a recorder graphics with no draw graphics. This simply means that there will be no simultaneous graphics output.


RecorderGraphics

public RecorderGraphics(java.awt.Graphics g)
Create a recorder graphics with a draw graphics. This means that there will be simultaneous graphics output and that all "get..."-methods return correct information.

Method Detail

main

public static void main(java.lang.String[] argv)
Main function for debugging and test purposes.


getRecording

public GraphicsRecording getRecording()
Returns the graphics recording object.


create

public java.awt.Graphics create()
If we have a draw graphics, then let it do the job. NULL otherwise.

Specified by:
create in class java.awt.Graphics

create

public java.awt.Graphics create(int x,
                                int y,
                                int width,
                                int height)
Let parent class do the job.

Overrides:
create in class java.awt.Graphics

translate

public void translate(int x,
                      int y)
Record and pass on if we have a display graphics.

Specified by:
translate in class java.awt.Graphics

getColor

public java.awt.Color getColor()
Return null if no draw graphics, return display graphics color otherwise.

Specified by:
getColor in class java.awt.Graphics

setColor

public void setColor(java.awt.Color c)
Set foreground color.

Specified by:
setColor in class java.awt.Graphics

setPaintMode

public void setPaintMode()
Record and pass on if we have a display graphics.

Specified by:
setPaintMode in class java.awt.Graphics

setXORMode

public void setXORMode(java.awt.Color c1)
Record and pass on if we have a display graphics.

Specified by:
setXORMode in class java.awt.Graphics

getFont

public java.awt.Font getFont()
Return null if no draw graphics, return display graphics font otherwise.

Specified by:
getFont in class java.awt.Graphics

setFont

public void setFont(java.awt.Font font)
Set the font used.

Specified by:
setFont in class java.awt.Graphics

getFontMetrics

public java.awt.FontMetrics getFontMetrics()
Return null if no draw graphics, return display graphics fotn metrics otherwise.

Overrides:
getFontMetrics in class java.awt.Graphics

getFontMetrics

public java.awt.FontMetrics getFontMetrics(java.awt.Font f)
Return null if no draw graphics, return display graphics fotn metrics otherwise.

Specified by:
getFontMetrics in class java.awt.Graphics

getClipBounds

public java.awt.Rectangle getClipBounds()
Return null if no draw graphics, return display graphics clip bounds otherwise.

Specified by:
getClipBounds in class java.awt.Graphics

clipRect

public void clipRect(int x,
                     int y,
                     int width,
                     int height)
Record and pass on if we have a display graphics.

Specified by:
clipRect in class java.awt.Graphics

setClip

public void setClip(int x,
                    int y,
                    int width,
                    int height)
Set clip rect.

Specified by:
setClip in class java.awt.Graphics

getClip

public java.awt.Shape getClip()
Return the clip shape set previously if no draw graphics, otherwise return display graphics clip shape.

Specified by:
getClip in class java.awt.Graphics

setClip

public void setClip(java.awt.Shape clip)
Set the clip shape. Also store a local copy.

Specified by:
setClip in class java.awt.Graphics

copyArea

public void copyArea(int x,
                     int y,
                     int width,
                     int height,
                     int dx,
                     int dy)
Do operation if we have a graphics object, then record.

Specified by:
copyArea in class java.awt.Graphics

drawLine

public void drawLine(int x1,
                     int y1,
                     int x2,
                     int y2)
Draw a line.

Specified by:
drawLine in class java.awt.Graphics

fillRect

public void fillRect(int x,
                     int y,
                     int width,
                     int height)
Do operation if we have a graphics object, then record.

Specified by:
fillRect in class java.awt.Graphics

drawRect

public void drawRect(int x,
                     int y,
                     int width,
                     int height)
Draw a rectangle.

Overrides:
drawRect in class java.awt.Graphics

clearRect

public void clearRect(int x,
                      int y,
                      int width,
                      int height)
Do operation if we have a graphics object, then record.

Specified by:
clearRect in class java.awt.Graphics

drawRoundRect

public void drawRoundRect(int x,
                          int y,
                          int width,
                          int height,
                          int arcWidth,
                          int arcHeight)
Do operation if we have a graphics object, then record.

Specified by:
drawRoundRect in class java.awt.Graphics

fillRoundRect

public void fillRoundRect(int x,
                          int y,
                          int width,
                          int height,
                          int arcWidth,
                          int arcHeight)
Do operation if we have a graphics object, then record.

Specified by:
fillRoundRect in class java.awt.Graphics

draw3DRect

public void draw3DRect(int x,
                       int y,
                       int width,
                       int height,
                       boolean raised)
Do operation if we have a graphics object, then record.

Overrides:
draw3DRect in class java.awt.Graphics

fill3DRect

public void fill3DRect(int x,
                       int y,
                       int width,
                       int height,
                       boolean raised)
Do operation if we have a graphics object, then record.

Overrides:
fill3DRect in class java.awt.Graphics

drawOval

public void drawOval(int x,
                     int y,
                     int width,
                     int height)
Draw an oval.

Specified by:
drawOval in class java.awt.Graphics

fillOval

public void fillOval(int x,
                     int y,
                     int width,
                     int height)
Fill an oval if graphics, record operation.

Specified by:
fillOval in class java.awt.Graphics

drawArc

public void drawArc(int x,
                    int y,
                    int width,
                    int height,
                    int startAngle,
                    int arcAngle)
Draw an arc if graphics, record operation.

Specified by:
drawArc in class java.awt.Graphics

fillArc

public void fillArc(int x,
                    int y,
                    int width,
                    int height,
                    int startAngle,
                    int arcAngle)
Fill an arc if graphics, record operation.

Specified by:
fillArc in class java.awt.Graphics

drawPolyline

public void drawPolyline(int[] xPoints,
                         int[] yPoints,
                         int nPoints)
Draw a polyline if graphics, record operation.

Specified by:
drawPolyline in class java.awt.Graphics

drawPolygon

public void drawPolygon(int[] xPoints,
                        int[] yPoints,
                        int nPoints)
Draw a polygon.

Specified by:
drawPolygon in class java.awt.Graphics

drawPolygon

public void drawPolygon(java.awt.Polygon p)
Draw a polygon.

Overrides:
drawPolygon in class java.awt.Graphics

fillPolygon

public void fillPolygon(int[] xPoints,
                        int[] yPoints,
                        int nPoints)
Fill a polygon.

Specified by:
fillPolygon in class java.awt.Graphics

fillPolygon

public void fillPolygon(java.awt.Polygon p)
Fill a polygon.

Overrides:
fillPolygon in class java.awt.Graphics

drawString

public void drawString(java.lang.String str,
                       int x,
                       int y)
Draw a string.

Specified by:
drawString in class java.awt.Graphics

drawString

public void drawString(java.text.AttributedCharacterIterator iterator,
                       int x,
                       int y)
Draw a string. This is not finished, just to make it compile with JDK 1.3.

Specified by:
drawString in class java.awt.Graphics

drawChars

public void drawChars(char[] data,
                      int offset,
                      int length,
                      int x,
                      int y)
Draw chars if graphics, record operation.

Overrides:
drawChars in class java.awt.Graphics

drawBytes

public void drawBytes(byte[] data,
                      int offset,
                      int length,
                      int x,
                      int y)
Draw bytes if graphics, record operation.

Overrides:
drawBytes in class java.awt.Graphics

drawImage

public boolean drawImage(java.awt.Image img,
                         int x,
                         int y,
                         java.awt.image.ImageObserver observer)
Draw image if we have a draw graphics, record operation.

Specified by:
drawImage in class java.awt.Graphics

drawImage

public boolean drawImage(java.awt.Image img,
                         int x,
                         int y,
                         int width,
                         int height,
                         java.awt.image.ImageObserver observer)
Draw image if we have a draw graphics, record operation.

Specified by:
drawImage in class java.awt.Graphics

drawImage

public boolean drawImage(java.awt.Image img,
                         int x,
                         int y,
                         java.awt.Color bgcolor,
                         java.awt.image.ImageObserver observer)
Draw image if we have a draw graphics, record operation.

Specified by:
drawImage in class java.awt.Graphics

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)
Draw image if we have a draw graphics, record operation.

Specified by:
drawImage in class java.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)
Draw image if we have a draw graphics, record operation.

Specified by:
drawImage in class java.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.Color bgcolor,
                         java.awt.image.ImageObserver observer)
Draw image if we have a draw graphics, record operation.

Specified by:
drawImage in class java.awt.Graphics

dispose

public void dispose()
Release all memory resources.

Specified by:
dispose in class java.awt.Graphics

finalize

public void finalize()
Finalize everything.

Overrides:
finalize in class java.awt.Graphics

toString

public java.lang.String toString()
Overrides:
toString in class java.awt.Graphics

getClipRect

public java.awt.Rectangle getClipRect()
Return the clip rect that has been set by a previous call if we have no draw graphics, otherwise return that of the draw graphics.

Overrides:
getClipRect in class java.awt.Graphics