本文整理汇总了Java中org.eazegraph.lib.models.PieModel.getEndAngle方法的典型用法代码示例。如果您正苦于以下问题:Java PieModel.getEndAngle方法的具体用法?Java PieModel.getEndAngle怎么用?Java PieModel.getEndAngle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eazegraph.lib.models.PieModel
的用法示例。
在下文中一共展示了PieModel.getEndAngle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onDataChanged
import org.eazegraph.lib.models.PieModel; //导入方法依赖的package包/类
/**
* Should be called after new data is inserted. Will be automatically called, when the view dimensions
* has changed.
*
* Calculates the start- and end-angles for every PieSlice.
*/
@Override
protected void onDataChanged() {
super.onDataChanged();
int currentAngle = 0;
int index = 0;
int size = mPieData.size();
for (PieModel model : mPieData) {
int endAngle = (int) (currentAngle + model.getValue() * 360.f / mTotalValue);
if(index == size-1) {
endAngle = 360;
}
model.setStartAngle(currentAngle);
model.setEndAngle(endAngle);
currentAngle = model.getEndAngle();
index++;
}
calcCurrentItem();
onScrollFinished();
}
示例2: calcCurrentItem
import org.eazegraph.lib.models.PieModel; //导入方法依赖的package包/类
/**
* Calculate which pie slice is under the pointer, and set the current item
* field accordingly.
*/
private void calcCurrentItem() {
int pointerAngle;
// calculate the correct pointer angle, depending on clockwise drawing or not
if(mOpenClockwise) {
pointerAngle = (mIndicatorAngle + 360 - mPieRotation) % 360;
}
else {
pointerAngle = (mIndicatorAngle + 180 + mPieRotation) % 360;
}
for (int i = 0; i < mPieData.size(); ++i) {
PieModel model = mPieData.get(i);
if (model.getStartAngle() <= pointerAngle && pointerAngle <= model.getEndAngle()) {
if (i != mCurrentItem) {
setCurrentItem(i, false);
}
break;
}
}
}
示例3: centerOnCurrentItem
import org.eazegraph.lib.models.PieModel; //导入方法依赖的package包/类
/**
* Kicks off an animation that will result in the pointer being centered in the
* pie slice of the currently selected item.
*/
private void centerOnCurrentItem() {
if(!mPieData.isEmpty()) {
PieModel current = mPieData.get(getCurrentItem());
int targetAngle;
if(mOpenClockwise) {
targetAngle = (mIndicatorAngle - current.getStartAngle()) - ((current.getEndAngle() - current.getStartAngle()) / 2);
if (targetAngle < 0 && mPieRotation > 0) targetAngle += 360;
}
else {
targetAngle = current.getStartAngle() + (current.getEndAngle() - current.getStartAngle()) / 2;
targetAngle += mIndicatorAngle;
if (targetAngle > 270 && mPieRotation < 90) targetAngle -= 360;
}
mAutoCenterAnimator.setIntValues(targetAngle);
mAutoCenterAnimator.setDuration(AUTOCENTER_ANIM_DURATION).start();
}
}