Class Helper

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

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

    Fields
    Modifier and Type
    Field
    Description
    static final javafx.scene.paint.Color
     
    static final double
     
    static final double
     
    static final double
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static final void
    adjustTextSize(javafx.scene.control.Label TEXT, double MAX_WIDTH, double FONT_SIZE)
     
    static final void
    adjustTextSize(javafx.scene.text.Text TEXT, double MAX_WIDTH, double FONT_SIZE)
     
    static final double[]
    calcAutoScale(double MIN_VALUE, double MAX_VALUE)
     
    static final double
    calcNiceNumber(double RANGE, boolean ROUND)
    Returns a "niceScaling" number approximately equal to the range.
    static final double
    clamp(double MIN, double MAX, double VALUE)
     
    static final int
    clamp(int MIN, int MAX, int VALUE)
     
    static final long
    clamp(long MIN, long MAX, long VALUE)
     
    static final <T extends Number>
    T
    clamp(T MIN, T MAX, T VALUE)
     
    static final double
    clampMax(double MAX, double VALUE)
     
    static final double
    clampMin(double MIN, double VALUE)
     
    static final double
    colorDistance(javafx.scene.paint.Color COLOR_1, javafx.scene.paint.Color COLOR_2)
     
    static final String
    colorToCss(javafx.scene.paint.Color COLOR)
     
    static final javafx.scene.paint.ImagePattern
     
    static final javafx.scene.image.Image
    createNoiseImage(double WIDTH, double HEIGHT, javafx.scene.paint.Color DARK_COLOR, javafx.scene.paint.Color BRIGHT_COLOR, double ALPHA_VARIATION_IN_PERCENT)
     
    static final void
    drawAlarms(Clock CLOCK, double SIZE, double ALARM_MARKER_SIZE, double ALARM_MARKER_RADIUS, Map<Alarm,javafx.scene.shape.Circle> ALARM_MAP, DateTimeFormatter DATE_TIME_FORMATTER, ZonedDateTime TIME)
     
    static final void
    drawDot(javafx.scene.canvas.GraphicsContext CTX, double CENTER_X, double CENTER_Y, double SIZE)
     
    static final void
    drawLine(javafx.scene.canvas.GraphicsContext CTX, double P1X, double P1Y, double P2X, double P2Y)
     
    static final void
    drawRadialTickMarks(Gauge GAUGE, javafx.scene.canvas.GraphicsContext CTX, double MIN_VALUE, double MAX_VALUE, double START_ANGLE, double ANGLE_RANGE, double ANGLE_STEP, double CENTER_X, double CENTER_Y, double SIZE)
     
    static final void
    drawTimeAreas(Clock CLOCK, javafx.scene.canvas.GraphicsContext CTX, List<TimeSection> AREAS, double SIZE, double XY_INSIDE, double XY_OUTSIDE, double WH_INSIDE, double WH_OUTSIDE)
     
    static final void
    drawTimeSections(Clock CLOCK, javafx.scene.canvas.GraphicsContext CTX, List<TimeSection> SECTIONS, double SIZE, double XY_INSIDE, double XY_OUTSIDE, double WH_INSIDE, double WH_OUTSIDE, double LINE_WIDTH)
     
    static final void
    drawTrapezoid(javafx.scene.canvas.GraphicsContext CTX, double PI1X, double PI1Y, double PI2X, double PI2Y, double PO1X, double PO1Y, double PO2X, double PO2Y)
     
    static final void
    drawTriangle(javafx.scene.canvas.GraphicsContext CTX, double PIX, double PIY, double PO1X, double PO1Y, double PO2X, double PO2Y)
     
    static final void
    enableNode(javafx.scene.Node NODE, boolean ENABLE)
     
    static final String
    formatNumber(Gauge GAUGE, double VALUE)
     
    static final String
    formatNumber(Locale LOCALE, double MIN_VALUE, double MAX_VALUE, int DECIMALS, double VALUE)
     
    static final String
    formatNumber(Locale LOCALE, String FORMAT_STRING, int DECIMALS, double VALUE)
     
    static final javafx.scene.paint.Color
    getColorOfSection(List<Section> SECTIONS, double VALUE, javafx.scene.paint.Color DEFAULT_COLOR)
     
    static final DateTimeFormatter
     
    static final DateTimeFormatter
     
    static final double[]
    getNiceScale(double MIN, double MAX)
    Calculates nice minValue, maxValue and stepSize for given MIN and MAX values
    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
    static final ThreadFactory
    getThreadFactory(String THREAD_NAME, boolean IS_DAEMON)
     
    static final javafx.scene.paint.Color
    getTranslucentColorFrom(javafx.scene.paint.Color COLOR, double FACTOR)
     
    static final boolean
    isBright(javafx.scene.paint.Color COLOR)
     
    static final boolean
    isDark(javafx.scene.paint.Color COLOR)
     
    static final boolean
    isMonochrome(javafx.scene.paint.Color COLOR)
     
    static final double
    nearest(double SMALLER, double VALUE, double LARGER)
     
    static final void
    rotateContextForText(javafx.scene.canvas.GraphicsContext CTX, double START_ANGLE, double ANGLE, TickLabelOrientation ORIENTATION)
     
    static final double
    round(double VALUE, int PRECISION)
     
    static final int
    roundDoubleToInt(double VALUE)
     
    static final double
    roundTo(double VALUE, double TARGET)
     
    static final double
    roundToHalf(double VALUE)
     
    static final 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 final void
     

    Methods inherited from class java.lang.Object

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

    • MAX_TICK_MARK_LENGTH

      public static final double MAX_TICK_MARK_LENGTH
      See Also:
    • MAX_TICK_MARK_WIDTH

      public static final double MAX_TICK_MARK_WIDTH
      See Also:
    • INACTIVE_ALARM_COLOR

      public static final javafx.scene.paint.Color INACTIVE_ALARM_COLOR
    • MIN_FONT_SIZE

      public static final double MIN_FONT_SIZE
      See Also:
  • 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 final 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 final 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)
    • rotateContextForText

      public static final void rotateContextForText(javafx.scene.canvas.GraphicsContext CTX, double START_ANGLE, double ANGLE, TickLabelOrientation ORIENTATION)
    • 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)
    • 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)
    • createCarbonPattern

      public static final javafx.scene.paint.ImagePattern createCarbonPattern()
    • drawTrapezoid

      public static final void drawTrapezoid(javafx.scene.canvas.GraphicsContext CTX, double PI1X, double PI1Y, double PI2X, double PI2Y, double PO1X, double PO1Y, double PO2X, double PO2Y)
    • drawTriangle

      public static final void drawTriangle(javafx.scene.canvas.GraphicsContext CTX, double PIX, double PIY, double PO1X, double PO1Y, double PO2X, double PO2Y)
    • drawDot

      public static final void drawDot(javafx.scene.canvas.GraphicsContext CTX, double CENTER_X, double CENTER_Y, double SIZE)
    • drawLine

      public static final void drawLine(javafx.scene.canvas.GraphicsContext CTX, double P1X, double P1Y, double P2X, double P2Y)
    • 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)
    • isBright

      public static final boolean isBright(javafx.scene.paint.Color COLOR)
    • isDark

      public static final boolean isDark(javafx.scene.paint.Color COLOR)
    • getTranslucentColorFrom

      public static final javafx.scene.paint.Color getTranslucentColorFrom(javafx.scene.paint.Color COLOR, double FACTOR)
    • drawRadialTickMarks

      public static final void drawRadialTickMarks(Gauge GAUGE, javafx.scene.canvas.GraphicsContext CTX, double MIN_VALUE, double MAX_VALUE, double START_ANGLE, double ANGLE_RANGE, double ANGLE_STEP, double CENTER_X, double CENTER_Y, double SIZE)
    • createNoiseImage

      public static final javafx.scene.image.Image createNoiseImage(double WIDTH, double HEIGHT, javafx.scene.paint.Color DARK_COLOR, javafx.scene.paint.Color BRIGHT_COLOR, double ALPHA_VARIATION_IN_PERCENT)
    • drawTimeSections

      public static final void drawTimeSections(Clock CLOCK, javafx.scene.canvas.GraphicsContext CTX, List<TimeSection> SECTIONS, double SIZE, double XY_INSIDE, double XY_OUTSIDE, double WH_INSIDE, double WH_OUTSIDE, double LINE_WIDTH)
    • drawTimeAreas

      public static final void drawTimeAreas(Clock CLOCK, javafx.scene.canvas.GraphicsContext CTX, List<TimeSection> AREAS, double SIZE, double XY_INSIDE, double XY_OUTSIDE, double WH_INSIDE, double WH_OUTSIDE)
    • drawAlarms

      public static final void drawAlarms(Clock CLOCK, double SIZE, double ALARM_MARKER_SIZE, double ALARM_MARKER_RADIUS, Map<Alarm,javafx.scene.shape.Circle> ALARM_MAP, DateTimeFormatter DATE_TIME_FORMATTER, ZonedDateTime TIME)
    • formatNumber

      public static final String formatNumber(Gauge GAUGE, double VALUE)
    • formatNumber

      public static final String formatNumber(Locale LOCALE, String FORMAT_STRING, int DECIMALS, double VALUE)
    • formatNumber

      public static final String formatNumber(Locale LOCALE, double MIN_VALUE, double MAX_VALUE, int DECIMALS, double VALUE)