@Override public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); // based on columns in SystemTimeTableModel if (column == 0) { setHorizontalAlignment(SwingConstants.TRAILING); } else if (column == 1) { long start = (Long) value; long intervalStart = toCompare.getStart(); if (start == intervalStart) { setFont(Styles.BOLD_ITALIC); } else if (intervalStart < start) { if (toCompare.getEnd() < start) { setFont(Styles.STRIKETHROUGH); } else { setFont(Styles.BOLD); } } else { long end = (Long) table.getValueAt(row, column + 1); if (intervalStart > end) { setFont(Styles.STRIKETHROUGH); } // else leave unformatted } setText(TimeFormatCache.formatDateTime(start)); } else if (column == 2) { long end = (Long) value; long intervalEnd = toCompare.getEnd(); if (end == intervalEnd) { setFont(Styles.BOLD_ITALIC); } else if (intervalEnd > end) { if (toCompare.getStart() > end) { setFont(Styles.STRIKETHROUGH); } else { setFont(Styles.BOLD); } } else { long start = (Long) table.getValueAt(row, column - 1); if (intervalEnd < start) { setFont(Styles.STRIKETHROUGH); } // else leave unformatted } setText(TimeFormatCache.formatDateTime(end)); } else if (column == 3) { setHorizontalAlignment(SwingConstants.CENTER); } // else just return the value return this; }
// attempt to get about 100 data points on each chart, based on the interval duration rounded to // the nearest 15 seconds // default to 60s public void recalculate() { if (!automatic) { throw new IllegalStateException( "cannot automatically set granularity; call setAutomatic(true) first"); } long duration = 0; Interval interval = app.getIntervalManager().getCurrentInterval(); if (Interval.DEFAULT.equals(interval)) { duration = app.getMaxSystemTime() - app.getMinSystemTime(); // no files parsed yet => default back to 60s if (duration == Long.MAX_VALUE) { granularity = 60000; return; } } else { duration = interval.getDuration(); } long granularity = duration / 100; if (granularity >= Integer.MAX_VALUE) { granularity = 2147475000; // MAX_VALUE rounded down to nearest 15000 } // round to nearest 15 seconds granularity = Math.round(granularity / 15000d) * 15000; if (granularity < 1000) { granularity = 1000; } this.granularity = (int) granularity; }