• R/O
  • SSH
  • HTTPS

observoice: Commit


Commit MetaInfo

Revision285 (tree)
Zeit2012-10-27 17:18:14
Autoruchan_nos

Log Message

グラフの表示時刻の範囲に応じて分割数を動的に変更

Ändern Zusammenfassung

Diff

--- branches/29115-reviewgraph/observoice/src/jp/sourceforge/observoice/ReviewLectureActivity.java (revision 284)
+++ branches/29115-reviewgraph/observoice/src/jp/sourceforge/observoice/ReviewLectureActivity.java (revision 285)
@@ -261,11 +261,37 @@
261261 UnderstandabilityChartFragment ucf = (UnderstandabilityChartFragment) f;
262262
263263 long beginToEnd = dateEnd.getTimeInMillis() - dateBegin.getTimeInMillis();
264- ucf.setDivision((beginToEnd + 9) / 10, 10);
265- ucf.setDateFormat(new SimpleDateFormat("MM-dd"));
264+ long diffInSecond = beginToEnd / 1000;
265+ long diffInMinute = diffInSecond / 60;
266+ long diffInHour = diffInMinute / 60;
267+ long diffInDay = diffInHour / 24;
268+ long diffInMonth = diffInDay / 30;
266269
267- Log.d("obsv", "setDivision: " + beginToEnd + "msec");
268270
271+ int numDivision = 1;
272+ String dateFormatString = "yyyy-MM-dd HH-mm";
273+ if (diffInDay <= 1) { // 1日以下
274+ numDivision = (int) (beginToEnd / (1000L * 60 * 60)); // 1時間ごと
275+ dateFormatString = "HH";
276+ } else if (diffInDay <= 30) {
277+ numDivision = (int) (beginToEnd / (1000L * 60 * 60 * 24));
278+ dateFormatString = "dd";
279+ } else if (diffInDay <= 60) {
280+ numDivision = (int) (beginToEnd / (1000L * 60 * 60 * 24 * 7));
281+ dateFormatString = "dd";
282+ } else if (diffInMonth <= 12) {
283+ numDivision = (int) (beginToEnd / (1000L * 60 * 60 * 24 * 30));
284+ dateFormatString = "MM";
285+ }
286+ if (numDivision > 0) {
287+ Log.d("obsv", "setDivision: " + beginToEnd + "msec / " + numDivision);
288+ ucf.setDivision(beginToEnd / numDivision, numDivision);
289+ } else {
290+ Log.d("obsv", "setDivision: default: " + beginToEnd + "msec / " + 1);
291+ ucf.setDivision(beginToEnd, 1);
292+ }
293+ ucf.setDateFormat(new SimpleDateFormat(dateFormatString));
294+
269295 ucf.update(comments, dateEnd.getTimeInMillis());
270296 } else if (f instanceof CommentListFragment) {
271297 ((CommentListFragment) f).update(comments);
--- branches/29115-reviewgraph/observoice/src/jp/sourceforge/observoice/fragment/UnderstandabilityChartFragment.java (revision 284)
+++ branches/29115-reviewgraph/observoice/src/jp/sourceforge/observoice/fragment/UnderstandabilityChartFragment.java (revision 285)
@@ -108,7 +108,7 @@
108108 renderer.setXTitle("時刻");
109109 renderer.setYTitle("理解度");
110110 renderer.setXAxisMin(0.5);
111- renderer.setXAxisMax(10.5);
111+ renderer.setXAxisMax(mNumDivision + 0.5);
112112 renderer.setYAxisMin(-2);
113113 renderer.setYAxisMax(2);
114114 renderer.setAxesColor(Color.GRAY);
@@ -154,6 +154,7 @@
154154 mChartRenderer.addXTextLabel(i + 1,
155155 mDateFormat.format(new Date(dateBegin + mDateDivision * i)));
156156 }
157+ mChartRenderer.setXAxisMax(mNumDivision + 0.5);
157158
158159 // Y軸の表示範囲を設定
159160 double ymax = 0;
Show on old repository browser