Я пытаюсь построить простой график и использовать следующий код для управления системой координат графика:
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 и т. д.
Есть ли что-то, что я не делаю?