1 import org.faceless.graph2.*; 2 import java.awt.Color ; 3 import java.io.FileOutputStream ; 4 import java.io.IOException ; 5 6 public class AreaGraphExample 7 { 8 public static void main (String args[]) throws IOException 9 { 10 AxesGraph graph = new AxesGraph(); 11 graph.setXRotation(25); 12 graph.setYRotation(15); 13 14 FunctionLineSeries sin = new FunctionLineSeries("Sine", 0, 6) { 17 public double func(double x) { return Math.cos(x)+2; } 18 }; 19 sin.setStyle(new Style(Color.RED)); 20 21 FunctionLineSeries cos = new FunctionLineSeries("CoSine", 0, 6) { 22 public double func(double x) { return Math.sin(x)+2; } 23 }; 24 cos.setStyle(new Style(Color.BLUE)); 25 26 AreaSeries series = new AreaSeries("area"); 29 series.add(cos); 30 series.add(sin); 31 graph.addSeries(series); 32 33 Key key = new Key(new Style(Color.WHITE)); 36 key.addSeries(sin, new TextStyle("Times", 12, Color.BLACK)); 37 key.addSeries(cos, new TextStyle("Times", 12, Color.BLACK)); 38 graph.addKey(key, Align.RIGHT); 39 40 ImageOutput image = new ImageOutput(500,300); 43 graph.draw(image); 44 FileOutputStream out = new FileOutputStream ("AreaGraphExample.png"); 45 image.writePNG(out, 0); 46 out.close(); 47 } 48 } 49 | Popular Tags |