Class QuickDrawContext
- java.lang.Object
-
- com.twelvemonkeys.imageio.plugins.pict.QuickDrawContext
-
class QuickDrawContext extends java.lang.ObjectEmulates an Apple QuickDraw rendering context, backed by a JavaGraphics2D.- Version:
- $Id: QuickDrawContext.java,v 1.0 Oct 3, 2007 1:24:35 AM haraldk Exp$
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classQuickDrawContext.RectangleStroke
-
Field Summary
Fields Modifier and Type Field Description private Patternbackgroundprivate java.awt.ColorbgColorprivate java.awt.ColorfgColorprivate PatternfillPatternprivate java.awt.Graphics2Dgraphicsprivate intpenModeprivate PatternpenPatternprivate java.awt.geom.Point2DpenPositionprivate java.awt.geom.Dimension2DpenSizeprivate intpenVisibilityprivate inttextModeprivate PatterntextPattern
-
Constructor Summary
Constructors Constructor Description QuickDrawContext(java.awt.Graphics2D pGraphics)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclosePicture()voidcopyBits(java.awt.image.BufferedImage pSrcBitmap, java.awt.Rectangle pSrcRect, java.awt.Rectangle pDstRect, int pMode, java.awt.Shape pMaskRgn)CopyBits.voidcopyDeepMask(java.awt.image.BufferedImage pSrcBitmap, java.awt.image.BufferedImage pMaskBitmap, java.awt.Rectangle pSrcRect, java.awt.Rectangle pMaskRect, java.awt.Rectangle pDstRect, int pSrcCopy, java.awt.Shape pMaskRgn)CopyDeepMask -- available to basic QuickDraw only in System 7, combines the functionality of both CopyBits and CopyMaskvoidcopyMask(java.awt.image.BufferedImage pSrcBitmap, java.awt.image.BufferedImage pMaskBitmap, java.awt.Rectangle pSrcRect, java.awt.Rectangle pMaskRect, java.awt.Rectangle pDstRect, int pSrcCopy, java.awt.Shape pMaskRgn)CopyMaskprotected voiddispose()voiddrawString(java.lang.String pString)DrawString - draws the text of a Pascal string.voideraseArc(java.awt.geom.Rectangle2D pRectangle, int pStartAngle, int pArcAngle)EraseArc(r,int,int) // fills the arc's interior with the background patternvoideraseOval(java.awt.geom.Rectangle2D pRectangle)EraseOval(r) // fills the oval's interior with the background patternvoiderasePoly(java.awt.Polygon pPolygon)voideraseRect(java.awt.geom.Rectangle2D pRectangle)EraseRect(r) // fills the rectangle's interior with the background patternvoideraseRegion(java.awt.geom.Area pArea)voideraseRoundRect(java.awt.geom.Rectangle2D pRectangle, int pArcW, int pArcH)EraseRoundRect(r,int,int) // fills the rectangle's interior with the background patternprivate voideraseShape(java.awt.Shape pShape)voidfillArc(java.awt.geom.Rectangle2D pRectangle, int pStartAngle, int pArcAngle, Pattern pPattern)FillArc(r,int,int, pat) // fills an arc's interior with any pattern you specify.voidfillOval(java.awt.geom.Rectangle2D pRectangle, Pattern pPattern)FillOval(r, pat) // fills an oval's interior with any pattern you specify.voidfillPoly(java.awt.Polygon pPolygon, Pattern pPattern)voidfillRect(java.awt.geom.Rectangle2D pRectangle, Pattern pPattern)FillRect(r, pat) // fills a rectangle's interior with any pattern you specify.voidfillRegion(java.awt.geom.Area pArea, Pattern pPattern)voidfillRoundRect(java.awt.geom.Rectangle2D pRectangle, int pArcW, int pArcH, Pattern pPattern)FillRoundRect(r,int,int,pat) // fills a rectangle's interior with any pattern you specify.private voidfillShape(java.awt.Shape pShape, Pattern pPattern)voidframeArc(java.awt.geom.Rectangle2D pRectangle, int pStartAngle, int pArcAngle)FrameArc(r,int,int) // outline arc with the size, pattern, and pattern mode of the graphics pen.voidframeOval(java.awt.geom.Rectangle2D pRectangle)FrameOval(r) // outline oval with the size, pattern, and pattern mode of the graphics pen.voidframePoly(java.awt.Polygon pPolygon)voidframeRect(java.awt.geom.Rectangle2D pRectangle)FrameRect(r) // outline rect with the size, pattern, and pattern mode of the graphics pen.voidframeRegion(java.awt.geom.Area pArea)voidframeRoundRect(java.awt.geom.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 voidframeShape(java.awt.Shape pShape)(package private) java.awt.ColorgetBackground()private java.awt.CompositegetCompositeFor(int pMode)(package private) java.awt.ColorgetForeground()java.awt.geom.Point2DgetPenPosition()Returns the pen position.private java.awt.StrokegetStroke(java.awt.geom.Dimension2D pPenSize)voidhidePen()HidePen Visibility (decrements visibility by one!)voidinvertArc(java.awt.geom.Rectangle2D pRectangle, int pStartAngle, int pArcAngle)InvertArc(r,int,int) // reverses the color of all pixels in the arcvoidinvertOval(java.awt.geom.Rectangle2D pRectangle)InvertOval(r) // reverses the color of all pixels in the ovalvoidinvertPoly(java.awt.Polygon pPolygon)voidinvertRect(java.awt.geom.Rectangle2D pRectangle)InvertRect(r) // reverses the color of all pixels in the rectvoidinvertRegion(java.awt.geom.Area pArea)voidinvertRoundRect(java.awt.geom.Rectangle2D pRectangle, int pArcW, int pArcH)InvertRoundRect(r,int,int) // reverses the color of all pixels in the rectprivate voidinvertShape(java.awt.Shape pShape)private booleanisPenVisible()Tells whether pen is visible.voidline(double pDeltaX, double pDeltaY)voidlineTo(double pX, double pY)voidlineTo(java.awt.geom.Point2D pPosition)voidmove(double pDeltaX, double pDeltaY)voidmoveTo(double pX, double pY)voidmoveTo(java.awt.geom.Point2D pPosition)voidpaintArc(java.awt.geom.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.voidpaintOval(java.awt.geom.Rectangle2D pRectangle)PaintOval(r) // fills an oval's interior with the pattern of the graphics pen, using the pattern mode of the graphics pen.voidpaintPoly(java.awt.Polygon pPolygon)voidpaintRect(java.awt.geom.Rectangle2D pRectangle)PaintRect(r) // fills a rectangle's interior with the pattern of the graphics pen, using the pattern mode of the graphics pen.voidpaintRegion(java.awt.geom.Area pArea)voidpaintRoundRect(java.awt.geom.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 voidpaintShape(java.awt.Shape pShape)voidsetBackground(java.awt.Color pColor)voidsetBackgroundPattern(Pattern pPaint)voidsetClipRegion(java.awt.Shape pClip)voidsetFillPattern(Pattern fillPattern)voidsetForeground(java.awt.Color pColor)voidsetOrigin(java.awt.geom.Point2D pOrigin)voidsetPenMode(int pPenMode)PenMode // Sets pen pattern modevoidsetPenNormal()PenNormal // Reset (except posiotion)voidsetPenPattern(Pattern pPattern)PenPat & PenPixPat // Sets pen bit pattern or pix patternvoidsetPenSize(java.awt.geom.Dimension2D pSize)Sets the pen size.(package private) voidsetTextFace(int face)(package private) voidsetTextFont(int fontFamily)voidsetTextFont(java.lang.String fontName)(package private) voidsetTextMode(int pSourceMode)(package private) voidsetTextRatio()voidsetTextSize(int pSize)protected voidsetupForErase()protected voidsetupForFill(Pattern pPattern)Sets up paint context for fill.protected voidsetupForInvert()protected voidsetupForPaint()Sets up context for line drawing/painting.protected voidsetupForText()Sets up context for text drawing.voidshowPen()ShowPen Visibility (increments visibility by one!)private static java.awt.geom.Arc2D.DoubletoArc(java.awt.geom.Rectangle2D pRectangle, int pStartAngle, int pArcAngle, boolean pClosed)Converts a rectangle to an arc.private static java.awt.geom.Ellipse2D.DoubletoOval(java.awt.geom.Rectangle2D pRectangle)private static java.awt.geom.RoundRectangle2D.DoubletoRoundRect(java.awt.geom.Rectangle2D pRectangle, int pArcW, int pArcH)
-
-
-
Field Detail
-
graphics
private final java.awt.Graphics2D graphics
-
background
private Pattern background
-
penVisibility
private int penVisibility
-
penPosition
private java.awt.geom.Point2D penPosition
-
penPattern
private Pattern penPattern
-
penSize
private java.awt.geom.Dimension2D penSize
-
penMode
private int penMode
-
bgColor
private java.awt.Color bgColor
-
fgColor
private java.awt.Color fgColor
-
textMode
private int textMode
-
textPattern
private Pattern textPattern
-
fillPattern
private Pattern fillPattern
-
-
Method Detail
-
dispose
protected void dispose()
-
closePicture
public void closePicture()
-
setClipRegion
public void setClipRegion(java.awt.Shape pClip)
-
setTextFont
void setTextFont(int fontFamily)
-
setTextFont
public void setTextFont(java.lang.String fontName)
-
setTextFace
void setTextFace(int face)
-
setTextMode
void setTextMode(int pSourceMode)
-
setTextSize
public void setTextSize(int pSize)
-
setTextRatio
void setTextRatio()
-
setOrigin
public void setOrigin(java.awt.geom.Point2D pOrigin)
-
setForeground
public void setForeground(java.awt.Color pColor)
-
getForeground
java.awt.Color getForeground()
-
setBackground
public void setBackground(java.awt.Color pColor)
-
getBackground
java.awt.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:
trueif pen is visible
-
getPenPosition
public java.awt.geom.Point2D getPenPosition()
Returns the pen position. GetPen- Returns:
- the current pen position
-
setPenSize
public void setPenSize(java.awt.geom.Dimension2D pSize)
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
public void setPenPattern(Pattern pPattern)
PenPat & PenPixPat // Sets pen bit pattern or pix pattern- Parameters:
pPattern- the new pattern
-
setPenNormal
public final void setPenNormal()
PenNormal // Reset (except posiotion)
-
setBackgroundPattern
public void setBackgroundPattern(Pattern pPaint)
-
setFillPattern
public void setFillPattern(Pattern fillPattern)
-
getCompositeFor
private java.awt.Composite getCompositeFor(int pMode)
-
setupForText
protected void setupForText()
Sets up context for text drawing.
-
setupForPaint
protected void setupForPaint()
Sets up context for line drawing/painting.
-
getStroke
private java.awt.Stroke getStroke(java.awt.geom.Dimension2D pPenSize)
-
setupForFill
protected void setupForFill(Pattern pPattern)
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
public final void moveTo(java.awt.geom.Point2D pPosition)
-
move
public final void move(double pDeltaX, double pDeltaY)
-
lineTo
public void lineTo(double pX, double pY)
-
lineTo
public final void lineTo(java.awt.geom.Point2D pPosition)
-
line
public final void line(double pDeltaX, double pDeltaY)
-
frameRect
public void frameRect(java.awt.geom.Rectangle2D pRectangle)
FrameRect(r) // outline rect with the size, pattern, and pattern mode of the graphics pen.- Parameters:
pRectangle- the rectangle to frame
-
paintRect
public void paintRect(java.awt.geom.Rectangle2D pRectangle)
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
public void fillRect(java.awt.geom.Rectangle2D pRectangle, Pattern pPattern)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
public void eraseRect(java.awt.geom.Rectangle2D pRectangle)
EraseRect(r) // fills the rectangle's interior with the background pattern- Parameters:
pRectangle- the rectangle to erase
-
invertRect
public void invertRect(java.awt.geom.Rectangle2D pRectangle)
InvertRect(r) // reverses the color of all pixels in the rect- Parameters:
pRectangle- the rectangle to invert
-
toRoundRect
private static java.awt.geom.RoundRectangle2D.Double toRoundRect(java.awt.geom.Rectangle2D pRectangle, int pArcW, int pArcH)
-
frameRoundRect
public void frameRoundRect(java.awt.geom.Rectangle2D pRectangle, int pArcW, int pArcH)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
public void paintRoundRect(java.awt.geom.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.- Parameters:
pRectangle- the rectangle to paintpArcW- width of the oval defining the rounded corner.pArcH- height of the oval defining the rounded corner.
-
fillRoundRect
public void fillRoundRect(java.awt.geom.Rectangle2D pRectangle, int pArcW, int pArcH, Pattern pPattern)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
public void eraseRoundRect(java.awt.geom.Rectangle2D pRectangle, int pArcW, int pArcH)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
public void invertRoundRect(java.awt.geom.Rectangle2D pRectangle, int pArcW, int pArcH)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
private static java.awt.geom.Ellipse2D.Double toOval(java.awt.geom.Rectangle2D pRectangle)
-
frameOval
public void frameOval(java.awt.geom.Rectangle2D pRectangle)
FrameOval(r) // outline oval with the size, pattern, and pattern mode of the graphics pen.- Parameters:
pRectangle- the rectangle to frame
-
paintOval
public void paintOval(java.awt.geom.Rectangle2D pRectangle)
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
public void fillOval(java.awt.geom.Rectangle2D pRectangle, Pattern pPattern)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
public void eraseOval(java.awt.geom.Rectangle2D pRectangle)
EraseOval(r) // fills the oval's interior with the background pattern- Parameters:
pRectangle- the rectangle to erase
-
invertOval
public void invertOval(java.awt.geom.Rectangle2D pRectangle)
InvertOval(r) // reverses the color of all pixels in the oval- Parameters:
pRectangle- the rectangle to invert
-
toArc
private static java.awt.geom.Arc2D.Double toArc(java.awt.geom.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
public void frameArc(java.awt.geom.Rectangle2D pRectangle, int pStartAngle, int pArcAngle)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
public void paintArc(java.awt.geom.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.- 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
public void fillArc(java.awt.geom.Rectangle2D pRectangle, int pStartAngle, int pArcAngle, Pattern pPattern)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
public void eraseArc(java.awt.geom.Rectangle2D pRectangle, int pStartAngle, int pArcAngle)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
public void invertArc(java.awt.geom.Rectangle2D pRectangle, int pStartAngle, int pArcAngle)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
public void framePoly(java.awt.Polygon pPolygon)
-
paintPoly
public void paintPoly(java.awt.Polygon pPolygon)
-
fillPoly
public void fillPoly(java.awt.Polygon pPolygon, Pattern pPattern)
-
erasePoly
public void erasePoly(java.awt.Polygon pPolygon)
-
invertPoly
public void invertPoly(java.awt.Polygon pPolygon)
-
frameRegion
public void frameRegion(java.awt.geom.Area pArea)
-
paintRegion
public void paintRegion(java.awt.geom.Area pArea)
-
fillRegion
public void fillRegion(java.awt.geom.Area pArea, Pattern pPattern)
-
eraseRegion
public void eraseRegion(java.awt.geom.Area pArea)
-
invertRegion
public void invertRegion(java.awt.geom.Area pArea)
-
frameShape
private void frameShape(java.awt.Shape pShape)
-
paintShape
private void paintShape(java.awt.Shape pShape)
-
fillShape
private void fillShape(java.awt.Shape pShape, Pattern pPattern)
-
invertShape
private void invertShape(java.awt.Shape pShape)
-
eraseShape
private void eraseShape(java.awt.Shape pShape)
-
copyBits
public void copyBits(java.awt.image.BufferedImage pSrcBitmap, java.awt.Rectangle pSrcRect, java.awt.Rectangle pDstRect, int pMode, java.awt.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(java.awt.image.BufferedImage pSrcBitmap, java.awt.image.BufferedImage pMaskBitmap, java.awt.Rectangle pSrcRect, java.awt.Rectangle pMaskRect, java.awt.Rectangle pDstRect, int pSrcCopy, java.awt.Shape pMaskRgn)CopyMask
-
copyDeepMask
public void copyDeepMask(java.awt.image.BufferedImage pSrcBitmap, java.awt.image.BufferedImage pMaskBitmap, java.awt.Rectangle pSrcRect, java.awt.Rectangle pMaskRect, java.awt.Rectangle pDstRect, int pSrcCopy, java.awt.Shape pMaskRgn)CopyDeepMask -- available to basic QuickDraw only in System 7, combines the functionality of both CopyBits and CopyMask
-
drawString
public void drawString(java.lang.String pString)
DrawString - draws the text of a Pascal string.- Parameters:
pString- a Pascal string (a string of length less than or equal to 255 chars).
-
-