本文整理汇总了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;
}
示例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;
}