PenStyle, BrushStyle and FontStyle
In SciChart, almost all styling methods expect an instance of either PenStyle or BrushStyle to be passed in. Those that deals with text styling, expect an instance of a FontStyle. All these classes are designed to hold a relevant information related to drawing.
SciChart also provides a ColorUtil helper class with some color constants and helper methods to work with colors. It can be used for some common conversions and retrieving partial color information.
PenStyle
There are several available PenStyle implementations which allow us to specify how lines should be drawn in SciChart:
- SolidPenStyle - allows to draw 2D lines with solid color.
- LinearGradientPenStyle - allows to draw 2D lines with linear gradient.
- RadialGradientPenStyle - allows to draw 2D lines with radial gradient.
- TexturePenStyle - allows to draw textured 2D lines.
Also, all PenStyle implementations allows to specify the following parameters for a pen:
- color - the pen color.
- antiAliasing - is pen anti-aliased or not.
- thickness - it's thickness.
- strokeDashArray - used to create dashed pens.
To create one of the PenStyle instance, call an appropriate type constructor, for example:
// Solid Pen
SolidPenStyle solidPenStyle = new SolidPenStyle(0xFF99EE99, true, 1, new float[]{10, 3, 10, 3});
// Linear Gradient Pen requires LinearGradientBrushStyle
final LinearGradientPenStyle linearGradientPenStyle = new LinearGradientPenStyle(linearGradientBrush, true, 1f, null);
// Radial Gradient Pen requires RadialGradientBrushStyle
final RadialGradientPenStyle radialGradientPenStyle = new RadialGradientPenStyle(radialGradientBrush, true, 1f, null);
// Texture Pen requires TextureBrushStyle
final TexturePenStyle texturedPenStyle = new TexturePenStyle(textureBrush, true, 1f, null);
BrushStyle
As to the BrushStyle class, it has similar implementations as the PenStyle like the following:
- SolidBrushStyle - allows to draw 2D fills with solid color.
- LinearGradientBrushStyle - allows to draw 2D fills with linear gradient.
- RadialGradientBrushStyle - allows to draw 2D fills with radial gradient.
- TextureBrushStyle - allows to draw 2D fills with textures.
// Solid Brush
final SolidBrushStyle solidBrushStyle = new SolidBrushStyle(Color.RED);
// Linear Gradient Brush
final LinearGradientBrushStyle linearGradientBrush = new LinearGradientBrushStyle(0, 0, 0, 1, Color.RED, Color.BLUE);
// Radial Gradient Brush
final RadialGradientBrushStyle radialGradientBrush = new RadialGradientBrushStyle(0.5f, 0.5f, 0.25f, 0.5f, Color.RED, Color.BLUE);
// Texture Brush - Bitmap with Texture should be provided
final TextureBrushStyle textureBrush = new TextureBrushStyle(texture);
FontStyle
The FontStyle type is designed to hold a relevant information related to text, such as:
- Font style - a Typeface object
- Text size
- Text color
The FontStyle type instances can be created in this way:
Typeface typeface = Typeface.createFromAsset(getActivity().getAssets(), "font/font.ttf");
FontStyle fontStyle = new FontStyle(typeface, 14, ColorUtil.Red, true);