- Timestamp:
- 2009-01-11T20:11:07+01:00 (16 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r1214 r1254 19 19 import org.openstreetmap.josm.tools.DateParser; 20 20 import org.openstreetmap.josm.Main; 21 import org.openstreetmap.josm.gui.mappaint.ElemStyle; 21 22 22 23 … … 139 140 private static Collection<String> directionKeys = null; 140 141 142 143 /* mappaint style cache */ 144 public ElemStyle mappaintStyle = null; 145 public boolean isMappaintArea = false; 146 141 147 /** 142 148 * Implementation of the visitor scheme. Subclasses have to call the correct … … 214 220 checkTagged(); 215 221 checkDirectionTagged(); 222 mappaintStyle = null; 216 223 } 217 224 /** … … 226 233 checkTagged(); 227 234 checkDirectionTagged(); 235 mappaintStyle = null; 228 236 } 229 237 … … 262 270 tagged = osm.tagged; 263 271 incomplete = osm.incomplete; 272 mappaintStyle = null; 264 273 } 265 274 -
trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java
r1240 r1254 53 53 protected Collection<OsmPrimitive> alreadyDrawn; 54 54 protected Collection<Way> alreadyDrawnAreas; 55 protected Boolean useStyleCache; 56 57 protected int profilerVisibleNodes; 58 protected int profilerVisibleWays; 59 protected int profilerVisibleAreas; 55 60 56 61 protected boolean isZoomOk(ElemStyle e) { … … 67 72 // XXX - do we need a Preference setting for this (if things vary widely)? 68 73 return !(circum >= e.maxScale / 22 || circum < e.minScale / 22); 74 } 75 76 public ElemStyle getPrimitiveStyle(OsmPrimitive osm) { 77 if(!useStyleCache) 78 return (styles != null) ? (IconElemStyle)styles.get(osm) : null; 79 80 if(osm.mappaintStyle == null) { 81 osm.mappaintStyle = styles.get(osm); 82 osm.isMappaintArea = styles.isArea(osm); 83 } 84 return osm.mappaintStyle; 85 } 86 87 public boolean isPrimitiveArea(OsmPrimitive osm) { 88 if(!useStyleCache) 89 return styles.isArea((Way)osm); 90 91 if(osm.mappaintStyle == null) { 92 osm.mappaintStyle = styles.get(osm); 93 osm.isMappaintArea = styles.isArea(osm); 94 } 95 return osm.isMappaintArea; 69 96 } 70 97 … … 80 107 if ((!selectedCall && n.selected) || (p.x < 0) || (p.y < 0) 81 108 || (p.x > nc.getWidth()) || (p.y > nc.getHeight())) return; 82 83 IconElemStyle nodeStyle = styles != null ? (IconElemStyle)styles.get(n) : null; 109 110 profilerVisibleNodes++; 111 112 IconElemStyle nodeStyle = (IconElemStyle)getPrimitiveStyle(n); 84 113 if (nodeStyle != null && isZoomOk(nodeStyle)) 85 114 drawNode(n, nodeStyle.icon, nodeStyle.annotate, n.selected); … … 104 133 if(!isPolygonVisible(polygon)) 105 134 return; 106 107 ElemStyle wayStyle = styles != null ? styles.get(w) : null;135 136 ElemStyle wayStyle = getPrimitiveStyle(w); 108 137 109 138 if(!isZoomOk(wayStyle)) 110 139 return; 111 140 112 LineElemStyle l = null; 113 Color areacolor = untaggedColor; 114 if(wayStyle!=null) 115 { 116 if(wayStyle instanceof LineElemStyle) 117 l = (LineElemStyle)wayStyle; 118 else if (wayStyle instanceof AreaElemStyle) 119 { 120 areacolor = ((AreaElemStyle)wayStyle).color; 121 l = ((AreaElemStyle)wayStyle).line; 122 if (fillAreas) 123 drawArea(polygon, w.selected ? selectedColor : areacolor); 124 } 125 } 126 127 drawWay(w, l, areacolor, w.selected); 141 if(wayStyle==null) 142 { 143 // way without style 144 profilerVisibleWays++; 145 drawWay(w, null, untaggedColor, w.selected); 146 } 147 else if(wayStyle instanceof LineElemStyle) 148 { 149 // way with line style 150 profilerVisibleWays++; 151 drawWay(w, (LineElemStyle)wayStyle, untaggedColor, w.selected); 152 } 153 else if (wayStyle instanceof AreaElemStyle) 154 { 155 // way with area style 156 if (fillAreas) 157 { 158 profilerVisibleAreas++; 159 drawArea(polygon, w.selected ? selectedColor : ((AreaElemStyle)wayStyle).color); 160 } 161 drawWay(w, ((AreaElemStyle)wayStyle).line, ((AreaElemStyle)wayStyle).color, w.selected); 162 } 128 163 } 129 164 … … 785 820 786 821 boolean profiler = Main.pref.getBoolean("mappaint.profiler",false); 822 useStyleCache = Main.pref.getBoolean("mappaint.cache",true); 823 fillAreas = Main.pref.getBoolean("mappaint.fillareas", true); 824 fillAlpha = Math.min(255, Math.max(0, Integer.valueOf(Main.pref.getInteger("mappaint.fillalpha", 50)))); 825 787 826 long profilerStart = java.lang.System.currentTimeMillis(); 788 827 long profilerLast = profilerStart; 789 828 int profilerN; 790 829 if(profiler) 791 { 792 System.out.println("Mappaint Profiler"); 793 } 830 System.out.println("Mappaint Profiler (" + 831 (useStyleCache ? "cache=true, " : "cache=false, ") + 832 (fillAreas ? "fillareas=true, " : "fillareas=false, ") + 833 "fillalpha=" + fillAlpha + "%)"); 794 834 795 835 getSettings(virtual); 796 836 useRealWidth = Main.pref.getBoolean("mappaint.useRealWidth",false); 797 837 zoomLevelDisplay = Main.pref.getBoolean("mappaint.zoomLevelDisplay",false); 798 fillAreas = Main.pref.getBoolean("mappaint.fillareas", true);799 fillAlpha = Math.min(255, Math.max(0, Integer.valueOf(Main.pref.getInteger("mappaint.fillalpha", 50))));800 838 circum = Main.map.mapView.getScale()*100*Main.proj.scaleFactor()*40041455; // circumference of the earth in meter 801 839 styles = MapPaintStyles.getStyles().getStyleSet(); … … 808 846 alreadyDrawnAreas = new LinkedList<Way>(); 809 847 selectedCall = false; 848 849 profilerVisibleNodes = 0; 850 profilerVisibleWays = 0; 851 profilerVisibleAreas = 0; 810 852 811 853 if(profiler) … … 831 873 if(profiler) 832 874 { 833 System.out.format("Relations: %4dms, n=%d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN); 875 System.out.format("Relations: %4dms, n=%5d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN); 834 876 profilerLast = java.lang.System.currentTimeMillis(); 835 877 } … … 839 881 for (final Way osm : data.ways) 840 882 { 841 if (!osm.incomplete && !osm.deleted && !alreadyDrawn.contains(osm)) 842 { 843 if(styles.isArea((Way)osm) && !alreadyDrawnAreas.contains(osm)) 883 //if (!osm.incomplete && !osm.deleted && !alreadyDrawn.contains(osm)) 884 if (!osm.incomplete && !osm.deleted) 885 { 886 //if(styles.isArea((Way)osm) && !alreadyDrawnAreas.contains(osm)) 887 if(isPrimitiveArea(osm)) 844 888 { 845 889 osm.visit(this); … … 853 897 if(profiler) 854 898 { 855 System.out.format("Areas : %4dms, n=%d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN); 899 System.out.format("Areas : %4dms, n=%5d, visible=%d\n", 900 (java.lang.System.currentTimeMillis()-profilerLast), profilerN, profilerVisibleAreas); 856 901 profilerLast = java.lang.System.currentTimeMillis(); 857 902 } … … 868 913 if(profiler) 869 914 { 870 System.out.format("Ways : %4dms, n=%d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN); 915 System.out.format("Ways : %4dms, n=%5d, visible=%d\n", 916 (java.lang.System.currentTimeMillis()-profilerLast), profilerN, profilerVisibleWays); 871 917 profilerLast = java.lang.System.currentTimeMillis(); 872 918 } … … 885 931 if(profiler) 886 932 { 887 System.out.format("Ways : %4dms, n=%d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN); 933 System.out.format("Ways : %4dms, n=%5d, visible=%d\n", 934 (java.lang.System.currentTimeMillis()-profilerLast), profilerN, profilerVisibleWays); 888 935 profilerLast = java.lang.System.currentTimeMillis(); 889 936 } … … 895 942 for (final OsmPrimitive osm : data.getSelected()) { 896 943 if (!osm.incomplete && !osm.deleted 897 && !(osm instanceof Node) && !alreadyDrawn.contains(osm)) 944 //&& !(osm instanceof Node) && !alreadyDrawn.contains(osm)) 945 && !(osm instanceof Node)) 898 946 { 899 947 osm.visit(this); … … 904 952 if(profiler) 905 953 { 906 System.out.format("Selected : %4dms, n=%d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN); 954 System.out.format("Selected : %4dms, n=%5d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN); 907 955 profilerLast = java.lang.System.currentTimeMillis(); 908 956 } … … 910 958 /*** DISPLAY CACHED SEGMENTS (WAYS) NOW ***/ 911 959 displaySegments(); 912 /*System.out.println("display segments " + (java.lang.System.currentTimeMillis()-profilerLast) + "ms"); 913 profilerLast = java.lang.System.currentTimeMillis();*/ 960 /*if(profiler) 961 { 962 System.out.format("DS : %4dms\n", (java.lang.System.currentTimeMillis()-profilerLast)); 963 profilerLast = java.lang.System.currentTimeMillis(); 964 }*/ 914 965 915 966 /*** NODES ***/ 916 967 profilerN = 0; 917 968 for (final OsmPrimitive osm : data.nodes) 918 if (!osm.incomplete && !osm.deleted && !alreadyDrawn.contains(osm)) 969 //if (!osm.incomplete && !osm.deleted && !alreadyDrawn.contains(osm)) 970 if (!osm.incomplete && !osm.deleted) 919 971 { 920 972 osm.visit(this); … … 924 976 if(profiler) 925 977 { 926 System.out.format("Nodes : %4dms, n=%d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN); 978 System.out.format("Nodes : %4dms, n=%5d, visible=%d\n", 979 (java.lang.System.currentTimeMillis()-profilerLast), profilerN, profilerVisibleNodes); 927 980 profilerLast = java.lang.System.currentTimeMillis(); 928 981 } … … 944 997 if(profiler) 945 998 { 946 System.out.format("Virtual : %4dms, n=%d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN); 999 System.out.format("Virtual : %4dms, n=%5d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN); 947 1000 profilerLast = java.lang.System.currentTimeMillis(); 948 1001 } 949 1002 950 1003 displaySegments(null); 951 /*System.out.println("display segments virtual " + (java.lang.System.currentTimeMillis()-profilerLast) + "ms"); 952 profilerLast = java.lang.System.currentTimeMillis();*/ 1004 /*if(profiler) 1005 { 1006 System.out.format("VirtualDS: %4dms\n", (java.lang.System.currentTimeMillis()-profilerLast)); 1007 profilerLast = java.lang.System.currentTimeMillis(); 1008 }*/ 953 1009 } 954 1010 -
trunk/src/org/openstreetmap/josm/io/OsmReader.java
r1196 r1254 98 98 osm.checkTagged(); 99 99 osm.checkDirectionTagged(); 100 osm.mappaintStyle = null; 100 101 } 101 102 }
Note:
See TracChangeset
for help on using the changeset viewer.