Package io.fi0x.javaconsolegraph
Class Transformer
java.lang.Object
io.fi0x.javaconsolegraph.Transformer
This class contains methods, to transform arrays and lists into a single String,
that is formatted to display a nice looking graph or table.
-
Method Summary
Modifier and TypeMethodDescriptionString[][]getGraphString(double[] values) Get a correctly formattedStringthat will print out a graph.static TransformerGet theTransformer-singleton and create it if it does not exist yet.Get a correctly formattedStringthat will print out a table.Get a correctly formattedStringthat will print out a table.Get a correctly formattedStringthat will print out a table.voidsetGraphSettings(String xAxis, String yAxis, double xMin, double yMin, double scaleX, double scaleY, int xValues, int yValues) Change the behaviour of the graph formatting.voidsetTableSettings(boolean centeredEntries, boolean useSeparators, int entryPadding) Change the behaviour of the table formatting.
-
Method Details
-
getInstance
Get theTransformer-singleton and create it if it does not exist yet.- Returns:
- The instance of the
Transformer-singleton.
-
getTable
Get a correctly formattedStringthat will print out a table.- Parameters:
columnHeaders- The headers of each column that the table should have.columns- The individual entries of each column.- Returns:
- A correctly formatted
Stringthat will create a table with the provided headers and entries.
-
getTable
Get a correctly formattedStringthat will print out a table.- Parameters:
columns- The individual columns of the table, including their headers.- Returns:
- A correctly formatted string that will create a table with the provided headers and entries.
-
getTable
Get a correctly formattedStringthat will print out a table.- Parameters:
rows- The individual rows of the table, including their headers.- Returns:
- A correctly formatted string that will create a table with the provided headers and entries.
-
setTableSettings
public void setTableSettings(boolean centeredEntries, boolean useSeparators, int entryPadding) Change the behaviour of the table formatting.- Parameters:
centeredEntries- Weather or not entries should be centered in their column.useSeparators- Weather or not separators should be added between columns and rows.entryPadding- Weather or not entries should get extra spaces before and after the normal padding.
-
getGraphString
Get a correctly formattedStringthat will print out a graph.- Parameters:
values- The individual values that get mapped on the xAxis.- Returns:
- A correctly formatted
String-Array that represents a graph. Can be used to create a table.
-
setGraphSettings
public void setGraphSettings(String xAxis, String yAxis, double xMin, double yMin, double scaleX, double scaleY, int xValues, int yValues) Change the behaviour of the graph formatting.- Parameters:
xAxis- How the xAxis should be named.yAxis- How the yAxis should be named.xMin- What the lowest value on the xAxis is.yMin- What the lowestValue on the yAxis is.scaleX- How large the steps between individual xValues should be.scaleY- How large the steps between individual yValues should be.xValues- How many individual values should be displayed in x-direction.yValues- How many individual values should be displayed in y-direction.
-