2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
3 * Copyright (C) 2014 The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
17 * The Jalview Authors are detailed in the 'AUTHORS' file.
19 package jalview.appletgui;
25 import java.awt.event.*;
27 import jalview.datamodel.*;
28 import jalview.schemes.AnnotationColourGradient;
29 import jalview.schemes.GraduatedColor;
30 import jalview.util.MessageManager;
38 public class FeatureRenderer implements jalview.api.FeatureRenderer
42 Hashtable featureColours = new Hashtable();
44 // A higher level for grouping features of a
46 Hashtable featureGroups = null;
48 // Holds web links for feature groups and feature types
49 // in the form label|link
50 Hashtable featureLinks = null;
52 // This is actually an Integer held in the hashtable,
53 // Retrieved using the key feature type
62 float transparency = 1f;
64 TransparencySetter transparencySetter = null;
67 * Creates a new FeatureRenderer object.
72 public FeatureRenderer(AlignViewport av)
76 if (!System.getProperty("java.version").startsWith("1.1"))
78 transparencySetter = new TransparencySetter();
82 public void transferSettings(FeatureRenderer fr)
84 renderOrder = fr.renderOrder;
85 featureGroups = fr.featureGroups;
86 featureColours = fr.featureColours;
87 transparency = fr.transparency;
88 if (av != null && fr.av != null && fr.av != av)
90 if (fr.av.featuresDisplayed != null)
92 if (av.featuresDisplayed == null)
94 av.featuresDisplayed = new Hashtable();
98 av.featuresDisplayed.clear();
100 Enumeration en = fr.av.featuresDisplayed.keys();
101 while (en.hasMoreElements())
103 av.featuresDisplayed.put(en.nextElement(), Boolean.TRUE);
109 static String lastFeatureAdded;
111 static String lastFeatureGroupAdded;
113 static String lastDescriptionAdded;
115 int featureIndex = 0;
117 boolean deleteFeature = false;
119 FeatureColourPanel colourPanel;
121 class FeatureColourPanel extends Panel
125 private Color maxCol;
127 private boolean isColourByLabel, isGcol;
130 * render a feature style in the amend feature dialog box
132 public void updateColor(Object newcol)
135 Color bg, col = null;
136 GraduatedColor gcol = null;
138 if (newcol instanceof Color)
141 col = (Color) newcol;
144 else if (newcol instanceof GraduatedColor)
147 gcol = (GraduatedColor) newcol;
152 throw new Error("Invalid color for MyCheckBox");
156 setBackground(bg = col);
160 if (gcol.getThreshType() != AnnotationColourGradient.NO_THRESHOLD)
163 + ((gcol.getThreshType() == AnnotationColourGradient.ABOVE_THRESHOLD) ? "(>)"
166 if (isColourByLabel = gcol.isColourByLabel())
168 setBackground(bg = Color.white);
169 vlabel += " (by Label)";
173 setBackground(bg = gcol.getMinColor());
174 maxCol = gcol.getMaxColor();
187 public void paint(Graphics g)
189 Dimension d = getSize();
194 g.setColor(Color.white);
195 g.fillRect(d.width / 2, 0, d.width / 2, d.height);
196 g.setColor(Color.black);
197 Font f = new Font("Verdana", Font.PLAIN, 10);
199 g.drawString(MessageManager.getString("label.label"), 0, 0);
204 g.fillRect(d.width / 2, 0, d.width / 2, d.height);
212 boolean amendFeatures(final SequenceI[] sequences,
213 final SequenceFeature[] features, boolean newFeatures,
214 final AlignmentPanel ap)
216 Panel bigPanel = new Panel(new BorderLayout());
217 final TextField name = new TextField(16);
218 final TextField source = new TextField(16);
219 final TextArea description = new TextArea(3, 35);
220 final TextField start = new TextField(8);
221 final TextField end = new TextField(8);
222 final Choice overlaps;
223 Button deleteButton = new Button("Delete");
224 deleteFeature = false;
226 colourPanel = new FeatureColourPanel();
227 colourPanel.setSize(110, 15);
228 final FeatureRenderer fr = this;
230 Panel panel = new Panel(new GridLayout(3, 1));
232 featureIndex = 0; // feature to be amended.
235 // /////////////////////////////////////
236 // /MULTIPLE FEATURES AT SELECTED RESIDUE
237 if (!newFeatures && features.length > 1)
239 panel = new Panel(new GridLayout(4, 1));
241 tmp.add(new Label("Select Feature: "));
242 overlaps = new Choice();
243 for (int i = 0; i < features.length; i++)
245 String item = features[i].getType() + "/" + features[i].getBegin()
246 + "-" + features[i].getEnd();
248 if (features[i].getFeatureGroup() != null)
249 item += " (" + features[i].getFeatureGroup() + ")";
251 overlaps.addItem(item);
256 overlaps.addItemListener(new java.awt.event.ItemListener()
258 public void itemStateChanged(java.awt.event.ItemEvent e)
260 int index = overlaps.getSelectedIndex();
263 featureIndex = index;
264 name.setText(features[index].getType());
265 description.setText(features[index].getDescription());
266 source.setText(features[index].getFeatureGroup());
267 start.setText(features[index].getBegin() + "");
268 end.setText(features[index].getEnd() + "");
270 SearchResults highlight = new SearchResults();
271 highlight.addResult(sequences[0], features[index].getBegin(),
272 features[index].getEnd());
274 ap.seqPanel.seqCanvas.highlightSearchResults(highlight);
277 Object col = getFeatureStyle(name.getText());
280 col = new jalview.schemes.UserColourScheme()
281 .createColourFromName(name.getText());
284 colourPanel.updateColor(col);
291 // ////////////////////////////////////
295 tmp.add(new Label("Name: ", Label.RIGHT));
300 tmp.add(new Label("Group: ", Label.RIGHT));
305 tmp.add(new Label("Colour: ", Label.RIGHT));
306 tmp.add(colourPanel);
308 bigPanel.add(panel, BorderLayout.NORTH);
311 panel.add(new Label("Description: ", Label.RIGHT));
312 panel.add(new ScrollPane().add(description));
316 bigPanel.add(panel, BorderLayout.SOUTH);
319 panel.add(new Label(" Start:", Label.RIGHT));
321 panel.add(new Label(" End:", Label.RIGHT));
323 bigPanel.add(panel, BorderLayout.CENTER);
327 bigPanel.add(panel, BorderLayout.CENTER);
330 if (lastFeatureAdded == null)
332 if (features[0].type != null)
334 lastFeatureAdded = features[0].type;
338 lastFeatureAdded = "feature_1";
342 if (lastFeatureGroupAdded == null)
344 if (features[0].featureGroup != null)
346 lastFeatureGroupAdded = features[0].featureGroup;
350 lastFeatureAdded = "Jalview";
354 String title = newFeatures ? "Create New Sequence Feature(s)"
355 : "Amend/Delete Features for " + sequences[0].getName();
357 final JVDialog dialog = new JVDialog(ap.alignFrame, title, true, 385,
360 dialog.setMainPanel(bigPanel);
364 name.setText(lastFeatureAdded);
365 source.setText(lastFeatureGroupAdded);
369 dialog.ok.setLabel(MessageManager.getString("label.amend"));
370 dialog.buttonPanel.add(deleteButton, 1);
371 deleteButton.addActionListener(new ActionListener()
373 public void actionPerformed(ActionEvent evt)
375 deleteFeature = true;
376 dialog.setVisible(false);
379 name.setText(features[0].getType());
380 source.setText(features[0].getFeatureGroup());
383 start.setText(features[0].getBegin() + "");
384 end.setText(features[0].getEnd() + "");
385 description.setText(features[0].getDescription());
386 Color col = getColour(name.getText());
389 col = new jalview.schemes.UserColourScheme()
390 .createColourFromName(name.getText());
392 Object fcol = getFeatureStyle(name.getText());
393 // simply display the feature color in a box
394 colourPanel.updateColor(fcol);
395 dialog.setResizable(true);
396 // TODO: render the graduated color in the box.
397 colourPanel.addMouseListener(new java.awt.event.MouseAdapter()
399 public void mousePressed(java.awt.event.MouseEvent evt)
401 if (!colourPanel.isGcol)
403 new UserDefinedColours(fr, ap.alignFrame);
407 FeatureColourChooser fcc = new FeatureColourChooser(
408 ap.alignFrame, name.getText());
409 dialog.transferFocus();
413 dialog.setVisible(true);
415 jalview.io.FeaturesFile ffile = new jalview.io.FeaturesFile();
419 // This ensures that the last sequence
420 // is refreshed and new features are rendered
422 lastFeatureAdded = name.getText().trim();
423 lastFeatureGroupAdded = source.getText().trim();
424 lastDescriptionAdded = description.getText().replace('\n', ' ');
427 if (lastFeatureGroupAdded != null && lastFeatureGroupAdded.length() < 1)
428 lastFeatureGroupAdded = null;
433 SequenceFeature sf = features[featureIndex];
436 sf.type = lastFeatureAdded;
437 sf.featureGroup = lastFeatureGroupAdded;
438 sf.description = lastDescriptionAdded;
439 if (!colourPanel.isGcol)
441 // update colour - otherwise its already done.
442 setColour(sf.type, colourPanel.getBackground());
446 sf.begin = Integer.parseInt(start.getText());
447 sf.end = Integer.parseInt(end.getText());
448 } catch (NumberFormatException ex)
452 ffile.parseDescriptionHTML(sf, false);
456 sequences[0].deleteFeature(sf);
462 if (dialog.accept && name.getText().length() > 0)
464 for (int i = 0; i < sequences.length; i++)
466 features[i].type = lastFeatureAdded;
467 features[i].featureGroup = lastFeatureGroupAdded;
468 features[i].description = lastDescriptionAdded;
469 sequences[i].addSequenceFeature(features[i]);
470 ffile.parseDescriptionHTML(features[i], false);
473 if (av.featuresDisplayed == null)
475 av.featuresDisplayed = new Hashtable();
478 if (featureGroups == null)
480 featureGroups = new Hashtable();
483 col = colourPanel.getBackground();
484 // setColour(lastFeatureAdded, fcol);
486 if (lastFeatureGroupAdded != null)
488 featureGroups.put(lastFeatureGroupAdded, new Boolean(true));
490 if (fcol instanceof Color)
492 setColour(lastFeatureAdded, fcol);
494 av.featuresDisplayed.put(lastFeatureAdded,
495 getFeatureStyle(lastFeatureAdded));
499 String[] tro = new String[renderOrder.length];
500 tro[0] = renderOrder[renderOrder.length - 1];
501 System.arraycopy(renderOrder, 0, tro, 1, renderOrder.length - 1);
506 // no update to the alignment
510 // refresh the alignment and the feature settings dialog
511 if (av.featureSettings != null)
513 av.featureSettings.refreshTable();
515 // findAllFeatures();
517 ap.paintAlignment(true);
522 public Color findFeatureColour(Color initialCol, SequenceI seq, int i)
525 if (!av.showSequenceFeatures)
531 sequenceFeatures = lastSeq.getSequenceFeatures();
532 if (sequenceFeatures == null)
537 sfSize = sequenceFeatures.length;
539 if (jalview.util.Comparison.isGap(lastSeq.getCharAt(i)))
544 currentColour = null;
546 drawSequence(null, lastSeq, lastSeq.findPosition(i), -1, -1);
548 if (currentColour == null)
553 return new Color(((Integer) currentColour).intValue());
557 * This is used by the Molecule Viewer to get the accurate colour of the
560 boolean overview = false;
585 // SequenceFeature sf;
588 SequenceFeature[] sequenceFeatures;
590 int sfSize, sfindex, spos, epos;
592 synchronized public void drawSequence(Graphics g, SequenceI seq,
593 int start, int end, int y1)
595 if (seq.getSequenceFeatures() == null
596 || seq.getSequenceFeatures().length == 0)
601 if (transparencySetter != null && g != null)
603 transparencySetter.setTransparency(g, transparency);
606 if (lastSeq == null || seq != lastSeq
607 || sequenceFeatures != seq.getSequenceFeatures())
610 sequenceFeatures = seq.getSequenceFeatures();
611 sfSize = sequenceFeatures.length;
614 if (av.featuresDisplayed == null || renderOrder == null)
617 if (av.featuresDisplayed.size() < 1)
622 sequenceFeatures = seq.getSequenceFeatures();
623 sfSize = sequenceFeatures.length;
627 spos = lastSeq.findPosition(start);
628 epos = lastSeq.findPosition(end);
631 fm = g.getFontMetrics();
635 for (int renderIndex = 0; renderIndex < renderOrder.length; renderIndex++)
637 type = renderOrder[renderIndex];
638 if (!av.featuresDisplayed.containsKey(type))
643 // loop through all features in sequence to find
644 // current feature to render
645 for (sfindex = 0; sfindex < sfSize; sfindex++)
647 if (!sequenceFeatures[sfindex].type.equals(type))
652 if (featureGroups != null
653 && sequenceFeatures[sfindex].featureGroup != null
655 .containsKey(sequenceFeatures[sfindex].featureGroup)
656 && !((Boolean) featureGroups
657 .get(sequenceFeatures[sfindex].featureGroup))
664 && (sequenceFeatures[sfindex].getBegin() > epos || sequenceFeatures[sfindex]
672 if (sequenceFeatures[sfindex].begin <= start
673 && sequenceFeatures[sfindex].end >= start)
675 currentColour = new Integer(
676 getColour(sequenceFeatures[sfindex]).getRGB());// av.featuresDisplayed
677 // .get(sequenceFeatures[sfindex].type);
681 else if (sequenceFeatures[sfindex].type.equals("disulfide bond"))
684 renderFeature(g, seq,
685 seq.findIndex(sequenceFeatures[sfindex].begin) - 1,
686 seq.findIndex(sequenceFeatures[sfindex].begin) - 1,
687 getColour(sequenceFeatures[sfindex])
688 // new Color(((Integer) av.featuresDisplayed
689 // .get(sequenceFeatures[sfindex].type)).intValue())
691 renderFeature(g, seq,
692 seq.findIndex(sequenceFeatures[sfindex].end) - 1,
693 seq.findIndex(sequenceFeatures[sfindex].end) - 1,
694 getColour(sequenceFeatures[sfindex])
695 // new Color(((Integer) av.featuresDisplayed
696 // .get(sequenceFeatures[sfindex].type)).intValue())
702 if (showFeature(sequenceFeatures[sfindex]))
704 renderFeature(g, seq,
705 seq.findIndex(sequenceFeatures[sfindex].begin) - 1,
706 seq.findIndex(sequenceFeatures[sfindex].end) - 1,
707 getColour(sequenceFeatures[sfindex]), start, end, y1);
714 if (transparencySetter != null && g != null)
716 transparencySetter.setTransparency(g, 1.0f);
724 void renderFeature(Graphics g, SequenceI seq, int fstart, int fend,
725 Color featureColour, int start, int end, int y1)
728 if (((fstart <= end) && (fend >= start)))
731 { // fix for if the feature we have starts before the sequence start,
732 fstart = start; // but the feature end is still valid!!
740 for (i = fstart; i <= fend; i++)
742 s = seq.getCharAt(i);
744 if (jalview.util.Comparison.isGap(s))
749 g.setColor(featureColour);
751 g.fillRect((i - start) * av.charWidth, y1, av.charWidth,
754 if (!av.validCharWidth)
759 g.setColor(Color.white);
760 charOffset = (av.charWidth - fm.charWidth(s)) / 2;
761 g.drawString(String.valueOf(s), charOffset
762 + (av.charWidth * (i - start)), (y1 + av.charHeight)
763 - av.charHeight / 5); // pady = height / 5;
769 Hashtable minmax = null;
772 * Called when alignment in associated view has new/modified features to
773 * discover and display.
776 public void featuresAdded()
783 * find all features on the alignment
785 void findAllFeatures()
787 jalview.schemes.UserColourScheme ucs = new jalview.schemes.UserColourScheme();
789 av.featuresDisplayed = new Hashtable();
790 Vector allfeatures = new Vector();
791 minmax = new Hashtable();
792 AlignmentI alignment = av.getAlignment();
793 for (int i = 0; i < alignment.getHeight(); i++)
795 SequenceFeature[] features = alignment.getSequenceAt(i)
796 .getSequenceFeatures();
798 if (features == null)
804 while (index < features.length)
806 if (features[index].begin == 0 && features[index].end == 0)
811 if (!av.featuresDisplayed.containsKey(features[index].getType()))
813 if (getColour(features[index].getType()) == null)
815 featureColours.put(features[index].getType(),
816 ucs.createColourFromName(features[index].getType()));
819 av.featuresDisplayed.put(features[index].getType(), new Integer(
820 getColour(features[index].getType()).getRGB()));
821 allfeatures.addElement(features[index].getType());
823 if (features[index].score != Float.NaN)
825 int nonpos = features[index].getBegin() >= 1 ? 0 : 1;
826 float[][] mm = (float[][]) minmax.get(features[index].getType());
831 minmax.put(features[index].getType(), mm);
833 if (mm[nonpos] == null)
835 mm[nonpos] = new float[]
836 { features[index].score, features[index].score };
841 if (mm[nonpos][0] > features[index].score)
843 mm[nonpos][0] = features[index].score;
845 if (mm[nonpos][1] < features[index].score)
847 mm[nonpos][1] = features[index].score;
856 renderOrder = new String[allfeatures.size()];
857 Enumeration en = allfeatures.elements();
858 int i = allfeatures.size() - 1;
859 while (en.hasMoreElements())
861 renderOrder[i] = en.nextElement().toString();
867 * get a feature style object for the given type string. Creates a
868 * java.awt.Color for a featureType with no existing colourscheme. TODO:
869 * replace return type with object implementing standard abstract colour/style
873 * @return java.awt.Color or GraduatedColor
875 public Object getFeatureStyle(String featureType)
877 Object fc = featureColours.get(featureType);
880 jalview.schemes.UserColourScheme ucs = new jalview.schemes.UserColourScheme();
881 Color col = ucs.createColourFromName(featureType);
882 featureColours.put(featureType, fc = col);
887 public Color getColour(String featureType)
889 Object fc = getFeatureStyle(featureType);
891 if (fc instanceof Color)
897 if (fc instanceof GraduatedColor)
899 return ((GraduatedColor) fc).getMaxColor();
902 throw new Error("Implementation Error: Unrecognised render object "
903 + fc.getClass() + " for features of type " + featureType);
908 * @param sequenceFeature
909 * @return true if feature is visible.
911 private boolean showFeature(SequenceFeature sequenceFeature)
913 Object fc = getFeatureStyle(sequenceFeature.type);
914 if (fc instanceof GraduatedColor)
916 return ((GraduatedColor) fc).isColored(sequenceFeature);
925 * implement graduated colouring for features with scores
928 * @return render colour for the given feature
930 public Color getColour(SequenceFeature feature)
932 Object fc = getFeatureStyle(feature.getType());
933 if (fc instanceof Color)
939 if (fc instanceof GraduatedColor)
941 return ((GraduatedColor) fc).findColor(feature);
944 throw new Error("Implementation Error: Unrecognised render object "
945 + fc.getClass() + " for features of type " + feature.getType());
948 public void setColour(String featureType, Object col)
951 // Color _col = (col instanceof Color) ? ((Color) col) : (col instanceof
952 // GraduatedColor) ? ((GraduatedColor) col).getMaxColor() : null;
953 // Object c = featureColours.get(featureType);
954 // if (c == null || c instanceof Color || (c instanceof GraduatedColor &&
955 // !((GraduatedColor)c).getMaxColor().equals(_col)))
957 featureColours.put(featureType, col);
961 public void setFeaturePriority(Object[][] data)
963 // The feature table will display high priority
964 // features at the top, but theses are the ones
965 // we need to render last, so invert the data
966 if (av.featuresDisplayed != null)
968 av.featuresDisplayed.clear();
972 * if (visibleNew) { if (av.featuresDisplayed != null) {
973 * av.featuresDisplayed.clear(); } else { av.featuresDisplayed = new
974 * Hashtable(); } } if (data == null) { return; }
977 renderOrder = new String[data.length];
981 for (int i = 0; i < data.length; i++)
983 String type = data[i][0].toString();
984 setColour(type, data[i][1]);
985 if (((Boolean) data[i][2]).booleanValue())
987 av.featuresDisplayed.put(type, new Integer(getColour(type)
991 renderOrder[data.length - i - 1] = type;
997 * @return a simple list of feature group names or null
999 public String[] getGroups()
1002 if (featureGroups != null)
1004 String[] gps = new String[featureGroups.size()];
1005 Enumeration gn = featureGroups.keys();
1007 while (gn.hasMoreElements())
1009 gps[i++] = (String) gn.nextElement();
1017 * get visible or invisible groups
1020 * true to return visible groups, false to return hidden ones.
1021 * @return list of groups
1023 public String[] getGroups(boolean visible)
1026 if (featureGroups != null)
1028 Vector gp = new Vector();
1030 Enumeration gn = featureGroups.keys();
1031 while (gn.hasMoreElements())
1033 String nm = (String) gn.nextElement();
1034 Boolean state = (Boolean) featureGroups.get(nm);
1035 if (state.booleanValue() == visible)
1040 String[] gps = new String[gp.size()];
1044 while (gn.hasMoreElements())
1046 gps[i++] = (String) gn.nextElement();
1054 * set all feature groups in toset to be visible or invisible
1059 * the state of the named groups to set
1061 public void setGroupState(String[] toset, boolean visible)
1064 if (toset != null && toset.length > 0 && featureGroups != null)
1066 boolean rdrw = false;
1067 for (int i = 0; i < toset.length; i++)
1069 Object st = featureGroups.get(toset[i]);
1070 featureGroups.put(toset[i], new Boolean(visible));
1073 rdrw = rdrw || (visible != ((Boolean) st).booleanValue());
1078 if (this.av != null)
1079 if (this.av.featureSettings != null)
1081 av.featureSettings.rebuildGroups();
1082 this.av.featureSettings.resetTable(true);
1090 av.alignmentChanged(null);
1096 ArrayList<String> hiddenGroups = new ArrayList<String>();
1099 * analyse alignment for groups and hash tables (used to be embedded in
1100 * FeatureSettings.setTableData)
1102 * @return true if features are on the alignment
1104 public boolean buildGroupHash()
1106 boolean alignmentHasFeatures = false;
1107 if (featureGroups == null)
1109 featureGroups = new Hashtable();
1111 hiddenGroups = new ArrayList<String>();
1112 hiddenGroups.addAll(featureGroups.keySet());
1113 ArrayList allFeatures = new ArrayList();
1114 ArrayList allGroups = new ArrayList();
1115 SequenceFeature[] tmpfeatures;
1117 AlignmentI alignment = av.getAlignment();
1118 for (int i = 0; i < alignment.getHeight(); i++)
1120 if (alignment.getSequenceAt(i).getSequenceFeatures() == null)
1125 alignmentHasFeatures = true;
1127 tmpfeatures = alignment.getSequenceAt(i).getSequenceFeatures();
1129 while (index < tmpfeatures.length)
1131 if (tmpfeatures[index].getFeatureGroup() != null)
1133 group = tmpfeatures[index].featureGroup;
1134 // Remove group from the hiddenGroup list
1135 hiddenGroups.remove(group);
1136 if (!allGroups.contains(group))
1138 allGroups.add(group);
1140 boolean visible = true;
1141 if (featureGroups.containsKey(group))
1143 visible = ((Boolean) featureGroups.get(group)).booleanValue();
1147 featureGroups.put(group, new Boolean(visible));
1152 if (!allFeatures.contains(tmpfeatures[index].getType()))
1154 allFeatures.add(tmpfeatures[index].getType());
1160 return alignmentHasFeatures;
1164 * rebuild the featuresDisplayed and renderorder list based on the
1165 * featureGroups hash and any existing display state and force a repaint if
1168 * @return true if alignment has visible features
1170 public boolean buildFeatureHash()
1172 boolean alignmentHasFeatures = false;
1173 if (featureGroups == null)
1175 alignmentHasFeatures = buildGroupHash();
1177 if (!alignmentHasFeatures)
1179 Hashtable fdisp = av.featuresDisplayed;
1180 Vector allFeatures = new Vector();
1181 SequenceFeature[] tmpfeatures;
1183 AlignmentI alignment = av.getAlignment();
1184 for (int i = 0; i < alignment.getHeight(); i++)
1186 if (alignment.getSequenceAt(i).getSequenceFeatures() == null)
1191 alignmentHasFeatures = true;
1193 tmpfeatures = alignment.getSequenceAt(i).getSequenceFeatures();
1195 while (index < tmpfeatures.length)
1197 boolean visible = true;
1198 if (tmpfeatures[index].getFeatureGroup() != null)
1200 group = tmpfeatures[index].featureGroup;
1201 if (featureGroups.containsKey(group))
1203 visible = ((Boolean) featureGroups.get(group)).booleanValue();
1207 if (visible && !allFeatures.contains(tmpfeatures[index].getType()))
1209 allFeatures.addElement(tmpfeatures[index].getType());
1214 if (allFeatures.size() > 0)
1216 String[] neworder = new String[allFeatures.size()];
1217 int p = neworder.length - 1;
1218 for (int i = renderOrder.length - 1; i >= 0; i--)
1220 if (allFeatures.contains(renderOrder[i]))
1222 neworder[p--] = renderOrder[i];
1223 allFeatures.removeElement(renderOrder[i]);
1227 av.featuresDisplayed.remove(renderOrder[i]);
1230 for (int i = allFeatures.size() - 1; i > 0; i++)
1232 Object e = allFeatures.elementAt(i);
1235 neworder[p--] = (String) e;
1236 av.featuresDisplayed.put(e, getColour((String) e));
1239 renderOrder = neworder;
1243 return alignmentHasFeatures;
1248 * @return the displayed feature type as an array of strings
1250 protected String[] getDisplayedFeatureTypes()
1252 String[] typ = null;
1253 synchronized (renderOrder)
1255 typ = new String[renderOrder.length];
1256 System.arraycopy(renderOrder, 0, typ, 0, typ.length);
1257 for (int i = 0; i < typ.length; i++)
1259 if (av.featuresDisplayed.get(typ[i]) == null)
1269 class TransparencySetter
1271 void setTransparency(Graphics g, float value)
1273 Graphics2D g2 = (Graphics2D) g;
1274 g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,