Package com.illumon.iris.db.plot.util
Class PlotUtils
java.lang.Object
com.illumon.iris.db.plot.util.PlotUtils
public class PlotUtils extends Object
Utilities class for plotting.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PlotUtils.HashMapWithDefault<K,V>
-
Method Summary
Modifier and Type Method Description static org.jfree.data.Range
combineRangeIgnoreNaN(org.jfree.data.Range... ranges)
static org.jfree.data.Range
combineRangeIgnoreNaN(org.jfree.data.Range r1, org.jfree.data.Range r2)
static ComboAggregateFactory
createCategoryComboAgg(ComboAggregateFactory.ComboBy agg)
static Table
createCategoryHistogramTable(Table t, String... byColumns)
static Table
createCategoryTable(Table t, String[] catColumns)
static TableHandle
createCategoryTableHandle(Table t, String[] catColumns, String... otherColumns)
static TableHandle
createCategoryTableHandle(Table t, String catColumn, String... otherColumns)
static TableBackedTableMapHandle
createCategoryTableMapHandle(Table t, String[] catColumns, String[] otherColumns, String[] byColumns, PlotInfo plotInfo)
static TableBackedTableMapHandle
createCategoryTableMapHandle(Table t, String catColumn, String[] otherColumns, String[] byColumns, PlotInfo plotInfo)
static <T> IndexableData
createEmptyIndexableData(Class<T> c, PlotInfo plotInfo)
static IndexableNumericData
createEmptyIndexableNumericDataArray(Class dataType, PlotInfo plotInfo)
static <T> IndexableData
createIndexableData(Table t, String column, PlotInfo plotInfo)
static <T> IndexableData
createIndexableData(Object data, PlotInfo plotInfo)
static <T> IndexableData
createIndexableData(Object data, Class<T> c, PlotInfo plotInfo)
static <T> IndexableData
createIndexableData(Map<String,Object> snapshotData, TableDefinition tableDefinition, String column, PlotInfo plotInfo)
static <T> IndexableData
createIndexableData(Map<String,Object> snapshotData, Class<T> c, String column, PlotInfo plotInfo)
static <T extends Comparable>
IndexableDatacreateIndexableData(T[] data, PlotInfo plotInfo)
static IndexableNumericData
createIndexableNumericDataArray(Object data, Class dataType, PlotInfo plotInfo)
static IndexableNumericData
createIndexableNumericDataArray(Map<String,Object> data, TableHandle th, String column, PlotInfo plotInfo)
static IndexableNumericData
createIndexableNumericDataArray(Map<String,Object> data, TableDefinition tableDefinition, String column, PlotInfo plotInfo)
static IndexableNumericData
createIndexableNumericDataArray(Map<String,Object> data, Table t, String column, PlotInfo plotInfo)
static Table
doubleTable(double[] x, String colName)
Creates a new table with a column of doubles holding the specified data.static Table
doubleTable(float[] x, String colName)
Creates a new table with a column of doubles holding the specified data.static Table
doubleTable(int[] x, String colName)
Creates a new table with a column of doubles holding the specified data.static Table
doubleTable(long[] x, String colName)
Creates a new table with a column of doubles holding the specified data.static Table
doubleTable(short[] x, String colName)
Creates a new table with a column of doubles holding the specified data.static Table
doubleTable(Double[] x, String colName)
Creates a new table with a column of doubles holding the specified data.static Table
doubleTable(Float[] x, String colName)
Creates a new table with a column of doubles holding the specified data.static Table
doubleTable(Integer[] x, String colName)
Creates a new table with a column of doubles holding the specified data.static Table
doubleTable(Long[] x, String colName)
Creates a new table with a column of doubles holding the specified data.static Table
doubleTable(Short[] x, String colName)
Creates a new table with a column of doubles holding the specified data.static <T extends Number>
TabledoubleTable(List<T> x, String colName)
Creates a new table with a column of doubles holding the specified data.static <T extends Number>
TabledoubleTable(T[] x, String colName)
Creates a new table with a column of doubles holding the specified data.static void
emptyPoolQueue()
Waits for all existing threads in the pool to run.static void
emptySequentialPoolQueue()
Waits for all existingRunnable
s in the sequential pool to run.static List<Condition>
getColumnConditions(Table arg, String column)
static Color[]
getNColors(ColorPalette colorPalette, int n)
Gets theColor
array for this palette.static Function<Long,Number>
getNumberFromNumericOrTimeSource(Table t, String numericCol, PlotInfo plotInfo)
static Paint
intToColor(ChartImpl chart, Integer color)
Gets the color of thechart
's color palette at the specified indexcolor
.static void
invokeLater(Runnable runnable)
Adds theRunnable
to the pool to execute later.static void
invokeOffEDT(Runnable runnable)
If not EventDispatchThread, executes theRunnable
in-line, else willinvokeLater(Runnable)
static double
maxIgnoreNaN(double... values)
static double
maxIgnoreNaN(double oldMin, double value)
static float
maxIgnoreNaN(float oldMin, float value)
static int
maxIgnoreNull(int oldMin, int value)
static long
maxIgnoreNull(long oldMin, long value)
static short
maxIgnoreNull(short oldMin, short value)
static double
minIgnoreNaN(double... values)
static double
minIgnoreNaN(double oldMin, double value)
static float
minIgnoreNaN(float oldMin, float value)
static int
minIgnoreNull(int oldMin, int value)
static long
minIgnoreNull(long oldMin, long value)
static short
minIgnoreNull(short oldMin, short value)
static double
numberToDouble(Number n)
Gets the double equivalent of theNumber
.static void
sequentialInvokeLater(Runnable runnable)
Adds theRunnable
to the sequential pool to execute later.static void
setPoolThreadCount(int n)
Sets the number of threads for the thread pool.static Table
table(double[] x, String colName)
Creates a new table with a column of doubles holding the specified data.static Table
table(float[] x, String colName)
Creates a new table with a column of floats holding the specified data.static Table
table(int[] x, String colName)
Creates a new table with a column of ints holding the specified data.static Table
table(long[] x, String colName)
Creates a new table with a column of longs holding the specified data.static Table
table(short[] x, String colName)
Creates a new table with a column of shorts holding the specified data.static <T> Table
table(List<T> x, String colName)
Creates a new table with a column holding the specified data.static <T> Table
table(T[] x, String colName)
Creates a new table with a column holding the specified data.static double[]
toDouble(float[] x)
Creates a new array of doubles holding the specified data.static double[]
toDouble(int[] x)
Creates a new array of doubles holding the specified data.static double[]
toDouble(long[] x)
Creates a new array of doubles holding the specified data.static <T extends Number>
double[]toDouble(T[] x)
Creates a new array of doubles holding the specified data.static float[]
toFloat(double[] x)
Creates a new array of floats holding the specified data.static float[]
toFloat(int[] x)
Creates a new array of floats holding the specified data.static float[]
toFloat(long[] x)
Creates a new array of floats holding the specified data.static <T extends Number>
float[]toFloat(T[] x)
Creates a new array of floats holding the specified data.static String
uniqueVarName(String root)
Gets a variable name not already in theQueryScope
by appending random integers to the end ofroot
until a unique name is found.
-
Method Details
-
uniqueVarName
Gets a variable name not already in theQueryScope
by appending random integers to the end ofroot
until a unique name is found.- Parameters:
root
- base variable name- Returns:
- unique randomized variable name based off
root
-
invokeLater
Adds theRunnable
to the pool to execute later.- Parameters:
runnable
- runnable
-
invokeOffEDT
If not EventDispatchThread, executes theRunnable
in-line, else willinvokeLater(Runnable)
- Parameters:
runnable
- runnable
-
sequentialInvokeLater
Adds theRunnable
to the sequential pool to execute later.- Parameters:
runnable
- runnable
-
setPoolThreadCount
public static void setPoolThreadCount(int n)Sets the number of threads for the thread pool.- Parameters:
n
- number of threads
-
emptyPoolQueue
public static void emptyPoolQueue()Waits for all existing threads in the pool to run.- Throws:
UnsupportedOperationException
- if the pool has more than one thread.
-
emptySequentialPoolQueue
public static void emptySequentialPoolQueue()Waits for all existingRunnable
s in the sequential pool to run. -
intToColor
Gets the color of thechart
's color palette at the specified indexcolor
.- Parameters:
chart
- chartcolor
- index- Returns:
- color of the
chart
at the indexcolor
-
numberToDouble
Gets the double equivalent of theNumber
. NullQueryConstants
are converted to Double.NaN.- Parameters:
n
- number- Returns:
- double value of
n
- Throws:
UnsupportedOperationException
-n
isn't a supported data type
-
table
Creates a new table with a column holding the specified data.- Parameters:
x
- datacolName
- column name- Returns:
- new table with column holding
x
-
table
Creates a new table with a column holding the specified data.- Type Parameters:
T
- type of the data inx
- Parameters:
x
- datacolName
- column name- Returns:
- new table with column holding
x
-
table
Creates a new table with a column of shorts holding the specified data.- Parameters:
x
- datacolName
- column name- Returns:
- new table with column holding
x
-
table
Creates a new table with a column of ints holding the specified data.- Parameters:
x
- datacolName
- column name- Returns:
- new table with column holding
x
-
table
Creates a new table with a column of longs holding the specified data.- Parameters:
x
- datacolName
- column name- Returns:
- new table with column holding
x
-
table
Creates a new table with a column of floats holding the specified data.- Parameters:
x
- datacolName
- column name- Returns:
- new table with column holding
x
-
table
Creates a new table with a column of doubles holding the specified data.- Parameters:
x
- datacolName
- column name- Returns:
- new table with column holding
x
-
doubleTable
Creates a new table with a column of doubles holding the specified data. Values ofx
are converted to their corresponding double values. Nulls are mapped to Double.NaN.- Type Parameters:
T
- type of the data inx
- Parameters:
x
- datacolName
- column name- Returns:
- new table with column holding
x
-
doubleTable
Creates a new table with a column of doubles holding the specified data. Values ofx
are converted to their corresponding double values. Nulls are mapped to Double.NaN.- Type Parameters:
T
- type of the data inx
- Parameters:
x
- datacolName
- column name- Returns:
- new table with column holding
x
-
doubleTable
Creates a new table with a column of doubles holding the specified data. Values ofx
are converted to their corresponding double values. Nulls are mapped to Double.NaN.- Parameters:
x
- datacolName
- column name- Returns:
- new table with column holding
x
-
doubleTable
Creates a new table with a column of doubles holding the specified data. Values ofx
are converted to their corresponding double values. Nulls are mapped to Double.NaN.- Parameters:
x
- datacolName
- column name- Returns:
- new table with column holding
x
-
doubleTable
Creates a new table with a column of doubles holding the specified data. Values ofx
are converted to their corresponding double values. Nulls are mapped to Double.NaN.- Parameters:
x
- datacolName
- column name- Returns:
- new table with column holding
x
-
doubleTable
Creates a new table with a column of doubles holding the specified data. Values ofx
are converted to their corresponding double values. Nulls are mapped to Double.NaN.- Parameters:
x
- datacolName
- column name- Returns:
- new table with column holding
x
-
doubleTable
Creates a new table with a column of doubles holding the specified data. Values ofx
are converted to their corresponding double values. Nulls are mapped to Double.NaN.- Parameters:
x
- datacolName
- column name- Returns:
- new table with column holding
x
-
doubleTable
Creates a new table with a column of doubles holding the specified data. Values ofx
are converted to their corresponding double values. Nulls are mapped to Double.NaN.- Parameters:
x
- datacolName
- column name- Returns:
- new table with column holding
x
-
doubleTable
Creates a new table with a column of doubles holding the specified data. Values ofx
are converted to their corresponding double values. Nulls are mapped to Double.NaN.- Parameters:
x
- datacolName
- column name- Returns:
- new table with column holding
x
-
doubleTable
Creates a new table with a column of doubles holding the specified data. Values ofx
are converted to their corresponding double values. Nulls are mapped to Double.NaN.- Parameters:
x
- datacolName
- column name- Returns:
- new table with column holding
x
-
doubleTable
Creates a new table with a column of doubles holding the specified data. Values ofx
are converted to their corresponding double values. Nulls are mapped to Double.NaN.- Parameters:
x
- datacolName
- column name- Returns:
- new table with column holding
x
-
doubleTable
Creates a new table with a column of doubles holding the specified data. Values ofx
are converted to their corresponding double values. Nulls are mapped to Double.NaN.- Parameters:
x
- datacolName
- column name- Returns:
- new table with column holding
x
-
toFloat
public static float[] toFloat(double[] x)Creates a new array of floats holding the specified data. Values ofx
are converted to their corresponding float values. Nulls are mapped to Float.NaN.- Parameters:
x
- data- Returns:
- new float array holding
x
-
toFloat
public static float[] toFloat(int[] x)Creates a new array of floats holding the specified data. Values ofx
are converted to their corresponding float values. Nulls are mapped to Float.NaN.- Parameters:
x
- data- Returns:
- new float array holding
x
-
toFloat
public static float[] toFloat(long[] x)Creates a new array of floats holding the specified data. Values ofx
are converted to their corresponding float values. Nulls are mapped to Float.NaN.- Parameters:
x
- data- Returns:
- new float array holding
x
-
toFloat
Creates a new array of floats holding the specified data. Values ofx
are converted to their corresponding float values. Nulls are mapped to Float.NaN.- Type Parameters:
T
- type of the data inx
- Parameters:
x
- data- Returns:
- new float array holding
x
-
toDouble
public static double[] toDouble(float[] x)Creates a new array of doubles holding the specified data. Values ofx
are converted to their corresponding double values. Nulls are mapped to Double.NaN.- Parameters:
x
- data- Returns:
- new float array holding
x
-
toDouble
public static double[] toDouble(int[] x)Creates a new array of doubles holding the specified data. Values ofx
are converted to their corresponding double values. Nulls are mapped to Double.NaN.- Parameters:
x
- data- Returns:
- new float array holding
x
-
toDouble
public static double[] toDouble(long[] x)Creates a new array of doubles holding the specified data. Values ofx
are converted to their corresponding double values. Nulls are mapped to Double.NaN.- Parameters:
x
- data- Returns:
- new float array holding
x
-
toDouble
Creates a new array of doubles holding the specified data. Values ofx
are converted to their corresponding double values. Nulls are mapped to Double.NaN.- Type Parameters:
T
- type of the data inx
- Parameters:
x
- data- Returns:
- new float array holding
x
-
getNColors
Gets theColor
array for this palette.- Returns:
- Array of
Color
for this palette.
-
combineRangeIgnoreNaN
public static org.jfree.data.Range combineRangeIgnoreNaN(@NotNull org.jfree.data.Range... ranges) -
combineRangeIgnoreNaN
public static org.jfree.data.Range combineRangeIgnoreNaN(org.jfree.data.Range r1, org.jfree.data.Range r2) -
minIgnoreNaN
public static double minIgnoreNaN(double... values) -
minIgnoreNaN
public static double minIgnoreNaN(double oldMin, double value) -
maxIgnoreNaN
public static double maxIgnoreNaN(double... values) -
maxIgnoreNaN
public static double maxIgnoreNaN(double oldMin, double value) -
minIgnoreNaN
public static float minIgnoreNaN(float oldMin, float value) -
maxIgnoreNaN
public static float maxIgnoreNaN(float oldMin, float value) -
minIgnoreNull
public static int minIgnoreNull(int oldMin, int value) -
maxIgnoreNull
public static int maxIgnoreNull(int oldMin, int value) -
minIgnoreNull
public static short minIgnoreNull(short oldMin, short value) -
maxIgnoreNull
public static short maxIgnoreNull(short oldMin, short value) -
minIgnoreNull
public static long minIgnoreNull(long oldMin, long value) -
maxIgnoreNull
public static long maxIgnoreNull(long oldMin, long value) -
createCategoryTableHandle
public static TableHandle createCategoryTableHandle(Table t, String catColumn, String... otherColumns) -
createCategoryTableHandle
public static TableHandle createCategoryTableHandle(Table t, String[] catColumns, String... otherColumns) -
createCategoryTableMapHandle
-
createCategoryTableMapHandle
-
createCategoryTable
-
createCategoryHistogramTable
-
createCategoryComboAgg
-
getColumnConditions
-
getNumberFromNumericOrTimeSource
-
createIndexableData
-
createIndexableData
public static <T> IndexableData createIndexableData(Map<String,Object> snapshotData, @NotNull TableDefinition tableDefinition, String column, PlotInfo plotInfo) -
createIndexableData
-
createEmptyIndexableData
-
createIndexableData
-
createIndexableData
-
createIndexableData
public static <T extends Comparable> IndexableData createIndexableData(T[] data, PlotInfo plotInfo) -
createIndexableNumericDataArray
public static IndexableNumericData createIndexableNumericDataArray(Map<String,Object> data, @NotNull TableHandle th, String column, PlotInfo plotInfo) -
createIndexableNumericDataArray
-
createIndexableNumericDataArray
public static IndexableNumericData createIndexableNumericDataArray(Map<String,Object> data, @NotNull TableDefinition tableDefinition, String column, PlotInfo plotInfo) -
createEmptyIndexableNumericDataArray
public static IndexableNumericData createEmptyIndexableNumericDataArray(Class dataType, PlotInfo plotInfo) -
createIndexableNumericDataArray
public static IndexableNumericData createIndexableNumericDataArray(Object data, Class dataType, PlotInfo plotInfo)
-