package edu.mit.csail.uid;

public class Pattern {
   protected String imgURL = null;
   protected float similarity = 0.7f;

   int dx=0, dy=0;

   public Pattern(){ }
   public Pattern(String imgURL_){
      imgURL = imgURL_;
   }

   public Pattern similar(float similarity_){
      similarity = similarity_;
      return this;
   }

   public Pattern exact(){
      similarity = 1.0f;
      return this;
   }

   public Pattern targetOffset(int dx_, int dy_){
      dx = dx_;
      dy = dy_;
      return this;
   }

   public String toString(){
     String ret = "Pattern(\"" + imgURL + "\")";
     ret += ".similar(" + similarity +")";
     return ret;
   }

   Location getTargetOffset(){
      return new Location(dx, dy);
   }

}


@@ -47,26 +47,16 @@
 rn %7B%0A   
-protected 
 String i
@@ -76,18 +76,8 @@
 %0A   
-protected 
 floa
@@ -141,16 +141,110 @@
 rn()%7B %7D%0A
+   public Pattern(Pattern p)%7B%0A      imgURL = p.imgURL;%0A      similarity = p.similarity;%0A   %7D%0A%0A
    publi
@@ -344,32 +344,75 @@
 larity_)%7B%0A      
+Pattern ret = new Pattern(this);%0A      ret.
 similarity = sim
@@ -426,36 +426,35 @@
 _;%0A      return 
-this
+ret
 ;%0A   %7D%0A%0A   publi
@@ -578,16 +578,59 @@
 %7B%0A      
+Pattern ret = new Pattern(this);%0A      ret.
 dx = dx_
@@ -637,16 +637,20 @@
 ;%0A      
+ret.
 dy = dy_
@@ -656,36 +656,35 @@
 _;%0A      return 
-this
+ret
 ;%0A   %7D%0A%0A   publi

change Pattern to be immutable