public class DimColorEffect extends AttributeEffect
The members of the DimColorEffect class allow developers to set visual effects to the points in the chart that meet the criteria of the ConditionalAttributes.
When a Conditional Attribute is set to the chart, you can apply some effects to the points in that range. For example, below is a chart with a conditional section between March and October. The color of the bars in this range has been decolorized using the Alpha method:
PopulateProductSales(chart1); DimColorEffect dimColorEffect; dimColorEffect = new DimColorEffect(); dimColorEffect.setAlpha(100); dimColorEffect.setUseTranslucency(false); AxisSection sect; sect = new AxisSection(((AxisSectionValue)3.0), ((AxisSectionValue)10.0), new java.awt.Color(230,230,250,255)); chart1.getAxisX().getSections().add(sect); ConditionalAttributes condition; condition = new ConditionalAttributes(); SectionCondition sectionCond; sectionCond = new SectionCondition(sect); sectionCond.setDataElement(DataElement.XValue); condition.setCondition(sectionCond); condition.getEffects().add(((AttributeEffect)dimColorEffect)); chart1.getConditionalAttributes().add((condition)); chart1.getTitles().add(new TitleDockable("Wine Sales by Type")); chart1.setGallery(Gallery.BAR); chart1.getAxisY().getGrids().getMajor().setVisible(false); chart1.getAxisY().getLabelsFormat().setFormat(AxisFormat.CURRENCY);
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; } }
Constructor and Description |
---|
DimColorEffect()
Constructs a newly allocated DimColorEffect object
|
Modifier and Type | Method and Description |
---|---|
int |
getAlpha()
Allows you customize the Alpha component of the color of the selected points.
|
boolean |
isUseTranslucency()
Allows you choose whether to use transparency or not in the selected points.
|
void |
resetAlpha()
Set the property Alpha to its default value.
|
void |
resetUseTranslucency()
Set the property UseTranslucency to its default value.
|
void |
setAlpha(int value)
Allows you customize the Alpha component of the color of the selected points.
|
void |
setUseTranslucency(boolean value)
Allows you choose whether to use transparency or not in the selected points.
|
public DimColorEffect()
public int getAlpha()
Allows you customize the Alpha component of the color of the selected points.
The Alpha component accepts values from 0 to 255.
The Alpha component determines the opacity of the color. When the Alpha is set to 0, the color is fully transparent, whereas an Alpha component of 255 gives a fully opaque color.
Below, the selected points have an Alpha value set to 80:
DimColorEffect dimColorEffect; dimColorEffect = new DimColorEffect(); dimColorEffect.setAlpha(80);
The same points, with an Alpha component set to 180:
DimColorEffect dimColorEffect; dimColorEffect = new DimColorEffect(); dimColorEffect.setAlpha(180);
resetAlpha
public void setAlpha(int value)
Allows you customize the Alpha component of the color of the selected points.
The Alpha component accepts values from 0 to 255.
The Alpha component determines the opacity of the color. When the Alpha is set to 0, the color is fully transparent, whereas an Alpha component of 255 gives a fully opaque color.
Below, the selected points have an Alpha value set to 80:
DimColorEffect dimColorEffect; dimColorEffect = new DimColorEffect(); dimColorEffect.setAlpha(80);
The same points, with an Alpha component set to 180:
DimColorEffect dimColorEffect; dimColorEffect = new DimColorEffect(); dimColorEffect.setAlpha(180);
value
- resetAlpha
public boolean isUseTranslucency()
Allows you choose whether to use transparency or not in the selected points.
When this method is set to true, and the Alpha component is close to 0, the points will become transparent. On the contrary. if the Alpha component is close to 0 but this method is set to false, the points will be pale.
Below, the selected points have an Alpha component of 50, and UseTranslucency is set to true. You can see that grid lines in the Y axis are visible through the bars:
DimColorEffect dimColorEffect;
dimColorEffect = new DimColorEffect();
dimColorEffect.setAlpha(50);
dimColorEffect.setUseTranslucency(true);
However, when UseTranslucency is set to false, you can see that the points are drawn with a solid pale color:
DimColorEffect dimColorEffect;
dimColorEffect = new DimColorEffect();
dimColorEffect.setAlpha(50);
dimColorEffect.setUseTranslucency(false);
resetUseTranslucency
public void setUseTranslucency(boolean value)
Allows you choose whether to use transparency or not in the selected points.
When this method is set to true, and the Alpha component is close to 0, the points will become transparent. On the contrary. if the Alpha component is close to 0 but this method is set to false, the points will be pale.
Below, the selected points have an Alpha component of 50, and UseTranslucency is set to true. You can see that grid lines in the Y axis are visible through the bars:
DimColorEffect dimColorEffect;
dimColorEffect = new DimColorEffect();
dimColorEffect.setAlpha(50);
dimColorEffect.setUseTranslucency(true);
However, when UseTranslucency is set to false, you can see that the points are drawn with a solid pale color:
DimColorEffect dimColorEffect;
dimColorEffect = new DimColorEffect();
dimColorEffect.setAlpha(50);
dimColorEffect.setUseTranslucency(false);
value
- resetUseTranslucency
public void resetAlpha()
setAlpha
public void resetUseTranslucency()
isUseTranslucency
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.