Changeset 7402 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2014-08-15T18:53:18+02:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/tools
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/ColorScale.java
r7319 r7402 1 1 // License: GPL. For details, see LICENSE file. 2 3 2 package org.openstreetmap.josm.tools; 4 3 … … 8 7 9 8 /** 10 * Utility class that helps to work with color scale 11 * for coloring GPX tracks etc. 9 * Utility class that helps to work with color scale for coloring GPX tracks etc. 12 10 * @since 7319 13 11 */ … … 17 15 private Color belowMinColor; 18 16 private Color aboveMaxColor; 19 17 20 18 private Color[] colors; 21 19 private String title = ""; 22 20 private int intervalCount = 5; 23 21 24 22 private ColorScale() { 25 23 26 24 } 27 25 28 26 public static ColorScale createHSBScale(int count) { 29 27 ColorScale sc = new ColorScale(); … … 36 34 return sc; 37 35 } 38 36 39 37 public static ColorScale createCyclicScale(int count) { 40 38 ColorScale sc = new ColorScale(); … … 46 44 sc.colors = new Color[count]; 47 45 for (int i = 0; i < sc.colors.length; i++) { 48 46 49 47 float angle = 4 - i / 256f * 4; 50 48 int quadrant = (int) angle; … … 62 60 return sc; 63 61 } 64 62 65 63 /** 66 64 * transition function: … … 80 78 this.max = max; 81 79 } 82 80 83 81 /** 84 82 * Add standard colors for values below min or above max value … … 88 86 belowMinColor = colors[0]; 89 87 } 90 88 91 89 public final Color getColor(double value) { 92 90 if (value<min) return belowMinColor; … … 100 98 return colors[n-1]; // this happens when value==max 101 99 } 102 // int hdoplvl =(int) Math.round(colorModeDynamic ? ((hdop-minval)*255/(maxval-minval))103 // : (hdop <= 0 ? 0 : hdop * hdopfactor));104 // int hdopcolor = 255 - (hdoplvl > 255 ? 255 : hdoplvl);105 100 } 106 101 107 102 public final Color getColor(Number value) { 108 103 return (value==null)? noDataColor : getColor(value.doubleValue()); … … 110 105 111 106 public Color getNoDataColor() { 112 113 107 return noDataColor; 114 108 } … … 117 111 this.noDataColor = noDataColor; 118 112 } 119 113 120 114 public ColorScale makeTransparent(int alpha) { 121 115 for (int i = 0; i < colors.length; i++) { … … 124 118 return this; 125 119 } 126 120 127 121 public ColorScale addTitle(String title) { 128 122 this.title = title; 129 123 return this; 130 124 } 131 125 132 126 public ColorScale setIntervalCount(int intervalCount) { 133 127 this.intervalCount = intervalCount; 134 128 return this; 135 129 } 136 130 137 131 public ColorScale makeReversed() { 138 132 int n = colors.length; … … 148 142 return this; 149 143 } 150 144 151 145 public void drawColorBar(Graphics2D g, int x, int y, int w, int h, double valueScale) { 152 146 int n=colors.length; 153 147 154 148 for (int i=0; i<n; i++) { 155 149 g.setColor(colors[i]); … … 160 154 } 161 155 } 162 156 163 157 int fw, fh; 164 FontMetrics fm = g.getFontMetrics(); 158 FontMetrics fm = g.getFontMetrics(); 165 159 fh = fm.getHeight()/2; 166 160 fw = fm.stringWidth(String.valueOf(Math.max((int)Math.abs(max*valueScale), (int)Math.abs(min*valueScale)))) + fm.stringWidth("0.123"); -
trunk/src/org/openstreetmap/josm/tools/FontsManager.java
r7383 r7402 9 9 import java.util.Arrays; 10 10 import java.util.Collection; 11 import java.util.Map; 11 12 12 import org.openstreetmap.josm.io.CachedFile; 13 13 14 /** 15 * Custom fonts manager that provides some embedded fonts to ensure 16 * a common rendering on different platforms. 17 * @since 7383 18 */ 14 19 public class FontsManager { 15 20 16 public static Map<String, Font> fonts; 17 public static Collection<String> includedFonts = Arrays.asList( 21 /** 22 * List of fonts embedded into JOSM jar. 23 */ 24 public static final Collection<String> INCLUDED_FONTS = Arrays.asList( 18 25 "DroidSans.ttf", 19 26 "DroidSans-Bold.ttf" 20 27 ); 21 28 29 private FontsManager() { 30 // Hide constructor for utility classes 31 } 32 33 /** 34 * Initializes the fonts manager. 35 */ 22 36 public static void initialize() { 23 37 GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); 24 for (String fontFile : includedFonts) {38 for (String fontFile : INCLUDED_FONTS) { 25 39 String url = "resource://data/fonts/"+fontFile; 26 try (InputStream i = new CachedFile(url).getInputStream()) 27 { 40 try (InputStream i = new CachedFile(url).getInputStream()) { 28 41 Font f = Font.createFont(Font.TRUETYPE_FONT, i); 29 42 if (f == null) { -
trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
r7313 r7402 93 93 /** 94 94 * Position of an overlay icon 95 * @author imi96 95 */ 97 96 public static enum OverlayPosition { … … 1277 1276 Node item = list.item(0); 1278 1277 if (item instanceof Element) { 1279 String value = ((Element)item).getAttribute("value"); 1280 String[] s = value.split(" "); 1278 String[] s = ((Element)item).getAttribute("value").split(" "); 1281 1279 if (s.length == 3) { 1282 int[] rgb = new int[3]; 1283 try { 1284 for (int i = 0; i<3; i++) { 1285 rgb[i] = Integer.parseInt(s[i]); 1286 } 1287 return new Color(rgb[0], rgb[1], rgb[2]); 1288 } catch (IllegalArgumentException e) { 1289 Main.error(e); 1290 } 1280 return parseRGB(s); 1291 1281 } 1292 }1282 } 1293 1283 } 1294 1284 } … … 1303 1293 } 1304 1294 return null; 1295 } 1296 1297 private static Color parseRGB(String[] s) { 1298 int[] rgb = new int[3]; 1299 try { 1300 for (int i = 0; i<3; i++) { 1301 rgb[i] = Integer.parseInt(s[i]); 1302 } 1303 return new Color(rgb[0], rgb[1], rgb[2]); 1304 } catch (IllegalArgumentException e) { 1305 Main.error(e); 1306 return null; 1307 } 1305 1308 } 1306 1309 -
trunk/src/org/openstreetmap/josm/tools/PlatformHookWindows.java
r7344 r7402 56 56 57 57 private static final byte[] INSECURE_PUBLIC_KEY = new byte[] { 58 0x30, (byte) 0x82, 0x1, 0x22, 0x30, 0xd, 0x6, 0x9, 0x2a, (byte) 0x86, 0x48, (byte) 0x86, (byte) 0xf7, 0xd, 0x1, 0x1, 0x1, 0x5, 0x0, 0x3, (byte) 0x82, 0x1, 0xf, 0x0, 58 0x30, (byte) 0x82, 0x1, 0x22, 0x30, 0xd, 0x6, 0x9, 0x2a, (byte) 0x86, 0x48, 59 (byte) 0x86, (byte) 0xf7, 0xd, 0x1, 0x1, 0x1, 0x5, 0x0, 0x3, (byte) 0x82, 0x1, 0xf, 0x0, 59 60 0x30, (byte) 0x82, 0x01, 0x0a, 0x02, (byte) 0x82, 0x01, 0x01, 0x00, (byte) 0x95, (byte) 0x95, (byte) 0x88, 60 (byte) 0x84, (byte) 0xc8, (byte) 0xd9, 0x6b, (byte) 0xc5, (byte) 0xda, 0x0b, 0x69, (byte) 0xbf, (byte) 0xfc, 0x7e, (byte) 0xb9, (byte) 0x96, 0x2c, (byte) 0xeb, (byte) 0x8f, 61 (byte) 0xbc, 0x6e, 0x40, (byte) 0xe6, (byte) 0xe2, (byte) 0xfc, (byte) 0xf1, 0x7f, 0x73, (byte) 0xa7, (byte) 0x9d, (byte) 0xde, (byte) 0xc7, (byte) 0x88, 62 0x57, 0x51, (byte) 0x84, (byte) 0xed, (byte) 0x96, (byte) 0xfb, (byte) 0xe1, 0x38, (byte) 0xef, 0x08, 0x2b, (byte) 0xf3, (byte) 0xc7, (byte) 0xc3, 63 0x5d, (byte) 0xfe, (byte) 0xf9, 0x51, (byte) 0xe6, 0x29, (byte) 0xfc, (byte) 0xe5, 0x0d, (byte) 0xa1, 0x0d, (byte) 0xa8, (byte) 0xb4, (byte) 0xae, 64 0x26, 0x18, 0x19, 0x4d, 0x6c, 0x0c, 0x3b, 0x12, (byte) 0xba, (byte) 0xbc, 0x5f, 0x32, (byte) 0xb3, (byte) 0xbe, 65 (byte) 0x9d, 0x17, 0x0d, 0x4d, 0x2f, 0x1a, 0x48, (byte) 0xb7, (byte) 0xac, (byte) 0xf7, 0x1a, 0x43, 0x01, (byte) 0x97, 66 (byte) 0xf4, (byte) 0xf8, 0x4c, (byte) 0xbb, 0x6a, (byte) 0xbc, 0x33, (byte) 0xe1, 0x73, 0x1e, (byte) 0x86, (byte) 0xfb, 0x2e, (byte) 0xb1, 67 0x63, 0x75, (byte) 0x85, (byte) 0xdc, (byte) 0x82, 0x6c, 0x28, (byte) 0xf1, (byte) 0xe3, (byte) 0x90, 0x63, (byte) 0x9d, 0x3d, 0x48, 68 (byte) 0x8a, (byte) 0x8c, 0x47, (byte) 0xe2, 0x10, 0x0b, (byte) 0xef, (byte) 0x91, (byte) 0x94, (byte) 0xb0, 0x6c, 0x4c, (byte) 0x80, 0x76, 69 0x03, (byte) 0xe1, (byte) 0xb6, (byte) 0x90, (byte) 0x87, (byte) 0xd9, (byte) 0xae, (byte) 0xf4, (byte) 0x8e, (byte) 0xe0, (byte) 0x9f, (byte) 0xe7, 0x3a, 0x2c, 70 0x2f, 0x21, (byte) 0xd4, 0x46, (byte) 0xba, (byte) 0x95, 0x70, (byte) 0xa9, 0x5b, 0x20, 0x2a, (byte) 0xfa, 0x52, 0x3e, 71 (byte) 0x9d, (byte) 0xd9, (byte) 0xef, 0x28, (byte) 0xc5, (byte) 0xd1, 0x60, (byte) 0x89, 0x68, 0x6e, 0x7f, (byte) 0xd7, (byte) 0x9e, (byte) 0x89, 72 0x4c, (byte) 0xeb, 0x4d, (byte) 0xd2, (byte) 0xc6, (byte) 0xf4, 0x2d, 0x02, 0x5d, (byte) 0xda, (byte) 0xde, 0x33, (byte) 0xfe, (byte) 0xc1, 73 0x7e, (byte) 0xde, 0x4f, 0x1f, (byte) 0x9b, 0x6e, 0x6f, 0x0f, 0x66, 0x71, 0x19, (byte) 0xe9, 0x43, 0x3c, 74 (byte) 0x83, 0x0a, 0x0f, 0x28, 0x21, (byte) 0xc8, 0x38, (byte) 0xd3, 0x4e, 0x48, (byte) 0xdf, (byte) 0xd4, (byte) 0x99, (byte) 0xb5, 75 (byte) 0xc6, (byte) 0x8d, (byte) 0xd4, (byte) 0xc1, 0x69, 0x58, 0x79, (byte) 0x82, 0x32, (byte) 0x82, (byte) 0xd4, (byte) 0x86, (byte) 0xe2, 0x04, 76 0x08, 0x63, (byte) 0x87, (byte) 0xf0, 0x2a, (byte) 0xf6, (byte) 0xec, 0x3e, 0x51, 0x0f, (byte) 0xda, (byte) 0xb4, 0x67, 0x19, 77 0x5e, 0x16, 0x02, (byte) 0x9f, (byte) 0xf1, 0x19, 0x0c, 0x3e, (byte) 0xb8, 0x04, 0x49, 0x07, 0x53, 0x02, 78 0x03, 0x01, 0x00, 0x01 61 (byte) 0x84, (byte) 0xc8, (byte) 0xd9, 0x6b, (byte) 0xc5, (byte) 0xda, 0x0b, 0x69, (byte) 0xbf, (byte) 0xfc, 62 0x7e, (byte) 0xb9, (byte) 0x96, 0x2c, (byte) 0xeb, (byte) 0x8f, (byte) 0xbc, 0x6e, 0x40, (byte) 0xe6, (byte) 0xe2, 63 (byte) 0xfc, (byte) 0xf1, 0x7f, 0x73, (byte) 0xa7, (byte) 0x9d, (byte) 0xde, (byte) 0xc7, (byte) 0x88, 0x57, 0x51, 64 (byte) 0x84, (byte) 0xed, (byte) 0x96, (byte) 0xfb, (byte) 0xe1, 0x38, (byte) 0xef, 0x08, 0x2b, (byte) 0xf3, 65 (byte) 0xc7, (byte) 0xc3, 0x5d, (byte) 0xfe, (byte) 0xf9, 0x51, (byte) 0xe6, 0x29, (byte) 0xfc, (byte) 0xe5, 0x0d, 66 (byte) 0xa1, 0x0d, (byte) 0xa8, (byte) 0xb4, (byte) 0xae, 0x26, 0x18, 0x19, 0x4d, 0x6c, 0x0c, 0x3b, 0x12, (byte) 0xba, 67 (byte) 0xbc, 0x5f, 0x32, (byte) 0xb3, (byte) 0xbe, (byte) 0x9d, 0x17, 0x0d, 0x4d, 0x2f, 0x1a, 0x48, (byte) 0xb7, 68 (byte) 0xac, (byte) 0xf7, 0x1a, 0x43, 0x01, (byte) 0x97, (byte) 0xf4, (byte) 0xf8, 0x4c, (byte) 0xbb, 0x6a, (byte) 0xbc, 69 0x33, (byte) 0xe1, 0x73, 0x1e, (byte) 0x86, (byte) 0xfb, 0x2e, (byte) 0xb1, 0x63, 0x75, (byte) 0x85, (byte) 0xdc, 70 (byte) 0x82, 0x6c, 0x28, (byte) 0xf1, (byte) 0xe3, (byte) 0x90, 0x63, (byte) 0x9d, 0x3d, 0x48, (byte) 0x8a, (byte) 0x8c, 71 0x47, (byte) 0xe2, 0x10, 0x0b, (byte) 0xef, (byte) 0x91, (byte) 0x94, (byte) 0xb0, 0x6c, 0x4c, (byte) 0x80, 0x76, 0x03, 72 (byte) 0xe1, (byte) 0xb6, (byte) 0x90, (byte) 0x87, (byte) 0xd9, (byte) 0xae, (byte) 0xf4, (byte) 0x8e, (byte) 0xe0, 73 (byte) 0x9f, (byte) 0xe7, 0x3a, 0x2c, 0x2f, 0x21, (byte) 0xd4, 0x46, (byte) 0xba, (byte) 0x95, 0x70, (byte) 0xa9, 0x5b, 74 0x20, 0x2a, (byte) 0xfa, 0x52, 0x3e, (byte) 0x9d, (byte) 0xd9, (byte) 0xef, 0x28, (byte) 0xc5, (byte) 0xd1, 0x60, 75 (byte) 0x89, 0x68, 0x6e, 0x7f, (byte) 0xd7, (byte) 0x9e, (byte) 0x89, 0x4c, (byte) 0xeb, 0x4d, (byte) 0xd2, (byte) 0xc6, 76 (byte) 0xf4, 0x2d, 0x02, 0x5d, (byte) 0xda, (byte) 0xde, 0x33, (byte) 0xfe, (byte) 0xc1, 0x7e, (byte) 0xde, 0x4f, 0x1f, 77 (byte) 0x9b, 0x6e, 0x6f, 0x0f, 0x66, 0x71, 0x19, (byte) 0xe9, 0x43, 0x3c, (byte) 0x83, 0x0a, 0x0f, 0x28, 0x21, (byte) 0xc8, 78 0x38, (byte) 0xd3, 0x4e, 0x48, (byte) 0xdf, (byte) 0xd4, (byte) 0x99, (byte) 0xb5, (byte) 0xc6, (byte) 0x8d, (byte) 0xd4, 79 (byte) 0xc1, 0x69, 0x58, 0x79, (byte) 0x82, 0x32, (byte) 0x82, (byte) 0xd4, (byte) 0x86, (byte) 0xe2, 0x04, 0x08, 0x63, 80 (byte) 0x87, (byte) 0xf0, 0x2a, (byte) 0xf6, (byte) 0xec, 0x3e, 0x51, 0x0f, (byte) 0xda, (byte) 0xb4, 0x67, 0x19, 0x5e, 81 0x16, 0x02, (byte) 0x9f, (byte) 0xf1, 0x19, 0x0c, 0x3e, (byte) 0xb8, 0x04, 0x49, 0x07, 0x53, 0x02, 0x03, 0x01, 0x00, 0x01 79 82 }; 80 83 … … 226 229 if (!insecureCertificates.isEmpty()) { 227 230 StringBuilder message = new StringBuilder("<html>"); 228 message.append(tr("A previous version of JOSM has installed a custom certificate in order to provide HTTPS support for Remote Control:")); 231 message.append(tr("A previous version of JOSM has installed a custom certificate "+ 232 "in order to provide HTTPS support for Remote Control:")); 229 233 message.append("<br><ul>"); 230 234 for (String alias : insecureCertificates) { … … 235 239 message.append("</ul>"); 236 240 message.append(tr("It appears it could be an important <b>security risk</b>.<br><br>"+ 237 "You are now going to be prompted by Windows to remove this insecure certificate.<br>For your own safety, <b>please click Yes</b> in next dialog.")); 241 "You are now going to be prompted by Windows to remove this insecure certificate.<br>"+ 242 "For your own safety, <b>please click Yes</b> in next dialog.")); 238 243 message.append("</html>"); 239 244 JOptionPane.showMessageDialog(Main.parent, message.toString(), tr("Warning"), JOptionPane.WARNING_MESSAGE); … … 268 273 "If unsure, you can also click No then disable HTTPS support in Remote Control preferences.")); 269 274 message.append("</html>"); 270 JOptionPane.showMessageDialog(Main.parent, message.toString(), tr("HTTPS support in Remote Control"), JOptionPane.INFORMATION_MESSAGE); 275 JOptionPane.showMessageDialog(Main.parent, message.toString(), 276 tr("HTTPS support in Remote Control"), JOptionPane.INFORMATION_MESSAGE); 271 277 // install it to Windows-ROOT keystore, used by IE, Chrome and Safari, but not by Firefox 272 278 Main.info(tr("Adding JOSM localhost certificate to {0} keystore", WINDOWS_ROOT));
Note:
See TracChangeset
for help on using the changeset viewer.