| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.renderer; |
| 22 |
|
|
| 23 |
|
import java.awt.Color; |
| 24 |
|
import java.awt.Graphics; |
| 25 |
|
|
| 26 |
|
import jalview.api.AlignViewportI; |
| 27 |
|
import jalview.datamodel.AlignmentAnnotation; |
| 28 |
|
import jalview.datamodel.Annotation; |
| 29 |
|
import jalview.datamodel.ColumnSelection; |
| 30 |
|
import jalview.datamodel.ContactListI; |
| 31 |
|
import jalview.datamodel.ContactMatrixI; |
| 32 |
|
import jalview.datamodel.ContactRange; |
| 33 |
|
import jalview.datamodel.HiddenColumns; |
| 34 |
|
import jalview.renderer.api.AnnotationRowRendererI; |
| 35 |
|
|
| 36 |
|
|
| 37 |
|
@author |
| 38 |
|
|
| 39 |
|
|
| |
|
| 69.4% |
Uncovered Elements: 30 (98) |
Complexity: 27 |
Complexity Density: 0.46 |
|
| 40 |
|
public abstract class ContactMapRenderer implements AnnotationRowRendererI |
| 41 |
|
{ |
| 42 |
|
|
| 43 |
|
|
| 44 |
|
|
| 45 |
|
@author |
| 46 |
|
|
| 47 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.14 |
|
| 48 |
|
public class Shading |
| 49 |
|
{ |
| 50 |
|
|
| 51 |
|
|
| 52 |
|
|
| 53 |
|
Color no_data; |
| 54 |
|
|
| 55 |
|
|
| 56 |
|
|
| 57 |
|
|
| 58 |
|
Color hidden; |
| 59 |
|
|
| 60 |
|
|
| 61 |
|
|
| 62 |
|
|
| 63 |
|
Color maxColor, minColor; |
| 64 |
|
|
| 65 |
|
|
| 66 |
|
|
| 67 |
|
|
| 68 |
|
Color selMinColor, selMaxColor; |
| 69 |
|
|
| 70 |
|
|
| 71 |
|
|
| 72 |
|
@param |
| 73 |
|
|
| 74 |
|
@param |
| 75 |
|
|
| 76 |
|
@param |
| 77 |
|
|
| 78 |
|
@param |
| 79 |
|
|
| 80 |
|
@param |
| 81 |
|
|
| 82 |
|
@param |
| 83 |
|
|
| 84 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
| 85 |
150 |
public Shading(Color no_data, Color hidden, Color maxColor,... |
| 86 |
|
Color minColor, Color selMinColor, Color selMaxColor) |
| 87 |
|
{ |
| 88 |
150 |
super(); |
| 89 |
150 |
this.no_data = no_data; |
| 90 |
150 |
this.hidden = hidden; |
| 91 |
150 |
this.maxColor = maxColor; |
| 92 |
150 |
this.minColor = minColor; |
| 93 |
150 |
this.selMinColor = selMinColor; |
| 94 |
150 |
this.selMaxColor = selMaxColor; |
| 95 |
|
} |
| 96 |
|
|
| 97 |
|
} |
| 98 |
|
|
| 99 |
|
final Shading shade; |
| 100 |
|
|
| 101 |
|
|
| 102 |
|
|
| 103 |
|
|
| 104 |
|
@return |
| 105 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 106 |
150 |
public static ContactMapRenderer newPAERenderer()... |
| 107 |
|
{ |
| 108 |
150 |
return new ContactMapRenderer() |
| 109 |
|
{ |
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 110 |
150 |
@Override... |
| 111 |
|
public Shading getShade() |
| 112 |
|
{ |
| 113 |
150 |
return new Shading(Color.pink, Color.red, |
| 114 |
|
|
| 115 |
|
new Color(247, 252, 245), new Color(0, 68, 28), |
| 116 |
|
new Color(28, 0, 68), new Color(245, 247, 252)); |
| 117 |
|
} |
| 118 |
|
}; |
| 119 |
|
} |
| 120 |
|
|
| 121 |
|
|
| 122 |
|
|
| 123 |
|
@return |
| 124 |
|
|
| 125 |
|
public abstract Shading getShade(); |
| 126 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 127 |
150 |
public ContactMapRenderer()... |
| 128 |
|
{ |
| 129 |
150 |
this.shade = getShade(); |
| 130 |
|
} |
| 131 |
|
|
| |
|
| 67.5% |
Uncovered Elements: 27 (83) |
Complexity: 21 |
Complexity Density: 0.41 |
|
| 132 |
150 |
@Override... |
| 133 |
|
public void renderRow(Graphics g, int charWidth, int charHeight, |
| 134 |
|
boolean hasHiddenColumns, AlignViewportI viewport, |
| 135 |
|
HiddenColumns hiddenColumns, ColumnSelection columnSelection, |
| 136 |
|
AlignmentAnnotation _aa, Annotation[] aa_annotations, int sRes, |
| 137 |
|
int eRes, float min, float max, int y) |
| 138 |
|
{ |
| 139 |
150 |
if (sRes > aa_annotations.length) |
| 140 |
|
{ |
| 141 |
0 |
return; |
| 142 |
|
} |
| 143 |
150 |
eRes = Math.min(eRes, aa_annotations.length); |
| 144 |
|
|
| 145 |
150 |
int x = 0, topY = y; |
| 146 |
|
|
| 147 |
|
|
| 148 |
|
|
| 149 |
|
|
| 150 |
|
|
| 151 |
|
|
| 152 |
150 |
boolean showGroups = _aa.isShowGroupsForContactMatrix(); |
| 153 |
150 |
int column; |
| 154 |
150 |
int aaMax = aa_annotations.length - 1; |
| 155 |
150 |
ContactMatrixI cm = viewport.getContactMatrix(_aa); |
| 156 |
150 |
if (cm == null) |
| 157 |
|
{ |
| 158 |
0 |
return; |
| 159 |
|
} |
| 160 |
8966 |
while (x < eRes - sRes) |
| 161 |
|
{ |
| 162 |
8816 |
column = sRes + x; |
| 163 |
8816 |
if (hasHiddenColumns) |
| 164 |
|
{ |
| 165 |
0 |
column = hiddenColumns.visibleToAbsoluteColumn(column); |
| 166 |
|
} |
| 167 |
|
|
| 168 |
8816 |
boolean colsel = false; |
| 169 |
8816 |
if (columnSelection != null) |
| 170 |
|
{ |
| 171 |
8816 |
colsel = columnSelection.contains(column); |
| 172 |
|
} |
| 173 |
|
|
| 174 |
8816 |
if (column > aaMax) |
| 175 |
|
{ |
| 176 |
0 |
break; |
| 177 |
|
} |
| 178 |
|
|
| 179 |
8816 |
if (aa_annotations[column] == null) |
| 180 |
|
{ |
| 181 |
4329 |
x++; |
| 182 |
4329 |
continue; |
| 183 |
|
} |
| 184 |
4487 |
ContactListI contacts = viewport.getContactList(_aa, column); |
| 185 |
4487 |
if (contacts == null) |
| 186 |
|
{ |
| 187 |
0 |
x++; |
| 188 |
0 |
continue; |
| 189 |
|
} |
| 190 |
|
|
| 191 |
4487 |
Color gpcol = (cm == null) ? Color.white |
| 192 |
|
: contacts.getColourForGroup(); |
| 193 |
|
|
| 194 |
|
|
| 195 |
4487 |
boolean maskHiddenCols = false; |
| 196 |
|
|
| 197 |
|
|
| 198 |
|
|
| 199 |
|
|
| 200 |
|
|
| 201 |
|
|
| 202 |
|
|
| 203 |
|
|
| 204 |
4487 |
final ContactGeometry cgeom = new ContactGeometry(contacts, |
| 205 |
|
_aa.graphHeight); |
| 206 |
|
|
| 207 |
4487 |
for (int ht = 0, botY = topY |
| 208 |
183951 |
- _aa.height; ht < _aa.graphHeight; ht += cgeom.pixels_step) |
| 209 |
|
{ |
| 210 |
179474 |
ContactGeometry.contactInterval ci = cgeom.mapFor(ht); |
| 211 |
|
|
| 212 |
|
|
| 213 |
|
|
| 214 |
|
|
| 215 |
179417 |
Color col; |
| 216 |
179424 |
boolean rowsel = false; |
| 217 |
179461 |
boolean containsHidden = false; |
| 218 |
179471 |
if (columnSelection != null) |
| 219 |
|
{ |
| 220 |
179473 |
rowsel = cgeom.intersects(ci, columnSelection, hiddenColumns, |
| 221 |
|
maskHiddenCols); |
| 222 |
|
} |
| 223 |
|
|
| 224 |
179458 |
if (colsel || rowsel) |
| 225 |
|
{ |
| 226 |
|
|
| 227 |
0 |
col = getSelectedColorForRange(min, max, contacts, ci.cStart, |
| 228 |
|
ci.cEnd); |
| 229 |
0 |
if (colsel && rowsel) |
| 230 |
|
{ |
| 231 |
0 |
col = new Color(col.getBlue(), col.getGreen(), col.getRed()); |
| 232 |
|
} |
| 233 |
|
else |
| 234 |
|
{ |
| 235 |
0 |
col = new Color(col.getBlue(), col.getBlue(), col.getBlue()); |
| 236 |
|
} |
| 237 |
|
} |
| 238 |
|
else |
| 239 |
|
{ |
| 240 |
179460 |
col = getColorForRange(min, max, contacts, ci.cStart, ci.cEnd); |
| 241 |
|
} |
| 242 |
179451 |
if (containsHidden) |
| 243 |
|
{ |
| 244 |
0 |
col = shade.hidden; |
| 245 |
|
} |
| 246 |
179465 |
if (showGroups && gpcol != null && gpcol != Color.white) |
| 247 |
|
{ |
| 248 |
|
|
| 249 |
0 |
col = new Color((int) ((col.getRed() + gpcol.getRed()) / 2f), |
| 250 |
|
(int) ((col.getGreen() + gpcol.getGreen()) / 2f), |
| 251 |
|
(int) ((col.getBlue() + gpcol.getBlue()) / 2f)); |
| 252 |
|
} |
| 253 |
179473 |
g.setColor(col); |
| 254 |
179465 |
if (cgeom.pixels_step > 1) |
| 255 |
|
{ |
| 256 |
0 |
g.fillRect(x * charWidth, botY + ht, charWidth, |
| 257 |
|
cgeom.pixels_step); |
| 258 |
|
} |
| 259 |
|
else |
| 260 |
|
{ |
| 261 |
179471 |
g.drawLine(x * charWidth, botY + ht, (x + 1) * charWidth, |
| 262 |
|
botY + ht); |
| 263 |
|
} |
| 264 |
|
} |
| 265 |
4487 |
x++; |
| 266 |
|
} |
| 267 |
|
|
| 268 |
|
} |
| 269 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 270 |
179440 |
Color shadeFor(float min, float max, float value)... |
| 271 |
|
{ |
| 272 |
179440 |
return jalview.util.ColorUtils.getGraduatedColour(value, 0, |
| 273 |
|
shade.minColor, max, shade.maxColor); |
| 274 |
|
} |
| 275 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 276 |
179463 |
public Color getColorForRange(float min, float max, ContactListI cl,... |
| 277 |
|
int i, int j) |
| 278 |
|
{ |
| 279 |
179458 |
ContactRange cr = cl.getRangeFor(i, j); |
| 280 |
|
|
| 281 |
179444 |
return shadeFor(min, max, (float) cr.getMean()); |
| 282 |
|
} |
| 283 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 284 |
0 |
public Color getSelectedColorForRange(float min, float max,... |
| 285 |
|
ContactListI cl, int i, int j) |
| 286 |
|
{ |
| 287 |
0 |
ContactRange cr = cl.getRangeFor(i, j); |
| 288 |
|
|
| 289 |
0 |
return jalview.util.ColorUtils.getGraduatedColour((float) cr.getMin(), |
| 290 |
|
0, shade.selMinColor, max, shade.selMaxColor); |
| 291 |
|
} |
| 292 |
|
|
| 293 |
|
} |