diff --git a/swing/src/main/java/info/openrocket/swing/gui/plot/Plot.java b/swing/src/main/java/info/openrocket/swing/gui/plot/Plot.java index d6730b401..1e1e47ef7 100644 --- a/swing/src/main/java/info/openrocket/swing/gui/plot/Plot.java +++ b/swing/src/main/java/info/openrocket/swing/gui/plot/Plot.java @@ -211,7 +211,7 @@ public abstract class Plot, C extend // Determine the appropriate name based on the time and series String name = getNameBasedOnIdxAndSeries(ser, item); - return formatSampleTooltip(name, dataX, unitX, dataY, unitY, item); + return formatSampleTooltip(name, dataX, unitX, dataY, unitY); } }; @@ -298,8 +298,7 @@ public abstract class Plot, C extend } protected String formatSampleTooltip(String dataName, double dataX, String unitX, double dataY, String unitY, - int sampleIdx, boolean addYValue) { - String ord_end = getOrdinalEnding(sampleIdx); + boolean addYValue) { DecimalFormat df_y = DecimalFormatter.df(dataY, 2, false); DecimalFormat df_x = DecimalFormatter.df(dataX, 2, false); @@ -313,28 +312,17 @@ public abstract class Plot, C extend } sb.append(String.format("X: %s %s
" + - "%d%s sample" + - "", df_x.format(dataX), unitX, sampleIdx, ord_end)); + "", df_x.format(dataX), unitX)); return sb.toString(); } - protected String formatSampleTooltip(String dataName, double dataX, String unitX, double dataY, String unitY, int sampleIdx) { - return formatSampleTooltip(dataName, dataX, unitX, dataY, unitY, sampleIdx, true); + protected String formatSampleTooltip(String dataName, double dataX, String unitX, double dataY, String unitY) { + return formatSampleTooltip(dataName, dataX, unitX, dataY, unitY, true); } - protected String formatSampleTooltip(String dataName, double dataX, String unitX, int sampleIdx) { - return formatSampleTooltip(dataName, dataX, unitX, 0, "", sampleIdx, false); - } - - protected String getOrdinalEnding(int n) { - if (n % 100 == 11 || n % 100 == 12 || n % 100 == 13) return "th"; - return switch (n % 10) { - case 1 -> "st"; - case 2 -> "nd"; - case 3 -> "rd"; - default -> "th"; - }; + protected String formatSampleTooltip(String dataName, double dataX, String unitX) { + return formatSampleTooltip(dataName, dataX, unitX, 0, "", false); } protected static class LegendItems implements LegendItemSource { diff --git a/swing/src/main/java/info/openrocket/swing/gui/plot/SimulationPlot.java b/swing/src/main/java/info/openrocket/swing/gui/plot/SimulationPlot.java index 86a7a880f..27fb0f7f5 100644 --- a/swing/src/main/java/info/openrocket/swing/gui/plot/SimulationPlot.java +++ b/swing/src/main/java/info/openrocket/swing/gui/plot/SimulationPlot.java @@ -324,8 +324,7 @@ public class SimulationPlot extends Plot events, String tName, double time, String unitT, String xName, double dataX, String unitX, - String yName, double dataY, String unitY, int sampleIdx) { - String ord_end = getOrdinalEnding(sampleIdx); + String yName, double dataY, String unitY) { DecimalFormat df_t = DecimalFormatter.df(time, 2, false); DecimalFormat df_y = DecimalFormatter.df(dataY, 2, false); @@ -385,7 +383,6 @@ public class SimulationPlot extends Plot", xName, df_x.format(dataX), unitX)); sb.append(String.format("%s: %s %s
", yName, df_y.format(dataY), unitY)); - sb.append(String.format("%d%s sample", sampleIdx, ord_end)); // End tooltip sb.append("");