Top Description Fields Constructors Methods
com.sun.javafx.sg.prism

public Class NGRegion

extends NGGroup
Class Inheritance
Imports
javafx.geometry.Insets, .Side, javafx.scene.layout.Background, .BackgroundFill, .BackgroundImage, .BackgroundPosition, .BackgroundRepeat, .BackgroundSize, .Border, .BorderImage, .BorderRepeat, .BorderStroke, .BorderStrokeStyle, .BorderWidths, .CornerRadii, javafx.scene.paint.Color, .LinearGradient, javafx.scene.shape.StrokeLineCap, .StrokeLineJoin, .StrokeType, java.util.Collections, .List, .WeakHashMap, com.sun.glass.ui.Screen, com.sun.javafx.PlatformUtil, com.sun.javafx.application.PlatformImpl, com.sun.javafx.geom.Path2D, .RectBounds, .Rectangle, .Shape, com.sun.javafx.geom.transform.Affine2D, .BaseTransform, .GeneralTransform3D, com.sun.javafx.logging.PulseLogger, com.sun.javafx.scene.NodeHelper, com.sun.javafx.tk.Toolkit, com.sun.prism.BasicStroke, .Graphics, .Image, .RTTexture, .Texture, .PrinterGraphics, com.sun.prism.impl.PrismSettings, com.sun.prism.paint.ImagePattern, .Paint, com.sun.scenario.effect.Offset

Implementation of the Region peer. This behaves like an NGGroup, in that it has children, but like a leaf node, in that it also draws itself if it has a Background or Border which contains non-transparent fills / strokes / images.

Field Summary

Modifier and TypeField 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 final int
CACHE_SLICE_H

Indicates the cached image can be sliced horizontally.

private static final int
CACHE_SLICE_V

Indicates the cached image can be sliced vertically.

private 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 WeakHashMap<Screen, RegionImageCache>
imageCacheMap

Screen to RegionImageCache mapping.

private NGShape
private static final Offset
private EffectFilter
private 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 List<CornerRadii>
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 final Affine2D
SCRATCH_AFFINE

This scratch transform is used when transforming shapes.

private Shape
shape

The shape of the region.

private static final Rectangle
TEMP_RECT

Temporary rect for general use.

private float
width

The width and height of the region.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
clearDirty()

Overrides com.sun.javafx.sg.prism.NGGroup.clearDirty.

When cleaning the dirty flag, we also have to keep in mind the NGShape used by the NGRegion

protected RectBounds
computeOpaqueRegion(RectBounds opaqueRegion)

Overrides com.sun.javafx.sg.prism.NGNode.computeOpaqueRegion.

The opaque region of an NGRegion takes into account the opaque insets specified by the Region during synchronization.

protected NGNode.RenderRootResult
computeRenderRoot(NodePath
the NodePath to populate with the path to the render root. Cannot be null.
path
,
RectBounds
the current dirty region. Cannot be null.
dirtyRegion
,
int
index of culling information
cullingIndex
,
BaseTransform
current transform. Cannot be null.
tx
,
GeneralTransform3D
current perspective transform. Cannot be null.
pvTx
)

Overrides com.sun.javafx.sg.prism.NGGroup.computeRenderRoot.

* 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

Returns:

