Fwd: BeanShell to create an image layer from a file or URL !!! gif/jpeg/png : 無料・フリー素材/写真
Fwd: BeanShell to create an image layer from a file or URL !!! gif/jpeg/png / Jon_Aquino
ライセンス | クリエイティブ・コモンズ 表示 2.1 |
---|---|
説明 | This is kind of neat. As you can see from the screenshot, oneapplication is adding logos to a map!#end---------- Forwarded message ----------From: Jonathan Aquino Date: Fri, 5 Nov 2004 23:35:15 -0800Subject: BeanShell to create an image layer from a file or URL !!! gif/jpeg/pngTo: JUMP Users Discussion This awesome idea was requested by Andrew Collins and took me twohours to write. It's a BeanShell script to create an image layer froma GIF, JPEG, or PNG file or URL !!!1. Click View > BeanShell.2. Copy the code below into the clipboard.3. Paste the code into the BeanShell window with Ctrl+V. JUMP willcreate the image layer!{minx = 100; maxx = 952; miny = 100; maxy = 489; //Image coordinatesfilenameOrURL = newURL("http://www.apsu.edu/field_biology/center/sym2001/fig1p66.jpg");//filenameOrURL = "c:/junk/Arrow.jpg";layerName = "Image";image = Toolkit.getDefaultToolkit().getImage(filenameOrURL);import com.vividsolutions.jts.geom.*;import com.vividsolutions.jump.feature.*;import com.vividsolutions.jump.geom.EnvelopeUtil;import com.vividsolutions.jump.workbench.model.*;import com.vividsolutions.jump.workbench.ui.renderer.style.Style;import com.vividsolutions.jump.workbench.ui.Viewport;mediaTracker = new MediaTracker(wc.layerViewPanel);mediaTracker.addImage(image, 0);mediaTracker.waitForID(0);envelope = new Envelope(minx, maxx, miny, maxy);wc.layerManager.addLayer(StandardCategoryNames.WORKING, layerName, FeatureDatasetFactory.createFromGeometry( Collections.singleton(EnvelopeUtil.toGeometry(envelope)))) .addStyle(new Style() { public void paint(Feature f, Graphics2D g, Viewport viewport) { originalTransform = g.getTransform(); try { xScale = viewport.scale*envelope.width/image.getWidth(null); yScale = viewport.scale*envelope.height/image.getHeight(null); g.scale(xScale, yScale); upperLeftCorner = viewport.toViewPoint(new Coordinate(minx, maxy)); g.translate(upperLeftCorner.x/xScale, upperLeftCorner.y/yScale); g.drawImage(image, 0, 0, null); } finally { g.setTransform(originalTransform); } } public void initialize(Layer layer) {} public Object clone() { throw new UnsupportedOperationException(); } public void setEnabled(boolean enabled) {} public boolean isEnabled() { return true; }});wc.layerManager.getLayer(layerName).getBasicStyle().renderingFill = false;}--jonaquino.blogspot.com |
撮影日 | 2004-11-06 08:12:53 |
撮影者 | Jon_Aquino , Victoria BC, Canada |
撮影地 |