aboutsummaryrefslogtreecommitdiff
path: root/src/EquasiveGraph3D.java
blob: b4dac2de6bea7c7df32297c3a50e110716e1966e (plain) (blame)
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
/*     */ import GUIComponents.ProgressFrame;
/*     */ import java.awt.Color;
/*     */ import java.awt.Graphics;
/*     */ import java.util.ArrayList;
/*     */ import java.util.List;
/*     */ 
/*     */ public class EquasiveGraph3D extends Dynamic3DGraph
/*     */ {
/*     */   private double xMax;
/*     */   private double yMax;
/*     */   private double zMax;
/*     */   private double zMin;
/*     */   private double xMin;
/*     */   private double yMin;
/*     */   private double xStep;
/*     */   private double yStep;
/*     */   private double yPix;
/*     */   private double xPix;
/*     */   private double zPix;
/*     */   protected ProgressFrame progress;
/*     */   private EquasiveGraph3D.InterchangeablePointModel pointModel;
/*     */ 
/*     */   public EquasiveGraph3D()
/*     */   {
/*  27 */     this(1.0D, -1.0D, -1.0D, 1.0D, -1.0D, 1.0D, 10.0D, 10.0D);
/*     */   }
/*     */   public EquasiveGraph3D(double xMax, double xMin, double yMin, double yMax, double zMin, double zMax, double xStep, double yStep) {
/*  30 */     this.xMax = xMax;
/*  31 */     this.yMax = yMax;
/*  32 */     this.zMin = zMin;
/*  33 */     this.zMax = zMax;
/*  34 */     this.xMin = xMin;
/*  35 */     this.yMin = yMin;
/*  36 */     this.xStep = xStep;
/*  37 */     this.yStep = yStep;
/*     */ 
/*  39 */     this.yPix = ((yMax - yMin) / 300.0D);
/*  40 */     this.xPix = ((xMax - xMin) / 300.0D);
/*  41 */     this.zPix = ((zMax - zMin) / 300.0D);
/*  42 */     this.pointModel = new EquasiveGraph3D.InterchangeablePointModel(PointModel.TRUE_Euclidean, PointMaker.ORIGINAL, PointGroup.DEFAULT);
/*     */   }
/*     */ 
/*     */   private void recalc() {
/*  46 */     this.yPix = ((this.yMax - this.yMin) / 300.0D);
/*  47 */     this.xPix = ((this.xMax - this.xMin) / 300.0D);
/*  48 */     this.zPix = ((this.zMax - this.zMin) / 300.0D);
/*     */   }
/*     */   public void setXMax(double x) {
/*  51 */     this.xMax = x;
/*  52 */     recalc();
/*     */   }
/*     */   public void setYMax(double y) {
/*  55 */     this.yMax = y;
/*  56 */     recalc();
/*     */   }
/*     */   public void setXMin(double x) {
/*  59 */     this.xMin = x;
/*  60 */     recalc();
/*     */   }
/*     */   public void setYMin(double y) {
/*  63 */     this.yMin = y;
/*  64 */     recalc();
/*     */   }
/*     */   public void setZMax(double z) {
/*  67 */     this.zMax = z;
/*  68 */     recalc();
/*     */   }
/*     */   public void setZMin(double z) {
/*  71 */     this.zMin = z;
/*  72 */     recalc();
/*     */   }
/*     */   public void setXStep(double x) {
/*  75 */     this.xStep = x;
/*  76 */     recalc();
/*     */   }
/*     */   public void setYStep(double y) {
/*  79 */     this.yStep = y;
/*  80 */     recalc();
/*     */   }
/*     */   public void clear() {
/*  83 */     super.reset();
/*     */   }
/*  85 */   public double getXMax() { return this.xMax; } 
/*  86 */   public double getYMin() { return this.yMin; } 
/*  87 */   public double getXMin() { return this.xMin; } 
/*  88 */   public double getYMax() { return this.yMax; } 
/*  89 */   public double getZMax() { return this.zMax; } 
/*  90 */   public double getZMin() { return this.zMin; } 
/*  91 */   public double getXStep() { return this.xStep; } 
/*  92 */   public double getYStep() { return this.yStep; } 
/*  93 */   protected double convertY(double y) { return y * this.yPix; } 
/*  94 */   protected double convertX(double x) { return x * this.xPix; } 
/*  95 */   protected double convertZ(double z) { return z * this.zPix; } 
/*     */   protected double getXPix() {
/*  97 */     return this.xPix;
/*     */   }
/*     */   protected double getYPix() {
/* 100 */     return this.yPix;
/*     */   }
/*     */   protected double getZPix() {
/* 103 */     return this.zPix;
/*     */   }
/* 105 */   public ProgressFrame getFrame() { return this.progress; } 
/*     */   public void reset() {
/* 107 */     this.points = new ArrayList(0);
/* 108 */     int i = 0;
/* 109 */     double equlen = getCount(getEquations());
/*     */ 
/* 111 */     boolean go = true;
/* 112 */     if (this.progress == null) {
/* 113 */       this.progress = new ProgressFrame(0, 100, M3DGraphWindow.getCurrent());
/*     */     }
/* 115 */     this.progress.setVisible(true);
/* 116 */     this.progress.setValue(0.0D);
/* 117 */     for (Object3D obj : this.axiesChar) {
/* 118 */       obj.setModel(this.pointModel);
/*     */     }
/* 120 */     for (double x = this.xMin / this.xPix; x < 150.0D; x += this.xStep) {
/* 121 */       int red = 255;
/* 122 */       int green = 0;
/* 123 */       int blue = 0;
/* 124 */       for (String equation : getEquations())
/*     */       {
/* 126 */         if (!equation.equals(""))
/* 127 */           for (double y = this.yMin / this.yPix; y < 150.0D; y += this.yStep)
/*     */           {
/* 129 */             Point3D[] pnts = { 
/* 130 */               this.pointModel.makePoint(x, y, equation(equation, convertX(x), convertY(y)) / this.zPix, this.pointModel), 
/* 131 */               this.pointModel.makePoint(x + this.xStep, y, equation(equation, convertX(x + this.xStep), convertY(y)) / this.zPix, this.pointModel), 
/* 132 */               this.pointModel.makePoint(x + this.xStep, y + this.yStep, equation(equation, convertX(x + this.xStep), convertY(y + this.yStep)) / this.zPix, this.pointModel), 
/* 133 */               this.pointModel.makePoint(x, y + this.yStep, equation(equation, convertX(x), convertY(y + this.yStep)) / this.zPix, this.pointModel) };
/*     */ 
/* 135 */             for (Point3D pnt : pnts) {
/* 136 */               if ((Double.isNaN(pnt.getZ())) || (Double.isInfinite(pnt.getZ()))) go = false;
/*     */             }
/* 138 */             if (go) {
/* 139 */               PointGroup temp = new PointGroup(pnts, this.pointModel);
/* 140 */               temp.setColor(new Color(red, green, blue));
/* 141 */               this.points.add(temp);
/*     */             } else {
/* 143 */               go = true;
/*     */             }
/* 145 */             if ((red == 255) && (blue == 0) && (green < 255)) {
/* 146 */               green += 10;
/* 147 */               if (green >= 255) green = 255;
/*     */             }
/* 149 */             else if ((green == 255) && (red > 0) && (blue == 0)) {
/* 150 */               red -= 10;
/* 151 */               if (red <= 0) red = 0;
/*     */             }
/* 153 */             else if ((green == 255) && (red == 0) && (blue < 255)) {
/* 154 */               blue += 10;
/* 155 */               if (blue >= 255) blue = 255;
/*     */             }
/* 157 */             else if ((blue == 255) && (red == 0) && (green > 0)) {
/* 158 */               green -= 10;
/* 159 */               if (green <= 0) green = 0;
/*     */             }
/* 161 */             else if ((blue == 255) && (green == 0) && (red < 255)) {
/* 162 */               red += 10;
/* 163 */               if (red >= 255) red = 255; 
/*     */             }
/*     */             else
/*     */             {
/* 166 */               blue -= 10;
/* 167 */               if (blue <= 0) blue = 0;
/*     */ 
/*     */             }
/*     */ 
/* 172 */             double yChange = (150.0D - this.yMin / this.yPix) / this.yStep;
/* 173 */             double xChange = (150.0D - this.xMin / this.xPix) / this.xStep;
/* 174 */             this.progress.incrementProgress(100.0D / (yChange * xChange * equlen));
/* 175 */             repaint();
/*     */           }
/*     */       }
/*     */     }
/* 179 */     this.progress.flagEnd();
/* 180 */     clean();
/*     */   }
/*     */ 
/*     */   public EquasiveGraph3D.InterchangeablePointModel getModel() {
/* 184 */     return this.pointModel;
/*     */   }
/*     */   public void setPointModel(PointModel pm) {
/* 187 */     this.pointModel.setModel(pm);
/*     */   }
/*     */   protected int getCount(String[] args) {
/* 190 */     int i = 0;
/* 191 */     for (String x : args) {
/* 192 */       if (!x.equals("")) i++;
/*     */     }
/* 194 */     return i; } 
/*     */   protected class InterchangeablePointModel implements PointModel, PointMaker, WirePlotter { private PointModel model;
/*     */     private PointMaker maker;
/*     */     private WirePlotter plotter;
/*     */ 
/* 201 */     public InterchangeablePointModel(PointModel model, PointMaker maker, WirePlotter plotter) { this.model = model;
/* 202 */       this.maker = maker;
/* 203 */       this.plotter = plotter; }
/*     */ 
/*     */     public double[] getRealCoords(double xPos, double yPos, double zPos, double xPivot, double yPivot, double zPivot, double zRotation, double xRotation, double yRotation, double scale, double xMove, double yMove, double camX, double camY, double camZ) {
/* 206 */       return this.model.getRealCoords(xPos, yPos, zPos, xPivot, yPivot, zPivot, zRotation, xRotation, yRotation, scale, xMove, yMove, camX, camY, camZ);
/*     */     }
/*     */     public void setModel(PointModel model) {
/* 209 */       this.model = model;
/*     */     }
/*     */     public void setMaker(PointMaker maker) {
/* 212 */       this.maker = maker;
/*     */     }
/*     */     public Point3D makePoint(double x, double y, double z, PointModel mod) {
/* 215 */       return this.maker.makePoint(x, y, z, mod);
/*     */     }
/*     */     public void plotWire(Graphics g, CoordinateSystem graph, Point3D[] points) {
/* 218 */       this.plotter.plotWire(g, graph, points);
/*     */     }
/*     */     public void setPlotter(WirePlotter plotter) {
/* 221 */       this.plotter = plotter;
/*     */     }
/*     */   }
/*     */ }

/* Location:           Modulus.jar
 * Qualified Name:     EquasiveGraph3D
 * JD-Core Version:    0.6.2
 */