Debug.output("Listener " + (listener == null?"is null,":"is OK,") + " listening (" + (listener == null?"nope":"" + listener.isListening()) + ")");
if (Debug.debugging("link")) { Debug.output(getName() + "|LinkLayer.prepare(): Listener " + (listener == null?"is null,":"is OK,") + " listening (" + (listener == null?"nope":"" + listener.isListening()) + ")"); }
    public OMGraphicList prepare() {	OMGraphicList currentList = getList();	if (listener != null && !listener.isListening()) {	    SwingWorker sw = new SwingWorker() {		    public Object construct() {			Debug.message("link", "LinkLayer.prepare():  calling for the LinkListener startup");			getListener().start(); 			return null;		    }		};	    sw.execute();// 	    listener.start();	}	Debug.output("Listener " + (listener == null?"is null,":"is OK,") + " listening (" + (listener == null?"nope":"" + listener.isListening()) + ")");	if (isCancelled()) {	    Debug.message("link", getName()+"|LinkLayer.prepare(): aborted.");	    return currentList;	}	Projection projection = getProjection();	if (projection == null) {	    Debug.error("Link Layer needs to be added to the MapBean before it can get graphics!");	    return currentList;	} else if (currentList != null) {	    // If the list isn't empty, it isn't being cleared when a	    // new projection is received, as dictated by the policy	    // of the layer.  Should regenerate it here.  If it's	    // understood that a new list will be sent by the server,	    // then a different ProjectionChangePolicy should be used.	    currentList.generate(projection);	}	Debug.message("basic", getName()+"|LinkLayer.prepare(): doing it");	// Setting the OMGraphicsList for this layer.  Remember, the	// LinkOMGraphicList is made up of OMGraphics, which are generated	// (projected) when the graphics are added to the list.  So,	// after this call, the list is ready for painting.	// call getRectangle();	if (Debug.debugging("link")) {	    System.out.println(		getName()+"|LinkLayer.prepare(): " +		"calling getRectangle " +		" with projection: " + projection +		" ul = " + projection.getUpperLeft() + 		" lr = " + projection.getLowerRight()); 	}	// 	LinkOMGraphicList omGraphicList;	////////////// Call getRectangle for server....	try {	    // We do want the link object here... If another thread is	    // using the link, wait.	    ClientLink l = linkManager.getLink(true);	    if (l == null) {		System.err.println("LinkLayer: unable to get link in prepare().");		return currentList;	    }	    synchronized(l) {		// 		omGraphicList = getGraphics(l, projection);		sendMapRequest(l, projection);	    } 	    linkManager.finLink();	} catch (UnknownHostException uhe) {	    System.err.println("LinkLayer: unknown host!");	    // 	    return currentList;	} catch (java.io.IOException ioe) {	    System.err.println("LinkLayer: IOException contacting server for map request!");	    System.err.println(ioe);	    linkManager.resetLink();	    if (!quiet) {		fireRequestMessage("Communication error between " + getName() + 				   " layer\nand Link Server: Host: " + host + 				   ", Port: " + port);	    }	    System.err.println("LinkLayer: Communication error between " + getName() + 			       " layer\nand Link Server: Host: " + host + 			       ", Port: " + port);	    // 	    return currentList;	}	/////////////////////////////////////////////////////	// With asynchronous behavior, we don't listen to the reply	// now.  The LinkListener will handle setting the new	// OMGraphicList if one is needed as decided by the server.	/////////////////////	// safe quit	// 	int size = 0;	// 	if (omGraphicList != null) {	// 	    size = omGraphicList.size();		// 	    if (Debug.debugging("basic")) {	// 		System.out.println(getName()+	// 				   "|LinkLayer.prepare(): finished with "+	// 				   size+" graphics");	// 	    }	// // 	    omGraphicList.project(projection);	// 	}	// 	else 	// 	    Debug.message("basic", getName()+	// 	      "|LinkLayer.prepare(): finished with null graphics list");	return currentList;    }