|
Chart FX for Java 6.5 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object SoftwareFX.ChartFX.GradientBackground
public final class GradientBackground
Provides access to the GradientBackground object.
As opposed to marker gradients, background gradients are used for cosmetic purposes only. In other words, background gradients are only used to enhance the chart's visual appearance and have no direct relation to the data contained in the chart.
In Chart FX, background gradients can be applied to 2 rectangular areas in the chart area: The chart's inside background and the main background. Chart FX allows horizontal, vertical, diagonal and radial gradients when applying gradient fills to either of these areas of the chart.
When applied to the chart background, gradients can help you achieve a superior visual effect for your desktop and web applications.
Creating the GradientBackground Object
In order to add a gradient background to your chart, you will need to create an instance of the GradientBackground object. Once an object has been created, you may assign the desired attributes to create the gradient. Below is a small example of creating the GradientBackground object and attribute assignment:
GradientBackground myGradient = new GradientBackground(GradientType.BACKWARD_DIAGONAL);
myGradient.setColor(0, java.awt.Color.red);
myGradient.setColor(1, java.awt.Color.blue);
myGradient.setPosition(0, 0);
myGradient.setPosition(1, 1);
chart1.setBackObject(myGradient);
Nested Class Summary | |
---|---|
static class |
GradientBackground.ColorCollection
Provides access to the ColorCollection object. |
static class |
GradientBackground.FloatCollection
Provides access to the FloatCollection object. |
Constructor Summary | |
---|---|
GradientBackground()
|
|
GradientBackground(int type)
|
Method Summary | |
---|---|
void |
draw(java.awt.Graphics2D graphics2D,
java.awt.Rectangle r,
java.awt.Color clrExternal)
Used to draw a Chart FX GradientBackground on a selected device context. |
float |
getAngle()
Gets the Angle. |
java.awt.Color |
getColor(int n)
Deprecated. You should use getColors() instead. |
java.awt.Color |
getColorFrom()
Gets the ColorFrom. |
GradientBackground.ColorCollection |
getColors()
Gets the Color Collection used for a gradient background. |
java.awt.Color |
getColorTo()
Gets the ColorTo. |
GradientBackground.FloatCollection |
getFactor()
Specifies the percentages of the starting color and the ending color to use at the corresponding position for two color gradients. |
float |
getFactor(int n)
Deprecated. You should use getFactor() instead. |
GradientBackground.FloatCollection |
getPosition()
Allows you to specify positions along the gradient background to correspond with color and factor attributes. |
float |
getPosition(int n)
Deprecated. You should use getPosition() instead. |
int |
getType()
Gets the Type. |
void |
setAngle(float value)
Sets the gradient angle when using the 'Angled' gradient background. |
void |
setColor(int n,
java.awt.Color value)
Deprecated. You should use getColors() instead. |
void |
setColorFrom(java.awt.Color value)
Beginning color of a gradient. |
void |
setColorTo(java.awt.Color value)
Ending color of a gradient. |
void |
setFactor(int n,
float value)
Deprecated. You should use getFactor() instead. |
void |
setPosition(int n,
float value)
Deprecated. You should use getPosition() instead. |
void |
setType(int value)
Sets the style of the gradient for a selected gradient background. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public GradientBackground()
public GradientBackground(int type)
Method Detail |
---|
public void draw(java.awt.Graphics2D graphics2D, java.awt.Rectangle r, java.awt.Color clrExternal)
Used to draw a Chart FX GradientBackground on a selected device context.
This method allows you to draw a GradientBackground to a selected device context without ever assigning the GradientBackground object to a chart.
The setType(int)
property allows you to select on of the supported Chart FX GradientBackground styles.
The getColor(int)
, setColorFrom(java.awt.Color)
and setColorTo(java.awt.Color)
proerties will allow you to selected the desired colors for the gradient.
graphics2D
- r
- A Rectangle object specifying the desired position and size of the gradient.clrExternal
- The external color for the gradient.getColor(int)
,
setColorFrom(java.awt.Color)
,
setColorTo(java.awt.Color)
,
setType(int)
,
DefaultBorder.draw(java.awt.Graphics2D, java.awt.Rectangle, java.awt.Color)
,
ImageBorder.draw(java.awt.Graphics2D, java.awt.Rectangle, java.awt.Color)
,
DefaultBorder
,
ImageBorder
public float getAngle()
Gets the Angle. For more detail see setAngle(float)
.
public java.awt.Color getColor(int n)
getColors()
instead.
public java.awt.Color getColorFrom()
Gets the ColorFrom. For more detail see setColorFrom(java.awt.Color)
.
public GradientBackground.ColorCollection getColors()
Gets the Color Collection used for a gradient background.
getFactor(int)
,
getPosition(int)
,
ChartCore.setBackObject(SoftwareFX.ChartFX.IAdornment)
,
ChartCore.setInsideBackObject(SoftwareFX.ChartFX.IAdornment)
,
Chart
public java.awt.Color getColorTo()
Gets the ColorTo. For more detail see setColorTo(java.awt.Color)
.
public float getFactor(int n)
getFactor()
instead.
public GradientBackground.FloatCollection getFactor()
Specifies the percentages of the starting color and the ending color to use at the corresponding position for two color gradients.
The Factor property is only supported for two (2) color gradients.
You must set the ChartCore.setScheme(int)
property to Scheme.Gradient in order to use a gradient in your chart.
Each configured Factor of a gradient will have a corresponding getPosition(int)
value.
The elements of this array property are a values ranging from 0.0 through 1.0.
You may assign gradients to the chart ChartCore.setBackObject(SoftwareFX.ChartFX.IAdornment)
and ChartCore.setInsideBackObject(SoftwareFX.ChartFX.IAdornment)
.
The chart below depicts the gradient background created with the sample below. Notice how using the factor allows you to control the gradient brush for an even fade:
getColor(int)
,
getPosition(int)
,
ChartCore.setScheme(int)
,
ChartCore.setBackObject(SoftwareFX.ChartFX.IAdornment)
,
ChartCore.setInsideBackObject(SoftwareFX.ChartFX.IAdornment)
,
Chart
public float getPosition(int n)
getPosition()
instead.
public GradientBackground.FloatCollection getPosition()
Allows you to specify positions along the gradient background to correspond with color and factor attributes.
The range of this array property is represented by values between 0.0 and 1.0; the first position value must be 0.0 and the last position value must be 1.0.
For two color gradients, each position value must have a corresponding getFactor(int)
value.
In multicolor gradients, each position value must have a corresponding getColor(int)
.
You must set the ChartCore.setScheme(int)
property to Scheme.Gradient in order to use a gradient in your chart.
You may assign gradients to the chart ChartCore.setBackObject(SoftwareFX.ChartFX.IAdornment)
and ChartCore.setInsideBackObject(SoftwareFX.ChartFX.IAdornment)
.
Below is a multicolor gradient assigned to the ChartCore.setBackObject(SoftwareFX.ChartFX.IAdornment)
. There are 6 colors in the gradient, therefore, 6 positions must be configured:
getColor(int)
,
getFactor(int)
,
ChartCore.setBackObject(SoftwareFX.ChartFX.IAdornment)
,
ChartCore.setInsideBackObject(SoftwareFX.ChartFX.IAdornment)
,
ChartCore.setScheme(int)
,
Chart
public int getType()
Gets the Type. For more detail see setType(int)
.
public void setAngle(float value)
Sets the gradient angle when using the 'Angled' gradient background.
The Angle property supports values ranging from 0 to 360 degrees.
You must select the 'Angled' type gradient when creating the GradientBackground object in order for this property to take effect.
You must set the ChartCore.setScheme(int)
property to Scheme.Gradient in order to use a gradient in your chart.
To set the gradient colors, you can use the getColor(int)
, setColorFrom(java.awt.Color)
and setColorTo(java.awt.Color)
properties.
When creating two color gradients, you can control the gradient brush using the getFactor(int)
and getPosition(int)
properties.
You may assign gradients to the chart ChartCore.setBackObject(SoftwareFX.ChartFX.IAdornment)
and ChartCore.setInsideBackObject(SoftwareFX.ChartFX.IAdornment)
.
The first chart gradient has been set to 45 degrees:
The second has been set to 120 degrees:
getColor(int)
,
getFactor(int)
,
getPosition(int)
,
ChartCore.setScheme(int)
,
ChartCore.setBackObject(SoftwareFX.ChartFX.IAdornment)
,
ChartCore.setInsideBackObject(SoftwareFX.ChartFX.IAdornment)
,
setType(int)
,
Chart
public void setColor(int n, java.awt.Color value)
getColors()
instead.
public void setColorFrom(java.awt.Color value)
Beginning color of a gradient.
This property sets the beginning color of a gradient to be applied to chart BackObject or InsideBackObject. You can also set the beginning color of the gradient by utilizing the Color property using index zero.
setAngle(float)
,
getColor(int)
,
setColorTo(java.awt.Color)
,
getFactor(int)
,
getPosition(int)
,
setType(int)
public void setColorTo(java.awt.Color value)
Ending color of a gradient.
This property sets the ending color of a gradient to be applied to chart BackObject or InsideBackObject. You can also set the ending color of the gradient by utilizing the Color property.
setAngle(float)
,
getColor(int)
,
setColorFrom(java.awt.Color)
,
getFactor(int)
,
getPosition(int)
,
setType(int)
public void setFactor(int n, float value)
getFactor()
instead.
public void setPosition(int n, float value)
getPosition()
instead.
public void setType(int value)
Sets the style of the gradient for a selected gradient background.
GradientType :
Gradient enumerations.Value | Description |
---|---|
GradientType.HORIZONTAL | Gradient painted from left to right. |
GradientType.VERTICAL | Gradient painted from top to bottom. |
GradientType.BACKWARD_DIAGONAL | Gradient painted from top right to bottom left. |
GradientType.FORWARD_DIAGONAL | Gradient painted from top left to bottom right. |
GradientType.RADIAL | Gradient painted in a circular manner from outside to inside. |
GradientType.ANGLED | Gradient painted using the configured angle value. |
When using the 'Angled' gradient enumeration, you can set the desired angle for the gradient using the setAngle(float)
property.
The getColor(int)
, setColorFrom(java.awt.Color)
and setColorTo(java.awt.Color)
properties allow you to configure the desired colors for a gradient background.
You must set the ChartCore.setScheme(int)
property to Scheme.Gradient in order to use a gradient in your chart.
You may assign gradients to the chart ChartCore.setBackObject(SoftwareFX.ChartFX.IAdornment)
and ChartCore.setInsideBackObject(SoftwareFX.ChartFX.IAdornment)
.
setAngle(float)
,
getColor(int)
,
setColorFrom(java.awt.Color)
,
setColorTo(java.awt.Color)
,
ChartCore.setScheme(int)
,
getFactor(int)
,
getPosition(int)
,
Chart
|
http://www.softwarefx.com | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |