1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package io.github.tonywasher.joceanus.tethys.javafx.pane;
18
19 import java.util.Iterator;
20
21 import javafx.scene.Node;
22 import javafx.scene.layout.FlowPane;
23
24 import io.github.tonywasher.joceanus.tethys.api.base.TethysUIComponent;
25 import io.github.tonywasher.joceanus.tethys.core.factory.TethysUICoreFactory;
26 import io.github.tonywasher.joceanus.tethys.core.pane.TethysUICoreFlowPaneManager;
27 import io.github.tonywasher.joceanus.tethys.javafx.base.TethysUIFXNode;
28
29
30
31
32 public class TethysUIFXFlowPaneManager
33 extends TethysUICoreFlowPaneManager {
34
35
36
37 private final TethysUIFXNode theNode;
38
39
40
41
42 private final FlowPane theFlowPane;
43
44
45
46
47
48
49 TethysUIFXFlowPaneManager(final TethysUICoreFactory<?> pFactory) {
50 super(pFactory);
51 theFlowPane = new FlowPane();
52 theNode = new TethysUIFXNode(theFlowPane);
53 }
54
55 @Override
56 public TethysUIFXNode getNode() {
57 return theNode;
58 }
59
60 @Override
61 public void setVisible(final boolean pVisible) {
62 theNode.setManaged(pVisible);
63 theNode.setVisible(pVisible);
64 }
65
66 @Override
67 public void addNode(final TethysUIComponent pNode) {
68 super.addNode(pNode);
69 theFlowPane.getChildren().add(TethysUIFXNode.getNode(pNode));
70 }
71
72 @Override
73 public void setChildVisible(final TethysUIComponent pChild,
74 final boolean pVisible) {
75
76 final Node myChildNode = TethysUIFXNode.getNode(pChild);
77 final boolean isVisible = myChildNode.isVisible();
78 if (isVisible == pVisible) {
79 return;
80 }
81
82
83 if (pVisible) {
84
85 final int myId = pChild.getId();
86 int myIndex = 0;
87 final Iterator<TethysUIComponent> myIterator = iterator();
88 while (myIterator.hasNext()) {
89 final TethysUIComponent myNode = myIterator.next();
90 final Integer myNodeId = myNode.getId();
91
92
93 if (myNodeId == myId) {
94
95 myChildNode.setVisible(true);
96 theFlowPane.getChildren().add(myIndex, myChildNode);
97 break;
98 }
99
100
101 if (TethysUIFXNode.getNode(myNode).isVisible()) {
102 myIndex++;
103 }
104 }
105
106
107 } else {
108
109 myChildNode.setVisible(false);
110 theFlowPane.getChildren().remove(myChildNode);
111 }
112 }
113
114 @Override
115 public void setPreferredWidth(final Integer pWidth) {
116 theFlowPane.setPrefWidth(pWidth);
117 }
118
119 @Override
120 public void setPreferredHeight(final Integer pHeight) {
121 theFlowPane.setPrefHeight(pHeight);
122 }
123
124 @Override
125 public void setBorderPadding(final Integer pPadding) {
126 super.setBorderPadding(pPadding);
127 theNode.createWrapperPane(getBorderTitle(), getBorderPadding());
128 }
129
130 @Override
131 public void setBorderTitle(final String pTitle) {
132 super.setBorderTitle(pTitle);
133 theNode.createWrapperPane(getBorderTitle(), getBorderPadding());
134 }
135 }