|
From: James M. <jma...@us...> - 2001-12-03 21:43:33
|
Update of /cvsroot/geotools/geotools/src/demonstrations In directory usw-pr-cvs1:/tmp/cvs-serv27234 Modified Files: ImageExample.java ImageExample.html Log Message: Moved image bounds into the param tags of the applet Index: ImageExample.java =================================================================== RCS file: /cvsroot/geotools/geotools/src/demonstrations/ImageExample.java,v retrieving revision 1.3 retrieving revision 1.4 diff -w -C2 -d -r1.3 -r1.4 *** ImageExample.java 2001/09/18 11:35:57 1.3 --- ImageExample.java 2001/12/03 21:43:29 1.4 *************** *** 4,7 **** --- 4,8 ---- import java.net.*; import java.io.*; + import java.util.StringTokenizer; import uk.ac.leeds.ccg.geotools.*; *************** *** 13,27 **** * and the image needs to be on the same server as the applet, otherwise you * will get java security problems. * * @author Cameron Shorter <a href="mailto:ca...@sh...">ca...@sh...</a> */ ! public class ImageExample extends java.applet.Applet ! { Viewer view = new Viewer(); Theme currentTheme; - GeoRectangle extent = new GeoRectangle(0,0,100,100); ImageLayer iLayer; - String imageString; - URL imageURL; public void init(){ --- 14,25 ---- * and the image needs to be on the same server as the applet, otherwise you * will get java security problems. + * JM: Not sure this is true, works fine in a browser run localy for me... * * @author Cameron Shorter <a href="mailto:ca...@sh...">ca...@sh...</a> */ ! public class ImageExample extends java.applet.Applet { Viewer view = new Viewer(); Theme currentTheme; ImageLayer iLayer; public void init(){ *************** *** 33,48 **** public void start(){ try{ ! imageString = this.getParameter("image"); ! imageURL = new URL(getCodeBase(),imageString); } catch(IOException e){ this.showStatus("Error loading file "+ imageString + "\n" + e); } - - iLayer=new ImageLayer(this.imageURL,this.extent); - this.currentTheme=new Theme(iLayer); - this.view.addTheme(this.currentTheme); - view.setMapExtent(this.extent); } --- 31,60 ---- public void start(){ + //get the name of the image to display + String imageString = this.getParameter("image"); + //and its bounds (in the form x,y,width,height) + String boundsString = this.getParameter("bounds"); + //get each part of the bounds. + StringTokenizer tok = new StringTokenizer(boundsString,","); + double x = new Double(tok.nextToken()).doubleValue(); + double y = new Double(tok.nextToken()).doubleValue(); + double w = new Double(tok.nextToken()).doubleValue(); + double h = new Double(tok.nextToken()).doubleValue(); + //construct a GeoRectangle + GeoRectangle extent = new GeoRectangle(x,y,w,h); + try{ ! //create a URL that points to the image ! URL imageURL = new URL(getCodeBase(),imageString); ! //construct an image layer from the image and the bounds ! iLayer=new ImageLayer(imageURL,extent); ! //create a theme using the image layer ! currentTheme=new Theme(iLayer); ! //add the image to the viewer. ! view.addTheme(this.currentTheme); } catch(IOException e){ this.showStatus("Error loading file "+ imageString + "\n" + e); } } Index: ImageExample.html =================================================================== RCS file: /cvsroot/geotools/geotools/src/demonstrations/ImageExample.html,v retrieving revision 1.3 retrieving revision 1.4 diff -w -C2 -d -r1.3 -r1.4 *** ImageExample.html 2001/09/10 22:33:55 1.3 --- ImageExample.html 2001/12/03 21:43:29 1.4 *************** *** 11,22 **** <H2>A basic map which uses an image to build a map layer.</H2> <P><APPLET ARCHIVE="jars/JimiCore.jar,jars/support.jar,jars/geotools.jar,jars/collections.jar" CODE="ImageExample.class" WIDTH="470" HEIGHT="170" ALIGN="BOTTOM"> ! <PARAM NAME="image" VALUE="images/logo.gif"> </APPLET> </P> - <P><<A HREF="ImageExample.java">source</A>></P> ! <P><CODE><APPLET ARCHIVE="jars/collections.jar,jars/JimiCore.jar,jars/geotools.jar" CODE="ImageExample.class" WIDTH=430 HEIGHT=270><BR> ! <PARAM NAME="image" VALUE="images/logo.jpg"><BR> </APPLET></CODE> --- 11,23 ---- <H2>A basic map which uses an image to build a map layer.</H2> <P><APPLET ARCHIVE="jars/JimiCore.jar,jars/support.jar,jars/geotools.jar,jars/collections.jar" CODE="ImageExample.class" WIDTH="470" HEIGHT="170" ALIGN="BOTTOM"> ! <PARAM NAME="image" VALUE="maps/worldview.gif"> ! <param name="bounds" value="-180,-90,360,180"> </APPLET> </P> <P><<A HREF="ImageExample.java">source</A>></P> ! <p>The applet requires two parameters, the first 'image' points to the relative location of the image to display, whils the second 'bounds' gives the spatial extent of the image.<br> <P><CODE><APPLET ARCHIVE="jars/collections.jar,jars/JimiCore.jar,jars/geotools.jar" CODE="ImageExample.class" WIDTH=430 HEIGHT=270><BR> ! <PARAM NAME="image" VALUE="maps/worldview.gif"><BR> ! <PARAM NAME="bounds" VALUE="-180,-90,360,180"><BR> </APPLET></CODE> |