Skip to content
Snippets Groups Projects
Commit 077bc660 authored by tjc's avatar tjc
Browse files

updates to allow opening circular plot from an Artemis window

git-svn-id: svn+ssh://svn.internal.sanger.ac.uk/repos/svn/pathsoft/artemis/trunk@8578 ee4ac58c-ac51-4696-9907-e4b3aa274f04
parent 547be900
Branches
No related tags found
No related merge requests found
......@@ -1058,7 +1058,7 @@ public class DNADraw extends ScrollPanel
{
public void actionPerformed(ActionEvent e)
{
Wizard.getFeaturesFromFile(DNADraw.this);
Wizard.getDNADrawFromFile(DNADraw.this);
majorTicks = null;
if(gcGraph != null)
......@@ -1132,7 +1132,11 @@ public class DNADraw extends ScrollPanel
fileMenu.add(new JSeparator());
JMenuItem fileMenuExit = new JMenuItem("Exit");
final JMenuItem fileMenuExit;
if(!close)
fileMenuExit = new JMenuItem("Exit");
else
fileMenuExit = new JMenuItem("Close");
fileMenuExit.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
......
......@@ -40,6 +40,7 @@ import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import uk.ac.sanger.artemis.Entry;
import uk.ac.sanger.artemis.Feature;
import uk.ac.sanger.artemis.FeatureKeyPredicate;
import uk.ac.sanger.artemis.FeatureKeyQualifierPredicate;
......@@ -129,8 +130,11 @@ class TrackViewer extends JFrame
else
key = new Key("-");
Entry entry = dnaDraw.getArtemisEntryGroup().getDefaultEntry();
if(entry == null)
entry = dnaDraw.getArtemisEntryGroup().getSequenceEntry();
keyChoice[i] = new KeyChoice(
dnaDraw.getArtemisEntryGroup().getDefaultEntry().getEntryInformation(),key);
entry.getEntryInformation(),key);
optionBox.add(keyChoice[i], c);
......@@ -167,7 +171,7 @@ class TrackViewer extends JFrame
else
{
qualifierChoice[i] = new QualifierChoice(
dnaDraw.getArtemisEntryGroup().getDefaultEntry().getEntryInformation(),key, qualifier, false);
entry.getEntryInformation(),key, qualifier, false);
optionBox.add(qualifierChoice[i], c);
c.gridx = 4;
qualifierValue[i] = new JTextField(track.getQualifierValue(), 10);
......
......@@ -38,6 +38,7 @@ import javax.swing.JSeparator;
import uk.ac.sanger.artemis.Entry;
import uk.ac.sanger.artemis.EntryGroup;
import uk.ac.sanger.artemis.EntryVector;
import uk.ac.sanger.artemis.Feature;
import uk.ac.sanger.artemis.FeatureVector;
import uk.ac.sanger.artemis.Options;
......@@ -71,7 +72,7 @@ public class Wizard
// option 1 - create dna display
// option 2 - edit existing dna
if(n == 0)
dna = getFeaturesFromFile(dna_current);
dna = getDNADrawFromFile(dna_current);
else if(n == 1 || n == 2)
{
Vector block = new Vector();
......@@ -168,22 +169,51 @@ public class Wizard
}
}
protected static DNADraw getFeaturesFromFile(DNADraw dna_current)
/**
* Create a DNADraw panel from a file
* @param dna_current
* @return
*/
protected static DNADraw getDNADrawFromFile(DNADraw dna_current)
{
Options.getOptions();
uk.ac.sanger.artemis.components.FileDialogEntrySource entrySource =
new uk.ac.sanger.artemis.components.FileDialogEntrySource(null, null);
final EntryGroup entryGroup = new SimpleEntryGroup();
Entry entry;
try
{
final EntryGroup entryGroup = new SimpleEntryGroup();
final Entry entry = entrySource.getEntry(true);
entry = entrySource.getEntry(true);
entryGroup.add(entry);
return getDNADrawFromArtemisEntry(dna_current, entryGroup, entry);
}
catch(OutOfRangeException e)
{
e.printStackTrace();
}
catch(NoSequenceException e)
{
JOptionPane.showMessageDialog(null, "No sequence found!",
"Sequence Missing", JOptionPane.WARNING_MESSAGE);
}
return null;
}
/**
* Create a DNADraw panel from an entry
* @param dna_current
* @param entryGroup
* @param entry
* @return
*/
public static DNADraw getDNADrawFromArtemisEntry(DNADraw dna_current,
final EntryGroup entryGroup,
final Entry entry)
{
for(int i=0; i<tracks.length; i++)
tracks[i].setEntry(entry);
FeatureVector features = entry.getAllFeatures();
Vector block = new Vector();
......@@ -227,12 +257,8 @@ public class Wizard
else
track = TRACK_5;
Block drawBlock = new Block(f.getIDString(),
range.getStart(),
range.getEnd(),
col,
10.f,
track, dna_current);
Block drawBlock = new Block(f.getIDString(), range.getStart(), range
.getEnd(), col, 10.f, track, dna_current);
drawBlock.setFeature(f);
block.add(drawBlock);
......@@ -257,24 +283,24 @@ public class Wizard
dna_current.setRestrictionEnzyme(new Vector());
dna_current.setMinorTickInterval(tick2);
dna_current.setTickInterval(tick);
}
catch(OutOfRangeException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch(NoSequenceException e)
EntryVector entries = entryGroup.getActiveEntries();
for(int i=0; i<entries.size(); i++)
{
// TODO Auto-generated catch block
e.printStackTrace();
Entry this_entry = entries.elementAt(i);
if(!this_entry.getName().equals(entry.getName()))
addFeaturesFromEntry(this_entry, dna_current);
}
return dna_current;
}
protected static DNADraw readEntry(final DNADraw dna_current,
/**
* Read a new entry from a file
* @param dna_current
* @param bases
* @return
*/
public static DNADraw readEntry(final DNADraw dna_current,
final Bases bases)
{
Options.getOptions();
......@@ -286,6 +312,27 @@ public class Wizard
final Entry entry = entrySource.getEntry(bases,true);
dna_current.getArtemisEntryGroup().add(entry);
addFeaturesFromEntry(entry, dna_current);
}
catch(OutOfRangeException e)
{
JOptionPane.showMessageDialog(null,
"Feature found out of range:\n"+
e.getMessage(),"Out of Range",
JOptionPane.WARNING_MESSAGE);
}
return dna_current;
}
/**
* Add features from an entry to a new track
* @param entry
* @param dna_current
*/
private static void addFeaturesFromEntry(final Entry entry,
final DNADraw dna_current)
{
FeatureVector features = entry.getAllFeatures();
Track track = addTrack(entry);
......@@ -315,19 +362,6 @@ public class Wizard
}
}
}
catch(OutOfRangeException e)
{
JOptionPane.showMessageDialog(null,
"Feature found out of range:\n"+
e.getMessage(),"Out of Range",
JOptionPane.WARNING_MESSAGE);
}
return dna_current;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment