- }
- updateRenderOrder(allfeatures);
- findingFeatures = false;
- }
- boolean firing=false;
- /**
- * replaces the current renderOrder with the unordered features in allfeatures.
- * The ordering of any types in both renderOrder and allfeatures is preserved,
- * and all new feature types are rendered on top of the existing types, in
- * the order given by getOrder or the order given in allFeatures.
- * Note. this operates directly on the featureOrder hash for efficiency. TODO:
- * eliminate the float storage for computing/recalling the persistent ordering
- *
- * @param allFeatures
- */
- public void updateRenderOrder(Vector allFeatures) {
- Vector allfeatures = new Vector(allFeatures);
- String[] oldRender = renderOrder;
- renderOrder = new String[allfeatures.size()];
- boolean initOrders=(featureOrder==null);
- int opos=0;
- if (renderOrder!=null)
- {
- for (int j=0; i<oldRender.length; j++)
- {
- if (oldRender[j]!=null)
- {
- if (initOrders)
- {
- setOrder(oldRender[j], (1-((float)j)/(float) oldRender.length));
- }
- if (allfeatures.contains(oldRender[j])) {
- renderOrder[opos++] = oldRender[j]; // existing features always
- // appear below new features
- allfeatures.removeElement(oldRender[j]);
- }
- }
- }
- }
- 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;
- }
-
- static String lastFeatureAdded;
- static String lastFeatureGroupAdded;
- static String lastDescriptionAdded;
-
- public boolean createNewFeatures(SequenceI[] sequences,
- SequenceFeature[] features)
- {
- return amendFeatures(sequences, features, true, null);
- }