1 import org.faceless.graph2.*; 2 import java.awt.Color ; 3 import java.io.FileOutputStream ; 4 import java.io.IOException ; 5 6 public class BubbleExample 7 { 8 public static void main (String args[]) throws IOException 9 { 10 AxesGraph graph = new AxesGraph(); 13 graph.getAxis(Axis.BOTTOM).setMinValue(0); 14 graph.getAxis(Axis.BOTTOM).setMaxValue(50); 15 graph.getAxis(Axis.LEFT).setMinValue(0); 16 graph.getAxis(Axis.LEFT).setMaxValue(50); 17 graph.setBackWallPaint(null, new Color (194,222,150), Axis.LEFT, Axis.BOTTOM, null); 18 19 BubbleSeries bubbles = new BubbleSeries("bubbles"); 22 23 bubbles.set(10, 10, 4); 24 bubbles.setStyle(10,10, new Style(Color.RED)); 25 26 bubbles.set(5, 43, 5); 27 bubbles.set(42, 16, 3); 28 29 bubbles.set(30, 25, 10); 30 Style s = new Style(Color.YELLOW); 31 s.setBorderColor(new Color (67,136,0)); 32 s.setLineThickness(4); 33 bubbles.setStyle (30,25, s); 34 35 bubbles.set(20, 35, 7); 36 bubbles.setStyle(20,35, new Style(new Color (255,117,205))); 37 38 bubbles.set(40, 22, 7); 39 Style s2 = new Style(new Color (188,129,226)); 40 s2.setBorderColor(new Color (250,123,213)); 41 s2.setLineThickness(2); 42 bubbles.setStyle (40,22, s2); 43 44 graph.addSeries(bubbles); 47 48 graph.addText ("Ice Cream Taste Test", new TextStyle("Arial", 20, Color.BLUE)); 51 graph.getAxis(Axis.BOTTOM).setLabel("Number of Tasters", new TextStyle("Arial", 10, Color.BLACK)); 52 graph.getAxis(Axis.LEFT).setLabel("Number of Scoops", new TextStyle("Arial", 10, Color.BLACK)); 53 bubbles.addMarker(new Text("Chocolate", new TextStyle("Arial", 12, Color.DARK_GRAY)),25,30); 54 bubbles.addMarker(new Text("Vanilla", new TextStyle("Arial", 12, Color.DARK_GRAY)),17,37); 55 bubbles.addMarker(new Text("Cookies 'n Cream", new TextStyle("Arial", 12, Color.DARK_GRAY)),33,22); 56 bubbles.addMarker(new Text("Strawberry", new TextStyle("Arial", 12, Color.DARK_GRAY)),6,10); 57 bubbles.addMarker(new Text("Lemon", new TextStyle("Arial", 12, Color.DARK_GRAY)),2,43); 58 bubbles.addMarker(new Text("Rum 'n' Raisen", new TextStyle("Arial", 12, Color.DARK_GRAY)),37,12); 59 bubbles.addMarker(new Text("Circle Width is Popularity", new TextStyle("Times", 14, Color.RED)),25,46); 60 61 ImageOutput image = new ImageOutput(400, 400); 64 graph.draw(image); 65 FileOutputStream out = new FileOutputStream ("BubbleExample.png"); 66 image.writePNG(out, 0); 67 out.close(); 68 } 69 } | Popular Tags |