- }
- if (allfeatures.size()==0) {
- // no new features - leave order unchanged.
- return;
- }
- int i=allfeatures.size()-1;
- int iSize=i;
- boolean sort=false;
- String[] newf = new String[allfeatures.size()];
- float[] sortOrder = new float[allfeatures.size()];
- Enumeration en = allfeatures.elements();
- // sort remaining elements
- while (en.hasMoreElements())
- {
- newf[i] = en.nextElement().toString();
- if (initOrders || !featureOrder.containsKey(newf[i]))
- {
- int denom = initOrders ? allfeatures.size() : featureOrder.size();
- // new unordered feature - compute persistent ordering at tail of
- // existing features.
- setOrder(newf[i], ((float)2*denom)/(float)(1+2*denom));
- }
- // set order from newly found feature from persisted ordering.
- sortOrder[i] = 2-((Float) featureOrder.get(newf[i])).floatValue();
- if (i<iSize)
- {
- // only sort if we need to
- sort = sort || sortOrder[i]>sortOrder[i+1];
- }
- i--;
- }
- if (sort)
- jalview.util.QuickSort.sort(sortOrder, newf);
- sortOrder=null;
- System.arraycopy(newf, 0, renderOrder, opos, newf.length);
- }
- public Color getColour(String featureType)
- {
- Color colour = (Color) featureColours.get(featureType);
- if (colour == null)
- {
- jalview.schemes.UserColourScheme ucs = new
- jalview.schemes.UserColourScheme();
- featureColours.put(featureType,
- colour=ucs.createColourFromName(featureType));
- }
- return colour;
- }