2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import jalview.analysis.AlignmentUtils;
24 import jalview.datamodel.Alignment;
25 import jalview.datamodel.AlignmentAnnotation;
26 import jalview.datamodel.Annotation;
27 import jalview.datamodel.Sequence;
28 import jalview.datamodel.SequenceGroup;
29 import jalview.datamodel.SequenceI;
30 import jalview.io.FileFormat;
31 import jalview.io.FormatAdapter;
32 import jalview.util.MessageManager;
34 import java.awt.Color;
35 import java.awt.Dimension;
37 import java.awt.FontMetrics;
38 import java.awt.Graphics;
39 import java.awt.Graphics2D;
40 import java.awt.Image;
41 import java.awt.MediaTracker;
42 import java.awt.RenderingHints;
43 import java.awt.Toolkit;
44 import java.awt.datatransfer.StringSelection;
45 import java.awt.event.ActionEvent;
46 import java.awt.event.ActionListener;
47 import java.awt.event.MouseEvent;
48 import java.awt.event.MouseListener;
49 import java.awt.event.MouseMotionListener;
50 import java.awt.geom.AffineTransform;
51 import java.awt.image.BufferedImage;
52 import java.util.ArrayList;
53 import java.util.Arrays;
54 import java.util.Collections;
55 import java.util.List;
56 import java.util.regex.Pattern;
58 import javax.swing.JCheckBoxMenuItem;
59 import javax.swing.JMenuItem;
60 import javax.swing.JPanel;
61 import javax.swing.JPopupMenu;
62 import javax.swing.SwingUtilities;
63 import javax.swing.ToolTipManager;
71 public class AnnotationLabels extends JPanel implements MouseListener,
72 MouseMotionListener, ActionListener
74 private static final Pattern LEFT_ANGLE_BRACKET_PATTERN = Pattern
77 String TOGGLE_LABELSCALE = MessageManager
78 .getString("label.scale_label_to_column");
80 String ADDNEW = MessageManager.getString("label.add_new_row");
82 String EDITNAME = MessageManager
83 .getString("label.edit_label_description");
85 String HIDE = MessageManager.getString("label.hide_row");
87 String DELETE = MessageManager.getString("label.delete_row");
89 String SHOWALL = MessageManager.getString("label.show_all_hidden_rows");
91 String OUTPUT_TEXT = MessageManager.getString("label.export_annotation");
93 String COPYCONS_SEQ = MessageManager
94 .getString("label.copy_consensus_sequence");
96 boolean resizePanel = false;
104 boolean resizing = false;
106 MouseEvent dragEvent;
112 private int scrollOffset = 0;
114 Font font = new Font("Arial", Font.PLAIN, 11);
116 private boolean hasHiddenRows;
119 * Creates a new AnnotationLabels object.
124 public AnnotationLabels(AlignmentPanel ap)
128 ToolTipManager.sharedInstance().registerComponent(this);
130 java.net.URL url = getClass().getResource("/images/idwidth.gif");
135 temp = java.awt.Toolkit.getDefaultToolkit().createImage(url);
140 MediaTracker mt = new MediaTracker(this);
141 mt.addImage(temp, 0);
143 } catch (Exception ex)
147 BufferedImage bi = new BufferedImage(temp.getHeight(this),
148 temp.getWidth(this), BufferedImage.TYPE_INT_RGB);
149 Graphics2D g = (Graphics2D) bi.getGraphics();
150 g.rotate(Math.toRadians(90));
151 g.drawImage(temp, 0, -bi.getWidth(this), this);
154 addMouseListener(this);
155 addMouseMotionListener(this);
156 addMouseWheelListener(ap.getAnnotationPanel());
159 public AnnotationLabels(AlignViewport av)
170 public void setScrollOffset(int y)
177 * sets selectedRow to -2 if no annotation preset, -1 if no visible row is at
181 * coordinate position to search for a row
183 void getSelectedRow(int y)
186 AlignmentAnnotation[] aa = ap.av.getAlignment()
187 .getAlignmentAnnotation();
191 for (int i = 0; i < aa.length; i++)
199 height += aa[i].height;
218 public void actionPerformed(ActionEvent evt)
220 AlignmentAnnotation[] aa = ap.av.getAlignment()
221 .getAlignmentAnnotation();
223 if (evt.getActionCommand().equals(ADDNEW))
225 AlignmentAnnotation newAnnotation = new AlignmentAnnotation(null,
226 null, new Annotation[ap.av.getAlignment().getWidth()]);
228 if (!editLabelDescription(newAnnotation))
233 ap.av.getAlignment().addAnnotation(newAnnotation);
234 ap.av.getAlignment().setAnnotationIndex(newAnnotation, 0);
236 else if (evt.getActionCommand().equals(EDITNAME))
238 editLabelDescription(aa[selectedRow]);
241 else if (evt.getActionCommand().equals(HIDE))
243 aa[selectedRow].visible = false;
245 else if (evt.getActionCommand().equals(DELETE))
247 ap.av.getAlignment().deleteAnnotation(aa[selectedRow]);
248 ap.av.getCalcManager().removeWorkerForAnnotation(aa[selectedRow]);
250 else if (evt.getActionCommand().equals(SHOWALL))
252 for (int i = 0; i < aa.length; i++)
254 if (!aa[i].visible && aa[i].annotations != null)
256 aa[i].visible = true;
260 else if (evt.getActionCommand().equals(OUTPUT_TEXT))
262 new AnnotationExporter().exportAnnotations(ap,
263 new AlignmentAnnotation[] { aa[selectedRow] });
265 else if (evt.getActionCommand().equals(COPYCONS_SEQ))
267 SequenceI cons = null;
268 if (aa[selectedRow].groupRef != null)
270 cons = aa[selectedRow].groupRef.getConsensusSeq();
274 cons = av.getConsensusSeq();
278 copy_annotseqtoclipboard(cons);
282 else if (evt.getActionCommand().equals(TOGGLE_LABELSCALE))
284 aa[selectedRow].scaleColLabel = !aa[selectedRow].scaleColLabel;
294 protected void refresh()
296 ap.validateAnnotationDimensions(false);
307 boolean editLabelDescription(AlignmentAnnotation annotation)
309 EditNameDialog dialog = new EditNameDialog(annotation.label,
310 annotation.description, " Annotation Name ",
311 "Annotation Description ", "Edit Annotation Name/Description",
319 annotation.label = dialog.getName();
321 String text = dialog.getDescription();
322 if (text != null && text.length() == 0)
326 annotation.description = text;
332 public void mousePressed(MouseEvent evt)
334 getSelectedRow(evt.getY() - getScrollOffset());
336 if (!evt.isPopupTrigger())
341 // handle popup menu event
342 final AlignmentAnnotation[] aa = ap.av.getAlignment()
343 .getAlignmentAnnotation();
345 JPopupMenu pop = new JPopupMenu(
346 MessageManager.getString("label.annotations"));
347 JMenuItem item = new JMenuItem(ADDNEW);
348 item.addActionListener(this);
353 { // let the user make everything visible again
354 item = new JMenuItem(SHOWALL);
355 item.addActionListener(this);
358 pop.show(this, evt.getX(), evt.getY());
361 item = new JMenuItem(EDITNAME);
362 item.addActionListener(this);
364 item = new JMenuItem(HIDE);
365 item.addActionListener(this);
367 // JAL-1264 hide all sequence-specific annotations of this type
368 if (selectedRow < aa.length)
370 if (aa[selectedRow].sequenceRef != null)
372 final String label = aa[selectedRow].label;
373 JMenuItem hideType = new JMenuItem();
374 String text = MessageManager.getString("label.hide_all") + " "
376 hideType.setText(text);
377 hideType.addActionListener(new ActionListener()
380 public void actionPerformed(ActionEvent e)
382 AlignmentUtils.showOrHideSequenceAnnotations(
383 ap.av.getAlignment(), Collections.singleton(label),
385 // for (AlignmentAnnotation ann : ap.av.getAlignment()
386 // .getAlignmentAnnotation())
388 // if (ann.sequenceRef != null && ann.label != null
389 // && ann.label.equals(label))
391 // ann.visible = false;
400 item = new JMenuItem(DELETE);
401 item.addActionListener(this);
405 item = new JMenuItem(SHOWALL);
406 item.addActionListener(this);
409 item = new JMenuItem(OUTPUT_TEXT);
410 item.addActionListener(this);
412 // TODO: annotation object should be typed for autocalculated/derived
414 if (selectedRow < aa.length)
416 final String label = aa[selectedRow].label;
417 if (!aa[selectedRow].autoCalculated)
419 if (aa[selectedRow].graph == AlignmentAnnotation.NO_GRAPH)
421 // display formatting settings for this row.
423 // av and sequencegroup need to implement same interface for
424 item = new JCheckBoxMenuItem(TOGGLE_LABELSCALE,
425 aa[selectedRow].scaleColLabel);
426 item.addActionListener(this);
430 else if (label.indexOf("Consensus") > -1)
433 // av and sequencegroup need to implement same interface for
434 final JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem(
435 MessageManager.getString("label.ignore_gaps_consensus"),
436 (aa[selectedRow].groupRef != null) ? aa[selectedRow].groupRef
437 .getIgnoreGapsConsensus() : ap.av
438 .isIgnoreGapsConsensus());
439 final AlignmentAnnotation aaa = aa[selectedRow];
440 cbmi.addActionListener(new ActionListener()
443 public void actionPerformed(ActionEvent e)
445 if (aaa.groupRef != null)
447 // TODO: pass on reference to ap so the view can be updated.
448 aaa.groupRef.setIgnoreGapsConsensus(cbmi.getState());
449 ap.getAnnotationPanel().paint(
450 ap.getAnnotationPanel().getGraphics());
454 ap.av.setIgnoreGapsConsensus(cbmi.getState(), ap);
459 // av and sequencegroup need to implement same interface for
460 if (aaa.groupRef != null)
462 final JCheckBoxMenuItem chist = new JCheckBoxMenuItem(
463 MessageManager.getString("label.show_group_histogram"),
464 aa[selectedRow].groupRef.isShowConsensusHistogram());
465 chist.addActionListener(new ActionListener()
468 public void actionPerformed(ActionEvent e)
470 // TODO: pass on reference
476 aaa.groupRef.setShowConsensusHistogram(chist.getState());
478 // ap.annotationPanel.paint(ap.annotationPanel.getGraphics());
482 final JCheckBoxMenuItem cprofl = new JCheckBoxMenuItem(
483 MessageManager.getString("label.show_group_logo"),
484 aa[selectedRow].groupRef.isShowSequenceLogo());
485 cprofl.addActionListener(new ActionListener()
488 public void actionPerformed(ActionEvent e)
490 // TODO: pass on reference
496 aaa.groupRef.setshowSequenceLogo(cprofl.getState());
498 // ap.annotationPanel.paint(ap.annotationPanel.getGraphics());
502 final JCheckBoxMenuItem cproflnorm = new JCheckBoxMenuItem(
503 MessageManager.getString("label.normalise_group_logo"),
504 aa[selectedRow].groupRef.isNormaliseSequenceLogo());
505 cproflnorm.addActionListener(new ActionListener()
508 public void actionPerformed(ActionEvent e)
511 // TODO: pass on reference
517 aaa.groupRef.setNormaliseSequenceLogo(cproflnorm.getState());
518 // automatically enable logo display if we're clicked
519 aaa.groupRef.setshowSequenceLogo(true);
521 // ap.annotationPanel.paint(ap.annotationPanel.getGraphics());
528 final JCheckBoxMenuItem chist = new JCheckBoxMenuItem(
529 MessageManager.getString("label.show_histogram"),
530 av.isShowConsensusHistogram());
531 chist.addActionListener(new ActionListener()
534 public void actionPerformed(ActionEvent e)
536 // TODO: pass on reference
542 av.setShowConsensusHistogram(chist.getState());
543 ap.alignFrame.setMenusForViewport();
545 // ap.annotationPanel.paint(ap.annotationPanel.getGraphics());
549 final JCheckBoxMenuItem cprof = new JCheckBoxMenuItem(
550 MessageManager.getString("label.show_logo"),
551 av.isShowSequenceLogo());
552 cprof.addActionListener(new ActionListener()
555 public void actionPerformed(ActionEvent e)
557 // TODO: pass on reference
563 av.setShowSequenceLogo(cprof.getState());
564 ap.alignFrame.setMenusForViewport();
566 // ap.annotationPanel.paint(ap.annotationPanel.getGraphics());
570 final JCheckBoxMenuItem cprofnorm = new JCheckBoxMenuItem(
571 MessageManager.getString("label.normalise_logo"),
572 av.isNormaliseSequenceLogo());
573 cprofnorm.addActionListener(new ActionListener()
576 public void actionPerformed(ActionEvent e)
578 // TODO: pass on reference
584 av.setShowSequenceLogo(true);
585 av.setNormaliseSequenceLogo(cprofnorm.getState());
586 ap.alignFrame.setMenusForViewport();
588 // ap.annotationPanel.paint(ap.annotationPanel.getGraphics());
593 final JMenuItem consclipbrd = new JMenuItem(COPYCONS_SEQ);
594 consclipbrd.addActionListener(this);
595 pop.add(consclipbrd);
598 pop.show(this, evt.getX(), evt.getY());
609 public void mouseReleased(MouseEvent evt)
611 int start = selectedRow;
612 getSelectedRow(evt.getY() - getScrollOffset());
613 int end = selectedRow;
617 // Swap these annotations
618 AlignmentAnnotation startAA = ap.av.getAlignment()
619 .getAlignmentAnnotation()[start];
622 end = ap.av.getAlignment().getAlignmentAnnotation().length - 1;
624 AlignmentAnnotation endAA = ap.av.getAlignment()
625 .getAlignmentAnnotation()[end];
627 ap.av.getAlignment().getAlignmentAnnotation()[end] = startAA;
628 ap.av.getAlignment().getAlignmentAnnotation()[start] = endAA;
634 ap.getAnnotationPanel().repaint();
644 public void mouseEntered(MouseEvent evt)
660 public void mouseExited(MouseEvent evt)
662 if (dragEvent == null)
676 public void mouseDragged(MouseEvent evt)
682 Dimension d = ap.annotationScroller.getPreferredSize();
683 int dif = evt.getY() - oldY;
685 dif /= ap.av.getCharHeight();
686 dif *= ap.av.getCharHeight();
688 if ((d.height - dif) > 20)
690 ap.annotationScroller.setPreferredSize(new Dimension(d.width,
692 d = ap.annotationSpaceFillerHolder.getPreferredSize();
693 ap.annotationSpaceFillerHolder.setPreferredSize(new Dimension(
694 d.width, d.height - dif));
695 ap.paintAlignment(true);
713 public void mouseMoved(MouseEvent evt)
715 resizePanel = evt.getY() < 10;
717 getSelectedRow(evt.getY() - getScrollOffset());
720 && ap.av.getAlignment().getAlignmentAnnotation().length > selectedRow)
722 AlignmentAnnotation aa = ap.av.getAlignment()
723 .getAlignmentAnnotation()[selectedRow];
725 StringBuffer desc = new StringBuffer();
726 if (aa.description != null
727 && !aa.description.equals("New description"))
729 // TODO: we could refactor and merge this code with the code in
730 // jalview.gui.SeqPanel.mouseMoved(..) that formats sequence feature
732 desc.append(aa.getDescription(true).trim());
733 // check to see if the description is an html fragment.
734 if (desc.length() < 6
735 || (desc.substring(0, 6).toLowerCase().indexOf("<html>") < 0))
737 // clean the description ready for embedding in html
738 desc = new StringBuffer(LEFT_ANGLE_BRACKET_PATTERN.matcher(desc)
739 .replaceAll("<"));
740 desc.insert(0, "<html>");
744 // remove terminating html if any
745 int i = desc.substring(desc.length() - 7).toLowerCase()
746 .lastIndexOf("</html>");
749 desc.setLength(desc.length() - 7 + i);
754 desc.append("<br/>");
756 // if (aa.hasProperties())
758 // desc.append("<table>");
759 // for (String prop : aa.getProperties())
761 // desc.append("<tr><td>" + prop + "</td><td>"
762 // + aa.getProperty(prop) + "</td><tr>");
764 // desc.append("</table>");
769 // begin the tooltip's html fragment
770 desc.append("<html>");
773 // TODO: limit precision of score to avoid noise from imprecise
775 // (64.7 becomes 64.7+/some tiny value).
776 desc.append(" Score: " + aa.score);
779 if (desc.length() > 6)
781 desc.append("</html>");
782 this.setToolTipText(desc.toString());
786 this.setToolTipText(null);
792 public void mouseClicked(MouseEvent evt)
794 final AlignmentAnnotation[] aa = ap.av.getAlignment()
795 .getAlignmentAnnotation();
796 if (!evt.isPopupTrigger() && SwingUtilities.isLeftMouseButton(evt))
798 if (selectedRow > -1 && selectedRow < aa.length)
800 if (aa[selectedRow].groupRef != null)
802 if (evt.getClickCount() >= 2)
804 // todo: make the ap scroll to the selection - not necessary, first
805 // click highlights/scrolls, second selects
806 ap.getSeqPanel().ap.getIdPanel().highlightSearchResults(null);
808 SequenceGroup sg = ap.av.getSelectionGroup();
810 || sg == aa[selectedRow].groupRef
811 || !(jalview.util.Platform.isControlDown(evt) || evt
814 if (jalview.util.Platform.isControlDown(evt)
815 || evt.isShiftDown())
817 // clone a new selection group from the associated group
818 ap.av.setSelectionGroup(new SequenceGroup(
819 aa[selectedRow].groupRef));
823 // set selection to the associated group so it can be edited
824 ap.av.setSelectionGroup(aa[selectedRow].groupRef);
829 // modify current selection with associated group
830 int remainToAdd = aa[selectedRow].groupRef.getSize();
831 for (SequenceI sgs : aa[selectedRow].groupRef.getSequences())
833 if (jalview.util.Platform.isControlDown(evt))
835 sg.addOrRemove(sgs, --remainToAdd == 0);
839 // notionally, we should also add intermediate sequences from
840 // last added sequence ?
841 sg.addSequence(sgs, --remainToAdd == 0);
846 ap.paintAlignment(false);
847 PaintRefresher.Refresh(ap, ap.av.getSequenceSetId());
848 ap.av.sendSelection();
852 ap.getSeqPanel().ap.getIdPanel().highlightSearchResults(
853 aa[selectedRow].groupRef.getSequences(null));
857 else if (aa[selectedRow].sequenceRef != null)
859 if (evt.getClickCount() == 1)
863 .highlightSearchResults(
864 Arrays.asList(new SequenceI[] { aa[selectedRow].sequenceRef }));
866 else if (evt.getClickCount() >= 2)
868 ap.getSeqPanel().ap.getIdPanel().highlightSearchResults(null);
869 SequenceGroup sg = ap.av.getSelectionGroup();
872 // we make a copy rather than edit the current selection if no
874 // see Enhancement JAL-1557
875 if (!(jalview.util.Platform.isControlDown(evt) || evt
878 sg = new SequenceGroup(sg);
880 sg.addSequence(aa[selectedRow].sequenceRef, false);
884 if (jalview.util.Platform.isControlDown(evt))
886 sg.addOrRemove(aa[selectedRow].sequenceRef, true);
890 // notionally, we should also add intermediate sequences from
891 // last added sequence ?
892 sg.addSequence(aa[selectedRow].sequenceRef, true);
898 sg = new SequenceGroup();
900 sg.setEndRes(ap.av.getAlignment().getWidth() - 1);
901 sg.addSequence(aa[selectedRow].sequenceRef, false);
903 ap.av.setSelectionGroup(sg);
904 ap.paintAlignment(false);
905 PaintRefresher.Refresh(ap, ap.av.getSequenceSetId());
906 ap.av.sendSelection();
916 * do a single sequence copy to jalview and the system clipboard
919 * sequence to be copied to clipboard
921 protected void copy_annotseqtoclipboard(SequenceI sq)
923 SequenceI[] seqs = new SequenceI[] { sq };
924 String[] omitHidden = null;
925 SequenceI[] dseqs = new SequenceI[] { sq.getDatasetSequence() };
926 if (dseqs[0] == null)
928 dseqs[0] = new Sequence(sq);
929 dseqs[0].setSequence(jalview.analysis.AlignSeq.extractGaps(
930 jalview.util.Comparison.GapChars, sq.getSequenceAsString()));
932 sq.setDatasetSequence(dseqs[0]);
934 Alignment ds = new Alignment(dseqs);
935 if (av.hasHiddenColumns())
937 omitHidden = av.getColumnSelection().getVisibleSequenceStrings(0,
938 sq.getLength(), seqs);
941 int[] alignmentStartEnd = new int[] { 0, ds.getWidth() - 1 };
942 List<int[]> hiddenCols = av.getColumnSelection().getHiddenColumns();
943 if (hiddenCols != null)
945 alignmentStartEnd = av.getAlignment().getVisibleStartAndEndIndex(
948 String output = new FormatAdapter().formatSequences(FileFormat.Fasta,
949 seqs, omitHidden, alignmentStartEnd);
951 Toolkit.getDefaultToolkit().getSystemClipboard()
952 .setContents(new StringSelection(output), Desktop.instance);
954 ArrayList<int[]> hiddenColumns = null;
955 if (av.hasHiddenColumns())
957 hiddenColumns = new ArrayList<int[]>();
958 for (int[] region : av.getColumnSelection().getHiddenColumns())
960 hiddenColumns.add(new int[] { region[0], region[1] });
964 Desktop.jalviewClipboard = new Object[] { seqs, ds, // what is the dataset
966 // sequence ? need to
968 // sequence as special.
979 public void paintComponent(Graphics g)
982 int width = getWidth();
985 width = ap.calculateIdWidth().width + 4;
988 Graphics2D g2 = (Graphics2D) g;
991 g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
992 RenderingHints.VALUE_ANTIALIAS_ON);
995 drawComponent(g2, true, width);
1000 * Draw the full set of annotation Labels for the alignment at the given
1004 * Graphics2D instance (needed for font scaling)
1006 * Width for scaling labels
1009 public void drawComponent(Graphics g, int width)
1011 drawComponent(g, false, width);
1014 private final boolean debugRedraw = false;
1017 * Draw the full set of annotation Labels for the alignment at the given
1021 * Graphics2D instance (needed for font scaling)
1023 * - true indicates that only current visible area needs to be
1026 * Width for scaling labels
1028 public void drawComponent(Graphics g, boolean clip, int width)
1030 if (av.getFont().getSize() < 10)
1036 g.setFont(av.getFont());
1039 FontMetrics fm = g.getFontMetrics(g.getFont());
1040 g.setColor(Color.white);
1041 g.fillRect(0, 0, getWidth(), getHeight());
1043 g.translate(0, getScrollOffset());
1044 g.setColor(Color.black);
1046 AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
1047 int fontHeight = g.getFont().getSize();
1050 int graphExtras = 0;
1052 Font baseFont = g.getFont();
1053 FontMetrics baseMetrics = fm;
1054 int ofontH = fontHeight;
1057 int[] visr = (ap != null && ap.getAnnotationPanel() != null) ? ap
1058 .getAnnotationPanel().getVisibleVRange() : null;
1059 if (clip && visr != null)
1062 visHeight = visr[1];
1064 boolean visible = true, before = false, after = false;
1067 hasHiddenRows = false;
1069 for (int i = 0; i < aa.length; i++)
1074 hasHiddenRows = true;
1087 System.out.println("before vis: " + i);
1091 // don't draw what isn't visible
1094 if (olY > visHeight)
1101 System.out.println("Scroll offset: " + sOffset
1102 + " after vis: " + i);
1106 // don't draw what isn't visible
1110 g.setColor(Color.black);
1112 offset = -aa[i].height / 2;
1116 offset += fm.getHeight() / 2;
1117 offset -= fm.getDescent();
1121 offset += fm.getDescent();
1124 x = width - fm.stringWidth(aa[i].label) - 3;
1126 if (aa[i].graphGroup > -1)
1129 // TODO: JAL-1291 revise rendering model so the graphGroup map is
1130 // computed efficiently for all visible labels
1131 for (int gg = 0; gg < aa.length; gg++)
1133 if (aa[gg].graphGroup == aa[i].graphGroup)
1138 if (groupSize * (fontHeight + 8) < aa[i].height)
1140 graphExtras = (aa[i].height - (groupSize * (fontHeight + 8))) / 2;
1144 // scale font to fit
1145 float h = aa[i].height / (float) groupSize, s;
1152 fontHeight = -8 + (int) h;
1153 s = ((float) fontHeight) / (float) ofontH;
1154 Font f = baseFont.deriveFont(AffineTransform
1155 .getScaleInstance(s, s));
1157 fm = g.getFontMetrics();
1158 graphExtras = (aa[i].height - (groupSize * (fontHeight + 8))) / 2;
1163 for (int gg = 0; gg < aa.length; gg++)
1165 if (aa[gg].graphGroup == aa[i].graphGroup)
1167 x = width - fm.stringWidth(aa[gg].label) - 3;
1168 g.drawString(aa[gg].label, x, y - graphExtras);
1170 if (aa[gg]._linecolour != null)
1173 g.setColor(aa[gg]._linecolour);
1174 g.drawLine(x, y - graphExtras + 3,
1175 x + fm.stringWidth(aa[gg].label), y - graphExtras
1179 g.setColor(Color.black);
1180 graphExtras += fontHeight + 8;
1184 g.setFont(baseFont);
1186 fontHeight = ofontH;
1190 g.drawString(aa[i].label, x, y + offset);
1197 g.drawImage(image, 2, 0 - getScrollOffset(), this);
1199 else if (dragEvent != null && aa != null)
1201 g.setColor(Color.lightGray);
1202 g.drawString(aa[selectedRow].label, dragEvent.getX(),
1203 dragEvent.getY() - getScrollOffset());
1206 if (!av.getWrapAlignment() && ((aa == null) || (aa.length < 1)))
1208 g.drawString(MessageManager.getString("label.right_click"), 2, 8);
1209 g.drawString(MessageManager.getString("label.to_add_annotation"), 2,
1214 public int getScrollOffset()
1216 return scrollOffset;