From 22cf1e199378990c45b2f80449150cf5215be2aa Mon Sep 17 00:00:00 2001 From: kasemir Date: Thu, 25 Jul 2024 14:43:29 -0400 Subject: [PATCH 1/2] Fix XYPlot axis major tick mark hangup Create XYPlot. Set width to 1530 pixels. Set X axis range to min=3.0, max=3.0 There will be a warning about the invalid axis range, it gets adjusted to some small range, but then the major tick mark computation gets stuck, keeps adding tick marks for the same position until it runs out of memory. This update detects a stuck linear axis tick mark computation and moved on. --- .../javafx/rtplot/internal/LinearTicks.java | 58 +++++++++++-------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/internal/LinearTicks.java b/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/internal/LinearTicks.java index 03c2014c4a..c310e9b449 100644 --- a/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/internal/LinearTicks.java +++ b/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/internal/LinearTicks.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014-2017 Oak Ridge National Laboratory. + * Copyright (c) 2014-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 @@ -90,7 +90,7 @@ public void compute(Double low, Double high, final Graphics2D gc, final int scre double newHigh = adjustedRange.getValue(); if (newLow != low || newHigh != high) { - logger.log(Level.WARNING, "Invalid value range for a linear scale {0,number,#.###############E0} ... {1,number,#.###############E0}. Adjusting the range to {2,number,#.###############E0} ... {3,number,#.###############E0}.", + logger.log(Level.WARNING, " for a linear scale {0,number,#.###############E0} ... {1,number,#.###############E0}. Adjusting the range to {2,number,#.###############E0} ... {3,number,#.###############E0}.", new Object[] {low, high, newLow, newHigh }); high = newHigh; low = newLow; @@ -163,35 +163,45 @@ public void compute(Double low, Double high, final Graphics2D gc, final int scre { double start = Math.ceil(low / distance) * distance; - // Set prev to one before the start - // and loop until high + distance - // to get minor marks before and after the major tick mark range - double prev = start - distance; - for (double value = start; value < high + distance; value += distance) - { - // Compute major tick marks - if (value >= low && value <= high) - major_ticks.add(new MajorTick<>(value, format(value))); - - // Fill major tick marks with minor ticks - for (int i=1; i= high) - continue; - minor_ticks.add(new MinorTick<>(min_val)); - } - prev = value; - } + // Set prev to one before the start + // and loop until high + distance + // to get minor marks before and after the major tick mark range + double prev = start - distance; + for (double value = start; value < high + distance; value += distance) + { + if (prev == value) + { + logger.log(Level.WARNING, "Major ticks for axis " + start + " ... " + high + " do not advance from " + value); + break; + } + // Compute major tick marks + if (value >= low && value <= high) + major_ticks.add(new MajorTick<>(value, format(value))); + + // Fill major tick marks with minor ticks + for (int i=1; i= high) + continue; + minor_ticks.add(new MinorTick<>(min_val)); + } + prev = value; + } } else { - distance = -distance; - double start = Math.floor(low / distance) * distance; + distance = -distance; + double start = Math.floor(low / distance) * distance; double prev = start - distance; for (double value = start; value > high + distance; value += distance) { + if (prev == value) + { + logger.log(Level.WARNING, "Major ticks for axis " + start + " ... " + high + " do not advance from " + value); + break; + } // Compute major tick marks if (value <= low && value >= high) major_ticks.add(new MajorTick<>(value, format(value))); From e22ee1a28a37ac43f12acd2abb0afa07108a9349 Mon Sep 17 00:00:00 2001 From: kasemir Date: Thu, 25 Jul 2024 14:51:02 -0400 Subject: [PATCH 2/2] Typo --- .../java/org/csstudio/javafx/rtplot/internal/LinearTicks.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/internal/LinearTicks.java b/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/internal/LinearTicks.java index c310e9b449..fe9d020a8e 100644 --- a/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/internal/LinearTicks.java +++ b/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/internal/LinearTicks.java @@ -90,7 +90,7 @@ public void compute(Double low, Double high, final Graphics2D gc, final int scre double newHigh = adjustedRange.getValue(); if (newLow != low || newHigh != high) { - logger.log(Level.WARNING, " for a linear scale {0,number,#.###############E0} ... {1,number,#.###############E0}. Adjusting the range to {2,number,#.###############E0} ... {3,number,#.###############E0}.", + logger.log(Level.WARNING, "Invalid value range for a linear scale {0,number,#.###############E0} ... {1,number,#.###############E0}. Adjusting the range to {2,number,#.###############E0} ... {3,number,#.###############E0}.", new Object[] {low, high, newLow, newHigh }); high = newHigh; low = newLow;