Java Swing O Reilly There’s (Ecommerce web host) not much mystery
Java Swing O Reilly There’s not much mystery here. Except for the two abstract methods, these methods just maintain various simple properties of ChartPainter: the colors used for painting, the font, and the labels and values for the chart. The real work takes place in the PieChartPainter class, which provides the implementation of the indexOfEntryAt() and paint() methods. The indexOfEntryAt() method allows our TableChart class to figure out which tooltip to show. The paint() method allows us to draw a pie chart of our data. // PieChartPainter.java // A pie chart implementation of the ChartPainter class. // import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.plaf.*; public class PieChartPainter extends ChartPainter { protected static PieChartPainter chartUI = new PieChartPainter(); protected int originX, originY; protected int radius; private static double piby2 = Math.PI / 2.0; private static double twopi = Math.PI * 2.0; private static double d2r = Math.PI / 180.0; // degrees to radians. public int indexOfEntryAt(MouseEvent me) { int x = me.getX() - originX; int y = originY - me.getY(); // upside down coordinate system. // is (x,y) in the circle? if (Math.sqrt(x*x + y*y) > radius) { return -1; } double percent = Math.atan2(Math.abs(y), Math.abs(x)); if (x >= 0) { if (y <= 0) { // (IV) percent = (piby2 - percent) + 3 * piby2; // (IV) } } else { if (y >= 0) { // (II) percent = Math.PI - percent; } else { // (III) percent = Math.PI + percent; } } percent /= twopi; double t = 0.0; if (values != null) { for (int i = 0; i < values.length; i++) { if (t + values[i] > percent) { return i; } t += values[i]; } - 464 -
From our experience, we are can tell you that you can find a reliable and cheap webhost service at Java Web Hosting services.