public class GradientBackground extends java.lang.Object implements IBackgroundAdornment
The GradientBackground object allows changing the color to the chart's background, using a gradient.
In Chart FX, background gradients can be applied to two rectangular areas in the chart area: The chart's inside background (setPlotAreaBackground
) and the main background (setChartBackground
). 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 setColors
, setColorFrom
and setColorTo
methods. When creating two color gradients, you can control the gradient brush using the setFactor
and setPosition
methods.
The following images show how gradients can be applied to the chart's backgound and plot area background:
GradientBackground myGradient;
myGradient = new GradientBackground(GradientType.BACKWARD_DIAGONAL);
myGradient.getColors().add(new java.awt.Color(0,128,0,255));
myGradient.getColors().add(new java.awt.Color(0,0,255,255));
myGradient.getPosition().add(0f);
myGradient.getPosition().add(0.5f);
myGradient.getPosition().add(1f);
myGradient.getFactor().add(0f);
myGradient.getFactor().add(0.5f);
myGradient.getFactor().add(1f);
chart1.setChartBackground(myGradient);
chart1.setForeColor(new java.awt.Color(255,255,255,255));
PopulateSouthAmericaPopulation(chart1);
chart1.setGallery(Gallery.BAR);
chart1.getLegendBox().setVisible(false);
chart1.getTitles().add(new TitleDockable("South American Countries Population"));
chart1.getAxisY().setScaleUnit(1000000);
chart1.getAxisY().getTitle().setText("(in Millions)");
public static void PopulateSouthAmericaPopulation(Chart chart1) { SouthAmericaPopulation[] data = new SouthAmericaPopulation[]{ new SouthAmericaPopulation("Brazil", 201033000), new SouthAmericaPopulation("Colombia", 47130000), new SouthAmericaPopulation("Argentina", 41350000), new SouthAmericaPopulation("Peru", 30476000), new SouthAmericaPopulation("Venezuela", 29760000), new SouthAmericaPopulation("Chile", 16841000), new SouthAmericaPopulation("Ecuador", 15779000), new SouthAmericaPopulation("Bolivia", 10517000) }; ObjectProvider objProvider = new ObjectProvider(data); chart1.getDataSourceSettings().setDataSource(objProvider); }
public static class SouthAmericaPopulation { public SouthAmericaPopulation(String country, double population) { this.setCountry(country); this.setPopulation(population); } private String privateCountry; public final String getCountry() { return privateCountry; } public final void setCountry(String value) { privateCountry = value; } private double privatePopulation; public final double getPopulation() { return privatePopulation; } public final void setPopulation(double value) { privatePopulation = value; } }
public static class Countries { public Countries(String country, double lei, double gdppc, java.awt.Image flag) { this.setCountry(country); this.setLEI(lei); this.setGDPPC(gdppc); this.setFlag(flag); } private String privateCountry; public final String getCountry() { return privateCountry; } public final void setCountry(String value) { privateCountry = value; } private double privateLEI; public final double getLEI() { return privateLEI; } public final void setLEI(double value) { privateLEI = value; } private double privateGDPPC; public final double getGDPPC() { return privateGDPPC; } public final void setGDPPC(double value) { privateGDPPC = value; } private java.awt.Image privateFlag; public final java.awt.Image getFlag() { return privateFlag; } public final void setFlag(java.awt.Image value) { privateFlag = value; } }
GradientBackground myGradient;
myGradient = new GradientBackground(GradientType.BACKWARD_DIAGONAL);
myGradient.getColors().add(new java.awt.Color(0,128,0,255));
myGradient.getColors().add(new java.awt.Color(0,0,255,255));
myGradient.getPosition().add(0f);
myGradient.getPosition().add(0.5f);
myGradient.getPosition().add(1f);
myGradient.getFactor().add(0f);
myGradient.getFactor().add(0.5f);
myGradient.getFactor().add(1f);
chart1.setPlotAreaBackground(myGradient);
PopulateSouthAmericaPopulation(chart1);
chart1.setGallery(Gallery.BAR);
chart1.getLegendBox().setVisible(false);
chart1.getTitles().add(new TitleDockable("South American Countries Population"));
chart1.getAxisY().setScaleUnit(1000000);
chart1.getAxisY().getTitle().setText("(in Millions)");
public static void PopulateSouthAmericaPopulation(Chart chart1) { SouthAmericaPopulation[] data = new SouthAmericaPopulation[]{ new SouthAmericaPopulation("Brazil", 201033000), new SouthAmericaPopulation("Colombia", 47130000), new SouthAmericaPopulation("Argentina", 41350000), new SouthAmericaPopulation("Peru", 30476000), new SouthAmericaPopulation("Venezuela", 29760000), new SouthAmericaPopulation("Chile", 16841000), new SouthAmericaPopulation("Ecuador", 15779000), new SouthAmericaPopulation("Bolivia", 10517000) }; ObjectProvider objProvider = new ObjectProvider(data); chart1.getDataSourceSettings().setDataSource(objProvider); }
public static class SouthAmericaPopulation { public SouthAmericaPopulation(String country, double population) { this.setCountry(country); this.setPopulation(population); } private String privateCountry; public final String getCountry() { return privateCountry; } public final void setCountry(String value) { privateCountry = value; } private double privatePopulation; public final double getPopulation() { return privatePopulation; } public final void setPopulation(double value) { privatePopulation = value; } }
public static class Countries { public Countries(String country, double lei, double gdppc, java.awt.Image flag) { this.setCountry(country); this.setLEI(lei); this.setGDPPC(gdppc); this.setFlag(flag); } private String privateCountry; public final String getCountry() { return privateCountry; } public final void setCountry(String value) { privateCountry = value; } private double privateLEI; public final double getLEI() { return privateLEI; } public final void setLEI(double value) { privateLEI = value; } private double privateGDPPC; public final double getGDPPC() { return privateGDPPC; } public final void setGDPPC(double value) { privateGDPPC = value; } private java.awt.Image privateFlag; public final java.awt.Image getFlag() { return privateFlag; } public final void setFlag(java.awt.Image value) { privateFlag = value; } }
Modifier and Type | Class and Description |
---|---|
static class |
GradientBackground.ColorCollection<T>
Description goes here
|
Constructor and Description |
---|
GradientBackground()
Constructs a newly allocated GradientBackground object
|
GradientBackground(GradientType type)
Constructs a newly allocated GradientBackground object
|
Modifier and Type | Method and Description |
---|---|
float |
getAngle()
Sets the gradient angle when using the 'Angled' gradient background.
|
java.awt.Color |
getColorFrom()
Gets or sets the beginning color of a gradient.
|
java.util.List<java.awt.Color> |
getColors()
Gets or sets the colors to be used for a gradient background.
|
java.awt.Color |
getColorTo()
Ending color of a gradient.
|
int |
getEffectArea()
Gets or sets a value indicating the percentage of chart area affected by a GradientBackground.
|
java.util.List<java.lang.Float> |
getFactor()
Specifies the percentages of the starting color and the ending color to use at the corresponding position for two color gradients.
|
java.util.List<java.lang.Float> |
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()
Sets the style of the gradient for a selected gradient background.
|
void |
resetAngle()
Set the property Angle to its default value.
|
void |
resetEffectArea()
Set the property EffectArea to its default value.
|
void |
resetType()
Set the property Type to its default value.
|
void |
setAngle(float value)
Sets the gradient angle when using the 'Angled' gradient background.
|
void |
setColorFrom(java.awt.Color value)
Gets or sets the beginning color of a gradient.
|
void |
setColorTo(java.awt.Color value)
Ending color of a gradient.
|
void |
setEffectArea(int value)
Gets or 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.
|
public GradientBackground()
public GradientBackground(GradientType type)
type
- public float getAngle()
Sets the gradient angle when using the 'Angled' gradient background.
The setAngle
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 border chart gradient has been set to 45 degrees:
GradientBackground myGradient;
myGradient = new GradientBackground(GradientType.ANGLED);
myGradient.getColors().add(new java.awt.Color(0,0,255,255));
myGradient.getPosition().add(0f);
myGradient.getPosition().add(0.5f);
myGradient.getPosition().add(1f);
myGradient.getFactor().add(0f);
myGradient.getFactor().add(0.5f);
myGradient.getFactor().add(1f);
myGradient.setAngle((short)45);
chart1.setChartBackground(myGradient);
chart1.setForeColor(new java.awt.Color(255,255,255,255));
PopulateSouthAmericaPopulation(chart1);
chart1.setGallery(Gallery.BAR);
chart1.getLegendBox().setVisible(false);
chart1.getTitles().add(new TitleDockable("South American Countries Population"));
chart1.getAxisY().setScaleUnit(1000000);
chart1.getAxisY().getTitle().setText("(in Millions)");
public static void PopulateSouthAmericaPopulation(Chart chart1) { SouthAmericaPopulation[] data = new SouthAmericaPopulation[]{ new SouthAmericaPopulation("Brazil", 201033000), new SouthAmericaPopulation("Colombia", 47130000), new SouthAmericaPopulation("Argentina", 41350000), new SouthAmericaPopulation("Peru", 30476000), new SouthAmericaPopulation("Venezuela", 29760000), new SouthAmericaPopulation("Chile", 16841000), new SouthAmericaPopulation("Ecuador", 15779000), new SouthAmericaPopulation("Bolivia", 10517000) }; ObjectProvider objProvider = new ObjectProvider(data); chart1.getDataSourceSettings().setDataSource(objProvider); }
public static class SouthAmericaPopulation { public SouthAmericaPopulation(String country, double population) { this.setCountry(country); this.setPopulation(population); } private String privateCountry; public final String getCountry() { return privateCountry; } public final void setCountry(String value) { privateCountry = value; } private double privatePopulation; public final double getPopulation() { return privatePopulation; } public final void setPopulation(double value) { privatePopulation = value; } }
public static class Countries { public Countries(String country, double lei, double gdppc, java.awt.Image flag) { this.setCountry(country); this.setLEI(lei); this.setGDPPC(gdppc); this.setFlag(flag); } private String privateCountry; public final String getCountry() { return privateCountry; } public final void setCountry(String value) { privateCountry = value; } private double privateLEI; public final double getLEI() { return privateLEI; } public final void setLEI(double value) { privateLEI = value; } private double privateGDPPC; public final double getGDPPC() { return privateGDPPC; } public final void setGDPPC(double value) { privateGDPPC = value; } private java.awt.Image privateFlag; public final java.awt.Image getFlag() { return privateFlag; } public final void setFlag(java.awt.Image value) { privateFlag = value; } }
The second has been set to 120 degrees:
GradientBackground myGradient;
myGradient = new GradientBackground(GradientType.ANGLED);
myGradient.getColors().add(new java.awt.Color(0,0,255,255));
myGradient.getPosition().add(0f);
myGradient.getPosition().add(0.5f);
myGradient.getPosition().add(1f);
myGradient.getFactor().add(0f);
myGradient.getFactor().add(0.5f);
myGradient.getFactor().add(1f);
myGradient.setAngle((short)120);
chart1.setChartBackground(myGradient);
chart1.setForeColor(new java.awt.Color(255,255,255,255));
PopulateSouthAmericaPopulation(chart1);
chart1.setGallery(Gallery.BAR);
chart1.getLegendBox().setVisible(false);
chart1.getTitles().add(new TitleDockable("South American Countries Population"));
chart1.getAxisY().setScaleUnit(1000000);
chart1.getAxisY().getTitle().setText("(in Millions)");
public static void PopulateSouthAmericaPopulation(Chart chart1) { SouthAmericaPopulation[] data = new SouthAmericaPopulation[]{ new SouthAmericaPopulation("Brazil", 201033000), new SouthAmericaPopulation("Colombia", 47130000), new SouthAmericaPopulation("Argentina", 41350000), new SouthAmericaPopulation("Peru", 30476000), new SouthAmericaPopulation("Venezuela", 29760000), new SouthAmericaPopulation("Chile", 16841000), new SouthAmericaPopulation("Ecuador", 15779000), new SouthAmericaPopulation("Bolivia", 10517000) }; ObjectProvider objProvider = new ObjectProvider(data); chart1.getDataSourceSettings().setDataSource(objProvider); }
public static class SouthAmericaPopulation { public SouthAmericaPopulation(String country, double population) { this.setCountry(country); this.setPopulation(population); } private String privateCountry; public final String getCountry() { return privateCountry; } public final void setCountry(String value) { privateCountry = value; } private double privatePopulation; public final double getPopulation() { return privatePopulation; } public final void setPopulation(double value) { privatePopulation = value; } }
public static class Countries { public Countries(String country, double lei, double gdppc, java.awt.Image flag) { this.setCountry(country); this.setLEI(lei); this.setGDPPC(gdppc); this.setFlag(flag); } private String privateCountry; public final String getCountry() { return privateCountry; } public final void setCountry(String value) { privateCountry = value; } private double privateLEI; public final double getLEI() { return privateLEI; } public final void setLEI(double value) { privateLEI = value; } private double privateGDPPC; public final double getGDPPC() { return privateGDPPC; } public final void setGDPPC(double value) { privateGDPPC = value; } private java.awt.Image privateFlag; public final java.awt.Image getFlag() { return privateFlag; } public final void setFlag(java.awt.Image value) { privateFlag = value; } }
resetAngle
public void setAngle(float value)
Sets the gradient angle when using the 'Angled' gradient background.
The setAngle
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 border chart gradient has been set to 45 degrees:
GradientBackground myGradient;
myGradient = new GradientBackground(GradientType.ANGLED);
myGradient.getColors().add(new java.awt.Color(0,0,255,255));
myGradient.getPosition().add(0f);
myGradient.getPosition().add(0.5f);
myGradient.getPosition().add(1f);
myGradient.getFactor().add(0f);
myGradient.getFactor().add(0.5f);
myGradient.getFactor().add(1f);
myGradient.setAngle((short)45);
chart1.setChartBackground(myGradient);
chart1.setForeColor(new java.awt.Color(255,255,255,255));
PopulateSouthAmericaPopulation(chart1);
chart1.setGallery(Gallery.BAR);
chart1.getLegendBox().setVisible(false);
chart1.getTitles().add(new TitleDockable("South American Countries Population"));
chart1.getAxisY().setScaleUnit(1000000);
chart1.getAxisY().getTitle().setText("(in Millions)");
public static void PopulateSouthAmericaPopulation(Chart chart1) { SouthAmericaPopulation[] data = new SouthAmericaPopulation[]{ new SouthAmericaPopulation("Brazil", 201033000), new SouthAmericaPopulation("Colombia", 47130000), new SouthAmericaPopulation("Argentina", 41350000), new SouthAmericaPopulation("Peru", 30476000), new SouthAmericaPopulation("Venezuela", 29760000), new SouthAmericaPopulation("Chile", 16841000), new SouthAmericaPopulation("Ecuador", 15779000), new SouthAmericaPopulation("Bolivia", 10517000) }; ObjectProvider objProvider = new ObjectProvider(data); chart1.getDataSourceSettings().setDataSource(objProvider); }
public static class SouthAmericaPopulation { public SouthAmericaPopulation(String country, double population) { this.setCountry(country); this.setPopulation(population); } private String privateCountry; public final String getCountry() { return privateCountry; } public final void setCountry(String value) { privateCountry = value; } private double privatePopulation; public final double getPopulation() { return privatePopulation; } public final void setPopulation(double value) { privatePopulation = value; } }
public static class Countries { public Countries(String country, double lei, double gdppc, java.awt.Image flag) { this.setCountry(country); this.setLEI(lei); this.setGDPPC(gdppc); this.setFlag(flag); } private String privateCountry; public final String getCountry() { return privateCountry; } public final void setCountry(String value) { privateCountry = value; } private double privateLEI; public final double getLEI() { return privateLEI; } public final void setLEI(double value) { privateLEI = value; } private double privateGDPPC; public final double getGDPPC() { return privateGDPPC; } public final void setGDPPC(double value) { privateGDPPC = value; } private java.awt.Image privateFlag; public final java.awt.Image getFlag() { return privateFlag; } public final void setFlag(java.awt.Image value) { privateFlag = value; } }
The second has been set to 120 degrees:
GradientBackground myGradient;
myGradient = new GradientBackground(GradientType.ANGLED);
myGradient.getColors().add(new java.awt.Color(0,0,255,255));
myGradient.getPosition().add(0f);
myGradient.getPosition().add(0.5f);
myGradient.getPosition().add(1f);
myGradient.getFactor().add(0f);
myGradient.getFactor().add(0.5f);
myGradient.getFactor().add(1f);
myGradient.setAngle((short)120);
chart1.setChartBackground(myGradient);
chart1.setForeColor(new java.awt.Color(255,255,255,255));
PopulateSouthAmericaPopulation(chart1);
chart1.setGallery(Gallery.BAR);
chart1.getLegendBox().setVisible(false);
chart1.getTitles().add(new TitleDockable("South American Countries Population"));
chart1.getAxisY().setScaleUnit(1000000);
chart1.getAxisY().getTitle().setText("(in Millions)");
public static void PopulateSouthAmericaPopulation(Chart chart1) { SouthAmericaPopulation[] data = new SouthAmericaPopulation[]{ new SouthAmericaPopulation("Brazil", 201033000), new SouthAmericaPopulation("Colombia", 47130000), new SouthAmericaPopulation("Argentina", 41350000), new SouthAmericaPopulation("Peru", 30476000), new SouthAmericaPopulation("Venezuela", 29760000), new SouthAmericaPopulation("Chile", 16841000), new SouthAmericaPopulation("Ecuador", 15779000), new SouthAmericaPopulation("Bolivia", 10517000) }; ObjectProvider objProvider = new ObjectProvider(data); chart1.getDataSourceSettings().setDataSource(objProvider); }
public static class SouthAmericaPopulation { public SouthAmericaPopulation(String country, double population) { this.setCountry(country); this.setPopulation(population); } private String privateCountry; public final String getCountry() { return privateCountry; } public final void setCountry(String value) { privateCountry = value; } private double privatePopulation; public final double getPopulation() { return privatePopulation; } public final void setPopulation(double value) { privatePopulation = value; } }
public static class Countries { public Countries(String country, double lei, double gdppc, java.awt.Image flag) { this.setCountry(country); this.setLEI(lei); this.setGDPPC(gdppc); this.setFlag(flag); } private String privateCountry; public final String getCountry() { return privateCountry; } public final void setCountry(String value) { privateCountry = value; } private double privateLEI; public final double getLEI() { return privateLEI; } public final void setLEI(double value) { privateLEI = value; } private double privateGDPPC; public final double getGDPPC() { return privateGDPPC; } public final void setGDPPC(double value) { privateGDPPC = value; } private java.awt.Image privateFlag; public final java.awt.Image getFlag() { return privateFlag; } public final void setFlag(java.awt.Image value) { privateFlag = value; } }
value
- resetAngle
public java.awt.Color getColorFrom()
Gets or 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 setColors
method using index zero.
Set the starting color of the gradient object 'myGradient' to red:
myGradient.setColorFrom(new java.awt.Color(255,0,0,255));
public void setColorFrom(java.awt.Color value)
Gets or 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 setColors
method using index zero.
Set the starting color of the gradient object 'myGradient' to red:
myGradient.setColorFrom(new java.awt.Color(255,0,0,255));
value
- public java.awt.Color getColorTo()
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 setColors
collection.
Set the ending color of the gradient object 'myGradient' to green:
myGradient.setColorTo(new java.awt.Color(0,128,0,255));
public void setColorTo(java.awt.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 setColors
collection.
Set the ending color of the gradient object 'myGradient' to green:
myGradient.setColorTo(new java.awt.Color(0,128,0,255));
value
- public java.util.List<java.awt.Color> getColors()
GradientBackground myGradient; myGradient = new GradientBackground(GradientType.RADIAL); myGradient.getColors().set(0, new java.awt.Color(0,0,255,255)); myGradient.getColors().set(1, new java.awt.Color(255,255,255,255));
public int getEffectArea()
myGradient.setEffectArea(50);
resetEffectArea
public void setEffectArea(int value)
myGradient.setEffectArea(50);
value
- resetEffectArea
public java.util.List<java.lang.Float> getFactor()
public java.util.List<java.lang.Float> getPosition()
public GradientType getType()
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
method.
Below is a gradient of type "BackwardDiagonal":
GradientBackground myGradient;
myGradient = new GradientBackground(GradientType.BACKWARD_DIAGONAL);
myGradient.getColors().add(new java.awt.Color(0,0,255,255));
chart1.setChartBackground(myGradient);
chart1.setForeColor(new java.awt.Color(0,0,0,255));
PopulateSouthAmericaPopulation(chart1);
chart1.setGallery(Gallery.BAR);
chart1.getLegendBox().setVisible(false);
chart1.getTitles().add(new TitleDockable("South American Countries Population"));
chart1.getAxisY().setScaleUnit(1000000);
chart1.getAxisY().getTitle().setText("(in Millions)");
public static void PopulateSouthAmericaPopulation(Chart chart1) { SouthAmericaPopulation[] data = new SouthAmericaPopulation[]{ new SouthAmericaPopulation("Brazil", 201033000), new SouthAmericaPopulation("Colombia", 47130000), new SouthAmericaPopulation("Argentina", 41350000), new SouthAmericaPopulation("Peru", 30476000), new SouthAmericaPopulation("Venezuela", 29760000), new SouthAmericaPopulation("Chile", 16841000), new SouthAmericaPopulation("Ecuador", 15779000), new SouthAmericaPopulation("Bolivia", 10517000) }; ObjectProvider objProvider = new ObjectProvider(data); chart1.getDataSourceSettings().setDataSource(objProvider); }
public static class SouthAmericaPopulation { public SouthAmericaPopulation(String country, double population) { this.setCountry(country); this.setPopulation(population); } private String privateCountry; public final String getCountry() { return privateCountry; } public final void setCountry(String value) { privateCountry = value; } private double privatePopulation; public final double getPopulation() { return privatePopulation; } public final void setPopulation(double value) { privatePopulation = value; } }
public static class Countries { public Countries(String country, double lei, double gdppc, java.awt.Image flag) { this.setCountry(country); this.setLEI(lei); this.setGDPPC(gdppc); this.setFlag(flag); } private String privateCountry; public final String getCountry() { return privateCountry; } public final void setCountry(String value) { privateCountry = value; } private double privateLEI; public final double getLEI() { return privateLEI; } public final void setLEI(double value) { privateLEI = value; } private double privateGDPPC; public final double getGDPPC() { return privateGDPPC; } public final void setGDPPC(double value) { privateGDPPC = value; } private java.awt.Image privateFlag; public final java.awt.Image getFlag() { return privateFlag; } public final void setFlag(java.awt.Image value) { privateFlag = value; } }
Alternatively, this is a gradient of type "Radial":
GradientBackground myGradient;
myGradient = new GradientBackground(GradientType.RADIAL);
/* END RELEVABT CODE *\/
myGradient.getColors().add(new java.awt.Color(0,0,255,255));
chart1.setChartBackground(myGradient);
chart1.setForeColor(new java.awt.Color(255,255,255,255));
PopulateSouthAmericaPopulation(chart1);
chart1.setGallery(Gallery.BAR);
chart1.getLegendBox().setVisible(false);
chart1.getTitles().add(new TitleDockable("South American Countries Population"));
chart1.getAxisY().setScaleUnit(1000000);
chart1.getAxisY().getTitle().setText("(in Millions)");
public static void PopulateSouthAmericaPopulation(Chart chart1) { SouthAmericaPopulation[] data = new SouthAmericaPopulation[]{ new SouthAmericaPopulation("Brazil", 201033000), new SouthAmericaPopulation("Colombia", 47130000), new SouthAmericaPopulation("Argentina", 41350000), new SouthAmericaPopulation("Peru", 30476000), new SouthAmericaPopulation("Venezuela", 29760000), new SouthAmericaPopulation("Chile", 16841000), new SouthAmericaPopulation("Ecuador", 15779000), new SouthAmericaPopulation("Bolivia", 10517000) }; ObjectProvider objProvider = new ObjectProvider(data); chart1.getDataSourceSettings().setDataSource(objProvider); }
public static class SouthAmericaPopulation { public SouthAmericaPopulation(String country, double population) { this.setCountry(country); this.setPopulation(population); } private String privateCountry; public final String getCountry() { return privateCountry; } public final void setCountry(String value) { privateCountry = value; } private double privatePopulation; public final double getPopulation() { return privatePopulation; } public final void setPopulation(double value) { privatePopulation = value; } }
public static class Countries { public Countries(String country, double lei, double gdppc, java.awt.Image flag) { this.setCountry(country); this.setLEI(lei); this.setGDPPC(gdppc); this.setFlag(flag); } private String privateCountry; public final String getCountry() { return privateCountry; } public final void setCountry(String value) { privateCountry = value; } private double privateLEI; public final double getLEI() { return privateLEI; } public final void setLEI(double value) { privateLEI = value; } private double privateGDPPC; public final double getGDPPC() { return privateGDPPC; } public final void setGDPPC(double value) { privateGDPPC = value; } private java.awt.Image privateFlag; public final java.awt.Image getFlag() { return privateFlag; } public final void setFlag(java.awt.Image value) { privateFlag = value; } }
Finally, this is a gradient of type "Vertical":
GradientBackground myGradient;
myGradient = new GradientBackground(GradientType.VERTICAL);
/* END RELEVABT CODE *\/
myGradient.getColors().add(new java.awt.Color(0,0,255,255));
chart1.setChartBackground(myGradient);
chart1.setForeColor(new java.awt.Color(0,0,0,255));
PopulateSouthAmericaPopulation(chart1);
chart1.setGallery(Gallery.BAR);
chart1.getLegendBox().setVisible(false);
chart1.getTitles().add(new TitleDockable("South American Countries Population"));
chart1.getAxisY().setScaleUnit(1000000);
chart1.getAxisY().getTitle().setText("(in Millions)");
public static void PopulateSouthAmericaPopulation(Chart chart1) { SouthAmericaPopulation[] data = new SouthAmericaPopulation[]{ new SouthAmericaPopulation("Brazil", 201033000), new SouthAmericaPopulation("Colombia", 47130000), new SouthAmericaPopulation("Argentina", 41350000), new SouthAmericaPopulation("Peru", 30476000), new SouthAmericaPopulation("Venezuela", 29760000), new SouthAmericaPopulation("Chile", 16841000), new SouthAmericaPopulation("Ecuador", 15779000), new SouthAmericaPopulation("Bolivia", 10517000) }; ObjectProvider objProvider = new ObjectProvider(data); chart1.getDataSourceSettings().setDataSource(objProvider); }
public static class SouthAmericaPopulation { public SouthAmericaPopulation(String country, double population) { this.setCountry(country); this.setPopulation(population); } private String privateCountry; public final String getCountry() { return privateCountry; } public final void setCountry(String value) { privateCountry = value; } private double privatePopulation; public final double getPopulation() { return privatePopulation; } public final void setPopulation(double value) { privatePopulation = value; } }
public static class Countries { public Countries(String country, double lei, double gdppc, java.awt.Image flag) { this.setCountry(country); this.setLEI(lei); this.setGDPPC(gdppc); this.setFlag(flag); } private String privateCountry; public final String getCountry() { return privateCountry; } public final void setCountry(String value) { privateCountry = value; } private double privateLEI; public final double getLEI() { return privateLEI; } public final void setLEI(double value) { privateLEI = value; } private double privateGDPPC; public final double getGDPPC() { return privateGDPPC; } public final void setGDPPC(double value) { privateGDPPC = value; } private java.awt.Image privateFlag; public final java.awt.Image getFlag() { return privateFlag; } public final void setFlag(java.awt.Image value) { privateFlag = value; } }
resetType
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
method.
Below is a gradient of type "BackwardDiagonal":
GradientBackground myGradient;
myGradient = new GradientBackground(GradientType.BACKWARD_DIAGONAL);
myGradient.getColors().add(new java.awt.Color(0,0,255,255));
chart1.setChartBackground(myGradient);
chart1.setForeColor(new java.awt.Color(0,0,0,255));
PopulateSouthAmericaPopulation(chart1);
chart1.setGallery(Gallery.BAR);
chart1.getLegendBox().setVisible(false);
chart1.getTitles().add(new TitleDockable("South American Countries Population"));
chart1.getAxisY().setScaleUnit(1000000);
chart1.getAxisY().getTitle().setText("(in Millions)");
public static void PopulateSouthAmericaPopulation(Chart chart1) { SouthAmericaPopulation[] data = new SouthAmericaPopulation[]{ new SouthAmericaPopulation("Brazil", 201033000), new SouthAmericaPopulation("Colombia", 47130000), new SouthAmericaPopulation("Argentina", 41350000), new SouthAmericaPopulation("Peru", 30476000), new SouthAmericaPopulation("Venezuela", 29760000), new SouthAmericaPopulation("Chile", 16841000), new SouthAmericaPopulation("Ecuador", 15779000), new SouthAmericaPopulation("Bolivia", 10517000) }; ObjectProvider objProvider = new ObjectProvider(data); chart1.getDataSourceSettings().setDataSource(objProvider); }
public static class SouthAmericaPopulation { public SouthAmericaPopulation(String country, double population) { this.setCountry(country); this.setPopulation(population); } private String privateCountry; public final String getCountry() { return privateCountry; } public final void setCountry(String value) { privateCountry = value; } private double privatePopulation; public final double getPopulation() { return privatePopulation; } public final void setPopulation(double value) { privatePopulation = value; } }
public static class Countries { public Countries(String country, double lei, double gdppc, java.awt.Image flag) { this.setCountry(country); this.setLEI(lei); this.setGDPPC(gdppc); this.setFlag(flag); } private String privateCountry; public final String getCountry() { return privateCountry; } public final void setCountry(String value) { privateCountry = value; } private double privateLEI; public final double getLEI() { return privateLEI; } public final void setLEI(double value) { privateLEI = value; } private double privateGDPPC; public final double getGDPPC() { return privateGDPPC; } public final void setGDPPC(double value) { privateGDPPC = value; } private java.awt.Image privateFlag; public final java.awt.Image getFlag() { return privateFlag; } public final void setFlag(java.awt.Image value) { privateFlag = value; } }
Alternatively, this is a gradient of type "Radial":
GradientBackground myGradient;
myGradient = new GradientBackground(GradientType.RADIAL);
/* END RELEVABT CODE *\/
myGradient.getColors().add(new java.awt.Color(0,0,255,255));
chart1.setChartBackground(myGradient);
chart1.setForeColor(new java.awt.Color(255,255,255,255));
PopulateSouthAmericaPopulation(chart1);
chart1.setGallery(Gallery.BAR);
chart1.getLegendBox().setVisible(false);
chart1.getTitles().add(new TitleDockable("South American Countries Population"));
chart1.getAxisY().setScaleUnit(1000000);
chart1.getAxisY().getTitle().setText("(in Millions)");
public static void PopulateSouthAmericaPopulation(Chart chart1) { SouthAmericaPopulation[] data = new SouthAmericaPopulation[]{ new SouthAmericaPopulation("Brazil", 201033000), new SouthAmericaPopulation("Colombia", 47130000), new SouthAmericaPopulation("Argentina", 41350000), new SouthAmericaPopulation("Peru", 30476000), new SouthAmericaPopulation("Venezuela", 29760000), new SouthAmericaPopulation("Chile", 16841000), new SouthAmericaPopulation("Ecuador", 15779000), new SouthAmericaPopulation("Bolivia", 10517000) }; ObjectProvider objProvider = new ObjectProvider(data); chart1.getDataSourceSettings().setDataSource(objProvider); }
public static class SouthAmericaPopulation { public SouthAmericaPopulation(String country, double population) { this.setCountry(country); this.setPopulation(population); } private String privateCountry; public final String getCountry() { return privateCountry; } public final void setCountry(String value) { privateCountry = value; } private double privatePopulation; public final double getPopulation() { return privatePopulation; } public final void setPopulation(double value) { privatePopulation = value; } }
public static class Countries { public Countries(String country, double lei, double gdppc, java.awt.Image flag) { this.setCountry(country); this.setLEI(lei); this.setGDPPC(gdppc); this.setFlag(flag); } private String privateCountry; public final String getCountry() { return privateCountry; } public final void setCountry(String value) { privateCountry = value; } private double privateLEI; public final double getLEI() { return privateLEI; } public final void setLEI(double value) { privateLEI = value; } private double privateGDPPC; public final double getGDPPC() { return privateGDPPC; } public final void setGDPPC(double value) { privateGDPPC = value; } private java.awt.Image privateFlag; public final java.awt.Image getFlag() { return privateFlag; } public final void setFlag(java.awt.Image value) { privateFlag = value; } }
Finally, this is a gradient of type "Vertical":
GradientBackground myGradient;
myGradient = new GradientBackground(GradientType.VERTICAL);
/* END RELEVABT CODE *\/
myGradient.getColors().add(new java.awt.Color(0,0,255,255));
chart1.setChartBackground(myGradient);
chart1.setForeColor(new java.awt.Color(0,0,0,255));
PopulateSouthAmericaPopulation(chart1);
chart1.setGallery(Gallery.BAR);
chart1.getLegendBox().setVisible(false);
chart1.getTitles().add(new TitleDockable("South American Countries Population"));
chart1.getAxisY().setScaleUnit(1000000);
chart1.getAxisY().getTitle().setText("(in Millions)");
public static void PopulateSouthAmericaPopulation(Chart chart1) { SouthAmericaPopulation[] data = new SouthAmericaPopulation[]{ new SouthAmericaPopulation("Brazil", 201033000), new SouthAmericaPopulation("Colombia", 47130000), new SouthAmericaPopulation("Argentina", 41350000), new SouthAmericaPopulation("Peru", 30476000), new SouthAmericaPopulation("Venezuela", 29760000), new SouthAmericaPopulation("Chile", 16841000), new SouthAmericaPopulation("Ecuador", 15779000), new SouthAmericaPopulation("Bolivia", 10517000) }; ObjectProvider objProvider = new ObjectProvider(data); chart1.getDataSourceSettings().setDataSource(objProvider); }
public static class SouthAmericaPopulation { public SouthAmericaPopulation(String country, double population) { this.setCountry(country); this.setPopulation(population); } private String privateCountry; public final String getCountry() { return privateCountry; } public final void setCountry(String value) { privateCountry = value; } private double privatePopulation; public final double getPopulation() { return privatePopulation; } public final void setPopulation(double value) { privatePopulation = value; } }
public static class Countries { public Countries(String country, double lei, double gdppc, java.awt.Image flag) { this.setCountry(country); this.setLEI(lei); this.setGDPPC(gdppc); this.setFlag(flag); } private String privateCountry; public final String getCountry() { return privateCountry; } public final void setCountry(String value) { privateCountry = value; } private double privateLEI; public final double getLEI() { return privateLEI; } public final void setLEI(double value) { privateLEI = value; } private double privateGDPPC; public final double getGDPPC() { return privateGDPPC; } public final void setGDPPC(double value) { privateGDPPC = value; } private java.awt.Image privateFlag; public final java.awt.Image getFlag() { return privateFlag; } public final void setFlag(java.awt.Image value) { privateFlag = value; } }
value
- resetType
public void resetAngle()
setAngle
public void resetEffectArea()
setEffectArea
public void resetType()
setType
2014 Software FX, Inc. All Rights Reserved. Chart FX is a registered trademark of Software FX, Inc
All other names are trademarks or registered trademarks of their respective owners.