src/org/math/plot/plots/BarPlot.java

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 import org.math.plot.utils.*;
00010 
00011 public class BarPlot extends ScatterPlot {
00012 
00013         public boolean draw_dot = true;
00014 
00015         public BarPlot(String n, Color c, boolean[][] _pattern, double[][] _XY) {
00016                 super(n, c, _pattern, _XY);
00017         }
00018 
00019         public BarPlot(String n, Color c, int _type, int _radius, double[][] _XY) {
00020                 super(n, c, _type, _radius, _XY);
00021         }
00022 
00023         public BarPlot(String n, Color c, double[][] _XY) {
00024                 super(n, c, _XY);
00025         }
00026 
00027         public void plot(AbstractDrawer draw, Color c) {
00028                 if (!visible)
00029                         return;
00030 
00031                 if (draw_dot)
00032                         super.plot(draw, c);
00033 
00034                 draw.setColor(c);
00035                 draw.setLineType(AbstractDrawer.CONTINOUS_LINE);
00036                 for (int i = 0; i < XY.length; i++) {
00037                         double[] axeprojection = Array.copy(XY[i]);
00038                         axeprojection[axeprojection.length - 1] = draw.canvas.base.baseCoords[0][axeprojection.length - 1];
00039                         draw.drawLine(XY[i], axeprojection);
00040                 }
00041         }
00042 
00043         public static void main(String[] args) {
00044                 Plot2DPanel p2 = new Plot2DPanel();
00045                 for (int i = 0; i < 3; i++) {
00046                         double[][] XYZ = new double[10][2];
00047                         for (int j = 0; j < XYZ.length; j++) {
00048                                 XYZ[j][0] = /*1 + */Math.random();
00049                                 XYZ[j][1] = /*100 * */Math.random();
00050                         }
00051                         p2.addBarPlot("toto" + i, XYZ);
00052                 }
00053 
00054                 p2.setLegendOrientation(PlotPanel.SOUTH);
00055                 new FrameView(p2).setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
00056 
00057                 Plot3DPanel p = new Plot3DPanel();
00058                 for (int i = 0; i < 3; i++) {
00059                         double[][] XYZ = new double[10][3];
00060                         for (int j = 0; j < XYZ.length; j++) {
00061                                 XYZ[j][0] = /*1 +*/Math.random();
00062                                 XYZ[j][1] = /*100 **/Math.random();
00063                                 XYZ[j][2] = /*0.0001 **/Math.random();
00064                         }
00065                         p.addBarPlot("toto" + i, XYZ);
00066                 }
00067 
00068                 p.setLegendOrientation(PlotPanel.SOUTH);
00069                 new FrameView(p).setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
00070         }
00071 }

Generated on Wed Sep 5 21:44:01 2007 for jmathplot by  doxygen 1.5.1