Changeset 3862 in josm for trunk/src/org/openstreetmap/josm/gui
- Timestamp:
- 2011-02-06T15:48:58+01:00 (14 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDialog.java
r3848 r3862 7 7 import java.awt.Font; 8 8 import java.awt.GridBagLayout; 9 import java.util.ArrayList; 9 10 import java.util.Collection; 10 11 import java.util.List; … … 34 35 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles; 35 36 import org.openstreetmap.josm.gui.mappaint.MultiCascade; 37 import org.openstreetmap.josm.gui.mappaint.StyleCache; 36 38 import org.openstreetmap.josm.gui.mappaint.StyleCache.StyleList; 37 39 import org.openstreetmap.josm.gui.mappaint.StyleSource; … … 300 302 txtMappaint.append("\n\n"); 301 303 } 304 305 if (sel.size() == 2) { 306 List<OsmPrimitive> selList = new ArrayList<OsmPrimitive>(sel); 307 StyleCache sc1 = selList.get(0).mappaintStyle; 308 StyleCache sc2 = selList.get(1).mappaintStyle; 309 if (sc1 == sc2) { 310 txtMappaint.append("The 2 selected Objects have identical style caches."); 311 } 312 if (!sc1.equals(sc2)) { 313 txtMappaint.append("The 2 selected Objects have different style caches."); 314 } 315 if (sc1.equals(sc2) && sc1 != sc2) { 316 txtMappaint.append("Warning: The 2 selected Objects have equal, but not identical style caches."); 317 } 318 } 302 319 } 303 320 -
trunk/src/org/openstreetmap/josm/gui/mappaint/AreaElemStyle.java
r3859 r3862 3 3 4 4 import java.awt.Color; 5 import java.awt.Rectangle; 6 import java.awt.TexturePaint; 7 import java.awt.image.BufferedImage; 8 9 import javax.swing.ImageIcon; 5 10 6 11 import org.openstreetmap.josm.Main; … … 10 15 import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings; 11 16 import org.openstreetmap.josm.data.osm.visitor.paint.MapPainter; 17 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles.IconReference; 12 18 import org.openstreetmap.josm.tools.Utils; 19 13 20 14 21 public class AreaElemStyle extends ElemStyle 15 22 { 16 23 public Color color; 24 public BufferedImage fillImage; 17 25 18 protected AreaElemStyle(Cascade c, Color color) { 26 protected AreaElemStyle(Cascade c, Color color, BufferedImage fillImage) { 19 27 super(c); 20 28 this.color = color; 29 this.fillImage = fillImage; 21 30 } 22 31 23 32 public static AreaElemStyle create(Cascade c) { 33 BufferedImage fillImage = null; 34 IconReference iconRef = c.get("fill-image", null, IconReference.class); 35 if (iconRef != null) { 36 ImageIcon icon = MapPaintStyles.getIcon(iconRef, false); 37 if (icon != null) { 38 if (!(icon.getImage() instanceof BufferedImage)) { 39 icon = MapPaintStyles.getIcon(iconRef, true); 40 } 41 if (!(icon.getImage() instanceof BufferedImage)) 42 throw new RuntimeException(); 43 fillImage = (BufferedImage) icon.getImage(); 44 } 45 } 46 24 47 Color color = c.get("fill-color", null, Color.class); 25 if (color == null) 48 if (color != null) { 49 50 int alpha = Math.min(255, Math.max(0, Integer.valueOf(Main.pref.getInteger("mappaint.fillalpha", 50)))); 51 Integer pAlpha = color_float2int(c.get("fill-opacity", null, float.class)); 52 if (pAlpha != null) { 53 alpha = pAlpha; 54 } 55 color = new Color(color.getRed(), color.getGreen(), color.getBlue(), alpha); 56 } 57 58 if (fillImage != null || color != null) 59 return new AreaElemStyle(c, color, fillImage); 60 else 26 61 return null; 27 int alpha = Math.min(255, Math.max(0, Integer.valueOf(Main.pref.getInteger("mappaint.fillalpha", 50))));28 Integer pAlpha = color_float2int(c.get("fill-opacity", null, float.class));29 if (pAlpha != null) {30 alpha = pAlpha;31 }32 color = new Color(color.getRed(), color.getGreen(), color.getBlue(), alpha);33 return new AreaElemStyle(c, color);34 62 } 35 63 … … 38 66 if (osm instanceof Way) 39 67 { 40 painter.drawArea((Way) osm, 41 osm.isSelected() ? paintSettings.getSelectedColor(color.getAlpha()) : color, 68 Color myColor = color; 69 if (color != null) { 70 if (osm.isSelected()) { 71 myColor = paintSettings.getSelectedColor(color.getAlpha()); 72 } 73 } 74 painter.drawArea((Way) osm, myColor, fillImage, 42 75 painter.isShowNames() ? painter.getAreaName(osm) : null); 43 76 } else if (osm instanceof Relation) 44 77 { 45 painter.drawArea((Relation) osm, 46 selected ? paintSettings.getRelationSelectedColor(color.getAlpha()) : color, 78 Color myColor = color; 79 if (color != null) { 80 if (selected) { 81 myColor = paintSettings.getRelationSelectedColor(color.getAlpha()); 82 } 83 } 84 painter.drawArea((Relation) osm, myColor, fillImage, 47 85 painter.getAreaName(osm)); 48 86 } … … 55 93 if (!super.equals(obj)) 56 94 return false; 57 return Utils.equal(color, ((AreaElemStyle) obj).color); 95 AreaElemStyle other = (AreaElemStyle) obj; 96 // we should get the same image object due to caching 97 if (fillImage != other.fillImage && (fillImage == null || other.fillImage == null || fillImage != other.fillImage)) 98 return false; 99 if (!Utils.equal(color, other.color)) 100 return false; 101 return true; 58 102 } 59 103 60 104 @Override 61 105 public int hashCode() { 62 return 11 * super.hashCode() + color.hashCode(); 106 int hash = 3; 107 hash = 61 * hash + (this.color != null ? this.color.hashCode() : 0); 108 hash = 61 * hash + (this.fillImage != null ? this.fillImage.hashCode() : 0); 109 return hash; 63 110 } 64 111 -
trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java
r3858 r3862 60 60 } 61 61 62 public static ImageIcon getIcon(IconReference ref) 62 public static ImageIcon getIcon(IconReference ref, boolean sanitize) 63 63 { 64 64 String styleName = ref.source.getPrefName(); … … 78 78 } 79 79 } 80 ImageIcon i = ImageProvider.getIfAvailable(dirs, "mappaint."+styleName, null, ref.iconName, ref.source.zipIcons); 80 ImageIcon i = ImageProvider.getIfAvailable(dirs, "mappaint."+styleName, null, ref.iconName, ref.source.zipIcons, sanitize); 81 81 if(i == null) 82 82 { -
trunk/src/org/openstreetmap/josm/gui/mappaint/NodeElemStyle.java
r3855 r3862 37 37 if (iconRef == null) 38 38 return null; 39 40 ImageIcon icon = MapPaintStyles.getIcon(iconRef);39 ImageIcon icon = MapPaintStyles.getIcon(iconRef, false); 40 41 41 String text = c.get("text", null, String.class); 42 42 -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Instruction.java
r3860 r3862 36 36 public void execute(Environment env) { 37 37 Object value = (val instanceof Expression) ? ((Expression) val).evaluate(env) : val; 38 if (key.equals("icon-image")) { 38 if (key.equals("icon-image") || key.equals("fill-image")) { 39 39 if (value instanceof String) { 40 40 value = new IconReference((String) value, env.source);
Note:
See TracChangeset
for help on using the changeset viewer.