- }
- 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 head of
- // existing features.
- setOrder(newf[i], i / (float) 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 (iSize > 1 && sort)
- jalview.util.QuickSort.sort(sortOrder, newf);
- sortOrder = null;
- System.arraycopy(newf, 0, renderOrder, opos, newf.length);
- }
-
- public Color getColour(String featureType)
- {
- if (!featureColours.containsKey(featureType))
- {
- jalview.schemes.UserColourScheme ucs = new jalview.schemes.UserColourScheme();
- Color col = ucs.createColourFromName(featureType);
- featureColours.put(featureType, col);
- return col;
- }
- else
- return (Color) featureColours.get(featureType);
- }
-
- static String lastFeatureAdded;
-
- static String lastFeatureGroupAdded;
-
- static String lastDescriptionAdded;
-
- int featureIndex = 0;
-
- boolean amendFeatures(final SequenceI[] sequences,
- final SequenceFeature[] features, boolean newFeatures,
- final AlignmentPanel ap)
- {
-
- featureIndex = 0;
-
- JPanel bigPanel = new JPanel(new BorderLayout());
- final JComboBox overlaps;
- final JTextField name = new JTextField(25);
- final JTextField source = new JTextField(25);
- final JTextArea description = new JTextArea(3, 25);
- final JSpinner start = new JSpinner();
- final JSpinner end = new JSpinner();
- start.setPreferredSize(new Dimension(80, 20));
- end.setPreferredSize(new Dimension(80, 20));
-
- final JPanel colour = new JPanel();
- colour.setBorder(BorderFactory.createEtchedBorder());
- colour.setMaximumSize(new Dimension(40, 10));
- colour.addMouseListener(new MouseAdapter()
- {
- public void mousePressed(MouseEvent evt)
- {
- Color col = JColorChooser.showDialog(Desktop.desktop,
- "Select Feature Colour", colour.getBackground());
- if (col != null)
- colour.setBackground(col);
-
- }
- });
-
- JPanel tmp = new JPanel();
- JPanel panel = new JPanel(new GridLayout(3, 1));
-
- // /////////////////////////////////////
- // /MULTIPLE FEATURES AT SELECTED RESIDUE
- if (!newFeatures && features.length > 1)
- {
- panel = new JPanel(new GridLayout(4, 1));
- tmp = new JPanel();
- tmp.add(new JLabel("Select Feature: "));
- overlaps = new JComboBox();
- for (int i = 0; i < features.length; i++)
- {
- overlaps.addItem(features[i].getType() + "/"
- + features[i].getBegin() + "-" + features[i].getEnd()
- + " (" + features[i].getFeatureGroup() + ")");
- }
-
- tmp.add(overlaps);