Changeset 13652 in osm for applications/editors/josm/plugins/wmsplugin/src
- Timestamp:
- 2009-02-10T20:57:50+01:00 (16 years ago)
- Location:
- applications/editors/josm/plugins/wmsplugin/src/wmsplugin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/wmsplugin/src/wmsplugin/GeorefImage.java
r13645 r13652 3 3 import java.awt.Dimension; 4 4 import java.awt.Graphics; 5 import java.awt.Image; 5 6 import java.awt.Point; 7 import java.awt.Toolkit; 6 8 import java.awt.image.BufferedImage; 9 import java.awt.image.FilteredImageSource; 10 import java.awt.image.ImageProducer; 11 import java.awt.image.RGBImageFilter; 7 12 import java.io.IOException; 8 13 import java.io.ObjectInputStream; … … 12 17 import javax.imageio.ImageIO; 13 18 19 import org.openstreetmap.josm.Main; 14 20 import org.openstreetmap.josm.data.coor.EastNorth; 15 21 import org.openstreetmap.josm.gui.NavigatableComponent; … … 69 75 } 70 76 77 boolean alphaChannel = Main.pref.getBoolean("wmsplugin.alpha_channel"); 78 Image ppImg = image; 79 if(!alphaChannel) { 80 // set alpha value to 255 81 ppImg = clearAlpha(image); 82 } 83 71 84 // We haven't got a saved resized copy, so resize and cache it 72 reImg = new BufferedImage(width, height, BufferedImage.TYPE_INT_ RGB);73 reImg.getGraphics().drawImage( image,85 reImg = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); 86 reImg.getGraphics().drawImage(ppImg, 74 87 0, 0, width, height, // dest 75 0, 0, image.getWidth(), image.getHeight(), // src88 0, 0, ppImg.getWidth(null), ppImg.getHeight(null), // src 76 89 null); 77 90 … … 95 108 ImageIO.write(image, "png", ImageIO.createImageOutputStream(out)); 96 109 } 110 111 private Image clearAlpha(Image img) { 112 ImageProducer ip = img.getSource(); 113 RGBImageFilter filter = new RGBImageFilter() { 114 public int filterRGB(int x, int y, int rgb) { 115 return rgb | 0xff000000; 116 } 117 }; 118 ImageProducer filt_ip = new FilteredImageSource(ip, filter); 119 Image out_img = Toolkit.getDefaultToolkit().createImage(filt_ip); 120 121 return out_img; 122 } 97 123 } -
applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSLayer.java
r13645 r13652 3 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 4 5 import java.lang.Math;6 5 import java.awt.Component; 7 6 import java.awt.Graphics; … … 13 12 import java.io.ObjectInputStream; 14 13 import java.io.ObjectOutputStream; 14 import java.util.concurrent.ExecutorService; 15 import java.util.concurrent.Executors; 15 16 16 17 import javax.swing.AbstractAction; 17 18 import javax.swing.Icon; 18 19 import javax.swing.ImageIcon; 20 import javax.swing.JCheckBoxMenuItem; 19 21 import javax.swing.JFileChooser; 20 import javax.swing.JCheckBoxMenuItem;21 22 import javax.swing.JMenuItem; 22 23 import javax.swing.JOptionPane; … … 26 27 import org.openstreetmap.josm.Main; 27 28 import org.openstreetmap.josm.actions.ExtensionFileFilter; 29 import org.openstreetmap.josm.data.Bounds; 30 import org.openstreetmap.josm.data.coor.EastNorth; 31 import org.openstreetmap.josm.data.coor.LatLon; 28 32 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 29 import org.openstreetmap.josm.data.Bounds;30 import org.openstreetmap.josm.data.coor.LatLon;31 33 import org.openstreetmap.josm.gui.MapView; 32 import java.util.concurrent.ExecutorService;33 import java.util.concurrent.Executors;34 35 34 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; 36 35 import org.openstreetmap.josm.gui.dialogs.LayerListPopup; 37 36 import org.openstreetmap.josm.gui.layer.Layer; 38 37 import org.openstreetmap.josm.tools.ImageProvider; 39 import org.openstreetmap.josm.data.coor.EastNorth;40 38 41 39 /** … … 61 59 protected GeorefImage[][] images = new GeorefImage[dax][day]; 62 60 JCheckBoxMenuItem startstop = new JCheckBoxMenuItem(tr("Automatic downloading"), true); 63 61 protected JCheckBoxMenuItem alphaChannel = new JCheckBoxMenuItem(new ToggleAlphaAction()); 64 62 protected String baseURL; 65 63 protected final int serializeFormatVersion = 4; … … 75 73 public WMSLayer(String name, String baseURL) { 76 74 super(name); 75 alphaChannel.setSelected(Main.pref.getBoolean("wmsplugin.alpha_channel")); 77 76 background = true; /* set global background variable */ 78 77 initializeImages(); … … 81 80 mv = Main.map.mapView; 82 81 getPPD(); 83 82 84 83 executor = Executors.newFixedThreadPool(3); 85 84 } … … 166 165 return; 167 166 } 168 167 169 168 for(int x = bminx; x<bmaxx; ++x) 170 169 for(int y = bminy; y<bmaxy; ++y){ … … 203 202 new JSeparator(), 204 203 startstop, 204 alphaChannel, 205 205 new JMenuItem(new changeResolutionAction()), 206 206 new JMenuItem(new downloadAction()), … … 237 237 getPPD(); 238 238 mv.repaint(); 239 } 240 } 241 242 public class ToggleAlphaAction extends AbstractAction { 243 public ToggleAlphaAction() { 244 super(tr("Alpha channel")); 245 } 246 public void actionPerformed(ActionEvent ev) { 247 JCheckBoxMenuItem checkbox = (JCheckBoxMenuItem) ev.getSource(); 248 boolean alphaChannel = checkbox.isSelected(); 249 Main.pref.put("wmsplugin.alpha_channel", alphaChannel); 250 Main.map.repaint(); 239 251 } 240 252 }
Note:
See TracChangeset
for help on using the changeset viewer.