java.lang.Object
eu.hansolo.medusa.tools.Helper
Created by hansolo on 11.12.15.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final javafx.scene.paint.Colorstatic final doublestatic final doublestatic final double -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final voidadjustTextSize(javafx.scene.control.Label TEXT, double MAX_WIDTH, double FONT_SIZE) static final voidadjustTextSize(javafx.scene.text.Text TEXT, double MAX_WIDTH, double FONT_SIZE) static final double[]calcAutoScale(double MIN_VALUE, double MAX_VALUE) static final doublecalcNiceNumber(double RANGE, boolean ROUND) Returns a "niceScaling" number approximately equal to the range.static final doubleclamp(double MIN, double MAX, double VALUE) static final intclamp(int MIN, int MAX, int VALUE) static final longclamp(long MIN, long MAX, long VALUE) static final <T extends Number>
Tclamp(T MIN, T MAX, T VALUE) static final doubleclampMax(double MAX, double VALUE) static final doubleclampMin(double MIN, double VALUE) static final doublecolorDistance(javafx.scene.paint.Color COLOR_1, javafx.scene.paint.Color COLOR_2) static final StringcolorToCss(javafx.scene.paint.Color COLOR) static final javafx.scene.paint.ImagePatternstatic final javafx.scene.image.ImagecreateNoiseImage(double WIDTH, double HEIGHT, javafx.scene.paint.Color DARK_COLOR, javafx.scene.paint.Color BRIGHT_COLOR, double ALPHA_VARIATION_IN_PERCENT) static final voiddrawAlarms(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 voiddrawDot(javafx.scene.canvas.GraphicsContext CTX, double CENTER_X, double CENTER_Y, double SIZE) static final voiddrawLine(javafx.scene.canvas.GraphicsContext CTX, double P1X, double P1Y, double P2X, double P2Y) static final voiddrawRadialTickMarks(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 voiddrawTimeAreas(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 voiddrawTimeSections(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 voiddrawTrapezoid(javafx.scene.canvas.GraphicsContext CTX, double PI1X, double PI1Y, double PI2X, double PI2Y, double PO1X, double PO1Y, double PO2X, double PO2Y) static final voiddrawTriangle(javafx.scene.canvas.GraphicsContext CTX, double PIX, double PIY, double PO1X, double PO1Y, double PO2X, double PO2Y) static final voidenableNode(javafx.scene.Node NODE, boolean ENABLE) static final StringformatNumber(Gauge GAUGE, double VALUE) static final StringformatNumber(Locale LOCALE, double MIN_VALUE, double MAX_VALUE, int DECIMALS, double VALUE) static final StringformatNumber(Locale LOCALE, String FORMAT_STRING, int DECIMALS, double VALUE) static final javafx.scene.paint.ColorgetColorOfSection(List<Section> SECTIONS, double VALUE, javafx.scene.paint.Color DEFAULT_COLOR) static final DateTimeFormattergetDateFormat(Locale LOCALE) static final DateTimeFormattergetLocalizedDateFormat(Locale LOCALE) static final double[]getNiceScale(double MIN, double MAX) Calculates nice minValue, maxValue and stepSize for given MIN and MAX valuesstatic final double[]getNiceScale(double MIN, double MAX, int MAX_NO_OF_TICKS) Calculates nice minValue, maxValue and stepSize for given MIN and MAX valuesstatic final ThreadFactorygetThreadFactory(String THREAD_NAME, boolean IS_DAEMON) static final javafx.scene.paint.ColorgetTranslucentColorFrom(javafx.scene.paint.Color COLOR, double FACTOR) static final booleanisBright(javafx.scene.paint.Color COLOR) static final booleanisDark(javafx.scene.paint.Color COLOR) static final booleanisMonochrome(javafx.scene.paint.Color COLOR) static final doublenearest(double SMALLER, double VALUE, double LARGER) static final voidrotateContextForText(javafx.scene.canvas.GraphicsContext CTX, double START_ANGLE, double ANGLE, TickLabelOrientation ORIENTATION) static final doubleround(double VALUE, int PRECISION) static final introundDoubleToInt(double VALUE) static final doubleroundTo(double VALUE, double TARGET) static final doubleroundToHalf(double VALUE) static final 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 final voidstopTask(ScheduledFuture<?> task)
-
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
-
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 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
-
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
-
getLocalizedDateFormat
-
enableNode
public static final void enableNode(javafx.scene.Node NODE, boolean ENABLE) -
colorToCss
-
getThreadFactory
-
stopTask
-
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
-
formatNumber
-
formatNumber
-