Ignore:
Timestamp:
2020-04-17T20:50:39+02:00 (4 years ago)
Author:
simon04
Message:

fix #18883 - InspectPrimitiveDialog: improve mapstyle summary

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
2 edited

Legend:

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

    r14153 r16322  
    77import java.awt.Dimension;
    88import java.awt.GridBagLayout;
     9import java.io.PrintWriter;
     10import java.io.StringWriter;
    911import java.text.Collator;
    1012import java.util.ArrayList;
     
    118120        double scale = nc.getDist100Pixel();
    119121
    120         final StringBuilder txtMappaint = new StringBuilder();
     122        final StringWriter stringWriter = new StringWriter();
     123        final PrintWriter txtMappaint = new PrintWriter(stringWriter);
    121124        MapCSSStyleSource.STYLE_SOURCE_LOCK.readLock().lock();
    122125        try {
    123126            for (IPrimitive osm : sel) {
    124                 txtMappaint.append(tr("Styles Cache for \"{0}\":", osm.getDisplayName(DefaultNameFormatter.getInstance())));
     127                String heading = tr("Styles for \"{0}\":", osm.getDisplayName(DefaultNameFormatter.getInstance()));
     128                txtMappaint.println(heading);
     129                txtMappaint.println(repeatString("=", heading.length()));
    125130
    126131                MultiCascade mc = new MultiCascade();
     
    128133                for (StyleSource s : elemstyles.getStyleSources()) {
    129134                    if (s.active) {
    130                         txtMappaint.append(tr("\n\n> applying {0} style \"{1}\"\n", getSort(s), s.getDisplayString()));
     135                        heading = tr("{0} style \"{1}\"", getSort(s), s.getDisplayString());
     136                        txtMappaint.println(heading);
     137                        txtMappaint.println(repeatString("-", heading.length()));
    131138                        s.apply(mc, osm, scale, false);
    132                         txtMappaint.append(tr("\nRange:{0}", mc.range));
     139                        txtMappaint.println(tr("Display range: {0}", mc.range));
    133140                        for (Entry<String, Cascade> e : mc.getLayers()) {
    134                             txtMappaint.append("\n ").append(e.getKey()).append(": \n").append(e.getValue());
     141                            txtMappaint.println(tr("Layer {0}", e.getKey()));
     142                            txtMappaint.print(" * ");
     143                            txtMappaint.println(e.getValue());
    135144                        }
    136                     } else {
    137                         txtMappaint.append(tr("\n\n> skipping \"{0}\" (not active)", s.getDisplayString()));
    138145                    }
    139146                }
    140                 txtMappaint.append(tr("\n\nList of generated Styles:\n"));
     147                txtMappaint.println();
     148                heading = tr("List of generated Styles:");
     149                txtMappaint.println(heading);
     150                txtMappaint.println(repeatString("-", heading.length()));
    141151                StyleElementList sl = elemstyles.get(osm, scale, nc);
    142152                for (StyleElement s : sl) {
    143                     txtMappaint.append(" * ").append(s).append('\n');
     153                    txtMappaint.print(" * ");
     154                    txtMappaint.println(s);
    144155                }
    145                 txtMappaint.append("\n\n");
     156                txtMappaint.println();
     157                txtMappaint.println();
    146158            }
    147159        } finally {
     
    153165            StyleCache sc2 = selList.get(1).getCachedStyle();
    154166            if (sc1 == sc2) {
    155                 txtMappaint.append(tr("The 2 selected objects have identical style caches."));
     167                txtMappaint.println(tr("The 2 selected objects have identical style caches."));
    156168            }
    157169            if (!sc1.equals(sc2)) {
    158                 txtMappaint.append(tr("The 2 selected objects have different style caches."));
     170                txtMappaint.println(tr("The 2 selected objects have different style caches."));
    159171            }
    160172            if (sc1 != sc2 && sc1.equals(sc2)) {
    161                 txtMappaint.append(tr("Warning: The 2 selected objects have equal, but not identical style caches."));
    162             }
    163         }
    164         return txtMappaint.toString();
     173                txtMappaint.println(tr("Warning: The 2 selected objects have equal, but not identical style caches."));
     174            }
     175        }
     176        return stringWriter.toString();
     177    }
     178
     179    private static String repeatString(String string, int count) {
     180        // Java 11: use String.repeat
     181        return new String(new char[count]).replace("\0", string);
    165182    }
    166183
     
    201218    private static String getSort(StyleSource s) {
    202219        if (s instanceof MapCSSStyleSource) {
    203             return tr("mapcss");
     220            return "MapCSS";
    204221        } else {
    205             return tr("unknown");
     222            return tr("UNKNOWN");
    206223        }
    207224    }
  • trunk/src/org/openstreetmap/josm/gui/mappaint/Range.java

    r14353 r16322  
    103103    @Override
    104104    public String toString() {
    105         return String.format("|s%s-%s", lower, upper);
     105        return String.format("|z%.4f-%.4f", lower, upper);
    106106    }
    107107
Note: See TracChangeset for help on using the changeset viewer.