*/
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;
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!
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)
{
/**
* 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)
+ if (newcol.isSimpleColour())
{
- isGcol = false;
- col = (Color) newcol;
- gcol = null;
- }
- else if (newcol instanceof GraduatedColor)
- {
- 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;
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);
start.setText(features[0].getBegin() + "");
end.setText(features[0].getEnd() + "");
description.setText(features[0].getDescription());
- 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)
{
}
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)
{
if (!colourPanel.isGcol)
{
// update colour - otherwise its already done.
- setColour(sf.type, colourPanel.getBackground());
+ setColour(sf.type, new FeatureColour(colourPanel.getBackground()));
}
try
{
{
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();