当前位置: 首页>>代码示例>>Java>>正文


Java ZoomType.HORIZONTAL_AND_VERTICAL属性代码示例

本文整理汇总了Java中lecho.lib.hellocharts.gesture.ZoomType.HORIZONTAL_AND_VERTICAL属性的典型用法代码示例。如果您正苦于以下问题:Java ZoomType.HORIZONTAL_AND_VERTICAL属性的具体用法?Java ZoomType.HORIZONTAL_AND_VERTICAL怎么用?Java ZoomType.HORIZONTAL_AND_VERTICAL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在lecho.lib.hellocharts.gesture.ZoomType的用法示例。


在下文中一共展示了ZoomType.HORIZONTAL_AND_VERTICAL属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: computeZoomViewport

private Viewport computeZoomViewport(float x, float y, float zoomLevel) {
    final Viewport maxViewport = getMaximumViewport();
    Viewport zoomViewport = new Viewport(getMaximumViewport());

    if (maxViewport.contains(x, y)) {

        if (zoomLevel < 1) {
            zoomLevel = 1;
        } else if (zoomLevel > getMaxZoom()) {
            zoomLevel = getMaxZoom();
        }

        final float newWidth = zoomViewport.width() / zoomLevel;
        final float newHeight = zoomViewport.height() / zoomLevel;

        final float halfWidth = newWidth / 2;
        final float halfHeight = newHeight / 2;

        float left = x - halfWidth;
        float right = x + halfWidth;
        float top = y + halfHeight;
        float bottom = y - halfHeight;

        if (left < maxViewport.left) {
            left = maxViewport.left;
            right = left + newWidth;
        } else if (right > maxViewport.right) {
            right = maxViewport.right;
            left = right - newWidth;
        }

        if (top > maxViewport.top) {
            top = maxViewport.top;
            bottom = top - newHeight;
        } else if (bottom < maxViewport.bottom) {
            bottom = maxViewport.bottom;
            top = bottom + newHeight;
        }

        ZoomType zoomType = getZoomType();
        if (ZoomType.HORIZONTAL_AND_VERTICAL == zoomType) {
            zoomViewport.set(left, top, right, bottom);
        } else if (ZoomType.HORIZONTAL == zoomType) {
            zoomViewport.left = left;
            zoomViewport.right = right;
        } else if (ZoomType.VERTICAL == zoomType) {
            zoomViewport.top = top;
            zoomViewport.bottom = bottom;
        }

    }
    return zoomViewport;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:53,代码来源:AbstractChartView.java

示例2: computeZoomViewport

private Viewport computeZoomViewport(float x, float y, float zoomLevel) {
    Viewport maxViewport = getMaximumViewport();
    Viewport zoomViewport = new Viewport(getMaximumViewport());
    if (maxViewport.contains(x, y)) {
        if (zoomLevel < 1.0f) {
            zoomLevel = 1.0f;
        } else if (zoomLevel > getMaxZoom()) {
            zoomLevel = getMaxZoom();
        }
        float newWidth = zoomViewport.width() / zoomLevel;
        float newHeight = zoomViewport.height() / zoomLevel;
        float halfWidth = newWidth / 2.0f;
        float halfHeight = newHeight / 2.0f;
        float left = x - halfWidth;
        float right = x + halfWidth;
        float top = y + halfHeight;
        float bottom = y - halfHeight;
        if (left < maxViewport.left) {
            left = maxViewport.left;
            right = left + newWidth;
        } else if (right > maxViewport.right) {
            right = maxViewport.right;
            left = right - newWidth;
        }
        if (top > maxViewport.top) {
            top = maxViewport.top;
            bottom = top - newHeight;
        } else if (bottom < maxViewport.bottom) {
            bottom = maxViewport.bottom;
            top = bottom + newHeight;
        }
        ZoomType zoomType = getZoomType();
        if (ZoomType.HORIZONTAL_AND_VERTICAL == zoomType) {
            zoomViewport.set(left, top, right, bottom);
        } else if (ZoomType.HORIZONTAL == zoomType) {
            zoomViewport.left = left;
            zoomViewport.right = right;
        } else if (ZoomType.VERTICAL == zoomType) {
            zoomViewport.top = top;
            zoomViewport.bottom = bottom;
        }
    }
    return zoomViewport;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:44,代码来源:AbstractChartView.java


注:本文中的lecho.lib.hellocharts.gesture.ZoomType.HORIZONTAL_AND_VERTICAL属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。