-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSurfacePlot.java
More file actions
181 lines (153 loc) · 4.64 KB
/
SurfacePlot.java
File metadata and controls
181 lines (153 loc) · 4.64 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
//package org.freehep.j3d.plot;
import javax.media.j3d.*;
import com.sun.j3d.utils.universe.SimpleUniverse;
import javax.swing.*;
import javax.vecmath.*;
/**
* A simple convenience class that end users can pop into their GUI to produce a
* surface plot.
*
* Warning: SurfacePlot extends Canvas3D and thus is a heavyweight object.
* @author Joy Kyriakopulos (joyk@fnal.gov)
* @version $Id: SurfacePlot.java 8584 2006-08-10 23:06:37Z duns $
*/
public class SurfacePlot extends Plot3D
{
private Binned2DData data;
private SurfaceBuilder builder;
private Node plot;
private boolean logZscaling = false;
private AxisBuilder xAxis;
private AxisBuilder yAxis;
private ZAxisBuilder zAxis;
private String xAxisLabel = "X Axis";
private String yAxisLabel = "Y Axis";
private String zAxisLabel = "Z Axis";
private double xmin;
private double xmax;
private double ymin;
private double ymax;
private double zmin;
private double zmax;
// MH 100111 changing background brightness
// public SurfacePlot(double background)
public SurfacePlot()
{
// MH 100111 changing background brightness
// super(background);
super();
}
public void setData(Binned2DData data)
{
this.data = data;
if (init) {
// if (data.xMin() != xmin || data.xMax() != xmax) {
// xmin = data.xMin();
// xmax = data.xMax();
xAxis.createLabelsNTicks(xmin, xmax);
xAxis.apply();
// }
// if (data.yMin() != ymin || data.yMax() != ymax) {
// ymin = data.yMin();
// ymax = data.yMax();
yAxis.createLabelsNTicks(ymin, ymax);
yAxis.apply();
// }
// if (data.zMin() != zmin || data.zMax() != zmax) {
// zmin = data.zMin();
// zmax = data.zMax();
zAxis.createLabelsNTicks(zmin, zmax, logZscaling);
zAxis.apply();
// }
if (logZscaling)
builder.updatePlot(new NormalizedBinned2DLogData(data));
else
builder.updatePlot(new NormalizedBinned2DData(data));
}
}
public boolean getLogZscaling()
{
return logZscaling;
}
public void setLogZscaling(boolean b)
{
// System.out.println("setting Log Scaling to: " + b + " from: " + logZscaling);
if (logZscaling != b) {
logZscaling = b;
if (data != null) {
zmin = data.zMin();
zmax = data.zMax();
zAxis.createLabelsNTicks(zmin, zmax, logZscaling);
zAxis.apply();
if (logZscaling)
builder.updatePlot(new NormalizedBinned2DLogData(data));
else
builder.updatePlot(new NormalizedBinned2DData(data));
}
}
}
public String getXAxisLabel()
{
return xAxisLabel;
}
public void setXAxisLabel(String s)
{
xAxisLabel = s;
xAxis.setLabel(s);
xAxis.apply();
}
public String getYAxisLabel()
{
return yAxisLabel;
}
public void setYAxisLabel(String s)
{
yAxisLabel = s;
yAxis.setLabel(s);
yAxis.apply();
}
public String getZAxisLabel()
{
return zAxisLabel;
}
public void setZAxisLabel(String s)
{
zAxisLabel = s;
zAxis.setLabel(s);
zAxis.apply();
}
protected Node createPlot()
{
builder = new SurfaceBuilder();
Node box = builder.buildOutsideBox();
if (logZscaling)
plot = builder.buildContent(new NormalizedBinned2DLogData(data));
else
plot = builder.buildContent(new NormalizedBinned2DData(data));
double[] tick = {0,.2,.4,.6,.8,1.0};
// double[] tick = {0,1,2,3,4,5,6,7,8,9,10};
// double[] tick = {0,.1,.2,.3,.4,.5,.6,.7,.8,.9,1.0};
String[] labels = {"0.0","0.3","0.6","1.0" };
// String[] labels = {"0","2","4","6","8","10" };
// String[] labels = {"0.0","0.2","0.4","0.6","0.8","1.0" };
xAxis = new XAxisBuilder(xAxisLabel,labels,tick);
yAxis = new YAxisBuilder(yAxisLabel,labels,tick);
zAxis = new ZAxisBuilder(zAxisLabel,labels,tick);
xAxis.createLabelsNTicks(data.xMin(), data.xMax());
yAxis.createLabelsNTicks(data.yMin(), data.yMax());
zAxis.createLabelsNTicks(data.zMin(), data.zMax(), logZscaling);
xAxis.apply();
yAxis.apply();
zAxis.apply();
Group g = new Group();
g.addChild(box);
g.addChild(plot);
g.addChild(xAxis.getNode());
g.addChild(yAxis.getNode());
g.addChild(zAxis.getNode());
// Background background = new Background(new Color3f(1.0f, 1.0f, 1.0f));
// background.setApplicationBounds(bounds);
// g.addChild(background);
return g;
}
}