Class HelperFX

java.lang.Object
eu.hansolo.toolboxfx.HelperFX

public class HelperFX extends Object
  • Method Details

    • nearest

      public static final double nearest(double smaller, double value, double larger)
    • calcAutoScale

      public static final double[] calcAutoScale(double minValue, double maxValue)
    • calcAutoScale

      public static final double[] calcAutoScale(double minValue, double maxValue, double maxNoOfMajorTicks, double maxNoOfMinorTicks)
    • snapToTicks

      public static final double snapToTicks(double minValue, double maxValue, double value, int newMinorTickCount, double newMajorTickUnit)
      Can be used to implement discrete steps e.g. on a slider.
      Parameters:
      minValue - The min value of the range
      maxValue - The max value of the range
      value - The value to snap
      newMinorTickCount - The number of ticks between 2 major tick marks
      newMajorTickUnit - 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
    • subdividePoints

      public static final List<Point> subdividePoints(List<Point> points, int subDevisions)
    • subdividePoints

      public static final Point[] subdividePoints(Point[] points, int subDevisions)
    • subdividePointsRadial

      public static final List<Point> subdividePointsRadial(List<Point> points, int subDevisions)
    • subdividePointsRadial

      public static final Point[] subdividePointsRadial(Point[] points, int subDivisions)
    • subdividePointsLinear

      public static final List<Point> subdividePointsLinear(List<Point> points, int subDevisions)
    • subdividePointsLinear

      public static final Point[] subdividePointsLinear(Point[] points, int subDivisions)
    • calcIntermediatePoint

      public static final Point calcIntermediatePoint(Point leftPoint, Point rightPoint, double intervalX)
    • calcIntersectionOfTwoLines

      public static final Point calcIntersectionOfTwoLines(Point A, Point B, Point C, Point D)
    • calcIntersectionOfTwoLines

      public static final Point calcIntersectionOfTwoLines(double X1, double Y1, double X2, double Y2, double X3, double Y3, double X4, double Y4)
    • calcIntersectionPoint

      public static final Point calcIntersectionPoint(Point leftPoint, Point rightPoint, double intersectionY)
    • calculateIntersectionPoint

      public static final double[] calculateIntersectionPoint(Point leftPoint, Point rightPoint, double intersectionY)
    • calculateIntersectionPoint

      public static final double[] calculateIntersectionPoint(double x1, double y1, double x2, double y2, double intersectionY)
    • smoothSparkLine

      public static final Point[] smoothSparkLine(List<Double> dataList, double minValue, double maxValue, Rectangle graphBounds, int noOfDatapoints)
    • isInRectangle

      public static final boolean isInRectangle(double x, double y, double minX, double minY, double maxX, double maxY)
    • isInCircle

      public static final boolean isInCircle(double x, double y, double centerX, double centerY, double radius)
    • isInEllipse

      public static final boolean isInEllipse(double x, double y, double centerX, double centerY, double radiusX, double radiusY)
    • isInPolygon

      public static final boolean isInPolygon(double x, double y, List<Point> pointsOfPolygon)
    • isInPolygon

      public static final boolean isInPolygon(double x, double y, int noOfPointsInPolygon, double[] pointsX, double[] pointsY)
    • isPointInPolygon

      public static final <T extends Point> boolean isPointInPolygon(T p, List<T> points)
    • isInSector

      public static final boolean isInSector(double x, double y, double centerX, double centerY, double radius, double startAngle, double segmentAngle)
    • isInRingSegment

      public static final boolean isInRingSegment(double x, double y, double centerX, double centerY, double outerRadius, double innerRadius, double newStartAngle, double segmentAngle)
    • isPointOnLine

      public static final boolean isPointOnLine(Point p, Point p1, Point p2)
    • distanceFromPointToLine

      public static final double distanceFromPointToLine(Point p, Point p1, Point p2)
    • squareDistance

      public static final <T extends Point> double squareDistance(T p1, T p2)
    • squareDistance

      public static final double squareDistance(double x1, double y1, double x2, double y2)
    • distance

      public static final double distance(Point p1, Point p2)
    • distance

      public static final double distance(double p1X, double p1Y, double p2X, double p2Y)
    • euclideanDistance

      public static final double euclideanDistance(Point p1, Point p2)
    • euclideanDistance

      public static final double euclideanDistance(double x1, double y1, double x2, double y2)
    • pointOnLine

      public static final Point pointOnLine(double p1X, double p1Y, double p2X, double p2Y, double distanceToP2)
    • checkLineCircleCollision

      public static final int checkLineCircleCollision(Point p1, Point p2, double centerX, double centerY, double radius)
    • checkLineCircleCollision

      public static final int checkLineCircleCollision(double p1X, double p1Y, double p2X, double p2Y, double centerX, double centerY, double radius)
    • checkCollision

      public static final 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 centerX, double centerY)
    • getAngleFromXY

      public static final double getAngleFromXY(double x, double y, double centerX, double centerY, double angleOffset)
    • rotatePointAroundRotationCenter

      public static final double[] rotatePointAroundRotationCenter(double x, double y, double rX, double rY, double angleDeg)
    • rotateCtx

      public static final void rotateCtx(javafx.scene.canvas.GraphicsContext ctx, double x, double y, double angle)
    • getPointBetweenP1AndP2

      public static final Point getPointBetweenP1AndP2(Point p1, Point p2)
    • getPointBetweenP1AndP2

      public static final double[] getPointBetweenP1AndP2(double p1X, double p1Y, double p2X, double p2Y)
    • createConvexHull_OLD

      public static final <T extends Point> List<T> createConvexHull_OLD(List<T> points)
    • createConvexHull

      public static final List<Point> createConvexHull(List<Point> points)
    • createSmoothedConvexHull

      public static final List<Point> createSmoothedConvexHull(List<Point> points, int subDivisions)
    • reduceHull

      public static final List<Point> reduceHull(List<Point> points, List<Point> hullPoints)
    • removePointsOnConvexHull

      public static final List<Point> removePointsOnConvexHull(List<Point> points, List<Point> convexHull)
    • noOfDiagonalEdges

      public static final int noOfDiagonalEdges(List<Point> polygonPoints)
    • isHorizontal

      public static final boolean isHorizontal(Point p1, Point p2)
    • isVertical

      public static final boolean isVertical(Point p1, Point p2)
    • getPointsToCheck

      public static final List<Point> getPointsToCheck(List<Point> points, List<Point> hullCurvePoints)
      Check the given hull curve for diagonals and collect all points that are in the rectangle that will be defined by the two points of each diagonal. This points can then be used to reduce the convex hull curve of a polygon to a rectangular hull curve
      Parameters:
      points - points to check
      hullCurvePoints - points on hull curve
      Returns:
      list of points that can be used to reduce the diagonals in a convex hull curve
    • addPointsOnCurve

      public static final List<Point> addPointsOnCurve(List<Point> curvePoints, List<Point> points)
      Add points from given points to curvePoints if points are on the polygon defined by curvePoints
      Parameters:
      curvePoints - list of points on curve
      points - list of points to add
      Returns:
      list of points incl. the added ones
    • findGaps

      public static final List<Point> findGaps(List<Point> curvePoints, double width, double height, List<Point> points)
      Curve points should be ordered counterclockwise along the curve
      Parameters:
      curvePoints - points that define the curve sorted counterclockwise
      width - width of the box that will be checked for next point
      height - height of the box that will be checked for next point
      points - points to check
      Returns:
      list of point pairs that define the start and end points of gaps
    • getPointsXFromPoints

      public static final double[] getPointsXFromPoints(List<Point> points)
    • getPointsYFromPoints

      public static final double[] getPointsYFromPoints(List<Point> points)
    • getDoubleArrayFromPoints

      public static final double[] getDoubleArrayFromPoints(List<Point> points)
    • sortXY

      public static final void sortXY(List<Point> points)
    • sortByDistance

      public static final List<Point> sortByDistance(List<Point> points)
      Sort a list of points by it's distance from each other. The algorithm starts with the point closest to 0,0 and from there always adds the point closest to the last point
      Parameters:
      points - list of points to sort
      Returns:
      list of points sorted by it's distance from each other
    • sortByDistance

      public static final List<Point> sortByDistance(List<Point> points, boolean counterClockWise)
    • nearestPoint

      public static final int nearestPoint(Point p, List<Point> points)
    • padLeft

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

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

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

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

      public static final List<Point> removeDuplicatePoints(List<Point> points, double tolerance)
    • simplify

      public static final List<Point> simplify(List<Point> points, double angleTolerance, double minDistance)
    • bearing

      public static final double bearing(Point p1, Point p2)
    • bearing

      public static final double bearing(double x1, double y1, double x2, double y2)
    • getCardinalDirectionFromBearing

      public static final String getCardinalDirectionFromBearing(double brng)
    • toHSL

      public static final double[] toHSL(javafx.scene.paint.Color color)
    • rgbToHSL

      public static final double[] rgbToHSL(double red, double green, double blue)
    • hslToRGB

      public static final javafx.scene.paint.Color hslToRGB(double hue, double saturation, double luminance)
    • hslToRGB

      public static final javafx.scene.paint.Color hslToRGB(double hue, double saturation, double luminance, double opacity)
    • colorToRGB

      public static final String colorToRGB(javafx.scene.paint.Color color)
    • colorToRGBA

      public static final String colorToRGBA(javafx.scene.paint.Color color)
    • colorToRGBA

      public static final String colorToRGBA(javafx.scene.paint.Color color, double alpha)
    • colorToWeb

      public static final String colorToWeb(javafx.scene.paint.Color color)
    • colorToCss

      public static final String colorToCss(javafx.scene.paint.Color color)
    • isMonochrome

      public static final boolean isMonochrome(javafx.scene.paint.Color color)
    • colorDistance

      public static final double colorDistance(javafx.scene.paint.Color color1, javafx.scene.paint.Color color2)
    • colorToYUV

      public static final 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 fromColor, javafx.scene.paint.Color toColor, int noOfColors)
    • createColorVariations

      public static final javafx.scene.paint.Color[] createColorVariations(javafx.scene.paint.Color color, int newNoOfColors)
    • getColorAt

      public static final javafx.scene.paint.Color getColorAt(List<javafx.scene.paint.Stop> stopList, double positionOfColor)
    • interpolateColor

      public static final javafx.scene.paint.Color interpolateColor(javafx.scene.paint.Stop lowerBound, javafx.scene.paint.Stop upperBound, double position)
    • interpolateColor

      public static final javafx.scene.paint.Color interpolateColor(javafx.scene.paint.Color color1, javafx.scene.paint.Color color2, double fraction)
    • getColorAt

      public static final javafx.scene.paint.Color getColorAt(javafx.scene.paint.LinearGradient gradient, double fraction)
    • getColorWithOpacityAt

      public static final javafx.scene.paint.Color getColorWithOpacityAt(javafx.scene.paint.LinearGradient gradient, double fraction, double targetOpacity)
    • interpolateColor

      public static final javafx.scene.paint.Color interpolateColor(javafx.scene.paint.Color color1, javafx.scene.paint.Color color2, double fraction, double targetOpacity)
    • enableNode

      public static final void enableNode(javafx.scene.Node node, boolean enable)
    • scaleNodeTo

      public static final void scaleNodeTo(javafx.scene.Node node, double targetWidth, double targetHeight)
    • smoothSparkLine

      public static final Point[] smoothSparkLine(List<Double> dataList, double minValue, double maxValue, javafx.scene.shape.Rectangle graphBounds, int noOfDatapoints)
    • drawRoundedRect

      public static final void drawRoundedRect(javafx.scene.canvas.GraphicsContext ctx, Bounds bounds, CornerRadii radii)
    • getCubicBezierXYatT

      public static final Point getCubicBezierXYatT(Point startPoint, Point controlPoint1, Point controlPoint2, Point endPoint, double distance)
      Parameters:
      startPoint -
      controlPoint1 -
      controlPoint2 -
      endPoint -
      distance - in % (0-1)
      Returns:
    • getCubicBezierXYatT

      public static final double[] getCubicBezierXYatT(double startPointX, double startPointY, double controlPoint1X, double controlPoint1Y, double controlPoint2X, double controlPoint2Y, double endPointX, double endPointY, double distance)
    • smoothPath

      public static final javafx.scene.shape.Path smoothPath(javafx.collections.ObservableList<javafx.scene.shape.PathElement> elements, boolean filled)
    • isInPolygon

      public static final boolean isInPolygon(double x, double y, javafx.scene.shape.Polygon polygon)
    • getDegrees

      public static final int getDegrees(double decDeg)
    • getMinutes

      public static final int getMinutes(double decDeg)
    • getSeconds

      public static final double getSeconds(double decDeg)
    • getDecimalDeg

      public static final double getDecimalDeg(int degrees, int minutes, double seconds)
    • getNodeByColRow

      public static final javafx.scene.Node getNodeByColRow(int col, int row, javafx.scene.layout.GridPane gridPane)
    • createColorMask

      public static final javafx.scene.effect.ColorInput createColorMask(javafx.scene.image.Image sourceImage, javafx.scene.paint.Color color)
    • createColorBlend

      public static final javafx.scene.effect.Blend createColorBlend(javafx.scene.image.Image sourceImage, javafx.scene.paint.Color color)
    • getRedChannel

      public static final javafx.scene.image.WritableImage getRedChannel(javafx.scene.image.Image sourceImage)
    • getGreenChannel

      public static final javafx.scene.image.WritableImage getGreenChannel(javafx.scene.image.Image sourceImage)
    • getBlueChannel

      public static final javafx.scene.image.WritableImage getBlueChannel(javafx.scene.image.Image sourceImage)
    • getTextDimension

      public static final Dimension getTextDimension(String text, javafx.scene.text.Font font)
    • getZoneOffset

      public static final ZoneOffset getZoneOffset()
    • getZoneOffset

      public static final ZoneOffset getZoneOffset(ZoneId zoneId)
    • toMillis

      public static final long toMillis(LocalDateTime dateTime, ZoneOffset zoneOffset)
    • toSeconds

      public static final long toSeconds(LocalDateTime dateTime, ZoneOffset zoneOffset)
    • toNumericValue

      public static final double toNumericValue(LocalDateTime date)
    • toNumericValue

      public static final double toNumericValue(LocalDateTime date, ZoneId zoneId)
    • toRealValue

      public static final LocalDateTime toRealValue(double value)
    • toRealValue

      public static final LocalDateTime toRealValue(double value, ZoneId zoneId)
    • secondsToLocalDateTime

      public static final LocalDateTime secondsToLocalDateTime(long seconds)
    • secondsToLocalDateTime

      public static final LocalDateTime secondsToLocalDateTime(long seconds, ZoneId zoneId)
    • saveAsPng

      public static final void saveAsPng(javafx.scene.Node node, String fileName)
    • createNoiseImage

      public static final javafx.scene.image.Image createNoiseImage(double width, double height, javafx.scene.paint.Color darkColor, javafx.scene.paint.Color brightColor, double alphaVariationInPercent)