- Timestamp:
- 2017-04-01T01:23:56+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java
r11713 r11809 231 231 232 232 private BoundingXYVisitor getBoundingBox() { 233 BoundingXYVisitor v = "problem".equals(mode) ? new ValidatorBoundingXYVisitor() : new BoundingXYVisitor();234 235 233 switch (mode) { 236 234 case "problem": 237 return modeProblem( (ValidatorBoundingXYVisitor) v);235 return modeProblem(new ValidatorBoundingXYVisitor()); 238 236 case "data": 239 return modeData( v);237 return modeData(new BoundingXYVisitor()); 240 238 case "layer": 241 return modeLayer( v);239 return modeLayer(new BoundingXYVisitor()); 242 240 case "selection": 243 241 case "conflict": 244 return modeSelectionOrConflict( v);242 return modeSelectionOrConflict(new BoundingXYVisitor()); 245 243 case "download": 246 return modeDownload( v);244 return modeDownload(new BoundingXYVisitor()); 247 245 default: 248 return v;246 return new BoundingXYVisitor(); 249 247 } 250 248 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/layer/LayerListTransferHandler.java
r11452 r11809 33 33 @Override 34 34 public int getSourceActions(JComponent c) { 35 // we know that the source is a layer list, so don't check c. 36 LayerListModel tableModel = (LayerListModel) ((JTable) c).getModel(); 37 if (tableModel.getSelectedLayers().isEmpty()) { 38 return 0; 35 if (c instanceof JTable) { 36 LayerListModel tableModel = (LayerListModel) ((JTable) c).getModel(); 37 if (!tableModel.getSelectedLayers().isEmpty()) { 38 int actions = MOVE; 39 if (onlyDataLayersSelected(tableModel)) { 40 actions |= COPY; 41 } 42 return actions /* soon: | LINK*/; 43 } 39 44 } 40 int actions = MOVE; 41 if (onlyDataLayersSelected(tableModel)) { 42 actions |= COPY; 43 } 44 return actions /* soon: | LINK*/; 45 return NONE; 45 46 } 46 47 … … 56 57 @Override 57 58 protected Transferable createTransferable(JComponent c) { 58 LayerListModel tableModel = (LayerListModel) ((JTable) c).getModel(); 59 return new LayerTransferable(tableModel.getLayerManager(), tableModel.getSelectedLayers()); 59 if (c instanceof JTable) { 60 LayerListModel tableModel = (LayerListModel) ((JTable) c).getModel(); 61 return new LayerTransferable(tableModel.getLayerManager(), tableModel.getSelectedLayers()); 62 } 63 return null; 60 64 } 61 65 -
trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/LineElement.java
r11553 r11809 70 70 public void paintPrimitive(OsmPrimitive primitive, MapPaintSettings paintSettings, StyledMapRenderer painter, 71 71 boolean selected, boolean outermember, boolean member) { 72 Way w = (Way) primitive;73 72 /* show direction arrows, if draw.segment.relevant_directions_only is not set, 74 73 the way is tagged with a direction key … … 82 81 boolean showOneway = !isModifier && !selected && 83 82 !paintSettings.isUseRealWidth() && 84 paintSettings.isShowOnewayArrow() && w.hasDirectionKeys();85 boolean onewayReversed = w.reversedDirection();83 paintSettings.isShowOnewayArrow() && primitive.hasDirectionKeys(); 84 boolean onewayReversed = primitive.reversedDirection(); 86 85 /* head only takes over control if the option is true, 87 86 the direction should be shown at all and not only because it's selected */ … … 109 108 } else if (member || outermember) { 110 109 myColor = paintSettings.getRelationSelectedColor(color.getAlpha()); 111 } else if ( w.isDisabled()) {110 } else if (primitive.isDisabled()) { 112 111 myColor = paintSettings.getInactiveColor(); 113 112 myDashedColor = paintSettings.getInactiveColor(); 114 113 } 115 114 116 painter.drawWay(w, myColor, myLine, myDashLine, myDashedColor, offset, showOrientation, 117 showOnlyHeadArrowOnly, showOneway, onewayReversed); 118 119 if ((paintSettings.isShowOrderNumber() || (paintSettings.isShowOrderNumberOnSelectedWay() && selected)) 120 && !painter.isInactiveMode()) { 121 int orderNumber = 0; 122 lastN = null; 123 for (Node n : w.getNodes()) { 124 if (lastN != null) { 125 orderNumber++; 126 painter.drawOrderNumber(lastN, n, orderNumber, myColor); 127 } 128 lastN = n; 115 if (primitive instanceof Way) { 116 Way w = (Way) primitive; 117 painter.drawWay(w, myColor, myLine, myDashLine, myDashedColor, offset, showOrientation, 118 showOnlyHeadArrowOnly, showOneway, onewayReversed); 119 120 if ((paintSettings.isShowOrderNumber() || (paintSettings.isShowOrderNumberOnSelectedWay() && selected)) 121 && !painter.isInactiveMode()) { 122 int orderNumber = 0; 123 lastN = null; 124 for (Node n : w.getNodes()) { 125 if (lastN != null) { 126 orderNumber++; 127 painter.drawOrderNumber(lastN, n, orderNumber, myColor); 128 } 129 lastN = n; 130 } 129 131 } 130 132 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/RepeatImageElement.java
r11452 r11809 81 81 public void paintPrimitive(OsmPrimitive primitive, MapPaintSettings paintSettings, StyledMapRenderer painter, 82 82 boolean selected, boolean outermember, boolean member) { 83 Way w = (Way) primitive; 84 painter.drawRepeatImage(w, pattern, painter.isInactiveMode() || w.isDisabled(), offset, spacing, phase, align); 83 if (primitive instanceof Way) { 84 Way w = (Way) primitive; 85 painter.drawRepeatImage(w, pattern, painter.isInactiveMode() || w.isDisabled(), offset, spacing, phase, align); 86 } 85 87 } 86 88 -
trunk/src/org/openstreetmap/josm/gui/widgets/JosmTextField.java
r8510 r11809 151 151 // Taken from http://stackoverflow.com/a/24571681/2257172 152 152 int h = getHeight(); 153 ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); 153 if (g instanceof Graphics2D) { 154 ((Graphics2D) g).setRenderingHint( 155 RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); 156 } 154 157 Insets ins = getInsets(); 155 158 FontMetrics fm = g.getFontMetrics(); -
trunk/src/org/openstreetmap/josm/gui/widgets/MultiSplitPane.java
r10600 r11809 158 158 @Override 159 159 public void paint(Graphics g, Divider divider) { 160 if ( (divider == activeDivider()) && !isContinuousLayout()) {160 if (g instanceof Graphics2D && divider == activeDivider() && !isContinuousLayout()) { 161 161 Graphics2D g2d = (Graphics2D) g; 162 162 g2d.setColor(Color.black); -
trunk/src/org/openstreetmap/josm/io/MultiFetchServerObjectReader.java
r11702 r11809 211 211 */ 212 212 public MultiFetchServerObjectReader append(OsmPrimitive primitive) { 213 if (primitive != null) { 214 switch (OsmPrimitiveType.from(primitive)) { 215 case NODE: return appendNode((Node) primitive); 216 case WAY: return appendWay((Way) primitive); 217 case RELATION: return appendRelation((Relation) primitive); 218 default: break; 219 } 213 if (primitive instanceof Node) { 214 return appendNode((Node) primitive); 215 } else if (primitive instanceof Way) { 216 return appendWay((Way) primitive); 217 } else if (primitive instanceof Relation) { 218 return appendRelation((Relation) primitive); 220 219 } 221 220 return this; -
trunk/src/org/openstreetmap/josm/io/OsmExporter.java
r11386 r11809 64 64 */ 65 65 public void exportData(File file, Layer layer, boolean noBackup) { 66 checkOsmDataLayer(layer); 66 if (!(layer instanceof OsmDataLayer)) { 67 throw new IllegalArgumentException( 68 MessageFormat.format("Expected instance of OsmDataLayer. Got ''{0}''.", layer.getClass().getName())); 69 } 67 70 save(file, (OsmDataLayer) layer, noBackup); 68 }69 70 protected static void checkOsmDataLayer(Layer layer) {71 if (!(layer instanceof OsmDataLayer)) {72 throw new IllegalArgumentException(MessageFormat.format("Expected instance of OsmDataLayer. Got ''{0}''.", layer73 .getClass().getName()));74 }75 71 } 76 72 -
trunk/src/org/openstreetmap/josm/io/remotecontrol/DNSName.java
r9344 r11809 203 203 constraintType = NAME_DIFF_TYPE; 204 204 else { 205 if (!(inputName instanceof DNSName)) { 206 throw new IllegalArgumentException("inputName: " + inputName); 207 } 205 208 String inName = 206 209 (((DNSName) inputName).getName()).toLowerCase(Locale.ENGLISH); -
trunk/src/org/openstreetmap/josm/tools/template_engine/ContextSwitchTemplate.java
r10659 r11809 23 23 public class ContextSwitchTemplate implements TemplateEntry { 24 24 25 private static final TemplateEngineDataProvider EM TPY_PROVIDER = new TemplateEngineDataProvider() {25 private static final TemplateEngineDataProvider EMPTY_PROVIDER = new TemplateEngineDataProvider() { 26 26 @Override 27 27 public Object getTemplateValue(String name, boolean special) { … … 258 258 @Override 259 259 public void appendText(StringBuilder result, TemplateEngineDataProvider dataProvider) { 260 List<OsmPrimitive> primitives = context.getPrimitives((OsmPrimitive) dataProvider); 261 if (primitives != null && !primitives.isEmpty()) { 262 template.appendText(result, primitives.get(0)); 263 } else { 264 template.appendText(result, EMTPY_PROVIDER); 265 } 260 if (dataProvider instanceof OsmPrimitive) { 261 List<OsmPrimitive> primitives = context.getPrimitives((OsmPrimitive) dataProvider); 262 if (primitives != null && !primitives.isEmpty()) { 263 template.appendText(result, primitives.get(0)); 264 } 265 } 266 template.appendText(result, EMPTY_PROVIDER); 266 267 } 267 268 268 269 @Override 269 270 public boolean isValid(TemplateEngineDataProvider dataProvider) { 270 List<OsmPrimitive> primitives = context.getPrimitives((OsmPrimitive) dataProvider); 271 if (primitives != null && !primitives.isEmpty()) 272 return template.isValid(primitives.get(0)); 273 else 274 return false; 275 } 276 271 if (dataProvider instanceof OsmPrimitive) { 272 List<OsmPrimitive> primitives = context.getPrimitives((OsmPrimitive) dataProvider); 273 if (primitives != null && !primitives.isEmpty()) { 274 return template.isValid(primitives.get(0)); 275 } 276 } 277 return false; 278 } 277 279 }
Note:
See TracChangeset
for help on using the changeset viewer.