本文整理汇总了Java中lecho.lib.hellocharts.model.Viewport.height方法的典型用法代码示例。如果您正苦于以下问题:Java Viewport.height方法的具体用法?Java Viewport.height怎么用?Java Viewport.height使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lecho.lib.hellocharts.model.Viewport
的用法示例。
在下文中一共展示了Viewport.height方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: computeScrollOffset
import lecho.lib.hellocharts.model.Viewport; //导入方法依赖的package包/类
public boolean computeScrollOffset(ChartComputator computator) {
if (scroller.computeScrollOffset()) {
// The scroller isn't finished, meaning a fling or programmatic pan operation is
// currently active.
final Viewport maxViewport = computator.getMaximumViewport();
computator.computeScrollSurfaceSize(surfaceSizeBuffer);
final float currXRange = maxViewport.left + maxViewport.width() * scroller.getCurrX() /
surfaceSizeBuffer.x;
final float currYRange = maxViewport.top - maxViewport.height() * scroller.getCurrY() /
surfaceSizeBuffer.y;
computator.setViewportTopLeft(currXRange, currYRange);
return true;
}
return false;
}
示例3: onCreateView
import lecho.lib.hellocharts.model.Viewport; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_good_bad, container, false);
chart = (LineChartView) rootView.findViewById(R.id.chart);
generateDefaultData();
chart.setLineChartData(data);
// Increase viewport height for better look
Viewport v = chart.getMaximumViewport();
float dy = v.height() * 0.2f;
v.inset(0, -dy);
chart.setMaximumViewport(v);
chart.setCurrentViewport(v);
return rootView;
}
示例4: previewY
import lecho.lib.hellocharts.model.Viewport; //导入方法依赖的package包/类
private void previewY() {
Viewport tempViewport = new Viewport(chart.getMaximumViewport());
float dy = tempViewport.height() / 4;
tempViewport.inset(0, dy);
previewChart.setCurrentViewportWithAnimation(tempViewport);
previewChart.setZoomType(ZoomType.VERTICAL);
}
示例5: previewXY
import lecho.lib.hellocharts.model.Viewport; //导入方法依赖的package包/类
private void previewXY() {
// Better to not modify viewport of any chart directly so create a copy.
Viewport tempViewport = new Viewport(chart.getMaximumViewport());
// Make temp viewport smaller.
float dx = tempViewport.width() / 4;
float dy = tempViewport.height() / 4;
tempViewport.inset(dx, dy);
previewChart.setCurrentViewportWithAnimation(tempViewport);
}
示例6: 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;
}
示例7: 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;
}
示例8: prepareCustomAxis
import lecho.lib.hellocharts.model.Viewport; //导入方法依赖的package包/类
private void prepareCustomAxis(Axis axis, int position) {
final Viewport maxViewport = computator.getMaximumViewport();
final Viewport visibleViewport = computator.getVisibleViewport();
final Rect contentRect = computator.getContentRectMinusAllMargins();
boolean isAxisVertical = isAxisVertical(position);
float viewportMin, viewportMax;
float scale = 1;
if (isAxisVertical) {
if (maxViewport.height() > 0 && visibleViewport.height() > 0) {
scale = contentRect.height() * (maxViewport.height() / visibleViewport.height());
}
viewportMin = visibleViewport.bottom;
viewportMax = visibleViewport.top;
} else {
if (maxViewport.width() > 0 && visibleViewport.width() > 0) {
scale = contentRect.width() * (maxViewport.width() / visibleViewport.width());
}
viewportMin = visibleViewport.left;
viewportMax = visibleViewport.right;
}
if (scale == 0) {
scale = 1;
}
int module = (int) Math.max(1,
Math.ceil((axis.getValues().size() * labelDimensionForStepsTab[position] * 1.5) / scale));
//Reinitialize tab to hold lines coordinates.
if (axis.hasLines() && (linesDrawBufferTab[position].length < axis.getValues().size() * 4)) {
linesDrawBufferTab[position] = new float[axis.getValues().size() * 4];
}
//Reinitialize tabs to hold all raw values to draw.
if (rawValuesTab[position].length < axis.getValues().size()) {
rawValuesTab[position] = new float[axis.getValues().size()];
}
//Reinitialize tabs to hold all raw values to draw.
if (valuesToDrawTab[position].length < axis.getValues().size()) {
valuesToDrawTab[position] = new AxisValue[axis.getValues().size()];
}
float rawValue;
int valueIndex = 0;
int valueToDrawIndex = 0;
for (AxisValue axisValue : axis.getValues()) {
// Draw axis values that are within visible viewport.
final float value = axisValue.getValue();
if (value >= viewportMin && value <= viewportMax) {
// Draw axis values that have 0 module value, this will hide some labels if there is no place for them.
if (0 == valueIndex % module) {
if (isAxisVertical) {
rawValue = computator.computeRawY(value);
} else {
rawValue = computator.computeRawX(value);
}
if (checkRawValue(contentRect, rawValue, axis.isInside(), position, isAxisVertical)) {
rawValuesTab[position][valueToDrawIndex] = rawValue;
valuesToDrawTab[position][valueToDrawIndex] = axisValue;
++valueToDrawIndex;
}
}
// If within viewport - increment valueIndex;
++valueIndex;
}
}
valuesToDrawNumTab[position] = valueToDrawIndex;
}
示例9: scroll
import lecho.lib.hellocharts.model.Viewport; //导入方法依赖的package包/类
public boolean scroll(ChartComputator computator, float distanceX, float distanceY, ScrollResult scrollResult) {
// Scrolling uses math based on the viewport (as opposed to math using pixels). Pixel offset is the offset in
// screen pixels, while viewport offset is the offset within the current viewport. For additional
// information on
// surface sizes and pixel offsets, see the docs for {@link computeScrollSurfaceSize()}. For additional
// information about the viewport, see the comments for {@link mCurrentViewport}.
final Viewport maxViewport = computator.getMaximumViewport();
final Viewport visibleViewport = computator.getVisibleViewport();
final Viewport currentViewport = computator.getCurrentViewport();
final Rect contentRect = computator.getContentRectMinusAllMargins();
final boolean canScrollLeft = currentViewport.left > maxViewport.left;
final boolean canScrollRight = currentViewport.right < maxViewport.right;
final boolean canScrollTop = currentViewport.top < maxViewport.top;
final boolean canScrollBottom = currentViewport.bottom > maxViewport.bottom;
boolean canScrollX = false;
boolean canScrollY = false;
if (canScrollLeft && distanceX <= 0) {
canScrollX = true;
} else if (canScrollRight && distanceX >= 0) {
canScrollX = true;
}
if (canScrollTop && distanceY <= 0) {
canScrollY = true;
} else if (canScrollBottom && distanceY >= 0) {
canScrollY = true;
}
if (canScrollX || canScrollY) {
computator.computeScrollSurfaceSize(surfaceSizeBuffer);
float viewportOffsetX = distanceX * visibleViewport.width() / contentRect.width();
float viewportOffsetY = -distanceY * visibleViewport.height() / contentRect.height();
computator
.setViewportTopLeft(currentViewport.left + viewportOffsetX, currentViewport.top + viewportOffsetY);
}
scrollResult.canScrollX = canScrollX;
scrollResult.canScrollY = canScrollY;
return canScrollX || canScrollY;
}
示例10: 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;
}
示例11: prepareCustomAxis
import lecho.lib.hellocharts.model.Viewport; //导入方法依赖的package包/类
private void prepareCustomAxis(Axis axis, int position) {
float viewportMin;
Viewport maxViewport = this.computator.getMaximumViewport();
Viewport visibleViewport = this.computator.getVisibleViewport();
Rect contentRect = this.computator.getContentRectMinusAllMargins();
boolean isAxisVertical = isAxisVertical(position);
float scale = 1.0f;
float viewportMax;
if (isAxisVertical) {
if (maxViewport.height() > 0.0f && visibleViewport.height() > 0.0f) {
scale = ((float) contentRect.height()) * (maxViewport.height() / visibleViewport.height());
}
viewportMin = visibleViewport.bottom;
viewportMax = visibleViewport.top;
} else {
if (maxViewport.width() > 0.0f && visibleViewport.width() > 0.0f) {
scale = ((float) contentRect.width()) * (maxViewport.width() / visibleViewport.width());
}
viewportMin = visibleViewport.left;
viewportMax = visibleViewport.right;
}
if (scale == 0.0f) {
scale = 1.0f;
}
int module = (int) Math.max(PathListView.NO_ZOOM, Math.ceil((((double) (axis.getValues().size() * this.labelDimensionForStepsTab[position])) * 1.5d) / ((double) scale)));
if (axis.hasLines() && this.linesDrawBufferTab[position].length < axis.getValues().size() * 4) {
this.linesDrawBufferTab[position] = new float[(axis.getValues().size() * 4)];
}
if (this.rawValuesTab[position].length < axis.getValues().size()) {
this.rawValuesTab[position] = new float[axis.getValues().size()];
}
if (this.valuesToDrawTab[position].length < axis.getValues().size()) {
this.valuesToDrawTab[position] = new AxisValue[axis.getValues().size()];
}
int valueIndex = 0;
int valueToDrawIndex = 0;
for (AxisValue axisValue : axis.getValues()) {
float value = axisValue.getValue();
if (value >= viewportMin && value <= viewportMax) {
if (valueIndex % module == 0) {
float rawValue;
if (isAxisVertical) {
rawValue = this.computator.computeRawY(value);
} else {
rawValue = this.computator.computeRawX(value);
}
if (checkRawValue(contentRect, rawValue, axis.isInside(), position, isAxisVertical)) {
this.rawValuesTab[position][valueToDrawIndex] = rawValue;
this.valuesToDrawTab[position][valueToDrawIndex] = axisValue;
valueToDrawIndex++;
}
}
valueIndex++;
}
}
this.valuesToDrawNumTab[position] = valueToDrawIndex;
}