forked from yannrichet/jmathplot
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathBarPlot.java
More file actions
109 lines (87 loc) · 2.93 KB
/
BarPlot.java
File metadata and controls
109 lines (87 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package org.math.plot.plots;
import java.awt.*;
import javax.swing.*;
import org.math.plot.*;
import org.math.plot.render.*;
import org.math.plot.utils.*;
public class BarPlot extends ScatterPlot {
public boolean draw_dot = true;
public BarPlot(String n, Color c, boolean[][] _pattern, double[][] _XY) {
super(n, c, _pattern, _XY);
}
public BarPlot(String n, Color[] c, boolean[][] _pattern, double[][] _XY) {
super(n, c, _pattern, _XY);
}
public BarPlot(String n, Color c, int _type, int _radius, double[][] _XY) {
super(n, c, _type, _radius, _XY);
}
public BarPlot(String n, Color[] c, int _type, int _radius, double[][] _XY) {
super(n, c, _type, _radius, _XY);
}
public BarPlot(String n, Color c, double[][] _XY) {
super(n, c, _XY);
}
public BarPlot(String n, Color[] c, double[][] _XY) {
super(n, c, _XY);
}
public void plot(AbstractDrawer draw, Color[] c) {
if (!visible)
return;
if (draw_dot)
super.plot(draw, c);
draw.setLineType(AbstractDrawer.CONTINOUS_LINE);
for (int i = 0; i < XY.length; i++) {
double[] axeprojection = Array.copy(XY[i]);
axeprojection[axeprojection.length - 1] = draw.canvas.base.baseCoords[0][axeprojection.length - 1];
draw.setColor(c.length == 1 ? c[0] : c[i]);
draw.drawLine(XY[i], axeprojection);
}
}
public static void main(String[] args) {
Plot2DPanel p2 = new Plot2DPanel();
for (int i = 0; i < 3; i++) {
double[][] XYZ = new double[10][2];
for (int j = 0; j < XYZ.length; j++) {
XYZ[j][0] = /*1 + */Math.random();
XYZ[j][1] = /*100 * */Math.random();
}
p2.addBarPlot("toto" + i, XYZ);
}
p2.setLegendOrientation(PlotPanel.SOUTH);
new FrameView(p2).setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Plot3DPanel p = new Plot3DPanel();
for (int i = 0; i < 3; i++) {
double[][] XYZ = new double[10][3];
for (int j = 0; j < XYZ.length; j++) {
XYZ[j][0] = /*1 +*/Math.random();
XYZ[j][1] = /*100 **/Math.random();
XYZ[j][2] = /*0.0001 **/Math.random();
}
p.addBarPlot("toto" + i, XYZ);
}
p.setLegendOrientation(PlotPanel.SOUTH);
new FrameView(p).setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Color[] c = new Color[10];
p2 = new Plot2DPanel();
double[][] XYZ = new double[10][2];
for (int j = 0; j < XYZ.length; j++) {
XYZ[j][0] = /*1 + */Math.random();
XYZ[j][1] = /*100 * */Math.random();
c[j] = new Color((int)(Math.random() * 0x1000000));
}
p2.addBarPlot("toto", c, XYZ);
p2.setLegendOrientation(PlotPanel.SOUTH);
new FrameView(p2).setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
p = new Plot3DPanel();
XYZ = new double[10][3];
for (int j = 0; j < XYZ.length; j++) {
XYZ[j][0] = /*1 +*/Math.random();
XYZ[j][1] = /*100 **/Math.random();
XYZ[j][2] = /*0.0001 **/Math.random();
c[j] = new Color((int)(Math.random() * 0x1000000));
}
p.addBarPlot("toto", c, XYZ);
p.setLegendOrientation(PlotPanel.SOUTH);
new FrameView(p).setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}