Revision 1847

View differences:

org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.api/src/main/java/org/gvsig/tools/swing/icontheme/IconThemeManager.java
69 69
	public void clear();
70 70

  
71 71
	public FolderSet getRepository();
72
        
73
        public double getScaleFactor();
74
        
75
        public void setScaleFactor(double scaleFactor);
72 76
}
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.impl/src/main/java/org/gvsig/tools/swing/impl/icontheme/BaseIconTheme.java
24 24
package org.gvsig.tools.swing.impl.icontheme;
25 25

  
26 26
import java.awt.Image;
27
import java.awt.image.BufferedImage;
27 28
import java.io.File;
28 29
import java.io.IOException;
29 30
import java.io.InputStream;
......
41 42

  
42 43
import org.apache.commons.io.FileUtils;
43 44
import org.apache.commons.lang3.StringUtils;
45
import org.gvsig.tools.swing.api.SimpleImage;
46
import org.gvsig.tools.swing.api.ToolsSwingLocator;
44 47
import org.slf4j.Logger;
45 48
import org.slf4j.LoggerFactory;
46 49

  
47 50
import org.gvsig.tools.swing.icontheme.IconTheme;
51
import org.gvsig.tools.swing.impl.DefaultSimpleImage;
48 52

  
49 53
/**
50 54
 * <p>
......
68 72
    class DefaultIcon implements Icon {
69 73

  
70 74
        private ImageIcon image;
75
        private ImageIcon scaledImage;
71 76
        private final URL resource;
72 77
        private final String name;
73 78
        private final String group;
......
75 80

  
76 81
        DefaultIcon(String provider, String group, String name, ImageIcon image, URL resource) {
77 82
            this.image = image;
83
            this.scaledImage = this.image;
84
            if (this.image != null ) {
85
                double scaleFactor = ToolsSwingLocator.getIconThemeManager().getScaleFactor();
86
                if (scaleFactor != 1) {
87
                    SimpleImage simpleImage = new DefaultSimpleImage(this.image);
88
                    simpleImage = simpleImage.resize(scaleFactor);
89
                    this.scaledImage = new ImageIcon(simpleImage.getBufferedImage());
90
                }
91
            }
78 92
            this.resource = resource;
79 93
            this.group = group;
80 94
            this.name = name;
......
106 120

  
107 121
        @Override
108 122
        public ImageIcon getImageIcon() {
109
            if (this.image != null) {
110
                return this.image;
123
            if (this.image == null) {
124
                try {
125
                    this.image = new ImageIcon((URL) this.resource);
126
                    double scaleFactor = ToolsSwingLocator.getIconThemeManager().getScaleFactor();
127
                    if (scaleFactor != 1) {
128
                        SimpleImage simpleImage = new DefaultSimpleImage(this.image);
129
                        simpleImage = simpleImage.resize(scaleFactor);
130
                        this.scaledImage = new ImageIcon(simpleImage.getBufferedImage());
131
                    } else {
132
                        this.scaledImage = this.image;
133
                    }
134
                } catch (Exception ex) {
135
                    return null;
136
                }
111 137
            }
112
            try {
113
                this.image = new ImageIcon((URL) this.resource);
114
            } catch (Exception ex) {
115
                return null;
116
            }
117
            return this.image;
138
            return this.scaledImage;
118 139
        }
119 140

  
120 141
        @Override
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.impl/src/main/java/org/gvsig/tools/swing/impl/icontheme/DefaultIconThemeManager.java
45 45
	private Map<String, IconTheme> themesByName = null;
46 46
	private List<IconTheme> themes = null; 
47 47
	private FolderSet repository = null;
48

  
48
        private double scaleFactor = 1.0;
49
        
49 50
	public static IconThemeManager getIconThemeManager(){
50 51
		if (iconThemeManager == null){
51 52
			iconThemeManager = new DefaultIconThemeManager();
......
54 55
	}
55 56

  
56 57
	public DefaultIconThemeManager() {
58
                this.scaleFactor = 1.0;
57 59
		this.defaultTheme = new BaseIconTheme();
58 60
		this.currentTheme = this.defaultTheme;
59 61
		this.themesByName = null;
......
164 166
		}
165 167
		return this.themesByName;
166 168
	}
169
        
170
        public double getScaleFactor() {
171
            return this.scaleFactor;
172
        }
173

  
174
    public void setScaleFactor(double scaleFactor) {
175
        this.scaleFactor = scaleFactor;
176
    }
177
        
178
        
167 179
}

Also available in: Unified diff