X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FSeqCanvas.java;h=42424d9dc8a4a30b95cd7f93905ec5d9e0385ec5;hb=32ce9ddb7ce1a68add53dd81785ae428ca136a83;hp=1ed5e50c31b54b2157dc69ff26bd6eb7b9c7c2d7;hpb=32911e66025ea89c66180d501575cda4d8d4521e;p=jalview.git diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 1ed5e50..42424d9 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -24,6 +24,7 @@ import java.awt.*; import java.awt.image.*; import javax.swing.*; +import jalview.schemes.*; /** @@ -43,14 +44,10 @@ public class SeqCanvas extends JComponent AlignViewport av; boolean displaySearch = false; int[] searchResults = null; - int chunkHeight; - int chunkWidth; boolean fastPaint = false; int LABEL_WEST; int LABEL_EAST; - boolean isOverview = false; - /** * Creates a new SeqCanvas object. * @@ -66,6 +63,28 @@ public class SeqCanvas extends JComponent setBackground(Color.white); } + MCview.PDBCanvas pdbCanvas; + public SequenceRenderer getSequenceRenderer() + { + return sr; + } + + public FeatureRenderer getFeatureRenderer() + { + return fr; + } + + public void setPDBCanvas(MCview.PDBCanvas pc) + { + pdbCanvas = pc; + } + + public AlignViewport getViewport() + { + return av; + } + + /** * DOCUMENT ME! * @@ -260,18 +279,20 @@ public class SeqCanvas extends JComponent // Set this to false to force a full panel paint public void paintComponent(Graphics g) { + super.paintComponent(g); + sr.renderGaps(av.renderGaps); - if ((img != null) && - (fastPaint || (getWidth() != g.getClipBounds().width) || - (getHeight() != g.getClipBounds().height))) + if ( img != null && (fastPaint + || (getVisibleRect().width != g.getClipBounds().width) + || (getVisibleRect().height != g.getClipBounds().height))) { g.drawImage(img, 0, 0, this); fastPaint = false; - return; } + // this draws the whole of the alignment imgWidth = getWidth(); imgHeight = getHeight(); @@ -284,7 +305,6 @@ public class SeqCanvas extends JComponent return; } - img = new BufferedImage(imgWidth, imgHeight, BufferedImage.TYPE_INT_RGB); gg = (Graphics2D) img.getGraphics(); gg.setFont(av.getFont()); @@ -294,11 +314,6 @@ public class SeqCanvas extends JComponent gg.setColor(Color.white); gg.fillRect(0, 0, imgWidth, imgHeight); - chunkWidth = getWrappedCanvasWidth(getWidth()); - chunkHeight = (av.getAlignment().getHeight() + 2) * av.charHeight; - - av.setChunkHeight(chunkHeight); - av.setChunkWidth(chunkWidth); if (av.getWrapAlignment()) { @@ -311,6 +326,12 @@ public class SeqCanvas extends JComponent } g.drawImage(img, 0, 0, this); + + if (pdbCanvas != null) + { + pdbCanvas.updateSeqColours(); + } + } /** @@ -385,16 +406,25 @@ public class SeqCanvas extends JComponent LABEL_WEST = fm.stringWidth(getMask()); } + int hgap = av.charHeight; + if(av.scaleAboveWrapped) + hgap += av.charHeight; + int cWidth = (canvasWidth - LABEL_EAST - LABEL_WEST) / av.charWidth; - int cHeight = (av.getAlignment().getHeight() + 2) * av.charHeight; + int cHeight = av.getAlignment().getHeight() * av.charHeight; + + av.setWrappedWidth(cWidth); av.endRes = av.startRes + cWidth; + int endx = (startRes + cWidth) - 1; - int ypos = 2 * av.charHeight; + int ypos = hgap; + while ((ypos <= canvasHeight) && (startRes < av.alignment.getWidth())) { + g.setFont(av.getFont()); g.setColor(Color.black); if (av.scaleLeftWrapped) @@ -437,10 +467,23 @@ public class SeqCanvas extends JComponent drawPanel(g, startRes, endx, 0, al.getHeight(), startRes, 0, ypos); + + if(av.showAnnotation) + { + g.translate(0, cHeight + ypos + 3); + if(annotations==null) + annotations = new AnnotationPanel(av); + + annotations.drawComponent( (Graphics2D) g, startRes, endx + 1); + g.translate(0, -cHeight - ypos); + } g.setClip(clip); g.translate(-LABEL_WEST, 0); - ypos += cHeight; + ypos += cHeight+getAnnotationHeight()+hgap; + if(av.showAnnotation) + ypos -= 3; + startRes += cWidth; endx = (startRes + cWidth) - 1; @@ -451,6 +494,18 @@ public class SeqCanvas extends JComponent } } + AnnotationPanel annotations; + int getAnnotationHeight() + { + if(!av.showAnnotation) + return 0; + + if(annotations==null) + annotations = new AnnotationPanel(av); + + return annotations.adjustPanelHeight(); + } + /** * DOCUMENT ME! * @@ -463,29 +518,103 @@ public class SeqCanvas extends JComponent * @param starty DOCUMENT ME! * @param offset DOCUMENT ME! */ + + float aaRatio = 2f/3f; + public void increaseAARatio() + { + aaRatio += .025; + if(aaRatio>1) + aaRatio = 1; + + repaint(); + } + + public void decreaseAARation() + { + aaRatio -= .025; + if(aaRatio<0) + aaRatio = 0; + + repaint(); + } + + synchronized public void drawPanel(Graphics g1, int x1, int x2, int y1, int y2, int startx, int starty, int offset) { - Graphics2D g = (Graphics2D) g1; - g.setFont(av.getFont()); + Graphics2D g = (Graphics2D) g1; + g.setFont(av.getFont()); + + SequenceI nextSeq, dna = null; + int aaHeight = av.charHeight, dnaHeight = av.charHeight; + Font dnafont = null, aafont = av.getFont(); + + /* if (av.getShowTranslation()) + { + aaHeight = (int) (av.getCharHeight() * aaRatio); + dnaHeight = (int) (av.getCharHeight() * (1 - aaRatio)); + java.awt.geom.AffineTransform transform = new java.awt.geom.AffineTransform(); + transform.scale(1f / 3f, 1); + dnafont = new Font(av.getFont().getName(), av.getFont().getStyle(), + dnaHeight); + dnafont = dnafont.deriveFont(transform); + + aafont = new Font(av.getFont().getName(), av.getFont().getStyle(), + aaHeight); + transform = new java.awt.geom.AffineTransform(); + transform.scale(1 / aaRatio, 1); + aafont = aafont.deriveFont(transform); + } +*/ - SequenceI nextSeq; + ColourSchemeI cs = av.getGlobalColourScheme(); /// First draw the sequences ///////////////////////////// for (int i = y1; i < y2; i++) { nextSeq = av.alignment.getSequenceAt(i); + g.setFont(aafont); + /* if(av.getShowTranslation()) + { + dna = nextSeq; + StringBuffer sb = new StringBuffer(); + for(int r = 0; r 0)) + if ((group == null) && (av.alignment.getGroups().size() > 0)) { - group = (SequenceGroup) groups.elementAt(0); + group = (SequenceGroup) av.alignment.getGroups().elementAt(0); groupIndex = 0; } - - if (group != null && !isOverview) + if (group != null) { do { @@ -647,14 +774,14 @@ public class SeqCanvas extends JComponent groupIndex++; - if (groupIndex >= groups.size()) + if (groupIndex >= av.alignment.getGroups().size()) { break; } - group = (SequenceGroup) groups.elementAt(groupIndex); + group = (SequenceGroup) av.alignment.getGroups().elementAt(groupIndex); } - while (groupIndex < groups.size()); + while (groupIndex < av.alignment.getGroups().size()); } /// Highlight search Results once all sequences have been drawn