本文整理汇总了Java中jloda.util.CanceledException类的典型用法代码示例。如果您正苦于以下问题:Java CanceledException类的具体用法?Java CanceledException怎么用?Java CanceledException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CanceledException类属于jloda.util包,在下文中一共展示了CanceledException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: destroyView
import jloda.util.CanceledException; //导入依赖的package包/类
/**
* ask view to destroy itself
*/
public void destroyView() throws CanceledException {
ProgramProperties.put(MeganProperties.CHART_WINDOW_GEOMETRY, new int[]{
getLocation().x, getLocation().y, getSize().width, getSize().height});
MeganProperties.removePropertiesListListener(getJMenuBar().getRecentFilesListener());
executorService.shutdownNow();
boolean ok = false;
try {
ok = executorService.awaitTermination(2, TimeUnit.SECONDS);
} catch (InterruptedException e) {
e.printStackTrace();
}
if (!ok)
NotificationsInSwing.showInternalError(getFrame(), "Failed to terminate runaway threads... (consider restarting MEGAN)");
getChartDrawer().close();
if (searchManager != null && searchManager.getFindDialogAsToolBar() != null)
searchManager.getFindDialogAsToolBar().close();
dir.removeViewer(this);
dispose();
}
示例2: apply
import jloda.util.CanceledException; //导入依赖的package包/类
/**
* collect all read data associated with the given iterator
*
* @param progress
* @return list of contig names and contigs
*/
public static List<ReadData> apply(final IReadBlockIterator iterator, final ProgressListener progress) throws IOException, CanceledException {
// collect all readDatas:
progress.setSubtask("Collecting reads:");
final List<ReadData> list = new LinkedList<>();
int countReads = 0;
{
progress.setMaximum(iterator.getMaximumProgress());
progress.setProgress(0);
while (iterator.hasNext()) {
final IReadBlock readBlock = iterator.next();
//System.err.println(readBlock.getReadName()+" -> "+countReads);
list.add(createReadData(countReads++, readBlock));
progress.setProgress(iterator.getProgress());
}
}
if (progress instanceof ProgressPercentage)
((ProgressPercentage) progress).reportTaskCompleted();
return list;
}
示例3: runNeighborNet
import jloda.util.CanceledException; //导入依赖的package包/类
/**
* Run the neighbor net algorithm
*/
public void runNeighborNet(ProgressListener progressListener, int ntax, double[][] D, int ordering[]) throws CanceledException {
NetNode netNodes = new NetNode();
/* Nodes are stored in a doubly linked list that we set up here */
for (int i = ntax; i >= 1; i--) /* Initially, all singleton nodes are active */ {
NetNode taxNode = new NetNode();
taxNode.id = i;
taxNode.next = netNodes.next;
netNodes.next = taxNode;
}
for (NetNode taxNode = netNodes; taxNode.next != null; taxNode = taxNode.next)
/* Set up links in other direction */
taxNode.next.prev = taxNode;
/* Perform the agglomeration step */
Stack amalgs = new Stack();
int num_nodes = ntax;
num_nodes = agglomNodes(progressListener, amalgs, D, netNodes, num_nodes);
expandNodes(progressListener, num_nodes, ntax, amalgs, netNodes, ordering);
}
示例4: exportAll
import jloda.util.CanceledException; //导入依赖的package包/类
/**
* export all matches in file
*
* @param connector
* @param fileName
* @param progressListener
* @throws java.io.IOException
*/
public static int exportAll(IConnector connector, String fileName, ProgressListener progressListener) throws IOException {
int total = 0;
try {
progressListener.setTasks("Export", "Writing all reads");
try (BufferedWriter w = new BufferedWriter(new FileWriter(fileName))) {
IReadBlockIterator it = connector.getAllReadsIterator(0, 10000, true, false);
progressListener.setMaximum(it.getMaximumProgress());
progressListener.setProgress(0);
while (it.hasNext()) {
total++;
write(it.next(), w);
progressListener.setProgress(it.getProgress());
}
}
} catch (CanceledException ex) {
System.err.println("USER CANCELED");
}
return total;
}
示例5: exportAll
import jloda.util.CanceledException; //导入依赖的package包/类
/**
* export all matches in file
*
* @param connector
* @param fileName
* @param progressListener
* @throws IOException
*/
public static long exportAll(BlastMode blastMode, IConnector connector, String fileName, ProgressListener progressListener) throws IOException {
progressListener.setTasks("Export", "Writing all matches");
long countMatches = 0;
try {
try (BufferedWriter w = new BufferedWriter(new FileWriter(fileName))) {
w.write(blastMode.toString().toUpperCase() + " file generated by MEGAN6\n\n");
IReadBlockIterator it = connector.getAllReadsIterator(0, 10000, true, true);
progressListener.setMaximum(it.getMaximumProgress());
progressListener.setProgress(0);
while (it.hasNext()) {
countMatches += writeMatches(it.next(), w);
progressListener.setProgress(it.getProgress());
}
}
} catch (CanceledException ex) {
System.err.println("USER CANCELED");
}
return countMatches;
}
示例6: launchComparison
import jloda.util.CanceledException; //导入依赖的package包/类
/**
* launch the computation of a comparison
*
* @param dir1
* @param dir2
* @param methodName
* @param options
* @throws IOException
*/
public static void launchComparison(Director dir0, Director dir1, Director dir2, String methodName,
String options) throws IOException, CanceledException {
IMethodItem item = null;
if (methodName.equals(ResamplingMethodItem.NAME)) {
item = new ResamplingMethodItem();
} else
NotificationsInSwing.showError("Unknown statistical method: " + methodName);
if (item != null) {
item.parseOptionString(options);
Map<Integer, Float> input1 = computeInputMapFromLeaves(dir1, item.getOptionUseInternal(), item.getOptionUseUnassigned());
System.err.println("Input map for " + dir1.getTitle() + ": " + input1.keySet().size());
Map<Integer, Float> input2 = computeInputMapFromLeaves(dir2, item.getOptionUseInternal(), item.getOptionUseUnassigned());
System.err.println("Input map for " + dir2.getTitle() + ": " + input2.keySet().size());
item.setInput(input1, input2);
item.apply(dir0.getDocument().getProgressListener());
Map<Integer, Double> result = item.getOutput();
ResamplingMethodItem.displayResult(result, dir1, dir2);
}
}
示例7: Long2IntegerBinMap
import jloda.util.CanceledException; //导入依赖的package包/类
/**
* open a bin file
*
* @param fileName
* @throws IOException
* @throws CanceledException
*/
public Long2IntegerBinMap(String fileName) throws IOException, CanceledException {
final File file = new File(fileName);
if (!file.exists())
throw new IOException("No such file: " + file);
if (!file.canRead())
throw new IOException("Can't read file: " + file);
if (!isBinFile(fileName))
throw new IOException("Wrong magic number: " + file);
try {
reader = new IntFileGetterMappedMemory(file);
} catch (IOException ex) { // on 32-bit machine, memory mapping will fail... use Random access
System.err.println("Opening file: " + file);
reader = new IntFileGetterRandomAccess(file);
}
}
示例8: computeTax2SpeciesMapRec
import jloda.util.CanceledException; //导入依赖的package包/类
/**
* recursively compute the taxon-id to species-id map
*
* @param v
* @param taxId2SpeciesId
* @return taxa below species
*/
private void computeTax2SpeciesMapRec(final Node v, int speciesId, final IntIntMap taxId2SpeciesId, Name2IdMap name2IdMap, final ProgressListener progress) throws CanceledException {
final int taxId = (Integer) v.getInfo();
if (speciesId == 0) {
if (name2IdMap.getRank(taxId) == TaxonomicLevels.getSpeciesId()) {
speciesId = taxId;
taxId2SpeciesId.put(taxId, speciesId);
}
} else
taxId2SpeciesId.put(taxId, speciesId);
for (Edge e = v.getFirstOutEdge(); e != null; e = v.getNextOutEdge(e))
computeTax2SpeciesMapRec(e.getTarget(), speciesId, taxId2SpeciesId, name2IdMap, progress);
progress.incrementProgress();
}
示例9: apply
import jloda.util.CanceledException; //导入依赖的package包/类
/**
* applies the min support filter to taxon classification
*
* @return mapping of old taxon ids to new taxon ids
*/
public Map<Integer, Integer> apply() throws CanceledException {
final Map<Integer, Integer> orphan2AncestorMapping = new HashMap<>();
if (progress != null) {
progress.setMaximum(tree.getNumberOfNodes());
progress.setProgress(0);
}
final Set<Integer> orphans = new HashSet<>();
if (tree.getRoot() != null)
computeOrphan2AncestorMappingRec(tree.getRoot(), orphan2AncestorMapping, orphans);
// Any orphans that popped out of the top of the taxonomy are mapped to unassigned
for (Integer id : orphans) {
orphan2AncestorMapping.put(id, IdMapper.UNASSIGNED_ID);
}
orphans.clear();
if (progress instanceof ProgressPercentage)
((ProgressPercentage) progress).reportTaskCompleted();
return orphan2AncestorMapping;
}
示例10: apply
import jloda.util.CanceledException; //导入依赖的package包/类
/**
* applies the min-support algorithm to the given taxonomic analysis
*
* @param tax2count
* @param minSupport
* @param progressListener
*/
public static void apply(Map<Integer, Integer> tax2count, int minSupport, final ProgressListener progressListener) {
MinSupportAlgorithm algorithm = new MinSupportAlgorithm(tax2count, minSupport, progressListener);
try {
Map<Integer, Integer> lowSupportTaxa2HighSupportTaxa = algorithm.apply();
for (Integer lowTaxon : lowSupportTaxa2HighSupportTaxa.keySet()) {
Integer highTaxon = lowSupportTaxa2HighSupportTaxa.get(lowTaxon);
Integer count = tax2count.get(highTaxon);
if (count == null)
tax2count.put(highTaxon, tax2count.get(lowTaxon));
else
tax2count.put(highTaxon, count + tax2count.get(lowTaxon));
}
tax2count.keySet().removeAll(lowSupportTaxa2HighSupportTaxa.keySet());
} catch (CanceledException e) {
Basic.caught(e);
}
}
示例11: apply
import jloda.util.CanceledException; //导入依赖的package包/类
/**
* apply the embedding algorithm to a single tree
*
* @param tree
* @param progressListener
*/
public void apply(PhyloTree tree, ProgressListener progressListener) throws CanceledException {
if (printILP) {
NodeSet nodes1 = tree.getNodes();
Iterator<Node> tempIt = nodes1.iterator();
int tempIndex = 1;
while (tempIt.hasNext()) {
Node tempNode = tempIt.next();
if (tempNode.getOutDegree() != 0) {
tree.setLabel(tempNode, Integer.toString(tempIndex));
tempIndex++;
}
}
}
if (tree.getRoot() == null || tree.getSpecialEdges().size() == 0) {
tree.getNode2GuideTreeChildren().clear();
return;
}
//System.err.println("Computing optimal embedding using circular-ordering algorithm");
apply(new PhyloTree[]{tree}, progressListener, false, true);
}
示例12: apply
import jloda.util.CanceledException; //导入依赖的package包/类
/**
* applies the indicated embedding algorithm
*
* @param algorithmName
* @param tree
*/
public static void apply(String algorithmName, PhyloTree tree) throws CanceledException {
ILayoutOptimizer embedder;
if (algorithmName.equalsIgnoreCase(ALGORITHM2008))
embedder = new LayoutOptimizer2008();
else if (algorithmName.equalsIgnoreCase(ALGORITHM2009))
embedder = new LayoutOptimizer2009();
else if (algorithmName.equalsIgnoreCase(ALGORITHM2010))
embedder = new EmbeddingOptimizerNNet();
else if (algorithmName.equalsIgnoreCase(ALGORITHM2010DIST))
embedder = new LayoutOptimizerDist();
else if (algorithmName.equalsIgnoreCase(ALGORITHMlsa))
embedder = new LayoutOptimizerLSA();
else
embedder = new LayoutUnoptimized();
embedder.apply(tree, null);
}
示例13: getNumberOfReticulationsInClusterNetwork
import jloda.util.CanceledException; //导入依赖的package包/类
/**
* get the number of reticulations in a cluster network
*
* @param tree1
* @param tree2
* @param progressListner
* @return number of reticulate nodes
* @throws CanceledException
*/
public static int getNumberOfReticulationsInClusterNetwork(PhyloTree tree1, PhyloTree tree2, ProgressListener progressListner) throws CanceledException, IOException {
Taxa allTaxa = new Taxa();
dendroscope.consensus.Utilities.extractTaxa(1, tree1, allTaxa);
dendroscope.consensus.Utilities.extractTaxa(2, tree2, allTaxa);
Set<Cluster> clusters = extractClusters(allTaxa, tree1, tree2);
PhyloTree hasseDiagram = HasseDiagram.constructHasse(clusters.toArray(new Cluster[clusters.size()]));
int count = 0;
for (Node v = hasseDiagram.getFirstNode(); v != null; v = v.getNext()) {
if (v.getInDegree() > 1)
count++;
}
return count;
}
示例14: apply
import jloda.util.CanceledException; //导入依赖的package包/类
/**
* applies the distortion-1 consensus method to obtain a tree
*
* @return consensus
*/
public PhyloTree apply(Document doc, TreeData[] trees) throws CanceledException {
doc.notifyTasks("LSA consensus", "");
ZClosure zclosure = new ZClosure();
System.err.println("LSA consensus input trees:" + trees.length);
SplitSystem splits = zclosure.apply(doc.getProgressListener(), trees);
Taxa taxa = zclosure.getTaxa();
System.err.println("LSA consensus splits: " + splits.size());
PhyloTree network = splits.createTreeFromSplits(taxa, false, doc.getProgressListener());
PhyloTree tree = computeLSA(network);
tree.setName("lsa-consensus");
return tree;
}
示例15: apply
import jloda.util.CanceledException; //导入依赖的package包/类
/**
* applies the strict consensus method to obtain a tree
*
* @return consensus
*/
public PhyloTree apply(Document doc, TreeData[] trees) throws CanceledException {
doc.notifyTasks("Strict consensus", "");
ZClosure zclosure = new ZClosure();
zclosure.setOptionFilter(ZClosure.FILTER_STRICT);
System.err.println("Strict consensus input trees:" + trees.length);
SplitSystem splits = zclosure.apply(doc.getProgressListener(), trees);
Taxa taxa = zclosure.getTaxa();
System.err.println("Strict consensus splits: " + splits.size());
// System.err.println("OUTGROUP: " + taxa.getLabel(taxa.maxId()));
PhyloTree tree = splits.createTreeFromSplits(taxa, doc.getProgressListener());
tree.setName("strict-consensus");
return tree;
}