- java.lang.Object
-
- eu.hansolo.tilesfx.tools.Helper
-
public class Helper extends java.lang.ObjectCreated by hansolo on 11.12.15.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String[]ALPHAstatic java.lang.String[]ALPHANUMERICstatic CountryGroupAMERICASstatic CountryGroupANZstatic CountryGroupAPACstatic CountryGroupAPJCstatic CountryGroupBENELUXstatic CountryGroupBRICSstatic CountryGroupDACHstatic CountryGroupEMEAstatic CountryGroupEUstatic java.lang.String[]EXTENDEDstatic java.lang.String[]EXTENDED_UMLAUTEstatic doubleMAP_HEIGHTstatic doubleMAP_OFFSET_Xstatic doubleMAP_OFFSET_Ystatic doubleMAP_WIDTHstatic doubleMIN_FONT_SIZEstatic CountryGroupNORAMstatic java.lang.String[]NUMERICstatic java.lang.String[]TIME_0_TO_12static java.lang.String[]TIME_0_TO_24static java.lang.String[]TIME_0_TO_5static java.lang.String[]TIME_0_TO_9static java.lang.String[]TIME_00_TO_59static java.lang.String[]TIME_24_TO_0static java.lang.String[]TIME_5_TO_0static java.lang.String[]TIME_59_TO_00static java.lang.String[]TIME_9_TO_0static java.time.DurationTIME_PERIOD_1_MONTHstatic java.time.DurationTIME_PERIOD_12_MONTHstatic java.time.DurationTIME_PERIOD_24_HOURSstatic java.time.DurationTIME_PERIOD_3_DAYSstatic java.time.DurationTIME_PERIOD_3_MONTHstatic java.time.DurationTIME_PERIOD_5_DAYSstatic java.time.DurationTIME_PERIOD_6_MONTHstatic java.time.DurationTIME_PERIOD_7_DAYS
-
Constructor Summary
Constructors Constructor Description Helper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidadjustTextSize(javafx.scene.control.Label TEXT, double MAX_WIDTH, double FONT_SIZE)static voidadjustTextSize(javafx.scene.text.Text TEXT, double MAX_WIDTH, double FONT_SIZE)static booleanbiggerThan(double A, double B)static double[]calcAutoScale(double MIN_VALUE, double MAX_VALUE)static doublecalcNiceNumber(double RANGE, boolean ROUND)Returns a "niceScaling" number approximately equal to the range.static intcalcNumberOfDatapointsForPeriod(java.time.Duration TIME_PERIOD, java.util.concurrent.TimeUnit RESOLUTION)static intcheckCollision(double a, double b, double c, double centerX, double centerY, double radius)static intcheckLineCircleCollision(double P1_X, double P1_Y, double P2_X, double P2_Y, double CENTER_X, double CENTER_Y, double RADIUS)static intcheckLineCircleCollision(Point P1, Point P2, double CENTER_X, double CENTER_Y, double RADIUS)static doubleclamp(double MIN, double MAX, double VALUE)static intclamp(int MIN, int MAX, int VALUE)static longclamp(long MIN, long MAX, long VALUE)static <T extends java.lang.Number>
Tclamp(T MIN, T MAX, T VALUE)static doubleclampMax(double MAX, double VALUE)static doubleclampMin(double MIN, double VALUE)static doublecolorDistance(javafx.scene.paint.Color COLOR_1, javafx.scene.paint.Color COLOR_2)static java.lang.StringcolorToCss(javafx.scene.paint.Color COLOR)static double[]colorToYUV(javafx.scene.paint.Color COLOR)static java.util.List<javafx.scene.paint.Color>createColorPalette(javafx.scene.paint.Color FROM_COLOR, javafx.scene.paint.Color TO_COLOR, int NO_OF_COLORS)static javafx.scene.paint.Color[]createColorVariations(javafx.scene.paint.Color COLOR, int NO_OF_COLORS)static <T extends Point>
java.util.List<T>createConvexHull(java.util.List<T> POINTS)static java.util.List<Point>createSmoothedConvexHull(java.util.List<Point> POINTS, int SUB_DIVISIONS)static doubledistance(double P1_X, double P1_Y, double P2_X, double P2_Y)static doubledistance(Point P1, Point P2)static voiddrawRoundedRect(javafx.scene.canvas.GraphicsContext CTX, CtxBounds BOUNDS, CtxCornerRadii RADII)static voidenableNode(javafx.scene.Node NODE, boolean ENABLE)static booleanequals(double A, double B)static doubleeuclideanDistance(double X1, double Y1, double X2, double Y2)static doubleeuclideanDistance(Point P1, Point P2)static voidfitNodeWidth(javafx.scene.Node NODE, double MAX_WIDTH)static doublegetAngleFromXY(double X, double Y, double CENTER_X, double CENTER_Y)static doublegetAngleFromXY(double X, double Y, double CENTER_X, double CENTER_Y, double ANGLE_OFFSET)static javafx.scene.paint.ColorgetColorAt(java.util.List<javafx.scene.paint.Stop> STOP_LIST, double POSITION_OF_COLOR)static javafx.scene.paint.ColorgetColorOfSection(java.util.List<Section> SECTIONS, double VALUE, javafx.scene.paint.Color DEFAULT_COLOR)static javafx.scene.paint.ColorgetColorWithOpacity(javafx.scene.paint.Color COLOR, double OPACITY)static javafx.scene.paint.ColorgetContrastColor(javafx.scene.paint.Color COLOR)static java.time.format.DateTimeFormattergetDateFormat(java.util.Locale LOCALE)static doublegetDecimalDeg(int DEGREES, int MINUTES, double SECONDS)static intgetDegrees(double DEC_DEG)static java.util.Map<java.lang.String,java.util.List<CountryPath>>getHiresCountryPaths()static java.time.format.DateTimeFormattergetLocalizedDateFormat(java.util.Locale LOCALE)static java.util.Map<java.lang.String,java.util.List<CountryPath>>getLoresCountryPaths()static intgetMinutes(double DEC_DEG)static double[]getNiceScale(double MIN, double MAX)Calculates nice minValue, maxValue and stepSize for given MIN and MAX valuesstatic double[]getNiceScale(double MIN, double MAX, int MAX_NO_OF_TICKS)Calculates nice minValue, maxValue and stepSize for given MIN and MAX valuesstatic double[]getPointBetweenP1AndP2(double P1_X, double P1_Y, double P2_X, double P2_Y)static PointgetPointBetweenP1AndP2(Point P1, Point P2)static doublegetSeconds(double DEC_DEG)static java.util.concurrent.ThreadFactorygetThreadFactory(java.lang.String THREAD_NAME, boolean IS_DAEMON)static javafx.scene.paint.ColorinterpolateColor(javafx.scene.paint.Stop LOWER_BOUND, javafx.scene.paint.Stop UPPER_BOUND, double POSITION)static booleanisBright(javafx.scene.paint.Color COLOR)static booleanisDark(javafx.scene.paint.Color COLOR)static booleanisInEllipse(double X, double Y, double ELLIPSE_CENTER_X, double ELLIPSE_CENTER_Y, double ELLIPSE_RADIUS_X, double ELLIPSE_RADIUS_Y)static booleanisInPolygon(double X, double Y, int NO_OF_POINTS_IN_POLYGON, double[] POINTS_X, double[] POINTS_Y)static booleanisInPolygon(double X, double Y, javafx.scene.shape.Polygon POLYGON)static booleanisInRectangle(double X, double Y, double MIN_X, double MIN_Y, double MAX_X, double MAX_Y)static booleanisInRingSegment(double X, double Y, double CENTER_X, double CENTER_Y, double OUTER_RADIUS, double INNER_RADIUS, double START_ANGLE, double SEGMENT_ANGLE)static booleanisMonochrome(javafx.scene.paint.Color COLOR)static <T> java.util.stream.Collector<T,?,java.util.List<T>>lastN(int n)static double[]latLonToXY(double LATITUDE, double LONGITUDE)static double[]latLonToXY(double LATITUDE, double LONGITUDE, double MAP_OFFSET_X, double MAP_OFFSET_Y)static booleanlessThan(double A, double B)static doublenearest(double SMALLER, double VALUE, double LARGER)static java.lang.Stringnormalize(java.lang.String TEXT)static <T> java.util.function.Predicate<T>not(java.util.function.Predicate<T> PREDICATE)static java.lang.StringpadLeft(java.lang.String text, java.lang.String filler, int n)static java.lang.StringpadRight(java.lang.String text, java.lang.String filler, int n)static PointpointOnLine(double P1_X, double P1_Y, double P2_X, double P2_Y, double DISTAINCE_TOP_2)static double[]rotatePointAroundRotationCenter(double X, double Y, double RX, double RY, double ANGLE)static PointrotatePointAroundRotationCenter(Point POINT, Point ROTATION_CENTER, double ANGLE)static doubleround(double VALUE, int PRECISION)static introundDoubleToInt(double VALUE)static doubleroundTo(double VALUE, double TARGET)static doubleroundToHalf(double VALUE)static voidscaleNodeTo(javafx.scene.Node NODE, double TARGET_WIDTH, double TARGET_HEIGHT)static javafx.scene.shape.PathsmoothPath(javafx.collections.ObservableList<javafx.scene.shape.PathElement> ELEMENTS, boolean FILLED)static voidsmoothPath(javafx.scene.shape.Path PATH, boolean FILLED)static Point[]smoothSparkLine(java.util.List<java.lang.Double> DATA_LIST, double MIN_VALUE, double MAX_VALUE, javafx.scene.shape.Rectangle GRAPH_BOUNDS, int NO_OF_DATAPOINTS)static doublesnapToTicks(double MIN_VALUE, double MAX_VALUE, double VALUE, int MINOR_TICK_COUNT, double MAJOR_TICK_UNIT)Can be used to implement discrete steps e.g.static voidstopTask(java.util.concurrent.ScheduledFuture<?> task)static Point[]subdividePoints(Point[] POINTS, int SUB_DEVISIONS)static java.util.List<Point>subdividePoints(java.util.List<Point> POINTS, int SUB_DEVISIONS)
-
-
-
Field Detail
-
MAP_WIDTH
public static final double MAP_WIDTH
- See Also:
- Constant Field Values
-
MAP_HEIGHT
public static final double MAP_HEIGHT
- See Also:
- Constant Field Values
-
MAP_OFFSET_X
public static final double MAP_OFFSET_X
- See Also:
- Constant Field Values
-
MAP_OFFSET_Y
public static final double MAP_OFFSET_Y
- See Also:
- Constant Field Values
-
MIN_FONT_SIZE
public static final double MIN_FONT_SIZE
- See Also:
- Constant Field Values
-
AMERICAS
public static final CountryGroup AMERICAS
-
APAC
public static final CountryGroup APAC
-
APJC
public static final CountryGroup APJC
-
ANZ
public static final CountryGroup ANZ
-
BENELUX
public static final CountryGroup BENELUX
-
BRICS
public static final CountryGroup BRICS
-
DACH
public static final CountryGroup DACH
-
EMEA
public static final CountryGroup EMEA
-
EU
public static final CountryGroup EU
-
NORAM
public static final CountryGroup NORAM
-
TIME_0_TO_5
public static final java.lang.String[] TIME_0_TO_5
-
TIME_5_TO_0
public static final java.lang.String[] TIME_5_TO_0
-
TIME_0_TO_9
public static final java.lang.String[] TIME_0_TO_9
-
TIME_9_TO_0
public static final java.lang.String[] TIME_9_TO_0
-
TIME_0_TO_12
public static final java.lang.String[] TIME_0_TO_12
-
TIME_0_TO_24
public static final java.lang.String[] TIME_0_TO_24
-
TIME_24_TO_0
public static final java.lang.String[] TIME_24_TO_0
-
TIME_00_TO_59
public static final java.lang.String[] TIME_00_TO_59
-
TIME_59_TO_00
public static final java.lang.String[] TIME_59_TO_00
-
NUMERIC
public static final java.lang.String[] NUMERIC
-
ALPHANUMERIC
public static final java.lang.String[] ALPHANUMERIC
-
ALPHA
public static final java.lang.String[] ALPHA
-
EXTENDED
public static final java.lang.String[] EXTENDED
-
EXTENDED_UMLAUTE
public static final java.lang.String[] EXTENDED_UMLAUTE
-
TIME_PERIOD_24_HOURS
public static final java.time.Duration TIME_PERIOD_24_HOURS
-
TIME_PERIOD_3_DAYS
public static final java.time.Duration TIME_PERIOD_3_DAYS
-
TIME_PERIOD_5_DAYS
public static final java.time.Duration TIME_PERIOD_5_DAYS
-
TIME_PERIOD_7_DAYS
public static final java.time.Duration TIME_PERIOD_7_DAYS
-
TIME_PERIOD_1_MONTH
public static final java.time.Duration TIME_PERIOD_1_MONTH
-
TIME_PERIOD_3_MONTH
public static final java.time.Duration TIME_PERIOD_3_MONTH
-
TIME_PERIOD_6_MONTH
public static final java.time.Duration TIME_PERIOD_6_MONTH
-
TIME_PERIOD_12_MONTH
public static final java.time.Duration TIME_PERIOD_12_MONTH
-
-
Method Detail
-
clamp
public static final <T extends java.lang.Number> T clamp(T MIN, T MAX, T VALUE)
-
clamp
public static final int clamp(int MIN, int MAX, int VALUE)
-
clamp
public static final long clamp(long MIN, long MAX, long VALUE)
-
clamp
public static final double clamp(double MIN, double MAX, double VALUE)
-
clampMin
public static final double clampMin(double MIN, double VALUE)
-
clampMax
public static final double clampMax(double MAX, double VALUE)
-
round
public static final double round(double VALUE, int PRECISION)
-
roundTo
public static final double roundTo(double VALUE, double TARGET)
-
roundToHalf
public static final double roundToHalf(double VALUE)
-
nearest
public static final double nearest(double SMALLER, double VALUE, double LARGER)
-
roundDoubleToInt
public static int roundDoubleToInt(double VALUE)
-
calcAutoScale
public static final double[] calcAutoScale(double MIN_VALUE, double MAX_VALUE)
-
getNiceScale
public static final double[] getNiceScale(double MIN, double MAX)Calculates nice minValue, maxValue and stepSize for given MIN and MAX values- Parameters:
MIN-MAX-- Returns:
- array of doubles with [niceMin, niceMax, niceRange, niceStep]
-
getNiceScale
public static final double[] getNiceScale(double MIN, double MAX, int MAX_NO_OF_TICKS)Calculates nice minValue, maxValue and stepSize for given MIN and MAX values- Parameters:
MIN-MAX-MAX_NO_OF_TICKS-- Returns:
- array of doubles with [niceMin, niceMax, niceRange, niceStep]
-
snapToTicks
public static double snapToTicks(double MIN_VALUE, double MAX_VALUE, double VALUE, int MINOR_TICK_COUNT, double MAJOR_TICK_UNIT)Can be used to implement discrete steps e.g. on a slider.- Parameters:
MIN_VALUE- The min value of the rangeMAX_VALUE- The max value of the rangeVALUE- The value to snapMINOR_TICK_COUNT- The number of ticks between 2 major tick marksMAJOR_TICK_UNIT- The distance between 2 major tick marks- Returns:
- The value snapped to the next tick mark defined by the given parameters
-
calcNiceNumber
public static final double calcNiceNumber(double RANGE, boolean ROUND)Returns a "niceScaling" number approximately equal to the range. Rounds the number if ROUND == true. Takes the ceiling if ROUND = false.- Parameters:
RANGE- the value range (maxValue - minValue)ROUND- whether to round the result or ceil- Returns:
- a "niceScaling" number to be used for the value range
-
getColorOfSection
public static final javafx.scene.paint.Color getColorOfSection(java.util.List<Section> SECTIONS, double VALUE, javafx.scene.paint.Color DEFAULT_COLOR)
-
adjustTextSize
public static final void adjustTextSize(javafx.scene.text.Text TEXT, double MAX_WIDTH, double FONT_SIZE)
-
adjustTextSize
public static final void adjustTextSize(javafx.scene.control.Label TEXT, double MAX_WIDTH, double FONT_SIZE)
-
fitNodeWidth
public static final void fitNodeWidth(javafx.scene.Node NODE, double MAX_WIDTH)
-
getDateFormat
public static final java.time.format.DateTimeFormatter getDateFormat(java.util.Locale LOCALE)
-
getLocalizedDateFormat
public static final java.time.format.DateTimeFormatter getLocalizedDateFormat(java.util.Locale LOCALE)
-
enableNode
public static final void enableNode(javafx.scene.Node NODE, boolean ENABLE)
-
colorToCss
public static final java.lang.String colorToCss(javafx.scene.paint.Color COLOR)
-
getThreadFactory
public static final java.util.concurrent.ThreadFactory getThreadFactory(java.lang.String THREAD_NAME, boolean IS_DAEMON)
-
stopTask
public static final void stopTask(java.util.concurrent.ScheduledFuture<?> task)
-
isMonochrome
public static final boolean isMonochrome(javafx.scene.paint.Color COLOR)
-
colorDistance
public static final double colorDistance(javafx.scene.paint.Color COLOR_1, javafx.scene.paint.Color COLOR_2)
-
colorToYUV
public static double[] colorToYUV(javafx.scene.paint.Color COLOR)
-
isBright
public static final boolean isBright(javafx.scene.paint.Color COLOR)
-
isDark
public static final boolean isDark(javafx.scene.paint.Color COLOR)
-
getContrastColor
public static final javafx.scene.paint.Color getContrastColor(javafx.scene.paint.Color COLOR)
-
getColorWithOpacity
public static final javafx.scene.paint.Color getColorWithOpacity(javafx.scene.paint.Color COLOR, double OPACITY)
-
createColorPalette
public static final java.util.List<javafx.scene.paint.Color> createColorPalette(javafx.scene.paint.Color FROM_COLOR, javafx.scene.paint.Color TO_COLOR, int NO_OF_COLORS)
-
createColorVariations
public static final javafx.scene.paint.Color[] createColorVariations(javafx.scene.paint.Color COLOR, int NO_OF_COLORS)
-
getColorAt
public static final javafx.scene.paint.Color getColorAt(java.util.List<javafx.scene.paint.Stop> STOP_LIST, double POSITION_OF_COLOR)
-
interpolateColor
public static final javafx.scene.paint.Color interpolateColor(javafx.scene.paint.Stop LOWER_BOUND, javafx.scene.paint.Stop UPPER_BOUND, double POSITION)
-
scaleNodeTo
public static final void scaleNodeTo(javafx.scene.Node NODE, double TARGET_WIDTH, double TARGET_HEIGHT)
-
normalize
public static final java.lang.String normalize(java.lang.String TEXT)
-
equals
public static final boolean equals(double A, double B)
-
biggerThan
public static final boolean biggerThan(double A, double B)
-
lessThan
public static final boolean lessThan(double A, double B)
-
subdividePoints
public static final java.util.List<Point> subdividePoints(java.util.List<Point> POINTS, int SUB_DEVISIONS)
-
smoothSparkLine
public static final Point[] smoothSparkLine(java.util.List<java.lang.Double> DATA_LIST, double MIN_VALUE, double MAX_VALUE, javafx.scene.shape.Rectangle GRAPH_BOUNDS, int NO_OF_DATAPOINTS)
-
getHiresCountryPaths
public static final java.util.Map<java.lang.String,java.util.List<CountryPath>> getHiresCountryPaths()
-
getLoresCountryPaths
public static final java.util.Map<java.lang.String,java.util.List<CountryPath>> getLoresCountryPaths()
-
drawRoundedRect
public static final void drawRoundedRect(javafx.scene.canvas.GraphicsContext CTX, CtxBounds BOUNDS, CtxCornerRadii RADII)
-
smoothPath
public static final void smoothPath(javafx.scene.shape.Path PATH, boolean FILLED)
-
smoothPath
public static final javafx.scene.shape.Path smoothPath(javafx.collections.ObservableList<javafx.scene.shape.PathElement> ELEMENTS, boolean FILLED)
-
isInRectangle
public static final boolean isInRectangle(double X, double Y, double MIN_X, double MIN_Y, double MAX_X, double MAX_Y)
-
isInEllipse
public static final boolean isInEllipse(double X, double Y, double ELLIPSE_CENTER_X, double ELLIPSE_CENTER_Y, double ELLIPSE_RADIUS_X, double ELLIPSE_RADIUS_Y)
-
isInPolygon
public static final boolean isInPolygon(double X, double Y, javafx.scene.shape.Polygon POLYGON)
-
isInPolygon
public static final boolean isInPolygon(double X, double Y, int NO_OF_POINTS_IN_POLYGON, double[] POINTS_X, double[] POINTS_Y)
-
isInRingSegment
public static final boolean isInRingSegment(double X, double Y, double CENTER_X, double CENTER_Y, double OUTER_RADIUS, double INNER_RADIUS, double START_ANGLE, double SEGMENT_ANGLE)
-
distance
public static final double distance(double P1_X, double P1_Y, double P2_X, double P2_Y)
-
euclideanDistance
public static double euclideanDistance(double X1, double Y1, double X2, double Y2)
-
pointOnLine
public static final Point pointOnLine(double P1_X, double P1_Y, double P2_X, double P2_Y, double DISTAINCE_TOP_2)
-
checkLineCircleCollision
public static int checkLineCircleCollision(Point P1, Point P2, double CENTER_X, double CENTER_Y, double RADIUS)
-
checkLineCircleCollision
public static int checkLineCircleCollision(double P1_X, double P1_Y, double P2_X, double P2_Y, double CENTER_X, double CENTER_Y, double RADIUS)
-
checkCollision
public static int checkCollision(double a, double b, double c, double centerX, double centerY, double radius)
-
getAngleFromXY
public static final double getAngleFromXY(double X, double Y, double CENTER_X, double CENTER_Y)
-
getAngleFromXY
public static final double getAngleFromXY(double X, double Y, double CENTER_X, double CENTER_Y, double ANGLE_OFFSET)
-
rotatePointAroundRotationCenter
public static final Point rotatePointAroundRotationCenter(Point POINT, Point ROTATION_CENTER, double ANGLE)
-
rotatePointAroundRotationCenter
public static final double[] rotatePointAroundRotationCenter(double X, double Y, double RX, double RY, double ANGLE)
-
getPointBetweenP1AndP2
public static final double[] getPointBetweenP1AndP2(double P1_X, double P1_Y, double P2_X, double P2_Y)
-
getDegrees
public static int getDegrees(double DEC_DEG)
-
getMinutes
public static int getMinutes(double DEC_DEG)
-
getSeconds
public static double getSeconds(double DEC_DEG)
-
getDecimalDeg
public static double getDecimalDeg(int DEGREES, int MINUTES, double SECONDS)
-
latLonToXY
public static final double[] latLonToXY(double LATITUDE, double LONGITUDE)
-
latLonToXY
public static final double[] latLonToXY(double LATITUDE, double LONGITUDE, double MAP_OFFSET_X, double MAP_OFFSET_Y)
-
not
public static final <T> java.util.function.Predicate<T> not(java.util.function.Predicate<T> PREDICATE)
-
createSmoothedConvexHull
public static final java.util.List<Point> createSmoothedConvexHull(java.util.List<Point> POINTS, int SUB_DIVISIONS)
-
createConvexHull
public static final <T extends Point> java.util.List<T> createConvexHull(java.util.List<T> POINTS)
-
padLeft
public static final java.lang.String padLeft(java.lang.String text, java.lang.String filler, int n)
-
padRight
public static final java.lang.String padRight(java.lang.String text, java.lang.String filler, int n)
-
lastN
public static <T> java.util.stream.Collector<T,?,java.util.List<T>> lastN(int n)
-
calcNumberOfDatapointsForPeriod
public static int calcNumberOfDatapointsForPeriod(java.time.Duration TIME_PERIOD, java.util.concurrent.TimeUnit RESOLUTION)
-
-