DisplaySyncHistogrampublic class DisplaySyncHistogram extends SyncCommon
Fields Summary |
---|
Map[] | mTimePeriodMap | private org.jfree.data.time.TimePeriodValues[] | mDatasetsSyncHist |
Constructors Summary |
---|
public DisplaySyncHistogram(String name)
super(name);
|
Methods Summary |
---|
private void | addHistEvent(long stopTime, int auth, double value)Helper to add an event to the data series.
Also updates error series if appropriate (x or X in details).
SimpleTimePeriod hour = getTimePeriod(stopTime, mHistWidth);
// Loop over all datasets to do the stacking.
for (int i = auth; i <= ERRORS; i++) {
addToPeriod(mDatasetsSyncHist, i, hour, value);
}
| private void | addToPeriod(org.jfree.data.time.TimePeriodValues[] tpv, int auth, org.jfree.data.time.SimpleTimePeriod period, double value)
int index;
if (mTimePeriodMap[auth].containsKey(period)) {
index = mTimePeriodMap[auth].get(period);
double oldValue = tpv[auth].getValue(index).doubleValue();
tpv[auth].update(index, oldValue + value);
} else {
index = tpv[auth].getItemCount();
mTimePeriodMap[auth].put(period, index);
tpv[auth].add(period, value);
}
| public org.eclipse.swt.widgets.Control | createComposite(org.eclipse.swt.widgets.Composite parent, com.android.ddmlib.log.EventLogParser logParser, ILogColumnListener listener)Creates the UI for the event display.
Control composite = createCompositeChart(parent, logParser, "Sync Histogram");
resetUI();
return composite;
| int | getDisplayType()Gets display type
return DISPLAY_TYPE_SYNC_HIST;
| private org.jfree.data.time.SimpleTimePeriod | getTimePeriod(long time, long numHoursWide)Creates a multiple-hour time period for the histogram.
Date date = new Date(time);
TimeZone zone = RegularTimePeriod.DEFAULT_TIME_ZONE;
Calendar calendar = Calendar.getInstance(zone);
calendar.setTime(date);
long hoursOfYear = calendar.get(Calendar.HOUR_OF_DAY) +
calendar.get(Calendar.DAY_OF_YEAR) * 24;
int year = calendar.get(Calendar.YEAR);
hoursOfYear = (hoursOfYear / numHoursWide) * numHoursWide;
calendar.clear();
calendar.set(year, 0, 1, 0, 0); // Jan 1
long start = calendar.getTimeInMillis() + hoursOfYear * 3600 * 1000;
return new SimpleTimePeriod(start, start + numHoursWide * 3600 * 1000);
| void | processSyncEvent(com.android.ddmlib.log.EventContainer event, int auth, long startTime, long stopTime, java.lang.String details, boolean newEvent, int syncSource)Callback to process a sync event.
if (newEvent) {
if (details.indexOf('x") >= 0 || details.indexOf('X") >= 0) {
auth = ERRORS;
}
double delta = (stopTime - startTime) * 100. / 1000 / 3600; // Percent of hour
addHistEvent(0, auth, delta);
} else {
// sync_details arrived for an event that has already been graphed.
if (details.indexOf('x") >= 0 || details.indexOf('X") >= 0) {
// Item turns out to be in error, so transfer time from old auth to error.
double delta = (stopTime - startTime) * 100. / 1000 / 3600; // Percent of hour
addHistEvent(0, auth, -delta);
addHistEvent(0, ERRORS, delta);
}
}
| void | resetUI()Resets the display.
super.resetUI();
XYPlot xyPlot = mChart.getXYPlot();
AbstractXYItemRenderer br = new XYBarRenderer();
mDatasetsSyncHist = new TimePeriodValues[NUM_AUTHS+1];
mTimePeriodMap = new HashMap[NUM_AUTHS + 1];
TimePeriodValuesCollection tpvc = new TimePeriodValuesCollection();
xyPlot.setDataset(tpvc);
xyPlot.setRenderer(br);
for (int i = 0; i < NUM_AUTHS + 1; i++) {
br.setSeriesPaint(i, AUTH_COLORS[i]);
mDatasetsSyncHist[i] = new TimePeriodValues(AUTH_NAMES[i]);
tpvc.addSeries(mDatasetsSyncHist[i]);
mTimePeriodMap[i] = new HashMap<SimpleTimePeriod, Integer>();
}
|
|