本文整理汇总了Java中lecho.lib.hellocharts.model.Viewport类的典型用法代码示例。如果您正苦于以下问题:Java Viewport类的具体用法?Java Viewport怎么用?Java Viewport使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Viewport类属于lecho.lib.hellocharts.model包,在下文中一共展示了Viewport类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: drawTargetCaloryLine
import lecho.lib.hellocharts.model.Viewport; //导入依赖的package包/类
public void drawTargetCaloryLine(Canvas drawCanvas) {
if (this.targetCalory > 0) {
float currentLeft = 0.0f;
float currentRight = 0.0f;
int target = this.targetCalory;
Viewport currentViewport = this.computator.getCurrentViewport();
if (currentViewport != null) {
currentLeft = currentViewport.left;
currentRight = currentViewport.right;
}
float rawX1 = this.computator.computeRawX(currentLeft);
float rawX2 = this.computator.computeRawX(currentRight);
float y = this.computator.computeRawY((float) target);
Path path1 = new Path();
path1.moveTo(rawX1, y);
path1.lineTo(rawX2, y);
drawCanvas.drawPath(path1, this.caloryLinePaint);
}
}
示例4: 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;
}
示例5: setViewport
import lecho.lib.hellocharts.model.Viewport; //导入依赖的package包/类
private void setViewport() {
int axisSize = this.axisValues.size();
if (this.viewportLeft == 0.0f && this.viewportRight == 0.0f) {
if (axisSize < 9) {
this.viewportLeft = -1.0f;
this.viewportRight = 8.0f;
} else {
this.viewportLeft = (float) (axisSize - 9);
this.viewportRight = (float) axisSize;
}
}
Viewport v_max = new Viewport(-1.0f, this.max, (float) this.axisValues.size(), this.min);
Viewport v_current = new Viewport(this.viewportLeft, this.max, this.viewportRight - 0.2f,
this.min);
this.chartView.setMaximumViewport(v_max);
this.chartView.setCurrentViewport(v_current);
}
示例6: setViewport
import lecho.lib.hellocharts.model.Viewport; //导入依赖的package包/类
private void setViewport(int dataSize) {
final Viewport maxViewPort = chart.getMaximumViewport();
final Viewport chartViewPort = new Viewport(maxViewPort);
if (dataSize > 2) {
chartViewPort.bottom = maxViewPort.bottom - 0.03f * maxViewPort.bottom;
chartViewPort.top = 1.03f * maxViewPort.top;
chartViewPort.right = 1.01f * maxViewPort.right;
chart.setMaximumViewport(chartViewPort);
chart.setCurrentViewport(chartViewPort);
} else {
chartViewPort.bottom = maxViewPort.bottom - 2f;
chartViewPort.top = maxViewPort.top + 2;
chartViewPort.right = maxViewPort.right + 2;
chartViewPort.left = maxViewPort.left - 2;
chart.setMaximumViewport(chartViewPort);
chart.setCurrentViewport(chartViewPort);
previewChart.setMaximumViewport(chartViewPort);
previewChart.setCurrentViewport(chartViewPort);
}
}
示例7: drawTargetCaloryText
import lecho.lib.hellocharts.model.Viewport; //导入依赖的package包/类
public void drawTargetCaloryText(Canvas drawCanvas) {
if (this.targetCalory > 0) {
float currentLeft = 0.0f;
Viewport currentViewport = this.computator.getCurrentViewport();
if (currentViewport != null) {
currentLeft = currentViewport.left;
}
float rawX1 = this.computator.computeRawX(currentLeft);
float y = this.computator.computeRawY((float) this.targetCalory);
String targetStr = String.valueOf(this.targetCalory);
float textWidth = this.caloryTextPaint.measureText(targetStr);
float textX = (rawX1 - textWidth) - ((float) ChartUtils.dp2px(this.density, 2));
float textY = y + (getTextHeight() / aj.hA);
RectF rect = new RectF(textX, y - (getTextHeight() / 2.0f), textX + textWidth, (getTextHeight() / 2.0f) + y);
this.caloryTextPaint.setColor(ChartUtils.COLOR_BACKGROUND);
drawCanvas.drawRoundRect(rect, 5.0f, 5.0f, this.caloryTextPaint);
if (this.targetCaloryTextColor != 0) {
this.caloryTextPaint.setColor(this.targetCaloryTextColor);
} else {
this.caloryTextPaint.setColor(ChartUtils.DEFAULT_TARGET_COLOR);
}
drawCanvas.drawText(targetStr, textX, textY, this.caloryTextPaint);
}
}
示例8: removeMargins
import lecho.lib.hellocharts.model.Viewport; //导入依赖的package包/类
public void removeMargins() {
Rect contentRect = this.computator.getContentRectMinusAllMargins();
if (contentRect.height() != 0 && contentRect.width() != 0) {
float pxX = this.computator.computeRawDistanceX(this.maxRadius * this.bubbleScaleX);
float pxY = this.computator.computeRawDistanceY(this.maxRadius * this.bubbleScaleY);
float scaleX = this.computator.getMaximumViewport().width() / ((float) contentRect.width());
float scaleY = this.computator.getMaximumViewport().height() / ((float) contentRect.height());
float dx = 0.0f;
float dy = 0.0f;
if (this.isBubbleScaledByX) {
dy = ((pxY - pxX) * scaleY) * ColumnChartData.DEFAULT_FILL_RATIO;
} else {
dx = ((pxX - pxY) * scaleX) * ColumnChartData.DEFAULT_FILL_RATIO;
}
Viewport maxViewport = this.computator.getMaximumViewport();
maxViewport.inset(dx, dy);
Viewport currentViewport = this.computator.getCurrentViewport();
currentViewport.inset(dx, dy);
this.computator.setMaxViewport(maxViewport);
this.computator.setCurrentViewport(currentViewport);
}
}
示例9: startAnimation
import lecho.lib.hellocharts.model.Viewport; //导入依赖的package包/类
@Override
public void startAnimation(Viewport startViewport, Viewport targetViewport) {
this.startViewport.set(startViewport);
this.targetViewport.set(targetViewport);
duration = FAST_ANIMATION_DURATION;
isAnimationStarted = true;
animationListener.onAnimationStarted();
start = SystemClock.uptimeMillis();
handler.post(runnable);
}
示例10: startAnimation
import lecho.lib.hellocharts.model.Viewport; //导入依赖的package包/类
@Override
public void startAnimation(Viewport startViewport, Viewport targetViewport) {
this.startViewport.set(startViewport);
this.targetViewport.set(targetViewport);
animator.setDuration(FAST_ANIMATION_DURATION);
animator.start();
}
示例11: setCurrentViewportWithAnimation
import lecho.lib.hellocharts.model.Viewport; //导入依赖的package包/类
@Override
public void setCurrentViewportWithAnimation(Viewport targetViewport, long duration) {
if (null != targetViewport) {
viewportAnimator.cancelAnimation();
viewportAnimator.startAnimation(getCurrentViewport(), targetViewport, duration);
}
ViewCompat.postInvalidateOnAnimation(this);
}
示例12: setCurrentViewport
import lecho.lib.hellocharts.model.Viewport; //导入依赖的package包/类
@Override
public void setCurrentViewport(Viewport targetViewport) {
if (null != targetViewport) {
chartRenderer.setCurrentViewport(targetViewport);
}
ViewCompat.postInvalidateOnAnimation(this);
}
示例13: canScrollHorizontally
import lecho.lib.hellocharts.model.Viewport; //导入依赖的package包/类
/**
* When embedded in a ViewPager, this will be called in order to know if we can scroll.
* If this returns true, the ViewPager will ignore the drag so that we can scroll our content.
* If this return false, the ViewPager will assume we won't be able to scroll and will consume the drag
*
* @param direction Amount of pixels being scrolled (x axis)
* @return true if the chart can be scrolled (ie. zoomed and not against the edge of the chart)
*/
@Override
public boolean canScrollHorizontally(int direction) {
if (getZoomLevel() <= 1.0) {
return false;
}
final Viewport currentViewport = getCurrentViewport();
final Viewport maximumViewport = getMaximumViewport();
if (direction < 0) {
return currentViewport.left > maximumViewport.left;
} else {
return currentViewport.right < maximumViewport.right;
}
}
示例14: initListener
import lecho.lib.hellocharts.model.Viewport; //导入依赖的package包/类
private void initListener() {
this.columnChartView.setViewportChangeListener(new ViewportChangeListener() {
public void onViewportChanged(Viewport viewport) {
if (viewport.left <= -1.0f && StepHistoryActivity.this.canload && ((float)
StepHistoryActivity.this.stepList.size()) > StepHistoryActivity.PER_PAGE
&& StepHistoryActivity.this.page < 4) {
StepHistoryActivity.this.page = StepHistoryActivity.this.page + 1;
StepHistoryActivity.this.getStepHistory();
}
}
});
}
示例15: drawUnclipped
import lecho.lib.hellocharts.model.Viewport; //导入依赖的package包/类
@Override
public void drawUnclipped(Canvas canvas) {
super.drawUnclipped(canvas);
final Viewport currentViewport = computator.getCurrentViewport();
final float left = computator.computeRawX(currentViewport.left);
final float top = computator.computeRawY(currentViewport.top);
final float right = computator.computeRawX(currentViewport.right);
final float bottom = computator.computeRawY(currentViewport.bottom);
previewPaint.setAlpha(DEFAULT_PREVIEW_TRANSPARENCY);
previewPaint.setStyle(Paint.Style.FILL);
canvas.drawRect(left, top, right, bottom, previewPaint);
previewPaint.setStyle(Paint.Style.STROKE);
previewPaint.setAlpha(FULL_ALPHA);
canvas.drawRect(left, top, right, bottom, previewPaint);
}