import jalview.datamodel.SequenceI;
import jalview.viewmodel.ViewportListenerI;
import jalview.viewmodel.ViewportRanges;
+import jalview.viewmodel.seqfeatures.IdColumn;
+import jalview.viewmodel.seqfeatures.IdColumns;
+import jalview.viewmodel.seqfeatures.IdColumns.ColumnCell;
/**
* DOCUMENT ME!
BufferedImage image;
-// Graphics2D gg;
+ // Graphics2D gg;
int imgHeight = 0;
this.av = av;
PaintRefresher.Register(this, av.getSequenceSetId());
av.getRanges().addPropertyChangeListener(this);
- }
+ }
/**
* DOCUMENT ME!
gg.translate(0, -transY);
gg.dispose();
-
+
fastPaint = true;
// Call repaint on alignment panel so that repaints from other alignment
{
g.setColor(Color.white);
g.fillRect(0, 0, getWidth(), getHeight());
-
+
if (fastPaint)
{
fastPaint = false;
g.drawImage(image, 0, 0, this);
-
+
return;
}
-
+
int oldHeight = imgHeight;
-
+
imgHeight = getHeight();
imgHeight -= (imgHeight % av.getCharHeight());
-
+
if (imgHeight < 1)
{
return;
}
-
+
if (oldHeight != imgHeight || image.getWidth(this) != getWidth())
{
- image = new BufferedImage(getWidth(), imgHeight,
- BufferedImage.TYPE_INT_RGB);
+ image = new BufferedImage(getWidth(), imgHeight,
+ BufferedImage.TYPE_INT_RGB);
}
-
+
Graphics2D gg = image.createGraphics();
-
+
// Fill in the background
gg.setColor(Color.white);
gg.fillRect(0, 0, getWidth(), imgHeight);
-
- drawIds(gg, av, av.getRanges().getStartSeq(), av.getRanges().getEndSeq(), searchResults);
+
+ drawIds(gg, av, av.getRanges().getStartSeq(),
+ av.getRanges().getEndSeq(), searchResults);
gg.dispose();
-
+
g.drawImage(image, 0, 0, this);
}
* @param endSeq
* @param selection
*/
- void drawIds(Graphics2D g, AlignViewport alignViewport, final int startSeq,
- final int endSeq, List<SequenceI> selection)
+ void drawIds(Graphics2D g, AlignViewport alignViewport,
+ final int startSeq, final int endSeq, List<SequenceI> selection)
{
Font font = alignViewport.getFont();
if (alignViewport.isSeqNameItalics())
{
- setIdfont(new Font(font.getName(), Font.ITALIC,
- font.getSize()));
+ setIdfont(new Font(font.getName(), Font.ITALIC, font.getSize()));
}
else
{
}
// Now draw the id strings
- int panelWidth = getWidth();
- int xPos = 0;
+ int fullPanelWidth = getWidth();
+
+ IdColumns id_cols = alignViewport.getIdColumns();
+ List<IdColumn> visible = id_cols.getVisible();
+ /**
+ * width of an idColumn
+ */
+ int colWid = 20;
+ int panelWidth = Math.max(fullPanelWidth / 2,
+ fullPanelWidth - (colWid * visible.size()));
// Now draw the id strings
for (int i = startSeq; i <= endSeq; i++)
{
+ int xPos = 0;
SequenceI sequence = alignViewport.getAlignment().getSequenceAt(i);
if (sequence == null)
{
continue;
}
-
if (hasHiddenRows || alignViewport.isDisplayReferenceSeq())
{
g.setFont(getHiddenFont(sequence, alignViewport));
+ fm = g.getFontMetrics();
}
// Selected sequence colours
g.setColor(currentColor);
int charHeight = alignViewport.getCharHeight();
- g.fillRect(0, (i - startSeq) * charHeight,
- getWidth(), charHeight);
+ g.fillRect(0, (i - startSeq) * charHeight, getWidth(), charHeight);
g.setColor(currentTextColor);
xPos = panelWidth - fm.stringWidth(string) - 4;
}
- g.drawString(string, xPos, (((i - startSeq) * charHeight) + charHeight)
- - (charHeight / 5));
+ g.drawString(string, xPos,
+ (((i - startSeq) * charHeight) + charHeight)
+ - (charHeight / 5));
+ if (visible != null && visible.size() > 0)
+ {
+ try
+ {
+ xPos = panelWidth + 2;
+ for (IdColumn col : visible)
+ {
+ ColumnCell col_cell = id_cols.getCellFor(sequence, col);
+ if (col_cell == null)
+ {
+ g.setColor(Color.gray);
+ g.fillRect(xPos + 1, (i - startSeq) * charHeight,
+ xPos + colWid - 3, charHeight);
+ }
+ else
+ {
+ g.setColor(col_cell.bg);
+ g.fillRect(xPos + 1, (i - startSeq) * charHeight,
+ xPos + colWid - 3, charHeight);
+ g.setColor(col_cell.fg);
+ g.drawString(col_cell.label, xPos,
+ (((i - startSeq) * charHeight) + charHeight)
+ - (charHeight / 5));
+ }
+ xPos += colWid;
+ g.setColor(currentTextColor);
+ }
+ } catch (Exception q)
+ {
+ }
+ }
if (hasHiddenRows && av.getShowHiddenMarkers())
{
drawMarker(g, alignViewport, i, startSeq, 0);
* @param starty
* @param yoffset
*/
- void drawMarker(Graphics2D g, AlignViewport alignViewport, int seqIndex, int starty, int yoffset)
+ void drawMarker(Graphics2D g, AlignViewport alignViewport, int seqIndex,
+ int starty, int yoffset)
{
SequenceI[] hseqs = alignViewport.getAlignment()
.getHiddenSequences().hiddenSequences;
/*
* vertices of the triangle, below or above hidden seqs
*/
- int[] xPoints = new int[]
- { getWidth() - charHeight,
+ int[] xPoints = new int[] { getWidth() - charHeight,
getWidth() - charHeight, getWidth() };
int yShift = seqIndex - starty;