package jalview.datamodel;
+import java.awt.Color;
import java.math.BigInteger;
import java.util.ArrayList;
+import java.util.BitSet;
+import java.util.HashMap;
import java.util.List;
import java.util.Spliterator;
import java.util.StringTokenizer;
{
return "Contact Matrix";
}
-
+ List<BitSet> groups=null;
+ @Override
+ public void updateGroups(List<BitSet> colGroups)
+ {
+ groups = colGroups;
+ colorMap=new HashMap<>();
+ }
+ @Override
+ public boolean hasGroups()
+ {
+ return groups!=null && groups.size()>0;
+ }
+ @Override
+ public List<BitSet> getGroups()
+ {
+ return groups;
+ }
+ @Override
+ public BitSet getGroupsFor(int column)
+ {
+ for (BitSet gp:groups) {
+ if (gp.get(column))
+ {
+ return gp;
+ }
+ }
+ return ContactMatrixI.super.getGroupsFor(column);
+ }
+ HashMap<BitSet,Color> colorMap = new HashMap<>();
+ @Override
+ public Color getColourForGroup(BitSet bs)
+ {
+ if (bs==null) {
+ return Color.white;
+ }
+ Color groupCol=colorMap.get(bs);
+ if (groupCol==null)
+ {
+ return Color.white;
+ }
+ return groupCol;
+ }
+ @Override
+ public void setColorForGroup(BitSet bs,Color color)
+ {
+ colorMap.put(bs,color);
+ }
public static String contactToFloatString(ContactMatrixI cm)
{
StringBuilder sb = new StringBuilder();
package jalview.datamodel;
+import java.awt.Color;
import java.util.Arrays;
import java.util.BitSet;
import java.util.List;
default double getCutHeight() {
return 0;
}
+
+ void updateGroups(List<BitSet> colGroups);
+
+ void setColorForGroup(BitSet bs, Color color);
+
+ default Color getColourForGroup(BitSet bs) { return Color.white;};
}
package jalview.datamodel;
+import java.awt.Color;
+import java.util.BitSet;
+import java.util.HashMap;
+import java.util.List;
+
/**
* Dummy contact matrix based on sequence distance
*
{
return width;
}
+ private List<BitSet> groups=null;
+ @Override
+ public void updateGroups(List<BitSet> colGroups)
+ {
+ groups = colGroups;
+ }
+ @Override
+ public boolean hasGroups()
+ {
+ return groups!=null;
+ }
+ @Override
+ public List<BitSet> getGroups()
+ {
+ return groups;
+ }
+
+ HashMap<BitSet,Color> colorMap = new HashMap<>();
+ @Override
+ public Color getColourForGroup(BitSet bs)
+ {
+ if (bs==null) {
+ return Color.white;
+ }
+ Color groupCol=colorMap.get(bs);
+ if (groupCol==null)
+ {
+ return Color.white;
+ }
+ return groupCol;
+ }
+ @Override
+ public void setColorForGroup(BitSet bs,Color color)
+ {
+ colorMap.put(bs,color);
+ }
}
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
+import java.util.ArrayList;
import java.util.BitSet;
+import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import jalview.analysis.Conservation;
import jalview.analysis.TreeModel;
import jalview.api.AlignViewportI;
+import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.BinaryNode;
import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.ContactMatrixI;
import jalview.datamodel.HiddenColumns;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceGroup;
void colourGroups(List<BinaryNode> groups)
{
AlignmentPanel[] aps = getAssociatedPanels();
+ List<BitSet> colGroups = new ArrayList<>();
+ Map<BitSet,Color> colors=new HashMap();
for (int i = 0; i < groups.size(); i++)
{
Color col = new Color((int) (Math.random() * 255),
if (!tp.isColumnWise()) {
createSeqGroupFor(aps, l, col);
} else {
- markColumnsFor(aps,l,col);
+ BitSet gp=createColumnGroupFor(l,col);
+
+ colGroups.add(gp);
+ colors.put(gp, col);
+ }
+ }
+ if (tp.isColumnWise())
+ {
+ AlignmentAnnotation aa = tp.getAssocAnnotation();
+ if (aa!=null) {
+ ContactMatrixI cm = av.getContactMatrix(aa);
+ if (cm!=null)
+ {
+ cm.updateGroups(colGroups);
+ for (BitSet gp:colors.keySet())
+ {
+ cm.setColorForGroup(gp, colors.get(gp));
+ }
+ }
}
}
}
return false;
}
+
+ private BitSet createColumnGroupFor(Vector<BinaryNode> l,
+ Color col)
+ {
+ BitSet gp=new BitSet();
+ for (BinaryNode bn:l)
+ {
+ int colm=-1;
+ if (bn.element()!=null && bn.element()instanceof Integer)
+ { colm = (Integer)bn.element();
+ } else {
+ // parse out from nodename
+ try {
+ colm = Integer.parseInt(bn.getName().substring(bn.getName().indexOf("c")+1));
+ } catch (Exception e)
+ {
+ continue;
+ }
+ }
+ gp.set(colm);
+ }
+ return gp;
+ }
private void markColumnsFor(AlignmentPanel[] aps, Vector<BinaryNode> l,
Color col)
import java.io.IOException;
import java.util.ArrayList;
+import java.util.BitSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import jalview.datamodel.Annotation;
import jalview.datamodel.ColumnSelection;
import jalview.datamodel.ContactListI;
+import jalview.datamodel.ContactMatrixI;
import jalview.datamodel.ContactRange;
import jalview.datamodel.HiddenColumns;
import jalview.renderer.api.AnnotationRowRendererI;
int column;
int aaMax = aa_annotations.length - 1;
+ ContactMatrixI cm = viewport.getContactMatrix(_aa);
while (x < eRes - sRes)
{
column = sRes + x;
x++;
continue;
}
+ Color gpcol = (cm==null) ? Color.white: cm.getColourForGroup(cm.getGroupsFor(column));
// feature still in development - highlight or omit regions hidden in
// the alignment - currently marks them as red rows
boolean maskHiddenCols = false;
{
col = shade.hidden;
}
+ if (gpcol!=null && gpcol!=Color.white) {
+ // todo - could overlay group as a transparent rectangle ?
+ col = new Color((int)(((float)(col.getRed()+gpcol.getRed()))/2f),
+ (int)(((float)(col.getGreen()+gpcol.getGreen()))/2f),
+ (int)(((float)(col.getBlue()+gpcol.getBlue()))/2f));
+ }
g.setColor(col);
+
if (cgeom.pixels_step > 1)
{
g.fillRect(x * charWidth, ht, charWidth, 1 + cgeom.pixels_step);
package jalview.ws.datamodel.alphafold;
+import java.awt.Color;
import java.util.ArrayList;
import java.util.BitSet;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
groups.add(gpset);
}
}
-
+ @Override
+ public void updateGroups(List<BitSet> colGroups)
+ {
+ if (colGroups!=null)
+ {
+ groups=colGroups;
+ }
+ }
@Override
public BitSet getGroupsFor(int column)
{
return ContactMatrixI.super.getGroupsFor(column);
}
+ HashMap<BitSet,Color> colorMap = new HashMap<>();
+ @Override
+ public Color getColourForGroup(BitSet bs)
+ {
+ if (bs==null) {
+ return Color.white;
+ }
+ Color groupCol=colorMap.get(bs);
+ if (groupCol==null)
+ {
+ return Color.white;
+ }
+ return groupCol;
+ }
+ @Override
+ public void setColorForGroup(BitSet bs,Color color)
+ {
+ colorMap.put(bs,color);
+ }
public void restoreGroups(List<BitSet> newgroups, String treeMethod,
String tree, double thresh2)
{