Class QuickDrawContext
java.lang.Object
com.twelvemonkeys.imageio.plugins.pict.QuickDrawContext
Emulates an Apple QuickDraw rendering context, backed by a Java
Graphics2D
.- Version:
- $Id: QuickDrawContext.java,v 1.0 Oct 3, 2007 1:24:35 AM haraldk Exp$
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Pattern
private Color
private Color
private Pattern
private final Graphics2D
private int
private Pattern
private Point2D
private Dimension2D
private int
private int
private Pattern
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
copyBits
(BufferedImage pSrcBitmap, Rectangle pSrcRect, Rectangle pDstRect, int pMode, Shape pMaskRgn) CopyBits.void
copyDeepMask
(BufferedImage pSrcBitmap, BufferedImage pMaskBitmap, Rectangle pSrcRect, Rectangle pMaskRect, Rectangle pDstRect, int pSrcCopy, Shape pMaskRgn) CopyDeepMask -- available to basic QuickDraw only in System 7, combines the functionality of both CopyBits and CopyMaskvoid
copyMask
(BufferedImage pSrcBitmap, BufferedImage pMaskBitmap, Rectangle pSrcRect, Rectangle pMaskRect, Rectangle pDstRect, int pSrcCopy, Shape pMaskRgn) CopyMaskprotected void
dispose()
void
drawString
(String pString) DrawString - draws the text of a Pascal string.void
eraseArc
(Rectangle2D pRectangle, int pStartAngle, int pArcAngle) EraseArc(r,int,int) // fills the arc's interior with the background patternvoid
eraseOval
(Rectangle2D pRectangle) EraseOval(r) // fills the oval's interior with the background patternvoid
void
eraseRect
(Rectangle2D pRectangle) EraseRect(r) // fills the rectangle's interior with the background patternvoid
eraseRegion
(Area pArea) void
eraseRoundRect
(Rectangle2D pRectangle, int pArcW, int pArcH) EraseRoundRect(r,int,int) // fills the rectangle's interior with the background patternprivate void
eraseShape
(Shape pShape) void
fillArc
(Rectangle2D pRectangle, int pStartAngle, int pArcAngle, Pattern pPattern) FillArc(r,int,int, pat) // fills an arc's interior with any pattern you specify.void
fillOval
(Rectangle2D pRectangle, Pattern pPattern) FillOval(r, pat) // fills an oval's interior with any pattern you specify.void
void
fillRect
(Rectangle2D pRectangle, Pattern pPattern) FillRect(r, pat) // fills a rectangle's interior with any pattern you specify.void
fillRegion
(Area pArea, Pattern pPattern) void
fillRoundRect
(Rectangle2D pRectangle, int pArcW, int pArcH, Pattern pPattern) FillRoundRect(r,int,int,pat) // fills a rectangle's interior with any pattern you specify.private void
void
frameArc
(Rectangle2D pRectangle, int pStartAngle, int pArcAngle) FrameArc(r,int,int) // outline arc with the size, pattern, and pattern mode of the graphics pen.void
frameOval
(Rectangle2D pRectangle) FrameOval(r) // outline oval with the size, pattern, and pattern mode of the graphics pen.void
void
frameRect
(Rectangle2D pRectangle) FrameRect(r) // outline rect with the size, pattern, and pattern mode of the graphics pen.void
frameRegion
(Area pArea) void
frameRoundRect
(Rectangle2D pRectangle, int pArcW, int pArcH) FrameRoundRect(r,int,int) // outline round rect with the size, pattern, and pattern mode of the graphics pen.private void
frameShape
(Shape pShape) (package private) Color
private Composite
getCompositeFor
(int pMode) (package private) Color
Returns the pen position.private Stroke
getStroke
(Dimension2D pPenSize) void
hidePen()
HidePen Visibility (decrements visibility by one!)void
invertArc
(Rectangle2D pRectangle, int pStartAngle, int pArcAngle) InvertArc(r,int,int) // reverses the color of all pixels in the arcvoid
invertOval
(Rectangle2D pRectangle) InvertOval(r) // reverses the color of all pixels in the ovalvoid
invertPoly
(Polygon pPolygon) void
invertRect
(Rectangle2D pRectangle) InvertRect(r) // reverses the color of all pixels in the rectvoid
invertRegion
(Area pArea) void
invertRoundRect
(Rectangle2D pRectangle, int pArcW, int pArcH) InvertRoundRect(r,int,int) // reverses the color of all pixels in the rectprivate void
invertShape
(Shape pShape) private boolean
Tells whether pen is visible.final void
line
(double pDeltaX, double pDeltaY) void
lineTo
(double pX, double pY) final void
final void
move
(double pDeltaX, double pDeltaY) void
moveTo
(double pX, double pY) final void
void
paintArc
(Rectangle2D pRectangle, int pStartAngle, int pArcAngle) PaintArc(r,int,int) // fills an arc's interior with the pattern of the graphics pen, using the pattern mode of the graphics pen.void
paintOval
(Rectangle2D pRectangle) PaintOval(r) // fills an oval's interior with the pattern of the graphics pen, using the pattern mode of the graphics pen.void
void
paintRect
(Rectangle2D pRectangle) PaintRect(r) // fills a rectangle's interior with the pattern of the graphics pen, using the pattern mode of the graphics pen.void
paintRegion
(Area pArea) void
paintRoundRect
(Rectangle2D pRectangle, int pArcW, int pArcH) PaintRooundRect(r,int,int) // fills a rectangle's interior with the pattern of the graphics pen, using the pattern mode of the graphics pen.private void
paintShape
(Shape pShape) void
setBackground
(Color pColor) void
setBackgroundPattern
(Pattern pPaint) void
setClipRegion
(Shape pClip) void
setFillPattern
(Pattern fillPattern) void
setForeground
(Color pColor) void
void
setPenMode
(int pPenMode) PenMode // Sets pen pattern modefinal void
PenNormal // Reset (except posiotion)void
setPenPattern
(Pattern pPattern) PenPat invalid input: '&' PenPixPat // Sets pen bit pattern or pix patternvoid
setPenSize
(Dimension2D pSize) Sets the pen size.(package private) void
setTextFace
(int face) (package private) void
setTextFont
(int fontFamily) void
setTextFont
(String fontName) (package private) void
setTextMode
(int pSourceMode) (package private) void
void
setTextSize
(int pSize) protected void
protected void
setupForFill
(Pattern pPattern) Sets up paint context for fill.protected void
protected void
Sets up context for line drawing/painting.protected void
Sets up context for text drawing.void
showPen()
ShowPen Visibility (increments visibility by one!)private static Arc2D.Double
toArc
(Rectangle2D pRectangle, int pStartAngle, int pArcAngle, boolean pClosed) Converts a rectangle to an arc.private static Ellipse2D.Double
toOval
(Rectangle2D pRectangle) private static RoundRectangle2D.Double
toRoundRect
(Rectangle2D pRectangle, int pArcW, int pArcH)
-
Field Details
-
graphics
-
background
-
penVisibility
private int penVisibility -
penPosition
-
penPattern
-
penSize
-
penMode
private int penMode -
bgColor
-
fgColor
-
textMode
private int textMode -
textPattern
-
fillPattern
-
-
Constructor Details
-
QuickDrawContext
QuickDrawContext(Graphics2D pGraphics)
-
-
Method Details
-
dispose
protected void dispose() -
closePicture
public void closePicture() -
setClipRegion
-
setTextFont
void setTextFont(int fontFamily) -
setTextFont
-
setTextFace
void setTextFace(int face) -
setTextMode
void setTextMode(int pSourceMode) -
setTextSize
public void setTextSize(int pSize) -
setTextRatio
void setTextRatio() -
setOrigin
-
setForeground
-
getForeground
Color getForeground() -
setBackground
-
getBackground
Color getBackground() -
hidePen
public void hidePen()HidePen Visibility (decrements visibility by one!) -
showPen
public void showPen()ShowPen Visibility (increments visibility by one!) -
isPenVisible
private boolean isPenVisible()Tells whether pen is visible.- Returns:
true
if pen is visible
-
getPenPosition
Returns the pen position. GetPen- Returns:
- the current pen position
-
setPenSize
Sets the pen size. PenSize- Parameters:
pSize
- the new size
-
setPenMode
public void setPenMode(int pPenMode) PenMode // Sets pen pattern mode- Parameters:
pPenMode
- the new pen mode
-
setPenPattern
PenPat invalid input: '&' PenPixPat // Sets pen bit pattern or pix pattern- Parameters:
pPattern
- the new pattern
-
setPenNormal
public final void setPenNormal()PenNormal // Reset (except posiotion) -
setBackgroundPattern
-
setFillPattern
-
getCompositeFor
-
setupForText
protected void setupForText()Sets up context for text drawing. -
setupForPaint
protected void setupForPaint()Sets up context for line drawing/painting. -
getStroke
-
setupForFill
Sets up paint context for fill.- Parameters:
pPattern
- the pattern to use for filling.
-
setupForErase
protected void setupForErase() -
setupForInvert
protected void setupForInvert() -
moveTo
public void moveTo(double pX, double pY) -
moveTo
-
move
public final void move(double pDeltaX, double pDeltaY) -
lineTo
public void lineTo(double pX, double pY) -
lineTo
-
line
public final void line(double pDeltaX, double pDeltaY) -
frameRect
FrameRect(r) // outline rect with the size, pattern, and pattern mode of the graphics pen.- Parameters:
pRectangle
- the rectangle to frame
-
paintRect
PaintRect(r) // fills a rectangle's interior with the pattern of the graphics pen, using the pattern mode of the graphics pen.- Parameters:
pRectangle
- the rectangle to paint
-
fillRect
FillRect(r, pat) // fills a rectangle's interior with any pattern you specify. The procedure transfers the pattern with the patCopy pattern mode, which directly copies your requested pattern into the shape.- Parameters:
pRectangle
- the rectangle to fillpPattern
- the pattern to use
-
eraseRect
EraseRect(r) // fills the rectangle's interior with the background pattern- Parameters:
pRectangle
- the rectangle to erase
-
invertRect
InvertRect(r) // reverses the color of all pixels in the rect- Parameters:
pRectangle
- the rectangle to invert
-
toRoundRect
-
frameRoundRect
FrameRoundRect(r,int,int) // outline round rect with the size, pattern, and pattern mode of the graphics pen.- Parameters:
pRectangle
- the rectangle to framepArcW
- width of the oval defining the rounded corner.pArcH
- height of the oval defining the rounded corner.
-
paintRoundRect
PaintRooundRect(r,int,int) // fills a rectangle's interior with the pattern of the graphics pen, using the pattern mode of the graphics pen.- Parameters:
pRectangle
- the rectangle to paintpArcW
- width of the oval defining the rounded corner.pArcH
- height of the oval defining the rounded corner.
-
fillRoundRect
FillRoundRect(r,int,int,pat) // fills a rectangle's interior with any pattern you specify. The procedure transfers the pattern with the patCopy pattern mode, which directly copies your requested pattern into the shape.- Parameters:
pRectangle
- the rectangle to fillpArcW
- width of the oval defining the rounded corner.pArcH
- height of the oval defining the rounded corner.pPattern
- the pattern to use
-
eraseRoundRect
EraseRoundRect(r,int,int) // fills the rectangle's interior with the background pattern- Parameters:
pRectangle
- the rectangle to erasepArcW
- width of the oval defining the rounded corner.pArcH
- height of the oval defining the rounded corner.
-
invertRoundRect
InvertRoundRect(r,int,int) // reverses the color of all pixels in the rect- Parameters:
pRectangle
- the rectangle to invertpArcW
- width of the oval defining the rounded corner.pArcH
- height of the oval defining the rounded corner.
-
toOval
-
frameOval
FrameOval(r) // outline oval with the size, pattern, and pattern mode of the graphics pen.- Parameters:
pRectangle
- the rectangle to frame
-
paintOval
PaintOval(r) // fills an oval's interior with the pattern of the graphics pen, using the pattern mode of the graphics pen.- Parameters:
pRectangle
- the rectangle to paint
-
fillOval
FillOval(r, pat) // fills an oval's interior with any pattern you specify. The procedure transfers the pattern with the patCopy pattern mode, which directly copies your requested pattern into the shape.- Parameters:
pRectangle
- the rectangle to fillpPattern
- the pattern to use
-
eraseOval
EraseOval(r) // fills the oval's interior with the background pattern- Parameters:
pRectangle
- the rectangle to erase
-
invertOval
InvertOval(r) // reverses the color of all pixels in the oval- Parameters:
pRectangle
- the rectangle to invert
-
toArc
private static Arc2D.Double toArc(Rectangle2D pRectangle, int pStartAngle, int pArcAngle, boolean pClosed) Converts a rectangle to an arc.- Parameters:
pRectangle
- the framing rectanglepStartAngle
- start angle in degrees (starting from 12'o clock, this differs from Java)pArcAngle
- rotation angle in degrees (starting frompStartAngle
, this differs from Java arcs)pClosed
- specifies if the arc should be closed- Returns:
- the arc
-
frameArc
FrameArc(r,int,int) // outline arc with the size, pattern, and pattern mode of the graphics pen.- Parameters:
pRectangle
- the rectangle to framepStartAngle
- start angle in degrees (starting from 12'o clock, this differs from Java)pArcAngle
- rotation angle in degrees (starting frompStartAngle
, this differs from Java arcs)
-
paintArc
PaintArc(r,int,int) // fills an arc's interior with the pattern of the graphics pen, using the pattern mode of the graphics pen.- Parameters:
pRectangle
- the rectangle to paintpStartAngle
- start angle in degrees (starting from 12'o clock, this differs from Java)pArcAngle
- rotation angle in degrees (starting frompStartAngle
, this differs from Java arcs)
-
fillArc
FillArc(r,int,int, pat) // fills an arc's interior with any pattern you specify. The procedure transfers the pattern with the patCopy pattern mode, which directly copies your requested pattern into the shape.- Parameters:
pRectangle
- the rectangle to fillpStartAngle
- start angle in degrees (starting from 12'o clock, this differs from Java)pArcAngle
- rotation angle in degrees (starting frompStartAngle
, this differs from Java arcs)pPattern
- the pattern to use
-
eraseArc
EraseArc(r,int,int) // fills the arc's interior with the background pattern- Parameters:
pRectangle
- the rectangle to erasepStartAngle
- start angle in degrees (starting from 12'o clock, this differs from Java)pArcAngle
- rotation angle in degrees (starting frompStartAngle
, this differs from Java arcs)
-
invertArc
InvertArc(r,int,int) // reverses the color of all pixels in the arc- Parameters:
pRectangle
- the rectangle to invertpStartAngle
- start angle in degrees (starting from 12'o clock, this differs from Java)pArcAngle
- rotation angle in degrees (starting frompStartAngle
, this differs from Java arcs)
-
framePoly
-
paintPoly
-
fillPoly
-
erasePoly
-
invertPoly
-
frameRegion
-
paintRegion
-
fillRegion
-
eraseRegion
-
invertRegion
-
frameShape
-
paintShape
-
fillShape
-
invertShape
-
eraseShape
-
copyBits
public void copyBits(BufferedImage pSrcBitmap, Rectangle pSrcRect, Rectangle pDstRect, int pMode, Shape pMaskRgn) CopyBits.Note that the destination is always
this
.- Parameters:
pSrcBitmap
- the source bitmap to copy pixels frompSrcRect
- the source rectanglepDstRect
- the destination rectanglepMode
- the blending modepMaskRgn
- the mask region
-
copyMask
public void copyMask(BufferedImage pSrcBitmap, BufferedImage pMaskBitmap, Rectangle pSrcRect, Rectangle pMaskRect, Rectangle pDstRect, int pSrcCopy, Shape pMaskRgn) CopyMask -
copyDeepMask
public void copyDeepMask(BufferedImage pSrcBitmap, BufferedImage pMaskBitmap, Rectangle pSrcRect, Rectangle pMaskRect, Rectangle pDstRect, int pSrcCopy, Shape pMaskRgn) CopyDeepMask -- available to basic QuickDraw only in System 7, combines the functionality of both CopyBits and CopyMask -
drawString
DrawString - draws the text of a Pascal string.- Parameters:
pString
- a Pascal string (a string of length less than or equal to 255 chars).
-