diff --git a/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/SPIMPipelineProgressViewController.java b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/SPIMPipelineProgressViewController.java index 6df8b3049f3ab90c7a43b8bbae669750746a0e6d..23d6098f4253719f2a55d0137b44684bfe4f0e64 100644 --- a/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/SPIMPipelineProgressViewController.java +++ b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/SPIMPipelineProgressViewController.java @@ -44,14 +44,17 @@ import javafx.scene.paint.Color; public class SPIMPipelineProgressViewController extends BorderPane implements CloseableControl, InitiableControl { + public final static Logger log = LoggerFactory .getLogger(cz.it4i.fiji.haas_spim_benchmark.ui.SPIMPipelineProgressViewController.class); - private static final String EMPTY_VALUE = "\u2007\u2007\u2007"; + private static final String EMPTY_VALUE = ""; private static final int PREFERRED_WIDTH = 900; private static final Map<JobState, Color> taskExecutionState2Color = new HashMap<>(); + + private static final double TIMEPOINT_TABLE_COLUMN_WIDTH_RATIO = 6; static { taskExecutionState2Color.put(JobState.Running, Color.rgb(0xF2, 0xD5, 0x39)); taskExecutionState2Color.put(JobState.Finished, Color.rgb(0x41, 0xB2, 0x80)); @@ -180,12 +183,18 @@ public class SPIMPipelineProgressViewController extends BorderPane implements Cl JavaFXRoutines.setCellValueFactory(this.tasks, i++, (Function<Task, String>) v -> Constants.BENCHMARK_TASK_NAME_MAP.get(v .getDescription())); + double tableColumnWidth = computeTableColumnWidth(computations); + + log.info("table column width " + tableColumnWidth); for (TaskComputation tc : computations) { - this.tasks.getColumns().add(new TableColumn<>(tc.getTimepoint() + "")); + TableColumn<ObservableValue<Task>, String> tableCol; + this.tasks.getColumns().add(tableCol = new TableColumn<>(columnHeader( + tc))); int index = i++; + tableCol.setPrefWidth(tableColumnWidth); constructCellFactory(index); } - fixNotVisibleColumn(); + this.tasks.getItems().addAll(taskList); }); timer.schedule(new TimerTask() { @@ -197,6 +206,23 @@ public class SPIMPipelineProgressViewController extends BorderPane implements Cl }, Constants.HAAS_UPDATE_TIMEOUT, Constants.HAAS_UPDATE_TIMEOUT); } + private long computeTableColumnWidth(List<TaskComputation> computations) { + return Math.round(this.tasks.getColumns().get(0) + .getWidth() / TIMEPOINT_TABLE_COLUMN_WIDTH_RATIO * (1 + Math.max(0, + computeMaxColumnHeaderTextLenght(computations) - 1) / 2)); + } + + private int computeMaxColumnHeaderTextLenght( + List<TaskComputation> computations) + { + return columnHeader( + computations.get(computations.size() - 1)).length(); + } + + private String columnHeader(TaskComputation taskComputation) { + return taskComputation.getTimepoint() + ""; + } + @SuppressWarnings("unchecked") private void constructCellFactory(int index) { JavaFXRoutines.setCellValueFactory(this.tasks, index, (Function<Task, TaskComputation>) v -> { @@ -221,8 +247,4 @@ public class SPIMPipelineProgressViewController extends BorderPane implements Cl private void updateTable() { registry.update(); } - - private void fixNotVisibleColumn() { - // this.tasks.getColumns().add(new TableColumn<>(" ")); - } }