Changeset 1221 in josm for trunk/src/org
- Timestamp:
- 2009-01-09T09:42:46+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
r1169 r1221 82 82 83 83 //putValue("help", "Action/AddNode/Autnode"); 84 selectedColor = Main.pref.getColor(marktr("selected"), Color. YELLOW);84 selectedColor = Main.pref.getColor(marktr("selected"), Color.red); 85 85 86 86 drawHelperLine = Main.pref.getBoolean("draw.helper-line", true); -
trunk/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java
r1186 r1221 79 79 putValue("help", "Action/Extrude/Extrude"); 80 80 initialMoveDelay = Main.pref.getInteger("edit.initial-move-delay",200); 81 selectedColor = Main.pref.getColor(marktr("selected"), Color. YELLOW);81 selectedColor = Main.pref.getColor(marktr("selected"), Color.red); 82 82 } 83 83 -
trunk/src/org/openstreetmap/josm/data/Preferences.java
r1180 r1221 183 183 } 184 184 185 synchronized public TreeMap<String, String> getAllColors() { 186 final TreeMap<String,String> all = new TreeMap<String,String>(); 187 for (final Entry<String,String> e : defaults.entrySet()) 188 if (e.getKey().startsWith("color.")) 189 all.put(e.getKey().substring(6), e.getValue()); 190 for (final Entry<String,String> e : properties.entrySet()) 191 if (e.getKey().startsWith("color.")) 192 all.put(e.getKey().substring(6), e.getValue()); 193 for (final Entry<String,String> e : override.entrySet()) 194 if (e.getKey().startsWith("color.")) 195 if (e.getValue() == null) 196 all.remove(e.getKey().substring(6)); 197 else 198 all.put(e.getKey().substring(6), e.getValue()); 199 return all; 200 } 201 185 202 synchronized public Map<String, String> getDefaults() { 186 203 return defaults; … … 345 362 */ 346 363 synchronized public Color getColor(String colName, Color def) { 347 String colStr = get("color."+colName); 348 if (colStr.equals("")) { 349 put("color."+colName, ColorHelper.color2html(def)); 350 return def; 351 } 352 return ColorHelper.html2color(colStr); 364 return getColor(colName, null, def); 353 365 } 354 366 … … 362 374 */ 363 375 synchronized public Color getColor(String colName, String specName, Color def) { 364 String colStr = get("color."+specName); 376 putDefault("color."+colName, ColorHelper.color2html(def)); 377 String colStr = specName != null ? get("color."+specName) : ""; 365 378 if(colStr.equals("")) 366 {367 379 colStr = get("color."+colName); 368 if (colStr.equals("")) { 369 put("color."+colName, ColorHelper.color2html(def)); 370 return def; 371 } 372 } 373 putDefault("color."+colName, ColorHelper.color2html(def)); 374 return ColorHelper.html2color(colStr); 380 return colStr.equals("") ? def : ColorHelper.html2color(colStr); 375 381 } 376 382 -
trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java
r1215 r1221 752 752 g.drawRect(p.x - radius, p.y - radius, size, size); 753 753 754 String name = getNodeName(n); 755 if (name!=null /* && annotate */) 756 { 757 g.setColor(textColor); 758 Font defaultFont = g.getFont(); 759 g.setFont (orderFont); 760 g.drawString (name, p.x+radius+2, p.y+radius+2); 761 g.setFont(defaultFont); 762 } 763 } 754 String name = getNodeName(n); 755 if (name!=null /* && annotate */) 756 { 757 g.setColor(textColor); 758 Font defaultFont = g.getFont(); 759 g.setFont (orderFont); 760 g.drawString (name, p.x+radius+2, p.y+radius+2); 761 g.setFont(defaultFont); 762 } 763 } 764 } 765 766 public void getColors() 767 { 768 super.getColors(); 769 untaggedColor = Main.pref.getColor(marktr("untagged"),Color.GRAY); 770 textColor = Main.pref.getColor (marktr("text"), Color.WHITE); 764 771 } 765 772 … … 767 774 // Shows areas before non-areas 768 775 public void visitAll(DataSet data, Boolean virtual) { 769 770 771 772 773 774 775 776 777 778 776 777 boolean profiler = Main.pref.getBoolean("mappaint.profiler",false); 778 long profilerStart = java.lang.System.currentTimeMillis(); 779 long profilerLast = profilerStart; 780 int profilerN; 781 if(profiler) 782 { 783 System.out.println("Mappaint Profiler"); 784 } 785 779 786 getSettings(virtual); 780 untaggedColor = Main.pref.getColor(marktr("untagged"),Color.GRAY);781 textColor = Main.pref.getColor (marktr("text"), Color.WHITE);782 787 useRealWidth = Main.pref.getBoolean("mappaint.useRealWidth",false); 783 788 zoomLevelDisplay = Main.pref.getBoolean("mappaint.zoomLevelDisplay",false); … … 795 800 selectedCall = false; 796 801 797 798 799 800 801 802 802 if(profiler) 803 { 804 System.out.format("Prepare : %4dms\n", (java.lang.System.currentTimeMillis()-profilerLast)); 805 profilerLast = java.lang.System.currentTimeMillis(); 806 } 807 803 808 if (fillAreas && styles.hasAreas()) { 804 809 Collection<Way> noAreaWays = new LinkedList<Way>(); 805 810 806 807 811 /*** RELATIONS ***/ 812 profilerN = 0; 808 813 for (final Relation osm : data.relations) 809 814 { 810 815 if(!osm.deleted && !osm.incomplete) 811 816 { 812 817 osm.visit(this); 813 814 815 } 816 817 818 819 820 821 822 823 824 818 profilerN++; 819 } 820 } 821 822 if(profiler) 823 { 824 System.out.format("Relations: %4dms, n=%d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN); 825 profilerLast = java.lang.System.currentTimeMillis(); 826 } 827 828 /*** AREAS ***/ 829 profilerN = 0; 825 830 for (final Way osm : data.ways) 826 831 { … … 836 841 } 837 842 alreadyDrawnAreas = null; 838 839 if(profiler) 840 841 842 843 844 845 846 843 844 if(profiler) 845 { 846 System.out.format("Areas : %4dms, n=%d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN); 847 profilerLast = java.lang.System.currentTimeMillis(); 848 } 849 850 /*** WAYS ***/ 851 profilerN = 0; 847 852 fillAreas = false; 848 853 for (final OsmPrimitive osm : noAreaWays) … … 851 856 profilerN++; 852 857 } 853 854 if(profiler) 855 856 857 858 858 859 if(profiler) 860 { 861 System.out.format("Ways : %4dms, n=%d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN); 862 profilerLast = java.lang.System.currentTimeMillis(); 863 } 859 864 } 860 865 else 861 866 { 862 /*** WAYS (filling disabled) ***/ 863 867 /*** WAYS (filling disabled) ***/ 868 profilerN = 0; 864 869 for (final OsmPrimitive osm : data.ways) 865 870 if (!osm.incomplete && !osm.deleted && !osm.selected) 866 871 { 867 872 osm.visit(this); 868 873 profilerN++; 869 870 871 if(profiler) 872 873 874 875 876 } 877 878 874 } 875 876 if(profiler) 877 { 878 System.out.format("Ways : %4dms, n=%d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN); 879 profilerLast = java.lang.System.currentTimeMillis(); 880 } 881 } 882 883 /*** SELECTED ***/ 879 884 selectedCall = true; 880 885 profilerN = 0; 881 886 for (final OsmPrimitive osm : data.getSelected()) { 882 887 if (!osm.incomplete && !osm.deleted 883 888 && !(osm instanceof Node) && !alreadyDrawn.contains(osm)) 884 889 { 885 890 osm.visit(this); 886 887 888 } 889 890 if(profiler) 891 892 893 894 895 896 891 profilerN++; 892 } 893 } 894 895 if(profiler) 896 { 897 System.out.format("Selected : %4dms, n=%d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN); 898 profilerLast = java.lang.System.currentTimeMillis(); 899 } 900 901 /*** DISPLAY CACHED SEGMENTS (WAYS) NOW ***/ 897 902 displaySegments(); 898 899 900 901 902 903 /*System.out.println("display segments " + (java.lang.System.currentTimeMillis()-profilerLast) + "ms"); 904 profilerLast = java.lang.System.currentTimeMillis();*/ 905 906 /*** NODES ***/ 907 profilerN = 0; 903 908 for (final OsmPrimitive osm : data.nodes) 904 909 if (!osm.incomplete && !osm.deleted && !alreadyDrawn.contains(osm)) 905 910 { 906 911 osm.visit(this); 907 908 909 910 if(profiler) 911 912 913 914 912 profilerN++; 913 } 914 915 if(profiler) 916 { 917 System.out.format("Nodes : %4dms, n=%d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN); 918 profilerLast = java.lang.System.currentTimeMillis(); 919 } 915 920 916 921 alreadyDrawn = null; 917 922 918 923 /*** VIRTUAL ***/ 919 924 if (virtualNodeSize != 0) 920 925 { 921 926 profilerN = 0; 922 927 currentColor = nodeColor; 923 928 for (final OsmPrimitive osm : data.ways) 924 929 if (!osm.incomplete && !osm.deleted) 925 930 { 926 931 visitVirtual((Way)osm); 927 928 929 930 if(profiler) 931 932 933 934 935 936 937 938 939 } 940 941 if(profiler) 942 943 944 932 profilerN++; 933 } 934 935 if(profiler) 936 { 937 System.out.format("Virtual : %4dms, n=%d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN); 938 profilerLast = java.lang.System.currentTimeMillis(); 939 } 940 941 displaySegments(null); 942 /*System.out.println("display segments virtual " + (java.lang.System.currentTimeMillis()-profilerLast) + "ms"); 943 profilerLast = java.lang.System.currentTimeMillis();*/ 944 } 945 946 if(profiler) 947 { 948 System.out.format("All : %4dms\n", (profilerLast-profilerStart)); 949 } 945 950 } 946 951 -
trunk/src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java
r1216 r1221 85 85 Rectangle bbox = new Rectangle(); 86 86 87 protected void getSettings(Boolean virtual) { 88 inactiveColor = Main.pref.getColor(marktr("inactive"), Color.DARK_GRAY); 89 selectedColor = Main.pref.getColor(marktr("selected"), Color.WHITE); 90 nodeColor = Main.pref.getColor(marktr("node"), Color.RED); 87 public void getColors() 88 { 89 inactiveColor = Main.pref.getColor(marktr("inactive"), Color.darkGray); 90 selectedColor = Main.pref.getColor(marktr("selected"), Color.red); 91 nodeColor = Main.pref.getColor(marktr("node"), Color.yellow); 91 92 dfltWayColor = Main.pref.getColor(marktr("way"), darkblue); 92 93 relationColor = Main.pref.getColor(marktr("relation"), teal); … … 94 95 incompleteColor = Main.pref.getColor(marktr("incomplete way"), darkerblue); 95 96 backgroundColor = Main.pref.getColor(marktr("background"), Color.BLACK); 97 } 98 99 protected void getSettings(Boolean virtual) { 96 100 showDirectionArrow = Main.pref.getBoolean("draw.segment.direction"); 97 101 showRelevantDirectionsOnly = Main.pref.getBoolean("draw.segment.relevant_directions_only", true); -
trunk/src/org/openstreetmap/josm/gui/MapScaler.java
r1169 r1221 31 31 String text = dist > 1000 ? (Math.round(dist/100)/10.0)+" km" : Math.round(dist*10)/10+" m"; 32 32 Rectangle2D bound = g.getFontMetrics().getStringBounds(text, g); 33 g.setColor( Main.pref.getColor(marktr("scale"), Color.white));33 g.setColor(getColor()); 34 34 g.drawLine(0, 5, 99, 5); 35 35 g.drawLine(0, 0, 0, 10); … … 41 41 } 42 42 43 static public Color getColor() 44 { 45 return Main.pref.getColor(marktr("scale"), Color.white); 46 } 47 43 48 public String helpTopic() { 44 49 return "MapView/Scaler"; -
trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java
r1169 r1221 137 137 } 138 138 139 static public Color getColor() 140 { 141 return Main.pref.getColor(marktr("conflict"), Color.gray); 142 } 143 139 144 /** 140 145 * Paint all conflicts that can be expressed on the main window. 141 146 */ 142 147 public void paintConflicts(final Graphics g, final NavigatableComponent nc) { 143 Color preferencesColor = Main.pref.getColor("conflict", Color.gray);144 if (preferencesColor.equals( Color.BLACK))148 Color preferencesColor = getColor(); 149 if (preferencesColor.equals(Main.pref.getColor(marktr("background"), Color.black))) 145 150 return; 146 151 g.setColor(preferencesColor); -
trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
r1210 r1221 108 108 } 109 109 110 static public Color getColor(String name) 111 { 112 return Main.pref.getColor(marktr("gps point"), name != null ? "layer "+name : null, Color.gray); 113 } 114 110 115 @Override public Component[] getMenuEntries() { 111 116 JMenuItem line = new JMenuItem(tr("Customize line drawing"), ImageProvider.get("mapmode/addsegment")); … … 142 147 color.addActionListener(new ActionListener() { 143 148 public void actionPerformed(ActionEvent e) { 144 JColorChooser c = new JColorChooser( Main.pref.getColor(marktr("gps point"), "layer "+name, Color.gray));149 JColorChooser c = new JColorChooser(getColor(name)); 145 150 Object[] options = new Object[]{tr("OK"), tr("Cancel"), tr("Default")}; 146 151 int answer = JOptionPane.showOptionDialog(Main.parent, c, tr("Choose a color"), JOptionPane.OK_CANCEL_OPTION, … … 370 375 ****************************************************************/ 371 376 // Long startTime = System.currentTimeMillis(); 372 Color neutralColor = Main.pref.getColor(marktr("gps point"), "layer "+name, Color.GRAY);377 Color neutralColor = getColor(name); 373 378 boolean forceLines = Main.pref.getBoolean("draw.rawgps.lines.force"); // also draw lines between points belonging to different segments 374 379 boolean direction = Main.pref.getBoolean("draw.rawgps.direction"); // draw direction arrows on the lines -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java
r1195 r1221 147 147 } 148 148 149 static public Color getColor(String name) 150 { 151 return Main.pref.getColor(marktr("gps marker"), name != null ? "layer "+name : null, Color.gray); 152 } 153 149 154 @Override public void paint(Graphics g, MapView mv) { 150 155 boolean mousePressedTmp = mousePressed; … … 152 157 String mkrTextShow = Main.pref.get("marker.show "+name, "show"); 153 158 154 g.setColor( Main.pref.getColor(marktr("gps marker"), "layer "+name, Color.gray));159 g.setColor(getColor(name)); 155 160 156 161 for (Marker mkr : data) { … … 191 196 color.addActionListener(new ActionListener(){ 192 197 public void actionPerformed(ActionEvent e) { 193 JColorChooser c = new JColorChooser( Main.pref.getColor(marktr("gps marker"), "layer "+name, Color.gray));198 JColorChooser c = new JColorChooser(getColor(name)); 194 199 Object[] options = new Object[]{tr("OK"), tr("Cancel"), tr("Default")}; 195 200 int answer = JOptionPane.showOptionDialog(Main.parent, c, tr("Choose a color"), JOptionPane.OK_CANCEL_OPTION, -
trunk/src/org/openstreetmap/josm/gui/preferences/ColorPreference.java
r1180 r1221 33 33 34 34 import org.openstreetmap.josm.Main; 35 import org.openstreetmap.josm.data.osm.visitor.SimplePaintVisitor; 35 import org.openstreetmap.josm.data.osm.visitor.MapPaintVisitor; 36 import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer; 37 import org.openstreetmap.josm.gui.layer.GpxLayer; 36 38 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 39 import org.openstreetmap.josm.gui.MapScaler; 40 import org.openstreetmap.josm.gui.dialogs.ConflictDialog; 37 41 import org.openstreetmap.josm.tools.ColorHelper; 38 42 import org.openstreetmap.josm.tools.GBC; … … 95 99 96 100 public void addGui(final PreferenceDialog gui) { 97 // initial fill with colors from preferences: 98 Map<String,String> prefColorMap = new TreeMap<String, String>(Main.pref.getAllPrefix("color.")); 99 fixColorPrefixes(prefColorMap); 100 Map<String,String> colorMap = new TreeMap<String, String>(); 101 for(String key : prefColorMap.keySet()) { 102 colorMap.put(key.substring("color.".length()), prefColorMap.get(key)); 103 } 104 setColorModel(colorMap); 101 fixColorPrefixes(); 102 setColorModel(Main.pref.getAllColors()); 105 103 106 104 colors = new JTable(tableModel) { … … 153 151 * Add all missing color entries. 154 152 */ 155 private void fixColorPrefixes(Map<String, String> prefColorMap) { 156 String[] cp = { 157 marktr("background"), ColorHelper.color2html(Color.black), 158 marktr("node"), ColorHelper.color2html(Color.red), 159 marktr("way"), ColorHelper.color2html(SimplePaintVisitor.darkblue), 160 marktr("incomplete way"), ColorHelper.color2html(SimplePaintVisitor.darkerblue), 161 marktr("relation"), ColorHelper.color2html(SimplePaintVisitor.teal), 162 marktr("selected"), ColorHelper.color2html(Color.white), 163 marktr("gps marker"), ColorHelper.color2html(Color.gray), 164 marktr("gps point"), ColorHelper.color2html(Color.gray), 165 marktr("conflict"), ColorHelper.color2html(Color.gray), 166 marktr("scale"), ColorHelper.color2html(Color.white), 167 marktr("inactive"), ColorHelper.color2html(Color.darkGray), 168 }; 169 for (int i = 0; i < cp.length/2; ++i) 170 { 171 if (!Main.pref.hasKey("color."+cp[i*2])) 172 Main.pref.put("color."+cp[i*2], cp[i*2+1]); 173 Main.pref.putDefault("color."+cp[i*2], cp[i*2+1]); 174 } 153 private void fixColorPrefixes() { 154 (new MapPaintVisitor()).getColors(); 155 MarkerLayer.getColor(null); 156 MapScaler.getColor(); 157 ConflictDialog.getColor(); 175 158 } 176 159
Note:
See TracChangeset
for help on using the changeset viewer.