gt: 			if ( type.equals("reference") || type.equals("GOA")){
context: /*
   *                  BioJava development code
   *
   * This code may be freely distributed and modified under the
   * terms of the GNU Lesser General Public Licence.  This should
   * be distributed with the code.  If you do not have a copy,
   * see:
   *
   *      http://www.gnu.org/copyleft/lesser.html
   *
   * Copyright for this code is held jointly by the individual
   * authors.  These should be listed in @author doc comments.
   *
   * For more information on the BioJava project and its aims,
   * or to join the biojava-l mailing list, visit the home page
   * at:
   *
   *      http://www.biojava.org/
   * 
   * Created on Nov 1, 2005
   *
   */
  package org.biojava.spice.manypanel.drawable;
  
  import java.awt.Color;
  import java.util.ArrayList;
  import java.util.Collections;
  import java.util.Iterator;
  import java.util.List;
  import java.util.Map;
  import java.util.logging.Logger;
  
  import org.biojava.dasobert.eventmodel.*;
  //import org.biojava.servlets.dazzle.datasource.GFFFeature;
  import org.biojava.spice.config.SpiceDefaults;
  import org.biojava.spice.das.SpiceDasSource;
  import org.biojava.spice.feature.*;
  import org.biojava.spice.manypanel.eventmodel.FeatureListener;
  
  /** all the data about a particular DAS source and the
   * Features associated with if ( and a particular accession code)
   * @author Andreas Prlic
   *
   */
  public class DrawableDasSource 
  implements Drawable,
  FeatureListener{
  
  	SpiceDasSource dasSource ;
  	Feature[] features;
  
  	String type;
  	public static final String TYPE_HISTOGRAM = "histogram";
  	public static final String TYPE_DEFAULT   = "default";
  
  	public static final  Color[] entColors = new Color []{
  		new Color(51,51,255), // blue
  		new Color(102,255,255),    // cyan
  		new Color(153,255,153), // green
  		new Color(153,255,153), // green
  		new Color(255,153,153), // pink
  		new Color(255,51,51),   // red
  		new Color(255,51,255)    // pink 
  	};
  
  	/** if the url of two das sources is the same
  	 *  this will return true;
  	 *  @param compareToSource a drawable das source to compare with
  	 *  @return a flag if the two are equal
  	 */
  	public boolean equals(DrawableDasSource compareToSource){
  		if ( dasSource.getUrl().equals(compareToSource.getDasSource().getUrl()))
  			return true;
  		return false;
  	}
  
  	public static final String[] txtColors = new String[] { "blue","pink","green","yellow","red","cyan","pink"};
  
  
  
  	static Logger logger = Logger.getLogger("org.biojava.spice");
  	boolean loading;
  	List<FeatureListener> featureListeners;
  
  
  	public DrawableDasSource(SpiceDasSource ds) {
  		super();
  
  		//SpiceDasSource sds = SpiceDasSource.fromDasSource(ds);
  		setType(TYPE_DEFAULT);
  
  
  		if ( ds.getDisplayType().equalsIgnoreCase(TYPE_HISTOGRAM)) { 
  			setType(TYPE_HISTOGRAM);
  			//logger.info(ds.getNickname() + " is a HISTOGRAM DAS SOURCE");
  		} else {
  			//logger.info(ds.getNickname() + " is a DEFAULT DAS SOURCE " + ds.getDisplayType());
  		}
  
  
  
  
  		this.dasSource = ds;   
  		clearDisplay();
  		clearFeatureListeners();
  		loading = false;
  
  	}
  
  	/*
  	public Feature convertEventFeatures(Feature[] features){
  
  		// join all features to one where the segments contain the score...
  		Feature f = new FeatureImpl();
  		if ( features.length > 0){
  			f = (Feature)features[0].clone();
  
  			for(int i = 1 ; i< features.length;i++){
  				Feature t = features[i];
  				List segments = t.getSegments();
  				Iterator iter = segments.iterator();
  				while (iter.hasNext()){
  					Segment s = (Segment) iter.next();  
  					Segment tmp = (Segment)s.clone();
  					f.addSegment(tmp);
  				}
  
  			}
  
  
  		}
  		//logger.info("convert features for histogram data " +f );
  		return f;
  	}*/
  
  	public String getType() {
  		return type;
  	}
  
  	public void setType(String type) {
  		this.type = type;
  	}
  
  	public static DrawableDasSource fromDasSource(SpiceDasSource ds){
  		DrawableDasSource  dds = new DrawableDasSource(ds);
  
  
  
  		return dds ;
  	}
  	public void clearFeatureListeners(){
  
  		featureListeners = new ArrayList<FeatureListener>();
  	}
  	public void addFeatureListener(FeatureListener feat){
  		if ( ! featureListeners.contains(feat))
  			featureListeners.add(feat);
  	}
  
  	public SpiceDasSource getDasSource(){
  		return dasSource;
  	}
  
  	public Color getColor() {
  
  		return null;
  	}
  
  	public boolean getLoading() {
  
  		return loading;
  	}
  
  	public void setColor(Color col) {
  
  
  	}
  
  	public void setLoading(boolean flag) {
  		loading = flag;
  
  	}
  
  	public Map[] getStylesheet(){
  		// TODO: load stylesheet into das source at some point...
  
  		return dasSource.getStylesheet();
  	}
  
  
  	/** a way to set Features from the outside 
  	 * 
  	 * @param feats
  	 */
  	public void setFeatures(Feature[] feats){
  		features = feats;
  	}
  
  
  	private void calculateMinMaxForHistograms(Feature[] feats){
  
  		for (int i = 0; i < feats.length; i++) {
  			Feature f = feats[i];
  
  			if (f instanceof HistogramFeature ){
  				dasSource.setUnlimitedFeatures(true);
  
  
  
  				HistogramFeature hf = (HistogramFeature) f;
  
  				List segments  = hf.getSegments();
  				SegmentComparator comp = new SegmentComparator();
  				Collections.sort(segments,comp);
  
  
  				Iterator iter = segments.iterator();
  
  				double max = 0;
  				double min = 0;
  
  				while ( iter.hasNext()){
  
  					HistogramSegment s= (HistogramSegment) iter.next();
  					double score = s.getScore();
  					if ( score > max)
  						max = score;
  					if ( score < min )
  						min = score;
  
  					//if ( f.getType().equals("hydrophobicity"))
  					//	 System.out.println(s.getStart()+"\t"+score);
  
  				}
  
  				hf.setMax(max);
  				hf.setMin(min);    			    			
  				//logger.info("found max/min " + max + " " +min);
  			}
  		}
  	}
  
  	public void newFeatures(FeatureEvent e){
  		Map<String,String>[] feats = e.getFeatures();
  		//logger.info("got " + feats.length + " features " +
  		//       featureListeners.size() + " featureListeners");
  		features = convertMap2Features(feats);
  
  		// calculate Max and Min of Histogram style features
  		calculateMinMaxForHistograms(features);
  
  
  
  		//logger.finest("joined to " + features.length + " features -check:"+feats.length  );
  		// AbstractChainRenderer is listening to this and
  		// needs to resize itself
  		//TODO: this should not be part of the Drawable code but of the DasSourcePanel code...
  		Iterator iter = featureListeners.iterator();
  		while (iter.hasNext()){
  			FeatureListener featL = (FeatureListener)iter.next();
  			//TODO: add support for versioning of reference objects
  			String version = null;
  			FeatureEvent event = new FeatureEvent(feats,dasSource,version);
  			featL.newFeatures(event);
  		}
  
  	}
  
  	public void comeBackLater(FeatureEvent e){
  		//TODO: display that the server is calculating ...
  	}
  
  	public Feature[] getFeatures(){
  
  		return features;
  	}
  
  	public void clearDisplay(){
  		features = new FeatureImpl[0];
  	}
  
  	/** returns a list of SPICE-Features objects */
  	private Feature[] convertMap2Features(Map[] mapfeatures){
  
  		List<Feature> features = new ArrayList<Feature>();
  
  		boolean secstruc = false ;
  		//String prevtype = "@prevtype" ;
  		boolean first = true ;
  
  		FeatureImpl feat    = null ;
  		Segment segment = null ;
  
  		//boolean secstrucContained = false;
  		//Feature secstrucfeature = new FeatureImpl() ;
  		int featuresCounter = 0;
  		for (int i = 0 ; i< mapfeatures.length;i++) {
  
  			Map currentFeatureMap = mapfeatures[i];
  			String type = (String) currentFeatureMap.get("TYPE") ;
  
  			// we are skipping literature references for the moment 
  			// TODO: add a display to spice for non-positional features
  			//
  