/**
* DOCUMENT ME!
- *
+ *
* @author $author$
* @version $Revision$
*/
String[] renderOrder;
PropertyChangeSupport changeSupport=new PropertyChangeSupport(this);
+ Vector allfeatures;
+
/**
* Creates a new FeatureRenderer object.
- *
+ *
* @param av
* DOCUMENT ME!
*/
{
lastSeq = seq;
sequenceFeatures = lastSeq.getDatasetSequence().getSequenceFeatures();
- if (sequenceFeatures!=null)
+ if (sequenceFeatures!=null)
{
sfSize = sequenceFeatures.length;
}
}
-
+
if (sequenceFeatures!=lastSeq.getDatasetSequence().getSequenceFeatures()) {
sequenceFeatures = lastSeq.getDatasetSequence().getSequenceFeatures();
if (sequenceFeatures != null)
{
sfSize = sequenceFeatures.length;
- }
+ }
}
-
+
if (sequenceFeatures == null)
{
return initialCol;
/**
* DOCUMENT ME!
- *
+ *
* @param g
* DOCUMENT ME!
* @param seq
/**
* search the alignment for all new features, give them a colour and display
* them. Then fires a PropertyChangeEvent on the changeSupport object.
- *
+ *
*/
synchronized void findAllFeatures()
{
}
/**
* Searches alignment for all features and updates colours
- *
+ *
* @param newMadeVisible
* if true newly added feature types will be rendered immediatly
*/
av.featuresDisplayed = new Hashtable();
}
- Vector allfeatures = new Vector();
+ allfeatures = new Vector();
Vector oldfeatures = new Vector();
- if (renderOrder!=null)
+ if (renderOrder!=null)
{
for (int i=0; i<renderOrder.length; i++) {
if (renderOrder[i]!=null)
* 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
*/
private void updateRenderOrder(Vector allFeatures) {
if (initOrders)
{
setOrder(oldRender[j], (1-(1+(float)j)/(float) oldRender.length));
- }
+ }
if (allfeatures.contains(oldRender[j])) {
renderOrder[opos++] = oldRender[j]; // existing features always
// appear below new features
int i=allfeatures.size()-1;
int iSize=i;
boolean sort=false;
- String[] newf = new String[allfeatures.size()];
+ 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]))
+ if (initOrders || !featureOrder.containsKey(newf[i]))
{
int denom = initOrders ? allfeatures.size() : featureOrder.size();
// new unordered feature - compute persistent ordering at head of
boolean newFeatures,
final AlignmentPanel ap)
{
+ findAllFeatures();
+
+ featureIndex = 0;
+
JPanel bigPanel = new JPanel(new BorderLayout());
- final JComboBox name = new JComboBox();
- final JComboBox source = new JComboBox();
+ 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));
}
});
- JPanel panel = new JPanel(new GridLayout(3, 2));
- panel.add(new JLabel("Sequence Feature Name: ", JLabel.RIGHT));
- panel.add(name);
- panel.add(new JLabel("Feature Group: ", JLabel.RIGHT));
- panel.add(source);
- panel.add(new JLabel("Feature Colour: ", JLabel.RIGHT));
JPanel tmp = new JPanel();
+ JPanel panel = new JPanel(new GridLayout(3, 1));
+
+ ///////////////////////////////////////
+ ///MULTIPLE FEATURES AT SELECTED RESIDUE
+ if(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);
+
+ overlaps.addItemListener(new ItemListener()
+ {
+ public void itemStateChanged(ItemEvent e)
+ {
+ int index = overlaps.getSelectedIndex();
+ if (index != -1)
+ {
+ featureIndex = index;
+ name.setText(features[index].getType());
+ description.setText(features[index].getDescription());
+ source.setText(features[index].getFeatureGroup());
+ start.setValue(new Integer(features[index].getBegin()));
+ end.setValue(new Integer(features[index].getEnd()));
+ colour.setBackground(
+ getColour(features[index].getType()));
+
+ SearchResults highlight = new SearchResults();
+ highlight.addResult(sequences[0],
+ features[index].getBegin(),
+ features[index].getEnd());
+
+ ap.seqPanel.seqCanvas.highlightSearchResults(highlight);
+
+ }
+ Color col = getColour(name.getText());
+ if (col == null)
+ {
+ col = new
+ jalview.schemes.UserColourScheme()
+ .createColourFromName(name.getText());
+ }
+
+ colour.setBackground(col);
+ }
+ });
+
+
+ panel.add(tmp);
+ }
+ //////////
+ //////////////////////////////////////
+
+ tmp = new JPanel();
+ panel.add(tmp);
+ tmp.add(new JLabel("Name: ", JLabel.RIGHT));
+ tmp.add(name);
+
+ tmp = new JPanel();
+ panel.add(tmp);
+ tmp.add(new JLabel("Group: ", JLabel.RIGHT));
+ tmp.add(source);
+
+ tmp = new JPanel();
+ panel.add(tmp);
+ tmp.add(new JLabel("Colour: ", JLabel.RIGHT));
tmp.add(colour);
colour.setPreferredSize(new Dimension(150, 15));
- panel.add(tmp);
- name.setEditable(true);
- source.setEditable(true);
bigPanel.add(panel, BorderLayout.NORTH);
+
panel = new JPanel();
panel.add(new JLabel("Description: ", JLabel.RIGHT));
description.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));
description.setLineWrap(true);
panel.add(new JScrollPane(description));
+ name.setText(features[0].type);
+ source.setText(features[0].featureGroup);
+ start.setValue(new Integer(features[0].getBegin()));
+ end.setValue(new Integer(features[0].getEnd()));
+ colour.setBackground( getColour(features[0].type) );
+ description.setText(features[0].getDescription());
+
if (!newFeatures)
{
bigPanel.add(panel, BorderLayout.SOUTH);
}
else
{
- lastFeatureAdded = "Jalview";
+ lastFeatureGroupAdded = "Jalview";
}
}
- Enumeration en;
- if (featureGroups != null)
- {
- en = featureGroups.keys();
- while (en.hasMoreElements())
- {
- source.addItem(en.nextElement().toString());
- }
- }
-
- if (newFeatures)
- {
- if (av.featuresDisplayed != null)
- {
- en = av.featuresDisplayed.keys();
- while (en.hasMoreElements())
- {
- name.addItem(en.nextElement().toString());
- }
- }
-
- name.setSelectedItem(lastFeatureAdded);
- source.setSelectedItem(lastFeatureGroupAdded);
- description.setText(
- lastDescriptionAdded == null ?
- features[0].description : lastDescriptionAdded);
-
- if (getColour(lastFeatureAdded) != null)
- {
- colour.setBackground(getColour(lastFeatureAdded));
- }
- else
- {
- colour.setBackground(new Color(60, 160, 115));
- }
-
- }
- else if (!newFeatures)
- {
- featureIndex = 0;
- for (int f = 0; f < features.length; f++)
- {
- name.addItem(features[f].getType().toString());
- }
-
- description.setText(features[0].getDescription());
- source.setSelectedItem(features[0].getFeatureGroup());
- start.setValue(new Integer(features[0].getBegin()));
- end.setValue(new Integer(features[0].getEnd()));
- colour.setBackground(
- getColour(name.getSelectedItem().toString()));
- name.addItemListener(new ItemListener()
- {
- public void itemStateChanged(ItemEvent e)
- {
- int index = name.getSelectedIndex();
- if (index != -1)
- {
- featureIndex = index;
- description.setText(features[index].getDescription());
- source.setSelectedItem(features[index].getFeatureGroup());
- start.setValue(new Integer(features[index].getBegin()));
- end.setValue(new Integer(features[index].getEnd()));
- colour.setBackground(
- getColour(name.getSelectedItem().toString()));
-
- SearchResults highlight = new SearchResults();
- highlight.addResult(sequences[0],
- features[index].getBegin(),
- features[index].getEnd());
-
- ap.seqPanel.seqCanvas.highlightSearchResults(highlight);
-
- }
- Color col = getColour(name.getSelectedItem().toString());
- if (col == null)
- {
- col = new
- jalview.schemes.UserColourScheme()
- .createColourFromName(name.getSelectedItem().toString());
- }
-
- colour.setBackground(col);
- }
- });
-
- }
Object[] options;
if (!newFeatures)
jalview.io.FeaturesFile ffile = new jalview.io.FeaturesFile();
if (reply == JOptionPane.OK_OPTION
- && name.getSelectedItem() != null
- && source.getSelectedItem() != null)
+ && name.getText() != null
+ && source.getText() != null)
{
// This ensures that the last sequence
// is refreshed and new features are rendered
lastSeq = null;
- lastFeatureAdded = name.getSelectedItem().toString();
- lastFeatureGroupAdded = source.getSelectedItem().toString();
+ lastFeatureAdded = name.getText();
+ lastFeatureGroupAdded = source.getText();
lastDescriptionAdded = description.getText().replaceAll("\n", " ");
}
else
{
if (reply == JOptionPane.OK_OPTION
- && name.getSelectedItem() != null
- && source.getSelectedItem() != null)
+ && name.getText() != null
+ && source.getText() != null)
{
for (int i = 0; i < sequences.length; i++)
{
}
}
- if (name.getSelectedIndex() == -1)
+ // if (name.getSelectedIndex() == -1)
{
- findAllFeatures();
+ // findAllFeatures();
}
return true;
setFeaturePriority(data, true);
}
/**
- *
+ *
* @param data { String(Type), Colour(Type), Boolean(Displayed) }
* @param visibleNew when true current featureDisplay list will be cleared
*/
av.featuresDisplayed = new Hashtable();
}
}
- if (data==null)
+ if (data==null)
{
return;
}
-
+
// The feature table will display high priority
// features at the top, but theses are the ones
// we need to render last, so invert the data
/**
* analogous to colour - store a normalized ordering for all feature types in
* this rendering context.
- *
+ *
* @param type
* Feature type string
* @param position
*/
public float setOrder(String type, float position)
{
- if (featureOrder==null)
+ if (featureOrder==null)
{
featureOrder = new Hashtable();
}
}
/**
* get the global priority (0 (top) to 1 (bottom))
- *
+ *
* @param type
* @return [0,1] or -1 for a type without a priority
*/
public float getOrder(String type) {
- if (featureOrder!=null)
+ if (featureOrder!=null)
{
if (featureOrder.containsKey(type))
{