+ else
+ {
+ iconOffset = 0;
+ }
+
+ if (row.autoCalculated && av.isCalculationInProgress(row))
+ {
+ y += charHeight;
+ usedFaded = true;
+ g.drawImage(fadedImage, 0, y - row.height, imgWidth, y, 0,
+ y - row.height, imgWidth, y, annotationPanel);
+ g.setColor(Color.black);
+ // g.drawString("Calculating "+aa[i].label+"....",20, y-row.height/2);
+
+ continue;
+ }
+
+ /*
+ * else if (annotationPanel.av.updatingConservation &&
+ * aa[i].label.equals("Conservation")) {
+ *
+ * y += charHeight; g.drawImage(annotationPanel.fadedImage, 0, y -
+ * row.height, annotationPanel.imgWidth, y, 0, y - row.height,
+ * annotationPanel.imgWidth, y, annotationPanel);
+ *
+ * g.setColor(Color.black); //
+ * g.drawString("Calculating Conservation.....",20, y-row.height/2);
+ *
+ * continue; } else if (annotationPanel.av.updatingConservation &&
+ * aa[i].label.equals("Quality")) {
+ *
+ * y += charHeight; g.drawImage(annotationPanel.fadedImage, 0, y -
+ * row.height, annotationPanel.imgWidth, y, 0, y - row.height,
+ * annotationPanel.imgWidth, y, annotationPanel);
+ * g.setColor(Color.black); // /
+ * g.drawString("Calculating Quality....",20, y-row.height/2);
+ *
+ * continue; }
+ */
+ // first pass sets up state for drawing continuation from left-hand
+ // column
+ // of startRes
+ x = (startRes == 0) ? 0 : -1;
+ while (x < endRes - startRes)
+ {
+ if (hasHiddenColumns)
+ {
+ column = hiddenColumns.visibleToAbsoluteColumn(startRes + x);
+ if (column > row_annotations.length - 1)
+ {
+ break;
+ }
+ }
+ else
+ {
+ column = startRes + x;
+ }
+
+ if ((row_annotations == null)
+ || (row_annotations.length <= column)
+ || (row_annotations[column] == null))
+ {
+ validRes = false;
+ }
+ else
+ {
+ validRes = true;
+ }
+ final String displayChar = validRes
+ ? row_annotations[column].displayCharacter
+ : null;
+ if (x > -1)
+ {
+ if (activeRow == i)
+ {
+ g.setColor(Color.red);
+
+ if (columnSelection != null)
+ {
+ if (columnSelection.contains(column))
+ {
+ g.fillRect(x * charWidth, y, charWidth, charHeight);
+ }
+ }
+ }
+ if (row.getInvalidStrucPos() > x)
+ {
+ g.setColor(Color.orange);
+ g.fillRect(x * charWidth, y, charWidth, charHeight);
+ }
+ else if (row.getInvalidStrucPos() == x)
+ {
+ g.setColor(Color.orange.darker());
+ g.fillRect(x * charWidth, y, charWidth, charHeight);
+ }
+ if (validCharWidth && validRes && displayChar != null
+ && (displayChar.length() > 0))
+ {
+ Graphics2D gg = ((Graphics2D) g);
+ float fmWidth = fm.charsWidth(displayChar.toCharArray(), 0,
+ displayChar.length());
+
+ /*
+ * shrink label width to fit in column, if that is
+ * both configured and necessary
+ */
+ boolean scaledToFit = false;
+ float fmScaling = 1f;
+ if (scaleColLabel && fmWidth > charWidth)
+ {
+ scaledToFit = true;
+ fmScaling = charWidth;
+ fmScaling /= fmWidth;
+ // and update the label's width to reflect the scaling.
+ fmWidth = charWidth;
+ }
+
+ charOffset = (int) ((charWidth - fmWidth) / 2f);
+
+ if (row_annotations[column].colour == null)
+ {
+ gg.setColor(Color.black);
+ }
+ else
+ {
+ gg.setColor(row_annotations[column].colour);
+ }
+
+ /*
+ * draw the label, unless it is the same secondary structure
+ * symbol (excluding RNA Helix) as the previous column
+ */
+ final int xPos = (x * charWidth) + charOffset;
+ final int yPos = y + iconOffset;
+
+ /*
+ * translate to drawing position _before_ applying any scaling
+ */
+ gg.translate(xPos, yPos);
+ if (scaledToFit)
+ {
+ /*
+ * use a scaling transform to make the label narrower
+ * (JalviewJS doesn't have Font.deriveFont(AffineTransform))
+ */
+ gg.transform(
+ AffineTransform.getScaleInstance(fmScaling, 1.0));
+ }
+ if (column == 0 || row.graph > 0)
+ {
+ gg.drawString(displayChar, 0, 0);
+ }
+ else if (row_annotations[column - 1] == null || (labelAllCols
+ || !displayChar.equals(
+ row_annotations[column - 1].displayCharacter)
+ || (displayChar.length() < 2
+ && row_annotations[column].secondaryStructure == ' ')))
+ {
+ gg.drawString(displayChar, 0, 0);
+ }
+ if (scaledToFit)
+ {
+ /*
+ * undo scaling before translating back
+ * (restoring saved transform does NOT work in JS PDFGraphics!)
+ */
+ gg.transform(AffineTransform
+ .getScaleInstance(1D / fmScaling, 1.0));
+ }
+ gg.translate(-xPos, -yPos);
+ }
+ }
+ if (row.hasIcons)
+ {
+ char ss = validRes ? row_annotations[column].secondaryStructure
+ : '-';
+
+ if (ss == '(')
+ {
+ // distinguish between forward/backward base-pairing
+ if (displayChar.indexOf(')') > -1)
+ {
+
+ ss = ')';
+
+ }
+ }
+ if (ss == '[')
+ {
+ if ((displayChar.indexOf(']') > -1))
+ {
+ ss = ']';
+
+ }
+ }
+ if (ss == '{')
+ {
+ // distinguish between forward/backward base-pairing
+ if (displayChar.indexOf('}') > -1)
+ {
+ ss = '}';
+
+ }
+ }
+ if (ss == '<')
+ {
+ // distinguish between forward/backward base-pairing
+ if (displayChar.indexOf('<') > -1)
+ {
+ ss = '>';