X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FFeatureRenderer.java;h=beef70c25c67a68e50f9df5b5a550ea84b355f4e;hb=bc77e2f0f477053147a4e56b681131c710eb3ec8;hp=b5b53fd86722bdbd336bf05a809fdebfeda3cefd;hpb=219069b19ed66908ea5ec0819802f772df3493f3;p=jalview.git diff --git a/src/jalview/gui/FeatureRenderer.java b/src/jalview/gui/FeatureRenderer.java index b5b53fd..beef70c 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 @@ -423,25 +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.addActionListener(new ActionListener() + colour.addMouseListener(new MouseAdapter() { - public void actionPerformed(ActionEvent evt) + public void mousePressed(MouseEvent evt) { colour.setBackground( JColorChooser.showDialog(Desktop.desktop, @@ -475,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); } @@ -525,9 +529,13 @@ public class FeatureRenderer features[0].description : lastDescriptionAdded); if (getColour(lastFeatureAdded) != null) + { colour.setBackground(getColour(lastFeatureAdded)); + } else + { colour.setBackground(new Color(60, 160, 115)); + } } else if (!newFeatures) @@ -540,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() @@ -554,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); } }); @@ -571,11 +594,13 @@ 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, @@ -605,8 +630,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) {}