| Modifier and Type | Class and Description |
|---|---|
| protected static class | AbstractRegionPainter.
A class encapsulating state useful when painting. |
| Modifier and Type | Field and Description |
|---|---|
| private float | bottomHeight
The height of the bottom section. |
| private float | bottomScale
The scaling factor to use for the bottom section. |
| private float | centerHeight
The height of the center section. |
| private float | centerHScale
The scaling factor to use for the center section, in the horizontal direction. |
| private float | centerVScale
The scaling factor to use for the center section, in the vertical direction. |
| private float | centerWidth
The width of the center section. |
| private AbstractRegionPainter. | ctx
PaintContext, which holds a lot of the state needed for cache hinting and x/y value decoding The data contained within the context is typically only computed once and reused over multiple paint calls, whereas the other values (w, h, f, leftWidth, etc) are recomputed for each call to paint. |
| private float | f
The scaling factor. |
| private float | leftScale
The scaling factor to use for the left section. |
| private float | leftWidth
The width of the left section. |
| private float | rightScale
The scaling factor to use for the right section. |
| private float | rightWidth
The width of the right section. |
| private float | topHeight
The height of the top section. |
| private float | topScale
The scaling factor to use for the top section. |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| private float | |
| private int | |
| protected void | configureGraphics(Graphics2D
The Graphics2D object to configure. Will not be null. g)Configures the given Graphics2D. |
| protected final float | Returns: the decoded x location of the control pointan encoded x value of the bezier control point (0...1, or 1...2, or 2...3) x, float the offset distance to the anchor from the control point x dx)Decodes and returns a float value representing the actual pixel location for the anchor point given the encoded X value of the control point, and the offset distance to the anchor from that control point. |
| protected final float | Returns: the decoded y position of the control pointan encoded y value of the bezier control point (0...1, or 1...2, or 2...3) y, float the offset distance to the anchor from the control point y dy)Decodes and returns a float value representing the actual pixel location for the anchor point given the encoded Y value of the control point, and the offset distance to the anchor from that control point. |
| protected final Color | Returns: The derived color, whose color value will change if the parent uiDefault color changes.A key corresponding to the value in the UI Defaults table
of UIManager where the base color is defined key, float The hue offset used for derivation. hOffset, float The saturation offset used for derivation. sOffset, float The brightness offset used for derivation. bOffset, int The alpha offset used for derivation. Between 0...255 aOffset)Decodes and returns a color, which is derived from a base color in UI defaults. |
| protected final Color | Returns: The derived colorThe first color color1, Color The second color color2, float The offset between color 1 and color 2, a value of 0.0 is
color 1 and 1.0 is color 2; midPoint)Decodes and returns a color, which is derived from a offset between two other colors. |
| protected final LinearGradientPaint | Returns: a valid LinearGradientPaint. This method never returns null.x1 x1, float y1 y1, float x2 x2, float y2 y2, float[] the midpoints midpoints, Color[] the colors colors)Given parameters for creating a LinearGradientPaint, this method will create and return a linear gradient paint. |
| protected final RadialGradientPaint | Returns: a valid RadialGradientPaint. This method never returns null.x-coordinate x, float y-coordinate y, float radius r, float[] the midpoints midpoints, Color[] the colors colors)Given parameters for creating a RadialGradientPaint, this method will create and return a radial gradient paint. |
| protected final float | Returns: the decoded x valuean encoded x value (0...1, or 1...2, or 2...3) x)Decodes and returns a float value representing the actual pixel location for the given encoded X value. |
| protected final float | Returns: the decoded y valuean encoded y value (0...1, or 1...2, or 2...3) y)Decodes and returns a float value representing the actual pixel location for the given encoded y value. |
| protected abstract void | doPaint(Graphics2D
The Graphics2D surface to paint to g, JComponent The JComponent related to the drawing event. For example, if the
region being rendered is Button, then c, int c will be a
JButton. If the region being drawn is ScrollBarSlider, then the
component will be JScrollBar. This value may be null.The width of the region to paint. Note that in the case of
painting the foreground, this value may differ from c.getWidth(). width, int The height of the region to paint. Note that in the case of
painting the foreground, this value may differ from c.getHeight(). height, Object[] The result of the call to getExtendedCacheKeys() extendedCacheKeys)Actually performs the painting operation. |
| protected final Color | Returns: The color that was obtained from the component or defaultColorThe component to get the color property from c, String The name of a bean style property or client property property, Color The color to return if no color was obtained from
the component. defaultColor, float additively modifies the HSB saturation component
of the color returned (ignored if default color is returned). saturationOffset, float additively modifies the HSB brightness component
of the color returned (ignored if default color is returned). brightnessOffset, int additively modifies the ARGB alpha component of the
color returned (ignored if default color is returned). alphaOffset)Get a color property from the given JComponent. |
| protected Object[] | Returns: Array of extra objects to be included in the cache keyThe component on the current paint call c)Get any extra attributes which the painter implementation would like to include in the image cache lookups. |
| private VolatileImage | getImage(GraphicsConfiguration config, JComponent c, int w, int h, Object[] extendedCacheKeys)
Gets the rendered image for this painter at the requested size, either from cache or create a new one |
| protected abstract AbstractRegionPainter. | Returns: a PaintContext associated with this paint operation.Gets the PaintContext for this painting operation. |
| public final void | paint(Graphics2D g, JComponent c, int w, int h)
Implements javax. Renders to the given |
| private void | |
| private void | paintWith9SquareCaching(Graphics2D g, AbstractRegionPainter.
|
| private void | |
| private void |
| bottomHeight | back to summary |
|---|---|
| private float bottomHeight The height of the bottom section. Recomputed on each call to paint. | |
| bottomScale | back to summary |
|---|---|
| private float bottomScale The scaling factor to use for the bottom section. Recomputed on each call to paint. | |
| centerHeight | back to summary |
|---|---|
| private float centerHeight The height of the center section. Recomputed on each call to paint. | |
| centerHScale | back to summary |
|---|---|
| private float centerHScale The scaling factor to use for the center section, in the horizontal direction. Recomputed on each call to paint. | |
| centerVScale | back to summary |
|---|---|
| private float centerVScale The scaling factor to use for the center section, in the vertical direction. Recomputed on each call to paint. | |
| centerWidth | back to summary |
|---|---|
| private float centerWidth The width of the center section. Recomputed on each call to paint. | |
| ctx | back to summary |
|---|---|
| private AbstractRegionPainter. PaintContext, which holds a lot of the state needed for cache hinting and x/y value decoding The data contained within the context is typically only computed once and reused over multiple paint calls, whereas the other values (w, h, f, leftWidth, etc) are recomputed for each call to paint. This field is retrieved from subclasses on each paint operation. It is up to the subclass to compute and cache the PaintContext over multiple calls. | |
| f | back to summary |
|---|---|
| private float f The scaling factor. Recomputed on each call to paint. | |
| leftScale | back to summary |
|---|---|
| private float leftScale The scaling factor to use for the left section. Recomputed on each call to paint. | |
| leftWidth | back to summary |
|---|---|
| private float leftWidth The width of the left section. Recomputed on each call to paint. | |
| rightScale | back to summary |
|---|---|
| private float rightScale The scaling factor to use for the right section. Recomputed on each call to paint. | |
| rightWidth | back to summary |
|---|---|
| private float rightWidth The width of the right section. Recomputed on each call to paint. | |
| topHeight | back to summary |
|---|---|
| private float topHeight The height of the top section. Recomputed on each call to paint. | |
| topScale | back to summary |
|---|---|
| private float topScale The scaling factor to use for the top section. Recomputed on each call to paint. | |
| AbstractRegionPainter | back to summary |
|---|---|
| protected AbstractRegionPainter() Create a new AbstractRegionPainter | |
| clamp | back to summary |
|---|---|
| private float clamp(float value) | |
| clamp | back to summary |
|---|---|
| private int clamp(int value) | |
| configureGraphics | back to summary |
|---|---|
| protected void configureGraphics(Graphics2D g) Configures the given Graphics2D. Often, rendering hints or compositing rules are applied to a Graphics2D object prior to painting, which should affect all of the subsequent painting operations. This method provides a convenient hook for configuring the Graphics object prior to rendering, regardless of whether the render operation is performed to an intermediate buffer or directly to the display.
| |
| decodeAnchorX | back to summary |
|---|---|
| protected final float decodeAnchorX(float x, float dx) Decodes and returns a float value representing the actual pixel location for the anchor point given the encoded X value of the control point, and the offset distance to the anchor from that control point.
| |
| decodeAnchorY | back to summary |
|---|---|
| protected final float decodeAnchorY(float y, float dy) Decodes and returns a float value representing the actual pixel location for the anchor point given the encoded Y value of the control point, and the offset distance to the anchor from that control point.
| |
| decodeColor | back to summary |
|---|---|
| protected final Color decodeColor(String key, float hOffset, float sOffset, float bOffset, int aOffset) Decodes and returns a color, which is derived from a base color in UI defaults.
| |
| decodeColor | back to summary |
|---|---|
| protected final Color decodeColor(Color color1, Color color2, float midPoint) Decodes and returns a color, which is derived from a offset between two other colors. | |
| decodeGradient | back to summary |
|---|---|
| protected final LinearGradientPaint decodeGradient(float x1, float y1, float x2, float y2, float[] midpoints, Color[] colors) Given parameters for creating a LinearGradientPaint, this method will create and return a linear gradient paint. One primary purpose for this method is to avoid creating a LinearGradientPaint where the start and end points are equal. In such a case, the end y point is slightly increased to avoid the overlap.
| |
| decodeRadialGradient | back to summary |
|---|---|
| protected final RadialGradientPaint decodeRadialGradient(float x, float y, float r, float[] midpoints, Color[] colors) Given parameters for creating a RadialGradientPaint, this method will create and return a radial gradient paint. One primary purpose for this method is to avoid creating a RadialGradientPaint where the radius is non-positive. In such a case, the radius is just slightly increased to avoid 0.
| |
| decodeX | back to summary |
|---|---|
| protected final float decodeX(float x) Decodes and returns a float value representing the actual pixel location for the given encoded X value.
| |
| decodeY | back to summary |
|---|---|
| protected final float decodeY(float y) Decodes and returns a float value representing the actual pixel location for the given encoded y value.
| |
| doPaint | back to summary |
|---|---|
| protected abstract void doPaint(Graphics2D g, JComponent c, int width, int height, Object[] extendedCacheKeys) Actually performs the painting operation. Subclasses must implement this method.
The graphics object passed may represent the actual surface being rendered to,
or it may be an intermediate buffer. It has also been pre-translated. Simply render
the component as if it were located at 0, 0 and had a width of
| |
| getComponentColor | back to summary |
|---|---|
| protected final Color getComponentColor(JComponent c, String property, Color defaultColor, float saturationOffset, float brightnessOffset, int alphaOffset) Get a color property from the given JComponent. First checks for a
| |
| getExtendedCacheKeys | back to summary |
|---|---|
| protected Object[] getExtendedCacheKeys(JComponent c) Get any extra attributes which the painter implementation would like to include in the image cache lookups. This is checked for every call of the paint(g, c, w, h) method.
| |
| getImage | back to summary |
|---|---|
| private VolatileImage getImage(GraphicsConfiguration config, JComponent c, int w, int h, Object[] extendedCacheKeys) Gets the rendered image for this painter at the requested size, either from cache or create a new one | |
| getPaintContext | back to summary |
|---|---|
| protected abstract AbstractRegionPainter. Gets the PaintContext for this painting operation. This method is called on every paint, and so should be fast and produce no garbage. The PaintContext contains information such as cache hints. It also contains data necessary for decoding points at runtime, such as the stretching insets, the canvas size at which the encoded points were defined, and whether the stretching insets are inverted. This method allows for subclasses to package the painting of different states with possibly different canvas sizes, etc, into one AbstractRegionPainter implementation.
| |
| paint | back to summary |
|---|---|
| public final void paint(Graphics2D g, JComponent c, int w, int h) Implements javax. Doc from javax. Renders to the given State on the graphics object may be honored by the The supplied object parameter acts as an optional configuration argument.
For example, it could be of type Generally, to enhance reusability, most standard Finally, the For example, suppose I have a
| |
| paint0 | back to summary |
|---|---|
| private void paint0(Graphics2D g, JComponent c, int width, int height, Object[] extendedCacheKeys) | |
| paintWith9SquareCaching | back to summary |
|---|---|
| private void paintWith9SquareCaching(Graphics2D g, AbstractRegionPainter. | |
| paintWithFixedSizeCaching | back to summary |
|---|---|
| private void paintWithFixedSizeCaching(Graphics2D g, JComponent c, int w, int h, Object[] extendedCacheKeys) | |
| prepare | back to summary |
|---|---|
| private void prepare(float w, float h) | |
| Modifier and Type | Class and Description |
|---|---|
| protected static enum | AbstractRegionPainter.
Cache mode. |
| Modifier and Type | Field and Description |
|---|---|
| private float | |
| private float | |
| private float | |
| private float | |
| private float | |
| private AbstractRegionPainter. | |
| private Dimension | |
| private float | |
| private float | |
| private float | |
| private static Insets | |
| private boolean | |
| private double | |
| private double | |
| private Insets |
| Access | Constructor and Description |
|---|---|
| public | PaintContext(Insets
The stretching insets. May be null. If null, then assumed to be 0, 0, 0, 0. insets, Dimension The size of the canvas used when encoding the various x/y values. May be null.
If null, then it is assumed that there are no encoded values, and any calls
to one of the "decode" methods will return the passed in value. canvasSize, boolean Whether to "invert" the meaning of the 9-square grid and stretching insets inverted)Creates a new PaintContext which does not attempt to cache or scale any cached images. |
| public | PaintContext(Insets
The stretching insets. May be null. If null, then assumed to be 0, 0, 0, 0. insets, Dimension The size of the canvas used when encoding the various x/y values. May be null.
If null, then it is assumed that there are no encoded values, and any calls
to one of the "decode" methods will return the passed in value. canvasSize, boolean Whether to "invert" the meaning of the 9-square grid and stretching insets inverted, AbstractRegionPainter.A hint as to which caching mode to use. If null, then set to no caching. cacheMode,The maximum scale in the horizontal direction to use before punting and redrawing from scratch.
For example, if maxH is 2, then we will attempt to scale any cached images up to 2x the canvas
width before redrawing from scratch. Reasonable maxH values may improve painting performance.
If set too high, then you may get poor looking graphics at higher zoom levels. Must be >= 1. maxH, double The maximum scale in the vertical direction to use before punting and redrawing from scratch.
For example, if maxV is 2, then we will attempt to scale any cached images up to 2x the canvas
height before redrawing from scratch. Reasonable maxV values may improve painting performance.
If set too high, then you may get poor looking graphics at higher zoom levels. Must be >= 1. maxV)Creates a new PaintContext. |
| a | back to summary |
|---|---|
| private float a | |
| aPercent | back to summary |
|---|---|
| private float aPercent | |
| b | back to summary |
|---|---|
| private float b | |
| bPercent | back to summary |
|---|---|
| private float bPercent | |
| c | back to summary |
|---|---|
| private float c | |
| cacheMode | back to summary |
|---|---|
| private AbstractRegionPainter. | |
| canvasSize | back to summary |
|---|---|
| private Dimension canvasSize | |
| cPercent | back to summary |
|---|---|
| private float cPercent | |
| d | back to summary |
|---|---|
| private float d | |
| dPercent | back to summary |
|---|---|
| private float dPercent | |
| EMPTY_INSETS | back to summary |
|---|---|
| private static Insets EMPTY_INSETS | |
| inverted | back to summary |
|---|---|
| private boolean inverted | |
| maxHorizontalScaleFactor | back to summary |
|---|---|
| private double maxHorizontalScaleFactor | |
| maxVerticalScaleFactor | back to summary |
|---|---|
| private double maxVerticalScaleFactor | |
| stretchingInsets | back to summary |
|---|---|
| private Insets stretchingInsets | |
| PaintContext | back to summary |
|---|---|
| public PaintContext(Insets insets, Dimension canvasSize, boolean inverted) Creates a new PaintContext which does not attempt to cache or scale any cached images.
| |
| PaintContext | back to summary |
|---|---|
| public PaintContext(Insets insets, Dimension canvasSize, boolean inverted, AbstractRegionPainter. Creates a new PaintContext.
| |
| Modifier and Type | Field and Description |
|---|---|
| public static final AbstractRegionPainter. | FIXED_SIZES
Fixed sizes. |
| public static final AbstractRegionPainter. | NINE_SQUARE_SCALE
Nine square scale. |
| public static final AbstractRegionPainter. | NO_CACHING
No caching. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static AbstractRegionPainter. | |
| public static AbstractRegionPainter. |
| FIXED_SIZES | back to summary |
|---|---|
| public static final AbstractRegionPainter. Fixed sizes. | |
| NINE_SQUARE_SCALE | back to summary |
|---|---|
| public static final AbstractRegionPainter. Nine square scale. | |
| NO_CACHING | back to summary |
|---|---|
| public static final AbstractRegionPainter. No caching. | |
| CacheMode | back to summary |
|---|---|
| private CacheMode() | |
| valueOf | back to summary |
|---|---|
| public static AbstractRegionPainter. | |
| values | back to summary |
|---|---|
| public static AbstractRegionPainter. | |