Changeset 1270 in josm


Ignore:
Timestamp:
2009-01-15T22:33:35+01:00 (15 years ago)
Author:
ulfl
Message:

move two properties from OsmPrimitive to Way to save some memory (we have a lot less Ways than Nodes)

add some more global on/off switches for drawing features (fillareas, strokes, icons, annotate) where you can set the maximum distance as displayed on the map. Feature (fillarea, ...) will only be drawn if current distance scaler as shown on the top left of the map is smaller than the setting. The defaults are 100000m which means "always shown".

Location:
trunk/src/org/openstreetmap/josm/data/osm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java

    r1263 r1270  
    4141    /* mappaint data */
    4242    public ElemStyle mappaintStyle = null;
    43     public boolean isMappaintArea = false;
    4443    public Integer mappaintVisibleCode = 0;
    4544    public Integer mappaintDrawnCode = 0;
    46     public Integer mappaintDrawnAreaCode = 0;
    4745    public Collection<String> errors;
    4846
  • trunk/src/org/openstreetmap/josm/data/osm/Way.java

    r1264 r1270  
    2626    public final List<Node> nodes = new ArrayList<Node>();
    2727
     28    /* mappaint data */
     29    public boolean isMappaintArea = false;
     30    public Integer mappaintDrawnAreaCode = 0;
     31    /* end of mappaint data */
     32   
    2833    public void visitNodes(Visitor v) {
    2934        for (Node n : this.nodes)
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java

    r1267 r1270  
    2828import org.openstreetmap.josm.data.osm.Way;
    2929import org.openstreetmap.josm.data.osm.visitor.SimplePaintVisitor;
     30import org.openstreetmap.josm.data.coor.LatLon;
    3031import org.openstreetmap.josm.gui.mappaint.AreaElemStyle;
    3132import org.openstreetmap.josm.gui.mappaint.ElemStyle;
     
    3839    protected boolean useRealWidth;
    3940    protected boolean zoomLevelDisplay;
    40     protected boolean fillAreas;
     41    protected int fillAreas;
    4142    protected boolean drawMultipolygon;
    42     protected boolean showName;
     43    protected int showNames;
     44    protected int showIcons;
     45    protected int useStrokes;
    4346    protected int fillAlpha;
    4447    protected Color untaggedColor;
     
    5053    protected ElemStyles.StyleSet styles;
    5154    protected double circum;
     55    protected double dist;
    5256    protected String regionalNameOrder[];
    5357    protected Boolean selectedCall;
     
    8488        if(osm.mappaintStyle == null && styles != null) {
    8589            osm.mappaintStyle =  styles.get(osm);
    86             osm.isMappaintArea = styles.isArea(osm);
     90            if(osm instanceof Way)
     91                ((Way)osm).isMappaintArea = styles.isArea(osm);
    8792        }
    8893        return osm.mappaintStyle;
    8994    }
    9095
    91     public boolean isPrimitiveArea(OsmPrimitive osm) {
     96    public boolean isPrimitiveArea(Way osm) {
    9297        if(!useStyleCache)
    93             return styles.isArea((Way)osm);
     98            return styles.isArea(osm);
    9499
    95100        if(osm.mappaintStyle == null && styles != null) {
    96101            osm.mappaintStyle = styles.get(osm);
    97             osm.isMappaintArea = styles.isArea(osm);
     102            if(osm instanceof Way)
     103                osm.isMappaintArea = styles.isArea(osm);
    98104        }
    99105        return osm.isMappaintArea;
     
    123129            return;
    124130
    125         if (nodeStyle != null && isZoomOk(nodeStyle))
     131        if (nodeStyle != null && isZoomOk(nodeStyle) && showIcons > dist)
    126132            drawNode(n, nodeStyle.icon, nodeStyle.annotate, n.selected);
    127133        else if (n.selected)
     
    161167
    162168        w.mappaintVisibleCode = 0;
    163         if(fillAreas)
     169        if(fillAreas > dist)
    164170            w.clearErrors();
    165171
     
    183189            if(!profilerOmitDraw)
    184190            {
    185                 if (fillAreas)
     191                if (fillAreas > dist)
    186192                {
    187193                    profilerVisibleAreas++;
     
    749755        int w = icon.getIconWidth(), h=icon.getIconHeight();
    750756        icon.paintIcon ( Main.map.mapView, g, p.x-w/2, p.y-h/2 );
    751         if(showName)
     757        if(showNames > dist)
    752758        {
    753759            String name = getNodeName(n);
     
    810816            Graphics2D g2d = (Graphics2D)g;
    811817            g2d.setColor(inactive ? inactiveColor : currentColor);
    812             if (currentStroke == null) {
     818            if (currentStroke == null && useStrokes > dist) {
    813819                if (currentDashed)
    814820                    g2d.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_BUTT,BasicStroke.JOIN_ROUND,0,new float[] {9},0));
     
    817823            }
    818824            g2d.draw(currentPath);
    819             g2d.setStroke(new BasicStroke(1));
     825            if(useStrokes > dist)
     826                g2d.setStroke(new BasicStroke(1));
    820827
    821828            currentPath = new GeneralPath();
     
    846853                g.drawRect(p.x - radius, p.y - radius, size, size);
    847854
    848             if(showName)
     855            if(showNames > dist)
    849856            {
    850857                String name = getNodeName(n);
     
    875882       
    876883        useStyleCache = Main.pref.getBoolean("mappaint.cache",true);
    877         fillAreas = Main.pref.getBoolean("mappaint.fillareas", true);
     884        fillAreas = Main.pref.getInteger("mappaint.fillareas", 100000);
    878885        fillAlpha = Math.min(255, Math.max(0, Integer.valueOf(Main.pref.getInteger("mappaint.fillalpha", 50))));
    879         showName = Main.pref.getBoolean("mappaint.showname", true);
     886        showNames = Main.pref.getInteger("mappaint.shownames", 100000);
     887        showIcons = Main.pref.getInteger("mappaint.showicons", 100000);
     888        useStrokes = Main.pref.getInteger("mappaint.strokes", 100000);
    880889
    881890        long profilerStart = java.lang.System.currentTimeMillis();
     
    885894            System.out.println("Mappaint Profiler (" +
    886895                (useStyleCache ? "cache=true, " : "cache=false, ") +
    887                 (fillAreas ? "fillareas=true, " : "fillareas=false, ") +
     896                "fillareas " + fillAreas + ", " +
    888897                "fillalpha=" + fillAlpha + "%)");
    889898
     
    908917        profilerVisibleSegments = 0;
    909918
     919        LatLon ll1 = nc.getLatLon(0,0);
     920        LatLon ll2 = nc.getLatLon(100,0);
     921        dist = ll1.greatCircleDistance(ll2);
     922        System.out.format("Circum   : %4f Dist: %f\n", circum, dist);
     923       
    910924        if(profiler)
    911925        {
     
    914928        }
    915929
    916         if (fillAreas && styles != null && styles.hasAreas()) {
     930        if (fillAreas > dist && styles != null && styles.hasAreas()) {
    917931            Collection<Way> noAreaWays = new LinkedList<Way>();
    918932
     
    959973            /*** WAYS ***/
    960974            profilerN = 0;
    961             fillAreas = false;
     975            fillAreas = 0;
    962976            for (final OsmPrimitive osm : noAreaWays)
    963977            {
Note: See TracChangeset for help on using the changeset viewer.