Class GroupGraphics
Non-isolated groups require that the group backdrop (copied from parent group or
page) is used as the initial contents of the image to which the group is rendered.
This allows blend modes to blend the group contents with the graphics behind
the group. Finally when the group rendering is done, backdrop removal must be
computed (see removeBackdrop).
It ensures the backdrop is not rendered twice on the parent but it leaves the
effects of blend modes.
This class renders the group contents to two images. groupImage is
initialized with the backdrop and group contents are drawn over it.
groupAlphaImage is initially fully transparent and it accumulates
the total alpha of the group contents excluding backdrop.
If a non-isolated group uses only the blend mode Normal, it can be optimized and rendered like an isolated group; backdrop usage and removal are not needed.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Graphics2Dprivate final BufferedImageprivate final Graphics2Dprivate final BufferedImage -
Constructor Summary
ConstructorsModifierConstructorDescription(package private)GroupGraphics(BufferedImage groupImage, Graphics2D groupGraphics) privateGroupGraphics(BufferedImage groupImage, Graphics2D groupGraphics, BufferedImage groupAlphaImage, Graphics2D alphaGraphics) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddRenderingHints(Map<?, ?> hints) private intbackdropRemoval(int groupRGB, int backdropRGB, int shift, float alphaFactor) Computes the backdrop removal equation.voidclearRect(int x, int y, int width, int height) voidvoidclipRect(int x, int y, int width, int height) voidcopyArea(int x, int y, int width, int height, int dx, int dy) create()voiddispose()voidvoiddrawArc(int x, int y, int width, int height, int startAngle, int arcAngle) voiddrawGlyphVector(GlyphVector g, float x, float y) voiddrawImage(BufferedImage img, BufferedImageOp op, int x, int y) booleandrawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer) booleandrawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer) booleandrawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer) booleandrawImage(Image img, int x, int y, int width, int height, ImageObserver observer) booleandrawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer) booleandrawImage(Image img, int x, int y, ImageObserver observer) booleandrawImage(Image img, AffineTransform xform, ImageObserver obs) voiddrawLine(int x1, int y1, int x2, int y2) voiddrawOval(int x, int y, int width, int height) voiddrawPolygon(int[] xPoints, int[] yPoints, int nPoints) voiddrawPolyline(int[] xPoints, int[] yPoints, int nPoints) voiddrawRenderableImage(RenderableImage img, AffineTransform xform) voiddrawRenderedImage(RenderedImage img, AffineTransform xform) voiddrawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) voiddrawString(String str, float x, float y) voiddrawString(String str, int x, int y) voiddrawString(AttributedCharacterIterator iterator, float x, float y) voiddrawString(AttributedCharacterIterator iterator, int x, int y) voidvoidfillArc(int x, int y, int width, int height, int startAngle, int arcAngle) voidfillOval(int x, int y, int width, int height) voidfillPolygon(int[] xPoints, int[] yPoints, int nPoints) voidfillRect(int x, int y, int width, int height) voidfillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) getClip()getColor()getFont()getPaint()getRenderingHint(RenderingHints.Key hintKey) boolean(package private) voidremoveBackdrop(BufferedImage backdrop, int offsetX, int offsetY) Computes backdrop removal.voidrotate(double theta) voidrotate(double theta, double x, double y) voidscale(double sx, double sy) voidsetBackground(Color color) voidsetClip(int x, int y, int width, int height) voidvoidvoidsetComposite(Composite comp) voidvoidvoidvoidsetRenderingHint(RenderingHints.Key hintKey, Object hintValue) voidsetRenderingHints(Map<?, ?> hints) voidvoidvoidsetXORMode(Color c1) voidshear(double shx, double shy) voidvoidtranslate(double tx, double ty) voidtranslate(int x, int y) Methods inherited from class java.awt.Graphics2D
draw3DRect, fill3DRectMethods inherited from class java.awt.Graphics
create, drawBytes, drawChars, drawPolygon, drawRect, fillPolygon, finalize, getClipBounds, getClipRect, getFontMetrics, hitClip, toString
-
Field Details
-
groupImage
-
groupAlphaImage
-
groupG2D
-
alphaG2D
-
-
Constructor Details
-
GroupGraphics
GroupGraphics(BufferedImage groupImage, Graphics2D groupGraphics) -
GroupGraphics
private GroupGraphics(BufferedImage groupImage, Graphics2D groupGraphics, BufferedImage groupAlphaImage, Graphics2D alphaGraphics)
-
-
Method Details
-
clearRect
public void clearRect(int x, int y, int width, int height) -
clipRect
public void clipRect(int x, int y, int width, int height) -
copyArea
public void copyArea(int x, int y, int width, int height, int dx, int dy) -
create
-
dispose
public void dispose() -
drawArc
public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) -
drawImage
-
drawImage
-
drawImage
public boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer) -
drawImage
-
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) -
drawImage
public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer) -
drawLine
public void drawLine(int x1, int y1, int x2, int y2) -
drawOval
public void drawOval(int x, int y, int width, int height) -
drawPolygon
public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints) - Specified by:
drawPolygonin classGraphics
-
drawPolyline
public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints) - Specified by:
drawPolylinein classGraphics
-
drawRoundRect
public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) - Specified by:
drawRoundRectin classGraphics
-
drawString
- Specified by:
drawStringin classGraphics2D
-
drawString
- Specified by:
drawStringin classGraphics2D
-
fillArc
public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) -
fillOval
public void fillOval(int x, int y, int width, int height) -
fillPolygon
public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) - Specified by:
fillPolygonin classGraphics
-
fillRect
public void fillRect(int x, int y, int width, int height) -
fillRoundRect
public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) - Specified by:
fillRoundRectin classGraphics
-
getClip
-
getClipBounds
- Specified by:
getClipBoundsin classGraphics
-
getColor
-
getFont
-
getFontMetrics
- Specified by:
getFontMetricsin classGraphics
-
setClip
public void setClip(int x, int y, int width, int height) -
setClip
-
setColor
-
setFont
-
setPaintMode
public void setPaintMode()- Specified by:
setPaintModein classGraphics
-
setXORMode
- Specified by:
setXORModein classGraphics
-
translate
public void translate(int x, int y) - Specified by:
translatein classGraphics2D
-
addRenderingHints
- Specified by:
addRenderingHintsin classGraphics2D
-
clip
- Specified by:
clipin classGraphics2D
-
draw
- Specified by:
drawin classGraphics2D
-
drawGlyphVector
- Specified by:
drawGlyphVectorin classGraphics2D
-
drawImage
- Specified by:
drawImagein classGraphics2D
-
drawImage
- Specified by:
drawImagein classGraphics2D
-
drawRenderableImage
- Specified by:
drawRenderableImagein classGraphics2D
-
drawRenderedImage
- Specified by:
drawRenderedImagein classGraphics2D
-
drawString
- Specified by:
drawStringin classGraphics2D
-
drawString
- Specified by:
drawStringin classGraphics2D
-
fill
- Specified by:
fillin classGraphics2D
-
getBackground
- Specified by:
getBackgroundin classGraphics2D
-
getComposite
- Specified by:
getCompositein classGraphics2D
-
getDeviceConfiguration
- Specified by:
getDeviceConfigurationin classGraphics2D
-
getFontRenderContext
- Specified by:
getFontRenderContextin classGraphics2D
-
getPaint
- Specified by:
getPaintin classGraphics2D
-
getRenderingHint
- Specified by:
getRenderingHintin classGraphics2D
-
getRenderingHints
- Specified by:
getRenderingHintsin classGraphics2D
-
getStroke
- Specified by:
getStrokein classGraphics2D
-
getTransform
- Specified by:
getTransformin classGraphics2D
-
hit
- Specified by:
hitin classGraphics2D
-
rotate
public void rotate(double theta) - Specified by:
rotatein classGraphics2D
-
rotate
public void rotate(double theta, double x, double y) - Specified by:
rotatein classGraphics2D
-
scale
public void scale(double sx, double sy) - Specified by:
scalein classGraphics2D
-
setBackground
- Specified by:
setBackgroundin classGraphics2D
-
setComposite
- Specified by:
setCompositein classGraphics2D
-
setPaint
- Specified by:
setPaintin classGraphics2D
-
setRenderingHint
- Specified by:
setRenderingHintin classGraphics2D
-
setRenderingHints
- Specified by:
setRenderingHintsin classGraphics2D
-
setStroke
- Specified by:
setStrokein classGraphics2D
-
setTransform
- Specified by:
setTransformin classGraphics2D
-
shear
public void shear(double shx, double shy) - Specified by:
shearin classGraphics2D
-
transform
- Specified by:
transformin classGraphics2D
-
translate
public void translate(double tx, double ty) - Specified by:
translatein classGraphics2D
-
removeBackdrop
Computes backdrop removal. The backdrop removal equation is given in section 11.4.4 in the PDF 32000-1:2008 standard. It returns the final colorCfor each pixel in the group:
C = Cn + (Cn - C0) * (alpha0 / alphagn - alpha0)
where
Cnis the group color including backdrop (read fromgroupImage),
C0is the backdrop color,
alpha0is the backdrop alpha,
alphagnis the group alpha excluding backdrop (read the alpha channel fromgroupAlphaImage)
The alpha of the result is equal to
alphagn, i.e., the alpha channel ofgroupAlphaImage.The
backdropimage may be much larger thangroupImageif, for example, the current page is used as the backdrop. Only a specific rectangular region ofbackdropis used in the backdrop removal: upper-left corner is at(offsetX, offsetY); width and height are equal to those ofgroupImage.- Parameters:
backdrop- group backdropoffsetX- backdrop left X coordinateoffsetY- backdrop upper Y coordinate
-
backdropRemoval
private int backdropRemoval(int groupRGB, int backdropRGB, int shift, float alphaFactor) Computes the backdrop removal equation.C = Cn + (Cn - C0) * (alpha0 / alphagn - alpha0)
-