程序包 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[] calcHeightToScale​(float height, float widthScale, float heightScale)
      以高度为基准, 转换对应比例的宽度
      static int[] calcHeightToScale​(int height, float widthScale, float heightScale)
      以高度为基准, 转换对应比例的宽度
      static long[] calcHeightToScale​(long height, long widthScale, long heightScale)
      以高度为基准, 转换对应比例的宽度
      static double calcScale​(double dividend, double divisor)
      计算比例 ( 商 )
      static double[] calcScaleToHeight​(double targetHeight, double currentWidth, double currentHeight)
      计算缩放比例 ( 根据高度比例转换宽度 )
      static float[] calcScaleToHeight​(float targetHeight, float currentWidth, float currentHeight)
      计算缩放比例 ( 根据高度比例转换宽度 )
      static int[] calcScaleToHeight​(int targetHeight, int currentWidth, int currentHeight)
      计算缩放比例 ( 根据高度比例转换宽度 )
      static long[] calcScaleToHeight​(long targetHeight, long currentWidth, long currentHeight)
      计算缩放比例 ( 根据高度比例转换宽度 )
      static double calcScaleToMath​(double value1, double value2)
      计算比例 ( 被除数 ( 最大值 ) / 除数 ( 最小值 ) )
      static double[] calcScaleToWidth​(double targetWidth, double currentWidth, double currentHeight)
      计算缩放比例 ( 根据宽度比例转换高度 )
      static float[] calcScaleToWidth​(float targetWidth, float currentWidth, float currentHeight)
      计算缩放比例 ( 根据宽度比例转换高度 )
      static int[] calcScaleToWidth​(int targetWidth, int currentWidth, int currentHeight)
      计算缩放比例 ( 根据宽度比例转换高度 )
      static long[] calcScaleToWidth​(long targetWidth, long currentWidth, long currentHeight)
      计算缩放比例 ( 根据宽度比例转换高度 )
      static double[] calcWidthHeightToScale​(double width, double height, double widthScale, double heightScale)
      通过宽度、高度根据对应的比例, 转换成对应的比例宽度高度 ( 智能转换 )
      static float[] calcWidthHeightToScale​(float width, float height, float widthScale, float heightScale)
      通过宽度、高度根据对应的比例, 转换成对应的比例宽度高度 ( 智能转换 )
      static int[] calcWidthHeightToScale​(int width, int height, float widthScale, float heightScale)
      通过宽度、高度根据对应的比例, 转换成对应的比例宽度高度 ( 智能转换 )
      static long[] calcWidthHeightToScale​(long width, long height, long widthScale, long heightScale)
      通过宽度、高度根据对应的比例, 转换成对应的比例宽度高度 ( 智能转换 )
      static double[] calcWidthToScale​(double width, double widthScale, double heightScale)
      以宽度为基准, 转换对应比例的高度
      static float[] calcWidthToScale​(float width, float widthScale, float heightScale)
      以宽度为基准, 转换对应比例的高度
      static int[] calcWidthToScale​(int width, float widthScale, float heightScale)
      以宽度为基准, 转换对应比例的高度
      static long[] calcWidthToScale​(long width, long widthScale, long 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 int[] calcScaleToWidth​(int targetWidth,
                                             int currentWidth,
                                             int currentHeight)
        计算缩放比例 ( 根据宽度比例转换高度 )
        参数:
        targetWidth - 需要的最终宽度
        currentWidth - 当前宽度
        currentHeight - 当前高度
        返回:
        int[] { 宽度, 高度 }
      • calcScaleToHeight

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

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

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

        public static int[] calcHeightToScale​(int height,
                                              float widthScale,
                                              float heightScale)
        以高度为基准, 转换对应比例的宽度
        参数:
        height - 高度
        widthScale - 宽度比例
        heightScale - 高度比例
        返回:
        int[] { 宽度, 高度 }
      • 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[] { 宽度, 高度 }
      • calcScaleToWidth

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

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

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

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

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

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

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

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

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

        public static float[] calcHeightToScale​(float height,
                                                float widthScale,
                                                float 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 比实体类