|
Chart FX 7 for Java Server | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.softwarefx.chartfx.server.adornments.GradientBackground
public 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. When applied to the chart background, gradients can help you achieve a superior visual effect for your desktop and web applications.
In Chart FX, background gradients can be applied to two rectangular areas in the chart area: The chart's inside background (Chart.setPlotAreaBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment)
i.e.,Chart.setPlotAreaBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment)
) and the main background (i.e., Chart.setBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment)
). Chart FX allows horizontal, vertical, diagonal and radial gradients when applying gradient fills to either of these areas of the chart.
To set the gradient colors, you can use the getColors()
, setColorFrom(java.awt.Color)
and setColorTo(java.awt.Color)
properties. When creating two color gradients, you can control the gradient brush using the getFactor()
and getPosition()
properties. The getPosition()
property allows you to specify where each color will start and stop in a multicolor gradient background.
Creating the GradientBackground Object
GradientBackground myGradient = new GradientBackground(GradientType.BACKWARD_DIAGONAL);
myGradient.getColors().add(new java.awt.Color(70, 109, 225));
myGradient.getColors().add(new java.awt.Color(245, 245, 220));
myGradient.getColors().add(new java.awt.Color(70, 109, 225));
myGradient.getPosition().add(0f);
myGradient.getPosition().add(0.9f);
myGradient.getPosition().add(1.0f);
chart1.setBackground(myGradient);
Nested Class Summary | |
---|---|
static class |
GradientBackground.ColorCollection
Provides access to the ColorCollection Class. |
static class |
GradientBackground.FloatCollection
Provides access to the FloatCollection Class. |
Constructor Summary | |
---|---|
GradientBackground()
|
|
GradientBackground(GradientType type)
|
Method Summary | |
---|---|
void |
draw(Graphics2D g,
Rectangle r,
Color clrExternal)
Draws a Chart FX GradientBackground on a selected device context. |
float |
getAngle()
Gets the Angle. |
Color |
getColorFrom()
Gets the ColorFrom. |
GradientBackground.ColorCollection |
getColors()
Sets the colors to be used for a gradient background. |
Color |
getColorTo()
Gets the ColorTo. |
int |
getEffectArea()
Gets the EffectArea. |
GradientBackground.FloatCollection |
getFactor()
Specifies the percentages of the starting color and the ending color to use at the corresponding position for two color gradients. |
GradientBackground.FloatCollection |
getPosition()
Gives access to a collection that allows you to specify positions along the gradient background to correspond with color and factor attributes. |
GradientType |
getType()
Gets the Type. |
void |
setAngle(float value)
Sets the gradient angle when using the 'Angled' gradient background. |
void |
setColorFrom(Color value)
Sets the beginning color of a gradient. |
void |
setColorTo(Color value)
Ending color of a gradient. |
void |
setEffectArea(int value)
Sets a value indicating the percentage of chart area affected by a GradientBackground. |
void |
setType(GradientType 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(GradientType type)
Method Detail |
---|
public void draw(Graphics2D g, Rectangle r, Color clrExternal)
Draws 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 background to a chart.
g
- A Graphics object is associated with a specific device context.r
- A Rectangle object specifying the desired position and size of the gradient.clrExternal
- The external color for the gradient.getColors()
,
setColorFrom(java.awt.Color)
,
setColorTo(java.awt.Color)
,
setType(com.softwarefx.chartfx.server.adornments.GradientType)
,
SimpleBorder.draw(java.awt.Graphics2D, java.awt.Rectangle, java.awt.Color)
,
ImageBorder.draw(java.awt.Graphics2D, java.awt.Rectangle, java.awt.Color)
,
ImageBackground.draw(java.awt.Graphics2D, java.awt.Rectangle, java.awt.Color)
,
SolidBackground.draw(java.awt.Graphics2D, java.awt.Rectangle, java.awt.Color)
,
SimpleBorder
,
ImageBorder
,
ImageBackground
,
SolidBackground
public float getAngle()
Gets the Angle. For more detail see setAngle(float)
.
public Color getColorFrom()
Gets the ColorFrom. For more detail see setColorFrom(java.awt.Color)
.
public Color getColorTo()
Gets the ColorTo. For more detail see setColorTo(java.awt.Color)
.
public GradientBackground.ColorCollection getColors()
Sets the colors to be used for a gradient background.
For more information regarding the Color type, please refer to the Java API Documentation.
Below, the gradient colors are set to blue and white:
Chart.setBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment)
,
setColorTo(java.awt.Color)
,
getFactor()
,
getPosition()
,
Chart.setBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment)
,
Chart.setPlotAreaBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment)
,
Chart
public int getEffectArea()
Gets the EffectArea. For more detail see setEffectArea(int)
.
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 color gradients.
Each configured Factor of a gradient will have a corresponding getPosition()
value.
The elements of this array property are a values ranging from 0.0 through 1.0.
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:
getColors()
,
getPosition()
,
Chart.setBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment)
,
Chart.setPlotAreaBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment)
,
Chart
public GradientBackground.FloatCollection getPosition()
Gives access to a collection that allows you to specify positions along the gradient background to correspond with color and factor attributes.
The range of this array method 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()
value.
Below is a multicolor gradient assigned to the Chart.setBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment)
. There are 6 colors in the gradient, therefore, 6 positions must be configured:
getColors()
,
getFactor()
,
Chart.setBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment)
,
Chart.setPlotAreaBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment)
,
Chart
public GradientType getType()
Gets the Type. For more detail see setType(com.softwarefx.chartfx.server.adornments.GradientType)
.
public void setAngle(float value)
Sets the gradient angle when using the 'Angled' gradient background.
The Angle method supports values ranging from 0 to 360 degrees.
You must select the 'Angled' type gradient when creating the GradientBackground object in order for this method to take effect.
The first chart gradient has been set to 45 degrees:
The second has been set to 120 degrees:
getColors()
,
getFactor()
,
Chart.setBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment)
,
Chart.setPlotAreaBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment)
,
setType(com.softwarefx.chartfx.server.adornments.GradientType)
,
Chart
public void setColorFrom(Color value)
Sets the beginning color of a gradient.
This method sets the beginning color of a gradient. You can also set the beginning color of the gradient by utilizing the getColors()
method using index zero.
getColors()
,
setColorTo(java.awt.Color)
,
Chart.setBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment)
,
Chart.setPlotAreaBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment)
,
Chart
public void setColorTo(Color value)
Ending color of a gradient.
This method sets the ending color of a gradient. You can also set the ending color of the gradient by setting the last index of the getColors()
collection.
getColors()
,
setColorFrom(java.awt.Color)
,
Chart.setBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment)
,
Chart.setPlotAreaBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment)
,
Chart
public void setEffectArea(int value)
Sets a value indicating the percentage of chart area affected by a GradientBackground.
This method may be configured to a value between 0 and 100. The default value is 20, indicating that 20 percent of the chart is affected by a gradient background.
Specifying 100 indicates the entire chart background should be configured with a GradientBackground.
setAngle(float)
,
getColors()
,
setColorFrom(java.awt.Color)
,
setColorTo(java.awt.Color)
,
getFactor()
,
getPosition()
,
setType(com.softwarefx.chartfx.server.adornments.GradientType)
,
draw(java.awt.Graphics2D, java.awt.Rectangle, java.awt.Color)
public void setType(GradientType value)
Sets the style of the gradient for a selected gradient background.
When using the 'Angled' gradient enumeration, you can set the desired angle for the gradient using the setAngle(float)
method.
Below is a gradient of type "BackwardDiagonal":
Alternatively, this is a gradient of type "Radial":
Finally, this is a gradient of type "Vertical":
setAngle(float)
,
getColors()
,
Chart.setBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment)
,
Chart.setPlotAreaBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment)
,
Chart
|
http://www.softwarefx.com | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |