程序包 dev.utils.common

类 ScaleUtils


  • public final class ScaleUtils
    extends java.lang.Object
    detail: 计算比例工具类
    作者:
    Ttt
    • 嵌套类概要

      嵌套类 
      修饰符和类型 说明
      static class  ScaleUtils.XY
      detail: XY 比实体类
    • 方法概要

      所有方法 静态方法 具体方法 
      修饰符和类型 方法 说明
      static double[] calcHeightToScale​(double height, double widthScale, double heightScale)
      以高度为基准, 转换对应比例的宽度
      static float[] calcHeightToScaleF​(double height, double widthScale, double heightScale)
      以高度为基准, 转换对应比例的宽度
      static int[] calcHeightToScaleI​(double height, double widthScale, double heightScale)
      以高度为基准, 转换对应比例的宽度
      static long[] calcHeightToScaleL​(double height, double widthScale, double heightScale)
      以高度为基准, 转换对应比例的宽度
      static double calcScale​(double dividend, double divisor)
      计算比例 ( 商 )
      static double[] calcScaleToHeight​(double targetHeight, double currentWidth, double currentHeight)
      计算缩放比例 ( 根据高度比例转换宽度 )
      static float[] calcScaleToHeightF​(double targetHeight, double currentWidth, double currentHeight)
      计算缩放比例 ( 根据高度比例转换宽度 )
      static int[] calcScaleToHeightI​(double targetHeight, double currentWidth, double currentHeight)
      计算缩放比例 ( 根据高度比例转换宽度 )
      static long[] calcScaleToHeightL​(double targetHeight, double currentWidth, double currentHeight)
      计算缩放比例 ( 根据高度比例转换宽度 )
      static double calcScaleToMath​(double value1, double value2)
      计算比例 ( 被除数 ( 最大值 ) / 除数 ( 最小值 ) )
      static double[] calcScaleToWidth​(double targetWidth, double currentWidth, double currentHeight)
      计算缩放比例 ( 根据宽度比例转换高度 )
      static float[] calcScaleToWidthF​(double targetWidth, double currentWidth, double currentHeight)
      计算缩放比例 ( 根据宽度比例转换高度 )
      static int[] calcScaleToWidthI​(double targetWidth, double currentWidth, double currentHeight)
      计算缩放比例 ( 根据宽度比例转换高度 )
      static long[] calcScaleToWidthL​(double targetWidth, double currentWidth, double currentHeight)
      计算缩放比例 ( 根据宽度比例转换高度 )
      static double[] calcWidthHeightToScale​(double width, double height, double widthScale, double heightScale)
      通过宽度、高度根据对应的比例, 转换成对应的比例宽度高度 ( 智能转换 )
      static float[] calcWidthHeightToScaleF​(double width, double height, double widthScale, double heightScale)
      通过宽度、高度根据对应的比例, 转换成对应的比例宽度高度 ( 智能转换 )
      static int[] calcWidthHeightToScaleI​(double width, double height, double widthScale, double heightScale)
      通过宽度、高度根据对应的比例, 转换成对应的比例宽度高度 ( 智能转换 )
      static long[] calcWidthHeightToScaleL​(double width, double height, double widthScale, double heightScale)
      通过宽度、高度根据对应的比例, 转换成对应的比例宽度高度 ( 智能转换 )
      static double[] calcWidthToScale​(double width, double widthScale, double heightScale)
      以宽度为基准, 转换对应比例的高度
      static float[] calcWidthToScaleF​(double width, double widthScale, double heightScale)
      以宽度为基准, 转换对应比例的高度
      static int[] calcWidthToScaleI​(double width, double widthScale, double heightScale)
      以宽度为基准, 转换对应比例的高度
      static long[] calcWidthToScaleL​(double width, double widthScale, double heightScale)
      以宽度为基准, 转换对应比例的高度
      static ScaleUtils.XY calcXY​(int x, int y)
      计算 XY 比
      static ScaleUtils.XY calcXY​(java.util.List<ScaleUtils.XY> xyLists, int x, int y)
      计算 XY 比
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 字段详细资料

      • XY_LIST

        public static final java.util.List<ScaleUtils.XY> XY_LIST
    • 方法详细资料

      • calcScale

        public static double calcScale​(double dividend,
                                       double divisor)
        计算比例 ( 商 )
        参数:
        dividend - 被除数
        divisor - 除数
        返回:
      • calcScaleToMath

        public static double calcScaleToMath​(double value1,
                                             double value2)
        计算比例 ( 被除数 ( 最大值 ) / 除数 ( 最小值 ) )
        参数:
        value1 - 第一个值
        value2 - 第二个值
        返回:
        被除数 ( 最大值 ) / 除数 ( 最小值 ) = 商
      • calcScaleToWidth

        public static double[] calcScaleToWidth​(double targetWidth,
                                                double currentWidth,
                                                double currentHeight)
        计算缩放比例 ( 根据宽度比例转换高度 )
        参数:
        targetWidth - 需要的最终宽度
        currentWidth - 当前宽度
        currentHeight - 当前高度
        返回:
        double[] { 宽度, 高度 }
      • calcScaleToHeight

        public static double[] calcScaleToHeight​(double targetHeight,
                                                 double currentWidth,
                                                 double currentHeight)
        计算缩放比例 ( 根据高度比例转换宽度 )
        参数:
        targetHeight - 需要的最终高度
        currentWidth - 当前宽度
        currentHeight - 当前高度
        返回:
        double[] { 宽度, 高度 }
      • calcWidthHeightToScale

        public static double[] calcWidthHeightToScale​(double width,
                                                      double height,
                                                      double widthScale,
                                                      double heightScale)
        通过宽度、高度根据对应的比例, 转换成对应的比例宽度高度 ( 智能转换 )
        参数:
        width - 宽度
        height - 高度
        widthScale - 宽度比例
        heightScale - 高度比例
        返回:
        double[] { 宽度, 高度 }
      • calcWidthToScale

        public static double[] calcWidthToScale​(double width,
                                                double widthScale,
                                                double heightScale)
        以宽度为基准, 转换对应比例的高度
        参数:
        width - 宽度
        widthScale - 宽度比例
        heightScale - 高度比例
        返回:
        double[] { 宽度, 高度 }
      • calcHeightToScale

        public static double[] calcHeightToScale​(double height,
                                                 double widthScale,
                                                 double heightScale)
        以高度为基准, 转换对应比例的宽度
        参数:
        height - 高度
        widthScale - 宽度比例
        heightScale - 高度比例
        返回:
        double[] { 宽度, 高度 }
      • calcScaleToWidthI

        public static int[] calcScaleToWidthI​(double targetWidth,
                                              double currentWidth,
                                              double currentHeight)
        计算缩放比例 ( 根据宽度比例转换高度 )
        参数:
        targetWidth - 需要的最终宽度
        currentWidth - 当前宽度
        currentHeight - 当前高度
        返回:
        int[] { 宽度, 高度 }
      • calcScaleToHeightI

        public static int[] calcScaleToHeightI​(double targetHeight,
                                               double currentWidth,
                                               double currentHeight)
        计算缩放比例 ( 根据高度比例转换宽度 )
        参数:
        targetHeight - 需要的最终高度
        currentWidth - 当前宽度
        currentHeight - 当前高度
        返回:
        int[] { 宽度, 高度 }
      • calcWidthHeightToScaleI

        public static int[] calcWidthHeightToScaleI​(double width,
                                                    double height,
                                                    double widthScale,
                                                    double heightScale)
        通过宽度、高度根据对应的比例, 转换成对应的比例宽度高度 ( 智能转换 )
        参数:
        width - 宽度
        height - 高度
        widthScale - 宽度比例
        heightScale - 高度比例
        返回:
        int[] { 宽度, 高度 }
      • calcWidthToScaleI

        public static int[] calcWidthToScaleI​(double width,
                                              double widthScale,
                                              double heightScale)
        以宽度为基准, 转换对应比例的高度
        参数:
        width - 宽度
        widthScale - 宽度比例
        heightScale - 高度比例
        返回:
        int[] { 宽度, 高度 }
      • calcHeightToScaleI

        public static int[] calcHeightToScaleI​(double height,
                                               double widthScale,
                                               double heightScale)
        以高度为基准, 转换对应比例的宽度
        参数:
        height - 高度
        widthScale - 宽度比例
        heightScale - 高度比例
        返回:
        int[] { 宽度, 高度 }
      • calcScaleToWidthL

        public static long[] calcScaleToWidthL​(double targetWidth,
                                               double currentWidth,
                                               double currentHeight)
        计算缩放比例 ( 根据宽度比例转换高度 )
        参数:
        targetWidth - 需要的最终宽度
        currentWidth - 当前宽度
        currentHeight - 当前高度
        返回:
        long[] { 宽度, 高度 }
      • calcScaleToHeightL

        public static long[] calcScaleToHeightL​(double targetHeight,
                                                double currentWidth,
                                                double currentHeight)
        计算缩放比例 ( 根据高度比例转换宽度 )
        参数:
        targetHeight - 需要的最终高度
        currentWidth - 当前宽度
        currentHeight - 当前高度
        返回:
        long[] { 宽度, 高度 }
      • calcWidthHeightToScaleL

        public static long[] calcWidthHeightToScaleL​(double width,
                                                     double height,
                                                     double widthScale,
                                                     double heightScale)
        通过宽度、高度根据对应的比例, 转换成对应的比例宽度高度 ( 智能转换 )
        参数:
        width - 宽度
        height - 高度
        widthScale - 宽度比例
        heightScale - 高度比例
        返回:
        long[] { 宽度, 高度 }
      • calcWidthToScaleL

        public static long[] calcWidthToScaleL​(double width,
                                               double widthScale,
                                               double heightScale)
        以宽度为基准, 转换对应比例的高度
        参数:
        width - 宽度
        widthScale - 宽度比例
        heightScale - 高度比例
        返回:
        long[] { 宽度, 高度 }
      • calcHeightToScaleL

        public static long[] calcHeightToScaleL​(double height,
                                                double widthScale,
                                                double heightScale)
        以高度为基准, 转换对应比例的宽度
        参数:
        height - 高度
        widthScale - 宽度比例
        heightScale - 高度比例
        返回:
        long[] { 宽度, 高度 }
      • calcScaleToWidthF

        public static float[] calcScaleToWidthF​(double targetWidth,
                                                double currentWidth,
                                                double currentHeight)
        计算缩放比例 ( 根据宽度比例转换高度 )
        参数:
        targetWidth - 需要的最终宽度
        currentWidth - 当前宽度
        currentHeight - 当前高度
        返回:
        float[] { 宽度, 高度 }
      • calcScaleToHeightF

        public static float[] calcScaleToHeightF​(double targetHeight,
                                                 double currentWidth,
                                                 double currentHeight)
        计算缩放比例 ( 根据高度比例转换宽度 )
        参数:
        targetHeight - 需要的最终高度
        currentWidth - 当前宽度
        currentHeight - 当前高度
        返回:
        float[] { 宽度, 高度 }
      • calcWidthHeightToScaleF

        public static float[] calcWidthHeightToScaleF​(double width,
                                                      double height,
                                                      double widthScale,
                                                      double heightScale)
        通过宽度、高度根据对应的比例, 转换成对应的比例宽度高度 ( 智能转换 )
        参数:
        width - 宽度
        height - 高度
        widthScale - 宽度比例
        heightScale - 高度比例
        返回:
        float[] { 宽度, 高度 }
      • calcWidthToScaleF

        public static float[] calcWidthToScaleF​(double width,
                                                double widthScale,
                                                double heightScale)
        以宽度为基准, 转换对应比例的高度
        参数:
        width - 宽度
        widthScale - 宽度比例
        heightScale - 高度比例
        返回:
        float[] { 宽度, 高度 }
      • calcHeightToScaleF

        public static float[] calcHeightToScaleF​(double height,
                                                 double widthScale,
                                                 double heightScale)
        以高度为基准, 转换对应比例的宽度
        参数:
        height - 高度
        widthScale - 宽度比例
        heightScale - 高度比例
        返回:
        float[] { 宽度, 高度 }
      • calcXY

        public static ScaleUtils.XY calcXY​(int x,
                                           int y)
        计算 XY 比
        参数:
        x - X 值
        y - Y 值
        返回:
        XY 比实体类
      • calcXY

        public static ScaleUtils.XY calcXY​(java.util.List<ScaleUtils.XY> xyLists,
                                           int x,
                                           int y)
        计算 XY 比
        参数:
        xyLists - XY 比集合
        x - X 值
        y - Y 值
        返回:
        XY 比实体类