From 17a613541a95e792e90a0d498bdb1f88319011f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rg=20Prante?= Date: Mon, 13 Dec 2021 21:21:39 +0100 Subject: [PATCH] cosmetic changes --- .../org/xbib/graphics/chart/io/CSVImporter.java | 15 +++++++-------- graphics-pdfbox-layout/build.gradle | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/graphics-chart/src/main/java/org/xbib/graphics/chart/io/CSVImporter.java b/graphics-chart/src/main/java/org/xbib/graphics/chart/io/CSVImporter.java index 777b899..f38a7e9 100644 --- a/graphics-chart/src/main/java/org/xbib/graphics/chart/io/CSVImporter.java +++ b/graphics-chart/src/main/java/org/xbib/graphics/chart/io/CSVImporter.java @@ -7,7 +7,7 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.nio.file.FileVisitOption; import java.nio.file.FileVisitResult; import java.nio.file.Files; @@ -35,7 +35,7 @@ public class CSVImporter { Theme theme) throws IOException { XYChart chart = new XYChart(width, height, theme); final PathMatcher pathMatcher = path.getFileSystem().getPathMatcher("glob:*.csv"); - Files.walkFileTree(path, EnumSet.of(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE, new SimpleFileVisitor() { + Files.walkFileTree(path, EnumSet.of(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE, new SimpleFileVisitor<>() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { if (pathMatcher.matches(file.getFileName())) { @@ -45,12 +45,11 @@ public class CSVImporter { } else { xAndYData = getSeriesDataFromCSVColumns(Files.newInputStream(file)); } + String base = file.toString().substring(0, file.toString().indexOf(".csv")); if (xAndYData[2] == null || xAndYData[2].trim().equalsIgnoreCase("")) { - chart.addSeries(file.toString().substring(0, file.toString().indexOf(".csv")), - getAxisData(xAndYData[0]), getAxisData(xAndYData[1])); + chart.addSeries(base, getAxisData(xAndYData[0]), getAxisData(xAndYData[1])); } else { - chart.addSeries(file.toString().substring(0, file.toString().indexOf(".csv")), - getAxisData(xAndYData[0]), getAxisData(xAndYData[1]), getAxisData(xAndYData[2])); + chart.addSeries(base, getAxisData(xAndYData[0]), getAxisData(xAndYData[1]), getAxisData(xAndYData[2])); } } return FileVisitResult.CONTINUE; @@ -62,7 +61,7 @@ public class CSVImporter { private static String[] getSeriesDataFromCSVRows(InputStream inputStream) throws IOException { String[] xAndYData = new String[3]; try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, - Charset.forName("UTF-8")))) { + StandardCharsets.UTF_8))) { int counter = 0; String line = null; while ((line = bufferedReader.readLine()) != null) { @@ -78,7 +77,7 @@ public class CSVImporter { xAndYData[1] = ""; xAndYData[2] = ""; try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, - Charset.forName("UTF-8")))) { + StandardCharsets.UTF_8))) { String line = null; while ((line = bufferedReader.readLine()) != null) { String[] dataArray = line.split(","); diff --git a/graphics-pdfbox-layout/build.gradle b/graphics-pdfbox-layout/build.gradle index ed13cc4..2a004c5 100644 --- a/graphics-pdfbox-layout/build.gradle +++ b/graphics-pdfbox-layout/build.gradle @@ -1,8 +1,8 @@ dependencies { api project(':graphics-pdfbox') api project(':graphics-barcode') + api project(':graphics-chart') api "org.xbib:settings-datastructures:${project.property('xbib-content.version')}" - //api "io.sf.carte:echosvg-bridge:${project.property('echosvg.version')}" runtimeOnly "org.xbib:settings-datastructures-json:${project.property('xbib-content.version')}" runtimeOnly "org.xbib:settings-datastructures-yaml:${project.property('xbib-content.version')}" }