X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FFeatureRenderer.java;h=0478a766625598d98b441ae857dc9f6a4746e5c1;hb=b2f9a8d7bce642ff4011bc6d49e02bb0569fbb11;hp=50bb6653530f3b9386109de967d60c4b70787d32;hpb=d423f22792e47dbc800ae220a58677f988971d06;p=jalview.git diff --git a/src/jalview/appletgui/FeatureRenderer.java b/src/jalview/appletgui/FeatureRenderer.java old mode 100755 new mode 100644 index 50bb665..0478a76 --- a/src/jalview/appletgui/FeatureRenderer.java +++ b/src/jalview/appletgui/FeatureRenderer.java @@ -1,19 +1,20 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5) - * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.1) + * Copyright (C) 2014 The Jalview Authors * * This file is part of Jalview. * * Jalview is free software: you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - * + * * Jalview is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. */ package jalview.appletgui; @@ -23,10 +24,10 @@ import java.awt.*; import java.awt.event.*; -import jalview.appletgui.FeatureSettings.MyCheckbox; import jalview.datamodel.*; import jalview.schemes.AnnotationColourGradient; import jalview.schemes.GraduatedColor; +import jalview.util.MessageManager; /** * DOCUMENT ME! @@ -34,7 +35,7 @@ import jalview.schemes.GraduatedColor; * @author $author$ * @version $Revision$ */ -public class FeatureRenderer +public class FeatureRenderer implements jalview.api.FeatureRenderer { AlignViewport av; @@ -84,6 +85,25 @@ public class FeatureRenderer featureGroups = fr.featureGroups; featureColours = fr.featureColours; transparency = fr.transparency; + if (av != null && fr.av != null && fr.av != av) + { + if (fr.av.featuresDisplayed != null) + { + if (av.featuresDisplayed == null) + { + av.featuresDisplayed = new Hashtable(); + } + else + { + av.featuresDisplayed.clear(); + } + Enumeration en = fr.av.featuresDisplayed.keys(); + while (en.hasMoreElements()) + { + av.featuresDisplayed.put(en.nextElement(), Boolean.TRUE); + } + } + } } static String lastFeatureAdded; @@ -176,7 +196,7 @@ public class FeatureRenderer g.setColor(Color.black); Font f = new Font("Verdana", Font.PLAIN, 10); g.setFont(f); - g.drawString("Label", 0, 0); + g.drawString(MessageManager.getString("label.label"), 0, 0); } else { @@ -346,7 +366,7 @@ public class FeatureRenderer } else { - dialog.ok.setLabel("Amend"); + dialog.ok.setLabel(MessageManager.getString("label.amend")); dialog.buttonPanel.add(deleteButton, 1); deleteButton.addActionListener(new ActionListener() { @@ -661,16 +681,16 @@ public class FeatureRenderer else if (sequenceFeatures[sfindex].type.equals("disulfide bond")) { - renderFeature(g, seq, seq - .findIndex(sequenceFeatures[sfindex].begin) - 1, seq - .findIndex(sequenceFeatures[sfindex].begin) - 1, + renderFeature(g, seq, + seq.findIndex(sequenceFeatures[sfindex].begin) - 1, + seq.findIndex(sequenceFeatures[sfindex].begin) - 1, getColour(sequenceFeatures[sfindex]) // new Color(((Integer) av.featuresDisplayed // .get(sequenceFeatures[sfindex].type)).intValue()) , start, end, y1); - renderFeature(g, seq, seq - .findIndex(sequenceFeatures[sfindex].end) - 1, seq - .findIndex(sequenceFeatures[sfindex].end) - 1, + renderFeature(g, seq, + seq.findIndex(sequenceFeatures[sfindex].end) - 1, + seq.findIndex(sequenceFeatures[sfindex].end) - 1, getColour(sequenceFeatures[sfindex]) // new Color(((Integer) av.featuresDisplayed // .get(sequenceFeatures[sfindex].type)).intValue()) @@ -681,9 +701,9 @@ public class FeatureRenderer { if (showFeature(sequenceFeatures[sfindex])) { - renderFeature(g, seq, seq - .findIndex(sequenceFeatures[sfindex].begin) - 1, seq - .findIndex(sequenceFeatures[sfindex].end) - 1, + renderFeature(g, seq, + seq.findIndex(sequenceFeatures[sfindex].begin) - 1, + seq.findIndex(sequenceFeatures[sfindex].end) - 1, getColour(sequenceFeatures[sfindex]), start, end, y1); } } @@ -748,6 +768,20 @@ public class FeatureRenderer Hashtable minmax = null; + /** + * Called when alignment in associated view has new/modified features to + * discover and display. + * + */ + public void featuresAdded() + { + lastSeq = null; + findAllFeatures(); + } + + /** + * find all features on the alignment + */ void findAllFeatures() { jalview.schemes.UserColourScheme ucs = new jalview.schemes.UserColourScheme(); @@ -755,10 +789,10 @@ public class FeatureRenderer av.featuresDisplayed = new Hashtable(); Vector allfeatures = new Vector(); minmax = new Hashtable(); - - for (int i = 0; i < av.alignment.getHeight(); i++) + AlignmentI alignment = av.getAlignment(); + for (int i = 0; i < alignment.getHeight(); i++) { - SequenceFeature[] features = av.alignment.getSequenceAt(i) + SequenceFeature[] features = alignment.getSequenceAt(i) .getSequenceFeatures(); if (features == null) @@ -778,8 +812,8 @@ public class FeatureRenderer { if (getColour(features[index].getType()) == null) { - featureColours.put(features[index].getType(), ucs - .createColourFromName(features[index].getType())); + featureColours.put(features[index].getType(), + ucs.createColourFromName(features[index].getType())); } av.featuresDisplayed.put(features[index].getType(), new Integer( @@ -1033,9 +1067,9 @@ public class FeatureRenderer for (int i = 0; i < toset.length; i++) { Object st = featureGroups.get(toset[i]); + featureGroups.put(toset[i], new Boolean(visible)); if (st != null) { - featureGroups.put(toset[i], new Boolean(visible)); rdrw = rdrw || (visible != ((Boolean) st).booleanValue()); } } @@ -1059,6 +1093,8 @@ public class FeatureRenderer } } + ArrayList hiddenGroups = new ArrayList(); + /** * analyse alignment for groups and hash tables (used to be embedded in * FeatureSettings.setTableData) @@ -1072,29 +1108,34 @@ public class FeatureRenderer { featureGroups = new Hashtable(); } - Vector allFeatures = new Vector(); - Vector allGroups = new Vector(); + hiddenGroups = new ArrayList(); + hiddenGroups.addAll(featureGroups.keySet()); + ArrayList allFeatures = new ArrayList(); + ArrayList allGroups = new ArrayList(); SequenceFeature[] tmpfeatures; String group; - for (int i = 0; i < av.alignment.getHeight(); i++) + AlignmentI alignment = av.getAlignment(); + for (int i = 0; i < alignment.getHeight(); i++) { - if (av.alignment.getSequenceAt(i).getSequenceFeatures() == null) + if (alignment.getSequenceAt(i).getSequenceFeatures() == null) { continue; } alignmentHasFeatures = true; - tmpfeatures = av.alignment.getSequenceAt(i).getSequenceFeatures(); + tmpfeatures = alignment.getSequenceAt(i).getSequenceFeatures(); int index = 0; while (index < tmpfeatures.length) { if (tmpfeatures[index].getFeatureGroup() != null) { group = tmpfeatures[index].featureGroup; + // Remove group from the hiddenGroup list + hiddenGroups.remove(group); if (!allGroups.contains(group)) { - allGroups.addElement(group); + allGroups.add(group); boolean visible = true; if (featureGroups.containsKey(group)) @@ -1110,7 +1151,7 @@ public class FeatureRenderer if (!allFeatures.contains(tmpfeatures[index].getType())) { - allFeatures.addElement(tmpfeatures[index].getType()); + allFeatures.add(tmpfeatures[index].getType()); } index++; } @@ -1139,16 +1180,17 @@ public class FeatureRenderer Vector allFeatures = new Vector(); SequenceFeature[] tmpfeatures; String group; - for (int i = 0; i < av.alignment.getHeight(); i++) + AlignmentI alignment = av.getAlignment(); + for (int i = 0; i < alignment.getHeight(); i++) { - if (av.alignment.getSequenceAt(i).getSequenceFeatures() == null) + if (alignment.getSequenceAt(i).getSequenceFeatures() == null) { continue; } alignmentHasFeatures = true; - tmpfeatures = av.alignment.getSequenceAt(i).getSequenceFeatures(); + tmpfeatures = alignment.getSequenceAt(i).getSequenceFeatures(); int index = 0; while (index < tmpfeatures.length) {