From a6baf786446b30a045b604ba64deb93dd226c058 Mon Sep 17 00:00:00 2001 From: Richeeyyy <richard.schmidt@mailbox.tu-dresden.de> Date: Thu, 25 Jul 2019 20:44:10 +0200 Subject: [PATCH] Resolve checkstyle violations and change the names of class variables --- .../commandline/CommandLineParser.java | 2 +- .../configparser/Configurable.java | 6 +- .../configparser/ConfigurationParser.java | 6 +- .../configparser/ConfigurationValidator.java | 4 +- .../mci/brailleplot/configparser/Format.java | 2 +- .../configparser/FormatProperty.java | 8 +- .../JavaPropertiesConfigurationValidator.java | 12 +- .../configparser/PrinterProperty.java | 2 +- .../configparser/ValidProperty.java | 6 +- .../csvparser/CategorialPointListList.java | 2 +- .../mci/brailleplot/csvparser/Constants.java | 2 +- .../csvparser/CoordinateSystem.java | 54 ++--- .../brailleplot/csvparser/CsvDotParser.java | 10 +- .../mci/brailleplot/csvparser/CsvType.java | 2 +- .../CsvXAlignedCategoriesParser.java | 8 +- .../csvparser/CsvXAlignedParser.java | 57 +++--- .../mci/brailleplot/csvparser/MetricAxis.java | 81 +++++--- .../brailleplot/csvparser/NominalAxis.java | 48 +++-- .../inf/mci/brailleplot/csvparser/Point.java | 184 +++++++++++------- .../brailleplot/csvparser/PointListList.java | 146 ++++++++------ .../inf/mci/brailleplot/csvparser/Range.java | 98 +++++----- .../mci/brailleplot/csvparser/SvgTools.java | 62 ++++-- .../inf/mci/brailleplot/csvparser/XType.java | 2 +- .../brailleplot/csvparser/package-info.java | 2 +- .../mci/brailleplot/diagrams/BarChart.java | 30 +-- .../inf/mci/brailleplot/diagrams/Diagram.java | 18 +- .../mci/brailleplot/diagrams/LinePlot.java | 4 +- .../mci/brailleplot/diagrams/ScatterPlot.java | 4 +- .../brailleplot/diagrams/package-info.java | 2 +- .../brailleplot/printabledata/MatrixData.java | 2 +- .../brailleplot/printabledata/Point2D.java | 10 +- .../printabledata/Point2DValued.java | 6 +- .../printabledata/SimpleMatrixDataImpl.java | 4 +- src/main/resources/Bundle.properties | 68 +++---- ...JavaPropertiesConfigurationParserTest.java | 6 +- .../illegalPropertyNameExample.properties | 4 +- src/test/resources/mapping.properties | 6 +- .../missingRequiredPropertyExample.properties | 2 +- 38 files changed, 552 insertions(+), 420 deletions(-) diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/commandline/CommandLineParser.java b/src/main/java/de/tudresden/inf/mci/brailleplot/commandline/CommandLineParser.java index f36ad63a..d035c228 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/commandline/CommandLineParser.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/commandline/CommandLineParser.java @@ -24,7 +24,7 @@ public class CommandLineParser { mOptions.addOption("h", SettingType.DISPLAY_HELP.toString(), false, "Print help and exit") .addOption("c", SettingType.CSV_LOCATION.toString(), true, "Path to CSV") .addOption("s", SettingType.SEMANTIC_MAPPING.toString(), true, "Literal for semantic mapping") - .addOption("p", SettingType.PRINTER_CONFIG_PATH.toString(), true, "path to printer configuration file"); + .addOption("mP", SettingType.PRINTER_CONFIG_PATH.toString(), true, "path to printer configuration file"); } /** diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/Configurable.java b/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/Configurable.java index b060ffc2..4e7a5989 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/Configurable.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/Configurable.java @@ -39,10 +39,10 @@ abstract class Configurable { } /** - * Get the property for the given property name. - * @param propertyName The name of the property. + * Get the property for the given property mName. + * @param propertyName The mName of the property. * @return A {@link ValidProperty} object that represents the property. - * @throws NoSuchElementException If no property has the specified name. + * @throws NoSuchElementException If no property has the specified mName. */ public final ValidProperty getProperty(final String propertyName) { // look for property diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/ConfigurationParser.java b/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/ConfigurationParser.java index 4eeaccb9..28e7976a 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/ConfigurationParser.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/ConfigurationParser.java @@ -63,7 +63,7 @@ public abstract class ConfigurationParser { /** * Get the names of all available format configurations. - * @return A {@link Set}<{@link String}> containing the name of each format. + * @return A {@link Set}<{@link String}> containing the mName of each format. */ public final Set<String> getFormatNames() { return mFormats.keySet(); @@ -71,9 +71,9 @@ public abstract class ConfigurationParser { /** * Get a specific format configuration. - * @param formatName The name of the format. + * @param formatName The mName of the format. * @return A {@link Format} object, representing the formats properties. - * @throws NoSuchElementException If no format has the specified name. + * @throws NoSuchElementException If no format has the specified mName. */ public final Format getFormat(final String formatName) { if (!mFormats.containsKey(formatName)) { diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/ConfigurationValidator.java b/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/ConfigurationValidator.java index 8235bc28..1659a9c8 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/ConfigurationValidator.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/ConfigurationValidator.java @@ -8,8 +8,8 @@ package de.tudresden.inf.mci.brailleplot.configparser; interface ConfigurationValidator { /** * Check whether a given pair of key and value is valid as a property or not. - * This method should check the key to be a legal property name and the corresponding type. - * @param key The property key/name + * This method should check the key to be a legal property mName and the corresponding type. + * @param key The property key/mName * @param value The property value * @return A {@link ValidProperty} object representing the validated property. * @throws ConfigurationValidationException On any error while checking the parsed properties validity. diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/Format.java b/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/Format.java index da454008..92100a33 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/Format.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/Format.java @@ -25,7 +25,7 @@ public final class Format extends Configurable { /** * Constructor. * @param properties A {@link List} of {@link FormatProperty} objects. - * @param formatName The name of the format. (e.g. 'A4') + * @param formatName The mName of the format. (e.g. 'A4') */ public Format(final List<FormatProperty> properties, final String formatName) { mFormatName = Objects.requireNonNull(formatName); diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/FormatProperty.java b/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/FormatProperty.java index 05700826..5ff279c7 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/FormatProperty.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/FormatProperty.java @@ -11,8 +11,8 @@ public final class FormatProperty extends ValidProperty { /** * Constructor. * - * @param format The name of the format. - * @param name The name of the property. + * @param format The mName of the format. + * @param name The mName of the property. * @param value The value of the property. */ public FormatProperty(final String format, final String name, final String value) { @@ -21,8 +21,8 @@ public final class FormatProperty extends ValidProperty { } /** - * Get the name of the format. - * @return A {@link String} containing the format name. + * Get the mName of the format. + * @return A {@link String} containing the format mName. */ public String getFormat() { return mFormat; diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/JavaPropertiesConfigurationValidator.java b/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/JavaPropertiesConfigurationValidator.java index 19d61e8b..1f8e34a4 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/JavaPropertiesConfigurationValidator.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/JavaPropertiesConfigurationValidator.java @@ -38,7 +38,7 @@ class JavaPropertiesConfigurationValidator implements ConfigurationValidator { // Definition of valid printer properties Map<String, Predicate<String>> p = new HashMap<>(); - definePrinterProperty("name", requireNotEmpty); + definePrinterProperty("mName", requireNotEmpty); definePrinterProperty("mode", requireNotEmpty); definePrinterProperty("brailletable", requireFileExists); definePrinterProperty("floatingDot.support", requireBoolean); @@ -72,7 +72,7 @@ class JavaPropertiesConfigurationValidator implements ConfigurationValidator { /** * Use this function in the validators constructor to add a printer property definition to the internal validation table. * The property will be treated as 'required'. - * @param propertyName The name of the property. (The prefix 'printer.' must be omitted.) + * @param propertyName The mName of the property. (The prefix 'printer.' must be omitted.) * @param validation The validation predicate. {@link Predicate}<{@link String}> */ private void definePrinterProperty(final String propertyName, final Predicate<String> validation) { @@ -80,7 +80,7 @@ class JavaPropertiesConfigurationValidator implements ConfigurationValidator { } /** * Use this function in the validators constructor to add a printer property definition to the internal validation table. - * @param propertyName The name of the property. (The prefix 'printer.' must be omitted.) + * @param propertyName The mName of the property. (The prefix 'printer.' must be omitted.) * @param validation The validation predicate. {@link Predicate}<{@link String}> * @param required Signals whether this is a required property or not. */ @@ -90,7 +90,7 @@ class JavaPropertiesConfigurationValidator implements ConfigurationValidator { /** * Use this function in the validators constructor to add a format property definition to the internal validation table. * The property will be treated as 'required'. - * @param propertyName The name of the property. (The prefix 'format.[name].' must be omitted.) + * @param propertyName The mName of the property. (The prefix 'format.[mName].' must be omitted.) * @param validation The validation predicate. {@link Predicate}<{@link String}> */ private void defineFormatProperty(final String propertyName, final Predicate<String> validation) { @@ -98,7 +98,7 @@ class JavaPropertiesConfigurationValidator implements ConfigurationValidator { } /** * Use this function in the validators constructor to add a format property definition to the internal validation table. - * @param propertyName The name of the property. (The prefix 'format.[name].' must be omitted.) + * @param propertyName The mName of the property. (The prefix 'format.[mName].' must be omitted.) * @param validation The validation predicate. {@link Predicate}<{@link String}> * @param required Signals whether this is a required property or not. */ @@ -184,7 +184,7 @@ class JavaPropertiesConfigurationValidator implements ConfigurationValidator { ) throws ConfigurationValidationException { // Is the property valid? if (!validation.containsKey(propertyName)) { - throw new ConfigurationValidationException("Invalid property name: " + propertyName); + throw new ConfigurationValidationException("Invalid property mName: " + propertyName); } // Check against its type requirement predicate if (!validation.get(propertyName).test(value)) { diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/PrinterProperty.java b/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/PrinterProperty.java index 753a81f0..65cd7dad 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/PrinterProperty.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/PrinterProperty.java @@ -10,7 +10,7 @@ public final class PrinterProperty extends ValidProperty { /** * Constructor. * - * @param name The name of the property. + * @param name The mName of the property. * @param value The value of the property. */ public PrinterProperty(final String name, final String value) { diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/ValidProperty.java b/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/ValidProperty.java index 1e6cab25..591b2e19 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/ValidProperty.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/ValidProperty.java @@ -1,7 +1,7 @@ package de.tudresden.inf.mci.brailleplot.configparser; /** - * Representation of a property consisting of a legal property name and value. + * Representation of a property consisting of a legal property mName and value. * @author Leonard Kupper * @version 2019.06.04 */ @@ -18,8 +18,8 @@ public abstract class ValidProperty { } /** - * Get the name of the property. - * @return A {@link String} containing the property name. + * Get the mName of the property. + * @return A {@link String} containing the property mName. */ public final String getName() { return mName; diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/CategorialPointListList.java b/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/CategorialPointListList.java index 89052be1..2dab709a 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/CategorialPointListList.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/CategorialPointListList.java @@ -4,7 +4,7 @@ import java.util.ArrayList; import java.util.List; /** - * A {@link PointListList} storing a list of category names. The x values of the + * A {@link PointListList} storing a list of category names. The mX values of the * added points should correspond to the index of their category in the category * list. */ diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/Constants.java b/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/Constants.java index d8e31462..31ceeefb 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/Constants.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/Constants.java @@ -21,7 +21,7 @@ public final class Constants { public static final List<Integer> MARGIN = Collections.unmodifiableList(Arrays.asList(15, 10, 15, 10)); /** List of letters for function naming. */ public static final List<String> FN_LIST = Collections - .unmodifiableList(Arrays.asList("f", "g", "h", "i", "j", "k", "l", "m", "o", "p", "q", "r")); + .unmodifiableList(Arrays.asList("f", "g", "h", "i", "j", "k", "l", "m", "o", "mP", "q", "r")); /** List of letters for point naming. */ public static final List<String> PN_LIST = Collections.unmodifiableList( Arrays.asList("A", "B", "C", "D", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "T")); diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/CoordinateSystem.java b/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/CoordinateSystem.java index 5b631415..fe03d648 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/CoordinateSystem.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/CoordinateSystem.java @@ -26,7 +26,7 @@ public class CoordinateSystem { public static final int CONSTANT = 3; /** - * Constructor for a coordinate system with a nominal x axis. TODO replace + * Constructor for a coordinate system with a nominal mX axis. TODO replace * by a factory in order to avoid code duplication * * @param xCategories @@ -40,8 +40,8 @@ public class CoordinateSystem { this.mSize = new Point(size); this.mSize.setX(this.mSize.getX() - (diagramContentMargin.get(1) + diagramContentMargin.get(CONSTANT))); this.mSize.setY(this.mSize.getY() - (diagramContentMargin.get(0) + diagramContentMargin.get(2))); - // this.mSize.x = Math.min(this.mSize.x, this.mSize.y); - // this.mSize.y = this.mSize.x; + // this.mSize.mX = Math.min(this.mSize.mX, this.mSize.mY); + // this.mSize.mY = this.mSize.mX; mXAxis = new NominalAxis(xCategories, this.mSize.getX(), xUnit); mYAxis = new MetricAxis(yRange, this.mSize.getY(), yRange.getName(), yUnit); @@ -69,8 +69,8 @@ public class CoordinateSystem { this.mSize = new Point(size); this.mSize.setX(this.mSize.getX() - (diagramContentMargin.get(1) + diagramContentMargin.get(CONSTANT))); this.mSize.setY(this.mSize.getY() - (diagramContentMargin.get(0) + diagramContentMargin.get(2))); - // this.mSize.x = Math.min(this.mSize.x, this.mSize.y); - // this.mSize.y = this.mSize.x; + // this.mSize.mX = Math.min(this.mSize.mX, this.mSize.mY); + // this.mSize.mY = this.mSize.mX; mXAxis = new MetricAxis(xRange, this.mSize.getX(), xRange.getName(), xUnit); mYAxis = new MetricAxis(yRange, this.mSize.getY(), yRange.getName(), yUnit); @@ -82,9 +82,9 @@ public class CoordinateSystem { * Converts a point from virtual to real coordinates. * * @param x - * | virtual x coordinate + * | virtual mX coordinate * @param y - * | virtual y coordinate + * | virtual mY coordinate * @return real point */ public Point convert(final double x, final double y) { @@ -99,9 +99,9 @@ public class CoordinateSystem { * Converts a point from virtual to real coordinates using an offset from the axes. * * @param x - * | virtual x coordinate + * | virtual mX coordinate * @param y - * | virtual y coordinate + * | virtual mY coordinate * @return real point */ public Point convertWithOffset(final double x, final double y) { @@ -135,13 +135,13 @@ public class CoordinateSystem { * space. * * @param x - * | virtual x coordinate + * | virtual mX coordinate * @param y - * | virtual y coordinate + * | virtual mY coordinate * @param dx - * | real x transformation + * | real mX transformation * @param dy - * | real y transformation + * | real mY transformation * @return real point */ public Point convert(final double x, final double y, final double dx, final double dy) { @@ -157,9 +157,9 @@ public class CoordinateSystem { * @param point * | virtual coordinates * @param dx - * | real x transformation + * | real mX transformation * @param dy - * | real y transformation + * | real mY transformation * @return real point */ public Point convert(final Point point, final double dx, final double dy) { @@ -167,7 +167,7 @@ public class CoordinateSystem { } /** - * Converts a distance on the x axis from virtual to real. + * Converts a distance on the mX axis from virtual to real. * * @param distance * | virtual distance @@ -178,7 +178,7 @@ public class CoordinateSystem { } /** - * Converts a distance on the y axis from virtual to real. + * Converts a distance on the mY axis from virtual to real. * * @param distance * | virtual distance @@ -200,11 +200,11 @@ public class CoordinateSystem { } /** - * Formats the x value of a point with respect to if Pi is set in the + * Formats the mX value of a point with respect to if Pi is set in the * coordinate system. * * @param x - * x-value + * mX-value * @return formated string for the point */ public String formatX(final double x) { @@ -216,11 +216,11 @@ public class CoordinateSystem { } /** - * Formats the x value of a point with respect to if Pi is set in the + * Formats the mX value of a point with respect to if Pi is set in the * coordinate system, for axis audio labels. * * @param x - * x-value + * mX-value * @return formated string for the point */ public String formatXForAxisSpeech(final double x) { @@ -232,11 +232,11 @@ public class CoordinateSystem { } /** - * Formats the x value of a point with respect to if Pi is set in the - * coordinate system, for symbol audio labels. + * Formats the mX value of a point with respect to if Pi is set in the + * coordinate system, for mSymbol audio labels. * * @param x - * x-value + * mX-value * @return formated string for the point */ public String formatXForSymbolSpeech(final double x) { @@ -248,10 +248,10 @@ public class CoordinateSystem { } /** - * Formats the y value of a point. + * Formats the mY value of a point. * * @param y - * y-value + * mY-value * @return formated string for the point */ public String formatY(final double y) { @@ -259,7 +259,7 @@ public class CoordinateSystem { } /** - * Formats a Point that it is optimized for speech output. E.g. (x / y) + * Formats a Point that it is optimized for speech output. E.g. (mX / mY) * * @param point * The point that should be transformed into a textual diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/CsvDotParser.java b/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/CsvDotParser.java index d3fc4a38..6a1ff79b 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/CsvDotParser.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/CsvDotParser.java @@ -12,8 +12,8 @@ import java.util.List; public class CsvDotParser extends CsvParseAlgorithm { /** - * Parses scattered point data in horizontal data sets, alternating x and y. The - * first column contains the row name in the x row. + * Parses scattered point data in horizontal data sets, alternating mX and mY. The + * first column contains the row mName in the mX row. * * @return the parsed data */ @@ -31,7 +31,7 @@ public class CsvDotParser extends CsvParseAlgorithm { row += 2; - // Get the row name + // Get the row mName if (xRowIterator.hasNext() && yRowIterator.hasNext()) { rowPoints.setName(xRowIterator.next()); yRowIterator.next(); @@ -63,8 +63,8 @@ public class CsvDotParser extends CsvParseAlgorithm { } /** - * Parses scattered point data in vertical data sets, alternating x and y. The - * first row contains the column name in the x column. + * Parses scattered point data in vertical data sets, alternating mX and mY. The + * first row contains the column mName in the mX column. * * @return the parsed data */ diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/CsvType.java b/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/CsvType.java index 0d5bd390..878d1c9e 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/CsvType.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/CsvType.java @@ -5,7 +5,7 @@ import com.beust.jcommander.IStringConverter; /** * Determines what data is represented how by the CSV file. The values are * structural properties, whereas the {@link XType} held by every value - * determines whether the x values are metric or categorial. + * determines whether the mX values are metric or categorial. */ public enum CsvType { DOTS(XType.METRIC), X_ALIGNED(XType.METRIC), X_ALIGNED_CATEGORIES(XType.CATEGORIAL); diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/CsvXAlignedCategoriesParser.java b/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/CsvXAlignedCategoriesParser.java index 9ffd87c9..a4edcbc6 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/CsvXAlignedCategoriesParser.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/CsvXAlignedCategoriesParser.java @@ -23,7 +23,7 @@ public class CsvXAlignedCategoriesParser extends CsvParseAlgorithm { Iterator<String> lineIterator = rowIterator.next().iterator(); - // Move the iterator to the first category name + // Move the iterator to the first category mName if (!lineIterator.hasNext()) { return pointListList; } @@ -34,7 +34,7 @@ public class CsvXAlignedCategoriesParser extends CsvParseAlgorithm { return pointListList; } - // Store all categories + // Store all mCategories while (lineIterator.hasNext()) { pointListList.addCategory(lineIterator.next()); } @@ -58,7 +58,7 @@ public class CsvXAlignedCategoriesParser extends CsvParseAlgorithm { break; } - // Find out the y value + // Find out the mY value Number yValue; try { yValue = Constants.NUMBER_FORMAT.parse(lineIterator.next()); @@ -120,7 +120,7 @@ public class CsvXAlignedCategoriesParser extends CsvParseAlgorithm { String currentCategory = lineIterator.next(); pointListList.addCategory(currentCategory); - // Find out the y values and add the points to the respective lists + // Find out the mY values and add the points to the respective lists int currentDataSet = 0; while (lineIterator.hasNext()) { Number yValue; diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/CsvXAlignedParser.java b/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/CsvXAlignedParser.java index b2c09299..246a3aae 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/CsvXAlignedParser.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/CsvXAlignedParser.java @@ -5,29 +5,34 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; - +/** + * Parser for CSV files with aligned mX-values. Inherits from CsvParseAlgorithm. + */ public class CsvXAlignedParser extends CsvParseAlgorithm { @Override - public PointListList parseAsHorizontalDataSets(List<? extends List<String>> csvData) { + public PointListList parseAsHorizontalDataSets(final List<? extends List<String>> csvData) { PointListList pointListList = new PointListList(); List<Number> xValues = new ArrayList<>(); Iterator<? extends List<String>> rowIterator = csvData.iterator(); - if(!rowIterator.hasNext()) + if (!rowIterator.hasNext()) { return pointListList; + } Iterator<String> lineIterator = rowIterator.next().iterator(); - // Move the iterator to the x value - if(!lineIterator.hasNext()) + // Move the iterator to the mX value + if (!lineIterator.hasNext()) { return pointListList; + } lineIterator.next(); - if(!lineIterator.hasNext()) + if (!lineIterator.hasNext()) { return pointListList; + } - // Store all x values, if one is not specified store NaN - while(lineIterator.hasNext()) { + // Store all mX values, if one is not specified store NaN + while (lineIterator.hasNext()) { Number xValue; try { xValue = Constants.NUMBER_FORMAT.parse(lineIterator.next()); @@ -38,12 +43,13 @@ public class CsvXAlignedParser extends CsvParseAlgorithm { } // Store each row's data set - while(rowIterator.hasNext()) { + while (rowIterator.hasNext()) { lineIterator = rowIterator.next().iterator(); // Create a PointList with the title of the data set - if(!lineIterator.hasNext()) + if (!lineIterator.hasNext()) { continue; + } PointListList.PointList pointList = new PointListList.PointList(); pointList.setName(lineIterator.next()); pointListList.add(pointList); @@ -51,16 +57,17 @@ public class CsvXAlignedParser extends CsvParseAlgorithm { // Add all the points int colPosition = 0; while (lineIterator.hasNext()) { - if(colPosition >= xValues.size()) + if (colPosition >= xValues.size()) { break; + } Number xValue = xValues.get(colPosition); - if(xValue.equals(Double.NaN)) { + if (xValue.equals(Double.NaN)) { lineIterator.next(); colPosition++; continue; } - // Find out the y value + // Find out the mY value Number yValue; try { yValue = Constants.NUMBER_FORMAT.parse(lineIterator.next()); @@ -80,36 +87,40 @@ public class CsvXAlignedParser extends CsvParseAlgorithm { } @Override - public PointListList parseAsVerticalDataSets(List<? extends List<String>> csvData) { + public PointListList parseAsVerticalDataSets(final List<? extends List<String>> csvData) { PointListList pointListList = new PointListList(); Iterator<? extends List<String>> rowIterator = csvData.iterator(); - if(!rowIterator.hasNext()) + if (!rowIterator.hasNext()) { return pointListList; + } Iterator<String> lineIterator = rowIterator.next().iterator(); // Move the iterator to the first title - if(!lineIterator.hasNext()) + if (!lineIterator.hasNext()) { return pointListList; + } lineIterator.next(); - if(!lineIterator.hasNext()) + if (!lineIterator.hasNext()) { return pointListList; + } // Add a PointList for each title - while(lineIterator.hasNext()) { + while (lineIterator.hasNext()) { PointListList.PointList pointList = new PointListList.PointList(); pointList.setName(lineIterator.next()); pointListList.add(pointList); } // Add the data - while(rowIterator.hasNext()) { + while (rowIterator.hasNext()) { lineIterator = rowIterator.next().iterator(); - if(!lineIterator.hasNext()) + if (!lineIterator.hasNext()) { continue; + } - // Find out the x value + // Find out the mX value Number xValue; try { xValue = Constants.NUMBER_FORMAT.parse(lineIterator.next()); @@ -117,9 +128,9 @@ public class CsvXAlignedParser extends CsvParseAlgorithm { continue; } - // Find out the y values and add the points to the respective lists + // Find out the mY values and add the points to the respective lists int currentDataSet = 0; - while(lineIterator.hasNext()) { + while (lineIterator.hasNext()) { Number yValue; try { yValue = Constants.NUMBER_FORMAT.parse(lineIterator.next()); diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/MetricAxis.java b/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/MetricAxis.java index c7494f02..5fe3cf03 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/MetricAxis.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/MetricAxis.java @@ -11,14 +11,26 @@ import java.util.List; * */ public class MetricAxis extends Axis { - public final double atom; - public final int atomCount; - public final List<Double> intervalSteps; - - public MetricAxis(Range axisRange, double size, String title, String unit) { + public final double mAtom; + public final int mAtomCount; + public final List<Double> mIntervalSteps; + public static final double LABEL_OFFSET_HORIZONTAL_X = -5; + public static final double LABEL_OFFSET_HORIZONTAL_Y = 20; + public static final double LABEL_OFFSET_VERTICAL_X = -10; + public static final double LABEL_OFFSET_VERTICAL_Y = 5; + public static final double POINT_OFFSET = 0; + public static final double CONSTANT_0 = 0.5; + public static final double CONSTANT_1 = 10; + public static final double CONSTANT_2 = 100; + public static final double CONSTANT_3 = 2.5; + public static final double CONSTANT_4 = 0.1; + public static final double CONSTANT_5 = 0.05; + public static final double CONSTANT_6 = 0.01; + + public MetricAxis(final Range axisRange, final double size, final String title, final String unit) { // Set the label offsets - super(-5, 20, -10, 5, 0, title, unit); + super(LABEL_OFFSET_HORIZONTAL_X, LABEL_OFFSET_HORIZONTAL_Y, LABEL_OFFSET_VERTICAL_X, LABEL_OFFSET_VERTICAL_Y, POINT_OFFSET, title, unit); boolean finished = false; double interval = 0; @@ -36,14 +48,21 @@ public class MetricAxis extends Axis { // Calculate which interval (virtual) the tics must minimally have. interval = axisRange.distance() / maxTics; dimensionExp = 0; - int direction = interval < 1 ? -1 : 1; - while (direction * 0.5 * Math.pow(10, dimensionExp) < direction * interval) { + + int direction; + if (interval < 1) { + direction = -1; + } else { + direction = 1; + } + + while (direction * CONSTANT_0 * Math.pow(CONSTANT_1, dimensionExp) < direction * interval) { dimensionExp += direction; } if (direction == 1) { dimensionExp--; } - dimension = Math.pow(10, dimensionExp); + dimension = Math.pow(CONSTANT_1, dimensionExp); factor = getFactorForIntervalAndDimension(interval, dimension); finished = true; interval = factor * dimension * 2; @@ -70,26 +89,30 @@ public class MetricAxis extends Axis { mDecimalFormat.setMaximumFractionDigits(Math.max(0, -dimensionExp + 2)); - atom = dimension / 100; - atomCount = (int) (mRange.distance() / atom + 1); + mAtom = dimension / CONSTANT_2; + mAtomCount = (int) (mRange.distance() / mAtom + 1); - intervalSteps = new ArrayList<>(); + mIntervalSteps = new ArrayList<>(); calculateIntervalSteps(dimension, factor); } @Override - public String formatForAxisLabel(double value) { + public String formatForAxisLabel(final double value) { String str = mDecimalFormat.format(value); - return "-0".equals(str) ? "0" : str; + if ("-0".equals(str)) { + return "0"; + } else { + return str; + } } @Override - public String formatForAxisAudioLabel(double value) { + public String formatForAxisAudioLabel(final double value) { return formatForAxisLabel(value); } @Override - public String formatForSymbolAudioLabel(double value) { + public String formatForSymbolAudioLabel(final double value) { return formatForAxisLabel(value); } @@ -97,19 +120,19 @@ public class MetricAxis extends Axis { * @param dimension * @param factor */ - private void calculateIntervalSteps(double dimension, double factor) { + private void calculateIntervalSteps(final double dimension, final double factor) { int i = 0; - if (Math.abs(factor - 2.5) < Constants.EPSILON) { - intervalSteps.add(i++, 2.5 * dimension); - intervalSteps.add(i++, dimension); + if (Math.abs(factor - CONSTANT_3) < Constants.EPSILON) { + mIntervalSteps.add(i++, CONSTANT_3 * dimension); + mIntervalSteps.add(i++, dimension); } else if (Math.abs(factor - 1) < Constants.EPSILON) { - intervalSteps.add(i++, dimension); + mIntervalSteps.add(i++, dimension); } - intervalSteps.add(i++, 0.5 * dimension); - intervalSteps.add(i++, 0.1 * dimension); - intervalSteps.add(i++, 0.05 * dimension); - intervalSteps.add(i, 0.01 * dimension); + mIntervalSteps.add(i++, CONSTANT_0 * dimension); + mIntervalSteps.add(i++, CONSTANT_4 * dimension); + mIntervalSteps.add(i++, CONSTANT_5 * dimension); + mIntervalSteps.add(i, CONSTANT_6 * dimension); } /** @@ -117,14 +140,14 @@ public class MetricAxis extends Axis { * @param dimension * @return the calculated factor */ - private double getFactorForIntervalAndDimension(double interval, double dimension) { + private double getFactorForIntervalAndDimension(final double interval, final double dimension) { double factor; if (interval > dimension) { - factor = 2.5; - } else if (interval > 0.5 * dimension) { + factor = CONSTANT_3; + } else if (interval > CONSTANT_0 * dimension) { factor = 1; } else { - factor = 0.5; + factor = CONSTANT_0; } return factor; } diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/NominalAxis.java b/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/NominalAxis.java index 73706ab3..47bec457 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/NominalAxis.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/NominalAxis.java @@ -11,35 +11,42 @@ import org.slf4j.LoggerFactory; */ public class NominalAxis extends Axis { - static final Logger log = LoggerFactory.getLogger(NominalAxis.class); + static final Logger LOG = LoggerFactory.getLogger(NominalAxis.class); /** - * The categories displayed on the Axis in order. + * The mCategories displayed on the Axis in order. */ - protected List<String> categories; + protected List<String> mCategories; + + public static final double LABEL_OFFSET_HORIZONTAL_X = 15; + public static final double LABEL_OFFSET_HORIZONTAL_Y = -10; + public static final double POINT_OFFSET = 0.5; /** * The nominal axis gets constructed so that each tic corresponds to one - * category. The tics are however shown + * category. The tics are however shown. * * @param categories * @param size * @param unit */ - public NominalAxis(List<String> categories, double size, String unit) { + public NominalAxis(final List<String> categories, final double size, final String unit) { // TODO: upon implementation of vertical nominal axes set the values // correctly - super(Constants.CHAR_WIDTH, 15, -10, -Constants.CHAR_WIDTH, 0.5, null, unit); + super(Constants.CHAR_WIDTH, LABEL_OFFSET_HORIZONTAL_X, LABEL_OFFSET_HORIZONTAL_Y, -Constants.CHAR_WIDTH, POINT_OFFSET, null, unit); - this.categories = categories; + this.mCategories = categories; double categorySize = size / categories.size(); int maxLabelLength = 0; - for (String label : categories) - if (label.length() > maxLabelLength) + for (String label : categories) { + if (label.length() > maxLabelLength) { maxLabelLength = label.length(); + } + } + if (categorySize < Constants.CHAR_WIDTH * (maxLabelLength + 1)) { - log.warn( + LOG.warn( "Der Platz reicht nicht aus, um Achsenbeschriftungen darzustellen. Die längste Beschriftung hat eine Länge von " + maxLabelLength + " Zeichen."); } @@ -56,32 +63,33 @@ public class NominalAxis extends Axis { } @Override - public String formatForAxisLabel(double value) { + public String formatForAxisLabel(final double value) { int categoryNumber = (int) Math.round(value); - if (categories.size() <= categoryNumber || categoryNumber < 0) + if (mCategories.size() <= categoryNumber || categoryNumber < 0) { return null; + } // throw new IllegalArgumentException("The selected category does not // exist"); - return categories.get(categoryNumber); + return mCategories.get(categoryNumber); } @Override - public String formatForAxisAudioLabel(double value) { + public String formatForAxisAudioLabel(final double value) { int categoryNumber = (int) Math.round(value); if (categoryNumber == 0) { - return "|" + categories.get(categoryNumber); - } else if (categoryNumber == categories.size()) { - return categories.get(categoryNumber - 1) + "|"; - } else if (categoryNumber > 0 && categoryNumber < categories.size()) { - return categories.get(categoryNumber - 1) + "|" + categories.get(categoryNumber); + return "|" + mCategories.get(categoryNumber); + } else if (categoryNumber == mCategories.size()) { + return mCategories.get(categoryNumber - 1) + "|"; + } else if (categoryNumber > 0 && categoryNumber < mCategories.size()) { + return mCategories.get(categoryNumber - 1) + "|" + mCategories.get(categoryNumber); } else { return null; } } @Override - public String formatForSymbolAudioLabel(double value) { + public String formatForSymbolAudioLabel(final double value) { return formatForAxisLabel(value); } diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/Point.java b/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/Point.java index 109c8436..84b2566e 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/Point.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/Point.java @@ -6,8 +6,8 @@ import com.beust.jcommander.IStringConverter; /** - * A point in a coordinate system specified by an x and y coordinate. Can also - * have a name and an SVG symbol. Provides helper methods, e.g. for calculating + * A point in a coordinate system specified by an mX and mY coordinate. Can also + * have a mName and an SVG mSymbol. Provides helper methods, e.g. for calculating * the distance between two points. * * @author Gregor Harlan Idea and supervising by Jens Bornschein @@ -17,75 +17,84 @@ import com.beust.jcommander.IStringConverter; */ public class Point implements Comparable<Point> { - protected double x; - protected double y; - protected String name; - protected Element symbol; + protected double mX; + protected double mY; + protected String mName; + protected Element mSymbol; /** - * Copy constructor + * Copy constructor. * * @param otherPoint * the point to copy */ - public Point(Point otherPoint) { - this(otherPoint.getX(), otherPoint.getY(), otherPoint.getName(), - otherPoint.getSymbol() != null ? (Element) otherPoint.getSymbol().cloneNode(true) : null); + public Point(final Point otherPoint) { + this.setX(otherPoint.getX()); + this.setY(otherPoint.getY()); + this.setName(otherPoint.getName()); + + Element symbol; + if (otherPoint.getSymbol() != null) { + symbol = (Element) otherPoint.getSymbol().cloneNode(true); + } else { + symbol = null; + } + this.setSymbol(symbol); } /** - * Represents a two dimensional Point in the plot + * Represents a two dimensional Point in the plot. * * @param x - * | x (horizontal) position of the point + * | mX (horizontal) position of the point * @param y - * | y (vertical) position of the point + * | mY (vertical) position of the point */ - public Point(double x, double y) { + public Point(final double x, final double y) { this(x, y, "", null); } /** - * Represents a two dimensional Point in the plot + * Represents a two dimensional Point in the plot. * * @param x - * | x (horizontal) position of the point + * | mX (horizontal) position of the point * @param y - * | y (vertical) position of the point + * | mY (vertical) position of the point * @param name - * | the name of the point + * | the mName of the point */ - public Point(double x, double y, String name) { + public Point(final double x, final double y, final String name) { this(x, y, name, null); } /** - * Represents a two dimensional Point in the plot + * Represents a two dimensional Point in the plot. * * @param x - * | x (horizontal) position of the point + * | mX (horizontal) position of the point * @param y - * | y (vertical) position of the point + * | mY (vertical) position of the point * @param symbol - * | the symbol to use for the point + * | the mSymbol to use for the point */ - public Point(double x, double y, Element symbol) { + public Point(final double x, final double y, final Element symbol) { this(x, y, "", symbol); } /** - * Represents a two dimensional Point in the plot + * Represents a two dimensional Point in the plot. * * @param x - * | x (horizontal) position of the point + * | mX (horizontal) position of the point * @param y - * | y (vertical) position of the point + * | mY (vertical) position of the point * @param name - * | the name of the point + * | the mName of the point * @param symbol - * | the symbol to use for the point + * | the mSymbol to use for the point */ - public Point(double x, double y, String name, Element symbol) { + public Point(final double x, final double y, final String name, final Element symbol) { this.setX(x); this.setY(y); this.setName(name); @@ -93,20 +102,20 @@ public class Point implements Comparable<Point> { } /** - * Move the point + * Move the point. * * @param dx - * | movement in x (horizontal) direction + * | movement in mX (horizontal) direction * @param dy - * | movement in y (vertical) direction + * | movement in mY (vertical) direction */ - public void translate(double dx, double dy) { + public void translate(final double dx, final double dy) { setX(getX() + dx); setY(getY() + dy); } /** - * formats the x value as an svg compatible decimal value. + * formats the mX value as an svg compatible decimal value. * * @return */ @@ -115,7 +124,7 @@ public class Point implements Comparable<Point> { } /** - * formats the y value as an svg compatible decimal value. + * formats the mY value as an svg compatible decimal value. * * @return */ @@ -125,10 +134,10 @@ public class Point implements Comparable<Point> { @Override /** - * formats the x and y values as svg compatible decimal values and combine + * formats the mX and mY values as svg compatible decimal values and combine * them by a comma. * - * @return x,y + * @return mX,mY */ public String toString() { return x() + "," + y(); @@ -140,103 +149,138 @@ public class Point implements Comparable<Point> { * @param other * | second point * @return the two dimensional euclidean distance between this and the other - * point. + * point */ - public double distance(Point other) { + public double distance(final Point other) { return Math.sqrt(Math.pow(other.getX() - getX(), 2) + Math.pow(other.getY() - getY(), 2)); } + /** + * Converts a string value to the corresponding point object. + * + */ public static class Converter implements IStringConverter<Point> { /** * Convert a formatted string to a point. The format is: - * {@code [<x>][,<y>]} Omitted values will default to 0. + * {@code [<mX>][,<mY>]} Omitted values will default to 0. * * @param value * | formatted string */ @Override - public Point convert(String value) { + public Point convert(final String value) { String[] s = value.split(","); - return new Point(s.length > 0 ? Double.parseDouble(s[0]) : 0, s.length > 1 ? Double.parseDouble(s[1]) : 0); + double x; + double y; + + if (s.length > 0) { + x = Double.parseDouble(s[0]); + } else { + x = 0; + } + + if (s.length > 1) { + y = Double.parseDouble(s[1]); + } else { + y = 0; + } + return new Point(x, y); } } /** - * Compares with x priority. Returns -1 if p2 is null. + * Compares with mX priority. Returns -1 if p2 is null. * * @param p2 * | other point * @return */ @Override - public int compareTo(Point p2) { + public int compareTo(final Point p2) { if (p2 != null) { if (Math.abs(p2.getX() - getX()) < Constants.EPSILON) { - return getY() < p2.getY() ? -1 : 1; - } else - return getX() < p2.getX() ? -1 : 1; + if (getY() < p2.getY()) { + return -1; + } else { + return 1; + } + } else { + if (getX() < p2.getX()) { + return -1; + } else { + return 1; + } + } } return -1; } /** - * Compare the y values of two points. Returns -1 if p2 is null. + * Compare the mY values of two points. Returns -1 if p2 is null. * * @param p2 * | other point * @return */ - public int compareToY(Point p2) { + public int compareToY(final Point p2) { if (p2 != null) { - return getY() < p2.getY() ? -1 : 1; + if (getY() < p2.getY()) { + return -1; + } else { + return 1; + } } return -1; } /** - * Compare the x values of two points. Returns -1 if p2 is null. + * Compare the mX values of two points. Returns -1 if p2 is null. * * @param p2 * | other point * @return */ - public int compareToX(Point p2) { + public int compareToX(final Point p2) { if (p2 != null) { - return getX() < p2.getX() ? -1 : 1; + if (getX() < p2.getX()) { + return -1; + } else { + return 1; + } } return -1; } - public double getX() { - return x; + public final double getX() { + return mX; } - public void setX(double x) { - this.x = x; + public final void setX(final double x) { + this.mX = x; } - public double getY() { - return y; + public final double getY() { + return mY; } - public void setY(double y) { - this.y = y; + public final void setY(final double y) { + this.mY = y; } - public String getName() { - return name; + public final String getName() { + return mName; } - public void setName(String name) { - this.name = name; + public final void setName(final String name) { + this.mName = name; } - public Element getSymbol() { - return symbol; + public final Element getSymbol() { + return mSymbol; } - public void setSymbol(Element symbol) { - this.symbol = symbol; + public final void setSymbol(final Element symbol) { + this.mSymbol = symbol; } } diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/PointListList.java b/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/PointListList.java index b9656bb5..087499a4 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/PointListList.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/PointListList.java @@ -16,11 +16,15 @@ import com.beust.jcommander.IStringConverter; public class PointListList extends ArrayList<PointListList.PointList> { private static final long serialVersionUID = 6902232865786868851L; - protected Double maxX = Double.NEGATIVE_INFINITY; - protected Double maxY = Double.NEGATIVE_INFINITY; - protected Double minX = Double.POSITIVE_INFINITY; - protected Double minY = Double.POSITIVE_INFINITY; + protected Double mMaxX = Double.NEGATIVE_INFINITY; + protected Double mMaxY = Double.NEGATIVE_INFINITY; + protected Double mMinX = Double.POSITIVE_INFINITY; + protected Double mMinY = Double.POSITIVE_INFINITY; + /** + * May be extended. + * @return + */ public XType getXType() { return XType.METRIC; } @@ -29,10 +33,11 @@ public class PointListList extends ArrayList<PointListList.PointList> { this(""); } - public PointListList(String pointLists) { + public PointListList(final String pointLists) { - if (pointLists == null || pointLists.isEmpty()) + if (pointLists == null || pointLists.isEmpty()) { return; + } // TODO: load from file @@ -47,55 +52,61 @@ public class PointListList extends ArrayList<PointListList.PointList> { } @Override - public boolean add(PointList pl) { + public boolean add(final PointList pl) { boolean success = super.add(pl); updateMinMax(); return success; } - public boolean add(List<Point> points) { + public final boolean add(final List<Point> points) { PointList pl = new PointList(points); return add(pl); } + /** + * May be extended. + */ public void updateMinMax() { - for(PointList checkPl : this) { - maxX = Math.max(getMaxX(), checkPl.getMaxX()); - maxY = Math.max(getMaxY(), checkPl.getMaxY()); - minX = Math.min(getMinX(), checkPl.getMinX()); - minY = Math.min(getMinY(), checkPl.getMinY()); + for (PointList checkPl : this) { + mMaxX = Math.max(getMaxX(), checkPl.getMaxX()); + mMaxY = Math.max(getMaxY(), checkPl.getMaxY()); + mMinX = Math.min(getMinX(), checkPl.getMinX()); + mMinY = Math.min(getMinY(), checkPl.getMinY()); } } - public double getMaxX() { - return maxX; + public final double getMaxX() { + return mMaxX; } - public double getMaxY() { - return maxY; + public final double getMaxY() { + return mMaxY; } - public double getMinX() { - return minX; + public final double getMinX() { + return mMinX; } - public double getMinY() { - return minY; + public final double getMinY() { + return mMinY; } - public boolean hasValidMinMaxValues() { - return maxX > minX && maxY > minY; + public final boolean hasValidMinMaxValues() { + return mMaxX > mMinX && mMaxY > mMinY; } + /** + * Converts a string value to a corresponding PointListList. + */ public static class Converter implements IStringConverter<PointListList> { @Override - public PointListList convert(String value) { + public PointListList convert(final String value) { return new PointListList(value); } } /** - * List of Points including max values + * List of Points including max values. * * @author Jens Bornschein * @@ -103,13 +114,13 @@ public class PointListList extends ArrayList<PointListList.PointList> { public static class PointList extends ArrayList<Point> { private static final long serialVersionUID = -2318768874799315111L; - private Double maxX = Double.NEGATIVE_INFINITY; - private Double maxY = Double.NEGATIVE_INFINITY; - private Double minX = Double.POSITIVE_INFINITY; - private Double minY = Double.POSITIVE_INFINITY; - private String name = ""; + private Double mMaxX = Double.NEGATIVE_INFINITY; + private Double mMaxY = Double.NEGATIVE_INFINITY; + private Double mMinX = Double.POSITIVE_INFINITY; + private Double mMinY = Double.POSITIVE_INFINITY; + private String mName = ""; - public PointList(List<Point> points) { + public PointList(final List<Point> points) { if (points != null && !points.isEmpty()) { for (Point p : points) { this.insertSorted(p); @@ -117,9 +128,10 @@ public class PointListList extends ArrayList<PointListList.PointList> { } } - public PointList(String points) { - if (points == null || points.isEmpty()) + public PointList(final String points) { + if (points == null || points.isEmpty()) { return; + } String[] pl = points.split("::"); @@ -147,54 +159,55 @@ public class PointListList extends ArrayList<PointListList.PointList> { this(""); } - public boolean insertSorted(Point p) { - maxX = Math.max(getMaxX(), p.getX()); - maxY = Math.max(getMaxY(), p.getY()); - minX = Math.min(getMinX(), p.getX()); - minY = Math.min(getMinY(), p.getY()); + public final boolean insertSorted(final Point p) { + mMaxX = Math.max(getMaxX(), p.getX()); + mMaxY = Math.max(getMaxY(), p.getY()); + mMinX = Math.min(getMinX(), p.getX()); + mMinY = Math.min(getMinY(), p.getY()); boolean returnVal = super.add(p); Comparable<Point> cmp = (Comparable<Point>) p; - for (int i = size()-1; i > 0 && cmp.compareTo(get(i-1)) < 0; i--) - Collections.swap(this, i, i-1); + for (int i = size() - 1; i > 0 && cmp.compareTo(get(i - 1)) < 0; i--) { + Collections.swap(this, i, i - 1); + } return returnVal; } @Deprecated - public void add(int index, Point element) { -// throw new UnsupportedOperationException("Only insertions via insertSorted are allowed"); + public final void add(final int index, final Point element) { +// throw new UnsupportedOperationException("Only insertions via insertSorted are allowed"); this.insertSorted(element); } @Deprecated - public boolean add(Point e) { -// throw new UnsupportedOperationException("Only insertions via insertSorted are allowed"); + public final boolean add(final Point e) { +// throw new UnsupportedOperationException("Only insertions via insertSorted are allowed"); return this.insertSorted(e); } - public double getMaxX() { - return maxX; + public final double getMaxX() { + return mMaxX; } - public double getMaxY() { - return maxY; + public final double getMaxY() { + return mMaxY; } - public double getMinX() { - return minX; + public final double getMinX() { + return mMinX; } - public double getMinY() { - return minY; + public final double getMinY() { + return mMinY; } - public String getName() { - return name; + public final String getName() { + return mName; } - public void setName(String name) { - this.name = name; + public final void setName(final String name) { + this.mName = name; } /** @@ -203,14 +216,16 @@ public class PointListList extends ArrayList<PointListList.PointList> { * @return first maximum point */ public Point getFirstMaximum() { - if(this.isEmpty()) + if (this.isEmpty()) { return null; + } Point maxPoint = get(0); - for(Point p : this) { - if(maxPoint.getY() < p.getY()) + for (Point p : this) { + if (maxPoint.getY() < p.getY()) { maxPoint = p; + } } return maxPoint; @@ -222,22 +237,27 @@ public class PointListList extends ArrayList<PointListList.PointList> { * @return first minimum point */ public Point getFirstMinimum() { - if(this.isEmpty()) + if (this.isEmpty()) { return null; + } Point minPoint = get(0); - for(Point p : this) { - if(minPoint.getY() > p.getY()) + for (Point p : this) { + if (minPoint.getY() > p.getY()) { minPoint = p; + } } return minPoint; } + /** + * Converts a string value to the corresponding PointList. + */ public class Converter implements IStringConverter<PointList> { @Override - public PointList convert(String value) { + public PointList convert(final String value) { return new PointList(value.trim()); } } diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/Range.java b/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/Range.java index 6cd7f50d..24ee6e7b 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/Range.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/Range.java @@ -9,31 +9,34 @@ import com.beust.jcommander.IStringConverter; * */ public class Range { - /** Start of the range */ - private double from; - /** End of the range */ - private double to; + /** Start of the range. */ + private double mFrom; + /** End of the range. */ + private double mTo; - private String name; + private String mName; + + public static final double CONSTANT_0 = -8; + public static final double CONSTANT_1 = 8; /** - * Constructor with name. - * @param from | start of the range - * @param to | end of the range + * Constructor with mName. + * @param from | start of the range + * @param to | end of the range * @param name */ - public Range(double from, double to, String name) { - this.from = from; - this.to = to; - this.name = name; + public Range(final double from, final double to, final String name) { + this.mFrom = from; + this.mTo = to; + this.mName = name; } /** - * Constructor without name. - * @param from | start of the range - * @param to | end of the range + * Constructor without mName. + * @param from | start of the range + * @param to | end of the range */ - public Range(double from, double to) { + public Range(final double from, final double to) { this(from, to, ""); } @@ -42,76 +45,79 @@ public class Range { * @return distance */ public double distance() { - return to - from; + return mTo - mFrom; } @Override public String toString() { - return name + " " + from + ":" + to; + return mName + " " + mFrom + ":" + mTo; } /** - * Converter class for parsing ranges from strings. + * Converter class for parsing ranges mFrom strings. */ public static class Converter implements IStringConverter<Range> { /** - * Converts a range specified by a string to a {@link Range} instance. - * The syntax is: {@code [["]<name>["]::]<from>:<to>[:<name>]}. - * The second name parameter is preferred. - * The from and to parameters should be parsable as Double. + * Converts a range specified by a string mTo a {@link Range} instance. + * The syntax is: {@code [["]<mName>["]::]<mFrom>:<mTo>[:<mName>]}. + * The second mName parameter is preferred. + * The mFrom and mTo parameters should be parsable as Double. * - * @param value | correctly formatted range string + * @param value | correctly formatted range string */ @Override - public Range convert(String value) { + public Range convert(final String value) { String[] parts = value.split("::"); String[] s; String name = ""; - // Extract the name if specified and remove quotations - if(parts.length > 1){ + // Extract the mName if specified and remove quotations + if (parts.length > 1) { name = parts[0].replace("\"", "").trim(); s = parts[1].split(":"); - }else{ + } else { s = parts[0].split(":"); } // There were not enough parameters specified. - if (s.length < 2) - return new Range(-8, 8); + if (s.length < 2) { + return new Range(CONSTANT_0, CONSTANT_1); + } /* - * If there are two parameters, use the first name string, + * If there are two parameters, use the first mName string, * if there are more, use the second one. */ - return s.length > 2 ? new Range(Double.parseDouble(s[0]), - Double.parseDouble(s[1]), s[2]) : new Range( - Double.parseDouble(s[0]), Double.parseDouble(s[1]), name); + if (s.length > 2) { + return new Range(Double.parseDouble(s[0]), Double.parseDouble(s[1]), s[2]); + } else { + return new Range(Double.parseDouble(s[0]), Double.parseDouble(s[1]), name); } + } } - public double getFrom() { - return from; + public final double getFrom() { + return mFrom; } - public void setFrom(double from) { - this.from = from; + public final void setFrom(final double from) { + this.mFrom = from; } - public double getTo() { - return to; + public final double getTo() { + return mTo; } - public void setTo(double to) { - this.to = to; + public final void setTo(final double to) { + this.mTo = to; } - public String getName() { - return name; + public final String getName() { + return mName; } - public void setName(String name) { - this.name = name; + public final void setName(final String name) { + this.mName = name; } } diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/SvgTools.java b/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/SvgTools.java index 194313c9..02fd8eb2 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/SvgTools.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/SvgTools.java @@ -2,32 +2,39 @@ package de.tudresden.inf.mci.brailleplot.csvparser; import java.text.MessageFormat; -public class SvgTools { +/** + * Class with methods needed vor SVG. + */ +public final class SvgTools { private SvgTools() { } /** - * Format a number for svg usage according to the constant DECIMAL_FORMAT + * Format a number for svg usage according to the constant DECIMAL_FORMAT. * * @param value * @return */ - public static String format2svg(double value) { + public static String format2svg(final double value) { return Constants.DECIMAL_FORMAT.format(value); } /** - * Formats an additional Name of an object. Checks if the name is set. If - * name is set, the name is packed into brackets and prepend with an + * Formats an additional Name of an object. Checks if the mName is set. If + * mName is set, the mName is packed into brackets and prepend with an * whitespace * * @param name - * | optional name of an object or NULL - * @return empty string or the name of the object packed into brackets and - * prepend with a whitespace e.g. ' (optional name)' + * | optional mName of an object or NULL + * @return empty string or the mName of the object packed into brackets and + * prepend with a whitespace e.g. ' (optional mName)' */ - public static String formatName(String name) { - return (name == null || name.isEmpty()) ? "" : " (" + name + ")"; + public static String formatName(final String name) { + if ((name == null || name.isEmpty())) { + return ""; + } else { + return " (" + name + ")"; + } } /** @@ -42,7 +49,7 @@ public class SvgTools { * @return a localized string for the given PropertyResourceBundle key, * filled with the set arguments */ - public static String translate(String key, Object... arguments) { + public static String translate(final String key, final Object... arguments) { return MessageFormat.format(Constants.BUNDLE.getString(key), arguments); } @@ -60,15 +67,22 @@ public class SvgTools { * @return a localized string for the given amount depending * PropertyResourceBundle key, filled with the set arguments */ - public static String translateN(String key, Object... arguments) { + public static String translateN(final String key, final Object... arguments) { int last = (int) arguments[arguments.length - 1]; - String suffix = last == 0 ? "_0" : last == 1 ? "_1" : "_n"; + String suffix; + if (last == 0) { + suffix = "_0"; + } else if (last == 1) { + suffix = "_1"; + } else { + suffix = "_n"; + } return translate(key + suffix, arguments); } /** * Formats a Point that it is optimized for textual output and packed into - * the caption with brackets. E.g. E(x | y) + * the caption with brackets. E.g. E(mX | mY) * * @param cs * the coordinate system @@ -81,15 +95,19 @@ public class SvgTools { * caption is set, otherwise packed in the caption with brackets and * the '|' as delimiter */ - public static String formatForText(CoordinateSystem cs, Point point, String cap) { + public static String formatForText(final CoordinateSystem cs, final Point point, final String cap) { String p = cs.formatX(point.getX()) + " | " + cs.formatY(point.getY()); String capTrimmed = cap.trim(); - return (capTrimmed != null && !capTrimmed.isEmpty()) ? capTrimmed + "(" + p + ")" : p; + if ((capTrimmed != null && !capTrimmed.isEmpty())) { + return capTrimmed + "(" + p + ")"; + } else { + return p; + } } /** * Try to translate the function index into a continuous literal starting - * with the char 'f'. If the given index is not valid it returns the name as + * with the char 'f'. If the given index is not valid it returns the mName as * a combination of 'f' + the given number. * * @param f @@ -97,15 +115,17 @@ public class SvgTools { * @return a literal representation to the given function index e.g. 'f', * 'g', 'h' or 'f1000'. */ - public static String getFunctionName(int f) { - if (f < 0 || f > (Constants.FN_LIST.size() - 1)) + public static String getFunctionName(final int f) { + if (f < 0 || f > (Constants.FN_LIST.size() - 1)) { return "f" + f; + } return Constants.FN_LIST.get(f); } - public static String getPointName(int p) { - if (p < 0 || p > (Constants.PN_LIST.size() - 1)) + public static String getPointName(final int p) { + if (p < 0 || p > (Constants.PN_LIST.size() - 1)) { return "P" + p; + } return Constants.PN_LIST.get(p); } } diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/XType.java b/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/XType.java index 3523f42b..9fb5a54b 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/XType.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/XType.java @@ -1,7 +1,7 @@ package de.tudresden.inf.mci.brailleplot.csvparser; /** - * Determines whether the x values are metric or categorial. + * Determines whether the mX values are metric or categorial. */ public enum XType { METRIC, CATEGORIAL diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/package-info.java b/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/package-info.java index 55270639..ba140a66 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/package-info.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/csvparser/package-info.java @@ -1,4 +1,4 @@ /** - * CSV parsing + * Package for parsing algorithms for CSV files and classes for data representation. */ package de.tudresden.inf.mci.brailleplot.csvparser; diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/diagrams/BarChart.java b/src/main/java/de/tudresden/inf/mci/brailleplot/diagrams/BarChart.java index 1c715bbd..cb65b679 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/diagrams/BarChart.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/diagrams/BarChart.java @@ -6,14 +6,14 @@ import de.tudresden.inf.mci.brailleplot.csvparser.PointListList; import java.util.List; /** - * Representation of a bar chart. + * Representation of a bar chart with basic data functions. * @author Richard Schmidt */ -public class BarChart { - private CategorialPointListList p; +public class BarChart /*implements Renderable*/ { + private CategorialPointListList mP; public BarChart(final CategorialPointListList p) { - this.p = p; + this.mP = p; p.updateMinMax(); } @@ -22,7 +22,7 @@ public class BarChart { * @return */ public int getCategoryCount() { - return p.getCategoryCount(); + return mP.getCategoryCount(); } /** @@ -30,7 +30,7 @@ public class BarChart { * @return */ public List<String> getCategoryNames() { - return p.getCategoryNames(); + return mP.getCategoryNames(); } /** @@ -38,16 +38,16 @@ public class BarChart { * @param name */ public void addCategory(final String name) { - p.mCategoryNames.add(name); + mP.mCategoryNames.add(name); } /** - * Get catery name by index. + * Get category name by index. * @param index * @return */ public String getCategoryName(final int index) { - return p.getCategoryName(index); + return mP.getCategoryName(index); } /** @@ -56,7 +56,7 @@ public class BarChart { * @return */ public double getCategorySum(final int index) { - return p.getCategorySum(index); + return mP.getCategorySum(index); } /** @@ -64,7 +64,7 @@ public class BarChart { * @return */ public double getMaxYSum() { - return p.getMaxYSum(); + return mP.getMaxYSum(); } /** @@ -72,7 +72,7 @@ public class BarChart { * @return */ public double getMinY() { - return p.getMinY(); + return mP.getMinY(); } /** @@ -80,7 +80,7 @@ public class BarChart { * @return */ public double getMaxY() { - return p.getMaxY(); + return mP.getMaxY(); } /** @@ -89,7 +89,7 @@ public class BarChart { * @return */ public PointListList.PointList getDataSet(final int index) { - return (PointListList.PointList) p.get(index); + return (PointListList.PointList) mP.get(index); } /** @@ -98,7 +98,7 @@ public class BarChart { * @return */ public String getDataSetName(final int index) { - return p.get(index).getName(); + return mP.get(index).getName(); } } diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/diagrams/Diagram.java b/src/main/java/de/tudresden/inf/mci/brailleplot/diagrams/Diagram.java index a7485592..33e37d3b 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/diagrams/Diagram.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/diagrams/Diagram.java @@ -3,18 +3,18 @@ package de.tudresden.inf.mci.brailleplot.diagrams; import de.tudresden.inf.mci.brailleplot.csvparser.PointListList; /** - * General representation of both scatter and line plots. + * General representation of both scatter and line plots with basic data functions. Classes LinePlot and ScatterPlot extend this class. * @author Richard Schmidt */ -public class Diagram { - public PointListList p; +public class Diagram /*implements Renderable*/ { + public PointListList mP; /** * Get the minimum x-value. * @return */ public double getMinX() { - return p.getMinX(); + return mP.getMinX(); } /** @@ -22,7 +22,7 @@ public class Diagram { * @return */ public double getMaxX() { - return p.getMaxX(); + return mP.getMaxX(); } /** @@ -30,7 +30,7 @@ public class Diagram { * @return */ public double getMinY() { - return p.getMinY(); + return mP.getMinY(); } /** @@ -38,7 +38,7 @@ public class Diagram { * @return */ public double getMaxY() { - return p.getMaxY(); + return mP.getMaxY(); } /** @@ -47,7 +47,7 @@ public class Diagram { * @return */ public PointListList.PointList getDataSet(final int index) { - return (PointListList.PointList) p.get(index); + return (PointListList.PointList) mP.get(index); } /** @@ -56,6 +56,6 @@ public class Diagram { * @return */ public String getDataSetName(final int index) { - return p.get(index).getName(); + return mP.get(index).getName(); } } diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/diagrams/LinePlot.java b/src/main/java/de/tudresden/inf/mci/brailleplot/diagrams/LinePlot.java index 8775f60b..4059a410 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/diagrams/LinePlot.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/diagrams/LinePlot.java @@ -3,13 +3,13 @@ package de.tudresden.inf.mci.brailleplot.diagrams; import de.tudresden.inf.mci.brailleplot.csvparser.PointListList; /** - * Representation of a line plot. + * Representation of a line plot. Inherits from Diagram. * @author Richard Schmidt */ public class LinePlot extends Diagram { public LinePlot(final PointListList p) { - this.p = p; + this.mP = p; p.updateMinMax(); } } diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/diagrams/ScatterPlot.java b/src/main/java/de/tudresden/inf/mci/brailleplot/diagrams/ScatterPlot.java index dc798030..ac3050c0 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/diagrams/ScatterPlot.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/diagrams/ScatterPlot.java @@ -3,13 +3,13 @@ package de.tudresden.inf.mci.brailleplot.diagrams; import de.tudresden.inf.mci.brailleplot.csvparser.PointListList; /** - * Representation for scatter plots. + * Representation for scatter plots. Inherits from Diagram. * @author Richard Schmidt */ public class ScatterPlot extends Diagram { public ScatterPlot(final PointListList p) { - this.p = p; + this.mP = p; p.updateMinMax(); } } diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/diagrams/package-info.java b/src/main/java/de/tudresden/inf/mci/brailleplot/diagrams/package-info.java index 8e06cb7e..d3179677 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/diagrams/package-info.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/diagrams/package-info.java @@ -1,4 +1,4 @@ /** - + Diagram representation. + + Classes for diagram representation with with basic data functions. */ package de.tudresden.inf.mci.brailleplot.diagrams; diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/printabledata/MatrixData.java b/src/main/java/de/tudresden/inf/mci/brailleplot/printabledata/MatrixData.java index b01567c7..435d7ef3 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/printabledata/MatrixData.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/printabledata/MatrixData.java @@ -4,7 +4,7 @@ import java.util.Iterator; /** * This data is used to describe the data for the "Braille" and "Graphics" print modes. - * The data is organized in a matrix structure, which can be queried for its values on integer x (row) and y (column) indices. + * The data is organized in a matrix structure, which can be queried for its values on integer mX (row) and mY (column) indices. * @param <T> The type used for representing the intensity. Could be set to {@link Boolean} for basic Braille support, * but could also by set to {@link Short} if different embossing strengths are required. * @author Georg Graßnick diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/printabledata/Point2D.java b/src/main/java/de/tudresden/inf/mci/brailleplot/printabledata/Point2D.java index 6bcf6401..bdee0d23 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/printabledata/Point2D.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/printabledata/Point2D.java @@ -6,7 +6,7 @@ import java.util.Objects; /** * Representation of a 2 dimensional point. - * Encapsulates a position on x and y axis. + * Encapsulates a position on mX and mY axis. * @author Georg Graßnick * @version 2019.06.26 */ @@ -17,8 +17,8 @@ public class Point2D { /** * Constructor. - * @param x Position on the x axis. - * @param y Position on the y axis. + * @param x Position on the mX axis. + * @param y Position on the mY axis. */ public Point2D(final Quantity<Length> x, final Quantity<Length> y) { if (x == null || y == null) { @@ -30,7 +30,7 @@ public class Point2D { /** * Getter. - * @return The position on the x axis. + * @return The position on the mX axis. */ public final Quantity<Length> getX() { return mX; @@ -38,7 +38,7 @@ public class Point2D { /** * Getter. - * @return The position on the y axis. + * @return The position on the mY axis. */ public final Quantity<Length> getY() { return mY; diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/printabledata/Point2DValued.java b/src/main/java/de/tudresden/inf/mci/brailleplot/printabledata/Point2DValued.java index 8b674c97..36a6cb2a 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/printabledata/Point2DValued.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/printabledata/Point2DValued.java @@ -6,7 +6,7 @@ import java.util.Objects; /** * Representation of a 2 dimensional point with an associated value. - * Encapsulates both the position on x and y axis, as well as a value (think of embossing intensity). + * Encapsulates both the position on mX and mY axis, as well as a value (think of embossing intensity). * @param <T> The type used for representing the intensity. Could be set to {@link Boolean} for basic Braille support, * but could also by set to {@link Short} if different embossing strengths are required. * @author Georg Graßnick @@ -18,8 +18,8 @@ public class Point2DValued<T> extends Point2D { /** * Constructor. - * @param x Position on the x axis. - * @param y Position on the y axis. + * @param x Position on the mX axis. + * @param y Position on the mY axis. * @param val The value of the dot */ public Point2DValued(final Quantity<Length> x, final Quantity<Length> y, final T val) { diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/printabledata/SimpleMatrixDataImpl.java b/src/main/java/de/tudresden/inf/mci/brailleplot/printabledata/SimpleMatrixDataImpl.java index 64f2c39f..87f78b7b 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/printabledata/SimpleMatrixDataImpl.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/printabledata/SimpleMatrixDataImpl.java @@ -114,7 +114,7 @@ public class SimpleMatrixDataImpl<T> extends AbstractPrintableData implements Ma private final int mCellWidth; private final int mCellHeight; - // We use indices starting at 1, so that we do not have to check for the x-index to be 0 in the next() method call + // We use indices starting at 1, so that we do not have to check for the mX-index to be 0 in the next() method call private int mCurrentX = 1; private int mCurrentY = 1; @@ -145,7 +145,7 @@ public class SimpleMatrixDataImpl<T> extends AbstractPrintableData implements Ma // Staying in the current cell, move down mCurrentY++; } else if (mCurrentX % mCellWidth != 0) { - // Staying in current cell, move right, set y to the top most index of the current cell + // Staying in current cell, move right, set mY to the top most index of the current cell mCurrentX++; mCurrentY = (((mCurrentY / mCellHeight) - 1) * mCellHeight) + 1; } else if (mCurrentX < mMatrix.getColumnCount()) { // Moving on to the next cell diff --git a/src/main/resources/Bundle.properties b/src/main/resources/Bundle.properties index 5d686412..85508b57 100644 --- a/src/main/resources/Bundle.properties +++ b/src/main/resources/Bundle.properties @@ -1,39 +1,39 @@ param.title = Titel der Grafik [--title "Sinus- und Cosinusfunktion"] -param.size = Größe der Grafik in Millimeter [--size 300,500] -param.xrange = Darstellungsbereich der x-Achse und abweichender Titel. Wird automatisch auf den Datenbereich erweitert, wenn "--autoscale" angegeben ist. Ist "--diagramtype FunctionPlot" gesetzt, wird der Bereich erweitert, so dass er 0 enthält. [--xrange "Jahre::-3:5"] -param.yrange = Darstellungsbereich der y-Achse und abweichender Titel. Wird automatisch auf den Datenbereich erweitert, wenn "--autoscale" angegeben ist. Ist "--diagramtype FunctionPlot" gesetzt, wird der Bereich erweitert, so dass er 0 enthält. [--yrange -3:5] +param.size = Gr��e der Grafik in Millimeter [--size 300,500] +param.xrange = Darstellungsbereich der x-Achse und abweichender Titel. Wird automatisch auf den Datenbereich erweitert, wenn "--autoscale" angegeben ist. Ist "--diagramtype FunctionPlot" gesetzt, wird der Bereich erweitert, so dass er 0 enth�lt. [--xrange "Jahre::-3:5"] +param.yrange = Darstellungsbereich der y-Achse und abweichender Titel. Wird automatisch auf den Datenbereich erweitert, wenn "--autoscale" angegeben ist. Ist "--diagramtype FunctionPlot" gesetzt, wird der Bereich erweitert, so dass er 0 enth�lt. [--yrange -3:5] param.pi = Einteilung der x-Achse in Vielfache von pi param.xlines = Hilfslinien auf der x-Achse, durch Leerzeichen getrennt [--xlines "1 3.5"] param.ylines = Hilfslinien auf der y-Achse, durch Leerzeichen getrennt [--ylines "1 3.5"] -param.css = Direkte Angabe von zusätzlichen CSS-Anweisungen oder Pfad zu einer CSS-Datei [--css "#grid { stroke: #444444 }"] oder [--css stylesheet.css] +param.css = Direkte Angabe von zus�tzlichen CSS-Anweisungen oder Pfad zu einer CSS-Datei [--css "#grid { stroke: #444444 }"] oder [--css stylesheet.css] param.gnuplot = Pfad zum Gnuplot-Programm [--gnuplot "C:\gnuplot.exe"] param.output = Pfad zur Ausgabedatei [--output "output/sinus.svg"] param.help = Hilfe -param.points = Liste von Punkten die markiert werden sollen. Es können mehrere Listen angegeben werden, welche duch {} zu grupieren sind. Punkte werden durch Leerzeichen getrennt. X- und Y-Werte jeweils durch ein Komma getrennt. Jeder Liste kann ein Titel gegeben werden ["Liste 1"::{1.2,3 4.5,6}{-1,-2.3}]. Wird ignoriert wenn --csvdata angegeben und ein valider Pfad ist. -param.integral = Zeichnet eine Integralfläche zwischen zwei Funktionen oder der X-Achse. Nur wenn "--diagramtype FunctionPlot" gesetzt ist. [--integral "Wahrscheinlichkeit::1,2[-2:2]" ] -param.device = Ausgabegerät -param.csvpath = Pfad zur CSV-Datei, aus der die Punkt-, Linien- oder Balkendaten gelesen werden (überschreibt --points) [--csvpath data.csv] -param.csvtype = Aufbau der CSV-Datei, kann abgekürzt werden [--csvtype x_aligned_categories] oder [--csvtype xac] +param.points = Liste von Punkten die markiert werden sollen. Es k�nnen mehrere Listen angegeben werden, welche duch {} zu grupieren sind. Punkte werden durch Leerzeichen getrennt. X- und Y-Werte jeweils durch ein Komma getrennt. Jeder Liste kann ein Titel gegeben werden ["Liste 1"::{1.2,3 4.5,6}{-1,-2.3}]. Wird ignoriert wenn --csvdata angegeben und ein valider Pfad ist. +param.integral = Zeichnet eine Integralfl�che zwischen zwei Funktionen oder der X-Achse. Nur wenn "--diagramtype FunctionPlot" gesetzt ist. [--integral "Wahrscheinlichkeit::1,2[-2:2]" ] +param.device = Ausgabeger�t +param.csvpath = Pfad zur CSV-Datei, aus der die Punkt-, Linien- oder Balkendaten gelesen werden (�berschreibt --points) [--csvpath data.csv] +param.csvtype = Aufbau der CSV-Datei, kann abgek�rzt werden [--csvtype x_aligned_categories] oder [--csvtype xac] param.csvorientation = Orientierung der CSV-Datei [--csvorientation horizontal] oder [--csvo h] param.autoscale = Wenn angegeben, wird das Diagramm automatisch auf den Datenbereich skaliert, wobei eine angegebene --xrange bzw. --yrange den minimal Rahmen darstellen. Wenn "--diagramtype FunctionPlot" gesetzt ist, wird der Parameter ignoriert. [--autoscale] -param.showhorizontalgrid = Horizontale Gitterlinien zeigen [--hgrid on] oder [--hgrid off]. Wird weder vgrid noch hgrid angegeben, wird je nach Diagrammtyp eine Standarddarstellung gewählt. -param.showverticalgrid = Horizontale Gitterlinien zeigen [--vgrid on] oder [--vgrid off]. Wird weder vgrid noch hgrid angegeben, wird je nach Diagrammtyp eine Standarddarstellung gewählt. +param.showhorizontalgrid = Horizontale Gitterlinien zeigen [--hgrid on] oder [--hgrid off]. Wird weder vgrid noch hgrid angegeben, wird je nach Diagrammtyp eine Standarddarstellung gew�hlt. +param.showverticalgrid = Horizontale Gitterlinien zeigen [--vgrid on] oder [--vgrid off]. Wird weder vgrid noch hgrid angegeben, wird je nach Diagrammtyp eine Standarddarstellung gew�hlt. param.diagramtype = Der Typ des Diagramms. Beeinflusst, welche weiteren Parameter ausgewertet werden. -param.trendline = Eine Funktion zur Berechnung der Trendline. "--diagramtype ScatterPlot" muss gesetzt sein. Parameter werden hinter dem Funktionsnamen angegeben. Mögliche Linientypen (Parameter in Klammern) sind mit Standardwerten: "MovingAverage n" (n: ganzzahlig und größer als 0, Filtergröße ist 2*n+1), "ExponentialSmoothing alpha" (alpha: zwischen 0 und 1), "BrownLES alpha forecast" (alpha: zwischen 0 und 1; forecast: größer als 0, wieviele Werte extrapoliert werden), "LinearRegression" (keine Parameter). Beispiel: "--trendline BrownLES 0.2 10" +param.trendline = Eine Funktion zur Berechnung der Trendline. "--diagramtype ScatterPlot" muss gesetzt sein. Parameter werden hinter dem Funktionsnamen angegeben. M�gliche Linientypen (Parameter in Klammern) sind mit Standardwerten: "MovingAverage n" (n: ganzzahlig und gr��er als 0, Filtergr��e ist 2*n+1), "ExponentialSmoothing alpha" (alpha: zwischen 0 und 1), "BrownLES alpha forecast" (alpha: zwischen 0 und 1; forecast: gr��er als 0, wieviele Werte extrapoliert werden), "LinearRegression" (keine Parameter). Beispiel: "--trendline BrownLES 0.2 10" param.hideoriginalpoints = Stellt die originalen Datenpunkte nicht dar, wenn "--trendline" gesetzt ist. -param.showdoubleaxes = Doppelte Achsen zeigen [--daxes on] oder [--daxes off]. Nicht für [--diagramtype FunctionPlot] verwendbar. Wird der Parameter nicht angegeben, wird je nach Diagrammtyp eine Wahl vorgegeben. -param.showlinepoints = Datenpunkte auf den Linien eines Liniendiagramms markieren [--lp on] oder [--lp off]. Nur für [--diagramtype LineChart] verwendbar. Wird der Parameter nicht angegeben, werden die Punkte nur angezeigt, wenn genug Platz vorhanden ist. +param.showdoubleaxes = Doppelte Achsen zeigen [--daxes on] oder [--daxes off]. Nicht f�r [--diagramtype FunctionPlot] verwendbar. Wird der Parameter nicht angegeben, wird je nach Diagrammtyp eine Wahl vorgegeben. +param.showlinepoints = Datenpunkte auf den Linien eines Liniendiagramms markieren [--lp on] oder [--lp off]. Nur f�r [--diagramtype LineChart] verwendbar. Wird der Parameter nicht angegeben, werden die Punkte nur angezeigt, wenn genug Platz vorhanden ist. param.pointsborderless = Wenn angegeben, erhalten Punktsymbole keinen Rand. Kann die Darstellung von Liniendiagrammen mit Datenpunkten verbessern. -param.baraccumulation = Wählt, auf welche Art mehrere Datenreihen in Balkendiagrammen akkumuliert werden [--ba stacked] -param.colors = Manuelle Farbwahl. Die Farben können durch Leerzeichen getrennt angegeben werden. Wurden keine oder zu wenige Farben angegeben, wird die Liste aus der Vorgabereihenfolge aufgefüllt [--colors rot grün blau] +param.baraccumulation = W�hlt, auf welche Art mehrere Datenreihen in Balkendiagrammen akkumuliert werden [--ba stacked] +param.colors = Manuelle Farbwahl. Die Farben k�nnen durch Leerzeichen getrennt angegeben werden. Wurden keine oder zu wenige Farben angegeben, wird die Liste aus der Vorgabereihenfolge aufgef�llt [--colors rot gr�n blau] param.sorting = Sortieren von nominalen Daten [--sorting <algorithm>] param.sortdescending = Wenn [--sorting <algorithm>] verwendet wird, sortiere absteigend [--sortdescending] -param.xtitle = Titel der X-Achse [--xtitle Titel]. Titel, die zu groß für eine Zeile sind, werden zu Darstellungsfehlern führen. -param.ytitle = Titel der Y-Achse [--ytitle Titel]. Titel, die zu groß für eine Zeile sind, werden zu Darstellungsfehlern führen. +param.xtitle = Titel der X-Achse [--xtitle Titel]. Titel, die zu gro� f�r eine Zeile sind, werden zu Darstellungsfehlern f�hren. +param.ytitle = Titel der Y-Achse [--ytitle Titel]. Titel, die zu gro� f�r eine Zeile sind, werden zu Darstellungsfehlern f�hren. param.xunit = Einheit der x-Achse [--xunit "1000 Menschen"] param.yunit = Einheit der y-Achse [--yunit "m^2"] -error.onoffparameter = Ungültiger Wert "{0}". Erlaubt sind: "on" und "off". +error.onoffparameter = Ung�ltiger Wert "{0}". Erlaubt sind: "on" und "off". xaxis = X-Achse yaxis = Y-Achse @@ -47,14 +47,14 @@ legend.ytic = Skaleneinteilung: {0} legend.poi_1 = Punkt {0} legend.poi_n = Punkte {0} -legend.integral_0 = Integral von {0} bis {1} über {2}(x)dx -legend.integral_1 = Integral von {0} bis {1} über {2}(x)dx und {3}(x)dx +legend.integral_0 = Integral von {0} bis {1} �ber {2}(x)dx +legend.integral_1 = Integral von {0} bis {1} �ber {2}(x)dx und {3}(x)dx desc = Beschreibung desc.intro_0 = Es wird ein leeres Koordinatensystem im x-Bereich{6} von {0} bis {1} (Skaleneinteilung: {2}) und y-Bereich{7} von {3} bis {4} (Skaleneinteilung: {5}) dargestellt. -desc.intro_1 = Es wird eine Funktion im x-Bereich{6} von {0} bis {1} (Skaleneinteilung: {2}) und y-Bereich{7} von {3} bis {4} (Skaleneinteilung: {5}) dargestellt: -desc.intro_n = Es werden {8} Funktionen im x-Bereich{6} von {0} bis {1} (Skaleneinteilung: {2}) und y-Bereich{7} von {3} bis {4} (Skaleneinteilung: {5}) dargestellt: +desc.intro_1 = Es wird eine�Funktion im x-Bereich{6} von {0} bis {1} (Skaleneinteilung: {2}) und y-Bereich{7} von {3} bis {4} (Skaleneinteilung: {5}) dargestellt: +desc.intro_n = Es werden {8}�Funktionen im x-Bereich{6} von {0} bis {1} (Skaleneinteilung: {2}) und y-Bereich{7} von {3} bis {4} (Skaleneinteilung: {5}) dargestellt: desc.intersections_0 = Die Funktionen haben keine Schnittpunkte. desc.intersections_1 = Die Funktionen {0} und {1} haben einen Schnittpunkt: @@ -74,18 +74,18 @@ legend.poi.intro_n = Folgende Punkte sind eingezeichnet: legend.poi.list_1 = Punkt {0}: legend.poi.list_n = Punktliste {0}: -desc.integral_0 = Angezeigt wird das Integral von {0} bis {1} über {2}(x)dx. -desc.integral_1 = Angezeigt wird das Integral von {0} bis {1} über {2}(x)dx und {3}(x)dx. +desc.integral_0 = Angezeigt wird das Integral von {0} bis {1} �ber {2}(x)dx. +desc.integral_1 = Angezeigt wird das Integral von {0} bis {1} �ber {2}(x)dx und {3}(x)dx. -desc.note = Die Angaben sind Näherungswerte und beziehen sich nur auf den sichtbaren Bereich. +desc.note = Die Angaben sind N�herungswerte und beziehen sich nur auf den sichtbaren Bereich. ### Descriptions for diagrams (not graphs) -desc.diagramtype_title = Dieses {0} trägt den Titel "{1}". +desc.diagramtype_title = Dieses {0} tr�gt den Titel "{1}". desc.diagramtype_notitle = Es wird ein {0} dargestellt. desc.diagramtype_barcharttype = Die Balken sind vertikal {0}. -# New diagram types should get their name setup here. +# New diagram types should get their mName setup here. # The format is desc.diagramtype.<DiagramType.toString()> desc.diagramtype.ScatterPlot = Punktdiagramm desc.diagramtype.LineChart = Liniendiagramm @@ -100,7 +100,7 @@ desc.axis_position_first = Die Achsen und ihre Beschriftungen befinden sich link desc.axis_position_first.intersect = und schneiden sich im Punkt {0} desc.axis_position_second_start.both = Beide Achsen werden desc.axis_position_second_start.vertical = Die vertikale Achse wird -desc.axis_position_second = auch auf der gegenüberliegenden Seite des Diagramms dargestellt. +desc.axis_position_second = auch auf der gegen�berliegenden Seite des Diagramms dargestellt. desc.vertical_det = vertikale desc.vertical_neutral = vertikales @@ -132,7 +132,7 @@ desc.line.minmax = Hinter ihren Namen stehen die Maximal- bzw. Minimalwerte. ### Bar chart specific descriptions -desc.barchart.sorting = Die Balken sind {0} und von links nach rechts folgendermaßen beschriftet: +desc.barchart.sorting = Die Balken sind {0} und von links nach rechts folgenderma�en beschriftet: # {0}: sorting criterium, {1}: ascending/descending, {2}: sorted desc.barchart.sorting.sortingstring = {0} {1} {2} @@ -149,15 +149,15 @@ desc.barchart.sorting.desc = absteigend ### Trendline descriptions -#{0}: desc.trendline_points_[1|n] {1}: desc.trendline_algorithm.<name> {2} TrendlineAlgorithm.getAlgorithmParams() +#{0}: desc.trendline_points_[1|n] {1}: desc.trendline_algorithm.<mName> {2} TrendlineAlgorithm.getAlgorithmParams() desc.trendline_points = Zu {0} wird eine Trendlinie, die mit dem Verfahren "{1}" {2} berechnet wurde, dargestellt. desc.trendline_points_1 = der Datenreihe desc.trendline_points_n = jeder Datenreihe -desc.trendline_algorithm.BrownLES = lineare exponentielle Glättung nach Brown +desc.trendline_algorithm.BrownLES = lineare exponentielle Gl�ttung nach Brown desc.trendline_algorithm.MovingAverage = gleitendes Mittel desc.trendline_algorithm.LinearRegression = lineare Regression -desc.trendline_algorithm.ExponentialSmoothing = exponentielle Glättung +desc.trendline_algorithm.ExponentialSmoothing = exponentielle Gl�ttung -desc.trendline_only_1 = Bei der dargestellten Linien handelt es sich um eine Trendlinie, die mit dem Verfahren {0} {1} berechnet wurde. Sie trägt den Titel "{2}". +desc.trendline_only_1 = Bei der dargestellten Linien handelt es sich um eine Trendlinie, die mit dem Verfahren {0} {1} berechnet wurde. Sie tr�gt den Titel "{2}". desc.trendline_only_n = Bei den dargestellten Linien handelt es sich um Trendlinien, die mit dem Verfahren "{0}" {1} berechnet wurden. Es werden {2} Datenreihen dargestellt: diff --git a/src/test/java/de/tudresden/inf/mci/brailleplot/configparser/JavaPropertiesConfigurationParserTest.java b/src/test/java/de/tudresden/inf/mci/brailleplot/configparser/JavaPropertiesConfigurationParserTest.java index 2424e277..886e423c 100644 --- a/src/test/java/de/tudresden/inf/mci/brailleplot/configparser/JavaPropertiesConfigurationParserTest.java +++ b/src/test/java/de/tudresden/inf/mci/brailleplot/configparser/JavaPropertiesConfigurationParserTest.java @@ -49,7 +49,7 @@ public class JavaPropertiesConfigurationParserTest { Assertions.assertEquals(0, mFormatConfig.getProperty("margin.left").toInt()); // values without default - Assertions.assertEquals("Dummy Printer", mPrinterConfig.getProperty("name").toString()); + Assertions.assertEquals("Dummy Printer", mPrinterConfig.getProperty("mName").toString()); Assertions.assertEquals(0.05, mPrinterConfig.getProperty("floatingDot.resolution").toDouble()); } @@ -63,7 +63,7 @@ public class JavaPropertiesConfigurationParserTest { @Test public void testFallbackProperties() { - String specifiedByConfig[] = {"name", "mode", "brailletable", "floatingDot.support", "floatingDot.resolution", "constraint.top", "constraint.left", "raster.dotDistance.horizontal", "raster.dotDistance.vertical", "raster.cellDistance.horizontal", "raster.cellDistance.vertical", "raster.dotDiameter"}; + String specifiedByConfig[] = {"mName", "mode", "brailletable", "floatingDot.support", "floatingDot.resolution", "constraint.top", "constraint.left", "raster.dotDistance.horizontal", "raster.dotDistance.vertical", "raster.cellDistance.horizontal", "raster.cellDistance.vertical", "raster.dotDiameter"}; String specifiedByFallback[] = {"mode", "brailletable", "floatingDot.support", "constraint.top", "constraint.left", "raster.constraint.top", "raster.constraint.left", "raster.constraint.width", "raster.constraint.height", "raster.type", "raster.dotDistance.horizontal", "raster.dotDistance.vertical", "raster.cellDistance.horizontal", "raster.cellDistance.vertical", "raster.dotDiameter"}; // config shall extend the fallback @@ -127,7 +127,7 @@ public class JavaPropertiesConfigurationParserTest { public void testIncompatibleTypeConversion() { Assertions.assertThrows(NumberFormatException.class, () -> mPrinterConfig.getProperty("floatingDot.support").toInt()); Assertions.assertThrows(NumberFormatException.class, () -> mPrinterConfig.getProperty("raster.cellDistance.horizontal").toInt()); - Assertions.assertThrows(NumberFormatException.class, () -> mPrinterConfig.getProperty("name").toDouble()); + Assertions.assertThrows(NumberFormatException.class, () -> mPrinterConfig.getProperty("mName").toDouble()); } } diff --git a/src/test/resources/illegalPropertyNameExample.properties b/src/test/resources/illegalPropertyNameExample.properties index dfcd2549..fcceefff 100644 --- a/src/test/resources/illegalPropertyNameExample.properties +++ b/src/test/resources/illegalPropertyNameExample.properties @@ -1,6 +1,6 @@ # JProperties Printer & Format Configuration # -# Embosser: Dummy Default with illegal property name +# Embosser: Dummy Default with illegal property mName # Test Revision (19-07-18) (DON'T USE FOR PRINTING) # # Description: @@ -17,7 +17,7 @@ printer.mode=normal printer.brailletable=src/test/resources/mapping.properties printer.floatingDot.support=false -# Illegal property name example +# Illegal property mName example printer.garbageProperty=illegal # The following values represent the fixed indentation and maximum technical printing area of the embosser. diff --git a/src/test/resources/mapping.properties b/src/test/resources/mapping.properties index 787be18b..8251bb94 100644 --- a/src/test/resources/mapping.properties +++ b/src/test/resources/mapping.properties @@ -115,7 +115,7 @@ 101110=110 # o 101010=111 -# p +# mP 111100=112 # q 111110=113 @@ -131,9 +131,9 @@ 111001=118 # w 010111=119 -# x +# mX 101101=120 -# y +# mY 101111=121 # z 101011=122 diff --git a/src/test/resources/missingRequiredPropertyExample.properties b/src/test/resources/missingRequiredPropertyExample.properties index a61d021c..1c453f75 100644 --- a/src/test/resources/missingRequiredPropertyExample.properties +++ b/src/test/resources/missingRequiredPropertyExample.properties @@ -16,7 +16,7 @@ ### ========================== # Missing required property (not specified by default): -# printer.name=Dummy Printer +# printer.mName=Dummy Printer printer.mode=normal printer.brailletable=src/test/resources/mapping.properties printer.floatingDot.support=true -- GitLab