Ignore:
Timestamp:
2010-01-07T07:58:44+01:00 (14 years ago)
Author:
jttt
Message:

Workaround division by zero exception when geoimage layer is added as first layer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/DialogsPanel.java

    r2711 r2749  
    4040        allDialogs = new ArrayList<ToggleDialog>();
    4141
    42         for (Integer i=0; i < pAllDialogs.size(); ++i) {
    43             add(pAllDialogs.get(i), false);
     42        for (ToggleDialog dialog: pAllDialogs) {
     43            add(dialog, false);
    4444        }
    4545
     
    106106        /*  INVISIBLE_TO_COLLAPSED,    does not happen */
    107107        ELEMENT_SHRINKS         /* else. (Remaining elements have more space.) */
    108     };
     108    }
    109109    /**
    110110     * Reconstruct the view, if the configurations of dialogs has changed.
     
    119119         * reset the panels
    120120         */
    121         for (int i=0; i < N; ++i) {
    122             final JPanel p = panels.get(i);
     121        for (JPanel p: panels) {
    123122            p.removeAll();
    124123            p.setVisible(false);
     
    180179            int sumC = 0;   // sum of heights of all collapsed dialogs (triggering dialog is never collapsed)
    181180
    182             for (int i=0; i<N; ++i) {
    183                 final ToggleDialog dlg = allDialogs.get(i);
     181            for (ToggleDialog dlg: allDialogs) {
    184182                if (dlg.isDialogInDefaultView()) {
    185183                    if (dlg != triggeredBy) {
    186184                        final int ph = dlg.getPreferredHeight();
    187                         final int ah = dlg.getSize().height;
     185                        final int ah = dlg.getHeight();
    188186                        sumP += ph;
    189187                        sumA += ah;
    190188                    }
    191                 }
    192                 else if (dlg.isDialogInCollapsedView()) {
    193                     sumC += dlg.getSize().height;
     189                } else if (dlg.isDialogInCollapsedView()) {
     190                    sumC += dlg.getHeight();
    194191                }
    195192            }
     
    234231                final ToggleDialog dlg = allDialogs.get(i);
    235232                if (dlg.isDialogInDefaultView() && dlg != triggeredBy) {
    236                     final int ha = dlg.getSize().height;
     233                    final int ha = dlg.getHeight();
    237234                    final int h0 = ha * R / sumA;
    238235                    final int he = dlg.getPreferredHeight() * s2 / (sumP + hp_trig);
     
    246243                        } catch (ArithmeticException e) { /* D_p may be zero - nothing wrong with that. */
    247244                            d = 0;
    248                         };
     245                        }
    249246                        dlg.setPreferredSize(new Dimension(Integer.MAX_VALUE, h0 - d));
    250247                    }
Note: See TracChangeset for help on using the changeset viewer.