X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FFeatureRenderer.java;h=12876edb05e464d704cf1a736cad7ae595332d27;hb=3f9c1d052c8fe2e92ae0d7a1c3088ccb82c58ba5;hp=ec03b859b49a66f09151777f4b5422246403778e;hpb=95032c2e3e635e40bd92f3c6e218dde19a7db068;p=jalview.git diff --git a/src/jalview/gui/FeatureRenderer.java b/src/jalview/gui/FeatureRenderer.java index ec03b85..12876ed 100755 --- a/src/jalview/gui/FeatureRenderer.java +++ b/src/jalview/gui/FeatureRenderer.java @@ -27,6 +27,7 @@ import java.util.*; import java.awt.image.*; import javax.swing.*; import javax.swing.JOptionPane; +import java.awt.event.*; /** @@ -211,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 @@ -308,7 +309,7 @@ public class FeatureRenderer int pady = (y1 + av.charHeight) - av.charHeight / 5; for (i = fstart; i <= fend; i++) { - s = seq.getSequence().charAt(i); + s = seq.getCharAt(i); if (jalview.util.Comparison.isGap(s)) { @@ -422,17 +423,47 @@ public class FeatureRenderer public boolean createNewFeatures(SequenceI[] sequences, SequenceFeature [] features) { + return amendFeatures(sequences, features, true, null); + } + int featureIndex = 0; + boolean amendFeatures(final SequenceI[] sequences, + final SequenceFeature[] features, + boolean newFeatures, + final AlignmentPanel ap) + { JPanel bigPanel = new JPanel(new BorderLayout()); - JComboBox name = new JComboBox(); - JComboBox source = new JComboBox(); - JTextArea description = new JTextArea(3,25); + 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(2, 2)); - panel.add(new JLabel("New Sequence Feature Name: ",JLabel.RIGHT)); + 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); @@ -442,27 +473,20 @@ public class FeatureRenderer description.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); description.setLineWrap(true); panel.add(new JScrollPane(description)); - bigPanel.add(panel, BorderLayout.CENTER); - - - Enumeration en; - if (av.featuresDisplayed != null) - { - en = av.featuresDisplayed.keys(); - while (en.hasMoreElements()) - { - name.addItem(en.nextElement().toString()); - } - } - if (featureGroups != null) + if(!newFeatures) { - en = featureGroups.keys(); - while (en.hasMoreElements()) - { - source.addItem(en.nextElement().toString()); - } + 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) @@ -477,60 +501,188 @@ public class FeatureRenderer lastFeatureAdded = "Jalview"; - name.setSelectedItem(lastFeatureAdded); - source.setSelectedItem(lastFeatureGroupAdded); - description.setText( - lastDescriptionAdded == null ? - features[0].description : lastDescriptionAdded); + 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