From e176bd4770ee1ef41f3a9e53aaf4d2f5c0f50ef5 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Mon, 4 Jan 2021 11:46:25 +0100 Subject: [PATCH] Issue #547: Re-add API endpoints required for manual zoom. --- .../xchart/internal/chartpart/Chart.java | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Chart.java b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Chart.java index 0bd12014c..83ca6f0cd 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Chart.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Chart.java @@ -241,6 +241,54 @@ Format getYAxisFormat(String yAxisDecimalPattern) { return format; } + public double getChartXFromCoordinate(int screenX) { + + if (axisPair == null) { + return Double.NaN; + } + return axisPair.getXAxis().getChartValue(screenX); + } + + public double getChartYFromCoordinate(int screenY) { + + if (axisPair == null) { + return Double.NaN; + } + return axisPair.getYAxis().getChartValue(screenY); + } + + public double getChartYFromCoordinate(int screenY, int yIndex) { + + if (axisPair == null) { + return Double.NaN; + } + return axisPair.getYAxis(yIndex).getChartValue(screenY); + } + + public double getScreenXFromChart(double xValue) { + + if (axisPair == null) { + return Double.NaN; + } + return axisPair.getXAxis().getScreenValue(xValue); + } + + public double getScreenYFromChart(double yValue) { + + if (axisPair == null) { + return Double.NaN; + } + return axisPair.getYAxis().getScreenValue(yValue); + } + + public double getScreenYFromChart(double yValue, int yIndex) { + + if (axisPair == null) { + return Double.NaN; + } + return axisPair.getYAxis(yIndex).getScreenValue(yValue); + } + // ArrayList getAnnotations() { // // return annotations;