Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix XYPlot axis major tick mark hangup #3093

Merged
merged 2 commits into from
Jul 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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<minor; ++i)
{
final double min_val = prev + ((value - prev)*i)/minor;
if (min_val <= low || min_val >= 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<minor; ++i)
{
final double min_val = prev + ((value - prev)*i)/minor;
if (min_val <= low || min_val >= 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)));
Expand Down
Loading