|
4 | 4 | import java.util.Collections;
|
5 | 5 | import java.util.HashMap;
|
6 | 6 | import java.util.Map;
|
7 |
| -import java.util.Optional; |
8 | 7 | import java.util.concurrent.Executors;
|
9 | 8 | import java.util.concurrent.ScheduledExecutorService;
|
10 | 9 | import java.util.concurrent.TimeUnit;
|
11 |
| -import java.util.function.*; |
| 10 | +import java.util.function.BiConsumer; |
| 11 | +import java.util.function.LongSupplier; |
| 12 | +import java.util.function.LongUnaryOperator; |
| 13 | +import java.util.function.Supplier; |
12 | 14 |
|
13 |
| -import bdv.fx.viewer.ViewerPanelFX; |
14 |
| -import bdv.viewer.Source; |
15 |
| -import javafx.animation.KeyFrame; |
16 |
| -import javafx.animation.Timeline; |
17 |
| -import javafx.beans.binding.Bindings; |
18 |
| -import javafx.beans.property.*; |
19 |
| -import javafx.beans.value.ObservableObjectValue; |
20 |
| -import javafx.event.ActionEvent; |
21 |
| -import javafx.event.EventHandler; |
22 |
| -import javafx.scene.Group; |
23 |
| -import javafx.scene.control.*; |
24 |
| -import javafx.scene.control.ScrollPane.ScrollBarPolicy; |
25 |
| -import javafx.scene.input.MouseEvent; |
26 |
| -import javafx.scene.layout.BorderPane; |
27 |
| -import javafx.scene.layout.HBox; |
28 |
| -import javafx.scene.layout.Priority; |
29 |
| -import javafx.scene.layout.Region; |
30 |
| -import javafx.scene.layout.VBox; |
31 |
| -import javafx.scene.paint.Color; |
32 |
| -import javafx.scene.text.Font; |
33 |
| -import javafx.util.Duration; |
34 |
| -import net.imglib2.RealPoint; |
35 | 15 | import org.janelia.saalfeldlab.fx.TitledPanes;
|
36 | 16 | import org.janelia.saalfeldlab.fx.ortho.OrthogonalViews;
|
37 | 17 | import org.janelia.saalfeldlab.fx.ortho.OrthogonalViews.ViewerAndTransforms;
|
|
57 | 37 | import org.slf4j.Logger;
|
58 | 38 | import org.slf4j.LoggerFactory;
|
59 | 39 |
|
| 40 | +import bdv.fx.viewer.ViewerPanelFX; |
| 41 | +import bdv.viewer.Source; |
| 42 | +import javafx.animation.KeyFrame; |
| 43 | +import javafx.animation.Timeline; |
| 44 | +import javafx.beans.binding.Bindings; |
| 45 | +import javafx.beans.property.BooleanProperty; |
| 46 | +import javafx.beans.property.LongProperty; |
| 47 | +import javafx.beans.property.ObjectProperty; |
| 48 | +import javafx.beans.property.ReadOnlyBooleanProperty; |
| 49 | +import javafx.beans.property.SimpleBooleanProperty; |
| 50 | +import javafx.beans.value.ObservableObjectValue; |
| 51 | +import javafx.event.ActionEvent; |
| 52 | +import javafx.event.EventHandler; |
| 53 | +import javafx.scene.Group; |
| 54 | +import javafx.scene.control.Alert; |
| 55 | +import javafx.scene.control.Button; |
| 56 | +import javafx.scene.control.ButtonType; |
| 57 | +import javafx.scene.control.CheckBox; |
| 58 | +import javafx.scene.control.Label; |
| 59 | +import javafx.scene.control.ScrollPane; |
| 60 | +import javafx.scene.control.ScrollPane.ScrollBarPolicy; |
| 61 | +import javafx.scene.control.TitledPane; |
| 62 | +import javafx.scene.control.Tooltip; |
| 63 | +import javafx.scene.input.MouseEvent; |
| 64 | +import javafx.scene.layout.BorderPane; |
| 65 | +import javafx.scene.layout.HBox; |
| 66 | +import javafx.scene.layout.Priority; |
| 67 | +import javafx.scene.layout.Region; |
| 68 | +import javafx.scene.layout.VBox; |
| 69 | +import javafx.scene.paint.Color; |
| 70 | +import javafx.scene.text.Font; |
| 71 | +import javafx.util.Duration; |
| 72 | +import net.imglib2.RealPoint; |
| 73 | + |
60 | 74 | public class BorderPaneWithStatusBars
|
61 | 75 | {
|
62 | 76 |
|
@@ -160,16 +174,29 @@ public BorderPaneWithStatusBars(
|
160 | 174 | center.orthogonalViews(),
|
161 | 175 | center.viewer3D().meshesGroup(),
|
162 | 176 | center.sourceInfo()
|
163 |
| - ); |
164 |
| - |
165 |
| - center.sourceInfo().currentNameProperty().addListener((obs, oldv, newv) -> { |
166 |
| - currentSourceStatus.textProperty().unbind(); |
167 |
| - Optional.ofNullable(newv).ifPresent(currentSourceStatus.textProperty()::bind); |
168 |
| - }); |
| 177 | + ); |
169 | 178 |
|
170 | 179 | final SingleChildStackPane sourceDisplayStatus = new SingleChildStackPane();
|
171 | 180 | center.sourceInfo().currentState().addListener((obs, oldv, newv) -> sourceDisplayStatus.setChild(newv.getDisplayStatus()));
|
172 | 181 |
|
| 182 | + // show source name by default, or override it with source status text if any |
| 183 | + center.sourceInfo().currentState().addListener((obs, oldv, newv) -> { |
| 184 | + sourceDisplayStatus.setChild(newv.getDisplayStatus()); |
| 185 | + currentSourceStatus.textProperty().unbind(); |
| 186 | + currentSourceStatus.textProperty().bind(Bindings.createStringBinding( |
| 187 | + () -> { |
| 188 | + if (newv.statusTextProperty() != null && newv.statusTextProperty().get() != null) |
| 189 | + return newv.statusTextProperty().get(); |
| 190 | + else if (newv.nameProperty().get() != null) |
| 191 | + return newv.nameProperty().get(); |
| 192 | + else |
| 193 | + return null; |
| 194 | + }, |
| 195 | + newv.nameProperty(), |
| 196 | + newv.statusTextProperty() |
| 197 | + )); |
| 198 | + }); |
| 199 | + |
173 | 200 | // for positioning the 'show status bar' checkbox on the right
|
174 | 201 | final Region valueStatusSpacing = new Region();
|
175 | 202 | HBox.setHgrow(valueStatusSpacing, Priority.ALWAYS);
|
@@ -272,21 +299,25 @@ public BorderPaneWithStatusBars(
|
272 | 299 | this.sideBar.setHbarPolicy(ScrollBarPolicy.NEVER);
|
273 | 300 | this.sideBar.setVbarPolicy(ScrollBarPolicy.AS_NEEDED);
|
274 | 301 | this.sideBar.setVisible(true);
|
275 |
| - this.sideBar.prefWidthProperty().set(250); |
| 302 | + this.sideBar.prefWidthProperty().set(280); |
276 | 303 | sourceTabs.widthProperty().bind(sideBar.prefWidthProperty());
|
277 | 304 | settingsContents.prefWidthProperty().bind(sideBar.prefWidthProperty());
|
278 | 305 |
|
279 | 306 | resizeSideBar = new ResizeOnLeftSide(sideBar, sideBar.prefWidthProperty(), dist -> Math.abs(dist) < 5);
|
280 | 307 | }
|
281 | 308 |
|
| 309 | + public ScrollPane getSideBar() |
| 310 | + { |
| 311 | + return sideBar; |
| 312 | + } |
| 313 | + |
282 | 314 | public void toggleSideBar()
|
283 | 315 | {
|
284 | 316 | if (pane.getRight() == null)
|
285 | 317 | {
|
286 | 318 | pane.setRight(sideBar);
|
287 | 319 | resizeSideBar.install();
|
288 | 320 | }
|
289 |
| - |
290 | 321 | else
|
291 | 322 | {
|
292 | 323 | resizeSideBar.remove();
|
|
0 commit comments