Newer
Older
final int baseAtStartOfView,
SAMRecord thisRead = bamViewRecord.sam;
int offset = getSequenceOffset(thisRead.getReferenceName());
int thisStart = thisRead.getAlignmentStart()+offset-baseAtStartOfView;
int thisEnd = thisRead.getAlignmentEnd()+offset-baseAtStartOfView;
if(highlightSAMRecord != null &&
highlightSAMRecord.sam.getReadName().equals(thisRead.getReadName()))
Stroke originalStroke = g2.getStroke();
Stroke stroke =
new BasicStroke (3.f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND);
Color c = g2.getColor();
g2.setColor(Color.black);
g2.drawLine((int)( thisStart * pixPerBase), ypos,
(int)( thisEnd * pixPerBase), ypos);
g2.setColor(c);
if(thisRead.getCigar().getCigarElements().size() == 1)
g2.drawLine((int)( thisStart * pixPerBase), ypos,
(int)( thisEnd * pixPerBase), ypos);
else
{
List<AlignmentBlock> blocks = thisRead.getAlignmentBlocks();
Color c = g2.getColor();
int lastEnd = 0;
for(int i=0; i<blocks.size(); i++)
{
AlignmentBlock block = blocks.get(i);
int blockStart = block.getReferenceStart()+offset-baseAtStartOfView;
int blockEnd = blockStart + block.getLength() - 1;
g2.drawLine((int)( blockStart * pixPerBase), ypos,
(int)( blockEnd * pixPerBase), ypos);
if(i > 0 && blockStart != lastEnd)
{
g2.setColor(Color.gray);
g2.drawLine((int)( blockStart * pixPerBase), ypos,
(int)( lastEnd * pixPerBase), ypos);
g2.setColor(c);
}
lastEnd = blockEnd;
}
}
if(isOrientation)
drawArrow(g2, thisRead, thisStart, thisEnd, pixPerBase, ypos);
// test if the mouse is over this read
if(lastMousePoint != null)
{
if(lastMousePoint.getY()+2 > ypos && lastMousePoint.getY()-2 < ypos)
if(lastMousePoint.getX() > thisStart * pixPerBase &&
lastMousePoint.getX() < thisEnd * pixPerBase)
{
mouseOverSAMRecord = bamViewRecord;
if (isSNPs && snps != null)
showSNPsOnReads(snps, g2, pixPerBase, ypos);
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
/**
* Draw arrow on the read to indicate orientation.
* @param g2
* @param thisRead
* @param thisStart
* @param thisEnd
* @param pixPerBase
* @param ypos
*/
private void drawArrow(Graphics2D g2,
SAMRecord thisRead,
int thisStart,
int thisEnd,
float pixPerBase,
int ypos)
{
if(thisRead.getReadNegativeStrandFlag())
{
int apos = ypos + 2;
g2.drawLine((int)( (thisStart+5) * pixPerBase), apos,
(int)( thisStart * pixPerBase), ypos);
}
else
{
int apos = ypos - 2;
g2.drawLine((int)( (thisEnd-5) * pixPerBase), apos,
(int)( thisEnd * pixPerBase), ypos);
}
}
/**
* Highlight a selected range
* @param g2
* @param pixPerBase
* @param start
* @param end
*/
private void drawSelectionRange(Graphics2D g2, float pixPerBase, int start, int end, Color c)
{
if(getSelection() != null)
{
Range selectedRange = getSelection().getSelectionRange();
if(selectedRange != null)
{
int rangeStart = selectedRange.getStart();
int rangeEnd = selectedRange.getEnd();
if(end < rangeStart || start > rangeEnd)
return;
int x = (int) (pixPerBase*(rangeStart-getBaseAtStartOfView()));
int width = (int) (pixPerBase*(rangeEnd-rangeStart+1));
g2.setColor(c);
g2.fillRect(x, 0, width, getHeight());
}
}
}
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
/**
* Draw a translucent line
* @param g2
* @param start
* @param end
* @param ypos
*/
private void drawTranslucentLine(Graphics2D g2, int start, int end, int ypos)
{
Composite origComposite = g2.getComposite();
g2.setComposite(translucent);
g2.drawLine(start, ypos, end, ypos);
g2.setComposite(origComposite);
}
/**
* Draw a translucent line
* @param g2
* @param start
* @param end
* @param ypos
*/
private void drawTranslucentJointedLine(Graphics2D g2, int start, int end, int ypos)
{
Composite origComposite = g2.getComposite();
g2.setComposite(translucent);
int mid = (int) ((end-start)/2.f)+start;
//g2.drawLine(start, ypos, end, ypos);
g2.drawLine(start, ypos, mid, ypos-5);
g2.drawLine(mid, ypos-5, end, ypos);
g2.setComposite(origComposite);
}
* @param snps
private void showSNPsOnReads(final List<Integer> snps,
final Graphics2D g2,
float pixPerBase, int ypos)
g2.setColor(Color.red);
for(int pos: snps)
g2.drawLine((int) (pos * pixPerBase), ypos + 2,
(int) (pos * pixPerBase), ypos - 2);
}
/**
* Get the SNP positions
* @param samRecord
*/
private List<Integer> getSNPs(final SAMRecord samRecord)
{
if(!isSNPs) // return null if not displaying SNPs
return null;
int rbeg = samRecord.getAlignmentStart();
int rend = samRecord.getAlignmentEnd();
int offset = getSequenceOffset(samRecord.getReferenceName());
ArrayList<Integer> snps = null;
// use alignment blocks of the contiguous alignment of
// subsets of read bases to a reference sequence
final char[] refSeq = bases.getSubSequenceC(
new Range(rbeg+offset, rend+offset), Bases.FORWARD);
final byte[] readSeq = samRecord.getReadBases();
offset = offset - getBaseAtStartOfView();
final List<AlignmentBlock> blocks = samRecord.getAlignmentBlocks();
int readStart = block.getReadStart();
int refStart = block.getReferenceStart();
int len = block.getLength();
for(int j=0; j<len; j++)
int readPos = readStart-1+j;
int refPos = refStart+j;
if (Character.toUpperCase(refSeq[refPos-rbeg]) != readSeq[readPos])
if(snps == null)
snps = new ArrayList<Integer>();
snps.add(refPos+offset);
System.err.println(samRecord.getReadName()+" "+e.getMessage());
return snps;
/**
* Add the alignment view to the supplied <code>JPanel</code> in
* a <code>JScrollPane</code>.
* @param mainPanel panel to add the alignment to
* @param autohide automatically hide the top panel containing the buttons
setDisplay(1, nbasesInView, null);
mainPanel.setLayout(new BorderLayout());
if(topPanel instanceof JPanel)
mainPanel.add(topPanel, BorderLayout.NORTH);
mainPanel.add(jspView, BorderLayout.CENTER);
JPanel bottomPanel = new JPanel(new BorderLayout());
coveragePanel = new CoveragePanel(this);
bottomPanel.add(coveragePanel, BorderLayout.CENTER);
//
snpPanel = new SnpPanel(this, bases);
bottomPanel.add(snpPanel, BorderLayout.NORTH);
if(feature_display == null)
{
scrollBar = new JScrollBar(JScrollBar.HORIZONTAL, 1, nbasesInView, 1,
getMaxBasesInPanel(getSequenceLength()));
scrollBar.setUnitIncrement(nbasesInView/20);
scrollBar.addAdjustmentListener(new AdjustmentListener()
{
public void adjustmentValueChanged(AdjustmentEvent e)
{
repaint();
if(isSNPplot)
snpPanel.repaint();
if(isCoverage)
coveragePanel.repaint();
}
});
bottomPanel.add(scrollBar, BorderLayout.SOUTH);
}
else
{
{
int seqLen = seqLengths.get((String) combo.getSelectedItem());
int artemisSeqLen = feature_display.getSequenceLength();
if(seqLen != artemisSeqLen)
{
int newIndex = -1;
for(int i=0; i<seqNames.size(); i++)
{
if(seqLengths.get(seqNames.get(i)) == artemisSeqLen)
{
// this looks like the correct sequence
combo.setSelectedIndex(i);
newIndex = i;
}
}
if(!Options.isBlackBeltMode())
{
String label[] = {
"The length of the sequence loaded does not match the length of",
"the default reference sequence in the BAM ("+seqNames.get(0)+").",
(newIndex == -1 ? "" : "The length does match the reference "+
};
new NonModalDialog(frame, label);
}
}
}
}
mainPanel.add(bottomPanel, BorderLayout.SOUTH);
coveragePanel.setPreferredSize(new Dimension(900, 100));
coveragePanel.setVisible(false);
snpPanel.setPreferredSize(new Dimension(900, 100));
snpPanel.setVisible(false);
jspView.getVerticalScrollBar().setValue(
jspView.getVerticalScrollBar().getMaximum());
private void addToViewMenu(final short thisBamIndex)
final File f = new File(bamList.get(thisBamIndex));
final JCheckBoxMenuItem cbBam = new JCheckBoxMenuItem(
f.getName(),
getImageIcon(getColourByCoverageColour(thisBamIndex)),
true);
bamFilesMenu.add(cbBam);
cbBam.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if(cbBam.isSelected())
laststart = -1;
repaint();
}
});
}
/**
* Refresh the colour of the icons used to identify the
* BAM files.
*/
protected void refreshColourOfBamMenu()
{
final Component cs[] = bamFilesMenu.getMenuComponents();
for(Component c : cs)
{
if(c instanceof JCheckBoxMenuItem)
{
final JCheckBoxMenuItem cbBam = (JCheckBoxMenuItem) c;
final Color col = getColorByJCheckBoxMenuItem(cbBam);
if(col != null)
cbBam.setIcon(getImageIcon(col));
protected Color getColorByJCheckBoxMenuItem(JCheckBoxMenuItem cbBam)
{
final String bam = cbBam.getText();
for(short i=0; i<bamList.size(); i++)
{
final File f = new File(bamList.get(i));
if(f.getName().equals(bam))
return getColourByCoverageColour(i);
}
return null;
}
/**
* Create an icon of a box using the given colour.
* @param c
* @return
*/
{
BufferedImage image = (BufferedImage)this.createImage(10, 10);
Graphics2D g2 = image.createGraphics();
g2.setColor(c);
g2.fillRect(0, 0, 10, 10);
return new ImageIcon(image);
}
final JMenuItem addBam = new JMenuItem("Add BAM ...");
menu.add(addBam);
addBam.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
FileSelectionDialog bamFileSelection = new FileSelectionDialog(
null, false, "BamView", "BAM");
List<String> bamFiles = bamFileSelection.getFiles(BAM_SUFFIX);
short count = (short) bamList.size();
bamList.addAll(bamFileSelection.getFiles(BAM_SUFFIX));
for(short i=0; i<bamFiles.size(); i++)
addToViewMenu((short) (i+count));
repaint();
}
});
bamFilesMenu.setFont(addBam.getFont());
final JMenuItem groupBams = new JMenuItem("Group BAMs ...");
final GroupBamFrame groupsFrame = new GroupBamFrame(this, bamFilesMenu);
groupBams.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0)
{
groupsFrame.updateAndDisplay();
}
});
bamFilesMenu.add(groupBams);
bamFilesMenu.addSeparator();
menu.add(bamFilesMenu);
final JMenu analyse = new JMenu("Analyse");
menu.add(analyse);
final JMenuItem readCount = new JMenuItem("Read count of selected features ...");
if(feature_display == null)
readCount.setEnabled(false);
readCount.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
FeatureVector features = feature_display.getSelection().getAllFeatures();
JCheckBox overlap = new JCheckBox("Include all overlapping reads", true);
overlap.setToolTipText("Include reads that partially overlap the feature");
JCheckBox spliced = new JCheckBox("Introns included", true);
Box yBox = Box.createVerticalBox();
yBox.add(overlap);
yBox.add(spliced);
final ReadCountDialog opts = new ReadCountDialog(new JFrame(),
"Read Count Options", feature_display, yBox);
if(opts.getStatus() == -1)
return;
//JOptionPane.showMessageDialog(null, yBox, "Read Count Option", JOptionPane.INFORMATION_MESSAGE);
new MappedReads(features, (String)combo.getSelectedItem(), samFileReaderHash, bamList,
seqNames, offsetLengths, concatSequences, seqLengths,
samRecordFlagPredicate, samRecordMapQPredicate,
!overlap.isSelected(), spliced.isSelected());
}
});
final JMenuItem rpkm = new JMenuItem("RPKM value of selected features ...");
analyse.add(rpkm);
if(feature_display == null)
rpkm.setEnabled(false);
rpkm.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
final FeatureVector features = feature_display.getSelection().getAllFeatures();
JCheckBox overlap = new JCheckBox("Include all overlapping reads", true);
overlap.setToolTipText("Include reads that partially overlap the feature");
JCheckBox spliced = new JCheckBox("Introns included", true);
JCheckBox allRefSeqs = new JCheckBox("Use reads mapped to all reference sequences", false);
Box yBox = Box.createVerticalBox();
yBox.add(overlap);
yBox.add(spliced);
if(seqLengths.size() > 1)
yBox.add(allRefSeqs);
final ReadCountDialog opts = new ReadCountDialog(new JFrame(),
"RPKM Options", feature_display, yBox);
if(opts.getStatus() == -1)
return;
int seqlen = 0;
if(feature_display != null)
seqlen = feature_display.getSequenceLength();
else if(bases != null)
seqlen = bases.getLength();
new MappedReads(features, (String)combo.getSelectedItem(),
samFileReaderHash, bamList, seqNames, offsetLengths, concatSequences,
seqLengths, seqlen, samRecordFlagPredicate, samRecordMapQPredicate,
!overlap.isSelected(), spliced.isSelected(), allRefSeqs.isSelected());
final JMenuItem createFeatures = new JMenuItem("Create features from coverage peaks ...");
analyse.add(createFeatures);
if(feature_display == null)
createFeatures.setEnabled(false);
createFeatures.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if(feature_display == null)
return;
new CreateFeatures(groupsFrame);
for(short i=0; i<bamList.size(); i++)
addToViewMenu(i);
menu.add(new JSeparator());
cbStackView.setFont(viewMenu.getFont());
cbIsizeStackView.setFont(viewMenu.getFont());
cbPairedStackView.setFont(viewMenu.getFont());
cbStrandStackView.setFont(viewMenu.getFont());
cbCoverageView.setFont(viewMenu.getFont());
cbCoverageStrandView.setFont(viewMenu.getFont());
baseQualityColour.setFont(viewMenu.getFont());
colourByCoverageColour.setFont(viewMenu.getFont());
markInsertions.setFont(viewMenu.getFont());
cbIsizeStackView.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
laststart = -1;
logMenuItem.setEnabled(isIsizeStackView());
getJspView().setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
viewMenu.add(cbIsizeStackView);
cbStackView.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
laststart = -1;
if(cbStackView.isSelected())
logMenuItem.setEnabled(false);
getJspView().setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
cbPairedStackView.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
laststart = -1;
if(cbPairedStackView.isSelected())
logMenuItem.setEnabled(false);
getJspView().setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
repaint();
}
});
viewMenu.add(cbPairedStackView);
cbStrandStackView.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
laststart = -1;
if(cbStrandStackView.isSelected())
logMenuItem.setEnabled(false);
getJspView().setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
viewMenu.add(cbStrandStackView);
cbCoverageView.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
laststart = -1;
if(cbCoverageView.isSelected())
{
logMenuItem.setEnabled(true);
coverageView.setPlotHeatMap(false);
coverageView.setPlotByStrand(false);
setViewportBtm();
getJspView().setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
repaint();
}
});
viewMenu.add(cbCoverageView);
cbCoverageStrandView.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
laststart = -1;
if(cbCoverageStrandView.isSelected())
{
logMenuItem.setEnabled(true);
coverageView.setPlotHeatMap(false);
coverageView.setPlotByStrand(true);
setViewportBtm();
getJspView().setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
repaint();
}
});
viewMenu.add(cbCoverageStrandView);
cbCoverageHeatMap.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
laststart = -1;
if(cbCoverageHeatMap.isSelected())
{
logMenuItem.setEnabled(true);
coverageView.setPlotHeatMap(true);
setViewportBtm();
getJspView().setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
}
repaint();
}
});
viewMenu.add(cbCoverageHeatMap);
final JCheckBoxMenuItem checkBoxSNPs = new JCheckBoxMenuItem("SNP marks");
//
JMenu colourMenu = new JMenu("Colour By");
colourMenu.add(colourByCoverageColour);
baseQualityColour.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if(baseQualityColour.isSelected())
{
checkBoxSNPs.setSelected(false);
isSNPs = false;
}
repaint();
}
});
colourMenu.add(baseQualityColour);
menu.add(colourMenu);
//
JCheckBoxMenuItem checkBoxOrientation = new JCheckBoxMenuItem("Orientation");
checkBoxOrientation.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
isOrientation = !isOrientation;
repaint();
}
});
showMenu.add(checkBoxOrientation);
JCheckBoxMenuItem checkBoxSingle = new JCheckBoxMenuItem("Single Reads");
checkBoxSingle.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
repaint();
isSingle = !isSingle;
}
});
showMenu.add(checkBoxSingle);
checkBoxSNPs.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if (isSNPs && bases == null)
{
JOptionPane.showMessageDialog(null,
"No reference sequence supplied to identify SNPs.", "SNPs",
JOptionPane.INFORMATION_MESSAGE);
}
isSNPs = !isSNPs;
if(isSNPs)
baseQualityColour.setSelected(false);
repaint();
}
});
showMenu.add(checkBoxSNPs);
markInsertions.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
repaint();
}
});
showMenu.add(markInsertions);
JCheckBoxMenuItem checkBoxCoverage = new JCheckBoxMenuItem("Coverage");
checkBoxCoverage.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
isCoverage = !isCoverage;
coveragePanel.setVisible(isCoverage);
if( isCoverage &&
!cbCoverageView.isSelected() &&
!cbCoverageStrandView.isSelected() &&
!cbCoverageHeatMap.isSelected())
graphMenu.add(checkBoxCoverage);
JCheckBoxMenuItem checkBoxSNP = new JCheckBoxMenuItem("SNP");
checkBoxSNP.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
isSNPplot = !isSNPplot;
snpPanel.setVisible(isSNPplot);
repaint();
}
});
graphMenu.add(checkBoxSNP);
menu.add(graphMenu);
final JCheckBoxMenuItem checkBoxSync =
new JCheckBoxMenuItem("Asynchronous", asynchronous);
checkBoxSync.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
{
asynchronous = checkBoxSync.isSelected();
}
});
JMenu maxHeightMenu = new JMenu("BamView Height");
final String hgts[] =
{"500", "800", "1000", "1500", "2500", "5000", "50000"};
ButtonGroup bgroup = new ButtonGroup();
for(int i=0; i<hgts.length; i++)
{
final String hgt = hgts[i];
final JCheckBoxMenuItem maxHeightMenuItem = new JCheckBoxMenuItem(hgt);
bgroup.add(maxHeightMenuItem);
maxHeightMenuItem.setSelected(hgts[i].equals(Integer.toString(maxHeight)));
maxHeightMenu.add(maxHeightMenuItem);
maxHeightMenuItem.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if(maxHeightMenuItem.isSelected())
maxHeight = Integer.parseInt(hgt);
int start = getBaseAtStartOfView();
setDisplay(start, nbasesInView+start, null);
}
});
}
logMenuItem.setEnabled(isIsizeStackView());
logMenuItem.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
logScale = logMenuItem.isSelected();
repaint();
}
});
JMenuItem filter = new JMenuItem("Filter Reads ...");
menu.add(filter);
filter.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if(filterFrame == null)
filterFrame = new SAMRecordFilter(BamView.this);
else
filterFrame.setVisible(true);
}
});
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
JMenuItem maxReadCoverage = new JMenuItem("Read Coverage Threshold ...");
menu.add(maxReadCoverage);
maxReadCoverage.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
final TextFieldInt maxRead = new TextFieldInt();
maxRead.setValue(MAX_COVERAGE);
int status = JOptionPane.showConfirmDialog(null, maxRead,
"Read Coverage Threshold", JOptionPane.OK_CANCEL_OPTION);
if(status == JOptionPane.OK_OPTION &&
maxRead.getValue() != MAX_COVERAGE)
{
MAX_COVERAGE = maxRead.getValue();
if(MAX_COVERAGE < 1)
MAX_COVERAGE = Integer.MAX_VALUE;
laststart = -1;
repaint();
}
}
});
JMenuItem readList = new JMenuItem("List Reads ...");
menu.add(readList);
readList.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
final JMenuItem bamSplitter = new JMenuItem("Clone window");
bamSplitter.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
BamView bamView = new BamView(new Vector<String>(bamList),
null, nbasesInView, entry_edit,
feature_display, bases, (JPanel) mainPanel.getParent(), null);
bamView.getJspView().getVerticalScrollBar().setValue(
bamView.getJspView().getVerticalScrollBar().getMaximum());
getJspView().getVerticalScrollBar().setValue(
bamView.getJspView().getVerticalScrollBar().getMaximum());
int start = getBaseAtStartOfView();
setDisplay(start, nbasesInView+start, null);
if(feature_display != null)
{
feature_display.addDisplayAdjustmentListener(bamView);
feature_display.getSelection().addSelectionChangeListener(bamView);
}
}
});
menu.add(new JSeparator());
menu.add(bamSplitter);
//
JMenu coverageMenu = new JMenu("Coverage Options");
coverageView.init(this, 0.f, 0, 0);
coverageView.createMenus(coverageMenu);
viewMenu.add(new JSeparator());
viewMenu.add(coverageMenu);
private JComponent bamTopPanel(final JFrame frame)
{
final JComponent topPanel;
{
topPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0));
if(feature_display != null)
this.selection = feature_display.getSelection();
}
else
{
topPanel = new JMenuBar();
frame.setJMenuBar((JMenuBar)topPanel);
JMenu fileMenu = new JMenu("File");
topPanel.add(fileMenu);
JMenuItem readBam = new JMenuItem("Open new BamView ...");
fileMenu.add(readBam);
readBam.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
BamView.main(s);
}
});
JMenuItem close = new JMenuItem("Close");
fileMenu.add(close);
close.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
BamView.this.setVisible(false);
Component comp = BamView.this;
while( !(comp instanceof JFrame) )
comp = comp.getParent();
((JFrame)comp).dispose();
}
});
JMenuItem exit = new JMenuItem("Exit");
fileMenu.add(new JSeparator());
fileMenu.add(exit);
exit.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
int status = JOptionPane.showConfirmDialog(BamView.this,
"Exit BamView?", "Exit",
JOptionPane.OK_CANCEL_OPTION);
if(status != JOptionPane.OK_OPTION)
return;
System.exit(0);
}
});
addKeyListener(new KeyAdapter()
{
public void keyPressed(final KeyEvent event)
{
switch (event.getKeyCode())
{
case KeyEvent.VK_UP:
setZoomLevel((int) (BamView.this.nbasesInView * 1.1));
break;
case KeyEvent.VK_DOWN:
if (showBaseAlignment)
break;
setZoomLevel((int) (BamView.this.nbasesInView * .9));
break;
default:
break;
}
}
});
}
if(seqNames.size() > 1)
{
int len = 0;
for(int i=0; i<seqNames.size(); i++)
len += seqLengths.get(seqNames.get(i));
if(feature_display != null &&
len == feature_display.getSequenceLength())
concatSequences = true;
else if(bases != null &&
len == bases.getLength() )
concatSequences = true;
}
// auto hide top panel
final JCheckBox buttonAutoHide = new JCheckBox("Hide", (frame == null));
buttonAutoHide.setToolTipText("Auto-Hide");
final MouseMotionListener mouseMotionListener = new MouseMotionListener()
{
public void mouseDragged(MouseEvent event)
{
handleCanvasMouseDrag(event);
}
public void mouseMoved(MouseEvent e)
{
lastMousePoint = e.getPoint();
int thisHgt = HEIGHT;
if (thisHgt < 5)
thisHgt = 15;
int y = (int) (e.getY() - jspView.getViewport().getViewRect().getY());
if (y < thisHgt)