From e7139af89390be3dc16db40cfba05dca066507fb Mon Sep 17 00:00:00 2001 From: jprocter Date: Mon, 21 Apr 2008 17:19:03 +0000 Subject: [PATCH] centrecolumnlabels format menu item and parameter added to applet --- src/jalview/appletgui/AlignFrame.java | 23 +++++++++++++++++++++-- src/jalview/appletgui/AlignViewport.java | 6 ++++++ src/jalview/appletgui/AnnotationPanel.java | 15 ++++++++------- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index 5620a3e..530b9a0 100755 --- a/src/jalview/appletgui/AlignFrame.java +++ b/src/jalview/appletgui/AlignFrame.java @@ -97,6 +97,12 @@ public class AlignFrame wrapMenuItem_actionPerformed(); } } + param = applet.getParameter("centrecolumnlabels"); + if (param != null) + { + centreColumnLabelFlag.setState(true); + centreColumnLabelFlag_stateChanged(); + } try { @@ -545,11 +551,20 @@ public class AlignFrame else if (evt.getSource() == autoCalculate) { viewport.autocalculateConsensus = autoCalculate.getState(); + } else if (evt.getSource() == this.centreColumnLabelFlag) + { + centreColumnLabelFlag_stateChanged(); } - + alignPanel.paintAlignment(true); } + private void centreColumnLabelFlag_stateChanged() + { + viewport.centreColumnLabels = centreColumnLabelFlag.getState(); + this.alignPanel.annotationPanel.repaint(); + } + public void actionPerformed(ActionEvent evt) { Object source = evt.getSource(); @@ -2465,6 +2480,7 @@ public class AlignFrame MenuItem documentation = new MenuItem(); MenuItem about = new MenuItem(); CheckboxMenuItem seqLimits = new CheckboxMenuItem(); + CheckboxMenuItem centreColumnLabelFlag = new CheckboxMenuItem(); private void jbInit() throws Exception @@ -2632,7 +2648,9 @@ public class AlignFrame autoCalculate.addItemListener(this); inputText.setLabel("Input from textbox"); inputText.addActionListener(this); - + centreColumnLabelFlag.setLabel("Centre column labels"); + centreColumnLabelFlag.addItemListener(this); + helpMenu.setLabel("Help"); documentation.setLabel("Documentation"); documentation.addActionListener(this); @@ -2771,6 +2789,7 @@ public class AlignFrame formatMenu.add(viewTextMenuItem); formatMenu.add(colourTextMenuItem); formatMenu.add(renderGapsMenuItem); + formatMenu.add(centreColumnLabelFlag); selectMenu.add(findMenuItem); selectMenu.addSeparator(); selectMenu.add(selectAllSequenceMenuItem); diff --git a/src/jalview/appletgui/AlignViewport.java b/src/jalview/appletgui/AlignViewport.java index f543dd9..193c9b0 100755 --- a/src/jalview/appletgui/AlignViewport.java +++ b/src/jalview/appletgui/AlignViewport.java @@ -164,6 +164,7 @@ public class AlignViewport upperCasebold = true; } } + } @@ -1442,5 +1443,10 @@ public class AlignViewport sg.recalcConservation(); } } + boolean centreColumnLabels; + public boolean getCentreColumnLabels() + { + return centreColumnLabels; + } } diff --git a/src/jalview/appletgui/AnnotationPanel.java b/src/jalview/appletgui/AnnotationPanel.java index d4055a5..ec5fbd8 100755 --- a/src/jalview/appletgui/AnnotationPanel.java +++ b/src/jalview/appletgui/AnnotationPanel.java @@ -42,14 +42,13 @@ public class AnnotationPanel static String COLOUR = "Colour"; static Color HELIX_COLOUR = Color.red.darker(); static Color SHEET_COLOUR = Color.green.darker().darker(); - + Image image; Graphics gg; FontMetrics fm; int imgWidth = 0; boolean fastPaint = false; - public static int GRAPH_HEIGHT = 40; boolean MAC = false; @@ -57,7 +56,6 @@ public class AnnotationPanel public AnnotationPanel(AlignmentPanel ap) { MAC = new jalview.util.Platform().isAMac(); - this.ap = ap; av = ap.av; setLayout(null); @@ -648,10 +646,13 @@ public class AnnotationPanel if (av.validCharWidth && validRes && (row.annotations[column].displayCharacter!=null && row.annotations[column].displayCharacter.length() > 0)) { - int charOffset = (av.charWidth - - fm.charWidth(row.annotations[column]. - displayCharacter.charAt( - 0))) / 2; + int charOffset = (av.getCentreColumnLabels()) ? ((av.charWidth - + fm.charsWidth(row.annotations[column]. + displayCharacter.toCharArray(),0, + row.annotations[column]. + displayCharacter.length())) / 2) + : (av.charWidth - fm.charWidth(row.annotations[column]. + displayCharacter.charAt(0))) / 2; if (row.annotations[column].colour == null) g.setColor(Color.black); -- 1.7.10.2