X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignmentPanel.java;h=26b470a3d546e4162debb1c4114a63841dad4217;hb=9be2898dd1635c87539a90de321975f043d005f3;hp=02330a58e5b492cc99630abb98539d6ef7152d1e;hpb=8e67558df4403377d98e3efb232a10bf72fbcdbf;p=jalview.git diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index 02330a5..26b470a 100755 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -11,6 +11,7 @@ import java.io.*; import java.awt.image.*; import org.jibble.epsgraphics.*; import javax.imageio.*; +import javax.swing.*; @@ -72,32 +73,13 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene av.setSelectionGroup(null); repaint(); break; - case KeyEvent.VK_X: - if(evt.isControlDown()) - alignFrame.cut_actionPerformed(null); - break; - case KeyEvent.VK_C: - if(evt.isControlDown()) - alignFrame.copy_actionPerformed(null); - break; - case KeyEvent.VK_V: - if(evt.isControlDown()) - alignFrame.paste(true); - break; - case KeyEvent.VK_A: - if(evt.isControlDown()) - alignFrame.selectAllSequenceMenuItem_actionPerformed(null); - break; + case KeyEvent.VK_DOWN: alignFrame.moveSelectedSequences(false); break; case KeyEvent.VK_UP: alignFrame.moveSelectedSequences(true); break; - case KeyEvent.VK_F: - if(evt.isControlDown()) - alignFrame.findMenuItem_actionPerformed(null); - break; } } }); @@ -107,6 +89,11 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene { // set idCanvas bufferedImage to null // to prevent drawing old image + FontMetrics fm = getFontMetrics(av.getFont()); + + scalePanelHolder.setPreferredSize(new Dimension(10, av.charHeight+fm.getDescent())); + idSpaceFillerPanel1.setPreferredSize(new Dimension(10, av.charHeight+fm.getDescent())); + idPanel.idCanvas.gg = null; annotationPanel.adjustPanelHeight(); Dimension d = calculateIdWidth(); @@ -285,6 +272,8 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene public void setScrollValues(int x, int y) { + av.setEndRes(x + seqPanel.seqCanvas.getWidth()/av.getCharWidth()-1); + hextent = seqPanel.seqCanvas.getWidth()/av.charWidth; vextent = seqPanel.seqCanvas.getHeight()/av.charHeight; @@ -308,6 +297,8 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene hscroll.setValues(x,hextent,0,av.getAlignment().getWidth()); vscroll.setValues(y,vextent,0,av.getAlignment().getHeight() ); + + } @@ -339,7 +330,6 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene } } - if(overviewPanel!=null) overviewPanel.setBoxPosition(); @@ -376,8 +366,6 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene } else { - if (overviewPanel != null) - overviewPanel.updateOverviewImage(); setScrollValues(av.getStartRes(), av.getStartSeq()); } @@ -401,149 +389,159 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene public int printUnwrapped(Graphics pg, int pwidth, int pheight, int pi) throws PrinterException { - int idWidth = calculateIdWidth().width + 4; + int idWidth = calculateIdWidth().width + 4; + FontMetrics fm = getFontMetrics(av.getFont()); + int scaleHeight = av.charHeight + fm.getDescent(); + pg.setColor(Color.white); + pg.fillRect(0, 0, pwidth, pheight); + pg.setFont(av.getFont()); - pg.setColor(Color.white); - pg.fillRect(0,0,pwidth, pheight); - pg.setFont( av.getFont() ); + //////////////////////////////////// + /// How many sequences and residues can we fit on a printable page? + int totalRes = (pwidth - idWidth) / av.getCharWidth(); - //////////////////////////////////// - /// How many sequences and residues can we fit on a printable page? - int totalRes = (pwidth - idWidth)/av.getCharWidth(); - int totalSeq = (int)((pheight - 30)/av.getCharHeight())-1; - int pagesWide = av.getAlignment().getWidth() / totalRes +1; - int pagesHigh = av.getAlignment().getHeight() / totalSeq +1; + int totalSeq = (int) ( (pheight - scaleHeight) / av.getCharHeight()) - 1; - if (pi >= pagesWide*pagesHigh) - return Printable.NO_SUCH_PAGE; + int pagesWide = av.getAlignment().getWidth() / totalRes + 1; - ///////////////////////////// - /// Only print these sequences and residues on this page - int startRes, endRes, startSeq, endSeq; - startRes = (pi % pagesWide) * totalRes; - endRes = startRes + totalRes-1; - if(endRes>av.getAlignment().getWidth()) - endRes = av.getAlignment().getWidth(); + ///////////////////////////// + /// Only print these sequences and residues on this page + int startRes, endRes, startSeq, endSeq; + startRes = (pi % pagesWide) * totalRes; + endRes = startRes + totalRes - 1; + if (endRes > av.getAlignment().getWidth()-1) + endRes = av.getAlignment().getWidth()-1; - startSeq = (pi / pagesWide) * totalSeq; - endSeq = startSeq + totalSeq; - if(endSeq > av.getAlignment().getHeight()) - endSeq = av.getAlignment().getHeight(); + startSeq = (pi / pagesWide) * totalSeq; + endSeq = startSeq + totalSeq; + if (endSeq > av.getAlignment().getHeight()) + endSeq = av.getAlignment().getHeight(); + int pagesHigh = ( (av.alignment.getHeight() / totalSeq) + 1) * pheight; - //////////////// - //draw Scale - pg.translate(idWidth,0); - scalePanel.drawScale(pg, startRes, endRes, pwidth-idWidth); + if (av.showAnnotation) + pagesHigh += annotationPanel.getHeight(); - pg.translate(-idWidth, 30); - //////////////// - // Draw the ids - Color currentColor=null; - Color currentTextColor=null; - for(int i=startSeq; i= pagesWide * pagesHigh) + return Printable.NO_SUCH_PAGE; + + //draw Scale + pg.translate(idWidth, 0); + scalePanel.drawScale(pg, startRes, endRes, pwidth - idWidth, scaleHeight); + pg.translate( -idWidth, scaleHeight); + //////////////// + // Draw the ids + Color currentColor = null; + Color currentTextColor = null; + for (int i = startSeq; i < endSeq; i++) { - currentColor = av.getAlignment().getSequenceAt(i).getColor(); - currentTextColor = Color.black; - } + if (av.getSelectionGroup() != null && + av.getSelectionGroup().sequences. + contains(av.getAlignment().getSequenceAt(i))) + { + currentColor = Color.gray; + currentTextColor = Color.black; + } + else + { + currentColor = av.getAlignment().getSequenceAt(i).getColor(); + currentTextColor = Color.black; + } - pg.setColor(currentColor); - pg.fillRect(0, jalview.analysis.AlignmentUtil.getPixelHeight(startSeq, i, av.getCharHeight()), - idWidth, - av.getCharHeight()); + pg.setColor(currentColor); + pg.fillRect(0, + jalview.analysis.AlignmentUtil.getPixelHeight(startSeq, i, + av.getCharHeight()), + idWidth, + av.getCharHeight()); - pg.setColor(currentTextColor); + pg.setColor(currentTextColor); - String string = av.getAlignment().getSequenceAt(i).getName(); - if(av.getShowFullId()) - string = av.getAlignment().getSequenceAt(i).getDisplayId(); + String string = av.getAlignment().getSequenceAt(i).getName(); + if (av.getShowFullId()) + string = av.getAlignment().getSequenceAt(i).getDisplayId(); - pg.drawString(string, 0, jalview.analysis.AlignmentUtil.getPixelHeight - (startSeq, i, av.getCharHeight()) + av.getCharHeight() - (av.getCharHeight() / 5)); - } + pg.drawString(string, 0, jalview.analysis.AlignmentUtil.getPixelHeight + (startSeq, i, av.getCharHeight()) + av.getCharHeight() - + (av.getCharHeight() / 5)); + } - // draw main sequence panel - pg.translate(idWidth,0); - seqPanel.seqCanvas.drawPanel(pg,startRes,endRes,startSeq,endSeq,startRes,startSeq,0); + // draw main sequence panel + pg.translate(idWidth, 0); + seqPanel.seqCanvas.drawPanel(pg, startRes, endRes, startSeq, endSeq, + startRes, startSeq, 0); - if(av.getShowAnnotation()) + if (av.showAnnotation && endSeq == av.alignment.getHeight()) { - pg.translate(-idWidth,(endSeq-startSeq)*av.charHeight); - alabels.drawComponent((Graphics2D)pg); - pg.translate(idWidth,0); - annotationPanel.drawComponent((Graphics2D) pg, startRes, endRes+1); + pg.translate( -idWidth, (endSeq - startSeq) * av.charHeight); + alabels.drawComponent( (Graphics2D) pg); + pg.translate(idWidth, 0); + annotationPanel.drawComponent( (Graphics2D) pg, startRes, endRes+1); } - return Printable.PAGE_EXISTS; + return Printable.PAGE_EXISTS; + } public int printWrappedAlignment(Graphics pg, int pwidth, int pheight, int pi) throws PrinterException { + int idWidth = calculateIdWidth().width + 4; - int idWidth = calculateIdWidth().width+4; - - if( seqPanel.seqCanvas.getWidth() < pwidth-idWidth) - pwidth = seqPanel.seqCanvas.getWidth() + idWidth; + int resWidth = seqPanel.seqCanvas.getWrappedCanvasWidth(pwidth - idWidth); + int totalHeight = totalHeight = (av.alignment.getHeight() + 2) * + ( (av.alignment.getWidth() + / resWidth) + 1) * av.charHeight; - pg.setColor(Color.white); - pg.fillRect(0,0,pwidth, pheight); - pg.setFont( av.getFont() ); + pg.setColor(Color.white); + pg.fillRect(0, 0, pwidth, pheight); + pg.setFont(av.getFont()); - //////////////////////////////////// - /// How many sequences and residues can we fit on a printable page? - AlignmentI da = av.alignment; - int endy = da.getHeight(); - int chunkHeight = (da.getHeight() + 2)*av.charHeight; - int chunkWidth = (pwidth-idWidth)/av.charWidth; + //////////////// + // Draw the ids + pg.setColor(Color.black); - int noChunksOnPage = pheight / chunkHeight; - int totalChunks = da.getWidth() / chunkWidth; + pg.translate(0, -pi * pheight); - if ( pi*noChunksOnPage > totalChunks ) - return Printable.NO_SUCH_PAGE; + pg.setClip(0,pi*pheight,pwidth, pheight); - //////////////// - // Draw the ids - pg.setClip(0,0,pwidth, noChunksOnPage*chunkHeight); + int ypos = 2 * av.charHeight; + do + { + for (int i = 0; i < av.alignment.getHeight(); i++) + { + SequenceI s = av.alignment.getSequenceAt(i); + String string = s.getName(); + if (av.getShowFullId()) + string = s.getDisplayId(); - pg.setColor(Color.black); + pg.drawString(string, 0, + AlignmentUtil.getPixelHeight(0, i, av.charHeight) + + ypos + + av.charHeight - (av.charHeight / 5)); - int rowSize = av.getEndRes() - av.getStartRes(); - // Draw the rest of the panels + } - for(int ypos=2*av.charHeight, row=av.getEndRes(); row