import jalview.io.FeaturesFile;
import jalview.io.FileLoader;
import jalview.io.FormatAdapter;
-import jalview.io.HTMLOutput;
+import jalview.io.HtmlSvgOutput;
import jalview.io.IdentifyFile;
import jalview.io.JalviewFileChooser;
import jalview.io.JalviewFileView;
.getKeyCode() <= KeyEvent.VK_NUMPAD9))
&& Character.isDigit(evt.getKeyChar()))
{
- alignPanel.seqPanel.numberPressed(evt.getKeyChar());
+ alignPanel.getSeqPanel().numberPressed(evt.getKeyChar());
}
switch (evt.getKeyCode())
}
if (viewport.cursorMode)
{
- alignPanel.seqPanel.moveCursor(0, 1);
+ alignPanel.getSeqPanel().moveCursor(0, 1);
}
break;
}
if (viewport.cursorMode)
{
- alignPanel.seqPanel.moveCursor(0, -1);
+ alignPanel.getSeqPanel().moveCursor(0, -1);
}
break;
case KeyEvent.VK_LEFT:
if (evt.isAltDown() || !viewport.cursorMode)
{
- slideSequences(false, alignPanel.seqPanel.getKeyboardNo1());
+ slideSequences(false, alignPanel.getSeqPanel().getKeyboardNo1());
}
else
{
- alignPanel.seqPanel.moveCursor(-1, 0);
+ alignPanel.getSeqPanel().moveCursor(-1, 0);
}
break;
case KeyEvent.VK_RIGHT:
if (evt.isAltDown() || !viewport.cursorMode)
{
- slideSequences(true, alignPanel.seqPanel.getKeyboardNo1());
+ slideSequences(true, alignPanel.getSeqPanel().getKeyboardNo1());
}
else
{
- alignPanel.seqPanel.moveCursor(1, 0);
+ alignPanel.getSeqPanel().moveCursor(1, 0);
}
break;
case KeyEvent.VK_SPACE:
if (viewport.cursorMode)
{
- alignPanel.seqPanel.insertGapAtCursor(evt.isControlDown()
+ alignPanel.getSeqPanel().insertGapAtCursor(evt.isControlDown()
|| evt.isShiftDown() || evt.isAltDown());
}
break;
}
else
{
- alignPanel.seqPanel.deleteGapAtCursor(evt.isControlDown()
+ alignPanel.getSeqPanel().deleteGapAtCursor(evt.isControlDown()
|| evt.isShiftDown() || evt.isAltDown());
}
case KeyEvent.VK_S:
if (viewport.cursorMode)
{
- alignPanel.seqPanel.setCursorRow();
+ alignPanel.getSeqPanel().setCursorRow();
}
break;
case KeyEvent.VK_C:
if (viewport.cursorMode && !evt.isControlDown())
{
- alignPanel.seqPanel.setCursorColumn();
+ alignPanel.getSeqPanel().setCursorColumn();
}
break;
case KeyEvent.VK_P:
if (viewport.cursorMode)
{
- alignPanel.seqPanel.setCursorPosition();
+ alignPanel.getSeqPanel().setCursorPosition();
}
break;
case KeyEvent.VK_COMMA:
if (viewport.cursorMode)
{
- alignPanel.seqPanel.setCursorRowAndColumn();
+ alignPanel.getSeqPanel().setCursorRowAndColumn();
}
break;
case KeyEvent.VK_Q:
if (viewport.cursorMode)
{
- alignPanel.seqPanel.setSelectionAreaAtCursor(true);
+ alignPanel.getSeqPanel().setSelectionAreaAtCursor(true);
}
break;
case KeyEvent.VK_M:
if (viewport.cursorMode)
{
- alignPanel.seqPanel.setSelectionAreaAtCursor(false);
+ alignPanel.getSeqPanel().setSelectionAreaAtCursor(false);
}
break;
{ (viewport.cursorMode ? "on" : "off") }));
if (viewport.cursorMode)
{
- alignPanel.seqPanel.seqCanvas.cursorX = viewport.startRes;
- alignPanel.seqPanel.seqCanvas.cursorY = viewport.startSeq;
+ alignPanel.getSeqPanel().seqCanvas.cursorX = viewport.startRes;
+ alignPanel.getSeqPanel().seqCanvas.cursorY = viewport.startSeq;
}
- alignPanel.seqPanel.seqCanvas.repaint();
+ alignPanel.getSeqPanel().seqCanvas.repaint();
break;
case KeyEvent.VK_F1:
abovePIDThreshold.setSelected(av.getAbovePIDThreshold());
conservationMenuItem.setSelected(av.getConservationSelected());
seqLimits.setSelected(av.getShowJVSuffix());
- idRightAlign.setSelected(av.rightAlignIds);
+ idRightAlign.setSelected(av.isRightAlignIds());
centreColumnLabelsMenuItem.setState(av.centreColumnLabels);
renderGapsMenuItem.setSelected(av.renderGaps);
wrapMenuItem.setSelected(av.wrapAlignment);
scaleAbove.setVisible(av.wrapAlignment);
scaleLeft.setVisible(av.wrapAlignment);
scaleRight.setVisible(av.wrapAlignment);
- annotationPanelMenuItem.setState(av.showAnnotation);
+ annotationPanelMenuItem.setState(av.isShowAnnotation());
/*
* Show/hide annotations only enabled if annotation panel is shown
*/
public FeatureRenderer getFeatureRenderer()
{
- return alignPanel.seqPanel.seqCanvas.getFeatureRenderer();
+ return alignPanel.getSeqPanel().seqCanvas.getFeatureRenderer();
}
@Override
@Override
protected void htmlMenuItem_actionPerformed(ActionEvent e)
{
- new HTMLOutput(alignPanel,
- alignPanel.seqPanel.seqCanvas.getSequenceRenderer(),
- alignPanel.seqPanel.seqCanvas.getFeatureRenderer());
+ // new HTMLOutput(alignPanel,
+ // alignPanel.getSeqPanel().seqCanvas.getSequenceRenderer(),
+ // alignPanel.getSeqPanel().seqCanvas.getFeatureRenderer());
+ new HtmlSvgOutput(alignPanel);
}
public void createImageMap(File file, String image)
public void exportAnnotations_actionPerformed(ActionEvent e)
{
new AnnotationExporter().exportAnnotations(alignPanel,
- viewport.showAnnotation ? viewport.getAlignment()
+ viewport.isShowAnnotation() ? viewport.getAlignment()
.getAlignmentAnnotation() : null, viewport
.getAlignment().getGroups(), ((Alignment) viewport
.getAlignment()).alignmentProperties);
if (viewport.cursorMode)
{
sg.add(viewport.getAlignment().getSequenceAt(
- alignPanel.seqPanel.seqCanvas.cursorY));
+ alignPanel.getSeqPanel().seqCanvas.cursorY));
}
else if (viewport.getSelectionGroup() != null
&& viewport.getSelectionGroup().getSize() != viewport
{
if (viewport.cursorMode)
{
- alignPanel.seqPanel.moveCursor(size, 0);
+ alignPanel.getSeqPanel().moveCursor(size, 0);
}
else
{
{
if (viewport.cursorMode)
{
- alignPanel.seqPanel.moveCursor(-size, 0);
+ alignPanel.getSeqPanel().moveCursor(-size, 0);
}
else
{
// >>>This is a fix for the moment, until a better solution is
// found!!<<<
- af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer()
+ af.alignPanel.getSeqPanel().seqCanvas.getFeatureRenderer()
.transferSettings(
- alignPanel.seqPanel.seqCanvas.getFeatureRenderer());
+ alignPanel.getSeqPanel().seqCanvas.getFeatureRenderer());
// TODO: maintain provenance of an alignment, rather than just make the
// title a concatenation of operations.
// >>>This is a fix for the moment, until a better solution is
// found!!<<<
- af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer()
+ af.alignPanel.getSeqPanel().seqCanvas.getFeatureRenderer()
.transferSettings(
- alignPanel.seqPanel.seqCanvas.getFeatureRenderer());
+ alignPanel.getSeqPanel().seqCanvas.getFeatureRenderer());
// TODO: maintain provenance of an alignment, rather than just make the
// title a concatenation of operations.
{
if (viewport.cursorMode)
{
- alignPanel.seqPanel.keyboardNo1 = null;
- alignPanel.seqPanel.keyboardNo2 = null;
+ alignPanel.getSeqPanel().keyboardNo1 = null;
+ alignPanel.getSeqPanel().keyboardNo2 = null;
}
viewport.setSelectionGroup(null);
viewport.getColumnSelection().clear();
viewport.setSelectionGroup(null);
- alignPanel.seqPanel.seqCanvas.highlightSearchResults(null);
- alignPanel.idPanel.idCanvas.searchResults = null;
+ alignPanel.getSeqPanel().seqCanvas.highlightSearchResults(null);
+ alignPanel.getIdPanel().getIdCanvas().searchResults = null;
alignPanel.paintAlignment(true);
PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
viewport.sendSelection();
{
viewport.setShowJVSuffix(seqLimits.isSelected());
- alignPanel.idPanel.idCanvas.setPreferredSize(alignPanel
+ alignPanel.getIdPanel().getIdCanvas().setPreferredSize(alignPanel
.calculateIdWidth());
alignPanel.paintAlignment(true);
}
@Override
public void idRightAlign_actionPerformed(ActionEvent e)
{
- viewport.rightAlignIds = idRightAlign.isSelected();
+ viewport.setRightAlignIds(idRightAlign.isSelected());
alignPanel.paintAlignment(true);
}
if (viewport.followHighlight = this.followHighlightMenuItem.getState())
{
alignPanel.scrollToPosition(
- alignPanel.seqPanel.seqCanvas.searchResults, false);
+ alignPanel.getSeqPanel().seqCanvas.searchResults, false);
}
}
try
{
featuresFile = new FeaturesFile(file, type).parse(viewport
- .getAlignment().getDataset(), alignPanel.seqPanel.seqCanvas
+ .getAlignment().getDataset(), alignPanel.getSeqPanel().seqCanvas
.getFeatureRenderer().featureColours, false,
jalview.bin.Cache.getDefault("RELAXEDSEQIDMATCHING", false));
} catch (Exception ex)
{
viewport.showSequenceFeatures = true;
showSeqFeatures.setSelected(true);
- if (alignPanel.seqPanel.seqCanvas.fr != null)
+ if (alignPanel.getSeqPanel().seqCanvas.fr != null)
{
// update the min/max ranges where necessary
- alignPanel.seqPanel.seqCanvas.fr.findAllFeatures(true);
+ alignPanel.getSeqPanel().seqCanvas.fr.findAllFeatures(true);
}
if (featureSettings != null)
{
boolean showSequenceFeatures = false;
- boolean showAnnotation = true;
+ private boolean showAnnotation = true;
SequenceAnnotationOrder sortAnnotationsBy = null;
Color textColour2 = Color.white;
- boolean rightAlignIds = false;
+ private boolean rightAlignIds = false;
/**
* Creates a new AlignViewport object.
antiAlias = Cache.getDefault("ANTI_ALIAS", false);
showJVSuffix = Cache.getDefault("SHOW_JVSUFFIX", true);
- showAnnotation = Cache.getDefault("SHOW_ANNOTATIONS", true);
+ setShowAnnotation(Cache.getDefault("SHOW_ANNOTATIONS", true));
- rightAlignIds = Cache.getDefault("RIGHT_ALIGN_IDS", false);
+ setRightAlignIds(Cache.getDefault("RIGHT_ALIGN_IDS", false));
centreColumnLabels = Cache.getDefault("CENTRE_COLUMN_LABELS", false);
autoCalculateConsensus = Cache.getDefault("AUTO_CALC_CONSENSUS", true);
*/
public boolean getShowAnnotation()
{
- return showAnnotation;
+ return isShowAnnotation();
}
/**
{
this.showAutocalculatedAbove = showAutocalculatedAbove;
}
+
+ public boolean isShowAnnotation()
+ {
+ return showAnnotation;
+ }
+
+ public boolean isRightAlignIds()
+ {
+ return rightAlignIds;
+ }
+
+ public void setRightAlignIds(boolean rightAlignIds)
+ {
+ this.rightAlignIds = rightAlignIds;
+ }
}
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.jbgui.GAlignmentPanel;
+import jalview.math.AlignmentDimension;
import jalview.schemes.ResidueProperties;
import jalview.structure.StructureSelectionManager;
import jalview.util.MessageManager;
OverviewPanel overviewPanel;
- SeqPanel seqPanel;
+ private SeqPanel seqPanel;
- IdPanel idPanel;
+ private IdPanel idPanel;
+ private boolean headless;
IdwidthAdjuster idwidthAdjuster;
/** DOCUMENT ME!! */
public AlignFrame alignFrame;
- ScalePanel scalePanel;
+ private ScalePanel scalePanel;
- AnnotationPanel annotationPanel;
+ private AnnotationPanel annotationPanel;
- AnnotationLabels alabels;
+ private AnnotationLabels alabels;
// this value is set false when selection area being dragged
boolean fastPaint = true;
{
alignFrame = af;
this.av = av;
- seqPanel = new SeqPanel(av, this);
- idPanel = new IdPanel(av, this);
+ setSeqPanel(new SeqPanel(av, this));
+ setIdPanel(new IdPanel(av, this));
- scalePanel = new ScalePanel(av, this);
+ setScalePanel(new ScalePanel(av, this));
- idPanelHolder.add(idPanel, BorderLayout.CENTER);
+ idPanelHolder.add(getIdPanel(), BorderLayout.CENTER);
idwidthAdjuster = new IdwidthAdjuster(this);
idSpaceFillerPanel1.add(idwidthAdjuster, BorderLayout.CENTER);
- annotationPanel = new AnnotationPanel(this);
- alabels = new AnnotationLabels(this);
+ setAnnotationPanel(new AnnotationPanel(this));
+ setAlabels(new AnnotationLabels(this));
- annotationScroller.setViewportView(annotationPanel);
- annotationSpaceFillerHolder.add(alabels, BorderLayout.CENTER);
+ annotationScroller.setViewportView(getAnnotationPanel());
+ annotationSpaceFillerHolder.add(getAlabels(), BorderLayout.CENTER);
- scalePanelHolder.add(scalePanel, BorderLayout.CENTER);
- seqPanelHolder.add(seqPanel, BorderLayout.CENTER);
+ scalePanelHolder.add(getScalePanel(), BorderLayout.CENTER);
+ seqPanelHolder.add(getSeqPanel(), BorderLayout.CENTER);
setScrollValues(0, 0);
idSpaceFillerPanel1.setPreferredSize(new Dimension(10, av.charHeight
+ fm.getDescent()));
- idPanel.idCanvas.gg = null;
- seqPanel.seqCanvas.img = null;
- annotationPanel.adjustPanelHeight();
+ getIdPanel().getIdCanvas().gg = null;
+ getSeqPanel().seqCanvas.img = null;
+ getAnnotationPanel().adjustPanelHeight();
Dimension d = calculateIdWidth();
d.setSize(d.width + 4, d.height);
- idPanel.idCanvas.setPreferredSize(d);
+ getIdPanel().getIdCanvas().setPreferredSize(d);
hscrollFillerPanel.setPreferredSize(d);
if (overviewPanel != null)
if (al.getAlignmentAnnotation() != null)
{
- fm = c.getFontMetrics(alabels.getFont());
+ fm = c.getFontMetrics(getAlabels().getFont());
while (i < al.getAlignmentAnnotation().length)
{
public void highlightSearchResults(SearchResults results)
{
scrollToPosition(results);
- seqPanel.seqCanvas.highlightSearchResults(results);
+ getSeqPanel().seqCanvas.highlightSearchResults(results);
}
/**
void scrollToWrappedVisible(int res)
{
- int cwidth = seqPanel.seqCanvas
- .getWrappedCanvasWidth(seqPanel.seqCanvas.getWidth());
+ int cwidth = getSeqPanel().seqCanvas
+ .getWrappedCanvasWidth(getSeqPanel().seqCanvas.getWidth());
if (res < av.getStartRes() || res >= (av.getStartRes() + cwidth))
{
vscroll.setValue((res / cwidth));
*/
protected void validateAnnotationDimensions(boolean adjustPanelHeight)
{
- int height = annotationPanel.adjustPanelHeight();
+ int height = getAnnotationPanel().adjustPanelHeight();
int theight = av.getCharHeight()
* (av.getAlignment().getHeight() + (!av.hasHiddenRows() ? 0
annotationScroller.setVisible(false);
annotationSpaceFillerHolder.setVisible(false);
}
- else if (av.showAnnotation)
+ else if (av.isShowAnnotation())
{
annotationScroller.setVisible(true);
annotationSpaceFillerHolder.setVisible(true);
width = av.getColumnSelection().findColumnPosition(width);
}
- av.setEndRes((x + (seqPanel.seqCanvas.getWidth() / av.charWidth)) - 1);
+ av.setEndRes((x + (getSeqPanel().seqCanvas.getWidth() / av.charWidth)) - 1);
- hextent = seqPanel.seqCanvas.getWidth() / av.charWidth;
- vextent = seqPanel.seqCanvas.getHeight() / av.charHeight;
+ hextent = getSeqPanel().seqCanvas.getWidth() / av.charWidth;
+ vextent = getSeqPanel().seqCanvas.getHeight() / av.charHeight;
if (hextent > width)
{
{
int x = hscroll.getValue();
av.setStartRes(x);
- av.setEndRes((x + (seqPanel.seqCanvas.getWidth() / av.getCharWidth())) - 1);
+ av.setEndRes((x + (getSeqPanel().seqCanvas.getWidth() / av.getCharWidth())) - 1);
}
if (evt.getSource() == vscroll)
{
if (offy > -1)
{
- int rowSize = seqPanel.seqCanvas
- .getWrappedCanvasWidth(seqPanel.seqCanvas.getWidth());
+ int rowSize = getSeqPanel().seqCanvas
+ .getWrappedCanvasWidth(getSeqPanel().seqCanvas.getWidth());
av.setStartRes(offy * rowSize);
av.setEndRes((offy + 1) * rowSize);
}
{
av.setStartSeq(offy);
av.setEndSeq(offy
- + (seqPanel.seqCanvas.getHeight() / av.getCharHeight()));
+ + (getSeqPanel().seqCanvas.getHeight() / av.getCharHeight()));
}
}
if (scrollX != 0 || scrollY != 0)
{
- idPanel.idCanvas.fastPaint(scrollY);
- seqPanel.seqCanvas.fastPaint(scrollX, scrollY);
- scalePanel.repaint();
+ getIdPanel().getIdCanvas().fastPaint(scrollY);
+ getSeqPanel().seqCanvas.fastPaint(scrollX, scrollY);
+ getScalePanel().repaint();
if (av.getShowAnnotation() && scrollX != 0)
{
- annotationPanel.fastPaint(scrollX);
+ getAnnotationPanel().fastPaint(scrollX);
}
}
}
{
invalidate();
- Dimension d = idPanel.idCanvas.getPreferredSize();
+ Dimension d = getIdPanel().getIdCanvas().getPreferredSize();
idPanelHolder.setPreferredSize(d);
hscrollFillerPanel.setPreferredSize(new Dimension(d.width, 12));
validate();
maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
}
- int canvasWidth = seqPanel.seqCanvas
- .getWrappedCanvasWidth(seqPanel.seqCanvas.getWidth());
+ int canvasWidth = getSeqPanel().seqCanvas
+ .getWrappedCanvasWidth(getSeqPanel().seqCanvas.getWidth());
if (canvasWidth > 0)
{
int max = maxwidth
- / seqPanel.seqCanvas
- .getWrappedCanvasWidth(seqPanel.seqCanvas
+ / getSeqPanel().seqCanvas
+ .getWrappedCanvasWidth(getSeqPanel().seqCanvas
.getWidth()) + 1;
vscroll.setMaximum(max);
vscroll.setUnitIncrement(1);
int pagesHigh = ((av.getAlignment().getHeight() / totalSeq) + 1)
* pheight;
- if (av.showAnnotation)
+ if (av.isShowAnnotation())
{
- pagesHigh += annotationPanel.adjustPanelHeight() + 3;
+ pagesHigh += getAnnotationPanel().adjustPanelHeight() + 3;
}
pagesHigh /= pheight;
// draw Scale
pg.translate(idWidth, 0);
- scalePanel.drawScale(pg, startRes, endRes, pwidth - idWidth,
+ getScalePanel().drawScale(pg, startRes, endRes, pwidth - idWidth,
scaleHeight);
pg.translate(-idWidth, scaleHeight);
Color currentColor = null;
Color currentTextColor = null;
- pg.setFont(idPanel.idCanvas.idfont);
+ pg.setFont(getIdPanel().getIdCanvas().getIdfont());
SequenceI seq;
for (int i = startSeq; i < endSeq; i++)
pg.setColor(currentTextColor);
int xPos = 0;
- if (av.rightAlignIds)
+ if (av.isRightAlignIds())
{
fm = pg.getFontMetrics();
xPos = idWidth
// draw main sequence panel
pg.translate(idWidth, 0);
- seqPanel.seqCanvas.drawPanel(pg, startRes, endRes, startSeq, endSeq, 0);
+ getSeqPanel().seqCanvas.drawPanel(pg, startRes, endRes, startSeq, endSeq, 0);
- if (av.showAnnotation && (endSeq == av.getAlignment().getHeight()))
+ if (av.isShowAnnotation() && (endSeq == av.getAlignment().getHeight()))
{
// draw annotation - need to offset for current scroll position
- int offset = -alabels.scrollOffset;
+ int offset = -getAlabels().getScrollOffset();
pg.translate(0, offset);
pg.translate(-idWidth - 3, (endSeq - startSeq) * av.charHeight + 3);
- alabels.drawComponent(pg, idWidth);
+ getAlabels().drawComponent(pg, idWidth);
pg.translate(idWidth + 3, 0);
- annotationPanel.renderer.drawComponent(annotationPanel, av,
+ getAnnotationPanel().renderer.drawComponent(getAnnotationPanel(), av,
pg, -1, startRes, endRes + 1);
pg.translate(0, -offset);
}
int annotationHeight = 0;
AnnotationLabels labels = null;
- if (av.showAnnotation)
+ if (av.isShowAnnotation())
{
- annotationHeight = annotationPanel.adjustPanelHeight();
+ annotationHeight = getAnnotationPanel().adjustPanelHeight();
labels = new AnnotationLabels(av);
}
maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
}
- int resWidth = seqPanel.seqCanvas.getWrappedCanvasWidth(pwidth
+ int resWidth = getSeqPanel().seqCanvas.getWrappedCanvasWidth(pwidth
- idWidth);
int totalHeight = cHeight * (maxwidth / resWidth + 1);
{
for (int i = 0; i < av.getAlignment().getHeight(); i++)
{
- pg.setFont(idPanel.idCanvas.idfont);
+ pg.setFont(getIdPanel().getIdCanvas().getIdfont());
SequenceI s = av.getAlignment().getSequenceAt(i);
String string = s.getDisplayId(av.getShowJVSuffix());
int xPos = 0;
- if (av.rightAlignIds)
+ if (av.isRightAlignIds())
{
FontMetrics fm = pg.getFontMetrics();
xPos = idWidth - fm.stringWidth(string) - 4;
pg.translate(idWidth, 0);
- seqPanel.seqCanvas.drawWrappedPanel(pg, pwidth - idWidth, totalHeight,
+ getSeqPanel().seqCanvas.drawWrappedPanel(pg, pwidth - idWidth, totalHeight,
0);
if ((pi * pheight) < totalHeight)
*
* @return
*/
- int getVisibleIdWidth()
+ public int getVisibleIdWidth()
{
return getVisibleIdWidth(true);
}
* be returned
* @return
*/
- int getVisibleIdWidth(boolean onscreen)
+ public int getVisibleIdWidth(boolean onscreen)
{
// see if rendering offscreen - check preferences and calc width accordingly
if (!onscreen && Cache.getDefault("FIGURE_AUTOIDWIDTH", false))
if (onscreen
|| (idwidth = Cache.getIntegerProperty("FIGURE_FIXEDIDWIDTH")) == null)
{
- return (idPanel.getWidth() > 0 ? idPanel.getWidth()
+ return (getIdPanel().getWidth() > 0 ? getIdPanel().getWidth()
: calculateIdWidth().width + 4);
}
return idwidth.intValue() + 4;
void makeAlignmentImage(jalview.util.ImageMaker.TYPE type, File file)
{
long progress = System.currentTimeMillis();
- boolean headless = (System.getProperty("java.awt.headless") != null && System
+ headless = (System.getProperty("java.awt.headless") != null && System
.getProperty("java.awt.headless").equals("true"));
if (alignFrame != null && !headless)
{
}
try
{
- int maxwidth = av.getAlignment().getWidth();
- if (av.hasHiddenColumns())
- {
- maxwidth = av.getColumnSelection().findColumnPosition(maxwidth);
- }
-
- int height = ((av.getAlignment().getHeight() + 1) * av.charHeight)
- + scalePanel.getHeight();
- int width = getVisibleIdWidth(false) + (maxwidth * av.charWidth);
-
- if (av.getWrapAlignment())
- {
- height = getWrappedHeight();
- if (headless)
- {
- // need to obtain default alignment width and then add in any
- // additional allowance for id margin
- // this duplicates the calculation in getWrappedHeight but adjusts for
- // offscreen idWith
- width = alignFrame.getWidth() - vscroll.getPreferredSize().width
- - alignFrame.getInsets().left
- - alignFrame.getInsets().right - getVisibleIdWidth()
- + getVisibleIdWidth(false);
- }
- else
- {
- width = seqPanel.getWidth() + getVisibleIdWidth(false);
- }
-
- }
- else if (av.getShowAnnotation())
- {
- height += annotationPanel.adjustPanelHeight() + 3;
- }
-
+ AlignmentDimension aDimension = getAlignmentDimension();
try
{
-
jalview.util.ImageMaker im;
final String imageAction, imageTitle;
if (type == jalview.util.ImageMaker.TYPE.PNG)
imageTitle = alignFrame.getTitle();
}
- im = new jalview.util.ImageMaker(this, type, imageAction, width,
- height, file, imageTitle);
+ im = new jalview.util.ImageMaker(this, type, imageAction,
+ aDimension.getWidth(), aDimension.getHeight(), file,
+ imageTitle);
if (av.getWrapAlignment())
{
if (im.getGraphics() != null)
{
- printWrappedAlignment(im.getGraphics(), width, height, 0);
+ printWrappedAlignment(im.getGraphics(), aDimension.getWidth(),
+ aDimension.getHeight(), 0);
im.writeImage();
}
}
{
if (im.getGraphics() != null)
{
- printUnwrapped(im.getGraphics(), width, height, 0);
+ printUnwrapped(im.getGraphics(), aDimension.getWidth(),
+ aDimension.getHeight(), 0);
im.writeImage();
}
}
}
}
+ public AlignmentDimension getAlignmentDimension()
+ {
+ int maxwidth = av.getAlignment().getWidth();
+ if (av.hasHiddenColumns())
+ {
+ maxwidth = av.getColumnSelection().findColumnPosition(maxwidth);
+ }
+
+ int height = ((av.getAlignment().getHeight() + 1) * av.charHeight)
+ + getScalePanel().getHeight();
+ int width = getVisibleIdWidth(false) + (maxwidth * av.charWidth);
+
+ if (av.getWrapAlignment())
+ {
+ height = getWrappedHeight();
+ if (headless)
+ {
+ // need to obtain default alignment width and then add in any
+ // additional allowance for id margin
+ // this duplicates the calculation in getWrappedHeight but adjusts for
+ // offscreen idWith
+ width = alignFrame.getWidth() - vscroll.getPreferredSize().width
+ - alignFrame.getInsets().left
+ - alignFrame.getInsets().right - getVisibleIdWidth()
+ + getVisibleIdWidth(false);
+ }
+ else
+ {
+ width = getSeqPanel().getWidth() + getVisibleIdWidth(false);
+ }
+
+ }
+ else if (av.getShowAnnotation())
+ {
+ height += getAnnotationPanel().adjustPanelHeight() + 3;
+ }
+ return new AlignmentDimension(width, height);
+
+ }
+
/**
* DOCUMENT ME!
*/
int getWrappedHeight()
{
- int seqPanelWidth = seqPanel.seqCanvas.getWidth();
+ int seqPanelWidth = getSeqPanel().seqCanvas.getWidth();
if (System.getProperty("java.awt.headless") != null
&& System.getProperty("java.awt.headless").equals("true"))
- alignFrame.getInsets().left - alignFrame.getInsets().right;
}
- int chunkWidth = seqPanel.seqCanvas
+ int chunkWidth = getSeqPanel().seqCanvas
.getWrappedCanvasWidth(seqPanelWidth);
int hgap = av.charHeight;
}
int annotationHeight = 0;
- if (av.showAnnotation)
+ if (av.isShowAnnotation())
{
- annotationHeight = annotationPanel.adjustPanelHeight();
+ annotationHeight = getAnnotationPanel().adjustPanelHeight();
}
int cHeight = av.getAlignment().getHeight() * av.charHeight + hgap
*/
public void closePanel()
{
- PaintRefresher.RemoveComponent(seqPanel.seqCanvas);
- PaintRefresher.RemoveComponent(idPanel.idCanvas);
+ PaintRefresher.RemoveComponent(getSeqPanel().seqCanvas);
+ PaintRefresher.RemoveComponent(getIdPanel().getIdCanvas());
PaintRefresher.RemoveComponent(this);
if (av != null)
{
jalview.structure.StructureSelectionManager ssm = av
.getStructureSelectionManager();
- ssm.removeStructureViewerListener(seqPanel, null);
- ssm.removeSelectionListener(seqPanel);
+ ssm.removeStructureViewerListener(getSeqPanel(), null);
+ ssm.removeSelectionListener(getSeqPanel());
av.setAlignment(null);
av = null;
}
public void updateFeatureRenderer(FeatureRenderer fr)
{
- fr.transferSettings(seqPanel.seqCanvas.getFeatureRenderer());
+ fr.transferSettings(getSeqPanel().seqCanvas.getFeatureRenderer());
}
public void updateFeatureRendererFrom(FeatureRenderer fr)
{
- if (seqPanel.seqCanvas.getFeatureRenderer() != null)
+ if (getSeqPanel().seqCanvas.getFeatureRenderer() != null)
{
- seqPanel.seqCanvas.getFeatureRenderer().transferSettings(fr);
+ getSeqPanel().seqCanvas.getFeatureRenderer().transferSettings(fr);
}
}
+
+ public ScalePanel getScalePanel()
+ {
+ return scalePanel;
+ }
+
+ public void setScalePanel(ScalePanel scalePanel)
+ {
+ this.scalePanel = scalePanel;
+ }
+
+ public SeqPanel getSeqPanel()
+ {
+ return seqPanel;
+ }
+
+ public void setSeqPanel(SeqPanel seqPanel)
+ {
+ this.seqPanel = seqPanel;
+ }
+
+ public AnnotationPanel getAnnotationPanel()
+ {
+ return annotationPanel;
+ }
+
+ public void setAnnotationPanel(AnnotationPanel annotationPanel)
+ {
+ this.annotationPanel = annotationPanel;
+ }
+
+ public AnnotationLabels getAlabels()
+ {
+ return alabels;
+ }
+
+ public void setAlabels(AnnotationLabels alabels)
+ {
+ this.alabels = alabels;
+ }
+
+ public IdPanel getIdPanel()
+ {
+ return idPanel;
+ }
+
+ public void setIdPanel(IdPanel idPanel)
+ {
+ this.idPanel = idPanel;
+ }
}
return fcols;
}
Enumeration en = ap.av.featuresDisplayed.keys();
- FeatureRenderer fr = ap.seqPanel.seqCanvas.getFeatureRenderer(); // consider
+ FeatureRenderer fr = ap.getSeqPanel().seqCanvas.getFeatureRenderer(); // consider
// higher
// level
// method ?
int selectedRow;
- int scrollOffset = 0;
+ private int scrollOffset = 0;
Font font = new Font("Arial", Font.PLAIN, 11);
addMouseListener(this);
addMouseMotionListener(this);
- addMouseWheelListener(ap.annotationPanel);
+ addMouseWheelListener(ap.getAnnotationPanel());
}
public AnnotationLabels(AlignViewport av)
*/
public void mousePressed(MouseEvent evt)
{
- getSelectedRow(evt.getY() - scrollOffset);
+ getSelectedRow(evt.getY() - getScrollOffset());
oldY = evt.getY();
}
public void mouseReleased(MouseEvent evt)
{
int start = selectedRow;
- getSelectedRow(evt.getY() - scrollOffset);
+ getSelectedRow(evt.getY() - getScrollOffset());
int end = selectedRow;
if (start != end)
resizePanel = false;
dragEvent = null;
repaint();
- ap.annotationPanel.repaint();
+ ap.getAnnotationPanel().repaint();
}
/**
{
resizePanel = evt.getY() < 10;
- getSelectedRow(evt.getY() - scrollOffset);
+ getSelectedRow(evt.getY() - getScrollOffset());
if (selectedRow > -1
&& ap.av.getAlignment().getAlignmentAnnotation().length > selectedRow)
{
// todo: make the ap scroll to the selection - not necessary, first
// click highlights/scrolls, second selects
- ap.seqPanel.ap.idPanel.highlightSearchResults(null);
+ ap.getSeqPanel().ap.getIdPanel().highlightSearchResults(null);
ap.av.setSelectionGroup(// new SequenceGroup(
aa[selectedRow].groupRef); // );
ap.paintAlignment(false);
}
else
{
- ap.seqPanel.ap.idPanel
+ ap.getSeqPanel().ap.getIdPanel()
.highlightSearchResults(aa[selectedRow].groupRef
.getSequences(null));
}
{
if (evt.getClickCount() == 1)
{
- ap.seqPanel.ap.idPanel.highlightSearchResults(Arrays
+ ap.getSeqPanel().ap.getIdPanel().highlightSearchResults(Arrays
.asList(new SequenceI[]
{ aa[selectedRow].sequenceRef }));
}
else if (evt.getClickCount() >= 2)
{
- ap.seqPanel.ap.idPanel.highlightSearchResults(null);
+ ap.getSeqPanel().ap.getIdPanel().highlightSearchResults(null);
SequenceGroup sg = ap.av.getSelectionGroup();
if (sg!=null)
{
{
// TODO: pass on reference to ap so the view can be updated.
aaa.groupRef.setIgnoreGapsConsensus(cbmi.getState());
- ap.annotationPanel.paint(ap.annotationPanel.getGraphics());
+ ap.getAnnotationPanel().paint(ap.getAnnotationPanel().getGraphics());
}
else
{
g.setColor(Color.white);
g.fillRect(0, 0, getWidth(), getHeight());
- g.translate(0, scrollOffset);
+ g.translate(0, getScrollOffset());
g.setColor(Color.black);
AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
int ofontH = fontHeight;
int sOffset = 0;
int visHeight = 0;
- int[] visr = (ap != null && ap.annotationPanel != null) ? ap.annotationPanel
+ int[] visr = (ap != null && ap.getAnnotationPanel() != null) ? ap.getAnnotationPanel()
.getVisibleVRange() : null;
if (clip && visr != null)
{
if (resizePanel)
{
- g.drawImage(image, 2, 0 - scrollOffset, this);
+ g.drawImage(image, 2, 0 - getScrollOffset(), this);
}
else if (dragEvent != null && aa != null)
{
g.setColor(Color.lightGray);
g.drawString(aa[selectedRow].label, dragEvent.getX(),
- dragEvent.getY() - scrollOffset);
+ dragEvent.getY() - getScrollOffset());
}
if (!av.wrapAlignment && ((aa == null) || (aa.length < 1)))
18);
}
}
+
+ public int getScrollOffset()
+ {
+ return scrollOffset;
+ }
}
public void adjustmentValueChanged(AdjustmentEvent evt)
{
// update annotation label display
- ap.alabels.setScrollOffset(-evt.getValue());
+ ap.getAlabels().setScrollOffset(-evt.getValue());
}
/**
return;
}
- ap.scalePanel.mousePressed(evt);
+ ap.getScalePanel().mousePressed(evt);
}
graphStretch = -1;
graphStretchY = -1;
mouseDragging = false;
- ap.scalePanel.mouseReleased(evt);
+ ap.getScalePanel().mouseReleased(evt);
}
/**
@Override
public void mouseEntered(MouseEvent evt)
{
- ap.scalePanel.mouseEntered(evt);
+ ap.getScalePanel().mouseEntered(evt);
}
/**
@Override
public void mouseExited(MouseEvent evt)
{
- ap.scalePanel.mouseExited(evt);
+ ap.getScalePanel().mouseExited(evt);
}
/**
}
else
{
- ap.scalePanel.mouseDragged(evt);
+ ap.getScalePanel().mouseDragged(evt);
}
}
{
try
{
- image = new BufferedImage(imgWidth, ap.annotationPanel.getHeight(),
+ image = new BufferedImage(imgWidth, ap.getAnnotationPanel().getHeight(),
BufferedImage.TYPE_INT_RGB);
} catch (OutOfMemoryError oom)
{
@Override
public int[] getVisibleVRange()
{
- if (ap != null && ap.alabels != null)
+ if (ap != null && ap.getAlabels() != null)
{
- int sOffset = -ap.alabels.scrollOffset;
+ int sOffset = -ap.getAlabels().getScrollOffset();
int visHeight = sOffset + ap.annotationSpaceFillerHolder.getHeight();
bounds[0] = sOffset;
bounds[1] = visHeight;
// TODO : Fix multiple seq to one chain issue here.
ap.getStructureSelectionManager().setMapping(seq, chains,
alreadyMapped, AppletFormatAdapter.FILE);
- if (ap.seqPanel.seqCanvas.fr != null)
+ if (ap.getSeqPanel().seqCanvas.fr != null)
{
- ap.seqPanel.seqCanvas.fr.featuresAdded();
+ ap.getSeqPanel().seqCanvas.fr.featuresAdded();
ap.paintAlignment(true);
}
// TODO : Fix multiple seq to one chain issue here.
ap.getStructureSelectionManager().setMapping(seq, chains,
alreadyMapped, AppletFormatAdapter.FILE);
- if (ap.seqPanel.seqCanvas.fr != null)
+ if (ap.getSeqPanel().seqCanvas.fr != null)
{
- ap.seqPanel.seqCanvas.fr.featuresAdded();
+ ap.getSeqPanel().seqCanvas.fr.featuresAdded();
ap.paintAlignment(true);
}
{
this.ap = ap;
this.av = ap.av;
- if (ap != null && ap.seqPanel != null && ap.seqPanel.seqCanvas != null
- && ap.seqPanel.seqCanvas.fr != null)
+ if (ap != null && ap.getSeqPanel() != null && ap.getSeqPanel().seqCanvas != null
+ && ap.getSeqPanel().seqCanvas.fr != null)
{
- transferSettings(ap.seqPanel.seqCanvas.fr);
+ transferSettings(ap.getSeqPanel().seqCanvas.fr);
}
}
highlight.addResult(sequences[0], features[index].getBegin(),
features[index].getEnd());
- ap.seqPanel.seqCanvas.highlightSearchResults(highlight);
+ ap.getSeqPanel().seqCanvas.highlightSearchResults(highlight);
}
Object col = getFeatureStyle(name.getText());
{
fr.featureGroups.put(check.getText(),
new Boolean(check.isSelected()));
- af.alignPanel.seqPanel.seqCanvas.repaint();
+ af.alignPanel.getSeqPanel().seqCanvas.repaint();
if (af.alignPanel.overviewPanel != null)
{
af.alignPanel.overviewPanel.updateOverviewImage();
searchResults.getResultEnd(i), "Search Results");
}
- if (ap.seqPanel.seqCanvas.getFeatureRenderer().amendFeatures(seqs,
+ if (ap.getSeqPanel().seqCanvas.getFeatureRenderer().amendFeatures(seqs,
features, true, ap))
{
ap.alignFrame.showSeqFeatures.setSelected(true);
if ((idMatch.size() > 0))
{
haveResults = true;
- ap.idPanel.highlightSearchResults(idMatch);
+ ap.getIdPanel().highlightSearchResults(idMatch);
}
else
{
- ap.idPanel.highlightSearchResults(null);
+ ap.getIdPanel().highlightSearchResults(null);
}
if (searchResults.getSize() > 0)
public void smoothFont_actionPerformed(ActionEvent e)
{
ap.av.antiAlias = smoothFont.isSelected();
- ap.annotationPanel.image = null;
+ ap.getAnnotationPanel().image = null;
ap.paintAlignment(true);
}
--- /dev/null
+package jalview.gui;
+
+import jalview.util.MessageManager;
+
+import java.awt.BorderLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.BorderFactory;
+import javax.swing.ButtonGroup;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JRadioButton;
+
+public class HTMLOptions extends JPanel
+{
+ JDialog dialog;
+
+ public boolean cancelled = false;
+
+ String value;
+
+ public HTMLOptions()
+ {
+ try
+ {
+ jbInit();
+ } catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+
+ ButtonGroup bg = new ButtonGroup();
+ bg.add(lineart);
+ bg.add(text);
+
+ JOptionPane pane = new JOptionPane(null, JOptionPane.DEFAULT_OPTION,
+ JOptionPane.DEFAULT_OPTION, null, new Object[]
+ { this });
+
+ dialog = pane.createDialog(Desktop.desktop, "HTML Rendering options");
+ dialog.setVisible(true);
+
+ }
+
+ private void jbInit() throws Exception
+ {
+ lineart.setFont(JvSwingUtils.getLabelFont());
+ lineart.setText(MessageManager.getString("label.lineart"));
+ text.setFont(JvSwingUtils.getLabelFont());
+ text.setText(MessageManager.getString("action.text"));
+ text.setSelected(true);
+ askAgain.setFont(JvSwingUtils.getLabelFont());
+ askAgain.setText(MessageManager.getString("label.dont_ask_me_again"));
+ ok.setText(MessageManager.getString("action.ok"));
+ ok.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ ok_actionPerformed(e);
+ }
+ });
+ cancel.setText(MessageManager.getString("action.cancel"));
+ cancel.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ cancel_actionPerformed(e);
+ }
+ });
+ jLabel1.setFont(JvSwingUtils.getLabelFont());
+ jLabel1.setText("Select HTML character rendering style");
+ this.setLayout(borderLayout1);
+ jPanel3.setBorder(BorderFactory.createEtchedBorder());
+ jPanel2.add(text);
+ jPanel2.add(lineart);
+ jPanel2.add(askAgain);
+ jPanel1.add(ok);
+ jPanel1.add(cancel);
+ jPanel3.add(jLabel1);
+ jPanel3.add(jPanel2);
+ this.add(jPanel3, java.awt.BorderLayout.CENTER);
+ this.add(jPanel1, java.awt.BorderLayout.SOUTH);
+ }
+
+ JRadioButton lineart = new JRadioButton();
+
+ JRadioButton text = new JRadioButton();
+
+ JCheckBox askAgain = new JCheckBox();
+
+ JButton ok = new JButton();
+
+ JButton cancel = new JButton();
+
+ JPanel jPanel1 = new JPanel();
+
+ JLabel jLabel1 = new JLabel();
+
+ JPanel jPanel2 = new JPanel();
+
+ JPanel jPanel3 = new JPanel();
+
+ BorderLayout borderLayout1 = new BorderLayout();
+
+ public void ok_actionPerformed(ActionEvent e)
+ {
+ if (lineart.isSelected())
+ {
+ value = "Lineart";
+ }
+ else
+ {
+ value = "Text";
+ }
+
+ if (!askAgain.isSelected())
+ {
+ jalview.bin.Cache.applicationProperties.remove("HTML_RENDERING");
+ }
+ else
+ {
+ jalview.bin.Cache.setProperty("HTML_RENDERING", value);
+ }
+
+ dialog.setVisible(false);
+ }
+
+ public void cancel_actionPerformed(ActionEvent e)
+ {
+ cancelled = true;
+ dialog.setVisible(false);
+ }
+
+ public String getValue()
+ {
+ return value;
+ }
+}
AnnotationPanel ap;
- Font idfont;
+ private Font idfont;
/**
* Creates a new IdCanvas object.
gg.setColor(Color.black);
}
- if (av.rightAlignIds)
+ if (av.isRightAlignIds())
{
xPos = panelWidth
- fm.stringWidth(s.getDisplayId(av.getShowJVSuffix())) - 4;
{
if (av.seqNameItalics)
{
- idfont = new Font(av.getFont().getName(), Font.ITALIC, av.getFont()
- .getSize());
+ setIdfont(new Font(av.getFont().getName(), Font.ITALIC, av.getFont()
+ .getSize()));
}
else
{
- idfont = av.getFont();
+ setIdfont(av.getFont());
}
- gg.setFont(idfont);
+ gg.setFont(getIdfont());
fm = gg.getFontMetrics();
if (av.antiAlias)
int annotationHeight = 0;
- if (av.showAnnotation)
+ if (av.isShowAnnotation())
{
if (ap == null)
{
}
else
{
- gg.setFont(idfont);
+ gg.setFont(getIdfont());
}
drawIdString(gg, s, i, 0, ypos);
}
- if (labels != null && av.showAnnotation)
+ if (labels != null && av.isShowAnnotation())
{
gg.translate(0, ypos + (alheight * av.charHeight));
labels.drawComponent(gg, getWidth());
String string = sequence.getDisplayId(av.getShowJVSuffix());
- if (av.rightAlignIds)
+ if (av.isRightAlignIds())
{
xPos = panelWidth - fm.stringWidth(string) - 4;
}
}
else
{
- gg.setFont(idfont);
+ gg.setFont(getIdfont());
}
}
searchResults = list;
repaint();
}
+
+ public Font getIdfont()
+ {
+ return idfont;
+ }
+
+ public void setIdfont(Font idfont)
+ {
+ this.idfont = idfont;
+ }
}
public class IdPanel extends JPanel implements MouseListener,
MouseMotionListener, MouseWheelListener
{
- protected IdCanvas idCanvas;
+ private IdCanvas idCanvas;
protected AlignViewport av;
{
this.av = av;
alignPanel = parent;
- idCanvas = new IdCanvas(av);
+ setIdCanvas(new IdCanvas(av));
linkImageURL = getClass().getResource("/images/link.gif").toString();
seqAnnotReport = new SequenceAnnotationReport(linkImageURL);
setLayout(new BorderLayout());
- add(idCanvas, BorderLayout.CENTER);
+ add(getIdCanvas(), BorderLayout.CENTER);
addMouseListener(this);
addMouseMotionListener(this);
addMouseWheelListener(this);
@Override
public void mouseMoved(MouseEvent e)
{
- SeqPanel sp = alignPanel.seqPanel;
+ SeqPanel sp = alignPanel.getSeqPanel();
int seq = Math.max(0, sp.findSeq(e));
if (seq > -1 && seq < av.getAlignment().getHeight())
{
{
mouseDragging = true;
- int seq = Math.max(0, alignPanel.seqPanel.findSeq(e));
+ int seq = Math.max(0, alignPanel.getSeqPanel().findSeq(e));
if (seq < lastid)
{
return;
}
- int seq = alignPanel.seqPanel.findSeq(e);
+ int seq = alignPanel.getSeqPanel().findSeq(e);
String url = null;
int i = 0;
String id = av.getAlignment().getSequenceAt(seq).getName();
return;
}
- int seq = alignPanel.seqPanel.findSeq(e);
+ int seq = alignPanel.getSeqPanel().findSeq(e);
if (SwingUtilities.isRightMouseButton(e))
{
*/
public void highlightSearchResults(List<SequenceI> list)
{
- idCanvas.setHighlighted(list);
+ getIdCanvas().setHighlighted(list);
if (list == null)
{
}
}
+ public IdCanvas getIdCanvas()
+ {
+ return idCanvas;
+ }
+
+ public void setIdCanvas(IdCanvas idCanvas)
+ {
+ this.idCanvas = idCanvas;
+ }
+
// this class allows scrolling off the bottom of the visible alignment
class ScrollThread extends Thread
{
{
active = true;
- Dimension d = ap.idPanel.idCanvas.getPreferredSize();
+ Dimension d = ap.getIdPanel().getIdCanvas().getPreferredSize();
int dif = evt.getX() - oldX;
if (((d.width + dif) > 20) || (dif > 0))
{
- ap.idPanel.idCanvas.setPreferredSize(new Dimension(d.width + dif,
+ ap.getIdPanel().getIdCanvas().setPreferredSize(new Dimension(d.width + dif,
d.height));
ap.paintAlignment(true);
}
view.setShowBoxes(av.getShowBoxes());
view.setShowColourText(av.getColourText());
view.setShowFullId(av.getShowJVSuffix());
- view.setRightAlignIds(av.rightAlignIds);
+ view.setRightAlignIds(av.isRightAlignIds());
view.setShowSequenceFeatures(av.showSequenceFeatures);
view.setShowText(av.getShowText());
view.setShowUnconserved(av.getShowUnconserved());
{
jalview.schemabinding.version2.FeatureSettings fs = new jalview.schemabinding.version2.FeatureSettings();
- String[] renderOrder = ap.seqPanel.seqCanvas.getFeatureRenderer().renderOrder;
+ String[] renderOrder = ap.getSeqPanel().seqCanvas.getFeatureRenderer().renderOrder;
Vector settingsAdded = new Vector();
Object gstyle = null;
{
for (int ro = 0; ro < renderOrder.length; ro++)
{
- gstyle = ap.seqPanel.seqCanvas.getFeatureRenderer()
+ gstyle = ap.getSeqPanel().seqCanvas.getFeatureRenderer()
.getFeatureStyle(renderOrder[ro]);
Setting setting = new Setting();
setting.setType(renderOrder[ro]);
}
else
{
- setting.setColour(ap.seqPanel.seqCanvas.getFeatureRenderer()
+ setting.setColour(ap.getSeqPanel().seqCanvas.getFeatureRenderer()
.getColour(renderOrder[ro]).getRGB());
}
setting.setDisplay(av.featuresDisplayed
.containsKey(renderOrder[ro]));
- float rorder = ap.seqPanel.seqCanvas.getFeatureRenderer()
+ float rorder = ap.getSeqPanel().seqCanvas.getFeatureRenderer()
.getOrder(renderOrder[ro]);
if (rorder > -1)
{
}
// Make sure we save none displayed feature settings
- Iterator en = ap.seqPanel.seqCanvas.getFeatureRenderer().featureColours
+ Iterator en = ap.getSeqPanel().seqCanvas.getFeatureRenderer().featureColours
.keySet().iterator();
while (en.hasNext())
{
Setting setting = new Setting();
setting.setType(key);
- setting.setColour(ap.seqPanel.seqCanvas.getFeatureRenderer()
+ setting.setColour(ap.getSeqPanel().seqCanvas.getFeatureRenderer()
.getColour(key).getRGB());
setting.setDisplay(false);
- float rorder = ap.seqPanel.seqCanvas.getFeatureRenderer()
+ float rorder = ap.getSeqPanel().seqCanvas.getFeatureRenderer()
.getOrder(key);
if (rorder > -1)
{
fs.addSetting(setting);
settingsAdded.addElement(key);
}
- en = ap.seqPanel.seqCanvas.getFeatureRenderer().featureGroups
+ en = ap.getSeqPanel().seqCanvas.getFeatureRenderer().featureGroups
.keySet().iterator();
Vector groupsAdded = new Vector();
while (en.hasNext())
}
Group g = new Group();
g.setName(grp);
- g.setDisplay(((Boolean) ap.seqPanel.seqCanvas
+ g.setDisplay(((Boolean) ap.getSeqPanel().seqCanvas
.getFeatureRenderer().featureGroups.get(grp))
.booleanValue());
fs.addGroup(g);
af.viewport.setConservationSelected(view.getConservationSelected());
af.viewport.setShowJVSuffix(view.getShowFullId());
- af.viewport.rightAlignIds = view.getRightAlignIds();
+ af.viewport.setRightAlignIds(view.getRightAlignIds());
af.viewport.setFont(new java.awt.Font(view.getFontName(), view
.getFontStyle(), view.getFontSize()));
af.alignPanel.fontChanged();
gc.setColourByLabel(setting.getColourByLabel());
}
// and put in the feature colour table.
- af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().setColour(
+ af.alignPanel.getSeqPanel().seqCanvas.getFeatureRenderer().setColour(
setting.getType(), gc);
}
else
{
- af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().setColour(
+ af.alignPanel.getSeqPanel().seqCanvas.getFeatureRenderer().setColour(
setting.getType(),
new java.awt.Color(setting.getColour()));
}
renderOrder[fs] = setting.getType();
if (setting.hasOrder())
{
- af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().setOrder(
+ af.alignPanel.getSeqPanel().seqCanvas.getFeatureRenderer().setOrder(
setting.getType(), setting.getOrder());
}
else
{
- af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().setOrder(
+ af.alignPanel.getSeqPanel().seqCanvas.getFeatureRenderer().setOrder(
setting.getType(),
fs / jms.getFeatureSettings().getSettingCount());
}
setting.getColour()));
}
}
- af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().renderOrder = renderOrder;
+ af.alignPanel.getSeqPanel().seqCanvas.getFeatureRenderer().renderOrder = renderOrder;
Hashtable fgtable;
- af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().featureGroups = fgtable = new Hashtable();
+ af.alignPanel.getSeqPanel().seqCanvas.getFeatureRenderer().featureGroups = fgtable = new Hashtable();
for (int gs = 0; gs < jms.getFeatureSettings().getGroupCount(); gs++)
{
Group grp = jms.getFeatureSettings().getGroup(gs);
{
Setting setting = jms.getFeatureSettings().getSetting(fs);
- af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().setColour(
+ af.alignPanel.getSeqPanel().seqCanvas.getFeatureRenderer().setColour(
setting.getType(), new java.awt.Color(setting.getColour()));
renderOrder[fs] = setting.getType();
setting.getColour()));
}
}
- af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().renderOrder = renderOrder;
+ af.alignPanel.getSeqPanel().seqCanvas.getFeatureRenderer().renderOrder = renderOrder;
}
af.setMenusFromViewport(af.viewport);
if (av.showSequenceFeatures)
{
- fr.transferSettings(ap.seqPanel.seqCanvas.getFeatureRenderer());
+ fr.transferSettings(ap.getSeqPanel().seqCanvas.getFeatureRenderer());
}
int alwidth = av.getAlignment().getWidth();
true,
true,
false,
- (ap.seqPanel.seqCanvas.fr != null) ? ap.seqPanel.seqCanvas.fr.minmax
+ (ap.getSeqPanel().seqCanvas.fr != null) ? ap.getSeqPanel().seqCanvas.fr.minmax
: null);
contents.append("</p>");
}
System.arraycopy(features, 0, tfeatures, 0, rsize);
features = tfeatures;
seqs = rseqs;
- if (ap.seqPanel.seqCanvas.getFeatureRenderer().amendFeatures(seqs,
+ if (ap.getSeqPanel().seqCanvas.getFeatureRenderer().amendFeatures(seqs,
features, true, ap))
{
ap.alignFrame.setShowSeqFeatures(true);
{
public void internalFrameClosing(InternalFrameEvent evt)
{
- ap.idPanel.idCanvas.setHighlighted(null);
+ ap.getIdPanel().getIdCanvas().setHighlighted(null);
}
});
redundantSequences.add(originalSequences[i]);
}
}
- ap.idPanel.idCanvas.setHighlighted(redundantSequences);
+ ap.getIdPanel().getIdCanvas().setHighlighted(redundantSequences);
}
/**
{
if (mouseDragging)
{
- ap.seqPanel.scrollCanvas(null);
+ ap.getSeqPanel().scrollCanvas(null);
}
}
{
if (mouseDragging)
{
- ap.seqPanel.scrollCanvas(evt);
+ ap.getSeqPanel().scrollCanvas(evt);
}
}
drawPanel(g, startRes, endx, 0, al.getHeight(), ypos);
- if (av.showAnnotation)
+ if (av.isShowAnnotation())
{
g.translate(0, cHeight + ypos + 3);
if (annotations == null)
int getAnnotationHeight()
{
- if (!av.showAnnotation)
+ if (!av.isShowAnnotation())
{
return 0;
}
* @param offset
* DOCUMENT ME!
*/
- void drawPanel(Graphics g1, int startRes, int endRes, int startSeq,
+ public void drawPanel(Graphics g1, int startRes, int endRes,
+ int startSeq,
int endSeq, int offset)
{
if (!av.hasHiddenColumns())
sequence.getDatasetSequence(),
rpos = sequence.findPosition(res));
seqARep.appendFeatures(tooltipText, rpos, features,
- this.ap.seqPanel.seqCanvas.fr.minmax);
+ this.ap.getSeqPanel().seqCanvas.fr.minmax);
}
if (tooltipText.length() == 6) // <html></html>
{
}
}
- ap.seqPanel.seqCanvas.repaint();
+ ap.getSeqPanel().seqCanvas.repaint();
}
/**
--- /dev/null
+package jalview.io;
+
+import jalview.datamodel.SequenceI;
+import jalview.gui.AlignViewport;
+import jalview.gui.AlignmentPanel;
+import jalview.gui.AnnotationPanel;
+import jalview.gui.FeatureRenderer;
+import jalview.gui.HTMLOptions;
+import jalview.math.AlignmentDimension;
+import jalview.util.MessageManager;
+
+import java.awt.Color;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.print.Printable;
+import java.awt.print.PrinterException;
+import java.io.File;
+import java.io.FileOutputStream;
+
+import org.jfree.graphics2d.svg.SVGGraphics2D;
+import org.jfree.graphics2d.svg.SVGHints;
+
+public class HtmlSvgOutput
+{
+ AlignViewport av;
+
+ FeatureRenderer fr;
+ AlignmentPanel ap;
+
+ AnnotationPanel annotationPanel;
+
+ public HtmlSvgOutput(AlignmentPanel ap)
+ {
+
+ this.av = ap.av;
+ this.ap = ap;
+ this.annotationPanel = ap.getAnnotationPanel();
+ generateHtmlSvgOutput();
+ }
+
+ public void generateHtmlSvgOutput()
+ {
+ File file = null;
+ try
+ {
+ JalviewFileChooser chooser = getHTMLChooser();
+ chooser.setFileView(new jalview.io.JalviewFileView());
+ chooser.setDialogTitle(ap.alignFrame.getTitle());
+ chooser.setToolTipText(MessageManager.getString("action.save"));
+ int value = chooser.showSaveDialog(ap.alignFrame);
+
+ if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION)
+ {
+ jalview.bin.Cache.setProperty("LAST_DIRECTORY", chooser
+ .getSelectedFile().getParent());
+ file = chooser.getSelectedFile();
+ }
+
+ AlignmentDimension aDimension = ap.getAlignmentDimension();
+ SVGGraphics2D g1 = new SVGGraphics2D(aDimension.getWidth(),
+ aDimension.getHeight());
+ SVGGraphics2D g2 = new SVGGraphics2D(aDimension.getWidth(),
+ aDimension.getHeight());
+
+ String renderStyle = jalview.bin.Cache.getDefault("HTML_RENDERING",
+ "Prompt each time");
+
+ // If we need to prompt, and if the GUI is visible then
+ // Prompt for rendering style
+ if (renderStyle.equalsIgnoreCase("Prompt each time")
+ && !(System.getProperty("java.awt.headless") != null && System
+ .getProperty("java.awt.headless").equals("true")))
+ {
+ HTMLOptions svgOption = new HTMLOptions();
+ renderStyle = svgOption.getValue();
+
+ if (renderStyle == null || svgOption.cancelled)
+ {
+ return;
+ }
+ }
+
+ if (renderStyle.equalsIgnoreCase("lineart"))
+ {
+ g1.setRenderingHint(SVGHints.KEY_DRAW_STRING_TYPE,
+ SVGHints.VALUE_DRAW_STRING_TYPE_VECTOR);
+ g2.setRenderingHint(SVGHints.KEY_DRAW_STRING_TYPE,
+ SVGHints.VALUE_DRAW_STRING_TYPE_VECTOR);
+ }
+ printUnwrapped(aDimension.getWidth(), aDimension.getHeight(), 0, g1,
+ g2);
+ FileOutputStream out = new FileOutputStream(file);
+
+ String titleSvgData = g1.getSVGDocument();
+ String alignSvgData = g2.getSVGDocument();
+ String htmlData = getHtml(titleSvgData, alignSvgData);
+
+ out.write(htmlData.getBytes());
+ out.flush();
+ out.close();
+
+ jalview.util.BrowserLauncher.openURL("file:///" + file);
+ } catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ static JalviewFileChooser getHTMLChooser()
+ {
+ return new jalview.io.JalviewFileChooser(
+ jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[]
+ { "html" }, new String[]
+ { "Hypertext Markup Language" }, "Hypertext Markup Language");
+ }
+
+ public int printUnwrapped(int pwidth, int pheight, int pi, Graphics... pg)
+ throws PrinterException
+ {
+ int idWidth = ap.getVisibleIdWidth(false);
+ FontMetrics fm = ap.getFontMetrics(av.getFont());
+ int scaleHeight = av.getCharHeight() + fm.getDescent();
+
+ pg[0].setColor(Color.white);
+ pg[0].fillRect(0, 0, pwidth, pheight);
+ pg[0].setFont(av.getFont());
+
+ // //////////////////////////////////
+ // / How many sequences and residues can we fit on a printable page?
+ int totalRes = (pwidth - idWidth) / av.getCharWidth();
+ int totalSeq = (pheight - scaleHeight) / av.getCharHeight() - 1;
+ int pagesWide = (av.getAlignment().getWidth() / totalRes) + 1;
+
+ // ///////////////////////////
+ // / Only print these sequences and residues on this page
+ int startRes;
+
+ // ///////////////////////////
+ // / Only print these sequences and residues on this page
+ int endRes;
+
+ // ///////////////////////////
+ // / Only print these sequences and residues on this page
+ int startSeq;
+
+ // ///////////////////////////
+ // / Only print these sequences and residues on this page
+ int endSeq;
+ startRes = (pi % pagesWide) * totalRes;
+ endRes = (startRes + totalRes) - 1;
+
+ if (endRes > (av.getAlignment().getWidth() - 1))
+ {
+ endRes = av.getAlignment().getWidth() - 1;
+ }
+ startSeq = (pi / pagesWide) * totalSeq;
+ endSeq = startSeq + totalSeq;
+ if (endSeq > av.getAlignment().getHeight())
+ {
+ endSeq = av.getAlignment().getHeight();
+ }
+ int pagesHigh = ((av.getAlignment().getHeight() / totalSeq) + 1)
+ * pheight;
+ if (av.isShowAnnotation())
+ {
+ pagesHigh += ap.getAnnotationPanel().adjustPanelHeight() + 3;
+ }
+ pagesHigh /= pheight;
+ if (pi >= (pagesWide * pagesHigh))
+ {
+ return Printable.NO_SUCH_PAGE;
+ }
+
+ // draw Scale
+ pg[1].translate(0, 0);
+ ap.getScalePanel().drawScale(pg[1], startRes, endRes, pwidth - idWidth,
+ scaleHeight);
+ pg[1].translate(-idWidth, scaleHeight);
+
+ // //////////////
+ // Draw the ids
+ Color currentColor = null;
+ Color currentTextColor = null;
+ pg[0].translate(0, scaleHeight);
+ pg[0].setFont(ap.getIdPanel().getIdCanvas().getIdfont());
+ SequenceI seq;
+ for (int i = startSeq; i < endSeq; i++)
+ {
+ seq = av.getAlignment().getSequenceAt(i);
+ if ((av.getSelectionGroup() != null)
+ && av.getSelectionGroup().getSequences(null).contains(seq))
+ {
+ currentColor = Color.gray;
+ currentTextColor = Color.black;
+ }
+ else
+ {
+ currentColor = av.getSequenceColour(seq);
+ currentTextColor = Color.black;
+ }
+ pg[0].setColor(currentColor);
+ pg[0].fillRect(0, (i - startSeq) * av.getCharHeight(), idWidth,
+ av.getCharHeight());
+ pg[0].setColor(currentTextColor);
+ int xPos = 0;
+ if (av.isRightAlignIds())
+ {
+ fm = pg[0].getFontMetrics();
+ xPos = idWidth
+ - fm.stringWidth(seq.getDisplayId(av.getShowJVSuffix()))
+ - 4;
+ }
+ pg[0].drawString(
+ seq.getDisplayId(av.getShowJVSuffix()),
+ xPos,
+ (((i - startSeq) * av.getCharHeight()) + av.getCharHeight())
+ - (av.getCharHeight() / 5));
+ }
+ pg[0].setFont(av.getFont());
+ pg[0].translate(idWidth, 0);
+
+ // draw main sequence panel
+ pg[1].translate(idWidth, 0);
+ ap.getSeqPanel().seqCanvas.drawPanel(pg[1], startRes, endRes, startSeq,
+ endSeq, 0);
+ if (av.isShowAnnotation() && (endSeq == av.getAlignment().getHeight()))
+ {
+ // draw annotation label - need to offset for current scroll position
+ int offset = -ap.getAlabels().getScrollOffset();
+ pg[0].translate(0, offset);
+ pg[0].translate(-idWidth - 3,
+ (endSeq - startSeq) * av.getCharHeight() + 3);
+ ap.getAlabels().drawComponent(pg[0], idWidth);
+ pg[0].translate(idWidth + 3, 0);
+ pg[0].translate(0, -offset);
+
+ // draw annotation - need to offset for current scroll position
+ pg[1].translate(0, offset);
+ pg[1].translate(-idWidth - 3,
+ (endSeq - startSeq) * av.getCharHeight() + 3);
+ pg[1].translate(idWidth + 3, 0);
+ ap.getAnnotationPanel().renderer.drawComponent(
+ ap.getAnnotationPanel(), av, pg[1], -1, startRes, endRes + 1);
+ pg[1].translate(0, -offset);
+ }
+
+ return Printable.PAGE_EXISTS;
+ }
+
+ private String getHtml(String titleSvg, String alignmentSvg)
+ {
+ StringBuilder htmlSvg = new StringBuilder();
+ htmlSvg.append("<html><style type=\"text/css\">" + "div.title {"
+ + "height: 100%;" + "width: 9%;" + "float: left;" + "}"
+ + "div.align {" + "height: 100%;" + "width: 91%;"
+ + "overflow: scroll;" + "float: right;" + "}" + "</style>"
+ + "<div style=\"width:100%; height:100%; overflow: hidden\">"
+ + "<div class=\"title\">");
+ htmlSvg.append(titleSvg);
+ htmlSvg.append("</div><div class=\"align\">").append(alignmentSvg);
+ htmlSvg.append("</div>");
+ return htmlSvg.toString();
+ }
+}
--- /dev/null
+package jalview.math;
+
+public class AlignmentDimension
+{
+ private int width;
+
+ private int height;
+
+ public AlignmentDimension(int width, int height)
+ {
+ this.width = width;
+ this.height = height;
+ }
+
+ public int getWidth()
+ {
+ return width;
+ }
+
+ public void setWidth(int width)
+ {
+ this.width = width;
+ }
+
+ public int getHeight()
+ {
+ return height;
+ }
+
+ public void setHeight(int height)
+ {
+ this.height = height;
+ }
+
+}