|
From: Ian T. <ian...@us...> - 2001-12-07 11:01:37
|
Update of /cvsroot/geotools/geotools/src/uk/ac/leeds/ccg/raster
In directory usw-pr-cvs1:/tmp/cvs-serv4747/uk/ac/leeds/ccg/raster
Modified Files:
ImageLayer.java
Log Message:
Removed unnecessary calls for updates in paint method
Index: ImageLayer.java
===================================================================
RCS file: /cvsroot/geotools/geotools/src/uk/ac/leeds/ccg/raster/ImageLayer.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -w -C2 -d -r1.29 -r1.30
*** ImageLayer.java 2001/11/22 11:00:01 1.29
--- ImageLayer.java 2001/12/07 11:01:33 1.30
***************
*** 30,37 ****
private Image image = null;
private GeoRectangle bbox = null;
- private MediaTracker tracker;
private int myID = 1;
private final static boolean DEBUG=false;
private Canvas obs = new Canvas();
private Toolkit tk;
private URL src = null;
--- 30,37 ----
private Image image = null;
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);
private Toolkit tk;
private URL src = null;
***************
*** 52,58 ****
bbox = bounds;
this.image = image;
! tracker = new MediaTracker(new Frame());
! tracker.addImage(this.image,0);
! this.setStatus(Layer.COMPLETED);
}
--- 52,60 ----
bbox = bounds;
this.image = image;
! tracker.addImage(this.image,++myID);
! this.setStatus(Layer.LOADING);
! thread = new Thread(this);
! thread.setPriority(Thread.MIN_PRIORITY);
! thread.start();
}
***************
*** 61,65 ****
this.src = source;
this.src_stream = null;
! //if (DEBUG) System.out.println("ImageLayer.changeImage= "+src);
changeImage(bounds);
}
--- 63,67 ----
this.src = source;
this.src_stream = null;
! if (DEBUG) System.out.println("ImageLayer.changeImage= "+src);
changeImage(bounds);
}
***************
*** 135,148 ****
public void paintScaled(GeoGraphics gg)
{
! // Print out a call stack
! //if(DEBUG) {
! // try {
! // throw new RuntimeException();
! // } catch (RuntimeException e) {
! // System.out.println("IL ("+this+")-->paintScaled call stack ");
! // e.printStackTrace();
! // }
! //}
!
double cellSizeX = 0;
double cellSizeY = 0;
--- 137,141 ----
public void paintScaled(GeoGraphics gg)
{
! if(DEBUG)System.out.println("Painting imagelayer");
double cellSizeX = 0;
double cellSizeY = 0;
***************
*** 156,161 ****
GeoRectangle out = gr.createIntersect(me);
! //if(DEBUG)System.out.println("IL-->gr "+gr+"\nme "+me+"\nout "+out);
! //if(DEBUG)System.out.println("IL-->getStatus="+this.getStatus());
int gh,gw;
if(DEBUG)System.out.println("IL ("+this+") -->0");
--- 149,153 ----
GeoRectangle out = gr.createIntersect(me);
! if(DEBUG)System.out.println("IL-->getStatus="+this.getStatus());
int gh,gw;
if(DEBUG)System.out.println("IL ("+this+") -->0");
***************
*** 164,173 ****
if(out.equals(me)){
! if(DEBUG)System.out.println("IL ("+this+") -->2 ");
! //if(DEBUG)System.out.println("IL-->No clip");
//GeoRectangle out = bbox;
int origin[]=scale.toGraphics(out.x,out.y);
gh=scale.toGraphics(out.height);
gw=scale.toGraphics(out.width);
if(this.image!=null){
drawn = g.drawImage(
--- 156,171 ----
if(out.equals(me)){
! //if(DEBUG)System.out.println("IL ("+this+") -->2 ");
! if(DEBUG)System.out.println("IL-->No clip ("+this+")");
//GeoRectangle out = bbox;
int origin[]=scale.toGraphics(out.x,out.y);
gh=scale.toGraphics(out.height);
gw=scale.toGraphics(out.width);
+ if(getStatus()!=Layer.COMPLETED){
+ if(DEBUG)System.out.println("Not ready returning");
+ g.setColor(Color.red);
+ g.drawRect(origin[0]+1,origin[1]-gh-1,gw-1,gh-1);
+ return;
+ }
if(this.image!=null){
drawn = g.drawImage(
***************
*** 178,197 ****
gh,
null);
- try {
- tracker.waitForID(myID);
- } catch (InterruptedException e) {
- System.out.println("IL-->Interupted while drawing");
- setStatus(Layer.ERRORED);
- return;
- }
if(DEBUG)System.out.println("IL ("+this+") -->3 drawn="+drawn);
- }
- //if((this.getStatus()&Layer.COMPLETED)==Layer.COMPLETED){
- // if(DEBUG)System.out.println("IL ("+this+") -->4 ");
- // g.setColor(Color.red);
- // g.drawRect(origin[0]+1,origin[1]-gh-1,gw-1,gh-1);
- //}
}
! else{
if(DEBUG)System.out.println("IL ("+this+") -->5 ");
if((this.getStatus()&Layer.COMPLETED)!=Layer.COMPLETED) {
--- 176,182 ----
gh,
null);
if(DEBUG)System.out.println("IL ("+this+") -->3 drawn="+drawn);
}
! } else{ // clipping required
if(DEBUG)System.out.println("IL ("+this+") -->5 ");
if((this.getStatus()&Layer.COMPLETED)!=Layer.COMPLETED) {
***************
*** 202,209 ****
//complex clip case
MemoryImageSource source;
! cellSizeX = me.width/this.image.getWidth(
! new Frame());
! cellSizeY = me.height/this.image.getHeight(
! new Frame());
int x,y,width,height;
if(out.y%cellSizeY>0){
--- 187,192 ----
//complex clip case
MemoryImageSource source;
! cellSizeX = me.width/this.image.getWidth(obs);
! cellSizeY = me.height/this.image.getHeight(obs);
int x,y,width,height;
if(out.y%cellSizeY>0){
***************
*** 211,234 ****
out.height+=cellSizeY;
}
- // out.x=out.x-(out.x%cellSizeX);
x=(int)Math.floor(((out.x-me.x)/cellSizeX));
y=(int)Math.ceil(((me.y-out.y+me.height-out.height)/cellSizeY));
width=(int)Math.ceil((out.width/cellSizeX));
height=(int)Math.ceil(((out.height)/cellSizeY));
- // out.x=out.x-(out.x%cellSizeX);
x=(int)Math.floor(((out.x-me.x)/cellSizeX));
- //y=(int)Math.ceil(((out.y-me.y+out.height)/cellSizeY));
- //h=(int)Math.ceil(((out.height)/cellsize));
- //mh=(int)Math.ceil(((me.height)/cellsize));
- //gh=(int)Math.ceil(((gr.height)/cellsize));
- //top=(int)Math.ceil(((out.y)/cellsize))+h;
- //mtop=(int)Math.ceil(((me.y)/cellsize))+mh;
- //y=(int)(Math.max(Math.ceil(out.y),Math.ceil(me.y))/cellSizeY);
y=(int)Math.ceil(((me.y-out.y+me.height-out.height)/cellSizeY));
! // if(DEBUG)System.out.println("IL-->start "+x+" "+y);
width=(int)Math.ceil((out.width/cellSizeX));
height=(int)Math.ceil(((out.height)/cellSizeY));
! //if(DEBUG)System.out.println("IL-->w/h "+width+" "+height);
y=Math.max(y,0);
int[] data = new int[(height*width)];
PixelGrabber pg = new PixelGrabber(
--- 194,217 ----
out.height+=cellSizeY;
}
x=(int)Math.floor(((out.x-me.x)/cellSizeX));
y=(int)Math.ceil(((me.y-out.y+me.height-out.height)/cellSizeY));
width=(int)Math.ceil((out.width/cellSizeX));
height=(int)Math.ceil(((out.height)/cellSizeY));
x=(int)Math.floor(((out.x-me.x)/cellSizeX));
y=(int)Math.ceil(((me.y-out.y+me.height-out.height)/cellSizeY));
! if(DEBUG)System.out.println("IL-->start "+x+" "+y);
width=(int)Math.ceil((out.width/cellSizeX));
height=(int)Math.ceil(((out.height)/cellSizeY));
! if(DEBUG)System.out.println("IL-->w/h "+width+" "+height);
y=Math.max(y,0);
+ int origin[]=scale.toGraphics(out.x,out.y);
+ gh=scale.toGraphics(out.height);
+ gw=scale.toGraphics(out.width);
+ if((this.getStatus()&Layer.COMPLETED)!=Layer.COMPLETED){
+ if(DEBUG)System.out.println("IL ("+this+") -->6 ");
+ g.setColor(Color.red);
+ g.drawRect(origin[0],origin[1]-gh,gw,gh);
+ return;
+ }
int[] data = new int[(height*width)];
PixelGrabber pg = new PixelGrabber(
***************
*** 254,281 ****
source = new MemoryImageSource(width,height,data,0,width);
Image image2 = obs.createImage(source);
- int origin[]=scale.toGraphics(out.x,out.y);
- gh=scale.toGraphics(out.height);
- gw=scale.toGraphics(out.width);
drawn=g.drawImage(image2,origin[0],origin[1]-gh,gw,gh,obs);
- try {
- tracker.waitForID(myID);
- } catch (InterruptedException e) {
- System.out.println("IL-->Interupted while drawing");
- setStatus(Layer.ERRORED);
- return;
- }
if(DEBUG)System.out.println("IL ("+this+") -->5.1 drawn="+drawn);
image2=null;
- if((this.getStatus()&Layer.COMPLETED)!=Layer.COMPLETED){
- if(DEBUG)System.out.println("IL ("+this+") -->6 ");
- g.setColor(Color.red);
- g.drawRect(origin[0],origin[1]-gh,gw,gh);
- }
}
}
}
! protected byte[] getImageData(java.io.InputStream instr)
! {
byte[] res = null;
try {
--- 237,248 ----
source = new MemoryImageSource(width,height,data,0,width);
Image image2 = obs.createImage(source);
drawn=g.drawImage(image2,origin[0],origin[1]-gh,gw,gh,obs);
if(DEBUG)System.out.println("IL ("+this+") -->5.1 drawn="+drawn);
image2=null;
}
}
}
! protected byte[] getImageData(java.io.InputStream instr) {
byte[] res = null;
try {
***************
*** 299,304 ****
public void run() {
setStatus(Layer.PENDING);
! if(DEBUG) System.out.println(
! "IL--> Request image " + this.src + " " + bbox);
// Start getting the image. If the image is .gif or .jpg then
--- 266,270 ----
public void run() {
setStatus(Layer.PENDING);
! if(DEBUG) System.out.println("IL--> Request image " + this.src + " " + bbox);
// Start getting the image. If the image is .gif or .jpg then
***************
*** 312,316 ****
//}
//if((type!=null) && type.startsWith("image")){
- Frame dummy = new Frame();
Toolkit tk = Toolkit.getDefaultToolkit();
// if(type.trim().endsWith("gif")
--- 278,281 ----
***************
*** 337,343 ****
// }
// if(DEBUG)System.out.println(
! // "IL--> Image Width="+this.image.getWidth(dummy));
- if(tracker==null)tracker = new MediaTracker(dummy);
tracker.addImage(this.image,++myID);
try {
--- 302,307 ----
// }
// if(DEBUG)System.out.println(
! // "IL--> Image Width="+this.image.getWidth(obs));
tracker.addImage(this.image,++myID);
try {
***************
*** 360,366 ****
setStatus(Layer.ABORTED);
if(DEBUG)System.out.println("IL ("+this+")-->Image Aborted ");
- //}else if(state == tracker.ERRORED){
- // setStatus(Layer.ERRORED);
- // if(DEBUG)System.out.println("IL ("+this+")-->Image Error ");
}else {
setStatus(Layer.ERRORED);
--- 324,327 ----
***************
*** 383,386 ****
--- 344,350 ----
*
* $Log$
+ * Revision 1.30 2001/12/07 11:01:33 ianturton
+ * Removed unnecessary calls for updates in paint method
+ *
* Revision 1.29 2001/11/22 11:00:01 kobit
* Separated image data loading from image creating and some comments added
|