Class Helper

java.lang.Object
eu.hansolo.tilesfx.tools.Helper

public class Helper extends Object
Created by hansolo on 11.12.15.
  • Field Details

    • MAP_WIDTH

      public static final double MAP_WIDTH
      See Also:
    • MAP_HEIGHT

      public static final double MAP_HEIGHT
      See Also:
    • MAP_OFFSET_X

      public static final double MAP_OFFSET_X
      See Also:
    • MAP_OFFSET_Y

      public static final double MAP_OFFSET_Y
      See Also:
    • MIN_FONT_SIZE

      public static final double MIN_FONT_SIZE
      See Also:
    • 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 String[] TIME_0_TO_5
    • TIME_5_TO_0

      public static final String[] TIME_5_TO_0
    • TIME_0_TO_9

      public static final String[] TIME_0_TO_9
    • TIME_9_TO_0

      public static final String[] TIME_9_TO_0
    • TIME_0_TO_12

      public static final String[] TIME_0_TO_12
    • TIME_0_TO_24

      public static final String[] TIME_0_TO_24
    • TIME_24_TO_0

      public static final String[] TIME_24_TO_0
    • TIME_00_TO_59

      public static final String[] TIME_00_TO_59
    • TIME_59_TO_00

      public static final String[] TIME_59_TO_00
    • NUMERIC

      public static final String[] NUMERIC
    • ALPHANUMERIC

      public static final String[] ALPHANUMERIC
    • ALPHA

      public static final String[] ALPHA
    • EXTENDED

      public static final String[] EXTENDED
    • EXTENDED_UMLAUTE

      public static final String[] EXTENDED_UMLAUTE
    • PERCENTAGE

      public static final String PERCENTAGE
      See Also:
    • DEGREE

      public static final String DEGREE
      See Also:
    • SECONDS_PER_MINUTE

      public static final long SECONDS_PER_MINUTE
      See Also:
    • SECONDS_PER_HOUR

      public static final long SECONDS_PER_HOUR
      See Also:
    • SECONDS_PER_DAY

      public static final long SECONDS_PER_DAY
      See Also:
    • SECONDS_PER_MONTH

      public static final long SECONDS_PER_MONTH
      See Also:
    • TIME_PERIOD_24_HOURS

      public static final Duration TIME_PERIOD_24_HOURS
    • TIME_PERIOD_3_DAYS

      public static final Duration TIME_PERIOD_3_DAYS
    • TIME_PERIOD_5_DAYS

      public static final Duration TIME_PERIOD_5_DAYS
    • TIME_PERIOD_7_DAYS

      public static final Duration TIME_PERIOD_7_DAYS
    • TIME_PERIOD_1_MONTH

      public static final Duration TIME_PERIOD_1_MONTH
    • TIME_PERIOD_3_MONTH

      public static final Duration TIME_PERIOD_3_MONTH
    • TIME_PERIOD_6_MONTH

      public static final Duration TIME_PERIOD_6_MONTH
    • TIME_PERIOD_12_MONTH

      public static final Duration TIME_PERIOD_12_MONTH
  • Constructor Details

    • Helper

      public Helper()
  • Method Details

    • clamp

      public static final <T extends 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(List<Section> SECTIONS, double VALUE, javafx.scene.paint.Color DEFAULT_COLOR)
    • adjustTextSize

      public static final double 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 DateTimeFormatter getDateFormat(Locale LOCALE)
    • getLocalizedDateFormat

      public static final DateTimeFormatter getLocalizedDateFormat(Locale LOCALE)
    • enableNode

      public static final void enableNode(javafx.scene.Node NODE, boolean ENABLE)
    • colorToCss

      public static final String colorToCss(javafx.scene.paint.Color COLOR)
    • getThreadFactory

      public static final ThreadFactory getThreadFactory(String THREAD_NAME, boolean IS_DAEMON)
    • stopTask

      public static final void stopTask(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 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(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 String normalize(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 List<Point> subdividePoints(List<Point> POINTS, int SUB_DEVISIONS)
    • subdividePoints

      public static final Point[] subdividePoints(Point[] POINTS, int SUB_DEVISIONS)
    • smoothSparkLine

      public static final Point[] smoothSparkLine(List<Double> DATA_LIST, double MIN_VALUE, double MAX_VALUE, javafx.scene.shape.Rectangle GRAPH_BOUNDS, int NO_OF_DATAPOINTS)
    • getHiresCountryPaths

      public static final Map<String,List<CountryPath>> getHiresCountryPaths()
    • getLoresCountryPaths

      public static final Map<String,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> Predicate<T> not(Predicate<T> PREDICATE)
    • createSmoothedConvexHull

      public static final List<Point> createSmoothedConvexHull(List<Point> POINTS, int SUB_DIVISIONS)
    • createConvexHull

      public static final <T extends Point> List<T> createConvexHull(List<T> POINTS)
    • splitStringInCharacters

      public static final List<Character> splitStringInCharacters(String text)
    • splitNumberInDigits

      public static final List<Character> splitNumberInDigits(double number)
    • padLeft

      public static final String padLeft(String text, String filler, int n)
    • padRight

      public static final String padRight(String text, String filler, int n)
    • lastN

      public static <T> Collector<T,?,List<T>> lastN(int n)
    • calcNumberOfDatapointsForPeriod

      public static final int calcNumberOfDatapointsForPeriod(Duration TIME_PERIOD, TimeUnit RESOLUTION)
    • calcNumberOfVerticalTickLinesForPeriod

      public static final int calcNumberOfVerticalTickLinesForPeriod(Duration TIME_PERIOD, TimeUnit RESOLUTION)