diff --git a/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/internal/ImagePlot.java b/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/internal/ImagePlot.java index 3c8f81766d..584f64fc19 100644 --- a/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/internal/ImagePlot.java +++ b/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/internal/ImagePlot.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015-2023 Oak Ridge National Laboratory. + * Copyright (c) 2015-2024 Oak Ridge National Laboratory. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -600,26 +600,19 @@ else if (numbers instanceof ArrayInteger) // Transform from full axis range into data range, // using the current 'zoom' state of each axis - final LinearScreenTransform t = new LinearScreenTransform(); + final LinearScreenTransform zoom_trans_x = new LinearScreenTransform(); AxisRange zoomed = x_axis.getValueRange(); - t.config(min_x, max_x, 0, data_width); + zoom_trans_x.config(min_x, max_x, 0, data_width); // Round down .. up to always cover the image_area - final int src_x1 = Math.max(0, (int) t.transform(zoomed.getLow())); - final int src_x2 = Math.min(data_width, (int)(t.transform(zoomed.getHigh()) + 1)); - - // Pixels of the image need to be aligned to their axis location, - // especially when zoomed way in and the pixels are huge. - // Turn pixel back into axis value, and then determine its destination on screen. - final int dst_x1 = x_axis.getScreenCoord(t.inverse(src_x1)); - final int dst_x2 = x_axis.getScreenCoord(t.inverse(src_x2)); + final int src_x1 = Math.max(0, (int) zoom_trans_x.transform(zoomed.getLow())); + final int src_x2 = Math.min(data_width, (int)(zoom_trans_x.transform(zoomed.getHigh()) + 1)); // For Y axis, min_y == bottom == data_height + final LinearScreenTransform zoom_trans_y = new LinearScreenTransform(); zoomed = y_axis.getValueRange(); - t.config(min_y, max_y, data_height, 0); - final int src_y1 = Math.max(0, (int) t.transform(zoomed.getHigh())); - final int src_y2 = Math.min(data_height, (int) (t.transform(zoomed.getLow() ) + 1)); - final int dst_y1 = y_axis.getScreenCoord(t.inverse(src_y1)); - final int dst_y2 = y_axis.getScreenCoord(t.inverse(src_y2)); + zoom_trans_y.config(min_y, max_y, data_height, 0); + final int src_y1 = Math.max(0, (int) zoom_trans_y.transform(zoomed.getHigh())); + final int src_y2 = Math.min(data_height, (int) (zoom_trans_y.transform(zoomed.getLow() ) + 1)); // Value range: Start with min..max from model double min_value = this.min, max_value = this.max; @@ -663,6 +656,15 @@ else if (numbers instanceof ArrayInteger) if (need_layout.getAndSet(false)) computeLayout(gc, area_copy, min_value, max_value); + // After potential layout update, get destination x,y of image. + // Pixels of the image need to be aligned to their axis location, + // especially when zoomed way in and the pixels are huge. + // Turn pixel back into axis value, and then determine its destination on screen. + final int dst_x1 = x_axis.getScreenCoord(zoom_trans_x.inverse(src_x1)); + final int dst_x2 = x_axis.getScreenCoord(zoom_trans_x.inverse(src_x2)); + final int dst_y1 = y_axis.getScreenCoord(zoom_trans_y.inverse(src_y1)); + final int dst_y2 = y_axis.getScreenCoord(zoom_trans_y.inverse(src_y2)); + // Fill with a 'background' color if (background.getAlpha() < 255) { // Clear because fill alone with transparent background leaves previous content