13
13
14
14
public abstract class AWTDrawer extends AbstractDrawer {
15
15
16
- protected Projection projection ;
16
+ public Projection projection ;
17
17
18
18
public AWTDrawer (PlotCanvas _canvas ) {
19
19
super (_canvas );
@@ -25,7 +25,7 @@ public AWTDrawer(PlotCanvas _canvas) {
25
25
* @see org.math.plot.render.AbstractDrawer#resetProjection()
26
26
*/
27
27
public void resetBaseProjection () {
28
- projection .initBaseCoordsProjection ();
28
+ projection .initBaseCoordsProjection (true );
29
29
}
30
30
31
31
/*
@@ -90,7 +90,7 @@ public int[] project(double... pC) {
90
90
* @see org.math.plot.render.AbstractDrawer#projectRatio(double[])
91
91
*/
92
92
public int [] projectBase (double ... rC ) {
93
- return projection .screenProjectionBaseRatio (rC );
93
+ return projection .screenProjectionBase (rC );
94
94
}
95
95
96
96
/*
@@ -134,7 +134,11 @@ public void drawText(String label, double... pC) {
134
134
comp2D .rotate (text_angle , x + w / 2 , y - h / 2 );
135
135
}
136
136
137
- comp2D .drawString (label , x , y );
137
+ String [] lines = label .split ("\n " );
138
+ for (int i = 0 ; i < lines .length ; i ++) {
139
+ comp2D .drawString (lines [i ], x , y );
140
+ y += h ;
141
+ }
138
142
139
143
if (text_angle != 0 ) {
140
144
comp2D .rotate (-text_angle , x + w / 2 , y - h / 2 );
@@ -148,7 +152,7 @@ public void drawText(String label, double... pC) {
148
152
* double[], double, double, double)
149
153
*/
150
154
public void drawTextBase (String label , double ... rC ) {
151
- int [] sC = projection .screenProjectionBaseRatio (rC );
155
+ int [] sC = projection .screenProjectionBase (rC );
152
156
153
157
// Corner offset adjustment : Text Offset is used Here
154
158
FontRenderContext frc = comp2D .getFontRenderContext ();
@@ -164,7 +168,12 @@ public void drawTextBase(String label, double... rC) {
164
168
comp2D .rotate (text_angle , x + w / 2 , y - h / 2 );
165
169
}
166
170
167
- comp2D .drawString (label , x , y );
171
+ String [] lines = label .split ("\n " );
172
+ for (int i = 0 ; i < lines .length ; i ++) {
173
+ comp2D .drawString (lines [i ], x , y );
174
+ y += h ;
175
+ }
176
+ //comp2D.drawString(label, x, y);
168
177
169
178
if (text_angle != 0 ) {
170
179
comp2D .rotate (-text_angle , x + w / 2 , y - h / 2 );
@@ -180,7 +189,7 @@ public void drawTextBase(String label, double... rC) {
180
189
public void drawLineBase (double []... rC ) {
181
190
int [][] sC = new int [rC .length ][];
182
191
for (int i = 0 ; i < sC .length ; i ++) {
183
- sC [i ] = projection .screenProjectionBaseRatio (rC [i ]);
192
+ sC [i ] = projection .screenProjectionBase (rC [i ]);
184
193
}
185
194
drawLine (sC );
186
195
}
@@ -383,27 +392,27 @@ public AffineTransform getAffineTransform(int width, int height, double[] _xyzSW
383
392
/*double[] _cornerSW_tr = new double[2];
384
393
double[] _cornerSW = { 0, img.getHeight(canvas) };
385
394
t.transform(_cornerSW, 0, _cornerSW_tr, 0, 1);
386
-
395
+
387
396
if (isDiff(_cornerSW_tr, cornerSW)) {
388
397
double[] vectSW_NW_1 = { (double) cornerNW[0] - (double) cornerSW[0], (double) cornerNW[1] - (double) cornerSW[1] };
389
398
double[] vectSW_NW_2 = { (double) cornerNW[0] - (double) _cornerSW_tr[0], (double) cornerNW[1] - (double) _cornerSW_tr[1] };
390
-
399
+
391
400
double normvect_1 = sqrt(sqr(vectSW_NW_1[0]) + sqr(vectSW_NW_1[1]));
392
401
double normvect_2 = sqrt(sqr(vectSW_NW_1[0]) + sqr(vectSW_NW_1[1]));
393
-
402
+
394
403
double cos_angle = (((vectSW_NW_1[0] * vectSW_NW_2[0] + vectSW_NW_1[1] * vectSW_NW_2[1]) / (normvect_1 * normvect_2)));
395
404
double vect = (vectSW_NW_1[0] * vectSW_NW_2[1] - vectSW_NW_1[1] * vectSW_NW_2[0]);
396
-
405
+
397
406
System.out.println(cos_angle + " " + vect + " -> " + toDegrees(acos(cos_angle)));
398
-
407
+
399
408
//System.out.println(" "+vectSE_NW_1[0]+","+vectSE_NW_1[1]+" "+vectSE_NW_2[0]+","+vectSE_NW_2[1]);
400
409
AffineTransform t2 = new AffineTransform();
401
410
if (vect > 0)
402
411
t2.rotate(acos(cos_angle), cornerNW[0], cornerNW[1]);
403
412
else
404
413
t2.rotate(-acos(cos_angle), cornerNW[0], cornerNW[1]);
405
414
t.preConcatenate(t2);
406
-
415
+
407
416
}*/
408
417
409
418
return t ;
0 commit comments