From: James Procter Date: Thu, 14 Sep 2023 09:16:21 +0000 (+0100) Subject: Merge branch 'develop' into spike/JAL-4047/JAL-4048_columns_in_sequenceID X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=f680b9a507cc1643c9eead990e15026c1eca4e6e;hp=-c;p=jalview.git Merge branch 'develop' into spike/JAL-4047/JAL-4048_columns_in_sequenceID --- f680b9a507cc1643c9eead990e15026c1eca4e6e diff --combined src/jalview/api/AlignViewportI.java index 3c266e5,0cfd03d..ba3ed75 --- a/src/jalview/api/AlignViewportI.java +++ b/src/jalview/api/AlignViewportI.java @@@ -20,13 -20,6 +20,13 @@@ */ package jalview.api; +import java.awt.Color; +import java.awt.Font; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + import jalview.analysis.Conservation; import jalview.analysis.TreeModel; import jalview.datamodel.AlignmentAnnotation; @@@ -44,7 -37,13 +44,7 @@@ import jalview.datamodel.SequenceI import jalview.renderer.ResidueShaderI; import jalview.schemes.ColourSchemeI; import jalview.viewmodel.ViewportRanges; - -import java.awt.Color; -import java.awt.Font; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import jalview.viewmodel.seqfeatures.IdColumns; /** * @author jimp @@@ -478,6 -477,15 +478,15 @@@ public interface AlignViewportI extend */ SearchResultsI getSearchResults(); + /** + * Retrieve a ContactListI corresponding to column in an annotation row in an + * alignment. + * + * @param _aa + * - annotation with associated matrix data + * @param column + * - column in alignment where _aa is associated + */ ContactListI getContactList(AlignmentAnnotation _aa, int column); /** @@@ -558,7 -566,5 +567,7 @@@ */ Iterator getViewAsVisibleContigs(boolean selectedRegionOnly); + IdColumns getIdColumns(); + ContactMatrixI getContactMatrix(AlignmentAnnotation alignmentAnnotation); } diff --combined src/jalview/gui/IdCanvas.java index 68a7a1e,aaded9e..2faea01 --- a/src/jalview/gui/IdCanvas.java +++ b/src/jalview/gui/IdCanvas.java @@@ -22,6 -22,7 +22,7 @@@ package jalview.gui import java.awt.BorderLayout; import java.awt.Color; + import java.awt.Dimension; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics; @@@ -36,9 -37,6 +37,9 @@@ import javax.swing.JPanel import jalview.datamodel.SequenceI; import jalview.viewmodel.ViewportListenerI; import jalview.viewmodel.ViewportRanges; +import jalview.viewmodel.seqfeatures.IdColumn; +import jalview.viewmodel.seqfeatures.IdColumns; +import jalview.viewmodel.seqfeatures.IdColumns.ColumnCell; /** * DOCUMENT ME! @@@ -201,7 -199,7 +202,7 @@@ public class IdCanvas extends JPanel im gg.translate(0, transY); - drawIds(gg, av, ss, es, searchResults); + drawIds(gg, av, ss, es, searchResults,true); gg.translate(0, -transY); @@@ -258,7 -256,7 +259,7 @@@ gg.fillRect(0, 0, getWidth(), imgHeight); drawIds(gg, av, av.getRanges().getStartSeq(), - av.getRanges().getEndSeq(), searchResults); + av.getRanges().getEndSeq(), searchResults,true); gg.dispose(); @@@ -278,7 -276,7 +279,7 @@@ * @param selection */ void drawIds(Graphics2D g, AlignViewport alignViewport, - final int startSeq, final int endSeq, List selection) + final int startSeq, final int endSeq, List selection, boolean forGUI) { Font font = alignViewport.getFont(); if (alignViewport.isSeqNameItalics()) @@@ -311,27 -309,19 +312,27 @@@ } // Now draw the id strings - int panelWidth = getWidth(); - int xPos = 0; + int fullPanelWidth = getWidth(); + + IdColumns id_cols = alignViewport.getIdColumns(); + List visible = id_cols.getVisible(); + /** + * width of an idColumn + */ + int colWid = 20; + int panelWidth = Math.max(fullPanelWidth / 2, + fullPanelWidth - (colWid * visible.size())); // Now draw the id strings for (int i = startSeq; i <= endSeq; i++) { + int xPos = 0; SequenceI sequence = alignViewport.getAlignment().getSequenceAt(i); if (sequence == null) { continue; } - if (hasHiddenRows || alignViewport.isDisplayReferenceSeq()) { g.setFont(getHiddenFont(sequence, alignViewport)); @@@ -375,37 -365,6 +376,37 @@@ (((i - startSeq) * charHeight) + charHeight) - (charHeight / 5)); + if (visible != null && visible.size() > 0) + { + try + { + xPos = panelWidth + 2; + for (IdColumn col : visible) + { + ColumnCell col_cell = id_cols.getCellFor(sequence, col); + if (col_cell == null) + { + g.setColor(Color.gray); + g.fillRect(xPos + 1, (i - startSeq) * charHeight, + xPos + colWid - 3, charHeight); + } + else + { + g.setColor(col_cell.bg); + g.fillRect(xPos + 1, (i - startSeq) * charHeight, + xPos + colWid - 3, charHeight); + g.setColor(col_cell.fg); + g.drawString(col_cell.label, xPos, + (((i - startSeq) * charHeight) + charHeight) + - (charHeight / 5)); + } + xPos += colWid; + g.setColor(currentTextColor); + } + } catch (Exception q) + { + } + } if (hasHiddenRows && av.getShowHiddenMarkers()) { drawMarker(g, alignViewport, i, startSeq, 0); @@@ -424,6 -383,25 +425,25 @@@ void drawIdsWrapped(Graphics2D g, AlignViewport alignViewport, int startSeq, int pageHeight) { + drawIdsWrapped(g, alignViewport, startSeq, pageHeight, -1, true); + } + + /** + * render sequence IDs and annotation labels when wrapped - without GUI junk + * @param g + * @param av2 + * @param i + * @param totalHeight + */ + public void drawIdsWrappedNoGUI(Graphics2D g, AlignViewport av2, int i, + int totalHeight) + { + drawIdsWrapped(g, av2, totalHeight, totalHeight, i,false); + } + + void drawIdsWrapped(Graphics2D g, AlignViewport alignViewport, + int startSeq, int pageHeight, int idWidth, boolean forGUI) + { int alignmentWidth = alignViewport.getAlignment().getWidth(); final int alheight = alignViewport.getAlignment().getHeight(); @@@ -470,8 -448,23 +490,23 @@@ if (labels != null && alignViewport.isShowAnnotation()) { + int getWidth = getWidth(); + int thisIdWidth = getWidth; g.translate(0, ypos + (alheight * charHeight)); - labels.drawComponent(g, getWidth()); + if (!manuallyAdjusted()) + { + int getAnnotationsIdWidth = labels.drawLabels(g, false, -1, false,forGUI, + null); + thisIdWidth = idWidth < 0 ? getAnnotationsIdWidth : idWidth; + if (thisIdWidth > getWidth) + { + this.setPreferredSize( + new Dimension(thisIdWidth, this.getHeight())); + this.repaint(); + alignViewport.setIdWidth(thisIdWidth); + } + } + labels.drawComponent(g, false, thisIdWidth, forGUI); g.translate(0, -ypos - (alheight * charHeight)); } @@@ -627,4 -620,17 +662,17 @@@ repaint(); } } + + private boolean manuallyAdjusted = false; + + public boolean manuallyAdjusted() + { + return manuallyAdjusted; + } + + public void setManuallyAdjusted(boolean b) + { + manuallyAdjusted = b; + } + } diff --combined src/jalview/gui/PopupMenu.java index f50b72b,109c140..ca0fb7f --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@@ -87,8 -87,6 +87,8 @@@ import jalview.util.Platform import jalview.util.StringUtils; import jalview.util.UrlLink; import jalview.viewmodel.seqfeatures.FeatureRendererModel; +import jalview.viewmodel.seqfeatures.IdColumn; +import jalview.viewmodel.seqfeatures.IdColumns; /** * The popup menu that is displayed on right-click on a sequence id, or in the @@@ -728,38 -726,9 +728,38 @@@ public class PopupMenu extends JPopupMe rnaStructureMenu.setVisible(false); } + if (forIdPanel) + { + addDisplayColumnsMenu(); + } + addLinksAndFeatures(seq, column); } + void addDisplayColumnsMenu() + { + JMenu dis_cols = new JMenu( + MessageManager.getString("action.displayed_columns")); + final IdColumns id_cols = ap.av.getIdColumns(); + id_cols.updateTypeList(); + for (final IdColumn col : id_cols.getIdColumns()) + { + JMenuItem col_entry = new JCheckBoxMenuItem(col.getLabel(), + col.isVisible()); + col_entry.addActionListener(new ActionListener() + { + + @Override + public void actionPerformed(ActionEvent e) + { + id_cols.toggleVisible(col.getLabel()); + } + }); + dis_cols.add(col_entry); + } + add(dis_cols); + } + /** * Adds *
    @@@ -937,6 -906,7 +937,7 @@@ if (Platform.isJS()) { details = new JInternalFrame(); + details.setFrameIcon(null); JPanel panel = new JPanel(new BorderLayout()); panel.setOpaque(true); panel.setBackground(Color.white); @@@ -1765,10 -1735,9 +1766,9 @@@ protected void addReferenceAnnotations_actionPerformed( Map> candidates) { - final SequenceGroup selectionGroup = this.ap.av.getSelectionGroup(); final AlignmentI alignment = this.ap.getAlignment(); AlignmentUtils.addReferenceAnnotations(candidates, alignment, - selectionGroup); + null); refresh(); } @@@ -1866,6 -1835,7 +1866,7 @@@ pane.setBackground(Color.WHITE); pane.add(textLabel, BorderLayout.NORTH); frame = new JInternalFrame(); + frame.setFrameIcon(null); frame.getContentPane().add(new JScrollPane(pane)); } else @@@ -2021,7 -1991,6 +2022,6 @@@ sg.setName(dialog.getName()); sg.setDescription(dialog.getDescription()); refresh(); - return null; }); } @@@ -2059,12 -2028,17 +2059,17 @@@ { if (dialog.getName().indexOf(" ") > -1) { - JvOptionPane.showMessageDialog(ap, - MessageManager.getString( - "label.spaces_converted_to_underscores"), - MessageManager.getString( - "label.no_spaces_allowed_sequence_name"), - JvOptionPane.WARNING_MESSAGE); + String ok = MessageManager.getString("action.ok"); + String cancel = MessageManager.getString("action.cancel"); + String message = MessageManager.getString( + "label.spaces_converted_to_underscores"); + String title = MessageManager.getString( + "label.no_spaces_allowed_sequence_name"); + Object[] options = new Object[] { ok, cancel }; + + JvOptionPane.frameDialog(message, title, + JvOptionPane.WARNING_MESSAGE, null, null, null, + false); } sequence.setName(dialog.getName().replace(' ', '_')); ap.paintAlignment(false, false); @@@ -2072,7 -2046,6 +2077,6 @@@ sequence.setDescription(dialog.getDescription()); ap.av.firePropertyChange("alignment", null, ap.av.getAlignment().getSequences()); - return null; }); } @@@ -2218,7 -2191,7 +2222,7 @@@ String[] omitHidden = null; - System.out.println("PROMPT USER HERE"); // TODO: decide if a prompt happens + jalview.bin.Console.outPrintln("PROMPT USER HERE"); // TODO: decide if a prompt happens // or we simply trust the user wants // wysiwig behaviour @@@ -2307,7 -2280,6 +2311,6 @@@ ap.alignFrame.addHistoryItem(editCommand); ap.av.firePropertyChange("alignment", null, ap.av.getAlignment().getSequences()); - return null; }); } } diff --combined src/jalview/viewmodel/AlignmentViewport.java index d41a5be,42768a6..7e0b6b4 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@@ -72,7 -72,6 +72,7 @@@ import jalview.util.Comparison import jalview.util.MapList; import jalview.util.MappingUtils; import jalview.util.MessageManager; +import jalview.viewmodel.seqfeatures.IdColumns; import jalview.viewmodel.styles.ViewStyle; import jalview.workers.AlignCalcManager; import jalview.workers.ComplementConsensusThread; @@@ -935,7 -934,7 +935,7 @@@ public abstract class AlignmentViewpor } if (calculator.workingInvolvedWith(alignmentAnnotation)) { - // System.err.println("grey out ("+alignmentAnnotation.label+")"); + // jalview.bin.Console.errPrintln("grey out ("+alignmentAnnotation.label+")"); return true; } return false; @@@ -1208,7 -1207,7 +1208,7 @@@ { if (sequenceSetID != null) { - System.err.println( + jalview.bin.Console.errPrintln( "Warning - overwriting a sequenceSetId for a viewport!"); } sequenceSetID = new String(newid); @@@ -2101,7 -2100,7 +2101,7 @@@ { if (aa == null) { - System.err.println("Null annotation row: ignoring."); + jalview.bin.Console.errPrintln("Null annotation row: ignoring."); continue; } if (!aa.visible) @@@ -2133,7 -2132,7 +2133,7 @@@ if (aa.graph > 0) { - aa.height += aa.graphHeight; + aa.height += aa.graphHeight+20; } if (aa.height == 0) @@@ -2294,7 -2293,7 +2294,7 @@@ { if (this == av) { - System.err.println("Ignoring recursive setCodingComplement request"); + jalview.bin.Console.errPrintln("Ignoring recursive setCodingComplement request"); } else { @@@ -2957,7 -2956,6 +2957,6 @@@ return alignment.getContactMatrixFor(alignmentAnnotation); } - /** * get the consensus sequence as displayed under the PID consensus annotation * row. @@@ -3124,28 -3122,6 +3123,28 @@@ false)); } + /** + * ordered list of annotation values displayed per sequence in ID panel + */ + private IdColumns id_columns = null; + + /** + * available and currently visible columns for this view + */ + @Override + public IdColumns getIdColumns() + { + if (alignment == null) + { + return null; + } + if (id_columns == null) + { + id_columns = new IdColumns(alignment); + } + return id_columns; + } + public void setSavedUpToDate(boolean s) { setSavedUpToDate(s, QuitHandler.Message.UNSAVED_CHANGES);