Class Utils

java.lang.Object
org.apache.pdfbox.jbig2.util.Utils

public class Utils extends Object
  • Field Details

  • Constructor Details

    • Utils

      public Utils()
  • Method Details

    • enlargeRectToGrid

      public static Rectangle enlargeRectToGrid(Rectangle2D r)
      Create a rectangle with the same area as the given input rectangle but with all of its edges snapped (rounded) to the integer grid. The resulting rectangle is guaranteed to cover all of the input rectangle's area, so that enlargeToGrid(r).contains(r) == true holds. This can be depicted as the edges being stretched in an outward direction.
      Parameters:
      r - the given rectangle
      Returns:
      the resulting rectangle
    • dilateRect

      public static Rectangle2D dilateRect(Rectangle2D r, double marginX, double marginY)
      Return a new rectangle which covers the area of the given rectangle with an additional margin on the sides.
      Parameters:
      r - the given rectangle
      marginX - horizontal value of the additional margin
      marginY - vertical value of the additional margin
      Returns:
      the resulting rectangle
    • clamp

      public static double clamp(double value, double min, double max)
      Clamp the value into the range [min..max].
      Parameters:
      value - input value
      min - minimal value
      max - maximal value
      Returns:
      the clamped value
    • floor

      public static int floor(double x)
      A fast implementation of Math.floor(double).
      Parameters:
      x - the argument
      Returns:
      resulting floor value
    • round

      public static int round(double x)
      A fast implementation of Math.round(double).
      Parameters:
      x - the argument
      Returns:
      rounded value
    • ceil

      public static int ceil(double x)
      A fast implementation of Math.ceil(double).
      Parameters:
      x - the argument
      Returns:
      resulting ceil value