Changeset 8510 in josm for trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java
- Timestamp:
- 2015-06-20T23:42:21+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java
r8509 r8510 149 149 int yCurrent0 = current.y - (int) Math.round(offset * dxNext / lenNext); 150 150 151 if (idx ==0) {151 if (idx == 0) { 152 152 ++idx; 153 153 prev = current; … … 172 172 int m = dxNext*(yCurrent0 - yPrev0) - dyNext*(xCurrent0 - xPrev0); 173 173 174 int cx = xPrev0 + (int) Math.round((double) m * dxPrev / det);175 int cy = yPrev0 + (int) Math.round((double) m * dyPrev / det);174 int cx = xPrev0 + (int) Math.round((double) m * dxPrev / det); 175 int cy = yPrev0 + (int) Math.round((double) m * dyPrev / det); 176 176 ++idx; 177 177 prev = current; … … 238 238 } 239 239 240 private static Map<Font, Boolean> IS_GLYPH_VECTOR_DOUBLE_TRANSLATION_BUG = new HashMap<>();240 private static Map<Font, Boolean> IS_GLYPH_VECTOR_DOUBLE_TRANSLATION_BUG = new HashMap<>(); 241 241 242 242 /** … … 335 335 super(g, nc, isInactiveMode); 336 336 337 if (nc !=null) {337 if (nc != null) { 338 338 Component focusOwner = FocusManager.getCurrentManager().getFocusOwner(); 339 339 useWiderHighlight = !(focusOwner instanceof AbstractButton || focusOwner == nc); … … 364 364 g.draw(path); 365 365 366 if (!isInactiveMode && useStrokes && dashes != null) {366 if (!isInactiveMode && useStrokes && dashes != null) { 367 367 g.setColor(dashedColor); 368 368 g.setStroke(dashes); … … 486 486 final double h = pb.height - nb.getHeight(); 487 487 488 final int x2 = pb.x + (int) (w/2.0);489 final int y2 = pb.y + (int) (h/2.0);488 final int x2 = pb.x + (int) (w/2.0); 489 final int y2 = pb.y + (int) (h/2.0); 490 490 491 491 final int nbw = (int) nb.getWidth(); … … 498 498 if (!labelOK) { 499 499 // if center position (C) is not inside osm shape, try naively some other positions as follows: 500 final int x1 = pb.x + (int) (w/4.0);501 final int x3 = pb.x + (int) (3*w/4.0);502 final int y1 = pb.y + (int) (h/4.0);503 final int y3 = pb.y + (int) (3*h/4.0);500 final int x1 = pb.x + (int) (w/4.0); 501 final int x3 = pb.x + (int) (3*w/4.0); 502 final int y1 = pb.y + (int) (h/4.0); 503 final int y3 = pb.y + (int) (3*h/4.0); 504 504 // +-----------+ 505 505 // | 5 1 6 | … … 526 526 if (labelOK) { 527 527 Font defaultFont = g.getFont(); 528 int x = (int) (centeredNBounds.getMinX() - nb.getMinX());529 int y = (int) (centeredNBounds.getMinY() - nb.getMinY());528 int x = (int) (centeredNBounds.getMinX() - nb.getMinX()); 529 int y = (int) (centeredNBounds.getMinY() - nb.getMinY()); 530 530 displayText(null, name, x, y, osm.isDisabled(), text); 531 531 g.setFont(defaultFont); … … 707 707 @Override 708 708 public void drawNode(Node n, Color color, int size, boolean fill) { 709 if (size <= 0 && !n.isHighlighted())709 if (size <= 0 && !n.isHighlighted()) 710 710 return; 711 711 712 712 Point p = nc.getPoint(n); 713 713 714 if (n.isHighlighted()) {714 if (n.isHighlighted()) { 715 715 drawPointHighlight(p, size); 716 716 } … … 737 737 738 738 final int w = img.getWidth(), h = img.getHeight(); 739 if (n.isHighlighted()) {739 if (n.isHighlighted()) { 740 740 drawPointHighlight(p, Math.max(w, h)); 741 741 } … … 768 768 int radius = s.size / 2; 769 769 770 if (n.isHighlighted()) {770 if (n.isHighlighted()) { 771 771 drawPointHighlight(p, s.size); 772 772 } … … 861 861 */ 862 862 private void drawPathHighlight(GeneralPath path, BasicStroke line) { 863 if (path == null)863 if (path == null) 864 864 return; 865 865 g.setColor(highlightColorTransparent); 866 866 float w = line.getLineWidth() + highlightLineWidth; 867 if (useWiderHighlight) w +=widerHighlight;868 while (w >= line.getLineWidth()) {867 if (useWiderHighlight) w += widerHighlight; 868 while (w >= line.getLineWidth()) { 869 869 g.setStroke(new BasicStroke(w, line.getEndCap(), line.getLineJoin(), line.getMiterLimit())); 870 870 g.draw(path); … … 879 879 g.setColor(highlightColorTransparent); 880 880 int s = size + highlightPointRadius; 881 if (useWiderHighlight) s +=widerHighlight;882 while (s >= size) {881 if (useWiderHighlight) s += widerHighlight; 882 while (s >= size) { 883 883 int r = (int) Math.floor(s/2d); 884 884 g.fillRoundRect(p.x-r, p.y-r, s, s, r, r); … … 890 890 // rotate image with direction last node in from to, and scale down image to 16*16 pixels 891 891 Image smallImg = ImageProvider.createRotatedImage(img, angle, new Dimension(16, 16)); 892 int w = smallImg.getWidth(null), h =smallImg.getHeight(null);893 g.drawImage(smallImg, (int) (pVia.x+vx+vx2)-w/2, (int)(pVia.y+vy+vy2)-h/2, nc);892 int w = smallImg.getWidth(null), h = smallImg.getHeight(null); 893 g.drawImage(smallImg, (int) (pVia.x+vx+vx2)-w/2, (int) (pVia.y+vy+vy2)-h/2, nc); 894 894 895 895 if (selected) { 896 896 g.setColor(isInactiveMode ? inactiveColor : relationSelectedColor); 897 g.drawRect((int) (pVia.x+vx+vx2)-w/2-2,(int)(pVia.y+vy+vy2)-h/2-2, w+4, h+4);897 g.drawRect((int) (pVia.x+vx+vx2)-w/2-2, (int) (pVia.y+vy+vy2)-h/2-2, w+4, h+4); 898 898 } 899 899 } … … 906 906 /* find the "from", "via" and "to" elements */ 907 907 for (RelationMember m : r.getMembers()) { 908 if (m.getMember().isIncomplete())908 if (m.getMember().isIncomplete()) 909 909 return; 910 910 else { 911 if (m.isWay()) {911 if (m.isWay()) { 912 912 Way w = m.getWay(); 913 if (w.getNodesCount() < 2) {913 if (w.getNodesCount() < 2) { 914 914 continue; 915 915 } … … 917 917 switch(m.getRole()) { 918 918 case "from": 919 if (fromWay == null) {919 if (fromWay == null) { 920 920 fromWay = w; 921 921 } 922 922 break; 923 923 case "to": 924 if (toWay == null) {924 if (toWay == null) { 925 925 toWay = w; 926 926 } 927 927 break; 928 928 case "via": 929 if (via == null) {929 if (via == null) { 930 930 via = w; 931 931 } 932 932 } 933 } else if (m.isNode()) {933 } else if (m.isNode()) { 934 934 Node n = m.getNode(); 935 if ("via".equals(m.getRole()) && via == null) {935 if ("via".equals(m.getRole()) && via == null) { 936 936 via = n; 937 937 } … … 944 944 945 945 Node viaNode; 946 if (via instanceof Node) {946 if (via instanceof Node) { 947 947 viaNode = (Node) via; 948 if (!fromWay.isFirstLastNode(viaNode))948 if (!fromWay.isFirstLastNode(viaNode)) 949 949 return; 950 950 } else { … … 955 955 956 956 String onewayviastr = viaWay.get("oneway"); 957 if (onewayviastr != null) {958 if ("-1".equals(onewayviastr)) {957 if (onewayviastr != null) { 958 if ("-1".equals(onewayviastr)) { 959 959 onewayvia = Boolean.TRUE; 960 960 Node tmp = firstNode; … … 969 969 } 970 970 971 if (fromWay.isFirstLastNode(firstNode)) {971 if (fromWay.isFirstLastNode(firstNode)) { 972 972 viaNode = firstNode; 973 973 } else if (!onewayvia && fromWay.isFirstLastNode(lastNode)) { … … 979 979 /* find the "direct" nodes before the via node */ 980 980 Node fromNode; 981 if (fromWay.firstNode() == via) {981 if (fromWay.firstNode() == via) { 982 982 fromNode = fromWay.getNode(1); 983 983 } else { … … 992 992 away from the "via" node along the first segment of the "from" way) 993 993 */ 994 double distanceFromVia =14;994 double distanceFromVia = 14; 995 995 double dx = pFrom.x >= pVia.x ? pFrom.x - pVia.x : pVia.x - pFrom.x; 996 996 double dy = pFrom.y >= pVia.y ? pFrom.y - pVia.y : pVia.y - pFrom.y; … … 1007 1007 double vy = distanceFromVia * Math.sin(fromAngle); 1008 1008 1009 if (pFrom.x < pVia.x) {1009 if (pFrom.x < pVia.x) { 1010 1010 vx = -vx; 1011 1011 } 1012 if (pFrom.y < pVia.y) {1012 if (pFrom.y < pVia.y) { 1013 1013 vy = -vy; 1014 1014 } … … 1018 1018 90degrees away from the first segment of the "from" way) 1019 1019 */ 1020 double distanceFromWay =10;1020 double distanceFromWay = 10; 1021 1021 double vx2 = 0; 1022 1022 double vy2 = 0; 1023 1023 double iconAngle = 0; 1024 1024 1025 if (pFrom.x >= pVia.x && pFrom.y >= pVia.y) {1026 if (!leftHandTraffic) {1025 if (pFrom.x >= pVia.x && pFrom.y >= pVia.y) { 1026 if (!leftHandTraffic) { 1027 1027 vx2 = distanceFromWay * Math.cos(Math.toRadians(fromAngleDeg - 90)); 1028 1028 vy2 = distanceFromWay * Math.sin(Math.toRadians(fromAngleDeg - 90)); … … 1033 1033 iconAngle = 270+fromAngleDeg; 1034 1034 } 1035 if (pFrom.x < pVia.x && pFrom.y >= pVia.y) {1036 if (!leftHandTraffic) {1035 if (pFrom.x < pVia.x && pFrom.y >= pVia.y) { 1036 if (!leftHandTraffic) { 1037 1037 vx2 = distanceFromWay * Math.sin(Math.toRadians(fromAngleDeg)); 1038 1038 vy2 = distanceFromWay * Math.cos(Math.toRadians(fromAngleDeg)); … … 1043 1043 iconAngle = 90-fromAngleDeg; 1044 1044 } 1045 if (pFrom.x < pVia.x && pFrom.y < pVia.y) {1046 if (!leftHandTraffic) {1045 if (pFrom.x < pVia.x && pFrom.y < pVia.y) { 1046 if (!leftHandTraffic) { 1047 1047 vx2 = distanceFromWay * Math.cos(Math.toRadians(fromAngleDeg + 90)); 1048 1048 vy2 = distanceFromWay * Math.sin(Math.toRadians(fromAngleDeg + 90)); … … 1053 1053 iconAngle = 90+fromAngleDeg; 1054 1054 } 1055 if (pFrom.x >= pVia.x && pFrom.y < pVia.y) {1056 if (!leftHandTraffic) {1055 if (pFrom.x >= pVia.x && pFrom.y < pVia.y) { 1056 if (!leftHandTraffic) { 1057 1057 vx2 = distanceFromWay * Math.sin(Math.toRadians(fromAngleDeg + 180)); 1058 1058 vy2 = distanceFromWay * Math.cos(Math.toRadians(fromAngleDeg + 180)); … … 1096 1096 poly.addPoint(p.x, p.y); 1097 1097 1098 if (lastPoint != null) {1098 if (lastPoint != null) { 1099 1099 dx = p.x - lastPoint.x; 1100 1100 dy = p.y - lastPoint.y; … … 1149 1149 double bestDistanceToCenter = Double.MAX_VALUE; 1150 1150 double bestQuality = -1; 1151 for (int i =0; i<longHalfSegmentStart.size(); i++) {1151 for (int i = 0; i < longHalfSegmentStart.size(); i++) { 1152 1152 double start = longHalfSegmentStart.get(i); 1153 1153 double end = longHalfSegmentEnd.get(i); … … 1215 1215 GlyphVector gv = text.font.layoutGlyphVector(frc, chars, 0, chars.length, dirFlag); 1216 1216 1217 for (int i =0; i<gv.getNumGlyphs(); ++i) {1217 for (int i = 0; i < gv.getNumGlyphs(); ++i) { 1218 1218 Rectangle2D rect = gv.getGlyphLogicalBounds(i).getBounds2D(); 1219 1219 double t = tStart + offsetSign * (rect.getX() + rect.getWidth()/2) / pathLength; … … 1271 1271 continue; 1272 1272 } 1273 if (highlightSegs == null) {1273 if (highlightSegs == null) { 1274 1274 highlightSegs = new GeneralPath(); 1275 1275 } … … 1333 1333 1334 1334 while (dist < segmentLength) { 1335 for (int i =0; i<2; ++i) {1335 for (int i = 0; i < 2; ++i) { 1336 1336 float onewaySize = i == 0 ? 3f : 2f; 1337 1337 GeneralPath onewayPath = i == 0 ? onewayArrowsCasing : onewayArrows; … … 1361 1361 lastPoint = p; 1362 1362 } 1363 if (way.isHighlighted()) {1363 if (way.isHighlighted()) { 1364 1364 drawPathHighlight(path, line); 1365 1365 } … … 1499 1499 MapCSSStyleSource.STYLE_SOURCE_LOCK.readLock().lock(); 1500 1500 try { 1501 for (int i = from; i <to; i++) {1501 for (int i = from; i < to; i++) { 1502 1502 OsmPrimitive osm = input.get(i); 1503 1503 if (osm.isDrawable()) { … … 1601 1601 final int noBuckets = (prims.size() + bucketsize - 1) / bucketsize; 1602 1602 final boolean singleThread = THREAD_POOL.a == 1 || noBuckets == 1; 1603 for (int i =0; i<noBuckets; i++) {1603 for (int i = 0; i < noBuckets; i++) { 1604 1604 int from = i*bucketsize; 1605 1605 int to = Math.min((i+1)*bucketsize, prims.size()); … … 1636 1636 highlightWaySegments = data.getHighlightedWaySegments(); 1637 1637 1638 long timeStart =0, timePhase1=0, timeFinished;1638 long timeStart = 0, timePhase1 = 0, timeFinished; 1639 1639 if (Main.isTraceEnabled()) { 1640 1640 timeStart = System.currentTimeMillis();
Note:
See TracChangeset
for help on using the changeset viewer.