Ignore:
Timestamp:
2012-03-08T12:11:38+01:00 (12 years ago)
Author:
bastiK
Message:

see #6797: load map images in background, in case they are loaded over a network. Show temporary image in the meantime.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/AreaElemStyle.java

    r4960 r5054  
    55
    66import java.awt.Color;
    7 import java.awt.image.BufferedImage;
    8 
    9 import javax.swing.ImageIcon;
    107
    118import org.openstreetmap.josm.Main;
     
    2724     */
    2825    public Color color;
    29     public MapImage<BufferedImage> fillImage;
     26    public MapImage fillImage;
    3027    public TextElement text;
    3128
    32     protected AreaElemStyle(Cascade c, Color color, MapImage<BufferedImage> fillImage, TextElement text) {
     29    protected AreaElemStyle(Cascade c, Color color, MapImage fillImage, TextElement text) {
    3330        super(c, -1000f);
    3431        CheckParameterUtil.ensureParameterNotNull(color);
     
    3936
    4037    public static AreaElemStyle create(Cascade c) {
    41         MapImage<BufferedImage> fillImage = null;
     38        MapImage fillImage = null;
    4239        Color color = null;
    4340
    4441        IconReference iconRef = c.get("fill-image", null, IconReference.class);
    4542        if (iconRef != null) {
    46             ImageIcon icon = MapPaintStyles.getIcon(iconRef, -1, -1);
    47             if (icon != null) {
    48                 if (!(icon.getImage() instanceof BufferedImage))
    49                     throw new RuntimeException();
    50                 fillImage = new MapImage<BufferedImage>(iconRef.iconName, iconRef.source);
    51                 fillImage.img = (BufferedImage) icon.getImage();
     43            fillImage = new MapImage(iconRef.iconName, iconRef.source);
     44            fillImage.getImage();
    5245
    53                 color = new Color(fillImage.img.getRGB(
    54                         fillImage.img.getWidth() / 2, fillImage.img.getHeight() / 2)
    55                 );
     46            color = new Color(fillImage.getImage().getRGB(
     47                    fillImage.getWidth() / 2, fillImage.getHeight() / 2)
     48            );
    5649
    57                 fillImage.alpha = Math.min(255, Math.max(0, Integer.valueOf(Main.pref.getInteger("mappaint.fill-image-alpha", 255))));
    58                 Integer pAlpha = Utils.color_float2int(c.get("fill-opacity", null, float.class));
    59                 if (pAlpha != null) {
    60                     fillImage.alpha = pAlpha;
    61                 }
     50            fillImage.alpha = Math.min(255, Math.max(0, Integer.valueOf(Main.pref.getInteger("mappaint.fill-image-alpha", 255))));
     51            Integer pAlpha = Utils.color_float2int(c.get("fill-opacity", null, float.class));
     52            if (pAlpha != null) {
     53                fillImage.alpha = pAlpha;
    6254            }
    6355        } else {
     
    7870            text = TextElement.create(c, PaintColors.AREA_TEXT.get(), true);
    7971        }
    80        
     72
    8173        if (color != null)
    8274            return new AreaElemStyle(c, color, fillImage, text);
Note: See TracChangeset for help on using the changeset viewer.