Update of /cvsroot/geotools/geotools/src/uk/ac/leeds/ccg/raster
In directory usw-pr-cvs1:/tmp/cvs-serv31334/uk/ac/leeds/ccg/raster
Modified Files:
ImageLayer.java
Log Message:
readded support of png/tiff images
Index: ImageLayer.java
===================================================================
RCS file: /cvsroot/geotools/geotools/src/uk/ac/leeds/ccg/raster/ImageLayer.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -w -C2 -d -r1.31 -r1.32
*** ImageLayer.java 2001/12/10 16:13:57 1.31
--- ImageLayer.java 2001/12/11 10:35:00 1.32
***************
*** 5,10 ****
import uk.ac.leeds.ccg.geotools.*;
import java.net.*;
import java.awt.image.*;
! //import com.sun.jimi.core.*;
import java.awt.*;
--- 5,11 ----
import uk.ac.leeds.ccg.geotools.*;
import java.net.*;
+ import java.io.*;
import java.awt.image.*;
! import com.sun.jimi.core.*;
import java.awt.*;
***************
*** 31,35 ****
private GeoRectangle bbox = null;
private int myID = 1;
! private final static boolean DEBUG=false;
private Canvas obs = new Canvas();
private MediaTracker tracker=new MediaTracker(obs);
--- 32,36 ----
private GeoRectangle bbox = null;
private int myID = 1;
! private final static boolean DEBUG=true;
private Canvas obs = new Canvas();
private MediaTracker tracker=new MediaTracker(obs);
***************
*** 275,290 ****
// Start getting the image. If the image is .gif or .jpg then
// use default java tools otherwise use Jimi class
! //String type="";
! //try{
! // URLConnection con = this.src.openConnection();
! // type = con.getContentType();
! //}catch(java.io.IOException ioe){
! // System.err.println("IL--> problem opening connection");
! //}
! //if((type!=null) && type.startsWith("image")){
! Toolkit tk = Toolkit.getDefaultToolkit();
! // if(type.trim().endsWith("gif")
! // || type.trim().endsWith("jpeg")){
!
// If a previous image was being tracked, then remove it.
if(tracker!=null){
--- 276,280 ----
// Start getting the image. If the image is .gif or .jpg then
// use default java tools otherwise use Jimi class
! String type="";
// If a previous image was being tracked, then remove it.
if(tracker!=null){
***************
*** 293,299 ****
--- 283,322 ----
this.image=null;
}
+ URLConnection con;
+ Toolkit tk = Toolkit.getDefaultToolkit();
if (src != null) {
+ try{
+ con = this.src.openConnection();
+ type = con.getContentType();
+ }catch(java.io.IOException ioe){
+ System.err.println("IL--> problem opening connection");
+ return;
+ }
+
+ if((type!=null) && type.startsWith("image")){
+ if(type.trim().endsWith("gif")
+ || type.trim().endsWith("jpeg")){
this.image = tk.getImage(this.src);
if(DEBUG)System.out.println("New fetch ?");
+ }else{
+ this.image = Jimi.getImage(this.src,type);
+ }
+ }else{
+ if(type.startsWith("text")){
+ try{
+ String line;
+ BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
+ while((line=in.readLine())!=null){
+ System.err.println("IL("+this+"):"+line);
+ setStatus(Layer.ERRORED);
+ }
+ return;
+ }catch(IOException e){
+ System.err.println("IL("+this+"):"+e);
+ setStatus(Layer.ERRORED);
+ return;
+ }
+ }
+ }
} // end of if (src != null)
if (src_stream != null) {
***************
*** 305,311 ****
- // }else{
- // this.image = Jimi.getImage(this.src,type);
- // }
// if(DEBUG)System.out.println(
// "IL--> Image Width="+this.image.getWidth(obs));
--- 328,331 ----
***************
*** 378,384 ****
*
* $Log$
! * Revision 1.31 2001/12/10 16:13:57 ianturton
! * added an internal buffer for the image source - this saves image reloads
! * when pixelgrabber is called. Don't ask me why this should be but it is!
*
* Revision 1.30 2001/12/07 11:01:33 ianturton
--- 398,403 ----
*
* $Log$
! * Revision 1.32 2001/12/11 10:35:00 ianturton
! * readded support of png/tiff images
*
* Revision 1.30 2001/12/07 11:01:33 ianturton
|