X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FFeatureRenderer.java;h=3f875493bb4dad398e8a349cba1f8ac62a3ec5bb;hb=44cbaf5e4c094d90ef1294dd47c75a652e5f2509;hp=03d4ce60d71b153d8bc4069665dfd29719f5daa7;hpb=303e2fff7dd24d9e17a603512702a087a9cc3337;p=jalview.git diff --git a/src/jalview/appletgui/FeatureRenderer.java b/src/jalview/appletgui/FeatureRenderer.java index 03d4ce6..3f87549 100644 --- a/src/jalview/appletgui/FeatureRenderer.java +++ b/src/jalview/appletgui/FeatureRenderer.java @@ -20,11 +20,13 @@ */ package jalview.appletgui; +import jalview.api.FeatureColourI; import jalview.datamodel.SearchResults; import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceI; -import jalview.schemes.AnnotationColourGradient; -import jalview.schemes.GraduatedColor; +import jalview.io.FeaturesFile; +import jalview.schemes.FeatureColour; +import jalview.schemes.UserColourScheme; import jalview.util.MessageManager; import jalview.viewmodel.AlignmentViewport; @@ -43,6 +45,9 @@ import java.awt.TextArea; import java.awt.TextField; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.Hashtable; /** * DOCUMENT ME! @@ -53,11 +58,15 @@ import java.awt.event.ActionListener; public class FeatureRenderer extends jalview.renderer.seqfeatures.FeatureRenderer { + + // Holds web links for feature groups and feature types + // in the form label|link + Hashtable featureLinks = null; + /** * Creates a new FeatureRenderer object. * * @param av - * DOCUMENT ME! */ public FeatureRenderer(AlignmentViewport av) { @@ -88,51 +97,35 @@ public class FeatureRenderer extends /** * render a feature style in the amend feature dialog box */ - public void updateColor(Object newcol) + public void updateColor(FeatureColourI newcol) { - - Color bg, col = null; - GraduatedColor gcol = null; + Color bg = null; String vlabel = ""; - if (newcol instanceof Color) - { - isGcol = false; - col = (Color) newcol; - gcol = null; - } - else if (newcol instanceof GraduatedColor) + if (newcol.isSimpleColour()) { - isGcol = true; - gcol = (GraduatedColor) newcol; - col = null; + bg = newcol.getColour(); + setBackground(bg); } else { - throw new Error( - MessageManager - .getString("error.invalid_colour_for_mycheckbox")); - } - if (col != null) - { - setBackground(bg = col); - } - else - { - if (gcol.getThreshType() != AnnotationColourGradient.NO_THRESHOLD) + if (newcol.isAboveThreshold()) { - vlabel += " " - + ((gcol.getThreshType() == AnnotationColourGradient.ABOVE_THRESHOLD) ? "(>)" - : "(<)"); + vlabel += " (>)"; } - if (isColourByLabel = gcol.isColourByLabel()) + else if (newcol.isBelowThreshold()) + { + vlabel += " (<)"; + } + + if (isColourByLabel = newcol.isColourByLabel()) { setBackground(bg = Color.white); vlabel += " (by Label)"; } else { - setBackground(bg = gcol.getMinColor()); - maxCol = gcol.getMaxColor(); + setBackground(bg = newcol.getMinColour()); + maxCol = newcol.getMaxColour(); } } label = vlabel; @@ -239,11 +232,12 @@ public class FeatureRenderer extends ap.seqPanel.seqCanvas.highlightSearchResults(highlight); } - Object col = getFeatureStyle(name.getText()); + FeatureColourI col = getFeatureStyle(name.getText()); if (col == null) { - col = new jalview.schemes.UserColourScheme() + Color generatedColour = UserColourScheme .createColourFromName(name.getText()); + col = new FeatureColour(generatedColour); } colourPanel.updateColor(col); @@ -351,21 +345,16 @@ public class FeatureRenderer extends start.setText(features[0].getBegin() + ""); end.setText(features[0].getEnd() + ""); description.setText(features[0].getDescription()); - Color col = getColour(name.getText()); - if (col == null) - { - col = new jalview.schemes.UserColourScheme() - .createColourFromName(name.getText()); - } - Object fcol = getFeatureStyle(name.getText()); + // lookup (or generate) the feature colour + FeatureColourI fcol = getFeatureStyle(name.getText()); // simply display the feature color in a box colourPanel.updateColor(fcol); dialog.setResizable(true); // TODO: render the graduated color in the box. - colourPanel.addMouseListener(new java.awt.event.MouseAdapter() + colourPanel.addMouseListener(new MouseAdapter() { @Override - public void mousePressed(java.awt.event.MouseEvent evt) + public void mousePressed(MouseEvent evt) { if (!colourPanel.isGcol) { @@ -373,15 +362,14 @@ public class FeatureRenderer extends } else { - FeatureColourChooser fcc = new FeatureColourChooser( - ap.alignFrame, name.getText()); + new FeatureColourChooser(ap.alignFrame, name.getText()); dialog.transferFocus(); } } }); dialog.setVisible(true); - jalview.io.FeaturesFile ffile = new jalview.io.FeaturesFile(); + FeaturesFile ffile = new FeaturesFile(); if (dialog.accept) { @@ -410,7 +398,7 @@ public class FeatureRenderer extends if (!colourPanel.isGcol) { // update colour - otherwise its already done. - setColour(sf.type, colourPanel.getBackground()); + setColour(sf.type, new FeatureColour(colourPanel.getBackground())); } try { @@ -450,7 +438,7 @@ public class FeatureRenderer extends { setGroupVisibility(lastFeatureGroupAdded, true); } - setColour(lastFeatureAdded, newColour); // was fcol + setColour(lastFeatureAdded, new FeatureColour(newColour)); // was fcol setVisible(lastFeatureAdded); findAllFeatures(false); // different to original applet behaviour ? // findAllFeatures();