From d057b0f3e6dcd8646d2dc38d1ae516aa69cfb56a Mon Sep 17 00:00:00 2001 From: Minimons Date: Fri, 16 Oct 2026 11:52:56 +0200 Subject: [PATCH] X: NFT - Method reordering --- .../impl/ref/EvelynMissionControlImpl.tjava | 239 +++++++++--------- 1 file changed, 120 insertions(+), 119 deletions(-) diff --git a/src/main/tjava/com/r35157/evelyn/emc/impl/ref/EvelynMissionControlImpl.tjava b/src/main/tjava/com/r35157/evelyn/emc/impl/ref/EvelynMissionControlImpl.tjava index d80f0f0..783856f 100644 --- a/src/main/tjava/com/r35157/evelyn/emc/impl/ref/EvelynMissionControlImpl.tjava +++ b/src/main/tjava/com/r35157/evelyn/emc/impl/ref/EvelynMissionControlImpl.tjava @@ -50,6 +50,125 @@ public final class EvelynMissionControlImpl implements javaFxRuntimeService.runLater(this::showWindow); } + static StatusIndexChart createStatusIndexChart() { + NumberAxis xAxis = new NumberAxis(0, 1, 1); + xAxis.setLabel("Time"); + xAxis.setTickLabelFormatter(TIMESTAMP_FORMATTER); + xAxis.setForceZeroInRange(false); + + double yBound = EMPTY_Y_BOUND; + NumberAxis yAxis = new NumberAxis(-yBound, yBound, yBound / 5.0); + yAxis.setLabel("Index value"); + yAxis.setForceZeroInRange(true); + + LineChart chart = new LineChart<>(xAxis, yAxis); + chart.setTitle("Evelyn Status Index History"); + chart.setCreateSymbols(false); + chart.setAnimated(false); + XYChart.Series priceIndexSeries = createSeries( + "Evelyn Price Index", + List.of(), + EvelynStatusIndexPoint::evelynPriceIndex + ); + chart.getData().add(priceIndexSeries); + //chart.getData().add(createSeries("EVE_SYRUP Pool Depth Index", history, EvelynStatusIndexPoint::eveSyrupPoolDepthIndex)); + //chart.getData().add(createSeries("EVE_SYRUP Pool Balance Index", history, EvelynStatusIndexPoint::eveSyrupPoolBalanceIndex)); + //chart.getData().add(createSeries("AAZDKK_USDT Pool Balance Index", history, EvelynStatusIndexPoint::aazdkkUsdtPoolBalanceIndex)); + //chart.getData().add(createSeries("AAZDKK_USDT Pool Price Index", history, EvelynStatusIndexPoint::aazdkkUsdtPoolPriceIndex)); + //chart.getData().add(createSeries("AAZDKK_USDT Pool Depth Index", history, EvelynStatusIndexPoint::aazdkkUsdtPoolDepthIndex)); + return new StatusIndexChart(chart, xAxis, yAxis, priceIndexSeries); + } + + static double calculateYBound(List history) { + BigDecimal maxAbsoluteValue = BigDecimal.ZERO; + for (EvelynStatusIndexPoint point : history) { + maxAbsoluteValue = max(maxAbsoluteValue, point.evelynPriceIndex()); + //maxAbsoluteValue = max(maxAbsoluteValue, point.eveSyrupPoolDepthIndex()); + //maxAbsoluteValue = max(maxAbsoluteValue, point.eveSyrupPoolBalanceIndex()); + //maxAbsoluteValue = max(maxAbsoluteValue, point.aazdkkUsdtPoolBalanceIndex()); + //maxAbsoluteValue = max(maxAbsoluteValue, point.aazdkkUsdtPoolPriceIndex()); + //maxAbsoluteValue = max(maxAbsoluteValue, point.aazdkkUsdtPoolDepthIndex()); + } + + double bound = maxAbsoluteValue.doubleValue(); + return bound == 0.0 ? EMPTY_Y_BOUND : bound; + } + + static void refreshChart( + StatusIndexChart statusIndexChart, + List history + ) { + if (!Platform.isFxApplicationThread()) { + throw new IllegalStateException("Status-index charts must be updated on the JavaFX Application Thread"); + } + + int commonPointCount = 0; + int maximumCommonPointCount = Math.min( + history.size(), + statusIndexChart.renderedHistory.size() + ); + while (commonPointCount < maximumCommonPointCount + && history.get(commonPointCount).equals( + statusIndexChart.renderedHistory.get(commonPointCount) + )) { + commonPointCount++; + } + if (commonPointCount < statusIndexChart.renderedHistory.size()) { + statusIndexChart.priceIndexSeries().getData().clear(); + statusIndexChart.renderedHistory = List.of(); + commonPointCount = 0; + } + for (int index = commonPointCount; index < history.size(); index++) { + EvelynStatusIndexPoint point = history.get(index); + statusIndexChart.priceIndexSeries().getData().add(new XYChart.Data<>( + point.timestamp().toEpochMilli(), + point.evelynPriceIndex() + )); + } + statusIndexChart.renderedHistory = List.copyOf(history); + updateAxisBounds(statusIndexChart, history); + } + + static final class StatusIndexChart { + private StatusIndexChart( + LineChart chart, + NumberAxis xAxis, + NumberAxis yAxis, + XYChart.Series priceIndexSeries + ) { + this.chart = chart; + this.xAxis = xAxis; + this.yAxis = yAxis; + this.priceIndexSeries = priceIndexSeries; + } + + LineChart chart() { + return chart; + } + + NumberAxis xAxis() { + return xAxis; + } + + NumberAxis yAxis() { + return yAxis; + } + + XYChart.Series priceIndexSeries() { + return priceIndexSeries; + } + + private final LineChart chart; + private final NumberAxis xAxis; + private final NumberAxis yAxis; + private final XYChart.Series priceIndexSeries; + private List renderedHistory = List.of(); + } + + private static BigDecimal max(BigDecimal currentMaximum, BigDecimal candidate) { + return currentMaximum.max(candidate.abs()); + } + private void showWindow() { if (window != null && window.isShowing()) { window.toFront(); @@ -93,35 +212,6 @@ public final class EvelynMissionControlImpl implements return tab; } - static StatusIndexChart createStatusIndexChart() { - NumberAxis xAxis = new NumberAxis(0, 1, 1); - xAxis.setLabel("Time"); - xAxis.setTickLabelFormatter(TIMESTAMP_FORMATTER); - xAxis.setForceZeroInRange(false); - - double yBound = EMPTY_Y_BOUND; - NumberAxis yAxis = new NumberAxis(-yBound, yBound, yBound / 5.0); - yAxis.setLabel("Index value"); - yAxis.setForceZeroInRange(true); - - LineChart chart = new LineChart<>(xAxis, yAxis); - chart.setTitle("Evelyn Status Index History"); - chart.setCreateSymbols(false); - chart.setAnimated(false); - XYChart.Series priceIndexSeries = createSeries( - "Evelyn Price Index", - List.of(), - EvelynStatusIndexPoint::evelynPriceIndex - ); - chart.getData().add(priceIndexSeries); - //chart.getData().add(createSeries("EVE_SYRUP Pool Depth Index", history, EvelynStatusIndexPoint::eveSyrupPoolDepthIndex)); - //chart.getData().add(createSeries("EVE_SYRUP Pool Balance Index", history, EvelynStatusIndexPoint::eveSyrupPoolBalanceIndex)); - //chart.getData().add(createSeries("AAZDKK_USDT Pool Balance Index", history, EvelynStatusIndexPoint::aazdkkUsdtPoolBalanceIndex)); - //chart.getData().add(createSeries("AAZDKK_USDT Pool Price Index", history, EvelynStatusIndexPoint::aazdkkUsdtPoolPriceIndex)); - //chart.getData().add(createSeries("AAZDKK_USDT Pool Depth Index", history, EvelynStatusIndexPoint::aazdkkUsdtPoolDepthIndex)); - return new StatusIndexChart(chart, xAxis, yAxis, priceIndexSeries); - } - private static XYChart.Series createSeries( String name, List history, @@ -138,60 +228,6 @@ public final class EvelynMissionControlImpl implements return series; } - static double calculateYBound(List history) { - BigDecimal maxAbsoluteValue = BigDecimal.ZERO; - for (EvelynStatusIndexPoint point : history) { - maxAbsoluteValue = max(maxAbsoluteValue, point.evelynPriceIndex()); - //maxAbsoluteValue = max(maxAbsoluteValue, point.eveSyrupPoolDepthIndex()); - //maxAbsoluteValue = max(maxAbsoluteValue, point.eveSyrupPoolBalanceIndex()); - //maxAbsoluteValue = max(maxAbsoluteValue, point.aazdkkUsdtPoolBalanceIndex()); - //maxAbsoluteValue = max(maxAbsoluteValue, point.aazdkkUsdtPoolPriceIndex()); - //maxAbsoluteValue = max(maxAbsoluteValue, point.aazdkkUsdtPoolDepthIndex()); - } - - double bound = maxAbsoluteValue.doubleValue(); - return bound == 0.0 ? EMPTY_Y_BOUND : bound; - } - - private static BigDecimal max(BigDecimal currentMaximum, BigDecimal candidate) { - return currentMaximum.max(candidate.abs()); - } - - static void refreshChart( - StatusIndexChart statusIndexChart, - List history - ) { - if (!Platform.isFxApplicationThread()) { - throw new IllegalStateException("Status-index charts must be updated on the JavaFX Application Thread"); - } - - int commonPointCount = 0; - int maximumCommonPointCount = Math.min( - history.size(), - statusIndexChart.renderedHistory.size() - ); - while (commonPointCount < maximumCommonPointCount - && history.get(commonPointCount).equals( - statusIndexChart.renderedHistory.get(commonPointCount) - )) { - commonPointCount++; - } - if (commonPointCount < statusIndexChart.renderedHistory.size()) { - statusIndexChart.priceIndexSeries().getData().clear(); - statusIndexChart.renderedHistory = List.of(); - commonPointCount = 0; - } - for (int index = commonPointCount; index < history.size(); index++) { - EvelynStatusIndexPoint point = history.get(index); - statusIndexChart.priceIndexSeries().getData().add(new XYChart.Data<>( - point.timestamp().toEpochMilli(), - point.evelynPriceIndex() - )); - } - statusIndexChart.renderedHistory = List.copyOf(history); - updateAxisBounds(statusIndexChart, history); - } - private static void updateAxisBounds( StatusIndexChart statusIndexChart, List history @@ -257,42 +293,6 @@ public final class EvelynMissionControlImpl implements refreshChart(testChart, evelynStatusTest.getStatusIndexHistory()); } - static final class StatusIndexChart { - private StatusIndexChart( - LineChart chart, - NumberAxis xAxis, - NumberAxis yAxis, - XYChart.Series priceIndexSeries - ) { - this.chart = chart; - this.xAxis = xAxis; - this.yAxis = yAxis; - this.priceIndexSeries = priceIndexSeries; - } - - LineChart chart() { - return chart; - } - - NumberAxis xAxis() { - return xAxis; - } - - NumberAxis yAxis() { - return yAxis; - } - - XYChart.Series priceIndexSeries() { - return priceIndexSeries; - } - - private final LineChart chart; - private final NumberAxis xAxis; - private final NumberAxis yAxis; - private final XYChart.Series priceIndexSeries; - private List renderedHistory = List.of(); - } - private static final String PRODUCTION_COLOR = "#ffd6d6"; private static final String TEST_COLOR = "#d8f3dc"; private static final double EMPTY_Y_BOUND = 1.0; @@ -301,6 +301,7 @@ public final class EvelynMissionControlImpl implements private static final DateTimeFormatter TIMESTAMP_TICK_FORMATTER = DateTimeFormatter.ofPattern("HH:mm dd/MM/yy") .withZone(ZoneId.of("Europe/Copenhagen")); + private static final StringConverter TIMESTAMP_FORMATTER = new StringConverter<>() { @Override public String toString(Number timestamp) {