X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FFeatureRenderer.java;h=beef70c25c67a68e50f9df5b5a550ea84b355f4e;hb=d587f1aa61946dc14f6f089cf1dc2a3116cfb773;hp=afe29a047ee4764d5dda6a9582b7af049c630551;hpb=174230b4233d9ce80f94527768d2cd2f76da11ab;p=jalview.git diff --git a/src/jalview/gui/FeatureRenderer.java b/src/jalview/gui/FeatureRenderer.java index afe29a0..beef70c 100755 --- a/src/jalview/gui/FeatureRenderer.java +++ b/src/jalview/gui/FeatureRenderer.java @@ -25,6 +25,9 @@ import java.awt.*; import java.util.*; import java.awt.image.*; +import javax.swing.*; +import javax.swing.JOptionPane; +import java.awt.event.*; /** @@ -209,7 +212,7 @@ public class FeatureRenderer { type = renderOrder[renderIndex]; - if(!av.featuresDisplayed.containsKey(type)) + if(type==null || !av.featuresDisplayed.containsKey(type)) continue; // loop through all features in sequence to find @@ -413,17 +416,270 @@ public class FeatureRenderer } - public void addNewFeature(String name, Color col, String group) + static String lastFeatureAdded; + static String lastFeatureGroupAdded; + static String lastDescriptionAdded; + + public boolean createNewFeatures(SequenceI[] sequences, + SequenceFeature [] features) { + return amendFeatures(sequences, features, true, null); + } - setColour(name, col); - if(av.featuresDisplayed==null) - av.featuresDisplayed = new Hashtable(); + int featureIndex = 0; + boolean amendFeatures(final SequenceI[] sequences, + final SequenceFeature[] features, + boolean newFeatures, + final AlignmentPanel ap) + { + JPanel bigPanel = new JPanel(new BorderLayout()); + final JComboBox name = new JComboBox(); + final JComboBox source = new JComboBox(); + 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) + { + colour.setBackground( + JColorChooser.showDialog(Desktop.desktop, + "Select Feature Colour", + colour.getBackground())); + } + }); + + 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(); + 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)); + + if(!newFeatures) + { + bigPanel.add(panel, BorderLayout.SOUTH); + + panel = new JPanel(); + panel.add(new JLabel(" Start:", JLabel.RIGHT)); + panel.add(start); + panel.add(new JLabel(" End:", JLabel.RIGHT)); + panel.add(end); + bigPanel.add(panel, BorderLayout.CENTER); + } + else + bigPanel.add(panel, BorderLayout.CENTER); + + if (lastFeatureAdded == null) + if (features[0].type != null) + lastFeatureAdded = features[0].type; + else + lastFeatureAdded = "feature_1"; + + if (lastFeatureGroupAdded == null) + if (features[0].featureGroup != null) + lastFeatureGroupAdded = features[0].featureGroup; + else + lastFeatureAdded = "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