X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAnnotationLabels.java;h=d9d6b9f60b7dfe822223cd8910c46837c1c9cf05;hb=refs%2Fheads%2Ffeature%2FJAL-4274_configurable_bitmap_export_preferences;hp=241e0a3776c94e9d497663f8512bb32f5856ec50;hpb=15c3c0e89d9157187e1ccc6962b115cb255dd04a;p=jalview.git diff --git a/src/jalview/gui/AnnotationLabels.java b/src/jalview/gui/AnnotationLabels.java index 241e0a3..d9d6b9f 100755 --- a/src/jalview/gui/AnnotationLabels.java +++ b/src/jalview/gui/AnnotationLabels.java @@ -88,7 +88,7 @@ public class AnnotationLabels extends JPanel /** * height in pixels for allowing height adjuster to be active */ - private static int HEIGHT_ADJUSTER_HEIGHT = 10; + public static int HEIGHT_ADJUSTER_HEIGHT = 10; private static final Font font = new Font("Arial", Font.PLAIN, 11); @@ -138,6 +138,8 @@ public class AnnotationLabels extends JPanel private int annotationIdWidth = -1; + public static final String RESIZE_MARGINS_MARK_PREF = "RESIZE_MARGINS_MARK"; + /** * Creates a new AnnotationLabels object * @@ -515,8 +517,10 @@ public class AnnotationLabels extends JPanel public void actionPerformed(ActionEvent e) { sel_row.setShowGroupsForContactMatrix(chitem.getState()); - ap.getAnnotationPanel() - .paint(ap.getAnnotationPanel().getGraphics()); + // so any annotation colour changes are propagated - though they + // probably won't be unless the annotation row colours are removed + // too! + ap.alignmentChanged(); } }); pop.add(chitem); @@ -562,7 +566,10 @@ public class AnnotationLabels extends JPanel "action.clustering_matrix_for", cm.getAnnotDescr(), 5f), progBar = System.currentTimeMillis()); - cm.setGroupSet(GroupSet.makeGroups(cm, 5f, true)); + cm.setGroupSet(GroupSet.makeGroups(cm, true)); + cm.randomlyReColourGroups(); + cm.transferGroupColorsTo(alignmentAnnotation); + ap.alignmentChanged(); ap.alignFrame.showContactMapTree(alignmentAnnotation, cm); ap.alignFrame.setProgressBar(null, progBar); } @@ -1161,8 +1168,7 @@ public class AnnotationLabels extends JPanel RenderingHints.VALUE_ANTIALIAS_ON); } - drawComponent(g2, true, width); - + drawComponent(g2, true, width, true); } /** @@ -1177,7 +1183,7 @@ public class AnnotationLabels extends JPanel */ public void drawComponent(Graphics g, int width) { - drawComponent(g, false, width); + drawComponent(g, false, width, true); } /** @@ -1192,7 +1198,7 @@ public class AnnotationLabels extends JPanel * @param width * Width for scaling labels */ - public void drawComponent(Graphics g, boolean clip, int givenWidth) + public void drawComponent(Graphics g, boolean clip, int givenWidth, boolean forGUI) { int width = givenWidth; IdwidthAdjuster iwa = null; @@ -1204,7 +1210,7 @@ public class AnnotationLabels extends JPanel { Graphics2D g2d = (Graphics2D) g; Graphics dummy = g2d.create(); - int newAnnotationIdWidth = drawLabels(dummy, clip, width, false, + int newAnnotationIdWidth = drawLabels(dummy, clip, width, false, forGUI, null); dummy.dispose(); Dimension d = ap.calculateDefaultAlignmentIdWidth(); @@ -1213,7 +1219,13 @@ public class AnnotationLabels extends JPanel { // If no manual adjustment to ID column with has been made then adjust // width match widest of alignment or annotation id widths + boolean allowShrink = Cache.getDefault("ALLOW_SHRINK_ID_WIDTH", + false); width = Math.max(alignmentIdWidth, newAnnotationIdWidth); + if (clip && width < givenWidth && !allowShrink) + { + width = givenWidth; + } } else if (newAnnotationIdWidth != annotationIdWidth && newAnnotationIdWidth > givenWidth @@ -1233,13 +1245,10 @@ public class AnnotationLabels extends JPanel } else { - Graphics2D g2d = (Graphics2D) g; - Graphics dummy = g2d.create(); - int newAnnotationIdWidth = drawLabels(dummy, clip, width, false, - null); + int newAnnotationIdWidth = drawLabels(g, clip, width, false, forGUI, null); width = Math.max(newAnnotationIdWidth, givenWidth); } - drawLabels(g, clip, width, true, null); + drawLabels(g, clip, width, true, forGUI, null); } /** @@ -1251,18 +1260,39 @@ public class AnnotationLabels extends JPanel * Returns the width of the annotation labels. * * @param g - * Graphics2D instance (needed for font scaling) + * Graphics2D instance (used for rendering and font scaling if no fmetrics supplied) * @param clip * - true indicates that only current visible area needs to be * rendered * @param width * Width for scaling labels + * @param actuallyDraw - when false, no graphics are rendered to g0 + * @param forGUI - when false, GUI relevant marks like indicators for dragging annotation panel height are not rendered * @param fmetrics * FontMetrics if Graphics object g is null */ - public int drawLabels(Graphics g, boolean clip, int width, - boolean actuallyDraw, FontMetrics fmetrics) + public int drawLabels(Graphics g0, boolean clip, int width, + boolean actuallyDraw, boolean forGUI, FontMetrics fmetrics) { + if (clip) + { + clip = Cache.getDefault("MOVE_SEQUENCE_ID_WITH_VISIBLE_ANNOTATIONS", + true); + } + Graphics g = null; + // create a dummy Graphics object if not drawing and one is supplied + if (g0 != null) + { + if (!actuallyDraw) + { + Graphics2D g2d = (Graphics2D) g0; + g = g2d.create(); + } + else + { + g = g0; + } + } int actualWidth = 0; if (g != null) { @@ -1282,6 +1312,17 @@ public class AnnotationLabels extends JPanel { g.setColor(Color.white); g.fillRect(0, 0, getWidth(), getHeight()); + + if (!Cache.getDefault(RESIZE_MARGINS_MARK_PREF, false) + && !av.getWrapAlignment() && forGUI) + { + g.setColor(Color.LIGHT_GRAY); + g.drawLine(0, HEIGHT_ADJUSTER_HEIGHT / 4, HEIGHT_ADJUSTER_WIDTH / 4, + HEIGHT_ADJUSTER_HEIGHT / 4); + g.drawLine(0, 3 * HEIGHT_ADJUSTER_HEIGHT / 4, + HEIGHT_ADJUSTER_WIDTH / 4, 3 * HEIGHT_ADJUSTER_HEIGHT / 4); + + } } if (actuallyDraw) @@ -1339,7 +1380,7 @@ public class AnnotationLabels extends JPanel { if (debugRedraw) { - System.out.println("before vis: " + i); + jalview.bin.Console.outPrintln("before vis: " + i); } before = true; } @@ -1353,7 +1394,7 @@ public class AnnotationLabels extends JPanel { if (debugRedraw) { - System.out.println( + jalview.bin.Console.outPrintln( "Scroll offset: " + sOffset + " after vis: " + i); } after = true; @@ -1548,4 +1589,9 @@ public class AnnotationLabels extends JPanel public void mouseEntered(MouseEvent e) { } + + public void drawComponentNotGUI(Graphics idGraphics, int idWidth) + { + drawComponent(idGraphics, false, idWidth, false); + } }