X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FFeatureRenderer.java;h=f519f99088e883c583cae8417dceeb7846c85bd2;hb=f9e86edb330898f638ab3713b9534e9b6364a3d4;hp=1cf15ace28d1288a9b84a5679a73d5de333298c5;hpb=c406d789d51e6ac1ff45e3568d37e9ed53025f03;p=jalview.git diff --git a/src/jalview/gui/FeatureRenderer.java b/src/jalview/gui/FeatureRenderer.java index 1cf15ac..f519f99 100644 --- a/src/jalview/gui/FeatureRenderer.java +++ b/src/jalview/gui/FeatureRenderer.java @@ -20,10 +20,13 @@ */ package jalview.gui; +import jalview.api.FeatureColourI; import jalview.datamodel.SearchResults; +import jalview.datamodel.SearchResultsI; import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceI; -import jalview.schemes.GraduatedColor; +import jalview.schemes.FeatureColour; +import jalview.util.ColorUtils; import jalview.util.MessageManager; import java.awt.BorderLayout; @@ -43,7 +46,6 @@ import java.util.Comparator; import javax.swing.JColorChooser; import javax.swing.JComboBox; import javax.swing.JLabel; -import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSpinner; @@ -58,8 +60,7 @@ import javax.swing.SwingConstants; * @version $Revision$ */ public class FeatureRenderer extends - jalview.renderer.seqfeatures.FeatureRenderer implements - jalview.api.FeatureRenderer + jalview.renderer.seqfeatures.FeatureRenderer { Color resBoxColour; @@ -73,9 +74,8 @@ public class FeatureRenderer extends */ public FeatureRenderer(AlignmentPanel ap) { - super(); + super(ap.av); this.ap = ap; - this.av = ap.av; if (ap != null && ap.getSeqPanel() != null && ap.getSeqPanel().seqCanvas != null && ap.getSeqPanel().seqCanvas.fr != null) @@ -94,7 +94,7 @@ public class FeatureRenderer extends static String lastDescriptionAdded; - Object oldcol, fcol; + FeatureColourI oldcol, fcol; int featureIndex = 0; @@ -126,20 +126,19 @@ public class FeatureRenderer extends @Override public void mousePressed(MouseEvent evt) { - if (fcol instanceof Color) + if (fcol.isSimpleColour()) { Color col = JColorChooser.showDialog(Desktop.desktop, MessageManager.getString("label.select_feature_colour"), - ((Color) fcol)); + fcol.getColour()); if (col != null) { - fcol = col; - updateColourButton(bigPanel, colour, col); + fcol = new FeatureColour(col); + updateColourButton(bigPanel, colour, new FeatureColour(col)); } } else { - if (fcc == null) { final String type = features[featureIndex].getType(); @@ -173,7 +172,8 @@ public class FeatureRenderer extends { panel = new JPanel(new GridLayout(4, 1)); tmp = new JPanel(); - tmp.add(new JLabel(MessageManager.getString("label.select_feature"))); + tmp.add(new JLabel(MessageManager.getString("label.select_feature") + + ":")); overlaps = new JComboBox(); for (int i = 0; i < features.length; i++) { @@ -199,18 +199,18 @@ public class FeatureRenderer extends start.setValue(new Integer(features[index].getBegin())); end.setValue(new Integer(features[index].getEnd())); - SearchResults highlight = new SearchResults(); + SearchResultsI highlight = new SearchResults(); highlight.addResult(sequences[0], features[index].getBegin(), features[index].getEnd()); ap.getSeqPanel().seqCanvas.highlightSearchResults(highlight); } - Object col = getFeatureStyle(name.getText()); + FeatureColourI col = getFeatureStyle(name.getText()); if (col == null) { - col = new jalview.schemes.UserColourScheme() - .createColourFromName(name.getText()); + col = new FeatureColour(ColorUtils + .createColourFromName(name.getText())); } oldcol = fcol = col; updateColourButton(bigPanel, colour, col); @@ -224,12 +224,13 @@ public class FeatureRenderer extends tmp = new JPanel(); panel.add(tmp); - tmp.add(new JLabel(MessageManager.getString("label.name"), JLabel.RIGHT)); + tmp.add(new JLabel(MessageManager.getString("label.name:"), + JLabel.RIGHT)); tmp.add(name); tmp = new JPanel(); panel.add(tmp); - tmp.add(new JLabel(MessageManager.getString("label.group") + ":", + tmp.add(new JLabel(MessageManager.getString("label.group:"), JLabel.RIGHT)); tmp.add(source); @@ -248,7 +249,7 @@ public class FeatureRenderer extends bigPanel.add(panel, BorderLayout.NORTH); panel = new JPanel(); - panel.add(new JLabel(MessageManager.getString("label.description"), + panel.add(new JLabel(MessageManager.getString("label.description:"), JLabel.RIGHT)); description.setFont(JvSwingUtils.getTextAreaFont()); description.setLineWrap(true); @@ -327,18 +328,15 @@ public class FeatureRenderer extends : MessageManager.formatMessage("label.amend_delete_features", new String[] { sequences[0].getName() }); - int reply = JOptionPane.showInternalOptionDialog(Desktop.desktop, - bigPanel, title, JOptionPane.YES_NO_CANCEL_OPTION, - JOptionPane.QUESTION_MESSAGE, null, options, + int reply = JvOptionPane.showInternalOptionDialog(Desktop.desktop, + bigPanel, title, JvOptionPane.YES_NO_CANCEL_OPTION, + JvOptionPane.QUESTION_MESSAGE, null, options, MessageManager.getString("action.ok")); jalview.io.FeaturesFile ffile = new jalview.io.FeaturesFile(); - if (reply == JOptionPane.OK_OPTION && name.getText().length() > 0) + if (reply == JvOptionPane.OK_OPTION && name.getText().length() > 0) { - // This ensures that the last sequence - // is refreshed and new features are rendered - lastSeq = null; lastFeatureAdded = name.getText().trim(); lastFeatureGroupAdded = source.getText().trim(); lastDescriptionAdded = description.getText().replaceAll("\n", " "); @@ -353,11 +351,11 @@ public class FeatureRenderer extends { SequenceFeature sf = features[featureIndex]; - if (reply == JOptionPane.NO_OPTION) + if (reply == JvOptionPane.NO_OPTION) { sequences[0].getDatasetSequence().deleteFeature(sf); } - else if (reply == JOptionPane.YES_OPTION) + else if (reply == JvOptionPane.YES_OPTION) { sf.type = lastFeatureAdded; sf.featureGroup = lastFeatureGroupAdded; @@ -380,7 +378,7 @@ public class FeatureRenderer extends else // NEW FEATURES ADDED { - if (reply == JOptionPane.OK_OPTION && lastFeatureAdded.length() > 0) + if (reply == JvOptionPane.OK_OPTION && lastFeatureAdded.length() > 0) { for (int i = 0; i < sequences.length; i++) { @@ -421,26 +419,25 @@ public class FeatureRenderer extends * * @param bigPanel * @param col - * @param col2 + * @param col */ protected void updateColourButton(JPanel bigPanel, JLabel colour, - Object col2) + FeatureColourI col) { colour.removeAll(); colour.setIcon(null); colour.setToolTipText(null); colour.setText(""); - if (col2 instanceof Color) + if (col.isSimpleColour()) { - colour.setBackground((Color) col2); + colour.setBackground(col.getColour()); } else { colour.setBackground(bigPanel.getBackground()); colour.setForeground(Color.black); - FeatureSettings.renderGraduatedColor(colour, (GraduatedColor) col2); - // colour.setForeground(colour.getBackground()); + FeatureSettings.renderGraduatedColor(colour, col); } }