00001 package org.math.plot.plots; 00002 00003 import java.awt.*; 00004 00005 import javax.swing.*; 00006 00007 import org.math.plot.*; 00008 import org.math.plot.render.*; 00009 00010 public class LinePlot extends ScatterPlot { 00011 00012 public boolean draw_dot = false; 00013 00014 public LinePlot(String n, Color c, boolean[][] _pattern, double[][] _XY) { 00015 super(n, c, _pattern, _XY); 00016 } 00017 00018 public LinePlot(String n, Color c, int _type, int _radius, double[][] _XY) { 00019 super(n, c, _type, _radius, _XY); 00020 } 00021 00022 public LinePlot(String n, Color c, double[][] _XY) { 00023 super(n, c, _XY); 00024 } 00025 00026 public void plot(AbstractDrawer draw, Color c) { 00027 if (!visible) 00028 return; 00029 00030 if (draw_dot) 00031 super.plot(draw, c); 00032 00033 draw.setColor(c); 00034 draw.setLineType(AbstractDrawer.CONTINOUS_LINE); 00035 for (int i = 0; i < XY.length - 1; i++) 00036 draw.drawLine(XY[i], XY[i + 1]); 00037 } 00038 00039 public static void main(String[] args) { 00040 Plot2DPanel p2 = new Plot2DPanel(); 00041 00042 double[][] XYZ = new double[100][2]; 00043 for (int j = 0; j < XYZ.length; j++) { 00044 XYZ[j][0] = 2*Math.PI*(double)j/XYZ.length; 00045 XYZ[j][1] = Math.sin(XYZ[j][0]); 00046 } 00047 p2.addLinePlot("sin" , XYZ); 00048 00049 00050 p2.setLegendOrientation(PlotPanel.SOUTH); 00051 new FrameView(p2).setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 00052 00053 Plot3DPanel p = new Plot3DPanel(); 00054 00055 XYZ = new double[100][3]; 00056 for (int j = 0; j < XYZ.length; j++) { 00057 XYZ[j][0] = 2*Math.PI*(double)j/XYZ.length; 00058 XYZ[j][1] = Math.sin(XYZ[j][0]); 00059 XYZ[j][2] = Math.sin(XYZ[j][0])*Math.cos(XYZ[j][1]); 00060 } 00061 p.addLinePlot("toto" , XYZ); 00062 00063 p.setLegendOrientation(PlotPanel.SOUTH); 00064 new FrameView(p).setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 00065 } 00066 }