public class J2DPrismGraphics extends java.lang.Object implements ReadbackGraphics, MaskTextureGraphics
Modifier and Type | Class and Description |
---|---|
private static class |
J2DPrismGraphics.AdaptorPathIterator |
private static class |
J2DPrismGraphics.AdaptorShape |
(package private) static class |
J2DPrismGraphics.FilterStroke |
(package private) static class |
J2DPrismGraphics.InnerStroke |
(package private) static class |
J2DPrismGraphics.OuterStroke |
Modifier and Type | Field and Description |
---|---|
private boolean |
antialiasedShape |
private static int |
cleared |
(package private) Rectangle |
clipRect |
private int |
clipRectIndex |
(package private) boolean |
cull |
private static Paint |
DEFAULT_PAINT |
private static BasicStroke |
DEFAULT_STROKE |
(package private) RectBounds |
devClipRect |
(package private) RectBounds |
finalClipRect |
private static java.util.concurrent.ConcurrentHashMap<java.awt.Font,java.lang.ref.WeakReference<java.awt.Font>> |
fontMap |
(package private) java.awt.Graphics2D |
g2d |
private boolean |
hasPreCullingBits |
(package private) static java.awt.geom.AffineTransform |
J2D_IDENTITY |
(package private) static java.awt.MultipleGradientPaint.CycleMethod[] |
LGP_CYCLE_METHODS |
(package private) java.awt.geom.Rectangle2D |
nodeBounds |
(package private) Paint |
paint |
(package private) boolean |
paintWasProportional |
private float |
pixelScale |
private NodePath |
renderRoot |
(package private) static MultipleGradientPaint.CycleMethod[] |
RGP_CYCLE_METHODS |
(package private) BasicStroke |
stroke |
(package private) J2DPresentable |
target |
private static J2DPrismGraphics.AdaptorShape |
tmpAdaptor |
private static java.awt.geom.AffineTransform |
tmpAT |
private static java.awt.geom.Ellipse2D |
tmpEllipse |
private static java.awt.geom.Line2D |
tmpLine |
private static java.awt.geom.Path2D |
tmpQuadShape |
private static java.awt.geom.Rectangle2D.Float |
tmpRect |
private static java.awt.geom.RoundRectangle2D |
tmpRRect |
(package private) Affine2D |
transform |
Constructor and Description |
---|
J2DPrismGraphics(java.awt.Graphics2D g2d,
int width,
int height) |
J2DPrismGraphics(J2DPresentable target,
java.awt.Graphics2D g2d) |
Modifier and Type | Method and Description |
---|---|
void |
blit(RTTexture srcTex,
RTTexture dstTex,
int srcX0,
int srcY0,
int srcX1,
int srcY1,
int dstX0,
int dstY0,
int dstX1,
int dstY1) |
boolean |
canReadBack() |
protected void |
captureTransform(java.awt.Graphics2D g2d)
Needed only by printing subclass, which over-rides it.
|
void |
clear()
Clears the current
RenderTarget with transparent pixels. |
void |
clear(Color color)
Clears the current
RenderTarget with the given Color . |
(package private) void |
clear(java.awt.Color c) |
void |
clearQuad(float x1,
float y1,
float x2,
float y2)
Clears the region represented by the given quad with transparent pixels.
|
private void |
doDrawMaskTexture(J2DRTTexture imgtex,
J2DRTTexture masktex,
int dx,
int dy,
int dw,
int dh,
int ix,
int iy,
int mx,
int my,
boolean srcover) |
(package private) void |
draw(java.awt.Shape shape) |
void |
draw(Shape shape) |
void |
drawEllipse(float x,
float y,
float width,
float height) |
void |
drawLine(float x1,
float y1,
float x2,
float y2) |
void |
drawMappedTextureRaw(Texture tex,
float dx1,
float dy1,
float dx2,
float dy2,
float tx11,
float ty11,
float tx21,
float ty21,
float tx12,
float ty12,
float tx22,
float ty22) |
void |
drawPixelsMasked(RTTexture imgtex,
RTTexture masktex,
int dx,
int dy,
int dw,
int dh,
int ix,
int iy,
int mx,
int my)
Apply a mask to the pixels of an image and render the results onto
the destination in device space.
|
void |
drawRect(float x,
float y,
float width,
float height) |
void |
drawRoundRect(float x,
float y,
float width,
float height,
float arcw,
float arch) |
void |
drawString(GlyphList gl,
FontStrike strike,
float x,
float y,
Color selectColor,
int start,
int end) |
private void |
drawString(GlyphList gl,
int start,
int end,
FontStrike strike,
float x,
float y) |
void |
drawTexture(Texture tex,
float x,
float y,
float w,
float h) |
void |
drawTexture(Texture tex,
float dx1,
float dy1,
float dx2,
float dy2,
float sx1,
float sy1,
float sx2,
float sy2) |
void |
drawTexture3SliceH(Texture tex,
float dx1,
float dy1,
float dx2,
float dy2,
float sx1,
float sy1,
float sx2,
float sy2,
float dh1,
float dh2,
float sh1,
float sh2) |
void |
drawTexture3SliceV(Texture tex,
float dx1,
float dy1,
float dx2,
float dy2,
float sx1,
float sy1,
float sx2,
float sy2,
float dv1,
float dv2,
float sv1,
float sv2) |
void |
drawTexture9Slice(Texture tex,
float dx1,
float dy1,
float dx2,
float dy2,
float sx1,
float sy1,
float sx2,
float sy2,
float dh1,
float dv1,
float dh2,
float dv2,
float sh1,
float sv1,
float sh2,
float sv2) |
void |
drawTextureRaw(Texture tex,
float dx1,
float dy1,
float dx2,
float dy2,
float tx1,
float ty1,
float tx2,
float ty2) |
void |
drawTextureVO(Texture tex,
float topopacity,
float botopacity,
float dx1,
float dy1,
float dx2,
float dy2,
float sx1,
float sy1,
float sx2,
float sy2) |
(package private) void |
fill(java.awt.Shape shape) |
void |
fill(Shape shape) |
void |
fillEllipse(float x,
float y,
float width,
float height) |
void |
fillQuad(float x1,
float y1,
float x2,
float y2) |
void |
fillRect(float x,
float y,
float width,
float height) |
void |
fillRoundRect(float x,
float y,
float width,
float height,
float arcw,
float arch) |
(package private) static int |
fixFractions(float[] fractions,
java.awt.Color[] colors) |
Screen |
getAssociatedScreen() |
private java.awt.AlphaComposite |
getAWTComposite() |
NGCamera |
getCameraNoClone() |
Rectangle |
getClipRect() |
int |
getClipRectIndex() |
Rectangle |
getClipRectNoClone() |
CompositeMode |
getCompositeMode() |
float |
getExtraAlpha() |
RectBounds |
getFinalClipNoClone() |
NGLightBase[] |
getLights() |
Paint |
getPaint() |
float |
getPixelScaleFactor() |
NodePath |
getRenderRoot() |
RenderTarget |
getRenderTarget() |
ResourceFactory |
getResourceFactory() |
BasicStroke |
getStroke() |
BaseTransform |
getTransformNoClone() |
boolean |
hasPreCullingBits() |
boolean |
isAlphaTestShader() |
boolean |
isAntialiasedShape() |
boolean |
isCulling() |
boolean |
isDepthBuffer() |
boolean |
isDepthTest() |
boolean |
isState3D() |
void |
maskInterpolatePixels(RTTexture imgtex,
RTTexture masktex,
int dx,
int dy,
int dw,
int dh,
int ix,
int iy,
int mx,
int my)
Use a mask to determine which pixels of an image are to be rendered
onto the destination in device space.
|
RTTexture |
readBack(Rectangle view) |
void |
releaseReadBackBuffer(RTTexture view) |
void |
reset() |
void |
scale(float sx,
float sy) |
void |
scale(float sx,
float sy,
float sz) |
void |
setAntialiasedShape(boolean aa) |
void |
setCamera(NGCamera camera) |
void |
setClipRect(Rectangle clipRect) |
void |
setClipRectIndex(int index) |
void |
setCompositeMode(CompositeMode mode) |
void |
setCulling(boolean cull) |
void |
setDepthBuffer(boolean depthBuffer) |
void |
setDepthTest(boolean depthTest) |
void |
setExtraAlpha(float extraAlpha) |
void |
setHasPreCullingBits(boolean hasBits) |
void |
setLights(NGLightBase[] lights) |
void |
setNodeBounds(RectBounds bounds)
Set the node bounds for any node that would like to render objects of a
different size to self.
|
void |
setPaint(Paint paint) |
void |
setPerspectiveTransform(GeneralTransform3D transform) |
void |
setPixelScaleFactor(float pixelScale) |
void |
setRenderRoot(NodePath root) |
void |
setState3D(boolean flag) |
void |
setStroke(BasicStroke stroke) |
void |
setTransform(BaseTransform xform) |
void |
setTransform(double m00,
double m10,
double m01,
double m11,
double m02,
double m12) |
void |
setTransform3D(double mxx,
double mxy,
double mxz,
double mxt,
double myx,
double myy,
double myz,
double myt,
double mzx,
double mzy,
double mzz,
double mzt) |
protected void |
setTransformG2D(java.awt.geom.AffineTransform tx)
Overridden by printing subclass to preserve the printer graphics
transform.
|
void |
setup3DRendering() |
void |
sync()
Synchronize, or flush, any outstanding rendering operations to the
destination in preparation for some caller potentially reusing or
disposing a resource that has been used as the source of a recently
invoked rendering operation.
|
private static java.awt.Shape |
tmpEllipse(float x,
float y,
float w,
float h) |
(package private) static java.awt.geom.AffineTransform |
tmpJ2DTransform(BaseTransform t) |
private static java.awt.Shape |
tmpLine(float x1,
float y1,
float x2,
float y2) |
private static java.awt.Shape |
tmpQuad(float x1,
float y1,
float x2,
float y2) |
private static java.awt.geom.Rectangle2D |
tmpRect(float x,
float y,
float w,
float h) |
private static java.awt.Shape |
tmpRRect(float x,
float y,
float w,
float h,
float aw,
float ah) |
private static java.awt.Shape |
tmpShape(Shape s) |
(package private) static java.awt.Color |
toJ2DColor(Color c) |
private static java.awt.Font |
toJ2DFont(FontStrike strike) |
(package private) java.awt.Paint |
toJ2DPaint(Paint p,
java.awt.geom.Rectangle2D b) |
(package private) static java.awt.Stroke |
toJ2DStroke(BasicStroke stroke) |
static java.awt.geom.AffineTransform |
toJ2DTransform(BaseTransform t) |
(package private) static Rectangle |
toPrRect(java.awt.Rectangle r) |
(package private) static BaseTransform |
toPrTransform(java.awt.geom.AffineTransform t) |
void |
transform(BaseTransform xform) |
void |
translate(float tx,
float ty) |
void |
translate(float tx,
float ty,
float tz) |
static final java.awt.MultipleGradientPaint.CycleMethod[] LGP_CYCLE_METHODS
static final MultipleGradientPaint.CycleMethod[] RGP_CYCLE_METHODS
private static final BasicStroke DEFAULT_STROKE
private static final Paint DEFAULT_PAINT
static java.awt.geom.AffineTransform J2D_IDENTITY
private int clipRectIndex
private boolean hasPreCullingBits
private float pixelScale
private static java.util.concurrent.ConcurrentHashMap<java.awt.Font,java.lang.ref.WeakReference<java.awt.Font>> fontMap
private static volatile int cleared
private static java.awt.geom.AffineTransform tmpAT
private static java.awt.geom.Path2D tmpQuadShape
private static java.awt.geom.Rectangle2D.Float tmpRect
private static java.awt.geom.Ellipse2D tmpEllipse
private static java.awt.geom.RoundRectangle2D tmpRRect
private static java.awt.geom.Line2D tmpLine
private static J2DPrismGraphics.AdaptorShape tmpAdaptor
private boolean antialiasedShape
J2DPresentable target
java.awt.Graphics2D g2d
Affine2D transform
Rectangle clipRect
RectBounds devClipRect
RectBounds finalClipRect
Paint paint
boolean paintWasProportional
BasicStroke stroke
boolean cull
java.awt.geom.Rectangle2D nodeBounds
private NodePath renderRoot
J2DPrismGraphics(J2DPresentable target, java.awt.Graphics2D g2d)
J2DPrismGraphics(java.awt.Graphics2D g2d, int width, int height)
static java.awt.Color toJ2DColor(Color c)
static int fixFractions(float[] fractions, java.awt.Color[] colors)
java.awt.Paint toJ2DPaint(Paint p, java.awt.geom.Rectangle2D b)
static java.awt.Stroke toJ2DStroke(BasicStroke stroke)
private static java.awt.Font toJ2DFont(FontStrike strike)
public static java.awt.geom.AffineTransform toJ2DTransform(BaseTransform t)
static java.awt.geom.AffineTransform tmpJ2DTransform(BaseTransform t)
static BaseTransform toPrTransform(java.awt.geom.AffineTransform t)
static Rectangle toPrRect(java.awt.Rectangle r)
private static java.awt.Shape tmpQuad(float x1, float y1, float x2, float y2)
private static java.awt.geom.Rectangle2D tmpRect(float x, float y, float w, float h)
private static java.awt.Shape tmpEllipse(float x, float y, float w, float h)
private static java.awt.Shape tmpRRect(float x, float y, float w, float h, float aw, float ah)
private static java.awt.Shape tmpLine(float x1, float y1, float x2, float y2)
private static java.awt.Shape tmpShape(Shape s)
public RenderTarget getRenderTarget()
getRenderTarget
in interface Graphics
public Screen getAssociatedScreen()
getAssociatedScreen
in interface Graphics
public ResourceFactory getResourceFactory()
getResourceFactory
in interface Graphics
public void reset()
public Rectangle getClipRect()
getClipRect
in interface Graphics
public Rectangle getClipRectNoClone()
getClipRectNoClone
in interface Graphics
public RectBounds getFinalClipNoClone()
getFinalClipNoClone
in interface Graphics
public void setClipRect(Rectangle clipRect)
setClipRect
in interface Graphics
private java.awt.AlphaComposite getAWTComposite()
public float getExtraAlpha()
getExtraAlpha
in interface Graphics
public void setExtraAlpha(float extraAlpha)
setExtraAlpha
in interface Graphics
public CompositeMode getCompositeMode()
getCompositeMode
in interface Graphics
public void setCompositeMode(CompositeMode mode)
setCompositeMode
in interface Graphics
public BasicStroke getStroke()
public void setStroke(BasicStroke stroke)
public BaseTransform getTransformNoClone()
getTransformNoClone
in interface Graphics
public void transform(BaseTransform xform)
public void setTransform(BaseTransform xform)
setTransform
in interface Graphics
public void setTransform(double m00, double m10, double m01, double m11, double m02, double m12)
setTransform
in interface Graphics
public void clear()
Graphics
RenderTarget
with transparent pixels.
Note that this operation is affected by the current clip rectangle,
if set. To clear the entire surface, call setClipRect(null)
prior to calling clear()
.
This is equivalent to calling:
clear(Color.TRANSPARENT);
public void clear(Color color)
Graphics
RenderTarget
with the given Color
.
Note that this operation is affected by the current clip rectangle,
if set. To clear the entire surface, call setClipRect(null)
prior to calling clear()
.void clear(java.awt.Color c)
public void clearQuad(float x1, float y1, float x2, float y2)
Graphics
clear()
methods, this
method does not attempt to clear the depth buffer.void fill(java.awt.Shape shape)
public void fillRect(float x, float y, float width, float height)
public void fillRoundRect(float x, float y, float width, float height, float arcw, float arch)
fillRoundRect
in interface Graphics
public void fillEllipse(float x, float y, float width, float height)
fillEllipse
in interface Graphics
public void fillQuad(float x1, float y1, float x2, float y2)
void draw(java.awt.Shape shape)
public void drawLine(float x1, float y1, float x2, float y2)
public void drawRect(float x, float y, float width, float height)
public void drawRoundRect(float x, float y, float width, float height, float arcw, float arch)
drawRoundRect
in interface Graphics
public void drawEllipse(float x, float y, float width, float height)
drawEllipse
in interface Graphics
public void setNodeBounds(RectBounds bounds)
Graphics
setNodeBounds
in interface Graphics
bounds
- should not include node transformprivate void drawString(GlyphList gl, int start, int end, FontStrike strike, float x, float y)
public void drawString(GlyphList gl, FontStrike strike, float x, float y, Color selectColor, int start, int end)
drawString
in interface Graphics
protected void setTransformG2D(java.awt.geom.AffineTransform tx)
protected void captureTransform(java.awt.Graphics2D g2d)
public void drawMappedTextureRaw(Texture tex, float dx1, float dy1, float dx2, float dy2, float tx11, float ty11, float tx21, float ty21, float tx12, float ty12, float tx22, float ty22)
drawMappedTextureRaw
in interface Graphics
public void drawTexture(Texture tex, float x, float y, float w, float h)
drawTexture
in interface Graphics
public void drawTexture(Texture tex, float dx1, float dy1, float dx2, float dy2, float sx1, float sy1, float sx2, float sy2)
drawTexture
in interface Graphics
public void drawTexture3SliceH(Texture tex, float dx1, float dy1, float dx2, float dy2, float sx1, float sy1, float sx2, float sy2, float dh1, float dh2, float sh1, float sh2)
drawTexture3SliceH
in interface Graphics
public void drawTexture3SliceV(Texture tex, float dx1, float dy1, float dx2, float dy2, float sx1, float sy1, float sx2, float sy2, float dv1, float dv2, float sv1, float sv2)
drawTexture3SliceV
in interface Graphics
public void drawTexture9Slice(Texture tex, float dx1, float dy1, float dx2, float dy2, float sx1, float sy1, float sx2, float sy2, float dh1, float dv1, float dh2, float dv2, float sh1, float sv1, float sh2, float sv2)
drawTexture9Slice
in interface Graphics
public void drawTextureRaw(Texture tex, float dx1, float dy1, float dx2, float dy2, float tx1, float ty1, float tx2, float ty2)
drawTextureRaw
in interface Graphics
public void drawTextureVO(Texture tex, float topopacity, float botopacity, float dx1, float dy1, float dx2, float dy2, float sx1, float sy1, float sx2, float sy2)
drawTextureVO
in interface Graphics
public void drawPixelsMasked(RTTexture imgtex, RTTexture masktex, int dx, int dy, int dw, int dh, int ix, int iy, int mx, int my)
MaskTextureGraphics
The image texture is combined with the mask texture by multiplying the pixels in the image texture by the alpha in the mask texture and then the result is applied to the destination using the current compositing rule (which should likely be SrcOver in most cases).
dst.argb = (img.argb * mask.a) Composite dst.argb
drawPixelsMasked
in interface MaskTextureGraphics
imgtex
- the texture containing the source image pixelsmasktex
- the texture containing the mask pixels, only the
alpha channel is used from this texturedx
- the X coordinate of the UL destination pixeldy
- the Y coordinate of the UL destination pixeldw
- the width of the pixel regions to be combineddh
- the height of the pixel regions to be combinedix
- the X coordinate of the UL pixel in the image textureiy
- the Y coordinate of the UL pixel in the image texturemx
- the X coordinate of the UL pixel in the mask texturemy
- the Y coordinate of the UL pixel in the mask texturepublic void maskInterpolatePixels(RTTexture imgtex, RTTexture masktex, int dx, int dy, int dw, int dh, int ix, int iy, int mx, int my)
MaskTextureGraphics
The mask texture controls the contribution of source and destination pixels in the resulting output. Note that a simple multiply of the source texture by the mask texture may not produce the correct masking operation for the case where a non-SrcOver blending mode is in use. In those conditions, it is more accurate to first compute the result of blending the source into the destination and to then use this method to choose how much of the result should be taken from the results of the blending and how much should remain the original destination pixel value. Mathematically, the mask alpha controls a linear interpolation between the image and destination pixels.
dst.argb = (mask.a * img.argb) + ((1 - mask.a) * dst.argb)Note that the current composite mode is ignored during this operation.
maskInterpolatePixels
in interface MaskTextureGraphics
imgtex
- the texture containing the source image pixelsmasktex
- the texture containing the mask pixels, only the
alpha channel is used from this texturedx
- the X coordinate of the UL destination pixeldy
- the Y coordinate of the UL destination pixeldw
- the width of the pixel regions to be combineddh
- the height of the pixel regions to be combinedix
- the X coordinate of the UL pixel in the image textureiy
- the Y coordinate of the UL pixel in the image texturemx
- the X coordinate of the UL pixel in the mask texturemy
- the Y coordinate of the UL pixel in the mask textureprivate void doDrawMaskTexture(J2DRTTexture imgtex, J2DRTTexture masktex, int dx, int dy, int dw, int dh, int ix, int iy, int mx, int my, boolean srcover)
public boolean canReadBack()
canReadBack
in interface ReadbackGraphics
public RTTexture readBack(Rectangle view)
readBack
in interface ReadbackGraphics
public void releaseReadBackBuffer(RTTexture view)
releaseReadBackBuffer
in interface ReadbackGraphics
public NGCamera getCameraNoClone()
getCameraNoClone
in interface Graphics
public void setPerspectiveTransform(GeneralTransform3D transform)
setPerspectiveTransform
in interface Graphics
public boolean isDepthBuffer()
isDepthBuffer
in interface Graphics
public boolean isDepthTest()
isDepthTest
in interface Graphics
public boolean isAlphaTestShader()
isAlphaTestShader
in interface Graphics
public void setAntialiasedShape(boolean aa)
setAntialiasedShape
in interface Graphics
public boolean isAntialiasedShape()
isAntialiasedShape
in interface Graphics
public void setTransform3D(double mxx, double mxy, double mxz, double mxt, double myx, double myy, double myz, double myt, double mzx, double mzy, double mzz, double mzt)
setTransform3D
in interface Graphics
public void setDepthBuffer(boolean depthBuffer)
setDepthBuffer
in interface Graphics
public void setDepthTest(boolean depthTest)
setDepthTest
in interface Graphics
public void sync()
Graphics
Texture
disposal
or "return to texture cache pool" operation.public void translate(float tx, float ty, float tz)
public void setCulling(boolean cull)
public boolean isCulling()
public void setClipRectIndex(int index)
setClipRectIndex
in interface Graphics
public int getClipRectIndex()
getClipRectIndex
in interface Graphics
public void setHasPreCullingBits(boolean hasBits)
setHasPreCullingBits
in interface Graphics
public boolean hasPreCullingBits()
hasPreCullingBits
in interface Graphics
public void setRenderRoot(NodePath root)
setRenderRoot
in interface Graphics
public NodePath getRenderRoot()
getRenderRoot
in interface Graphics
public void setState3D(boolean flag)
setState3D
in interface Graphics
public void setup3DRendering()
setup3DRendering
in interface Graphics
public void setPixelScaleFactor(float pixelScale)
setPixelScaleFactor
in interface Graphics
public float getPixelScaleFactor()
getPixelScaleFactor
in interface Graphics
public void blit(RTTexture srcTex, RTTexture dstTex, int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1)
public void setLights(NGLightBase[] lights)
public NGLightBase[] getLights()