Changeset 10001 in josm for trunk/src/org/openstreetmap/josm/gui/dialogs/DialogsPanel.java
- Timestamp:
- 2016-03-17T01:50:12+01:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/DialogsPanel.java
r9078 r10001 107 107 public void reconstruct(Action action, ToggleDialog triggeredBy) { 108 108 109 final int N= allDialogs.size();109 final int n = allDialogs.size(); 110 110 111 111 /** … … 126 126 * in the last panel anyway. 127 127 */ 128 JPanel p = panels.get( N-1); // current Panel (start with last one)128 JPanel p = panels.get(n-1); // current Panel (start with last one) 129 129 int k = -1; // indicates that current Panel index is N-1, but no default-view-Dialog has been added to this Panel yet. 130 for (int i = N-1; i >= 0; --i) {130 for (int i = n-1; i >= 0; --i) { 131 131 final ToggleDialog dlg = allDialogs.get(i); 132 132 if (dlg.isDialogInDefaultView()) { 133 133 if (k == -1) { 134 k = N-1;134 k = n-1; 135 135 } else { 136 136 --k; … … 146 146 147 147 if (k == -1) { 148 k = N-1;149 } 150 final int numPanels = N- k;148 k = n-1; 149 } 150 final int numPanels = n - k; 151 151 152 152 /** … … 154 154 */ 155 155 if (action == Action.ELEMENT_SHRINKS) { 156 for (int i = 0; i < N; ++i) {156 for (int i = 0; i < n; ++i) { 157 157 final ToggleDialog dlg = allDialogs.get(i); 158 158 if (dlg.isDialogInDefaultView()) { … … 191 191 192 192 /** total Height */ 193 final int H= mSpltPane.getMultiSplitLayout().getModel().getBounds().getSize().height;193 final int h = mSpltPane.getMultiSplitLayout().getModel().getBounds().getSize().height; 194 194 195 195 /** space, that is available for dialogs in default view (after the reconfiguration) */ 196 final int s2 = H- (numPanels - 1) * DIVIDER_SIZE - sumC;197 198 final int hp _trig = triggeredBy.getPreferredHeight();199 if (hp _trig <= 0) throw new IllegalStateException(); // Must be positive196 final int s2 = h - (numPanels - 1) * DIVIDER_SIZE - sumC; 197 198 final int hpTrig = triggeredBy.getPreferredHeight(); 199 if (hpTrig <= 0) throw new IllegalStateException(); // Must be positive 200 200 201 201 /** The new dialog gets a fair share */ 202 final int hn _trig = hp_trig * s2 / (hp_trig + sumP);203 triggeredBy.setPreferredSize(new Dimension(Integer.MAX_VALUE, hn _trig));202 final int hnTrig = hpTrig * s2 / (hpTrig + sumP); 203 triggeredBy.setPreferredSize(new Dimension(Integer.MAX_VALUE, hnTrig)); 204 204 205 205 /** This is remainig for the other default view dialogs */ 206 final int R= s2 - hn_trig;206 final int r = s2 - hnTrig; 207 207 208 208 /** 209 209 * Take space only from dialogs that are relatively large 210 210 */ 211 int D_m = 0; // additional space needed by the small dialogs212 int D_p = 0; // available space from the large dialogs213 for (int i = 0; i < N; ++i) {211 int dm = 0; // additional space needed by the small dialogs 212 int dp = 0; // available space from the large dialogs 213 for (int i = 0; i < n; ++i) { 214 214 final ToggleDialog dlg = allDialogs.get(i); 215 215 if (dlg.isDialogInDefaultView() && dlg != triggeredBy) { 216 216 final int ha = dlg.getSize().height; // current 217 final int h0 = ha * R/ sumA; // proportional shrinking218 final int he = dlg.getPreferredHeight() * s2 / (sumP + hp _trig); // fair share217 final int h0 = ha * r / sumA; // proportional shrinking 218 final int he = dlg.getPreferredHeight() * s2 / (sumP + hpTrig); // fair share 219 219 if (h0 < he) { // dialog is relatively small 220 220 int hn = Math.min(ha, he); // shrink less, but do not grow 221 D_m += hn - h0;221 dm += hn - h0; 222 222 } else { // dialog is relatively large 223 D_p += h0 - he;223 dp += h0 - he; 224 224 } 225 225 } 226 226 } 227 227 /** adjust, without changing the sum */ 228 for (int i = 0; i < N; ++i) {228 for (int i = 0; i < n; ++i) { 229 229 final ToggleDialog dlg = allDialogs.get(i); 230 230 if (dlg.isDialogInDefaultView() && dlg != triggeredBy) { 231 231 final int ha = dlg.getHeight(); 232 final int h0 = ha * R/ sumA;233 final int he = dlg.getPreferredHeight() * s2 / (sumP + hp _trig);232 final int h0 = ha * r / sumA; 233 final int he = dlg.getPreferredHeight() * s2 / (sumP + hpTrig); 234 234 if (h0 < he) { 235 235 int hn = Math.min(ha, he); … … 238 238 int d; 239 239 try { 240 d = (h0-he) * D_m / D_p;240 d = (h0-he) * dm / dp; 241 241 } catch (ArithmeticException e) { /* D_p may be zero - nothing wrong with that. */ 242 242 d = 0; … … 253 253 final List<Node> ch = new ArrayList<>(); 254 254 255 for (int i = k; i <= N-1; ++i) {255 for (int i = k; i <= n-1; ++i) { 256 256 if (i != k) { 257 257 ch.add(new Divider()); … … 279 279 * Hide the Panel, if there is nothing to show 280 280 */ 281 if (numPanels == 1 && panels.get( N-1).getComponents().length == 0) {281 if (numPanels == 1 && panels.get(n-1).getComponents().length == 0) { 282 282 parent.setDividerSize(0); 283 283 this.setVisible(false);
Note:
See TracChangeset
for help on using the changeset viewer.
