Class Helper


  • public class Helper
    extends java.lang.Object
    Created by hansolo on 11.12.15.
    • Constructor Summary

      Constructors 
      Constructor Description
      Helper()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void adjustTextSize​(javafx.scene.control.Label TEXT, double MAX_WIDTH, double FONT_SIZE)  
      static void adjustTextSize​(javafx.scene.text.Text TEXT, double MAX_WIDTH, double FONT_SIZE)  
      static boolean biggerThan​(double A, double B)  
      static double[] calcAutoScale​(double MIN_VALUE, double MAX_VALUE)  
      static double calcNiceNumber​(double RANGE, boolean ROUND)
      Returns a "niceScaling" number approximately equal to the range.
      static int calcNumberOfDatapointsForPeriod​(java.time.Duration TIME_PERIOD, java.util.concurrent.TimeUnit RESOLUTION)  
      static int checkCollision​(double a, double b, double c, double centerX, double centerY, double radius)  
      static int checkLineCircleCollision​(double P1_X, double P1_Y, double P2_X, double P2_Y, double CENTER_X, double CENTER_Y, double RADIUS)  
      static int checkLineCircleCollision​(Point P1, Point P2, double CENTER_X, double CENTER_Y, double RADIUS)  
      static double clamp​(double MIN, double MAX, double VALUE)  
      static int clamp​(int MIN, int MAX, int VALUE)  
      static long clamp​(long MIN, long MAX, long VALUE)  
      static <T extends java.lang.Number>
      T
      clamp​(T MIN, T MAX, T VALUE)  
      static double clampMax​(double MAX, double VALUE)  
      static double clampMin​(double MIN, double VALUE)  
      static double colorDistance​(javafx.scene.paint.Color COLOR_1, javafx.scene.paint.Color COLOR_2)  
      static java.lang.String colorToCss​(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 double distance​(double P1_X, double P1_Y, double P2_X, double P2_Y)  
      static double distance​(Point P1, Point P2)  
      static void drawRoundedRect​(javafx.scene.canvas.GraphicsContext CTX, CtxBounds BOUNDS, CtxCornerRadii RADII)  
      static void enableNode​(javafx.scene.Node NODE, boolean ENABLE)  
      static boolean equals​(double A, double B)  
      static double euclideanDistance​(double X1, double Y1, double X2, double Y2)  
      static double euclideanDistance​(Point P1, Point P2)  
      static void fitNodeWidth​(javafx.scene.Node NODE, double MAX_WIDTH)  
      static double getAngleFromXY​(double X, double Y, double CENTER_X, double CENTER_Y)  
      static double getAngleFromXY​(double X, double Y, double CENTER_X, double CENTER_Y, double ANGLE_OFFSET)  
      static javafx.scene.paint.Color getColorAt​(java.util.List<javafx.scene.paint.Stop> STOP_LIST, double POSITION_OF_COLOR)  
      static javafx.scene.paint.Color getColorOfSection​(java.util.List<Section> SECTIONS, double VALUE, javafx.scene.paint.Color DEFAULT_COLOR)  
      static javafx.scene.paint.Color getColorWithOpacity​(javafx.scene.paint.Color COLOR, double OPACITY)  
      static javafx.scene.paint.Color getContrastColor​(javafx.scene.paint.Color COLOR)  
      static java.time.format.DateTimeFormatter getDateFormat​(java.util.Locale LOCALE)  
      static double getDecimalDeg​(int DEGREES, int MINUTES, double SECONDS)  
      static int getDegrees​(double DEC_DEG)  
      static java.util.Map<java.lang.String,​java.util.List<CountryPath>> getHiresCountryPaths()  
      static java.time.format.DateTimeFormatter getLocalizedDateFormat​(java.util.Locale LOCALE)  
      static java.util.Map<java.lang.String,​java.util.List<CountryPath>> getLoresCountryPaths()  
      static int getMinutes​(double DEC_DEG)  
      static double[] getNiceScale​(double MIN, double MAX)
      Calculates nice minValue, maxValue and stepSize for given MIN and MAX values
      static double[] getNiceScale​(double MIN, double MAX, int MAX_NO_OF_TICKS)
      Calculates nice minValue, maxValue and stepSize for given MIN and MAX values
      static double[] getPointBetweenP1AndP2​(double P1_X, double P1_Y, double P2_X, double P2_Y)  
      static Point getPointBetweenP1AndP2​(Point P1, Point P2)  
      static double getSeconds​(double DEC_DEG)  
      static java.util.concurrent.ThreadFactory getThreadFactory​(java.lang.String THREAD_NAME, boolean IS_DAEMON)  
      static javafx.scene.paint.Color interpolateColor​(javafx.scene.paint.Stop LOWER_BOUND, javafx.scene.paint.Stop UPPER_BOUND, double POSITION)  
      static boolean isBright​(javafx.scene.paint.Color COLOR)  
      static boolean isDark​(javafx.scene.paint.Color COLOR)  
      static boolean isInEllipse​(double X, double Y, double ELLIPSE_CENTER_X, double ELLIPSE_CENTER_Y, double ELLIPSE_RADIUS_X, double ELLIPSE_RADIUS_Y)  
      static boolean isInPolygon​(double X, double Y, int NO_OF_POINTS_IN_POLYGON, double[] POINTS_X, double[] POINTS_Y)  
      static boolean isInPolygon​(double X, double Y, javafx.scene.shape.Polygon POLYGON)  
      static boolean isInRectangle​(double X, double Y, double MIN_X, double MIN_Y, double MAX_X, double MAX_Y)  
      static boolean isInRingSegment​(double X, double Y, double CENTER_X, double CENTER_Y, double OUTER_RADIUS, double INNER_RADIUS, double START_ANGLE, double SEGMENT_ANGLE)  
      static boolean isMonochrome​(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 boolean lessThan​(double A, double B)  
      static double nearest​(double SMALLER, double VALUE, double LARGER)  
      static java.lang.String normalize​(java.lang.String TEXT)  
      static <T> java.util.function.Predicate<T> not​(java.util.function.Predicate<T> PREDICATE)  
      static java.lang.String padLeft​(java.lang.String text, java.lang.String filler, int n)  
      static java.lang.String padRight​(java.lang.String text, java.lang.String filler, int n)  
      static Point pointOnLine​(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 Point rotatePointAroundRotationCenter​(Point POINT, Point ROTATION_CENTER, double ANGLE)  
      static double round​(double VALUE, int PRECISION)  
      static int roundDoubleToInt​(double VALUE)  
      static double roundTo​(double VALUE, double TARGET)  
      static double roundToHalf​(double VALUE)  
      static void scaleNodeTo​(javafx.scene.Node NODE, double TARGET_WIDTH, double TARGET_HEIGHT)  
      static javafx.scene.shape.Path smoothPath​(javafx.collections.ObservableList<javafx.scene.shape.PathElement> ELEMENTS, boolean FILLED)  
      static void smoothPath​(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 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.
      static void stopTask​(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)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • 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
    • Constructor Detail

      • Helper

        public Helper()
    • 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 range
        MAX_VALUE - The max value of the range
        VALUE - The value to snap
        MINOR_TICK_COUNT - The number of ticks between 2 major tick marks
        MAJOR_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)
      • subdividePoints

        public static final Point[] subdividePoints​(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​(Point P1,
                                            Point P2)
      • distance

        public static final double distance​(double P1_X,
                                            double P1_Y,
                                            double P2_X,
                                            double P2_Y)
      • euclideanDistance

        public static double euclideanDistance​(Point P1,
                                               Point P2)
      • 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 Point getPointBetweenP1AndP2​(Point P1,
                                                         Point P2)
      • 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)