Ignore:
Timestamp:
2007-10-07T13:57:09+02:00 (17 years ago)
Author:
frederik
Message:

changes for 0.5 compatibility

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/mappaint/src/mappaint/MapPaintVisitor.java

    r4423 r4847  
    1717import org.openstreetmap.josm.Main;
    1818import org.openstreetmap.josm.data.osm.Node;
    19 import org.openstreetmap.josm.data.osm.Segment;
    2019import org.openstreetmap.josm.data.osm.Way;
    2120import org.openstreetmap.josm.data.osm.DataSet;
     
    5655                }
    5756               
    58                 // formular to calculate a map scale: natural size / map size = scale
     57                // formula to calculate a map scale: natural size / map size = scale
    5958                // example: 876000mm (876m as displayed) / 22mm (roughly estimated screen size of legend bar) = 39818
    6059                //
     
    9594
    9695        /**
    97          * Draw just a line between the points.
    98          * White if selected (as always) or grey otherwise.
    99          * Want to make un-wayed segments stand out less than ways.
    100          */
    101         @Override public void visit(Segment ls) {
    102                 ElemStyle segmentStyle = MapPaintPlugin.elemStyles.getStyle(ls);
    103                 if(isZoomOk(segmentStyle)) {
    104                         drawSegment(ls, untaggedColor, showDirectionArrow);
    105                 }
    106         }
    107 
    108         /**
    10996         * Draw a line for all segments, according to tags.
    11097         * @param w The way to draw.
     
    145132                        drawWayAsArea(w, colour);
    146133                int orderNumber = 0;
    147                 for (Segment ls : w.segments)
    148                 {
     134               
     135                Node lastN = null;
     136                for (Node n : w.nodes) {
     137                        if (lastN == null) {
     138                                lastN = n;
     139                                continue;
     140                        }
    149141                        orderNumber++;
    150                                 if (area && fillAreas)
    151                                         //Draw segments in a different colour so direction arrows show against the fill
    152                                         drawSegment(ls, w.selected ? selectedColor : untaggedColor, showDirection, width,true);
     142        //              drawSegment(lastN, n, w.selected && !inactive ? selectedColor : wayColor, showDirectionArrow);
     143
     144                        if (area && fillAreas)
     145                                //Draw segments in a different colour so direction arrows show against the fill
     146                                drawSeg(lastN, n, w.selected ? selectedColor : untaggedColor, showDirection, width, true);
     147                        else
     148                                if (area)
     149                                        drawSeg(lastN, n, w.selected ? selectedColor : colour, showDirection, width, true);
    153150                                else
    154                                         if (area)
    155                                                 drawSegment(ls, w.selected ? selectedColor : colour, showDirection, width,true);
    156                                         else
    157                                                 if (realWidth > 0 && useRealWidth && !showDirection){
    158                                                         int tmpWidth = (int) (100 /  (float) (circum / realWidth));
    159                                                         if (tmpWidth > width) width = tmpWidth;
    160                                                 }
    161 
    162                                                 drawSegment(ls, w.selected ? selectedColor : colour,showDirection, width,dashed);
    163                                 if (!ls.incomplete && showOrderNumber)
    164                                 {
    165                                         try
    166                                         {
    167                                                 g.setColor(w.selected ? selectedColor : colour);
    168                                                 drawOrderNumber(ls, orderNumber);
     151                                        if (realWidth > 0 && useRealWidth && !showDirection){
     152                                                int tmpWidth = (int) (100 /  (float) (circum / realWidth));
     153                                                if (tmpWidth > width) width = tmpWidth;
    169154                                        }
    170                                         catch (IllegalAccessError e) {} //SimplePaintVisitor::drawOrderNumber was private prior to rev #211
    171                                 }
     155
     156                                        drawSeg(lastN, n, w.selected ? selectedColor : colour, showDirection, width, dashed);
     157
     158                                        if (showOrderNumber)
     159                                                drawOrderNumber(lastN, n, orderNumber);
     160                       
     161                        lastN = n;
    172162                }
    173163        }
     
    178168                Polygon polygon = new Polygon();
    179169                Point p;
    180                 boolean first=true;
    181                 for (Segment ls : w.segments)
     170                for (Node n : w.nodes)
    182171                {
    183                     if (ls.incomplete) continue;
    184                         if(first)
    185                         {
    186                                 p = nc.getPoint(ls.from.eastNorth);
    187                                 polygon.addPoint(p.x,p.y);
    188                                 first=false;
    189                         }
    190                         p = nc.getPoint(ls.to.eastNorth);
     172                        p = nc.getPoint(n.eastNorth);
    191173                        polygon.addPoint(p.x,p.y);
    192174                }
     
    224206         */
    225207        // Altered - now specify width
    226         @Override protected void drawSegment(Segment ls, Color col,boolean showDirection) {
    227                         if (useRealWidth && showDirection && !ls.selected) showDirection = false;
    228                         drawSegment(ls,col,showDirection,1,false);
    229         }
    230 
    231 
    232         // Altered - now specify width
    233         private void drawSegment (Segment ls, Color col,boolean showDirection, int width,boolean dashed) {
    234                 //do not draw already visible segments
    235                 if (ls.shown) return;
    236                 ls.shown=true;
    237                 if (ls.incomplete)
    238                         return;
    239                 if (ls.selected) {
    240                     col = selectedColor;
    241                 }
    242                 drawSeg(ls, col, showDirection, width, dashed);
    243         }
    244                
    245         private void drawSeg(Segment ls, Color col,boolean showDirection, int width,boolean dashed) {
     208        @Override protected void drawSegment(Node n1, Node n2, Color col, boolean showDirection) {
     209                if (useRealWidth && showDirection) showDirection = false;
     210                drawSeg(n1, n2, col, showDirection, 1, false);
     211        }
     212
     213        private void drawSeg(Node n1, Node n2, Color col, boolean showDirection, int width, boolean dashed) {
    246214                if (col != currentColor || width != currentWidth || dashed != currentDashed) {
    247215                        displaySegments(col, width, dashed);
    248216                }
    249                 Point p1 = nc.getPoint(ls.from.eastNorth);
    250                 Point p2 = nc.getPoint(ls.to.eastNorth);
     217                Point p1 = nc.getPoint(n1.eastNorth);
     218                Point p2 = nc.getPoint(n2.eastNorth);
    251219               
    252220                // checking if this segment is visible
     
    265233
    266234                //g.drawLine(p1.x, p1.y, p2.x, p2.y);
    267                 currrentPath.moveTo(p1.x, p1.y);
    268                 currrentPath.lineTo(p2.x, p2.y);
     235                currentPath.moveTo(p1.x, p1.y);
     236                currentPath.lineTo(p2.x, p2.y);
    269237
    270238                if (showDirection) {
     
    272240                        //g.drawLine(p2.x,p2.y, (int)(p2.x + 10*Math.cos(t-PHI)), (int)(p2.y + 10*Math.sin(t-PHI)));
    273241                        //g.drawLine(p2.x,p2.y, (int)(p2.x + 10*Math.cos(t+PHI)), (int)(p2.y + 10*Math.sin(t+PHI)));
    274                         currrentPath.lineTo((int)(p2.x + 10*Math.cos(t-PHI)), (int)(p2.y + 10*Math.sin(t-PHI)));
    275                         currrentPath.moveTo((int)(p2.x + 10*Math.cos(t+PHI)), (int)(p2.y + 10*Math.sin(t+PHI)));
    276                         currrentPath.lineTo(p2.x, p2.y);
     242                        currentPath.lineTo((int)(p2.x + 10*Math.cos(t-PHI)), (int)(p2.y + 10*Math.sin(t-PHI)));
     243                        currentPath.moveTo((int)(p2.x + 10*Math.cos(t+PHI)), (int)(p2.y + 10*Math.sin(t+PHI)));
     244                        currentPath.lineTo(p2.x, p2.y);
    277245                }
    278246                //g2d.setStroke(new BasicStroke(1));
     
    286254        protected void displaySegments(Color newColor, int newWidth, boolean newDash) {
    287255           
    288                 if (currrentPath != null) {
     256                if (currentPath != null) {
    289257                        Graphics2D g2d = (Graphics2D)g;
    290258                        g2d.setColor(currentColor);
     
    295263                                g2d.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
    296264                        }
    297                         g2d.draw(currrentPath);
     265                        g2d.draw(currentPath);
    298266                        g2d.setStroke(new BasicStroke(1));
    299267                       
    300                         currrentPath = new GeneralPath();
     268                        currentPath = new GeneralPath();
    301269                        currentColor = newColor;
    302270                        currentWidth = newWidth;
     
    327295                selectedColor = getPreferencesColor("selected", Color.YELLOW);
    328296                nodeColor = getPreferencesColor("node", Color.RED);
    329                 segmentColor = getPreferencesColor("segment", darkgreen);
    330297                dfltWayColor = getPreferencesColor("way", darkblue);
    331298                incompleteColor = getPreferencesColor("incomplete way", darkerblue);
     
    341308                Collection<Way> noAreaWays = new LinkedList<Way>();
    342309
    343                 for (final OsmPrimitive osm : data.segments)
    344                         if (!osm.deleted)
    345                                 osm.shown=false;
    346 
    347310                for (final OsmPrimitive osm : data.ways)
    348311                        if (!osm.deleted && MapPaintPlugin.elemStyles.isArea(osm))
     
    354317                        osm.visit(this);
    355318
    356                 for (final OsmPrimitive osm : data.segments)
    357                         if (!osm.deleted)
    358                                 osm.visit(this);
    359319               
    360320                for (final OsmPrimitive osm : data.nodes)
Note: See TracChangeset for help on using the changeset viewer.