java.awt
classes: Color
, Font
, BasicStroke
and Ellipse2D
.1 Color
This class is used to encapsulate colors in the default sRGB color space. Every color has an implicit alpha value of 1.0 or an explicit one provided in the constructor. The alpha value defines the transparency of a color and can be represented by a float value in the range 0.0 - 1.0 or 0 - 255.
The following constructors represent the same color:
let color1 = Ax.awt.Color.BLUE; let color2 = new Ax.awt.Color(0x0000FF) // RGB in hexadecimal let color3 = new Ax.awt.Color(0, 0, 255) // using RGB let color4 = new Ax.awt.Color(0, 0, 255, 255) // using RGBA = RGB + alpha
1.1 Example
In this example the Color
library is used to set the pie slices' colors.
var factory = new Ax.chart.Factory(); // Set colors factory.setColors( Ax.awt.Color.BLUE, Ax.awt.Color.RED, Ax.awt.Color.GREEN, Ax.awt.Color.ORANGE, Ax.awt.Color.YELLOW, Ax.awt.Color.CYAN, Ax.awt.Color.PINK, Ax.awt.Color.MAGENTA, Ax.awt.Color.GRAY ); var chart = factory.createPieChart("Simple pie", dataset => { dataset.setValue("Apache", 52); dataset.setValue("Nginx", 31); dataset.setValue("IIS", 12); dataset.setValue("LiteSpeed", 2); dataset.setValue("Google server", 1); dataset.setValue("Others", 2); }); return chart.toPNG(640, 400);

2 Font
This class represents fonts, which are used to render text in a visible way.
The class has the following constructor:
let font1 = new Ax.awt.Font("SansSerif", Ax.awt.Font.PLAIN, 9) // font family, font style, font size let font2 = new Ax.awt.Font("SansSerif", Ax.awt.Font.ITALIC + Ax.awt.Font.BOLD, 10);
2.1 Example
In the following example Font
is used to set the charts labels' font.
var factory = new Ax.chart.Factory(); var chart = factory.createMultiPieChart("Simple pie", dataset => { var data = [ [ 3.0, 4.0, 3.0, 5.0 ], [ 5.0, 7.0, 6.0, 8.0 ], [ 5.0, 7.0, 3.0, 8.0 ], [ 1.0, 2.0, 3.0, 4.0 ], [ 2.0, 3.0, 2.0, 3.0 ] ]; dataset.createCategory("Region ", "Sales ", data); }); var multiplepieplot = chart.getPlot(); multiplepieplot.setLimit(0.10000000000000001); var chart1 = multiplepieplot.getPieChart(); var pieplot = chart1.getPlot(); pieplot.setBackgroundPaint(null); pieplot.setOutlineStroke(null); pieplot.setLabelGenerator(new Ax.chart.labels.StandardPieSectionLabelGenerator("{0} ({2})")); pieplot.setMaximumLabelWidth(0.34999999999999998); // Set font pieplot.setLabelFont(new Ax.awt.Font("SansSerif", Ax.awt.Font.PLAIN, 9)); pieplot.setInteriorGap(0.29999999999999999); return chart.toPNG(640, 400);

3 BasicStroke
This class defines a basic set of rendering attributes for the outlines of graphics primitives. Check the final example to see its usage.
This class has a simple constructor:
let outline = new Ax.awt.BasicStroke(3); // stroke width
4 Ellipse2D
This class describes an ellipse that is defined by a framing rectangle. Check the final example to see its usage.
5 Example
This example shows the usage of all four classes.
var factory = new Ax.chart.Factory(); var chart = factory.createLineChart("Java Standard Class Library", "", "Class count", dataset => { dataset.addValue(212, "Classes", "JDK 1.0"); dataset.addValue(504, "Classes", "JDK 1.1"); dataset.addValue(1520, "Classes", "JDK 1.2"); dataset.addValue(1842, "Classes", "JDK 1.3"); dataset.addValue(2991, "Classes", "JDK 1.4"); dataset.addValue(3500, "Classes", "JDK 1.5"); }); chart.addSubtitle(new Ax.chart.title.TextTitle("Number of Classes By Release")); var source = new Ax.chart.title.TextTitle("Source: Java In A Nutshell (5th Edition)"); // Set the title font source.setFont(new Ax.awt.Font("SansSerif", Ax.awt.Font.PLAIN, 10)); source.setPosition(Ax.chart.ui.RectangleEdge.BOTTOM); source.setHorizontalAlignment(Ax.chart.ui.HorizontalAlignment.CENTER); chart.addSubtitle(source); var plot = chart.getPlot(); var renderer = plot.getRenderer(); renderer.setDefaultShapesVisible(true); renderer.setDrawOutlines(true); renderer.setUseFillPaint(true); // Set the background color renderer.setDefaultFillPaint(Ax.awt.Color.white); // Set the series stroke (the widh of the lines) renderer.setSeriesStroke(0, new Ax.awt.BasicStroke(3.0)); // Set the outline stroke (the width of the circles' outline) renderer.setSeriesOutlineStroke(0, new Ax.awt.BasicStroke(2.0)); // Set the series shape (the circles, instead of squares) renderer.setSeriesShape(0, new Ax.awt.geom.Ellipse2D.Double(-5.0, -5.0, 10.0, 10.0)); return chart.toPNG(640, 400);
