X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src2%2Ffr%2Forsay%2Flri%2Fvarna%2Fmodels%2FBaseList.java;fp=src2%2Ffr%2Forsay%2Flri%2Fvarna%2Fmodels%2FBaseList.java;h=0000000000000000000000000000000000000000;hb=d27359893c99db0e749a59d8a7ab73ea751da09e;hp=01ac0b1cee9f411ef6b2047fd68d9d6f8d24c772;hpb=9f55415c9f8005e9dcd8243453883ff853fd5b76;p=jalview.git diff --git a/src2/fr/orsay/lri/varna/models/BaseList.java b/src2/fr/orsay/lri/varna/models/BaseList.java deleted file mode 100644 index 01ac0b1..0000000 --- a/src2/fr/orsay/lri/varna/models/BaseList.java +++ /dev/null @@ -1,200 +0,0 @@ -package fr.orsay.lri.varna.models; - -import java.awt.Color; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; - -import fr.orsay.lri.varna.models.rna.ModeleBase; - -public class BaseList { - private HashSet _bases = new HashSet(); - private String _caption; - - public BaseList( BaseList b) - { - _caption = b._caption; - _bases = new HashSet(b._bases); - } - - - public BaseList( String caption) - { - _caption = caption; - } - - - public BaseList( String caption, ModeleBase mb) - { - this(caption); - addBase(mb); - } - - public boolean contains(ModeleBase mb) - { - return _bases.contains(mb); - } - - - public String getCaption() - { - return _caption; - } - - public void addBase(ModeleBase b) - { - _bases.add(b); - } - - public void removeBase(ModeleBase b) - { - _bases.remove(b); - } - - - public void addBases(Collection mbs) - { - _bases.addAll(mbs); - } - - public ArrayList getBases() - { - return new ArrayList(_bases); - } - - public void clear() - { - _bases.clear(); - } - - public static Color getAverageColor(ArrayList cols) - { - int r=0,g=0,b=0; - for (Color c : cols) - { - r += c.getRed(); - g += c.getGreen(); - b += c.getBlue(); - } - if (cols.size()>0) - { - r /= cols.size(); - g /= cols.size(); - b /= cols.size(); - } - return new Color(r,g,b); - } - - public Color getAverageOutlineColor() - { - ArrayList cols = new ArrayList(); - for (ModeleBase mb : _bases) - { cols.add(mb.getStyleBase().getBaseOutlineColor()); } - return getAverageColor(cols); - } - - public Color getAverageNameColor() - { - ArrayList cols = new ArrayList(); - for (ModeleBase mb : _bases) - { cols.add(mb.getStyleBase().getBaseNameColor()); } - return getAverageColor(cols); - } - - public Color getAverageNumberColor() - { - ArrayList cols = new ArrayList(); - for (ModeleBase mb : _bases) - { cols.add(mb.getStyleBase().getBaseNumberColor()); } - return getAverageColor(cols); - } - - public Color getAverageInnerColor() - { - ArrayList cols = new ArrayList(); - for (ModeleBase mb : _bases) - { cols.add(mb.getStyleBase().getBaseInnerColor()); } - return getAverageColor(cols); - } - - public String getNumbers() - { - String result = ""; - boolean first = true; - for (ModeleBase mb:_bases) - { - if (!first) - { result += ","; } - else - { first = false; } - result += "" + mb.getBaseNumber(); - } - result += ""; - return result; - } - - public String getContents() - { - String result = ""; - boolean first = true; - for (ModeleBase mb:_bases) - { - if (!first) - { result += ","; } - else - { first = false; } - result += "" + mb.getContent(); - } - result += ""; - return result; - } - - public ArrayList getIndices() - { - ArrayList indices = new ArrayList(); - for (ModeleBase mb : _bases) - { - indices.add(mb.getIndex()); - } - return indices; - } - - /** - * Returns, in a new BaseList, the intersection of the current BaseList and of the argument. - * @param mb The base list to be used for the intersection - * @return The intersection of the current base list and the argument. - */ - - public BaseList retainAll(BaseList mb) - { - HashSet cp = new HashSet(); - cp.addAll(_bases); - cp.retainAll(mb._bases); - BaseList result = new BaseList("TmpIntersection"); - result.addBases(cp); - return result; - } - - /** - * Returns, in a new BaseList, the list consisting of the current BaseList minus the list passed as argument. - * @param mb The base list to be subtracted from the current one - * @return The current base list minus the list passed as argument. - */ - - public BaseList removeAll(BaseList mb) - { - HashSet cp = new HashSet(); - cp.addAll(_bases); - cp.removeAll(mb._bases); - BaseList result = new BaseList("TmpMinus"); - result.addBases(cp); - return result; - } - - public int size() - { - return _bases.size(); - } - - -}