X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FFeatureRenderer.java;h=12876edb05e464d704cf1a736cad7ae595332d27;hb=3f9c1d052c8fe2e92ae0d7a1c3088ccb82c58ba5;hp=2ca3ca37ee205282dbce0bf1c06f998fd58cf8a8;hpb=b0530d7ac372a4b770d381f263970de9ecdb4212;p=jalview.git diff --git a/src/jalview/gui/FeatureRenderer.java b/src/jalview/gui/FeatureRenderer.java index 2ca3ca3..12876ed 100755 --- a/src/jalview/gui/FeatureRenderer.java +++ b/src/jalview/gui/FeatureRenderer.java @@ -212,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 @@ -309,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)) { @@ -423,26 +423,29 @@ public class FeatureRenderer public boolean createNewFeatures(SequenceI[] sequences, SequenceFeature [] features) { - return amendFeatures(sequences, features, true); + return amendFeatures(sequences, features, true, null); } int featureIndex = 0; - boolean amendFeatures(SequenceI[] sequences, - final SequenceFeature [] features, - boolean newFeatures) + 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 JTextField start = new JTextField(6); - final JTextField end = new JTextField(6); - final JButton colour = new JButton(" "); + 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.setBackground(new Color(60, 160, 115)); - colour.addActionListener(new ActionListener() + colour.addMouseListener(new MouseAdapter() { - public void actionPerformed(ActionEvent evt) + public void mousePressed(MouseEvent evt) { colour.setBackground( JColorChooser.showDialog(Desktop.desktop, @@ -476,9 +479,9 @@ public class FeatureRenderer bigPanel.add(panel, BorderLayout.SOUTH); panel = new JPanel(); - panel.add(new JLabel("Start: ", JLabel.RIGHT)); + panel.add(new JLabel(" Start:", JLabel.RIGHT)); panel.add(start); - panel.add(new JLabel("End: ", JLabel.RIGHT)); + panel.add(new JLabel(" End:", JLabel.RIGHT)); panel.add(end); bigPanel.add(panel, BorderLayout.CENTER); } @@ -524,6 +527,16 @@ public class FeatureRenderer 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) { @@ -535,8 +548,8 @@ public class FeatureRenderer description.setText(features[0].getDescription()); source.setSelectedItem(features[0].getFeatureGroup()); - start.setText(features[0].getBegin()+""); - end.setText(features[0].getEnd()+""); + start.setValue(new Integer(features[0].getBegin())); + end.setValue(new Integer(features[0].getEnd())); colour.setBackground( getColour(name.getSelectedItem().toString())); name.addItemListener(new ItemListener() @@ -549,11 +562,26 @@ public class FeatureRenderer featureIndex = index; description.setText(features[index].getDescription()); source.setSelectedItem(features[index].getFeatureGroup()); - start.setText(features[index].getBegin() + ""); - end.setText(features[index].getEnd() + ""); + 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); } }); @@ -566,15 +594,17 @@ public class FeatureRenderer else options = new Object[]{"OK", "Cancel"}; + String title = newFeatures ? "Create New Sequence Feature(s)" : + "Amend/Delete Features for " + +sequences[0].getName(); + int reply = JOptionPane.showInternalOptionDialog(Desktop.desktop, bigPanel, - newFeatures ? - "Create New Sequence Feature(s)" : - "Amend/Delete Features", + title, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, - options, null); + options, "OK"); jalview.io.FeaturesFile ffile = new jalview.io.FeaturesFile(); @@ -582,6 +612,9 @@ public class FeatureRenderer && name.getSelectedItem() != null && source.getSelectedItem() != null) { + //This ensures that the last sequence + //is refreshed and new features are rendered + lastSeq=null; lastFeatureAdded = name.getSelectedItem().toString(); lastFeatureGroupAdded = source.getSelectedItem().toString(); lastDescriptionAdded = description.getText().replaceAll("\n", " "); @@ -600,8 +633,8 @@ public class FeatureRenderer sf.description = lastDescriptionAdded; setColour(sf.type, colour.getBackground()); try{ - sf.begin = Integer.parseInt( start.getText() ); - sf.end = Integer.parseInt( end.getText() ); + sf.begin = ((Integer)start.getValue()).intValue(); + sf.end = ((Integer)end.getValue()).intValue(); }catch(NumberFormatException ex) {}