|
Chart FX for Java 6.2 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectSoftwareFX.ChartFX.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()
Sets the gradient angle when using the 'Angled' gradient background. |
java.awt.Color |
getColor(int n)
Deprecated. You should use GradientBackground#Colors instead. |
java.awt.Color |
getColorFrom()
Beginning color of a gradient. |
GradientBackground.ColorCollection |
getColors()
Gets the Color Collection used for a gradient background. |
java.awt.Color |
getColorTo()
Ending color of a gradient. |
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 GradientBackground#Factor() 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 GradientBackground#Position() instead. |
int |
getType()
Sets the style of the gradient for a selected gradient background. |
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 GradientBackground#Colors 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 GradientBackground#Factor() instead. |
void |
setPosition(int n,
float value)
Deprecated. You should use GradientBackground#Position() 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.
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()
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 Chart.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 Chart.setBackObject(SoftwareFX.ChartFX.IAdornment)
and Chart.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)
,
Chart.setScheme(int)
,
Chart.setBackObject(SoftwareFX.ChartFX.IAdornment)
,
Chart.setInsideBackObject(SoftwareFX.ChartFX.IAdornment)
,
setType(int)
,
Chart
public java.awt.Color getColor(int n)
GradientBackground#Colors
instead.
public java.awt.Color getColorFrom()
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 GradientBackground.ColorCollection getColors()
Gets the Color Collection used for a gradient background.
getFactor(int)
,
getPosition(int)
,
Chart.setBackObject(SoftwareFX.ChartFX.IAdornment)
,
Chart.setInsideBackObject(SoftwareFX.ChartFX.IAdornment)
,
Chart
public java.awt.Color getColorTo()
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 float getFactor(int n)
GradientBackground#Factor()
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 Chart.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 Chart.setBackObject(SoftwareFX.ChartFX.IAdornment)
and Chart.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)
,
Chart.setScheme(int)
,
Chart.setBackObject(SoftwareFX.ChartFX.IAdornment)
,
Chart.setInsideBackObject(SoftwareFX.ChartFX.IAdornment)
,
Chart
public float getPosition(int n)
GradientBackground#Position()
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 Chart.setScheme(int)
property to Scheme.Gradient in order to use a gradient in your chart.
You may assign gradients to the chart Chart.setBackObject(SoftwareFX.ChartFX.IAdornment)
and Chart.setInsideBackObject(SoftwareFX.ChartFX.IAdornment)
.
Below is a multicolor gradient assigned to the Chart.setBackObject(SoftwareFX.ChartFX.IAdornment)
. There are 6 colors in the gradient, therefore, 6 positions must be configured:
getColor(int)
,
getFactor(int)
,
Chart.setBackObject(SoftwareFX.ChartFX.IAdornment)
,
Chart.setInsideBackObject(SoftwareFX.ChartFX.IAdornment)
,
Chart.setScheme(int)
,
Chart
public int getType()
Sets the style of the gradient for a selected gradient background.
GradientType :
Gradient enumerations.Value | Description |
HORIZONTAL | Gradient painted from left to right. |
VERTICAL | Gradient painted from top to bottom. |
BACKWARD_DIAGONAL | Gradient painted from top right to bottom left. |
FORWARD_DIAGONAL | Gradient painted from top left to bottom right. |
RADIAL | Gradient painted in a circular manner from outside to inside. |
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 Chart.setScheme(int)
property to Scheme.Gradient in order to use a gradient in your chart.
You may assign gradients to the chart Chart.setBackObject(SoftwareFX.ChartFX.IAdornment)
and Chart.setInsideBackObject(SoftwareFX.ChartFX.IAdornment)
.
setAngle(float)
,
getColor(int)
,
setColorFrom(java.awt.Color)
,
setColorTo(java.awt.Color)
,
Chart.setScheme(int)
,
getFactor(int)
,
getPosition(int)
,
Chart
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 Chart.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 Chart.setBackObject(SoftwareFX.ChartFX.IAdornment)
and Chart.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)
,
Chart.setScheme(int)
,
Chart.setBackObject(SoftwareFX.ChartFX.IAdornment)
,
Chart.setInsideBackObject(SoftwareFX.ChartFX.IAdornment)
,
setType(int)
,
Chart
public void setColor(int n, java.awt.Color value)
GradientBackground#Colors
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)
GradientBackground#Factor()
instead.
public void setPosition(int n, float value)
GradientBackground#Position()
instead.
public void setType(int value)
Sets the style of the gradient for a selected gradient background.
GradientType :
Gradient enumerations.Value | Description |
HORIZONTAL | Gradient painted from left to right. |
VERTICAL | Gradient painted from top to bottom. |
BACKWARD_DIAGONAL | Gradient painted from top right to bottom left. |
FORWARD_DIAGONAL | Gradient painted from top left to bottom right. |
RADIAL | Gradient painted in a circular manner from outside to inside. |
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 Chart.setScheme(int)
property to Scheme.Gradient in order to use a gradient in your chart.
You may assign gradients to the chart Chart.setBackObject(SoftwareFX.ChartFX.IAdornment)
and Chart.setInsideBackObject(SoftwareFX.ChartFX.IAdornment)
.
setAngle(float)
,
getColor(int)
,
setColorFrom(java.awt.Color)
,
setColorTo(java.awt.Color)
,
Chart.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 |