* @author jimp
*
*/
-public interface AlignViewportI
+public interface AlignViewportI extends ViewStyleI
{
int getCharWidth();
Hashtable[] getRnaStructureConsensusHash();
-
- boolean getCentreColumnLabels();
boolean isIgnoreGapsConsensus();
boolean isCalculationInProgress(AlignmentAnnotation alignmentAnnotation);
* @param settingsForView
*/
public void setViewStyle(ViewStyleI settingsForView);
+
}
boolean sameStyle(ViewStyleI them);
+ void setFontName(String name);
+
+ void setFontStyle(int style);
+
+ void setFontSize(int size);
+
+ int getFontStyle();
+
+ String getFontName();
+
+ int getFontSize();
+
+ /**
+ * @return width of Sequence and Annotation ID margin. If less than zero, then
+ * width will be autocalculated
+ */
+ int getIdWidth();
+
+ /**
+ * Set width if
+ *
+ * @param i
+ */
+
+ void setIdWidth(int i);
+
+ /**
+ * centre columnar annotation labels in displayed alignment annotation
+ */
+ boolean isCentreColumnLabels();
+
+ /**
+ * centre columnar annotation labels in displayed alignment annotation
+ */
+ void setCentreColumnLabels(boolean centreColumnLabels);
+
+ /**
+ * enable or disable the display of Database Cross References in the sequence
+ * ID tooltip
+ */
+ void setShowDBRefs(boolean showdbrefs);
+
+ /**
+ *
+ * @return true if Database References are to be displayed on tooltips.
+ */
+ boolean isShowDBRefs();
+
+ /**
+ *
+ * @return true if Non-positional features are to be displayed on tooltips.
+ */
+ boolean isShowNPFeats();
+
+ /**
+ * enable or disable the display of Non-Positional sequence features in the
+ * sequence ID tooltip
+ *
+ * @param show
+ */
+ void setShowNPFeats(boolean shownpfeats);
+
}
conservationMenuItem.setSelected(av.getConservationSelected());
seqLimits.setSelected(av.getShowJVSuffix());
idRightAlign.setSelected(av.isRightAlignIds());
- centreColumnLabelsMenuItem.setState(av.centreColumnLabels);
+ centreColumnLabelsMenuItem.setState(av.isCentreColumnLabels());
renderGapsMenuItem.setSelected(av.isRenderGaps());
wrapMenuItem.setSelected(av.getWrapAlignment());
scaleAbove.setVisible(av.getWrapAlignment());
showSeqFeatures.setSelected(av.isShowSequenceFeatures());
hiddenMarkers.setState(av.getShowHiddenMarkers());
applyToAllGroups.setState(av.getColourAppliesToAllGroups());
- showNpFeatsMenuitem.setSelected(av.isShowNpFeats());
- showDbRefsMenuitem.setSelected(av.isShowDbRefs());
+ showNpFeatsMenuitem.setSelected(av.isShowNPFeats());
+ showDbRefsMenuitem.setSelected(av.isShowDBRefs());
autoCalculate.setSelected(av.autoCalculateConsensus);
sortByTree.setSelected(av.sortByTree);
listenToViewSelections.setSelected(av.followSelection);
@Override
public void centreColumnLabels_actionPerformed(ActionEvent e)
{
- viewport.centreColumnLabels = centreColumnLabelsMenuItem.getState();
+ viewport.setCentreColumnLabels(centreColumnLabelsMenuItem.getState());
alignPanel.paintAlignment(true);
}
scaleLeft.setVisible(wrapMenuItem.isSelected());
scaleRight.setVisible(wrapMenuItem.isSelected());
viewport.setWrapAlignment(wrapMenuItem.isSelected());
- alignPanel.setWrapAlignment(wrapMenuItem.isSelected());
+ alignPanel.updateLayout();
}
@Override
{
final boolean setVisible = annotationPanelMenuItem.isSelected();
viewport.setShowAnnotation(setVisible);
- alignPanel.setAnnotationVisible(setVisible);
this.showAllSeqAnnotations.setEnabled(setVisible);
this.hideAllSeqAnnotations.setEnabled(setVisible);
this.showAllAlAnnotations.setEnabled(setVisible);
this.hideAllAlAnnotations.setEnabled(setVisible);
+ alignPanel.updateLayout();
}
@Override
@Override
protected void showDbRefs_actionPerformed(ActionEvent e)
{
- viewport.setShowDbRefs(showDbRefsMenuitem.isSelected());
+ viewport.setShowDBRefs(showDbRefsMenuitem.isSelected());
}
/*
@Override
protected void showNpFeats_actionPerformed(ActionEvent e)
{
- viewport.setShowNpFeats(showNpFeatsMenuitem.isSelected());
+ viewport.setShowNPFeats(showNpFeatsMenuitem.isSelected());
}
/**
import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
import jalview.analysis.NJTree;
import jalview.api.AlignViewportI;
+import jalview.api.ViewStyleI;
import jalview.bin.Cache;
import jalview.commands.CommandI;
import jalview.datamodel.AlignmentI;
import jalview.ws.params.AutoCalcSetting;
import java.awt.Container;
+import java.awt.Dimension;
import java.awt.Font;
import java.awt.Rectangle;
import java.util.ArrayList;
setShowAnnotation(Cache.getDefault("SHOW_ANNOTATIONS", true));
setRightAlignIds(Cache.getDefault("RIGHT_ALIGN_IDS", false));
- centreColumnLabels = Cache.getDefault("CENTRE_COLUMN_LABELS", false);
+ setCentreColumnLabels(Cache.getDefault("CENTRE_COLUMN_LABELS", false));
autoCalculateConsensus = Cache.getDefault("AUTO_CALC_CONSENSUS", true);
setPadGaps(Cache.getDefault("PAD_GAPS", true));
- shownpfeats = Cache.getDefault("SHOW_NPFEATS_TOOLTIP", true);
- showdbrefs = Cache.getDefault("SHOW_DBREFS_TOOLTIP", true);
+ setShowNPFeats(Cache.getDefault("SHOW_NPFEATS_TOOLTIP", true));
+ setShowDBRefs(Cache.getDefault("SHOW_DBREFS_TOOLTIP", true));
viewStyle.setSeqNameItalics(Cache.getDefault("ID_ITALICS", true));
viewStyle.setWrapAlignment(Cache.getDefault("WRAP_ALIGNMENT", false));
viewStyle.setShowUnconserved(Cache
}
/**
- * centre columnar annotation labels in displayed alignment annotation TODO:
- * add to jalviewXML and annotation display settings
- */
- boolean centreColumnLabels = false;
-
- private boolean showdbrefs;
-
- private boolean shownpfeats;
-
- // --------END Structure Conservation
-
- /**
* get the consensus sequence as displayed under the PID consensus annotation
* row.
*
Container c = new Container();
java.awt.FontMetrics fm = c.getFontMetrics(font);
- setCharHeight(fm.getHeight());
- setCharWidth(fm.charWidth('M'));
+ int w = viewStyle.getCharWidth(), ww = fm.charWidth('M'), h = viewStyle
+ .getCharHeight();
+ // only update width/height if the new font won't fit
+ if (h < fm.getHeight())
+ {
+ setCharHeight(fm.getHeight());
+ }
+ if (w < ww)
+ {
+ setCharWidth(ww);
+ }
+ viewStyle.setFontName(font.getName());
+ viewStyle.setFontStyle(font.getStyle());
+ viewStyle.setFontSize(font.getSize());
+
validCharWidth = true;
}
+ @Override
+ public void setViewStyle(ViewStyleI settingsForView)
+ {
+ super.setViewStyle(settingsForView);
+ setFont(new Font(viewStyle.getFontName(), viewStyle.getFontStyle(),
+ viewStyle.getFontSize()));
+
+ }
/**
* DOCUMENT ME!
*
return false;
}
- public boolean getCentreColumnLabels()
- {
- return centreColumnLabels;
- }
-
- public void setCentreColumnLabels(boolean centrecolumnlabels)
- {
- centreColumnLabels = centrecolumnlabels;
- }
-
- /**
- * enable or disable the display of Database Cross References in the sequence
- * ID tooltip
- */
- public void setShowDbRefs(boolean show)
- {
- showdbrefs = show;
- }
-
- /**
- *
- * @return true if Database References are to be displayed on tooltips.
- */
- public boolean isShowDbRefs()
- {
- return showdbrefs;
- }
-
- /**
- *
- * @return true if Non-positional features are to be displayed on tooltips.
- */
- public boolean isShowNpFeats()
- {
- return shownpfeats;
- }
-
- /**
- * enable or disable the display of Non-Positional sequence features in the
- * sequence ID tooltip
- *
- * @param show
- */
- public void setShowNpFeats(boolean show)
- {
- shownpfeats = show;
- }
-
-
/**
* when set, view will scroll to show the highlighted position
*/
{
this.annotationColumnSelectionState = currentAnnotationColumnSelectionState;
}
+
+ @Override
+ public void setIdWidth(int i)
+ {
+ super.setIdWidth(i);
+ AlignmentPanel ap = getAlignPanel();
+ if (ap != null)
+ {
+ // modify GUI elements to reflect geometry change
+ Dimension idw = getAlignPanel().getIdPanel().getIdCanvas()
+ .getPreferredSize();
+ idw.width = i;
+ getAlignPanel().getIdPanel().getIdCanvas().setPreferredSize(idw);
+ }
+ }
}
setScrollValues(0, 0);
- setAnnotationVisible(av.isShowAnnotation());
-
hscroll.addAdjustmentListener(this);
vscroll.addAdjustmentListener(this);
});
fontChanged();
adjustAnnotationHeight();
-
+ updateLayout();
}
@Override
getAnnotationPanel().adjustPanelHeight();
Dimension d = calculateIdWidth();
+
d.setSize(d.width + 4, d.height);
getIdPanel().getIdCanvas().setPreferredSize(d);
hscrollFillerPanel.setPreferredSize(d);
public Dimension calculateIdWidth()
{
// calculate sensible default width when no preference is available
-
- int afwidth = (alignFrame != null ? alignFrame.getWidth() : 300);
- int maxwidth = Math.max(20,
- Math.min(afwidth - 200, 2 * afwidth / 3));
- return calculateIdWidth(maxwidth);
+ Dimension r = null;
+ if (av.getIdWidth() < 0)
+ {
+ int afwidth = (alignFrame != null ? alignFrame.getWidth() : 300);
+ int maxwidth = Math.max(20, Math.min(afwidth - 200, 2 * afwidth / 3));
+ r = calculateIdWidth(maxwidth);
+ av.setIdWidth(r.width);
+ }
+ else
+ {
+ r = new Dimension();
+ r.width = av.getIdWidth();
+ r.height = 0;
+ }
+ return r;
}
/**
}
/**
- * DOCUMENT ME!
+ * update alignment layout for viewport settings
*
* @param wrap
* DOCUMENT ME!
*/
- public void setWrapAlignment(boolean wrap)
+ public void updateLayout()
{
+ fontChanged();
+ setAnnotationVisible(av.isShowAnnotation());
+ boolean wrap = av.getWrapAlignment();
av.startSeq = 0;
scalePanelHolder.setVisible(!wrap);
hscroll.setVisible(!wrap);
{
text = new FeaturesFile().printGFFFormat(ap.av.getAlignment()
.getDataset().getSequencesArray(), ap.getFeatureRenderer()
- .getDisplayedFeatureCols(), true, ap.av.isShowNpFeats());// ap.av.featuresDisplayed//);
+ .getDisplayedFeatureCols(), true, ap.av.isShowNPFeats());// ap.av.featuresDisplayed//);
}
else
{
text = new FeaturesFile().printJalviewFormat(ap.av.getAlignment()
.getDataset().getSequencesArray(), ap.getFeatureRenderer()
- .getDisplayedFeatureCols(), true, ap.av.isShowNpFeats()); // ap.av.featuresDisplayed);
+ .getDisplayedFeatureCols(), true, ap.av.isShowNPFeats()); // ap.av.featuresDisplayed);
}
}
else
StringBuffer tip = new StringBuffer(64);
seqAnnotReport
.createSequenceAnnotationReport(tip, sequence,
- av.isShowDbRefs(), av.isShowNpFeats(),
+ av.isShowDBRefs(), av.isShowNPFeats(),
sp.seqCanvas.fr.getMinMax());
setToolTipText("<html>" + sequence.getDisplayId(true) + " "
+ tip.toString() + "</html>");
{
active = true;
- Dimension d = ap.getIdPanel().getIdCanvas().getPreferredSize();
+ int curwidth = ap.getAlignViewport().getIdWidth();
int dif = evt.getX() - oldX;
- if (((d.width + dif) > 20) || (dif > 0))
+ if (((curwidth + dif) > 20) || (dif > 0))
{
- ap.getIdPanel().getIdCanvas().setPreferredSize(new Dimension(d.width + dif,
- d.height));
+ ap.getAlignViewport().setIdWidth(curwidth + dif);
+
ap.paintAlignment(true);
}
view.setNormaliseSequenceLogo(av.isNormaliseSequenceLogo());
view.setShowGroupConsensus(av.isShowGroupConsensus());
view.setShowGroupConservation(av.isShowGroupConservation());
- view.setShowNPfeatureTooltip(av.isShowNpFeats());
- view.setShowDbRefTooltip(av.isShowDbRefs());
+ view.setShowNPfeatureTooltip(av.isShowNPFeats());
+ view.setShowDbRefTooltip(av.isShowDBRefs());
view.setFollowHighlight(av.followHighlight);
view.setFollowSelection(av.followSelection);
view.setIgnoreGapsinConsensus(av.isIgnoreGapsConsensus());
af.viewport.setRightAlignIds(view.getRightAlignIds());
af.viewport.setFont(new java.awt.Font(view.getFontName(), view
.getFontStyle(), view.getFontSize()));
- af.alignPanel.fontChanged();
af.viewport.setRenderGaps(view.getRenderGaps());
af.viewport.setWrapAlignment(view.getWrapAlignment());
- af.alignPanel.setWrapAlignment(view.getWrapAlignment());
af.viewport.setShowAnnotation(view.getShowAnnotation());
- af.alignPanel.setAnnotationVisible(view.getShowAnnotation());
af.viewport.setShowBoxes(view.getShowBoxes());
.isShowUnconserved() : false);
af.viewport.setStartRes(view.getStartRes());
af.viewport.setStartSeq(view.getStartSeq());
-
+ af.alignPanel.updateLayout();
ColourSchemeI cs = null;
// apply colourschemes
if (view.getBgColour() != null)
}
if (view.hasShowDbRefTooltip())
{
- af.viewport.setShowDbRefs(view.getShowDbRefTooltip());
+ af.viewport.setShowDBRefs(view.getShowDbRefTooltip());
}
if (view.hasShowNPfeatureTooltip())
{
- af.viewport.setShowNpFeats(view.hasShowNPfeatureTooltip());
+ af.viewport.setShowNPFeats(view.hasShowNPfeatureTooltip());
}
if (view.hasShowGroupConsensus())
{
af.viewport.setShowJVSuffix(view.getShowFullId());
af.viewport.setFont(new java.awt.Font(view.getFontName(), view
.getFontStyle(), view.getFontSize()));
- af.alignPanel.fontChanged();
af.viewport.setRenderGaps(view.getRenderGaps());
af.viewport.setWrapAlignment(view.getWrapAlignment());
- af.alignPanel.setWrapAlignment(view.getWrapAlignment());
- af.viewport.setShowAnnotation(view.getShowAnnotation());
- af.alignPanel.setAnnotationVisible(view.getShowAnnotation());
+
+ af.viewport.setShowAnnotation(view.isShowAnnotation());
af.viewport.setShowBoxes(view.getShowBoxes());
af.viewport.setShowText(view.getShowText());
af.viewport.setGlobalColourScheme(cs);
af.viewport.setColourAppliesToAllGroups(false);
+ af.alignPanel.updateLayout();
af.changeColour(cs);
if (view.getConservationSelected() && cs != null)
{
char s = '~';
// Need to find the sequence position here.
- if (av.validCharWidth)
+ if (av.isValidCharWidth())
{
for (int i = start; i <= end; i++)
{
graphics.setColor(Color.black);
graphics.fillRect(x1, y1, av.getCharWidth(), av.getCharHeight());
- if (av.validCharWidth)
+ if (av.isValidCharWidth())
{
graphics.setColor(Color.white);
boolean validRes = false;
boolean validEnd = false;
boolean labelAllCols = false;
- boolean centreColLabels, centreColLabelsDef = av
- .getCentreColumnLabels();
+ boolean centreColLabels, centreColLabelsDef = av.isCentreColumnLabels();
boolean scaleColLabel = false;
AlignmentAnnotation consensusAnnot = av
.getAlignmentConsensusAnnotation(), structConsensusAnnot = av
{
protected ViewStyleI viewStyle = new ViewStyle();
+
+ /**
+ * @param name
+ * @see jalview.api.ViewStyleI#setFontName(java.lang.String)
+ */
+ public void setFontName(String name)
+ {
+ viewStyle.setFontName(name);
+ }
+
+ /**
+ * @param style
+ * @see jalview.api.ViewStyleI#setFontStyle(int)
+ */
+ public void setFontStyle(int style)
+ {
+ viewStyle.setFontStyle(style);
+ }
+
+ /**
+ * @param size
+ * @see jalview.api.ViewStyleI#setFontSize(int)
+ */
+ public void setFontSize(int size)
+ {
+ viewStyle.setFontSize(size);
+ }
+
+ /**
+ * @return
+ * @see jalview.api.ViewStyleI#getFontStyle()
+ */
+ public int getFontStyle()
+ {
+ return viewStyle.getFontStyle();
+ }
+
+ /**
+ * @return
+ * @see jalview.api.ViewStyleI#getFontName()
+ */
+ public String getFontName()
+ {
+ return viewStyle.getFontName();
+ }
+
+ /**
+ * @return
+ * @see jalview.api.ViewStyleI#getFontSize()
+ */
+ public int getFontSize()
+ {
+ return viewStyle.getFontSize();
+ }
+
/**
* @param upperCasebold
* @see jalview.api.ViewStyleI#setUpperCasebold(boolean)
{
return viewStyle.sameStyle(them);
}
+
+ /**
+ * @return
+ * @see jalview.api.ViewStyleI#getIdWidth()
+ */
+ public int getIdWidth()
+ {
+ return viewStyle.getIdWidth();
+ }
+
+ /**
+ * @param i
+ * @see jalview.api.ViewStyleI#setIdWidth(int)
+ */
+ public void setIdWidth(int i)
+ {
+ viewStyle.setIdWidth(i);
+ }
+
+ /**
+ * @return
+ * @see jalview.api.ViewStyleI#isCentreColumnLabels()
+ */
+ public boolean isCentreColumnLabels()
+ {
+ return viewStyle.isCentreColumnLabels();
+ }
+
+ /**
+ * @param centreColumnLabels
+ * @see jalview.api.ViewStyleI#setCentreColumnLabels(boolean)
+ */
+ public void setCentreColumnLabels(boolean centreColumnLabels)
+ {
+ viewStyle.setCentreColumnLabels(centreColumnLabels);
+ }
+
+ /**
+ * @param showdbrefs
+ * @see jalview.api.ViewStyleI#setShowDBRefs(boolean)
+ */
+ public void setShowDBRefs(boolean showdbrefs)
+ {
+ viewStyle.setShowDBRefs(showdbrefs);
+ }
+
+ /**
+ * @return
+ * @see jalview.api.ViewStyleI#isShowDBRefs()
+ */
+ public boolean isShowDBRefs()
+ {
+ return viewStyle.isShowDBRefs();
+ }
+
+ /**
+ * @return
+ * @see jalview.api.ViewStyleI#isShowNPFeats()
+ */
+ public boolean isShowNPFeats()
+ {
+ return viewStyle.isShowNPFeats();
+ }
+
+ /**
+ * @param shownpfeats
+ * @see jalview.api.ViewStyleI#setShowNPFeats(boolean)
+ */
+ public void setShowNPFeats(boolean shownpfeats)
+ {
+ viewStyle.setShowNPFeats(shownpfeats);
+ }
}
int charWidth;
+ int idWidth = -1;
+
/**
* gui state - changes to colour scheme propagated to all groups
*/
private boolean colourAppliesToAllGroups;
/**
+ * centre columnar annotation labels in displayed alignment annotation
+ */
+ boolean centreColumnLabels = false;
+
+ private boolean showdbrefs;
+
+ private boolean shownpfeats;
+
+ // --------END Structure Conservation
+
+ /**
* colour according to the reference sequence defined on the alignment
*/
private boolean colourByReferenceSeq = false;
*/
boolean upperCasebold = false;
+ /**
+ * name of base font for view
+ */
+ private String fontName;
+ /**
+ * size for base font
+ */
+ private int fontSize;
+
public ViewStyle(ViewStyleI viewStyle)
{
ViewStyle.configureFrom(this, viewStyle);
*/
int wrappedWidth;
+ private int fontStyle;
+
/**
* GUI state
*
abovePIDThreshold = b;
}
+
/**
* DOCUMENT ME!
*
{
return equivalent(this, them);
}
+
+ @Override
+ public String getFontName()
+ {
+ return fontName;
+ }
+
+ @Override
+ public int getFontSize()
+ {
+ return fontSize;
+ }
+
+ @Override
+ public int getFontStyle()
+ {
+ return fontStyle;
+ }
+
+ @Override
+ public void setFontName(String name)
+ {
+ fontName = name;
+ }
+
+ @Override
+ public void setFontSize(int size)
+ {
+ fontSize = size;
+
+ }
+
+ @Override
+ public void setFontStyle(int style)
+ {
+ fontStyle = style;
+ }
+
+ @Override
+ public int getIdWidth()
+ {
+ return idWidth;
+ }
+
+ /**
+ * @param idWidth
+ * the idWidth to set
+ */
+ @Override
+ public void setIdWidth(int idWidth)
+ {
+ this.idWidth = idWidth;
+ }
+
+ /**
+ * @return the centreColumnLabels
+ */
+ @Override
+ public boolean isCentreColumnLabels()
+ {
+ return centreColumnLabels;
+ }
+
+ /**
+ * @param centreColumnLabels
+ * the centreColumnLabels to set
+ */
+ @Override
+ public void setCentreColumnLabels(boolean centreColumnLabels)
+ {
+ this.centreColumnLabels = centreColumnLabels;
+ }
+
+ /**
+ * @return the showdbrefs
+ */
+ @Override
+ public boolean isShowDBRefs()
+ {
+ return showdbrefs;
+ }
+
+ /**
+ * @param showdbrefs
+ * the showdbrefs to set
+ */
+ @Override
+ public void setShowDBRefs(boolean showdbrefs)
+ {
+ this.showdbrefs = showdbrefs;
+ }
+
+ /**
+ * @return the shownpfeats
+ */
+ @Override
+ public boolean isShowNPFeats()
+ {
+ return shownpfeats;
+ }
+
+ /**
+ * @param shownpfeats
+ * the shownpfeats to set
+ */
+ @Override
+ public void setShowNPFeats(boolean shownpfeats)
+ {
+ this.shownpfeats = shownpfeats;
+ }
}