public class NGRegion extends NGGroup
NGNode.DirtyFlag, NGNode.RenderRootResult
Modifier and Type | Field and Description |
---|---|
private Background |
background
The background to use for drawing.
|
private Insets |
backgroundInsets
The combined insets of all the backgrounds.
|
private Border |
border
The border to use for drawing.
|
private static int |
CACHE_SLICE_H
Indicates the cached image can be sliced horizontally.
|
private static int |
CACHE_SLICE_V
Indicates the cached image can be sliced vertically.
|
private java.lang.Integer |
cacheKey
Is the key into the image cache that identifies the required background
for the region.
|
private int |
cacheMode
Determined when a background is set on the region, this flag indicates whether this
background can be cached.
|
private boolean |
cacheShape
Whether we should attempt to use region caching for a region with a shape.
|
private boolean |
centerShape
Whether we should center the shape within the bounds of the region.
|
private float |
height
The width and height of the region.
|
private static java.util.WeakHashMap<Screen,RegionImageCache> |
imageCacheMap
Screen to RegionImageCache mapping.
|
private NGShape |
ngShape |
private static Offset |
nopEffect |
private EffectFilter |
nopEffectFilter |
private java.util.List<CornerRadii> |
normalizedFillCorners
The normalized list of CornerRadii have been precomputed at the FX layer to
properly account for percentages, insets and radii scaling to prevent
the radii from overflowing the dimensions of the region.
|
private java.util.List<CornerRadii> |
normalizedStrokeCorners |
private float |
opaqueBottom
A cached set of the opaque insets as given to us during synchronization.
|
private float |
opaqueLeft
A cached set of the opaque insets as given to us during synchronization.
|
private float |
opaqueRight
A cached set of the opaque insets as given to us during synchronization.
|
private float |
opaqueTop
A cached set of the opaque insets as given to us during synchronization.
|
private boolean |
scaleShape
Whether we should scale the shape to match the bounds of the region.
|
private static Affine2D |
SCRATCH_AFFINE
This scratch transform is used when transforming shapes.
|
private Shape |
shape
The shape of the region.
|
private static Rectangle |
TEMP_RECT
Temporary rect for general use.
|
private float |
width
The width and height of the region.
|
childDirty, contentBounds, cullingBits, dirty, DIRTY_CHILDREN_ACCUMULATED_THRESHOLD, DIRTY_REGION_CONTAINS_NODE_BOUNDS, DIRTY_REGION_CONTAINS_OR_INTERSECTS_NODE_BOUNDS, DIRTY_REGION_INTERSECTS_NODE_BOUNDS, dirtyBounds, dirtyChildrenAccumulated, TEMP_TRANSFORM, transformedBounds
Constructor and Description |
---|
NGRegion() |
Modifier and Type | Method and Description |
---|---|
void |
clearDirtyTree()
When cleaning the dirty tree, we also have to keep in mind
the NGShape used by the NGRegion
|
protected RectBounds |
computeOpaqueRegion(RectBounds opaqueRegion)
The opaque region of an NGRegion takes into account the opaque insets
specified by the Region during synchronization.
|
protected NGNode.RenderRootResult |
computeRenderRoot(NodePath path,
RectBounds dirtyRegion,
int cullingIndex,
BaseTransform tx,
GeneralTransform3D pvTx)
*
Culling Related Methods *
*
|
private Path2D |
createPath(float width,
float height,
float t,
float l,
float bo,
float ro,
CornerRadii radii)
Creates a rounded rectangle path with our width and height, different corner radii,
offset with given offsets
|
private Path2D[] |
createPaths(float t,
float l,
float bo,
float ro,
CornerRadii radii)
Creates a rounded rectangle path with our width and height, different corner radii, offset with given offsets.
|
private BasicStroke |
createStroke(BorderStrokeStyle sb,
double strokeWidth,
double lineLength,
boolean forceCentered)
Creates a Prism BasicStroke based on the stroke style, width, and line length.
|
private void |
doCorner(Path2D path,
CornerRadii radii,
float x,
float y,
int quadrant,
float tstart,
float tend,
boolean newPath)
Inserts geometry into the specified Path2D object for the specified
corner of a general rounded rectangle.
|
(package private) Background |
getBackground() |
(package private) Border |
getBorder() |
private java.lang.Integer |
getCacheKey(int w,
int h) |
(package private) float |
getHeight() |
private RegionImageCache |
getImageCache(Graphics g)
*
Implementations of methods defined in the parent classes, with the *
exception of rendering methods.
|
private CornerRadii |
getNormalizedFillRadii(int index)
Returns the normalized (non-percentage, non-overflowing) radii for the
selected index into the BackgroundFill objects.
|
private CornerRadii |
getNormalizedStrokeRadii(int index)
Returns the normalized (non-percentage, non-overflowing) radii for the
selected index into the BorderStroke objects.
|
(package private) static Paint |
getPlatformPaint(Paint paint)
Simple Helper Function for cleanup.
|
(package private) float |
getWidth() |
protected boolean |
hasOpaqueRegion()
Called only on NGNode subclasses which override
NGNode.supportsOpaqueRegions() to return
true, this method will return whether or not this NGNode is in a state where it has
an opaque region to actually return. |
protected boolean |
hasOverlappingContents() |
protected boolean |
hasVisuals()
Marks if the node has some visuals and that the bounds change
should be taken into account when using the dirty region.
|
void |
imagesUpdated()
Called by Region whenever an image that was being loaded in the background has
finished loading.
|
private Path2D |
makeRoundedEdge(CornerRadii radii,
float x0,
float y0,
float x1,
float y1,
int quadrant) |
private void |
paintTiles(Graphics g,
Image img,
BackgroundRepeat repeatX,
BackgroundRepeat repeatY,
Side horizontalSide,
Side verticalSide,
float regionX,
float regionY,
float regionWidth,
float regionHeight,
int srcX,
int srcY,
int srcW,
int srcH,
float tileX,
float tileY,
float tileWidth,
float tileHeight)
Paints a subsection (srcX,srcY,srcW,srcH) of an image tiled or stretched to fill the destination area
(regionWidth,regionHeight).
|
private void |
paintTiles(Graphics g,
Image img,
BorderRepeat repeatX,
BorderRepeat repeatY,
Side horizontalSide,
Side verticalSide,
float regionX,
float regionY,
float regionWidth,
float regionHeight,
int srcX,
int srcY,
int srcW,
int srcH,
float tileX,
float tileY,
float tileWidth,
float tileHeight) |
private void |
renderAsRectangle(Graphics g)
*
Drawing a region background and borders when the Region has no defined *
shape, and is therefore treated as a rounded rectangle.
|
private void |
renderAsShape(Graphics g)
*
Drawing a region background and borders when the Region has been *
specified to have a shape.
|
private void |
renderBackgroundRectangle(Graphics g) |
private void |
renderBackgroundRectangleFromCache(Graphics g,
RTTexture cached,
Rectangle rect,
int textureWidth,
int textureHeight,
double topInset,
double rightInset,
double bottomInset,
double leftInset,
int outsetsTop,
int outsetsRight,
int outsetsBottom,
int outsetsLeft) |
private void |
renderBackgroundRectanglesDirectly(Graphics g,
float width,
float height) |
private void |
renderBackgroundShape(Graphics g) |
private void |
renderBorderRectangle(Graphics g) |
protected void |
renderContent(Graphics g)
*
Region drawing.
|
private Shape |
resizeShape(float topOffset,
float rightOffset,
float bottomOffset,
float leftOffset)
Create a bigger or smaller version of shape.
|
private int |
roundUp(double d) |
private void |
setBorderStyle(Graphics g,
BorderStroke sb,
double length,
boolean forceCentered) |
void |
setOpaqueInsets(float top,
float right,
float bottom,
float left)
Called by the Region whenever it knows that the opaque insets have changed.
|
void |
setSize(float width,
float height)
Called by the Region whenever the width or height of the region has changed.
|
private int |
sliceSize(boolean isPercent,
double sliceSize,
float objSize,
float scale) |
protected boolean |
supportsOpaqueRegions()
Gets whether this NGNode supports opaque regions at all.
|
void |
updateBackground(Background b)
Called by the Region when the Background has changed.
|
private void |
updateBackgroundInsets()
Visits each of the background fills and takes their radii into account to determine the insets.
|
void |
updateBorder(Border b)
Called by the Region when the Border is changed.
|
void |
updateFillCorners(java.util.List<CornerRadii> normalizedFillCorners)
Called by the Region when any parameters are changed.
|
void |
updateShape(java.lang.Object shape,
boolean scaleShape,
boolean positionShape,
boolean cacheShape)
Called by the Region during synchronization.
|
void |
updateStrokeCorners(java.util.List<CornerRadii> normalizedStrokeCorners)
Called by the Region when any parameters are changed.
|
private int |
widthSize(boolean isPercent,
double sliceSize,
float objSize) |
add, addToRemoved, clear, clearDirty, clearFrom, drawDirtyOpts, getChildren, getRemovedChildren, isEmpty, markCullRegions, needsBlending, remove, remove, renderForcedContent, setBlendMode
accumulateDirtyRegions, accumulateGroupDirtyRegion, accumulateNodeDirtyRegion, applyClip, applyEffect, applyTransform, checkBoundsInQuad, clearPainted, computeNodeRenderRoot, computePadding, doPreCulling, doRender, effectChanged, geometryChanged, getCacheFilter, getClipNode, getClippedBounds, getCompleteBounds, getContentBounds, getEffect, getEffectBounds, getEffectFilter, getFilterContext, getName, getNodeBlendMode, getOpacity, getOpaqueRegion, getParent, getRenderRoot, getTransform, invalidateCache, invalidateCacheByTranslation, invalidateOpaqueRegion, isClean, isContentBounds2D, isDepthTest, isOpaqueRegionInvalid, isReadbackSupported, isRectClip, isShape3D, isVisible, markDirty, markTreeDirty, markTreeDirtyNoIncrement, printDirtyOpts, release, render, renderClip, renderEffect, renderForClip, setCachedAsBitmap, setClipNode, setContentBounds, setDepthTest, setEffect, setName, setNodeBlendMode, setOpacity, setParent, setTransformedBounds, setTransformMatrix, setVisible, toString, visualsChanged
private static final Affine2D SCRATCH_AFFINE
private static final Rectangle TEMP_RECT
private static java.util.WeakHashMap<Screen,RegionImageCache> imageCacheMap
private static final int CACHE_SLICE_V
private static final int CACHE_SLICE_H
private Background background
private Insets backgroundInsets
private Border border
private java.util.List<CornerRadii> normalizedFillCorners
private java.util.List<CornerRadii> normalizedStrokeCorners
private Shape shape
private NGShape ngShape
private boolean scaleShape
private boolean centerShape
private boolean cacheShape
private float opaqueTop
private float opaqueRight
private float opaqueBottom
private float opaqueLeft
private float width
private float height
private int cacheMode
private java.lang.Integer cacheKey
private static final Offset nopEffect
private EffectFilter nopEffectFilter
public void updateShape(java.lang.Object shape, boolean scaleShape, boolean positionShape, boolean cacheShape)
shape
- The shape, may be null.scaleShape
- whether to scale the shapepositionShape
- whether to center the shapepublic void setSize(float width, float height)
width
- The width of the region, not including insets or outsetsheight
- The height of the region, not including insets or outsetspublic void imagesUpdated()
public void updateBorder(Border b)
b
- Border, of type javafx.scene.layout.Borderpublic void updateStrokeCorners(java.util.List<CornerRadii> normalizedStrokeCorners)
normalizedStrokeCorners
- a precomputed copy of the radii in the
BorderStroke objects that are not percentages and do not overflowprivate CornerRadii getNormalizedStrokeRadii(int index)
index
- the index of the BorderStroke object being processedpublic void updateBackground(Background b)
b
- Background, of type javafx.scene.layout.Background. Can be null.public void updateFillCorners(java.util.List<CornerRadii> normalizedFillCorners)
normalizedStrokeCorners
- a precomputed copy of the radii in the
BackgroundFill objects that are not percentages and do not overflowprivate CornerRadii getNormalizedFillRadii(int index)
index
- the index of the BackgroundFill object being processedpublic void setOpaqueInsets(float top, float right, float bottom, float left)
top
- The top, if NaN then there is no opaque inset at allright
- The right, must not be NaN or Infinity, etc.bottom
- The bottom, must not be NaN or Infinity, etc.left
- The left, must not be NaN or Infinity, etc.public void clearDirtyTree()
clearDirtyTree
in class NGNode
private RegionImageCache getImageCache(Graphics g)
private java.lang.Integer getCacheKey(int w, int h)
protected boolean supportsOpaqueRegions()
NGNode
supportsOpaqueRegions
in class NGNode
protected boolean hasOpaqueRegion()
NGNode
NGNode.supportsOpaqueRegions()
to return
true, this method will return whether or not this NGNode is in a state where it has
an opaque region to actually return. If this method returns true, a subsequent call to
NGNode.computeOpaqueRegion(com.sun.javafx.geom.RectBounds)
must return
a non-null result. Any state used in the computation of this method, when it changes, must
result in a call to NGNode.invalidateOpaqueRegion()
.hasOpaqueRegion
in class NGNode
protected RectBounds computeOpaqueRegion(RectBounds opaqueRegion)
computeOpaqueRegion
in class NGNode
opaqueRegion
- protected NGNode.RenderRootResult computeRenderRoot(NodePath path, RectBounds dirtyRegion, int cullingIndex, BaseTransform tx, GeneralTransform3D pvTx)
NGGroup
computeRenderRoot
in class NGGroup
path
- the NodePath to populate with the path to the render root. Cannot be null.dirtyRegion
- the current dirty region. Cannot be null.cullingIndex
- index of culling informationtx
- current transform. Cannot be null.pvTx
- current perspective transform. Cannot be null.protected boolean hasVisuals()
NGNode
hasVisuals
in class NGGroup
protected boolean hasOverlappingContents()
hasOverlappingContents
in class NGGroup
protected void renderContent(Graphics g)
renderContent
in class NGGroup
private void renderAsShape(Graphics g)
private void renderBackgroundShape(Graphics g)
private void renderAsRectangle(Graphics g)
private void renderBackgroundRectangle(Graphics g)
private void renderBackgroundRectangleFromCache(Graphics g, RTTexture cached, Rectangle rect, int textureWidth, int textureHeight, double topInset, double rightInset, double bottomInset, double leftInset, int outsetsTop, int outsetsRight, int outsetsBottom, int outsetsLeft)
private void renderBackgroundRectanglesDirectly(Graphics g, float width, float height)
private void renderBorderRectangle(Graphics g)
private void updateBackgroundInsets()
private int widthSize(boolean isPercent, double sliceSize, float objSize)
private int sliceSize(boolean isPercent, double sliceSize, float objSize, float scale)
private int roundUp(double d)
private BasicStroke createStroke(BorderStrokeStyle sb, double strokeWidth, double lineLength, boolean forceCentered)
sb
- The BorderStrokeStylestrokeWidth
- The width of the stroke we're going to drawlineLength
- The total linear length of this stroke. This is needed for
handling "dashed" and "dotted" cases, otherwise, it is ignored.forceCentered
- When this is set to true, the stroke is always centered.
The "outer/inner" stroking has to be done by moving the lineprivate void setBorderStyle(Graphics g, BorderStroke sb, double length, boolean forceCentered)
private void doCorner(Path2D path, CornerRadii radii, float x, float y, int quadrant, float tstart, float tend, boolean newPath)
path
- radii
- x
- y
- quadrant
- tstart
- tend
- newPath
- private Path2D createPath(float width, float height, float t, float l, float bo, float ro, CornerRadii radii)
private Path2D makeRoundedEdge(CornerRadii radii, float x0, float y0, float x1, float y1, int quadrant)
private Path2D[] createPaths(float t, float l, float bo, float ro, CornerRadii radii)
private Shape resizeShape(float topOffset, float rightOffset, float bottomOffset, float leftOffset)
private void paintTiles(Graphics g, Image img, BorderRepeat repeatX, BorderRepeat repeatY, Side horizontalSide, Side verticalSide, float regionX, float regionY, float regionWidth, float regionHeight, int srcX, int srcY, int srcW, int srcH, float tileX, float tileY, float tileWidth, float tileHeight)
private void paintTiles(Graphics g, Image img, BackgroundRepeat repeatX, BackgroundRepeat repeatY, Side horizontalSide, Side verticalSide, float regionX, float regionY, float regionWidth, float regionHeight, int srcX, int srcY, int srcW, int srcH, float tileX, float tileY, float tileWidth, float tileHeight)
g
- The graphics context to draw image intoimg
- The image to drawrepeatX
- The horizontal repeat style for filling the area with the src imagerepeatY
- The vertical repeat style for filling the area with the src imagehorizontalSide
- The left or rightverticalSide
- The top or bottomregionX
- The top left corner X of the area of the graphics context to fill with our imgregionY
- The top left corner Y of the area of the graphics context to fill with our imgregionWidth
- The width of the area of the graphics context to fill with our imgregionHeight
- The height of the area of the graphics context to fill with our imgsrcX
- The top left corner X of the area of the image to paint withsrcY
- The top left corner Y of the area of the image to paint withsrcW
- The width of the area of the image to paint with, -1 to use the original image widthsrcH
- The height of the area of the image to paint with, -1 to use the original image heighttileX
- The top left corner X of the area of the first tile within the destination rectangle. In some
cases we begin by drawing the center tile, and working to the left & right (for example), so
this value is not always the same as regionX.tileY
- The top left corner Y of the area of the first tile within the destination rectangletileWidth
- The width of the area of the first tile within the destination rectangle, if <= 0, then the use intrinsic valuetileHeight
- The height of the area of the first tile within the destination rectangle, if <= 0, then the use intrinsic valuefinal Border getBorder()
final Background getBackground()
final float getWidth()
final float getHeight()