0
我试图绘制简单的图表,并使用下面的代码来管理图形的坐标系:的Java的AffineTransform视图改变
Graphics2D g2d = (Graphics2D) g;
// Save the current transform to put it back the way I found it
saveAT = g2d.getTransform();
int height = getHeight();
// Get the get the magnitude of the sample
long scale = thePlotArray.getRealScale();
// Set the x origin at 0 and the y origin in the center of the window
double yTrans = ((double)height)/2.0;
AffineTransform tform = AffineTransform.getTranslateInstance(0.0, yTrans);
// set the y scale to show all of the sample
double yScale = ((double)height)/((double)scale);
tform.scale(1, yScale);
g2d.setTransform(tform);
// Plot the data with a series of
g2d.drawLine(x1, y1, x2, y2);
// reset the transform back
g2d.setTransform(saveAT);
看来,直到我调整窗口的大小,然后起源跳起来运行良好大约1/10的窗口。当我打印出身高,体重,yTrans等数字时,这些数字似乎都是一样的。
有没有我没有做的事情?