Changeset 860 in josm for trunk/src


Ignore:
Timestamp:
2008-08-24T17:40:33+02:00 (16 years ago)
Author:
stoecker
Message:

fixed segment number display

Location:
trunk/src/org/openstreetmap/josm
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java

    r853 r860  
    3030import org.openstreetmap.josm.data.osm.WaySegment;
    3131import org.openstreetmap.josm.data.osm.visitor.AllNodesVisitor;
     32import org.openstreetmap.josm.data.osm.visitor.SimplePaintVisitor;
    3233import org.openstreetmap.josm.gui.MapFrame;
    3334import org.openstreetmap.josm.gui.MapView;
     
    240241                                        Point p1 = c.getPoint(w.nodes.get(nearestWaySeg.lowerIndex).eastNorth);
    241242                                        Point p2 = c.getPoint(w.nodes.get(nearestWaySeg.lowerIndex+1).eastNorth);
    242                                         int xd = p2.x-p1.x; if(xd < 0) xd = -xd;
    243                                         int yd = p2.y-p1.y; if(yd < 0) yd = -yd;
    244                                         if(xd+yd > Main.pref.getInteger("mappaint.node.virtual-space", 70))
     243                                        if(SimplePaintVisitor.isLargeSegment(p1, p2, Main.pref.getInteger("mappaint.node.virtual-space", 70)))
    245244                                        {
    246245                                                Point pc = new Point((p1.x+p2.x)/2, (p1.y+p2.y)/2);
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java

    r857 r860  
    357357                Point p1 = nc.getPoint(n1.eastNorth);
    358358                Point p2 = nc.getPoint(n2.eastNorth);
    359                 if (!isSegmentVisible(p1, p2)) {
    360                         return;
    361                 }
    362                 int strlen = (""+orderNumber).length();
    363                 int x = (p1.x+p2.x)/2 - 4*strlen;
    364                 int y = (p1.y+p2.y)/2 + 4;
    365 
    366                 Color c = g.getColor();
    367                 g.setColor(backgroundColor);
    368                 g.fillRect(x-1, y-12, 8*strlen+1, 14);
    369                 g.setColor(c);
    370                 g.drawString(""+orderNumber, x, y);
     359                drawOrderNumber(p1, p2, orderNumber);
    371360        }
    372361}
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java

    r857 r860  
    7575        protected int virtualNodeSize;
    7676        protected int virtualNodeSpace;
     77        protected int segmentNumberSpace;
    7778        protected int taggedNodeRadius;
    7879        protected int taggedNodeSize;
     
    109110                virtualNodeSize = virtual ? Main.pref.getInteger("mappaint.node.virtual-size", 4) / 2 : 0;
    110111                virtualNodeSpace = Main.pref.getInteger("mappaint.node.virtual-space", 70);
     112                segmentNumberSpace = Main.pref.getInteger("mappaint.segmentnumber.space", 40);
    111113
    112114                ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_ANTIALIASING,
     
    171173        }
    172174
     175        public static Boolean isLargeSegment(Point p1, Point p2, int space)
     176        {
     177                int xd = p1.x-p2.x; if(xd < 0) xd = -xd;
     178                int yd = p1.y-p2.y; if(yd < 0) yd = -yd;
     179                return (xd+yd > space);
     180        }
     181
    173182        public void visitVirtual(Way w) {
    174183                Iterator<Node> it = w.nodes.iterator();
     
    178187                        {
    179188                                Point p = nc.getPoint(it.next().eastNorth);
    180                                 if(isSegmentVisible(lastP, p))
     189                                if(isSegmentVisible(lastP, p) && isLargeSegment(lastP, p, virtualNodeSpace))
    181190                                {
    182                                         int xd = p.x-lastP.x; if(xd < 0) xd = -xd;
    183                                         int yd = p.y-lastP.y; if(yd < 0) yd = -yd;
    184                                         if(xd+yd > virtualNodeSpace)
    185                                         {
    186                                                 int x = (p.x+lastP.x)/2;
    187                                                 int y = (p.y+lastP.y)/2;
    188                                                 currentPath.moveTo(x-5, y);
    189                                                 currentPath.lineTo(x+5, y);
    190                                                 currentPath.moveTo(x, y-5);
    191                                                 currentPath.lineTo(x, y+5);
    192                                         }
     191                                        int x = (p.x+lastP.x)/2;
     192                                        int y = (p.y+lastP.y)/2;
     193                                        currentPath.moveTo(x-5, y);
     194                                        currentPath.lineTo(x+5, y);
     195                                        currentPath.moveTo(x, y-5);
     196                                        currentPath.lineTo(x, y+5);
    193197                                }
    194198                                lastP = p;
     
    282286         */
    283287        protected void drawOrderNumber(Point p1, Point p2, int orderNumber) {
    284                 int strlen = (""+orderNumber).length();
    285                 int x = (p1.x+p2.x)/2 - 4*strlen;
    286                 int y = (p1.y+p2.y)/2 + 4;
    287 
    288                 if (isSegmentVisible(p1, p2)) {
     288                if (isSegmentVisible(p1, p2) && isLargeSegment(p1, p2, segmentNumberSpace)) {
     289                        String on = Integer.toString(orderNumber);
     290                        int strlen = on.length();
     291                        int x = (p1.x+p2.x)/2 - 4*strlen;
     292                        int y = (p1.y+p2.y)/2 + 4;
     293
     294                        if(virtualNodeSize != 0 && isLargeSegment(p1, p2, virtualNodeSpace))
     295                        {
     296                                y = (p1.y+p2.y)/2 - virtualNodeSize - 3;
     297                        }
     298
     299                        displaySegments(currentColor); // draw nodes on top!
    289300                        Color c = g.getColor();
    290301                        g.setColor(backgroundColor);
    291302                        g.fillRect(x-1, y-12, 8*strlen+1, 14);
    292303                        g.setColor(c);
    293                         g.drawString(""+orderNumber, x, y);
     304                        g.drawString(on, x, y);
    294305                }
    295306        }
  • trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java

    r845 r860  
    188188                                double perDist = a-(a-b+c)*(a-b+c)/4/c; // perpendicular distance squared
    189189                                if (perDist < snapDistance && a < c+snapDistance && b < c+snapDistance) {
     190                                        if(w.selected) // prefer selected ways a little bit
     191                                                perDist -= 0.00001;
    190192                                        List<WaySegment> l;
    191193                                        if (nearest.containsKey(perDist)) {
Note: See TracChangeset for help on using the changeset viewer.