public class SolidBackground extends java.lang.Object implements IBackgroundAdornment
The SolidBackground object allows changing the color to the chart's background, using a solid color.
The Color can be changed for either the Chart's background area, or the Chart's plot area, by using the setBackColor
and setPlotAreaColor
methods.
The following image shows an Azure BackColor:
SolidBackground solidBackground;
solidBackground = new SolidBackground();
solidBackground.setColor(new java.awt.Color(240,255,255,255));
chart1.setChartBackground(solidBackground);
PopulatePopulationData(chart1);
chart1.getTitles().add(new TitleDockable("Population Distribution by Gender and Age Range"));
chart1.getAxisY().getTitle().setText("Percentage");
chart1.getAxisX().getTitle().setText("Age Range");
public static void PopulatePopulationData(Chart chart1, String fieldNames) { PopulationData[] data = new PopulationData[]{ new PopulationData("0-4", 10471, 10024), new PopulationData("5-9", 9954, 9512), new PopulationData("10-14", 10670, 10167), new PopulationData("15-19", 10871, 10312), new PopulationData("20-24", 10719, 10178), new PopulationData("25-29", 10060, 9744), new PopulationData("30-34", 10021, 9864), new PopulationData("35-39", 10479, 10424), new PopulationData("40-44", 11294, 11454), new PopulationData("45-49", 11080, 11377), new PopulationData("50-54", 9772, 10212), new PopulationData("55-59", 8415, 8944), new PopulationData("60-64", 6203, 6814), new PopulationData("65-69", 4712, 5412), new PopulationData("70-74", 3804, 4697), new PopulationData("75-79", 3094, 4282), new PopulationData("80-84", 2117, 3459), new PopulationData("85-89", 1072, 2135), new PopulationData("90-94", 397, 1034), new PopulationData("95-99", 91, 321), new PopulationData("100+", 12, 58) }; ObjectProvider objProvider = new ObjectProvider(data); chart1.getDataSourceSettings().setDataSource(objProvider); if (fieldNames != "") { List<DataField> removeFields = new ArrayList<DataField>(); List<String> includeFields = Arrays.asList(fieldNames.split(",")); chart1.getDataSourceSettings().fillFromSchema(); for (DataField dataField : chart1.getDataSourceSettings().getDataFields()) { if (dataField.isMeasure() && !includeFields.contains(dataField.getDataPath())) { removeFields.add(dataField); } } for (DataField dataField : removeFields) { chart1.getDataSourceSettings().getDataFields().remove(dataField); } } } public static void PopulatePopulationData(Chart chart1) { PopulatePopulationData(chart1, ""); }
public static class PopulationData { public PopulationData(String range, double male, double female) { this.setRange(range); this.setMale(male); this.setFemale(female); } private String privateRange; public final String getRange() { return privateRange; } public final void setRange(String value) { privateRange = value; } private double privateMale; public final double getMale() { return privateMale; } public final void setMale(double value) { privateMale = value; } private double privateFemale; public final double getFemale() { return privateFemale; } public final void setFemale(double value) { privateFemale = value; } }
Constructor and Description |
---|
SolidBackground()
Constructs a newly allocated SolidBackground object
|
SolidBackground(java.awt.Color color)
Constructs a newly allocated SolidBackground object
|
Modifier and Type | Method and Description |
---|---|
java.awt.Color |
getColor()
Gets or sets the color of the background.
|
void |
resetColor()
Set the property Color to its default value.
|
void |
setColor(java.awt.Color value)
Gets or sets the color of the background.
|
public SolidBackground()
public SolidBackground(java.awt.Color color)
color
- public java.awt.Color getColor()
Gets or sets the color of the background.
This method is used to set the color of the solid background in a chart. The Chart setChartBackground
is the area behind the ploting area, and is set to LightBlue in the sample:
PopulateProductSales(chart1);
chart1.getTitles().add(new TitleDockable("Wine Sales by Type"));
chart1.getAxisY().getLabelsFormat().setFormat(AxisFormat.CURRENCY);
java.awt.image.BufferedImage bitmap;
bitmap = ((java.awt.image.BufferedImage)new javax.swing.ImageIcon("SFX_logo.jpg"));
ImageBackground b;
b = new ImageBackground();
b.setImage(bitmap);
b.setMode(ImageMode.CENTER);
b.setBackColor(new java.awt.Color(173,216,230,255));
chart1.setChartBackground(b);
chart1.setPlotAreaColor(new java.awt.Color(255,255,255,255));
public static void PopulateProductSales(Chart chart1) { ProductSales[] data = new ProductSales[]{ new ProductSales("Jan", 12560, 23400, 34500), new ProductSales("Feb", 13400, 21000, 38900), new ProductSales("Mar", 16700, 17000, 42100), new ProductSales("Apr", 12000, 19020, 43800), new ProductSales("May", 15800, 26500, 37540), new ProductSales("Jun", 9800, 27800, 32580), new ProductSales("Jul", 17800, 29820, 34000), new ProductSales("Aug", 19800, 17800, 38000), new ProductSales("Sep", 23200, 32000, 41300), new ProductSales("Oct", 16700, 26500, 46590), new ProductSales("Nov", 11800, 23000, 48700), new ProductSales("Dec", 13400, 15400, 49100) }; ObjectProvider objProvider = new ObjectProvider(data); chart1.getDataSourceSettings().setDataSource(objProvider); }
public static class ProductSales { public ProductSales(String month, double white, double red, double sparkling) { this.setMonth(month); this.setWhite(white); this.setRed(red); this.setSparkling(sparkling); } private String privateMonth; public final String getMonth() { return privateMonth; } public final void setMonth(String value) { privateMonth = value; } private double privateWhite; public final double getWhite() { return privateWhite; } public final void setWhite(double value) { privateWhite = value; } private double privateRed; public final double getRed() { return privateRed; } public final void setRed(double value) { privateRed = value; } private double privateSparkling; public final double getSparkling() { return privateSparkling; } public final void setSparkling(double value) { privateSparkling = value; } }
It can also be used to set the color of the ploting area (i.e., setPlotAreaBackground
):
PopulateProductSales(chart1);
chart1.getTitles().add(new TitleDockable("Wine Sales by Type"));
chart1.getAxisY().getLabelsFormat().setFormat(AxisFormat.CURRENCY);
java.awt.image.BufferedImage bitmap;
bitmap = ((java.awt.image.BufferedImage)new javax.swing.ImageIcon("SFX_logo.jpg"));
ImageBackground b;
b = new ImageBackground();
b.setImage(bitmap);
b.setMode(ImageMode.CENTER);
b.setBackColor(new java.awt.Color(255,255,255,255));
chart1.setChartBackground(b);
chart1.setPlotAreaColor(new java.awt.Color(173,216,230,255));
public static void PopulateProductSales(Chart chart1) { ProductSales[] data = new ProductSales[]{ new ProductSales("Jan", 12560, 23400, 34500), new ProductSales("Feb", 13400, 21000, 38900), new ProductSales("Mar", 16700, 17000, 42100), new ProductSales("Apr", 12000, 19020, 43800), new ProductSales("May", 15800, 26500, 37540), new ProductSales("Jun", 9800, 27800, 32580), new ProductSales("Jul", 17800, 29820, 34000), new ProductSales("Aug", 19800, 17800, 38000), new ProductSales("Sep", 23200, 32000, 41300), new ProductSales("Oct", 16700, 26500, 46590), new ProductSales("Nov", 11800, 23000, 48700), new ProductSales("Dec", 13400, 15400, 49100) }; ObjectProvider objProvider = new ObjectProvider(data); chart1.getDataSourceSettings().setDataSource(objProvider); }
public static class ProductSales { public ProductSales(String month, double white, double red, double sparkling) { this.setMonth(month); this.setWhite(white); this.setRed(red); this.setSparkling(sparkling); } private String privateMonth; public final String getMonth() { return privateMonth; } public final void setMonth(String value) { privateMonth = value; } private double privateWhite; public final double getWhite() { return privateWhite; } public final void setWhite(double value) { privateWhite = value; } private double privateRed; public final double getRed() { return privateRed; } public final void setRed(double value) { privateRed = value; } private double privateSparkling; public final double getSparkling() { return privateSparkling; } public final void setSparkling(double value) { privateSparkling = value; } }
resetColor
public void setColor(java.awt.Color value)
Gets or sets the color of the background.
This method is used to set the color of the solid background in a chart. The Chart setChartBackground
is the area behind the ploting area, and is set to LightBlue in the sample:
PopulateProductSales(chart1);
chart1.getTitles().add(new TitleDockable("Wine Sales by Type"));
chart1.getAxisY().getLabelsFormat().setFormat(AxisFormat.CURRENCY);
java.awt.image.BufferedImage bitmap;
bitmap = ((java.awt.image.BufferedImage)new javax.swing.ImageIcon("SFX_logo.jpg"));
ImageBackground b;
b = new ImageBackground();
b.setImage(bitmap);
b.setMode(ImageMode.CENTER);
b.setBackColor(new java.awt.Color(173,216,230,255));
chart1.setChartBackground(b);
chart1.setPlotAreaColor(new java.awt.Color(255,255,255,255));
public static void PopulateProductSales(Chart chart1) { ProductSales[] data = new ProductSales[]{ new ProductSales("Jan", 12560, 23400, 34500), new ProductSales("Feb", 13400, 21000, 38900), new ProductSales("Mar", 16700, 17000, 42100), new ProductSales("Apr", 12000, 19020, 43800), new ProductSales("May", 15800, 26500, 37540), new ProductSales("Jun", 9800, 27800, 32580), new ProductSales("Jul", 17800, 29820, 34000), new ProductSales("Aug", 19800, 17800, 38000), new ProductSales("Sep", 23200, 32000, 41300), new ProductSales("Oct", 16700, 26500, 46590), new ProductSales("Nov", 11800, 23000, 48700), new ProductSales("Dec", 13400, 15400, 49100) }; ObjectProvider objProvider = new ObjectProvider(data); chart1.getDataSourceSettings().setDataSource(objProvider); }
public static class ProductSales { public ProductSales(String month, double white, double red, double sparkling) { this.setMonth(month); this.setWhite(white); this.setRed(red); this.setSparkling(sparkling); } private String privateMonth; public final String getMonth() { return privateMonth; } public final void setMonth(String value) { privateMonth = value; } private double privateWhite; public final double getWhite() { return privateWhite; } public final void setWhite(double value) { privateWhite = value; } private double privateRed; public final double getRed() { return privateRed; } public final void setRed(double value) { privateRed = value; } private double privateSparkling; public final double getSparkling() { return privateSparkling; } public final void setSparkling(double value) { privateSparkling = value; } }
It can also be used to set the color of the ploting area (i.e., setPlotAreaBackground
):
PopulateProductSales(chart1);
chart1.getTitles().add(new TitleDockable("Wine Sales by Type"));
chart1.getAxisY().getLabelsFormat().setFormat(AxisFormat.CURRENCY);
java.awt.image.BufferedImage bitmap;
bitmap = ((java.awt.image.BufferedImage)new javax.swing.ImageIcon("SFX_logo.jpg"));
ImageBackground b;
b = new ImageBackground();
b.setImage(bitmap);
b.setMode(ImageMode.CENTER);
b.setBackColor(new java.awt.Color(255,255,255,255));
chart1.setChartBackground(b);
chart1.setPlotAreaColor(new java.awt.Color(173,216,230,255));
public static void PopulateProductSales(Chart chart1) { ProductSales[] data = new ProductSales[]{ new ProductSales("Jan", 12560, 23400, 34500), new ProductSales("Feb", 13400, 21000, 38900), new ProductSales("Mar", 16700, 17000, 42100), new ProductSales("Apr", 12000, 19020, 43800), new ProductSales("May", 15800, 26500, 37540), new ProductSales("Jun", 9800, 27800, 32580), new ProductSales("Jul", 17800, 29820, 34000), new ProductSales("Aug", 19800, 17800, 38000), new ProductSales("Sep", 23200, 32000, 41300), new ProductSales("Oct", 16700, 26500, 46590), new ProductSales("Nov", 11800, 23000, 48700), new ProductSales("Dec", 13400, 15400, 49100) }; ObjectProvider objProvider = new ObjectProvider(data); chart1.getDataSourceSettings().setDataSource(objProvider); }
public static class ProductSales { public ProductSales(String month, double white, double red, double sparkling) { this.setMonth(month); this.setWhite(white); this.setRed(red); this.setSparkling(sparkling); } private String privateMonth; public final String getMonth() { return privateMonth; } public final void setMonth(String value) { privateMonth = value; } private double privateWhite; public final double getWhite() { return privateWhite; } public final void setWhite(double value) { privateWhite = value; } private double privateRed; public final double getRed() { return privateRed; } public final void setRed(double value) { privateRed = value; } private double privateSparkling; public final double getSparkling() { return privateSparkling; } public final void setSparkling(double value) { privateSparkling = value; } }
value
- resetColor
public void resetColor()
setColor
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.