本文整理汇总了Java中lecho.lib.hellocharts.model.Viewport.set方法的典型用法代码示例。如果您正苦于以下问题:Java Viewport.set方法的具体用法?Java Viewport.set怎么用?Java Viewport.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lecho.lib.hellocharts.model.Viewport
的用法示例。
在下文中一共展示了Viewport.set方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeScrollViewport
import lecho.lib.hellocharts.model.Viewport; //导入方法依赖的package包/类
private Viewport computeScrollViewport(float x, float y) {
Viewport maxViewport = getMaximumViewport();
Viewport currentViewport = getCurrentViewport();
Viewport scrollViewport = new Viewport(currentViewport);
if (maxViewport.contains(x, y)) {
final float width = currentViewport.width();
final float height = currentViewport.height();
final float halfWidth = width / 2;
final float halfHeight = height / 2;
float left = x - halfWidth;
float top = y + halfHeight;
left = Math.max(maxViewport.left, Math.min(left, maxViewport.right - width));
top = Math.max(maxViewport.bottom + height, Math.min(top, maxViewport.top));
scrollViewport.set(left, top, left + width, top - height);
}
return scrollViewport;
}
示例2: computeScrollViewport
import lecho.lib.hellocharts.model.Viewport; //导入方法依赖的package包/类
private Viewport computeScrollViewport(float x, float y) {
Viewport maxViewport = getMaximumViewport();
Viewport currentViewport = getCurrentViewport();
Viewport scrollViewport = new Viewport(currentViewport);
if (maxViewport.contains(x, y)) {
float width = currentViewport.width();
float height = currentViewport.height();
float top = y + (height / 2.0f);
float left = Math.max(maxViewport.left, Math.min(x - (width / 2.0f), maxViewport.right - width));
top = Math.max(maxViewport.bottom + height, Math.min(top, maxViewport.top));
scrollViewport.set(left, top, left + height, top - height);
}
return scrollViewport;
}
示例3: computeZoomViewport
import lecho.lib.hellocharts.model.Viewport; //导入方法依赖的package包/类
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;
}
示例4: computeZoomViewport
import lecho.lib.hellocharts.model.Viewport; //导入方法依赖的package包/类
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;
}