X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FFeatureRenderer.java;h=ed6a3c545378e15aa0364f3ffda94c59d3566178;hb=fd7eebe6dcf2346692d718ef91bb468cc12ebf44;hp=61e99acaef0a4f6d7e07c84621aa96d886619d88;hpb=f8e603128476ca6e093ea2fc65435d1294978c53;p=jalview.git diff --git a/src/jalview/gui/FeatureRenderer.java b/src/jalview/gui/FeatureRenderer.java index 61e99ac..ed6a3c5 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; @@ -93,7 +96,7 @@ public class FeatureRenderer extends static String lastDescriptionAdded; - Object oldcol, fcol; + FeatureColourI oldcol, fcol; int featureIndex = 0; @@ -125,20 +128,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(); @@ -172,7 +174,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++) { @@ -198,18 +201,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); @@ -223,12 +226,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); @@ -247,7 +251,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); @@ -326,14 +330,14 @@ 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 @@ -352,11 +356,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; @@ -379,7 +383,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++) { @@ -420,26 +424,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); } }