Ignore:
Timestamp:
19.01.2012 19:58:08 (4 months ago)
Author:
bastiK
Message:

make identity of map icons depend on the name and not the image data (see #6797)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/MapPainter.java

    r4724 r4822  
    4646import org.openstreetmap.josm.gui.mappaint.BoxTextElemStyle.HorizontalTextAlignment; 
    4747import org.openstreetmap.josm.gui.mappaint.BoxTextElemStyle.VerticalTextAlignment; 
     48import org.openstreetmap.josm.gui.mappaint.MapImage; 
    4849import org.openstreetmap.josm.gui.mappaint.NodeElemStyle; 
    4950import org.openstreetmap.josm.gui.mappaint.NodeElemStyle.Symbol; 
     
    505506    } 
    506507 
    507     public void drawLinePattern(Way way, ImageIcon pattern) { 
    508         final int width = pattern.getIconWidth(); 
    509         final int height = pattern.getIconHeight(); 
     508    public void drawLinePattern(Way way, Image pattern) { 
     509        final int width = pattern.getWidth(null); 
     510        final int height = pattern.getHeight(null); 
    510511 
    511512        Point lastP = null; 
     
    530531 
    531532                if (dist > 0) { 
    532                     g.drawImage(pattern.getImage(), 0, 0, (int) dist, height, 
     533                    g.drawImage(pattern, 0, 0, (int) dist, height, 
    533534                            width - (int) dist, 0, width, height, null); 
    534535                } 
    535536                while (dist < segmentLength) { 
    536537                    if (dist + width > segmentLength) { 
    537                         g.drawImage(pattern.getImage(), (int) dist, 0, (int) segmentLength, height, 
     538                        g.drawImage(pattern, (int) dist, 0, (int) segmentLength, height, 
    538539                                0, 0, (int) segmentLength - (int) dist, height, null); 
    539540                    } else { 
    540                         pattern.paintIcon(nc, g, (int) dist, 0); 
     541                        g.drawImage(pattern, (int) dist, 0, nc); 
    541542                    } 
    542543                    dist += width; 
     
    550551    } 
    551552 
    552     public void drawNodeIcon(Node n, ImageIcon icon, float iconAlpha, boolean selected, boolean member) { 
     553    public void drawNodeIcon(Node n, Image img, float alpha, boolean selected, boolean member) { 
    553554        Point p = nc.getPoint(n); 
    554555 
    555         final int w = icon.getIconWidth(), h=icon.getIconHeight(); 
     556        final int w = img.getWidth(null), h=img.getHeight(null); 
    556557        if(n.isHighlighted()) { 
    557558            drawPointHighlight(p, Math.max(w, h)); 
    558559        } 
    559560 
    560         if (iconAlpha != 1f) { 
    561             g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, iconAlpha)); 
    562         } 
    563         icon.paintIcon ( nc, g, p.x-w/2, p.y-h/2 ); 
     561        if (alpha != 1f) { 
     562            g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha)); 
     563        } 
     564        g.drawImage(img, p.x-w/2, p.y-h/2, nc); 
    564565        g.setPaintMode(); 
    565566        if (selected || member) 
     
    802803    } 
    803804 
    804     public void drawArea(Way w, Color color, BufferedImage fillImage, float fillImageAlpha, TextElement text) { 
    805         drawArea(w, getPath(w), color, fillImage, fillImageAlpha, text); 
    806     } 
    807  
    808     protected void drawArea(OsmPrimitive osm, Path2D.Double path, Color color, BufferedImage fillImage, float fillImageAlpha, TextElement text) { 
     805    public void drawArea(Way w, Color color, MapImage<BufferedImage> fillImage, TextElement text) { 
     806        drawArea(w, getPath(w), color, fillImage, text); 
     807    } 
     808 
     809    protected void drawArea(OsmPrimitive osm, Path2D.Double path, Color color, MapImage<BufferedImage> fillImage, TextElement text) { 
    809810 
    810811        Shape area = path.createTransformedShape(nc.getAffineTransform()); 
     
    815816                g.fill(area); 
    816817            } else { 
    817                 TexturePaint texture = new TexturePaint(fillImage, 
     818                TexturePaint texture = new TexturePaint(fillImage.img, 
    818819                        //                        new Rectangle(polygon.xpoints[0], polygon.ypoints[0], fillImage.getWidth(), fillImage.getHeight())); 
    819                         new Rectangle(0, 0, fillImage.getWidth(), fillImage.getHeight())); 
     820                        new Rectangle(0, 0, fillImage.img.getWidth(null), fillImage.img.getHeight(null))); 
    820821                g.setPaint(texture); 
    821                 if (fillImageAlpha != 1f) { 
    822                     g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, fillImageAlpha)); 
     822                if (fillImage.alpha != 1f) { 
     823                    g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, fillImage.alpha)); 
    823824                } 
    824825                g.fill(area); 
     
    871872    } 
    872873 
    873     public void drawArea(Relation r, Color color, BufferedImage fillImage, float fillImageAlpha, TextElement text) { 
     874    public void drawArea(Relation r, Color color, MapImage<BufferedImage> fillImage, TextElement text) { 
    874875        Multipolygon multipolygon = MultipolygonCache.getInstance().get(nc, r); 
    875876        if (!r.isDisabled() && !multipolygon.getOuterWays().isEmpty()) { 
     
    881882                drawArea(r, p, 
    882883                        pd.selected ? settings.getRelationSelectedColor(color.getAlpha()) : color, 
    883                                 fillImage, fillImageAlpha, text); 
     884                                fillImage, text); 
    884885            } 
    885886        } 
     
    898899    } 
    899900 
    900     public void drawRestriction(ImageIcon icon, Point pVia, double vx, double vx2, double vy, double vy2, double iconAngle, boolean selected) { 
    901         /* rotate icon with direction last node in from to */ 
    902         ImageIcon rotatedIcon = ImageProvider.createRotatedImage(null /*icon2*/, icon, iconAngle); 
    903  
    904         /* scale down icon to 16*16 pixels */ 
    905         ImageIcon smallIcon = new ImageIcon(rotatedIcon.getImage().getScaledInstance(16 , 16, Image.SCALE_SMOOTH)); 
    906         int w = smallIcon.getIconWidth(), h=smallIcon.getIconHeight(); 
    907         smallIcon.paintIcon (nc, g, (int)(pVia.x+vx+vx2)-w/2, (int)(pVia.y+vy+vy2)-h/2 ); 
     901    public void drawRestriction(Image img, Point pVia, double vx, double vx2, double vy, double vy2, double angle, boolean selected) { 
     902        /* rotate image with direction last node in from to */ 
     903        Image rotatedImg = ImageProvider.createRotatedImage(null , img, angle); 
     904 
     905        /* scale down image to 16*16 pixels */ 
     906        Image smallImg = new ImageIcon(rotatedImg.getScaledInstance(16 , 16, Image.SCALE_SMOOTH)).getImage(); 
     907        int w = smallImg.getWidth(null), h=smallImg.getHeight(null); 
     908        g.drawImage(smallImg, (int)(pVia.x+vx+vx2)-w/2, (int)(pVia.y+vy+vy2)-h/2, nc); 
    908909 
    909910        if (selected) { 
     
    913914    } 
    914915 
    915     public void drawRestriction(Relation r, NodeElemStyle icon) { 
     916    public void drawRestriction(Relation r, MapImage<Image> icon) { 
    916917        Way fromWay = null; 
    917918        Way toWay = null; 
     
    10841085        } 
    10851086 
    1086         drawRestriction(inactive || r.isDisabled() ? icon.getDisabledIcon() : icon.icon, 
     1087        drawRestriction(inactive || r.isDisabled() ? icon.getDisabled() : icon.img, 
    10871088                pVia, vx, vx2, vy, vy2, iconAngle, r.isSelected()); 
    10881089    } 
Note: See TracChangeset for help on using the changeset viewer.