| Revision 2,
1.4 KB
checked in by jdalbey, 10 years ago
(diff) |
|
Initial Import of project files
|
| Line | |
|---|
| 1 | package tmcsim.simulationmanager.model; |
|---|
| 2 | |
|---|
| 3 | import javax.swing.table.DefaultTableCellRenderer; |
|---|
| 4 | |
|---|
| 5 | /** |
|---|
| 6 | * IncidentTimeCellRenderer is a DefaultCellEditor overriding the necessary |
|---|
| 7 | * base methods to render the Long incident time value as a string of format |
|---|
| 8 | * H:MM:SS. If the incident time value is -1, this means the incident has |
|---|
| 9 | * started, and the renderer returns "Started" as the display value. |
|---|
| 10 | * |
|---|
| 11 | * @author Matthew |
|---|
| 12 | * @version |
|---|
| 13 | */ |
|---|
| 14 | @SuppressWarnings("serial") |
|---|
| 15 | public class IncidentTimeCellRenderer extends DefaultTableCellRenderer { |
|---|
| 16 | |
|---|
| 17 | public IncidentTimeCellRenderer() { } |
|---|
| 18 | |
|---|
| 19 | protected void setValue(Object value) { |
|---|
| 20 | |
|---|
| 21 | if(value != null && value instanceof Number) { |
|---|
| 22 | String time_str = new String(); |
|---|
| 23 | Long time_val = (Long)value; |
|---|
| 24 | |
|---|
| 25 | if(time_val == -1) { |
|---|
| 26 | super.setValue("Started"); |
|---|
| 27 | return; |
|---|
| 28 | } |
|---|
| 29 | |
|---|
| 30 | time_str += String.valueOf(time_val / 3600) + ":"; |
|---|
| 31 | |
|---|
| 32 | time_val = time_val % 3600; |
|---|
| 33 | |
|---|
| 34 | if(time_val / 60 < 10) |
|---|
| 35 | time_str += "0"; |
|---|
| 36 | |
|---|
| 37 | time_str += String.valueOf(time_val / 60) + ":"; |
|---|
| 38 | time_val = time_val % 60; |
|---|
| 39 | |
|---|
| 40 | if(time_val < 10) |
|---|
| 41 | time_str += "0"; |
|---|
| 42 | |
|---|
| 43 | time_str += String.valueOf(time_val); |
|---|
| 44 | |
|---|
| 45 | super.setValue(time_str); |
|---|
| 46 | } |
|---|
| 47 | } |
|---|
| 48 | } |
|---|
Note: See
TracBrowser
for help on using the repository browser.