use of com.ichi2.libanki.stats.Stats in project AnkiChinaAndroid by ankichinateam.
the class StudyOptionsFragment method calculateStat.
private double[] calculateStat(Collection col, long deckId) {
// 计算已熟悉
Stats stats = new Stats(col, deckId);
stats.calculateCardTypes(TYPE_LIFE);
return stats.getSeriesList()[0];
}
use of com.ichi2.libanki.stats.Stats in project AnkiChinaAndroid by ankichinateam.
the class ChartBuilder method calcStats.
private void calcStats(Stats.AxisType type) {
// Stats stats = new Stats(mCollectionData, mDeckId);
Stats stats = new Stats(CollectionHelper.getInstance().getCol(mChartView.getContext()), mDeckId);
switch(mChartType) {
case FORECAST:
stats.calculateDue(mChartView.getContext(), type);
break;
case REVIEW_COUNT:
stats.calculateReviewCount(type);
break;
case REVIEW_TIME:
stats.calculateReviewTime(type);
break;
case INTERVALS:
stats.calculateIntervals(mChartView.getContext(), type);
break;
case HOURLY_BREAKDOWN:
stats.calculateBreakdown(type);
break;
case WEEKLY_BREAKDOWN:
stats.calculateWeeklyBreakdown(type);
break;
case ANSWER_BUTTONS:
stats.calculateAnswerButtons(type);
break;
case CARDS_TYPES:
stats.calculateCardTypes(type);
break;
}
mCumulative = stats.getCumulative();
mSeriesList = stats.getSeriesList();
Object[] metaData = stats.getMetaInfo();
mBackwards = (Boolean) metaData[2];
mValueLabels = (int[]) metaData[3];
mColors = (int[]) metaData[4];
mAxisTitles = (int[]) metaData[5];
mMaxCards = (Integer) metaData[7];
mLastElement = (Double) metaData[10];
mFirstElement = (Double) metaData[9];
mHasColoredCumulative = (Boolean) metaData[19];
mMcount = (Double) metaData[18];
mDynamicAxis = (Boolean) metaData[20];
}
use of com.ichi2.libanki.stats.Stats in project AnkiChinaAndroid by ankichinateam.
the class OverviewStatsBuilder method startCalculate.
public void startCalculate() {
Timber.d("startCalculate");
Stats stats = new Stats(mCol, mDeckId);
mOverViewStats = new OverviewStats();
stats.calculateOverviewStatistics(mType, mOverViewStats);
calculateForecastOverview(mType, mOverViewStats);
mTodayStats = stats.calculateTodayStats();
}
use of com.ichi2.libanki.stats.Stats in project Anki-Android by Ramblurr.
the class ChartBuilder method onCreate.
// public void setRenderer(int type, int row) {
// Resources res = getResources();
// XYSeriesRenderer renderer = new XYSeriesRenderer();
// if (type <= 2) {
// switch (row) {
// case 0:
// renderer.setColor(res.getColor(R.color.statistics_due_young_cards));
// break;
// case 1:
// renderer.setColor(res.getColor(R.color.statistics_due_mature_cards));
// break;
// case 2:
// // renderer.setColor(res.getColor(R.color.statistics_due_failed_cards));
// break;
// }
// } else if (type == 3) {
// switch (row) {
// case 0:
// // renderer.setColor(res.getColor(R.color.statistics_reps_new_cards));
// break;
// case 1:
// renderer.setColor(res.getColor(R.color.statistics_reps_young_cards));
// break;
// case 2:
// renderer.setColor(res.getColor(R.color.statistics_reps_mature_cards));
// break;
// }
// } else {
// renderer.setColor(res.getColor(R.color.statistics_default));
// }
// mRenderer.addSeriesRenderer(renderer);
// }
@Override
protected void onCreate(Bundle savedInstanceState) {
// Log.i(AnkiDroidApp.TAG, "ChartBuilder.OnCreate");
Themes.applyTheme(this);
super.onCreate(savedInstanceState);
restorePreferences();
Resources res = getResources();
Stats stats = Stats.currentStats();
if (stats != null) {
mSeriesList = stats.getSeriesList();
mMeta = stats.getMetaInfo();
} else if (savedInstanceState != null) {
int len = savedInstanceState.getInt("seriesListLen");
mSeriesList = new double[len][];
for (int i = 0; i < len; i++) {
mSeriesList[i] = (double[]) savedInstanceState.getSerializable("seriesList" + i);
}
mMeta = (Object[]) savedInstanceState.getSerializable("meta");
} else {
finish();
}
String title = res.getString((Integer) mMeta[1]);
boolean backwards = (Boolean) mMeta[2];
int[] valueLabels = (int[]) mMeta[3];
int[] barColors = (int[]) mMeta[4];
int[] axisTitles = (int[]) mMeta[5];
String subTitle = (String) mMeta[6];
if (mSeriesList == null || mSeriesList[0].length < 2) {
// Log.i(AnkiDroidApp.TAG, "ChartBuilder - Data variable empty, closing chartbuilder");
finish();
return;
}
if (mFullScreen) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
}
View mainView = getLayoutInflater().inflate(R.layout.statistics, null);
setContentView(mainView);
mainView.setBackgroundColor(Color.WHITE);
mTitle = (TextView) findViewById(R.id.statistics_title);
if (mChartView == null) {
if (mFullScreen) {
mTitle.setText(title);
mTitle.setTextColor(Color.BLACK);
} else {
setTitle(title);
AnkiDroidApp.getCompat().setSubtitle(this, subTitle);
mTitle.setVisibility(View.GONE);
}
for (int i = 1; i < mSeriesList.length; i++) {
XYSeries series = new XYSeries(res.getString(valueLabels[i - 1]));
for (int j = 0; j < mSeriesList[i].length; j++) {
series.add(mSeriesList[0][j], mSeriesList[i][j]);
}
mDataset.addSeries(series);
XYSeriesRenderer renderer = new XYSeriesRenderer();
renderer.setColor(res.getColor(barColors[i - 1]));
mRenderer.addSeriesRenderer(renderer);
}
if (mSeriesList.length == 1) {
mRenderer.setShowLegend(false);
}
if (backwards) {
mPan = new double[] { mSeriesList[0][0] - 0.5, 0.5 };
} else {
mPan = new double[] { -0.5, mSeriesList[0][mSeriesList[0].length - 1] + 0.5 };
}
mRenderer.setLegendTextSize(17);
mRenderer.setBarSpacing(0.4);
mRenderer.setLegendHeight(60);
mRenderer.setAxisTitleTextSize(17);
mRenderer.setLabelsTextSize(17);
mRenderer.setXAxisMin(mPan[0]);
mRenderer.setXAxisMax(mPan[1]);
mRenderer.setYAxisMin(0);
mRenderer.setGridColor(Color.LTGRAY);
mRenderer.setShowGrid(true);
mRenderer.setXTitle(res.getStringArray(R.array.due_x_axis_title)[axisTitles[0]]);
mRenderer.setYTitle(res.getString(axisTitles[1]));
mRenderer.setBackgroundColor(Color.WHITE);
mRenderer.setMarginsColor(Color.WHITE);
mRenderer.setAxesColor(Color.BLACK);
mRenderer.setLabelsColor(Color.BLACK);
mRenderer.setYLabelsColor(0, Color.BLACK);
mRenderer.setYLabelsAngle(-90);
mRenderer.setXLabelsColor(Color.BLACK);
mRenderer.setXLabelsAlign(Align.CENTER);
mRenderer.setYLabelsAlign(Align.CENTER);
mRenderer.setZoomEnabled(false, false);
mRenderer.setMargins(new int[] { 15, 48, 30, 10 });
mRenderer.setAntialiasing(true);
mRenderer.setPanEnabled(true, false);
mRenderer.setPanLimits(mPan);
mChartView = ChartFactory.getBarChartView(this, mDataset, mRenderer, BarChart.Type.STACKED);
LinearLayout layout = (LinearLayout) findViewById(R.id.chart);
layout.addView(mChartView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
} else {
mChartView.repaint();
}
gestureDetector = new GestureDetector(new MyGestureDetector());
mChartView.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (gestureDetector.onTouchEvent(event)) {
return true;
}
return false;
}
});
}
use of com.ichi2.libanki.stats.Stats in project Anki-Android by Ramblurr.
the class DeckTask method doInBackgroundUpdateValuesFromDeck.
private TaskData doInBackgroundUpdateValuesFromDeck(TaskData... params) {
// Log.i(AnkiDroidApp.TAG, "doInBackgroundUpdateValuesFromDeck");
try {
Sched sched = params[0].getCollection().getSched();
Object[] obj = params[0].getObjArray();
boolean reset = (Boolean) obj[0];
if (reset) {
sched.reset();
}
int[] counts = sched.counts();
int totalNewCount = sched.totalNewForCurrentDeck();
int totalCount = sched.cardCount();
double progressMature = ((double) sched.matureCount()) / ((double) totalCount);
double progressAll = 1 - (((double) (totalNewCount + counts[1])) / ((double) totalCount));
double[][] serieslist = null;
// only calculate stats if necessary
if ((Boolean) obj[1]) {
serieslist = Stats.getSmallDueStats(sched.getCol());
}
return new TaskData(new Object[] { counts[0], counts[1], counts[2], totalNewCount, totalCount, progressMature, progressAll, sched.eta(counts), serieslist });
} catch (RuntimeException e) {
Log.e(AnkiDroidApp.TAG, "doInBackgroundUpdateValuesFromDeck - an error occurred: " + e);
return null;
}
}
Aggregations