Skip to content

Commit 0f87f2f

Browse files
committed
SwingTaskMonitorComponent: fix some comment style
SciJava tries to keep things under 80 character line lengths (which is probably dumb in this day and age, but that's the style currently). Long EOL comments break that, and confuse the SciJava style formatter.
1 parent 9b0977e commit 0f87f2f

File tree

1 file changed

+70
-26
lines changed

1 file changed

+70
-26
lines changed

src/main/java/org/scijava/ui/swing/task/SwingTaskMonitorComponent.java

Lines changed: 70 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -111,25 +111,55 @@
111111

112112
public class SwingTaskMonitorComponent {
113113

114-
private final JProgressBar globalProgressBar; // progress bar showing the global progression ( = progression of all tasks ). Clicking it toggles taskFrame visibility
114+
/**
115+
* Progress bar showing the global progression ( = progression of all tasks ).
116+
* Clicking it toggles taskFrame visibility.
117+
*/
118+
private final JProgressBar globalProgressBar;
115119
private final int sizeGlobalProgressBar;
116120

117-
private final JFrame taskFrame; // a container for the taskTable, visibility toggled by clickable globalProgressBar
118-
private final JTable taskTable; // JTable rendering each monitored task, contained in the taskFrame
119-
private final TaskTableModel taskTableModel; // model of the taskTable
121+
/**
122+
* A container for the {@link #taskTable}, visibility toggled by clickable
123+
* {@link #globalProgressBar}.
124+
*/
125+
private final JFrame taskFrame;
126+
127+
/**
128+
* {@link JTable} rendering each monitored task, contained in the
129+
* {@link #taskFrame}.
130+
*/
131+
private final JTable taskTable;
132+
133+
/** Model of the {@link #taskTable}. */
134+
private final TaskTableModel taskTableModel;
120135

121-
private final Boolean estimateTimeLeft; // flags whether each task should be timed
122-
private Boolean confirmBeforeCancel; // flags whether the user should confirm when a task is clicked to be canceled. not final because this behaviour can be changed
136+
/** Flags whether each task should be timed. */
137+
private final Boolean estimateTimeLeft;
123138

124-
private double globalProgression = 0; // store temporarily the current global progression - all tasks have an equal weight
139+
/**
140+
* Flags whether the user should confirm when a task is clicked to be
141+
* canceled. not final because this behaviour can be changed.
142+
*/
143+
private Boolean confirmBeforeCancel;
125144

126145
/**
127-
* Construct a Swing Task Monitor component - clickable circular progress bar
128-
* the component can be accessed with {@link SwingTaskMonitorComponent#getComponent()}
146+
* Stores temporarily the current global progression - all tasks have an equal
147+
* weight.
148+
*/
149+
private double globalProgression = 0;
150+
151+
/**
152+
* Constructs a Swing Task Monitor component - clickable circular progress bar
153+
* the component can be accessed with
154+
* {@link SwingTaskMonitorComponent#getComponent()}.
129155
*
130-
* @param context scijava context
131-
* @param estimateTimeLeft whether registered tasks should display an estimated remaining time
132-
* @param confirmBeforeCancel flags whether a confirmation window should popup when cancelling a task, can be overridden with {@link SwingTaskMonitorComponent#disableCancelConfirmation()} and {@link SwingTaskMonitorComponent#enableCancelConfirmation()}
156+
* @param context SciJava context
157+
* @param estimateTimeLeft whether registered tasks should display an
158+
* estimated remaining time
159+
* @param confirmBeforeCancel flags whether a confirmation window should pop up
160+
* when canceling a task, can be overridden with
161+
* {@link SwingTaskMonitorComponent#disableCancelConfirmation()} and
162+
* {@link SwingTaskMonitorComponent#enableCancelConfirmation()}
133163
* @param size of the circular progress bar (preferred size)
134164
* @param undecorated defines whether taskFrame is undecorated or not
135165
*/
@@ -182,7 +212,8 @@ public void mouseClicked(MouseEvent e) {
182212
taskTable.setRowHeight(65);
183213
taskTable.setRowMargin(2);
184214
taskTable.setDefaultRenderer(Task.class, new TaskRenderer(false));
185-
taskTable.getColumnModel().getColumn(1).setMaxWidth(30); // restrict size of second column to the size of the stop icon
215+
// restrict size of second column to the size of the stop icon
216+
taskTable.getColumnModel().getColumn(1).setMaxWidth(30);
186217

187218
// Scroll pane containing the JTable -> necessary when many tasks are displayed
188219
JScrollPane scrollPane = new JScrollPane(taskTable);
@@ -233,38 +264,51 @@ private void onEvent(final TaskEvent evt) {
233264
} else {
234265
taskTableModel.addOrUpdate(task);
235266
}
236-
globalProgressBar.setValue((int)(globalProgression*100)); // globalProgression has been updated during taskTableModel update
267+
// globalProgression has been updated during taskTableModel update
268+
globalProgressBar.setValue((int)(globalProgression*100));
237269
}
238270

239271
/**
240-
* User confirmation required when cancelling a task by clicking the task table
272+
* User confirmation required when canceling a task by clicking the task table.
241273
*/
242274
public void enableCancelConfirmation() {
243275
this.confirmBeforeCancel = true;
244276
}
245277

246278
/**
247-
* NO user confirmation required when cancelling a task by clicking the task table
279+
* NO user confirmation required when canceling a task by clicking the task table.
248280
*/
249281
public void disableCancelConfirmation() {
250282
this.confirmBeforeCancel = false;
251283
}
252284

253-
/*
254-
* Task Table Model, serves to update the table according to the events received. Note
255-
* that nothing is synchronized because every call is expected to happen from the
256-
* event dispatch thread. It is thus single threaded, no race condition expected.
285+
/**
286+
* Task Table Model, serves to update the table according to the events
287+
* received. Note that nothing is synchronized because every call is expected
288+
* to happen from the event dispatch thread. It is thus single threaded, no
289+
* race condition expected.
257290
*/
258291
class TaskTableModel extends AbstractTableModel {
259292

260293
TaskTableModel() {
261294
super();
262295
}
263296

264-
private List<Task> monitoredTasks = new ArrayList<>(); // indexed tasks
265-
private Set<Task> tasksSet = new HashSet<>(); // unordered tasks -> faster task lookup (may be overkill)
266-
private Map<Task,Double> previousCompletion = new HashMap<>(); // store the previous completion state of a certain task, before it was updated
267-
private Map<Task, Instant> startTime = new HashMap<>(); // Start time -> stores when a task was added to this table model
297+
/** Indexed tasks. */
298+
private List<Task> monitoredTasks = new ArrayList<>();
299+
300+
/** Unordered tasks &rarr; faster task lookup (may be overkill). */
301+
private Set<Task> tasksSet = new HashSet<>();
302+
303+
/**
304+
* Store the previous completion state of a certain task, before it was
305+
* updated.
306+
*/
307+
private Map<Task,Double> previousCompletion = new HashMap<>();
308+
309+
/** Start time -> stores when a task was added to this table model. */
310+
private Map<Task, Instant> startTime = new HashMap<>();
311+
268312
int totalTasks = 0;
269313
double totalProgression = 0;
270314

@@ -384,7 +428,7 @@ public Task getTask(int rowIndex) {
384428
}
385429

386430
/*
387-
* // From https://java-swing-tips.blogspot.com/2014/06/how-to-create-circular-progress.html
431+
* From https://java-swing-tips.blogspot.com/2014/06/how-to-create-circular-progress.html
388432
* UI for circular progress bar
389433
*/
390434
static class ProgressCircleUI extends BasicProgressBarUI {
@@ -437,7 +481,7 @@ class TaskRenderer implements TableCellRenderer {
437481
JLabel labelTop = new JLabel(); // top label : task name and status
438482
JProgressBar progressBar = new JProgressBar(); // standard linear progress bar
439483
JLabel labelBottom = new JLabel(); // bottom label : task completion, and optionally time left
440-
Icon errorIcon = UIManager.getIcon("OptionPane.errorIcon"); // icon for cancelling task
484+
Icon errorIcon = UIManager.getIcon("OptionPane.errorIcon"); // icon for canceling task
441485
JLabel cancelTask; // container for errorIcon
442486

443487
public TaskRenderer(boolean isBordered) {

0 commit comments

Comments
 (0)