/** FieldList - opbevarer koordinater for et emne og en tilhørende tekst */
public class FieldList {
    
    /** Field - specificvere hvad et Field er*/ 
    private class Field {
	public int koordx1;
	public int koordy1;
	public int koordx2;
	public int koordy2;
	public String text;
	
	/** Field - Laver en ny Field
	 *  @param x1 First coordinate of upper left corner
	 *  @param y1 Second coordinate of upper left corner
	 *  @param x2 First coordinate of lower right corner
	 *  @param y2 Second coordinate of lower right corner
	 *  @param s A string
	 */
	public Field(int x1, int y1, int x2, int y2, String s) {
	    // Save the parameters as field variables
	    koordx1 = x1;
	    koordy1 = y1;
	    koordx2 = x2;
	    koordy2 = y2;
	    text = s;
	}
    }


    Field Liste[];  // List of fields
    int nextpos = 0;  // next empty position
    
    /** FieldList Constructs laver en tom liste */
    public FieldList() {
	Liste = new Field[10];
    }
    
    /** insertField - inserts a new Field in the list
     *  @param x1 First coordinate of upper left corner
     *  @param y1 Second coordinate of upper left corner
     *  @param x2 First coordinate of lower right corner
     *  @param y2 Second coordinate of lower right corner
     *  @param s A string
     */
    public void insertField(int x1, int y1, int x2, int y2, String s) {
	if ( nextpos == Liste.length ) { 
 	    Field[] temp = new Field[2 * Liste.length];
 	    for (int i = 0 ; i < Liste.length ; i++)
		temp[i] = Liste[i];
	    Liste = temp; }
	
	Liste[nextpos] = new Field(x1, y1, x2, y2, s);
	  nextpos = nextpos + 1;	  
    }
     
    public void clear() {
	//Laver listen tom, ved at overskrive den gamle med en ny 
	Liste = new Field[10];
    }
    
    /** Report - Prints the string associated with all fields 
     *  containing (x,y)
     *  @param x The first coordinate
     *  @param y The second coordinate
     */
    public void report(int x, int y) {
	for (int i = 0; i < nextpos; i++)
	    if ( x > Liste[i].koordx1  &&  x < Liste[i].koordx2 )
		 if ( y > Liste[i].koordy1  &&  y < Liste[i].koordy2 )
		 System.out.println(Liste[i].text);
		 }
}