A prism BasicStroke
createStroke
(BorderStrokeStyle
The BorderStrokeStyle
sb
,
double
The width of the stroke we're going to draw
strokeWidth
,
double
The total linear length of this stroke. This is needed for handling "dashed" and "dotted" cases, otherwise, it is ignored.
lineLength
,
boolean
When this is set to true, the stroke is always centered. The "outer/inner" stroking has to be done by moving the line
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.

pack-priv final Background
pack-priv final Border
private Integer
getCacheKey(int w, int h)

pack-priv final float
private RegionImageCache
getImageCache(final Graphics g)

* Implementations of methods defined in the parent classes, with the * exception of rendering methods.

private CornerRadii

Returns:

the normalized radii for the indicated BackgroundFill object
getNormalizedFillRadii
(int
the index of the BackgroundFill object being processed
index
)

Returns the normalized (non-percentage, non-overflowing) radii for the selected index into the BackgroundFill objects.

private CornerRadii

Returns:

the normalized radii for the indicated BorderStroke object
getNormalizedStrokeRadii
(int
the index of the BorderStroke object being processed
index
)

Returns the normalized (non-percentage, non-overflowing) radii for the selected index into the BorderStroke objects.

pack-priv static Paint
getPlatformPaint(Paint paint)

Simple Helper Function for cleanup.

pack-priv final float
protected boolean
hasOpaqueRegion()

Overrides com.sun.javafx.sg.prism.NGNode.hasOpaqueRegion.

Called only on NGNode subclasses which override 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
protected boolean
hasVisuals()

Overrides com.sun.javafx.sg.prism.NGGroup.hasVisuals.

Marks if the node has some visuals and that the bounds change should be taken into account when using the dirty region.

public 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, BorderRepeat repeatX, BorderRepeat repeatY, Side horizontalSide, Side verticalSide, final float regionX, final float regionY, final float regionWidth, final float regionHeight, final int srcX, final int srcY, final int srcW, final int srcH, float tileX, float tileY, float tileWidth, float tileHeight)

private void
paintTiles(Graphics
The graphics context to draw image into
g
,
Image
The image to draw
img
,
BackgroundRepeat
The horizontal repeat style for filling the area with the src image
repeatX
,
BackgroundRepeat
The vertical repeat style for filling the area with the src image
repeatY
,
Side
The left or right
horizontalSide
,
Side
The top or bottom
verticalSide
,
final float
The top left corner X of the area of the graphics context to fill with our img
regionX
,
final float
The top left corner Y of the area of the graphics context to fill with our img
regionY
,
final float
The width of the area of the graphics context to fill with our img
regionWidth
,
final float
The height of the area of the graphics context to fill with our img
regionHeight
,
final int
The top left corner X of the area of the image to paint with
srcX
,
final int
The top left corner Y of the area of the image to paint with
srcY
,
final int
The width of the area of the image to paint with, -1 to use the original image width
srcW
,
final int
The height of the area of the image to paint with, -1 to use the original image height
srcH
,
float
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.
tileX
,
float
The top left corner Y of the area of the first tile within the destination rectangle
tileY
,
float
The width of the area of the first tile within the destination rectangle, if <= 0, then the use intrinsic value
tileWidth
,
float
The height of the area of the first tile within the destination rectangle, if <= 0, then the use intrinsic value
tileHeight
)

Paints a subsection (srcX,srcY,srcW,srcH) of an image tiled or stretched to fill the destination area (regionWidth,regionHeight).

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
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
private void
protected void
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)

public void
setOpaqueInsets(float
The top, if NaN then there is no opaque inset at all
top
,
float
The right, must not be NaN or Infinity, etc.
right
,
float
The bottom, must not be NaN or Infinity, etc.
bottom
,
float
The left, must not be NaN or Infinity, etc.
left
)

Called by the Region whenever it knows that the opaque insets have changed.

