Changeset 10198 in josm
- Timestamp:
- 2016-05-12T16:37:14+02:00 (9 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDialog.java
r9965 r10198 25 25 26 26 import org.openstreetmap.josm.Main; 27 import org.openstreetmap.josm.data.conflict.Conflict;28 import org.openstreetmap.josm.data.coor.EastNorth;29 import org.openstreetmap.josm.data.osm.BBox;30 import org.openstreetmap.josm.data.osm.Node;31 27 import org.openstreetmap.josm.data.osm.OsmPrimitive; 32 28 import org.openstreetmap.josm.data.osm.OsmPrimitiveComparator; 33 import org.openstreetmap.josm.data.osm.Relation;34 import org.openstreetmap.josm.data.osm.RelationMember;35 import org.openstreetmap.josm.data.osm.Way;36 29 import org.openstreetmap.josm.gui.DefaultNameFormatter; 37 30 import org.openstreetmap.josm.gui.ExtendedDialog; … … 50 43 import org.openstreetmap.josm.gui.widgets.JosmTextArea; 51 44 import org.openstreetmap.josm.tools.GBC; 52 import org.openstreetmap.josm.tools.Geometry;53 45 import org.openstreetmap.josm.tools.WindowGeometry; 54 import org.openstreetmap.josm.tools.date.DateUtils;55 46 56 47 /** … … 68 59 private boolean editcountTabLoaded; 69 60 70 public InspectPrimitiveDialog(Collection<OsmPrimitive> primitives, OsmDataLayer layer) { 61 /** 62 * Constructs a new {@code InspectPrimitiveDialog}. 63 * @param primitives collection of primitives 64 * @param layer data layer 65 */ 66 public InspectPrimitiveDialog(final Collection<OsmPrimitive> primitives, OsmDataLayer layer) { 71 67 super(Main.parent, tr("Advanced object info"), new String[] {tr("Close")}); 72 68 this.primitives = new ArrayList<>(primitives); … … 78 74 final JTabbedPane tabs = new JTabbedPane(); 79 75 80 tabs.addTab(tr("data"), genericMonospacePanel(new JPanel(), buildDataText( )));76 tabs.addTab(tr("data"), genericMonospacePanel(new JPanel(), buildDataText(layer, this.primitives))); 81 77 82 78 final JPanel pMapPaint = new JPanel(); … … 101 97 if (!editcountTabLoaded && ((SingleSelectionModel) e.getSource()).getSelectedIndex() == 2) { 102 98 editcountTabLoaded = true; 103 genericMonospacePanel(pEditCounts, buildListOfEditorsText( ));99 genericMonospacePanel(pEditCounts, buildListOfEditorsText(primitives)); 104 100 } 105 101 } … … 109 105 } 110 106 111 protected JPanel genericMonospacePanel(JPanel p, String s) {107 protected static JPanel genericMonospacePanel(JPanel p, String s) { 112 108 p.setLayout(new GridBagLayout()); 113 109 JosmTextArea jte = new JosmTextArea(); … … 119 115 } 120 116 121 protected String buildDataText() {122 DataText dt = new DataText();117 protected static String buildDataText(OsmDataLayer layer, List<OsmPrimitive> primitives) { 118 InspectPrimitiveDataText dt = new InspectPrimitiveDataText(layer); 123 119 Collections.sort(primitives, new OsmPrimitiveComparator()); 124 120 for (OsmPrimitive o : primitives) { … … 128 124 } 129 125 130 class DataText { 131 private static final String INDENT = " "; 132 private static final char NL = '\n'; 133 134 private final StringBuilder s = new StringBuilder(); 135 136 private DataText add(String title, String... values) { 137 s.append(INDENT).append(title); 138 for (String v : values) { 139 s.append(v); 140 } 141 s.append(NL); 142 return this; 143 } 144 145 private String getNameAndId(String name, long id) { 146 if (name != null) { 147 return name + tr(" ({0})", /* sic to avoid thousand seperators */ Long.toString(id)); 148 } else { 149 return Long.toString(id); 150 } 151 } 152 153 public void addPrimitive(OsmPrimitive o) { 154 155 addHeadline(o); 156 157 if (!(o.getDataSet() != null && o.getDataSet().getPrimitiveById(o) != null)) { 158 s.append(NL).append(INDENT).append(tr("not in data set")).append(NL); 159 return; 160 } 161 if (o.isIncomplete()) { 162 s.append(NL).append(INDENT).append(tr("incomplete")).append(NL); 163 return; 164 } 165 s.append(NL); 166 167 addState(o); 168 addCommon(o); 169 addAttributes(o); 170 addSpecial(o); 171 addReferrers(s, o); 172 addConflicts(o); 173 s.append(NL); 174 } 175 176 void addHeadline(OsmPrimitive o) { 177 addType(o); 178 addNameAndId(o); 179 } 180 181 void addType(OsmPrimitive o) { 182 if (o instanceof Node) { 183 s.append(tr("Node: ")); 184 } else if (o instanceof Way) { 185 s.append(tr("Way: ")); 186 } else if (o instanceof Relation) { 187 s.append(tr("Relation: ")); 188 } 189 } 190 191 void addNameAndId(OsmPrimitive o) { 192 String name = o.get("name"); 193 if (name == null) { 194 s.append(o.getUniqueId()); 195 } else { 196 s.append(getNameAndId(name, o.getUniqueId())); 197 } 198 } 199 200 void addState(OsmPrimitive o) { 201 StringBuilder sb = new StringBuilder(INDENT); 202 /* selected state is left out: not interesting as it is always selected */ 203 if (o.isDeleted()) { 204 sb.append(tr("deleted")).append(INDENT); 205 } 206 if (!o.isVisible()) { 207 sb.append(tr("deleted-on-server")).append(INDENT); 208 } 209 if (o.isModified()) { 210 sb.append(tr("modified")).append(INDENT); 211 } 212 if (o.isDisabledAndHidden()) { 213 sb.append(tr("filtered/hidden")).append(INDENT); 214 } 215 if (o.isDisabled()) { 216 sb.append(tr("filtered/disabled")).append(INDENT); 217 } 218 if (o.hasDirectionKeys()) { 219 if (o.reversedDirection()) { 220 sb.append(tr("has direction keys (reversed)")).append(INDENT); 221 } else { 222 sb.append(tr("has direction keys")).append(INDENT); 223 } 224 } 225 String state = sb.toString().trim(); 226 if (!state.isEmpty()) { 227 add(tr("State: "), sb.toString().trim()); 228 } 229 } 230 231 void addCommon(OsmPrimitive o) { 232 add(tr("Data Set: "), Integer.toHexString(o.getDataSet().hashCode())); 233 add(tr("Edited at: "), o.isTimestampEmpty() ? tr("<new object>") 234 : DateUtils.fromTimestamp(o.getRawTimestamp())); 235 add(tr("Edited by: "), o.getUser() == null ? tr("<new object>") 236 : getNameAndId(o.getUser().getName(), o.getUser().getId())); 237 add(tr("Version: "), Integer.toString(o.getVersion())); 238 add(tr("In changeset: "), Integer.toString(o.getChangesetId())); 239 } 240 241 void addAttributes(OsmPrimitive o) { 242 if (o.hasKeys()) { 243 add(tr("Tags: ")); 244 for (String key : o.keySet()) { 245 s.append(INDENT).append(INDENT); 246 s.append(String.format("\"%s\"=\"%s\"%n", key, o.get(key))); 247 } 248 } 249 } 250 251 void addSpecial(OsmPrimitive o) { 252 if (o instanceof Node) { 253 addCoordinates((Node) o); 254 } else if (o instanceof Way) { 255 addBbox(o); 256 add(tr("Centroid: "), Main.getProjection().eastNorth2latlon( 257 Geometry.getCentroid(((Way) o).getNodes())).toStringCSV(", ")); 258 addWayNodes((Way) o); 259 } else if (o instanceof Relation) { 260 addBbox(o); 261 addRelationMembers((Relation) o); 262 } 263 } 264 265 void addRelationMembers(Relation r) { 266 add(trn("{0} Member: ", "{0} Members: ", r.getMembersCount(), r.getMembersCount())); 267 for (RelationMember m : r.getMembers()) { 268 s.append(INDENT).append(INDENT); 269 addHeadline(m.getMember()); 270 s.append(tr(" as \"{0}\"", m.getRole())); 271 s.append(NL); 272 } 273 } 274 275 void addWayNodes(Way w) { 276 add(tr("{0} Nodes: ", w.getNodesCount())); 277 for (Node n : w.getNodes()) { 278 s.append(INDENT).append(INDENT); 279 addNameAndId(n); 280 s.append(NL); 281 } 282 } 283 284 void addBbox(OsmPrimitive o) { 285 BBox bbox = o.getBBox(); 286 if (bbox != null) { 287 add(tr("Bounding box: "), bbox.toStringCSV(", ")); 288 EastNorth bottomRigth = Main.getProjection().latlon2eastNorth(bbox.getBottomRight()); 289 EastNorth topLeft = Main.getProjection().latlon2eastNorth(bbox.getTopLeft()); 290 add(tr("Bounding box (projected): "), 291 Double.toString(topLeft.east()), ", ", 292 Double.toString(bottomRigth.north()), ", ", 293 Double.toString(bottomRigth.east()), ", ", 294 Double.toString(topLeft.north())); 295 add(tr("Center of bounding box: "), bbox.getCenter().toStringCSV(", ")); 296 } 297 } 298 299 void addCoordinates(Node n) { 300 if (n.getCoor() != null) { 301 add(tr("Coordinates: "), 302 Double.toString(n.getCoor().lat()), ", ", 303 Double.toString(n.getCoor().lon())); 304 add(tr("Coordinates (projected): "), 305 Double.toString(n.getEastNorth().east()), ", ", 306 Double.toString(n.getEastNorth().north())); 307 } 308 } 309 310 void addReferrers(StringBuilder s, OsmPrimitive o) { 311 List<OsmPrimitive> refs = o.getReferrers(); 312 if (!refs.isEmpty()) { 313 add(tr("Part of: ")); 314 for (OsmPrimitive p : refs) { 315 s.append(INDENT).append(INDENT); 316 addHeadline(p); 317 s.append(NL); 318 } 319 } 320 } 321 322 void addConflicts(OsmPrimitive o) { 323 Conflict<?> c = layer.getConflicts().getConflictForMy(o); 324 if (c != null) { 325 add(tr("In conflict with: ")); 326 addNameAndId(c.getTheir()); 327 } 328 } 329 330 @Override 331 public String toString() { 332 return s.toString(); 333 } 334 } 335 336 protected String buildMapPaintText() { 126 protected static String buildMapPaintText() { 337 127 final Collection<OsmPrimitive> sel = Main.main.getCurrentDataSet().getAllSelected(); 338 128 ElemStyles elemstyles = MapPaintStyles.getStyles(); … … 392 182 Count only tagged nodes (so empty way nodes don't inflate counts). 393 183 */ 394 protected String buildListOfEditorsText() {184 protected static String buildListOfEditorsText(Iterable<OsmPrimitive> primitives) { 395 185 final StringBuilder s = new StringBuilder(); 396 186 final Map<String, Integer> editCountByUser = new TreeMap<>(Collator.getInstance(Locale.getDefault())); … … 416 206 final String username = entry.getKey(); 417 207 final Integer editCount = entry.getValue(); 418 s.append(String.format("%6d %s %n", editCount, username));208 s.append(String.format("%6d %s\n", editCount, username)); 419 209 } 420 210 return s.toString(); -
trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/NodeElement.java
r10001 r10198 241 241 242 242 Stroke stroke = null; 243 if (strokeColor != null ) {243 if (strokeColor != null && strokeWidth != null) { 244 244 Integer strokeAlpha = Utils.color_float2int(c.get("symbol-stroke-opacity", null, Float.class)); 245 245 if (strokeAlpha != null) {
Note:
See TracChangeset
for help on using the changeset viewer.