Ignore:
Timestamp:
2007-07-15T03:44:47+02:00 (19 years ago)
Author:
ulf
Message:

fix the whole XML handler, so the sequence of the XML tags doesn't matter

optional new feature (experimental): show/hide elements depending on current zoomlevel and scale_max setting in elemstyles.xml. Can be enabled by setting mappaint.zoomLevelDisplay to true (default is false). It's working fine, but is still really experimental, as the scale_max settings in elemstyles.xml currently doesn't make a lot of sense (at least for editing).

File:
1 edited

Legend:

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

    r2853 r3591  
    3030public class MapPaintVisitor extends SimplePaintVisitor {
    3131
     32        protected boolean isZoomOk(ElemStyle e) {
     33                double circum = Main.map.mapView.getScale()*100*Main.proj.scaleFactor()*40041455; // circumference of the earth in meter
     34               
     35                /* show everything, if the user wishes so */
     36                if(!Main.pref.getBoolean("mappaint.zoomLevelDisplay",false)) {
     37                        return true;
     38                }
     39                       
     40                if(e == null) {
     41                        /* the default for things that don't have a rule (show, if scale is smaller than 1500m) */
     42                        if(circum < 1500) {
     43                                return true;
     44                        } else {
     45                                return false;
     46                        }
     47                }
     48               
     49                if(circum>=e.getMinZoom() / 70) {
     50                        return false;
     51                } else {
     52                        return true;
     53                }
     54        }
     55       
    3256        /**
    3357         * Draw a small rectangle.
     
    3963        @Override public void visit(Node n) {
    4064                ElemStyle nodeStyle = MapPaintPlugin.elemStyles.getStyle(n);
    41                 if(nodeStyle!=null && Main.map.mapView.zoom()>=nodeStyle.getMinZoom()){
     65                if(nodeStyle!=null){
    4266                        if(nodeStyle instanceof IconElemStyle) {
    43                                 drawNode(n, ((IconElemStyle)nodeStyle).getIcon());
     67                                if(isZoomOk(nodeStyle)) {
     68                                        drawNode(n, ((IconElemStyle)nodeStyle).getIcon());
     69                                }
    4470                        } else {
    4571                                // throw some sort of exception
     
    5884         */
    5985        @Override public void visit(Segment ls) {
     86                ElemStyle segmentStyle = MapPaintPlugin.elemStyles.getStyle(ls);
     87                if(isZoomOk(segmentStyle)) {
    6088                        drawSegment(ls, getPreferencesColor("untagged",Color.GRAY),Main.pref.getBoolean("draw.segment.direction"));
     89                }
    6190        }
    6291
     
    75104                boolean area=false;
    76105                ElemStyle wayStyle = MapPaintPlugin.elemStyles.getStyle(w);
     106               
     107                if(!isZoomOk(wayStyle)) {
     108                        return;
     109                }
     110               
    77111                if(wayStyle!=null)
    78112                {
     
    188222                Point p1 = nc.getPoint(ls.from.eastNorth);
    189223                Point p2 = nc.getPoint(ls.to.eastNorth);
    190 
     224               
    191225                // checking if this segment is visible
    192226                if ((p1.x < 0) && (p2.x < 0)) return ;
     
    223257         */
    224258        @Override public void drawNode(Node n, Color color) {
    225                 Point p = nc.getPoint(n.eastNorth);
    226                 if ((p.x < 0) || (p.y < 0) || (p.x > nc.getWidth()) || (p.y > nc.getHeight())) return;
    227                 g.setColor(color);
    228                 g.drawRect(p.x-1, p.y-1, 2, 2);
     259                if(isZoomOk(null)) {
     260                        Point p = nc.getPoint(n.eastNorth);
     261                        if ((p.x < 0) || (p.y < 0) || (p.x > nc.getWidth()) || (p.y > nc.getHeight())) return;
     262                        g.setColor(color);
     263                        g.drawRect(p.x-1, p.y-1, 2, 2);
     264                }
    229265        }
    230266
Note: See TracChangeset for help on using the changeset viewer.