public void
setSize(float
The width of the region, not including insets or outsets
width
,
float
The height of the region, not including insets or outsets
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()

Overrides com.sun.javafx.sg.prism.NGNode.supportsOpaqueRegions.

Gets whether this NGNode supports opaque regions at all.

public void
updateBackground(Background
Background, of type javafx.scene.layout.Background. Can be null.
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.

public void
updateBorder(Border
Border, of type javafx.scene.layout.Border
b
)

Called by the Region when the Border is changed.

public void
updateFillCorners(List<CornerRadii> normalizedFillCorners)

Called by the Region when any parameters are changed.

public void
updateShape(Object
The shape, may be null.
shape
,
boolean
whether to scale the shape
scaleShape
,
boolean
whether to center the shape
positionShape
,
boolean cacheShape)

Called by the Region during synchronization.

public void
updateStrokeCorners(List<CornerRadii>
a precomputed copy of the radii in the BorderStroke objects that are not percentages and do not overflow
normalizedStrokeCorners
)

Called by the Region when any parameters are changed.

private int
widthSize(boolean isPercent, double sliceSize, float objSize)

Inherited from com.sun.javafx.sg.prism.NGGroup:
addaddToRemovedclearclearFromdrawDirtyOptsgetChildrengetRemovedChildrenisEmptymarkCullRegionsneedsBlendingremoveremoverenderForcedContentsetBlendModesetViewOrderChildren

Field Detail

backgroundback to summary
private Background background

The background to use for drawing. Since this is an immutable object, I can simply refer to its fields / methods directly when rendering. I will make sure this is not ever null at the time that we do the sync, so that the code in this class can assume non-null.

backgroundInsetsback to summary
private Insets backgroundInsets

The combined insets of all the backgrounds. As of right now, Background doesn't store this information itself, although it probably could (and probably should).

borderback to summary
private Border border

The border to use for drawing. Similar to background, this is not-null and immutable.

CACHE_SLICE_Hback to summary
private static final int CACHE_SLICE_H

Indicates the cached image can be sliced horizontally.

CACHE_SLICE_Vback to summary
private static final int CACHE_SLICE_V

Indicates the cached image can be sliced vertically.

cacheKeyback to summary
private Integer cacheKey

Is the key into the image cache that identifies the required background for the region.

cacheModeback to summary
private int cacheMode

Determined when a background is set on the region, this flag indicates whether this background can be cached. As of this time, the only backgrounds which can be cached are those where there are only solid fills or linear gradients.

cacheShapeback to summary
private boolean cacheShape

Whether we should attempt to use region caching for a region with a shape.

centerShapeback to summary
private boolean centerShape

Whether we should center the shape within the bounds of the region. Only applies if the shape is not null.

heightback to summary
private float height

The width and height of the region.

imageCacheMapback to summary
private static WeakHashMap<Screen, RegionImageCache> imageCacheMap

Screen to RegionImageCache mapping. This mapping is required as textures are only valid in graphics context used to create them (relies on a one to one mapping between Screen and GraphicsContext).

ngShapeback to summary
private NGShape ngShape
nopEffectback to summary
private static final Offset nopEffect
nopEffectFilterback to summary
private EffectFilter nopEffectFilter
normalizedFillCornersback to summary
private 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. The List objects are shared with the FX layer and are therefore unmodifiable. If the normalized list is null then it means that all of the raw radii in the list were already absolute and non-overflowing and so the originals can be used from the arrays of strokes and fills.

normalizedStrokeCornersback to summary
private List<CornerRadii> normalizedStrokeCorners
opaqueBottomback to summary
private float opaqueBottom

A cached set of the opaque insets as given to us during synchronization. We hold on to this so that we can determine the opaque insets in the computeOpaqueRegion method.

opaqueLeftback to summary
private float opaqueLeft

A cached set of the opaque insets as given to us during synchronization. We hold on to this so that we can determine the opaque insets in the computeOpaqueRegion method.

opaqueRightback to summary
private float opaqueRight

A cached set of the opaque insets as given to us during synchronization. We hold on to this so that we can determine the opaque insets in the computeOpaqueRegion method.

opaqueTopback to summary
private float opaqueTop

A cached set of the opaque insets as given to us during synchronization. We hold on to this so that we can determine the opaque insets in the computeOpaqueRegion method.

scaleShapeback to summary
private boolean scaleShape

Whether we should scale the shape to match the bounds of the region. Only applies if the shape is not null.

SCRATCH_AFFINEback to summary
private static final Affine2D SCRATCH_AFFINE

This scratch transform is used when transforming shapes. Because this is a static variable, it is only intended to be used from a single thread, the render thread in this case.

shapeback to summary
private Shape shape

The shape of the region. Usually this will be null (except for things like check box checks, scroll bar down arrows / up arrows, etc). If this is not null, it determines the shape of the region to draw. If it is null, then the assumed shape of the region is one of a rounded rectangle. This shape is a com.sun.javafx.geom.Shape, and is not touched by the FX scene graph except during synchronization, so it is safe to access on the render thread.

TEMP_RECTback to summary
private static final Rectangle TEMP_RECT

Temporary rect for general use. Because this is a static variable, it is only intended to be used from a single thread, the render thread in this case.

widthback to summary
private float width

The width and height of the region.

Constructor Detail

NGRegionback to summary
public NGRegion()

Method Detail

clearDirtyback to summary
public void clearDirty()

Overrides com.sun.javafx.sg.prism.NGGroup.clearDirty.

When cleaning the dirty flag, we also have to keep in mind the NGShape used by the NGRegion

Annotations
@Override
computeOpaqueRegionback to summary
protected RectBounds computeOpaqueRegion(RectBounds opaqueRegion)

Overrides com.sun.javafx.sg.prism.NGNode.computeOpaqueRegion.

The opaque region of an NGRegion takes into account the opaque insets specified by the Region during synchronization. It also takes into account the clip and the effect.

Annotations
@Override
computeRenderRootback to summary
protected NGNode.RenderRootResult computeRenderRoot(NodePath path, RectBounds dirtyRegion, int cullingIndex, BaseTransform tx, GeneralTransform3D pvTx)

Overrides com.sun.javafx.sg.prism.NGGroup.computeRenderRoot.

Doc from com.sun.javafx.sg.prism.NGGroup.computeRenderRoot.

* Culling Related Methods * *

Parameters
path:NodePath

Doc from com.sun.javafx.sg.prism.NGNode.computeRenderRoot.

the NodePath to populate with the path to the render root. Cannot be null.

dirtyRegion:RectBounds

Doc from com.sun.javafx.sg.prism.NGNode.computeRenderRoot.

the current dirty region. Cannot be null.

cullingIndex:int

Doc from com.sun.javafx.sg.prism.NGNode.computeRenderRoot.

index of culling information

tx:BaseTransform

Doc from com.sun.javafx.sg.prism.NGNode.computeRenderRoot.

current transform. Cannot be null.

pvTx:GeneralTransform3D

Doc from com.sun.javafx.sg.prism.NGNode.computeRenderRoot.

current perspective transform. Cannot be null.

Returns:NGNode.RenderRootResult

Doc from com.sun.javafx.sg.prism.NGNode.computeRenderRoot.

The result of visiting this node.

Annotations
@Override
createPathback to summary
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

createPathsback to summary
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. Each side as a separate path. The sides are returned in the CSS standard order of top, right, bottom, left.

createStrokeback to summary
private BasicStroke createStroke(BorderStrokeStyle sb, double strokeWidth, double lineLength, boolean forceCentered)

Creates a Prism BasicStroke based on the stroke style, width, and line length.

Parameters
sb:BorderStrokeStyle

The BorderStrokeStyle

strokeWidth:double

The width of the stroke we're going to draw

lineLength:double

The total linear length of this stroke. This is needed for handling "dashed" and "dotted" cases, otherwise, it is ignored.

forceCentered:boolean

When this is set to true, the stroke is always centered. The "outer/inner" stroking has to be done by moving the line

Returns:BasicStroke

A prism BasicStroke

doCornerback to summary
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. The corner drawn is specified by the quadrant parameter, whose least significant 2 bits specify the following corners and the associated start, corner, and end points (which are always drawn clockwise): 0 - Top Left: X + 0 , Y + VR, X, Y, X + HR, Y + 0 1 - Top Right: X - HR, Y + 0 , X, Y, X + 0 , Y + VR 2 - Bottom Right: X + 0 , Y - VR, X, Y, X - HR, Y + 0 3 - Bottom Left: X + HR, Y + 0 , X, Y, X + 0 , Y - VR The associated horizontal and vertical radii are fetched from the indicated CornerRadii object which is assumed to be absolute (not percentage based) and already scaled so that no pair of radii are larger than the indicated width/height of the rounded rectangle being expressed. The tstart and tend parameters specify what portion of the rounded corner should be drawn with 0f => 1f being the entire rounded corner. The newPath parameter indicates whether the path should reach the starting point with a moveTo() command or a lineTo() segment.

getBackgroundback to summary
pack-priv final Background getBackground()
getBorderback to summary
pack-priv final Border getBorder()
getCacheKeyback to summary
private Integer getCacheKey(int w, int h)
getHeightback to summary
pack-priv final float getHeight()
getImageCacheback to summary
private RegionImageCache getImageCache(final Graphics g)

* Implementations of methods defined in the parent classes, with the * exception of rendering methods. * *

getNormalizedFillRadiiback to summary
private CornerRadii getNormalizedFillRadii(int index)

Returns the normalized (non-percentage, non-overflowing) radii for the selected index into the BackgroundFill objects. If a List was synchronized from the Region object, the value from that List, otherwise the raw radii are fetched from the indicated BackgroundFill object.

Parameters
index:int

the index of the BackgroundFill object being processed

Returns:CornerRadii

the normalized radii for the indicated BackgroundFill object

getNormalizedStrokeRadiiback to summary
private CornerRadii getNormalizedStrokeRadii(int index)

Returns the normalized (non-percentage, non-overflowing) radii for the selected index into the BorderStroke objects. If a List was synchronized from the Region object, the value from that List, otherwise the raw radii are fetched from the indicated BorderStroke object.

Parameters
index:int

the index of the BorderStroke object being processed

Returns:CornerRadii

the normalized radii for the indicated BorderStroke object

getPlatformPaintback to summary
pack-priv static Paint getPlatformPaint(Paint paint)

Simple Helper Function for cleanup.

getWidthback to summary
pack-priv final float getWidth()
hasOpaqueRegionback to summary
protected boolean hasOpaqueRegion()

Overrides com.sun.javafx.sg.prism.NGNode.hasOpaqueRegion.

Doc from com.sun.javafx.sg.prism.NGNode.hasOpaqueRegion.

Called only on NGNode subclasses which override 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 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 invalidateOpaqueRegion().

Returns:boolean

Whether this NGNode currently has an opaque region.

Annotations
@Override
hasOverlappingContentsback to summary
protected boolean hasOverlappingContents()

Overrides com.sun.javafx.sg.prism.NGGroup.hasOverlappingContents.

Annotations
@Override
hasVisualsback to summary
protected boolean hasVisuals()

Overrides com.sun.javafx.sg.prism.NGGroup.hasVisuals.

Doc from com.sun.javafx.sg.prism.NGNode.hasVisuals.

Marks if the node has some visuals and that the bounds change should be taken into account when using the dirty region. This will be false for NGGroup (but not for NGRegion)

Returns:boolean

true if the node has some visuals

Annotations
@Override
imagesUpdatedback to summary
public void imagesUpdated()

Called by Region whenever an image that was being loaded in the background has finished loading. Nothing changes in terms of metrics or sizes or caches, but we do need to repaint everything.

makeRoundedEdgeback to summary
private Path2D makeRoundedEdge(CornerRadii radii, float x0, float y0, float x1, float y1, int quadrant)
paintTilesback to summary
private void paintTiles(Graphics g, Image img, BorderRepeat repeatX, BorderRepeat repeatY, Side horizontalSide, Side verticalSide, final float regionX, final float regionY, final float regionWidth, final float regionHeight, final int srcX, final int srcY, final int srcW, final int srcH, float tileX, float tileY, float tileWidth, float tileHeight)
paintTilesback to summary
private void paintTiles(Graphics g, Image img, BackgroundRepeat repeatX, BackgroundRepeat repeatY, Side horizontalSide, Side verticalSide, final float regionX, final float regionY, final float regionWidth, final float regionHeight, final int srcX, final int srcY, final int srcW, final 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). It is assumed we are pre-transformed to the correct origin, top left or destination area. When tiling the first tile is positioned within the rectangle (tileX,tileY,tileW,tileH). Drawing two images next to each other on a non-pixel boundary can not be done simply so we use integers here. This assumption may be wrong when drawing though a scale transform.

Parameters
g:Graphics

The graphics context to draw image into

img:Image

The image to draw

repeatX:BackgroundRepeat

The horizontal repeat style for filling the area with the src image

repeatY:BackgroundRepeat

The vertical repeat style for filling the area with the src image

horizontalSide:Side

The left or right

verticalSide:Side

The top or bottom

regionX:float

The top left corner X of the area of the graphics context to fill with our img

regionY:float

The top left corner Y of the area of the graphics context to fill with our img

regionWidth:float

The width of the area of the graphics context to fill with our img

regionHeight:float

The height of the area of the graphics context to fill with our img

srcX:int

The top left corner X of the area of the image to paint with

srcY:int

The top left corner Y of the area of the image to paint with

srcW:int

The width of the area of the image to paint with, -1 to use the original image width

srcH:int

The height of the area of the image to paint with, -1 to use the original image height

tileX:float

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:float

The top left corner Y of the area of the first tile within the destination rectangle

tileWidth:float

The width of the area of the first tile within the destination rectangle, if <= 0, then the use intrinsic value

tileHeight:float

The height of the area of the first tile within the destination rectangle, if <= 0, then the use intrinsic value

renderAsRectangleback to summary
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. This is the * most common code path for UI Controls. * *

renderAsShapeback to summary
private void renderAsShape(Graphics g)

* Drawing a region background and borders when the Region has been * specified to have a shape. This is typically used to render some * portions of a UI Control, such as the tick on a CheckBox, the dot on a * RadioButton, or the disclosure node arrow on a TreeView. In these * cases, the overall region size is typically very small and can * therefore easily be cached. * *

renderBackgroundRectangleback to summary
private void renderBackgroundRectangle(Graphics g)
renderBackgroundRectangleFromCacheback to summary
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)
renderBackgroundRectanglesDirectlyback to summary
private void renderBackgroundRectanglesDirectly(Graphics g, float width, float height)
renderBackgroundShapeback to summary
private void renderBackgroundShape(Graphics g)
renderBorderRectangleback to summary
private void renderBorderRectangle(Graphics g)
renderContentback to summary
protected void renderContent(Graphics g)

Overrides com.sun.javafx.sg.prism.NGGroup.renderContent.

* Region drawing. * *

Annotations
@Override
resizeShapeback to summary
private Shape resizeShape(float topOffset, float rightOffset, float bottomOffset, float leftOffset)

Create a bigger or smaller version of shape. If not scaleShape then the shape is just centered rather than resized. Proportions are not maintained when resizing. This is necessary so as to ensure that the fill never looks scaled. For example, a tile-imaged based background will look stretched if we were to render a scaled shape. Instead, we produce a new shape based on the scaled size and then fill that shape without additional transforms.

roundUpback to summary
private int roundUp(double d)
setBorderStyleback to summary
private void setBorderStyle(Graphics g, BorderStroke sb, double length, boolean forceCentered)
setOpaqueInsetsback to summary
public void setOpaqueInsets(float top, float right, float bottom, float left)

Called by the Region whenever it knows that the opaque insets have changed. The Region must make sure that these opaque insets include the opaque inset information from the Border and Background as well, the NGRegion will not recompute this information. This is done because Border and Background are immutable, and as such this information is computed once and stored rather than recomputed each time we have to render. Any developer supplied opaque insets must be combined with the Border / Background intrinsic opaque insets prior to this call and passed as the arguments to this method.

Parameters
top:float

The top, if NaN then there is no opaque inset at all

right:float

The right, must not be NaN or Infinity, etc.

bottom:float

The bottom, must not be NaN or Infinity, etc.

left:float

The left, must not be NaN or Infinity, etc.

setSizeback to summary
public void setSize(float width, float height)

Called by the Region whenever the width or height of the region has changed. The Region *should* only call this when the width or height have actually changed.

Parameters
width:float

The width of the region, not including insets or outsets

height:float

The height of the region, not including insets or outsets

sliceSizeback to summary
private int sliceSize(boolean isPercent, double sliceSize, float objSize, float scale)
supportsOpaqueRegionsback to summary
protected boolean supportsOpaqueRegions()

Overrides com.sun.javafx.sg.prism.NGNode.supportsOpaqueRegions.

Doc from com.sun.javafx.sg.prism.NGNode.supportsOpaqueRegions.

Gets whether this NGNode supports opaque regions at all. Most node types do not, but some do. If an NGNode subclass is written to support opaque regions, it must override this method to return true. The subclass must then also override the computeDirtyRegion method to return the dirty region, or null if the node in its current state doesn't have one. This method is intended to be immutable.

Returns:boolean

Whether this NGNode implementation supports opaque regions. This could also have been implemented via an interface that some NGNodes implemented, but then we'd have instanceof checks which I'd rather avoid.

Annotations
@Override
updateBackgroundback to summary
public void updateBackground(Background b)

Called by the Region when the Background has changed. The Region *must* only call this method if the background object has actually changed, or excessive work may be done.

Parameters
b:Background

Background, of type javafx.scene.layout.Background. Can be null.

updateBackgroundInsetsback to summary
private void updateBackgroundInsets()

Visits each of the background fills and takes their radii into account to determine the insets. The backgroundInsets variable is cleared whenever the fills change, or whenever the size of the region has changed (because if the size of the region changed and a radius is percentage based then we need to recompute the insets).

updateBorderback to summary
public void updateBorder(Border b)

Called by the Region when the Border is changed. The Region *must* only call this method if the border object has actually changed, or excessive work may be done.

Parameters
b:Border

Border, of type javafx.scene.layout.Border

updateFillCornersback to summary
public void updateFillCorners(List<CornerRadii> normalizedFillCorners)

Called by the Region when any parameters are changed. It is only technically needed when a parameter that affects the size of any percentage or overflowing corner radii is changed, but since the data is not processed here in NGRegion, it is set on every update of the peers for any reason. A null value means that the raw radii in the BackgroundFill objects themselves were already absolute and non-overflowing.

updateShapeback to summary
public void updateShape(Object shape, boolean scaleShape, boolean positionShape, boolean cacheShape)

Called by the Region during synchronization. The Region *should* ensure that this is only called when one of these properties has changed. The cost of calling it excessively is only that the opaque region is invalidated excessively. Updating the shape and associated booleans is actually a very cheap operation.

Parameters
shape:Object

The shape, may be null.

scaleShape:boolean

whether to scale the shape

positionShape:boolean

whether to center the shape

updateStrokeCornersback to summary
public void updateStrokeCorners(List<CornerRadii> normalizedStrokeCorners)

Called by the Region when any parameters are changed. It is only technically needed when a parameter that affects the size of any percentage or overflowing corner radii is changed, but since the data is not processed here in NGRegion, it is set on every update of the peers for any reason. A null value means that the raw radii in the BorderStroke objects themselves were already absolute and non-overflowing.

Parameters
normalizedStrokeCorners:List<CornerRadii>

a precomputed copy of the radii in the BorderStroke objects that are not percentages and do not overflow

widthSizeback to summary
private int widthSize(boolean isPercent, double sliceSize, float objSize)