1 import org.faceless.graph2.*; 2 import java.awt.Color ; 3 import java.io.FileOutputStream ; 4 import java.io.IOException ; 5 6 public class MarkerExample 7 { 8 public static void main(String args[]) throws IOException 9 { 10 AxesGraph graph = new AxesGraph(); 14 graph.setAxis(Axis.BOTTOM, new MarkerAxis(20)); 15 graph.setXRotation(20); 16 graph.setYRotation(30); 17 18 BarSeries series1 = new BarSeries("populations"); 21 series1.setStyle(new Style(Color.GREEN)); 22 series1.setBarWidth(0.5); 23 series1.setBarDepth(0.8); 24 series1.set("flag.UK", 59778002); 25 series1.set("flag.AU", 19546792); 26 series1.set("flag.NZ", 3908037); 27 series1.set("flag.VE", 24287670); 28 series1.set("flag.FR", 59765983); 29 series1.set("flag.GR", 10645343); 30 series1.set("flag.CA", 31902268); 31 series1.set("flag.EG", 70712345); 32 series1.set("flag.CO", 41008227); 33 series1.set("flag.RU", 144978573); 34 series1.set("flag.DE", 83251851); 35 series1.set("flag.IT", 57715625); 36 series1.set("flag.ZA", 43647658); 37 38 graph.addSeries(series1); 39 40 Style style = new Style(new Color (249, 218, 232)); 43 style.setBorderColor(Color.BLACK); 44 style.setLineThickness(2); 45 Key key = new Key(style); 46 47 TextStyle ts = new TextStyle("Comic", 14, Color.BLACK); 50 key.addCustom(new Marker("flag.UK", 15), "United Kingdom", ts); 51 key.addCustom(new Marker("flag.AU", 15), "Australia", ts); 52 key.addCustom(new Marker("flag.NZ", 15), "New Zealand", ts); 53 key.addCustom(new Marker("flag.VE", 15), "Venezuela", ts); 54 key.addCustom(new Marker("flag.FR", 15), "France", ts); 55 key.addCustom(new Marker("flag.GR", 15), "Greece", ts); 56 key.addCustom(new Marker("flag.CA", 15), "Canada", ts); 57 key.addCustom(new Marker("flag.EG", 15), "Egypt", ts); 58 key.addCustom(new Marker("flag.CO", 15), "Colombia", ts); 59 key.addCustom(new Marker("flag.RU", 15), "Russian Federation", ts); 60 key.addCustom(new Marker("flag.DE", 15), "Germany", ts); 61 key.addCustom(new Marker("flag.IT", 15), "Italy", ts); 62 key.addCustom(new Marker("flag.ZA", 15), "South Africa", ts); 63 graph.addKey(key, Align.RIGHT); 64 65 graph.addText("Populations", new TextStyle("Helvetica", 30, Color.BLUE, Align.CENTER)); 68 graph.getAxis(Axis.LEFT).setLabel("Number of People", new TextStyle("Times", 12, Color.BLACK)); 69 graph.getAxis(Axis.BOTTOM).setLabel("Country", new TextStyle("Times", 12, Color.BLACK)); 70 71 ImageOutput image = new ImageOutput(650,500); 74 75 80 graph.draw(image); 81 FileOutputStream out = new FileOutputStream ("MarkerExample.png"); 82 image.writePNG(out, 0); 83 out.close(); 84 } 85 } 86 | Popular Tags |