本文整理了Java中com.bc.ceres.core.ProgressMonitor.isCanceled()
方法的一些代码示例,展示了ProgressMonitor.isCanceled()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ProgressMonitor.isCanceled()
方法的具体详情如下:
包路径:com.bc.ceres.core.ProgressMonitor
类名称:ProgressMonitor
方法名:isCanceled
暂无
代码示例来源:origin: bcdev/beam
private static void checkCanceled(ProgressMonitor pm) throws IOException {
if (pm.isCanceled()) {
throw new IOException("Process terminated by user.");
}
}
代码示例来源:origin: bcdev/beam
private static void checkForCancelation(ProgressMonitor pm) {
if (pm.isCanceled()) {
throw new OperatorException("Operation canceled.");
}
}
代码示例来源:origin: senbox-org/snap-desktop
@Override
protected ProductSceneImage doInBackground(com.bc.ceres.core.ProgressMonitor pm) throws Exception {
try {
return createProductSceneImage(rasterDataNode, existingView, pm);
} finally {
if (pm.isCanceled()) {
rasterDataNode.unloadRasterData();
}
}
}
};
代码示例来源:origin: bcdev/beam
@Override
protected ProductSceneImage doInBackground(com.bc.ceres.core.ProgressMonitor pm) throws Exception {
try {
return createProductSceneImage(selectedProductNode, pm);
} finally {
if (pm.isCanceled()) {
selectedProductNode.unloadRasterData();
}
}
}
代码示例来源:origin: bcdev/beam
public void export(KmlFeature kmlFeature, ZipOutputStream zipOutputStream, final ProgressMonitor pm) throws
IOException {
final int numOverlaysToExport = getNumOverlaysToExport(kmlFeature);
pm.beginTask("Exporting KMZ...", numOverlaysToExport);
try {
exportImages(kmlFeature, zipOutputStream, pm);
zipOutputStream.putNextEntry(new ZipEntry(OVERLAY_KML));
final String kml = createKml(kmlFeature);
zipOutputStream.write(kml.getBytes());
pm.isCanceled();
} finally {
zipOutputStream.close();
pm.done();
}
}
代码示例来源:origin: senbox-org/s1tbx
protected static void getRemoteFiles(final FtpDownloader ftp, final Map<String, Long> fileSizeMap,
final String remotePath, final File localPath, final ProgressMonitor pm) {
final Set<String> remoteFileNames = fileSizeMap.keySet();
pm.beginTask("Downloading Orbit files from " + remotePath, remoteFileNames.size());
for (String fileName : remoteFileNames) {
if (pm.isCanceled()) break;
final long fileSize = fileSizeMap.get(fileName);
final File localFile = new File(localPath, fileName);
if (localFile.exists() && localFile.length() == fileSize)
continue;
try {
int attempts = 0;
while (attempts < 3) {
final FtpDownloader.FTPError result = ftp.retrieveFile(remotePath + '/' + fileName, localFile, fileSize);
if (result == FtpDownloader.FTPError.OK) {
break;
} else {
attempts++;
localFile.delete();
}
}
} catch (Exception e) {
localFile.delete();
System.out.println(e.getMessage());
}
pm.worked(1);
}
pm.done();
}
代码示例来源:origin: bcdev/beam
private List<Product> getAllProducts(ProgressMonitor pm) {
List<Product> result = new ArrayList<Product>();
pm.beginTask("Scanning product locations ...", productLocationList.size());
try {
for (ProductLocation productLocation : productLocationList) {
if (pm.isCanceled()) {
break;
}
for (Product product : productLocation.getProducts(ProgressMonitor.NULL).values()) {
result.add(product);
}
pm.worked(1);
}
} finally {
pm.done();
}
return result;
}
代码示例来源:origin: bcdev/beam
@Override
protected Repository[] doInBackground() throws Exception {
final ArrayList<File> dirList = new ArrayList<File>();
dirList.add(baseDir);
if (doRecursive) {
final File[] subDirs = collectAllSubDirs(baseDir);
for (File subDir : subDirs) {
dirList.add(subDir);
}
}
pm.beginTask("Collecting repositories...", dirList.size());
final ArrayList<Repository> repositoryList = new ArrayList<Repository>();
try {
RepositoryScanner.ProductFileFilter filter = new RepositoryScanner.ProductFileFilter();
for (File subDir : dirList) {
final File[] subDirFiles = subDir.listFiles(filter);
if (subDirFiles.length > 0) {
final Repository repository = new Repository(subDir);
repositoryList.add(repository);
}
if (pm.isCanceled()) {
return repositoryList.toArray(new Repository[repositoryList.size()]);
}
pm.worked(1);
}
return repositoryList.toArray(new Repository[repositoryList.size()]);
} finally {
pm.done();
}
}
代码示例来源:origin: senbox-org/snap-desktop
private static Boolean writeProduct(Product product,
File file,
String formatName,
boolean incremental,
ProgressMonitor pm) {
Debug.assertNotNull(product);
try {
// todo - really add GPF dependency?!?
/*
if (product.getProductReader() instanceof OperatorProductReader) {
GPF.writeProduct(product, file, formatName, incremental, pm);
} else {
ProductIO.writeProduct(product, file, formatName, incremental, pm);
}
*/
ProductIO.writeProduct(product, file, formatName, incremental, pm);
return !pm.isCanceled() ? true : null;
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
javax.swing.SwingUtilities.invokeLater(() -> Dialogs.showError("Writing failed", e.getMessage()));
return false;
}
}
代码示例来源:origin: bcdev/beam
protected void writeAllBands(ProgressMonitor pm) throws IOException {
Product product = _sourceProduct;
ProductWriter productWriter = this;
// for correct progress indication we need to collect
// all bands which shall be written to the output
ArrayList<Band> bandsToWrite = new ArrayList<Band>();
for (int i = 0; i < product.getNumBands(); i++) {
Band band = product.getBandAt(i);
if (productWriter.shouldWrite(band)) {
bandsToWrite.add(band);
}
}
if (!bandsToWrite.isEmpty()) {
pm.beginTask("Writing bands of product '" + product.getName() + "'...", bandsToWrite.size());
try {
for (Band band : bandsToWrite) {
if (pm.isCanceled()) {
break;
}
band.writeRasterDataFully(SubProgressMonitor.create(pm, 1));
}
} finally {
pm.done();
}
}
}
代码示例来源:origin: bcdev/beam
private static void writeAllBands(Product product, ProgressMonitor pm) throws IOException {
ProductWriter productWriter = product.getProductWriter();
// for correct progress indication we need to collect
// all bands which shall be written to the output
ArrayList<Band> bandsToWrite = new ArrayList<Band>();
for (int i = 0; i < product.getNumBands(); i++) {
Band band = product.getBandAt(i);
if (productWriter.shouldWrite(band)) {
bandsToWrite.add(band);
}
}
if (!bandsToWrite.isEmpty()) {
pm.beginTask("Writing bands of product '" + product.getName() + "'...", bandsToWrite.size());
try {
for (Band band : bandsToWrite) {
if (pm.isCanceled()) {
break;
}
band.writeRasterDataFully(SubProgressMonitor.create(pm, 1));
}
} finally {
pm.done();
}
}
}
代码示例来源:origin: bcdev/beam
private void exportImages(KmlFeature kmlFeature, ZipOutputStream zipOutputStream, ProgressMonitor pm) throws
IOException {
if (pm.isCanceled()) {
return;
}
if (kmlFeature instanceof KmlOverlay) {
KmlOverlay overlay = (KmlOverlay) kmlFeature;
zipOutputStream.putNextEntry(new ZipEntry(overlay.getIconFileName()));
ImageEncoder encoder = ImageCodec.createImageEncoder(IMAGE_TYPE, zipOutputStream, null);
encoder.encode(overlay.getOverlay());
pm.worked(1);
}
if (kmlFeature instanceof KmlContainer) {
KmlContainer container = (KmlContainer) kmlFeature;
for (KmlFeature feature : container.getChildren()) {
exportImages(feature, zipOutputStream, pm);
}
}
}
代码示例来源:origin: bcdev/beam
private void reprojectProducts(List<Product> allProducts, ProgressMonitor pm) {
pm.beginTask("Reprojecting source products...", allProducts.size());
try {
for (Product product : allProducts) {
if (pm.isCanceled()) {
return;
}
if (!product.isCompatibleProduct(tsProduct, LAT_LON_EPSILON)) {
HashMap<String, Product> productToBeReprojectedMap = new HashMap<String, Product>();
productToBeReprojectedMap.put("source", product);
productToBeReprojectedMap.put("collocateWith", tsProduct);
final Product collocatedProduct = GPF.createProduct("Reproject", createProjectionParameters(), productToBeReprojectedMap);
collocatedProduct.setStartTime(product.getStartTime());
collocatedProduct.setEndTime(product.getEndTime());
product = collocatedProduct;
}
productTimeMap.put(formatTimeString(product), product);
pm.worked(1);
}
} finally {
pm.done();
}
}
代码示例来源:origin: senbox-org/snap-desktop
@Override
protected Boolean doInBackground() throws Exception {
errorList.clear();
try {
pm.beginTask(getOperationStr() + " products...", entries.length);
for (ProductEntry entry : entries) {
if (pm.isCanceled())
break;
try {
if (operationType.equals(TYPE.COPY_TO)) {
ProductFileHandler.copyTo(entry, targetFolder);
} else if (operationType.equals(TYPE.MOVE_TO)) {
ProductFileHandler.moveTo(entry, targetFolder);
} else if (operationType.equals(TYPE.DELETE)) {
ProductFileHandler.delete(entry);
}
pm.worked(1);
} catch (Exception e) {
errorList.add(new DBScanner.ErrorFile(entry.getFile(), getOperationStr() + " file failed: " + e.getMessage()));
}
}
} catch (Throwable e) {
System.out.println("File Handling Exception\n" + e.getMessage());
} finally {
pm.done();
}
return true;
}
代码示例来源:origin: senbox-org/snap-desktop
public void performAction(final ProgressMonitor pm) {
outputFolder = requestFolderForSave("Download product(s) to folder", "snap.download.folder");
if (outputFolder == null) return;
final ProductEntry[] selections = actionHandler.getSelectedProductEntries();
pm.beginTask("Downloading...", selections.length);
try {
final OpenData openData = new OpenData(COPERNICUS_HOST, COPERNICUS_ODATA_ROOT);
for(ProductEntry entry : selections) {
if (pm.isCanceled()) {
SystemUtils.LOG.info("DownloadActionExt: Download is cancelled");
break;
}
OpenData.Entry oData = openData.getEntryByID(entry.getRefID());
SystemUtils.LOG.info(oData.fileName);
openData.getProduct(entry.getRefID(), oData, outputFolder, new SubProgressMonitor(pm, 1));
}
for (ActionExtListener listener : listenerList) {
listener.notifyMSG(this, ActionExtListener.MSG.NEW_REPO);
}
} catch (Exception e) {
Dialogs.showError("unable to download " + e.getMessage());
} finally {
pm.done();
}
}
代码示例来源:origin: bcdev/beam
if (pm.isCanceled()) {
break;
代码示例来源:origin: bcdev/beam
@Override
public synchronized void readBandRasterData(int sourceOffsetX, int sourceOffsetY, int sourceWidth, int sourceHeight,
int sourceStepX, int sourceStepY, ProductData destBuffer, ProgressMonitor pm) throws
IOException {
AvhrrFile.RawCoordinates rawCoord = avhrrFile.getRawCoordinates(
sourceOffsetX, sourceOffsetY, sourceWidth, sourceHeight);
final byte[] flagsData = (byte[]) destBuffer.getElems();
int targetIdx = rawCoord.targetStart;
pm.beginTask("Reading AVHRR band '" + getBandName() + "'...", rawCoord.maxY - rawCoord.minY);
try {
for (int sourceY = rawCoord.minY; sourceY <= rawCoord.maxY; sourceY += sourceStepY) {
if (pm.isCanceled()) {
break;
}
final byte flag = readFlags(sourceY);
for (int sourceX = rawCoord.minX; sourceX <= rawCoord.maxX; sourceX += sourceStepX) {
flagsData[targetIdx] = flag;
targetIdx += rawCoord.targetIncrement;
}
pm.done();
}
} finally {
pm.done();
}
}
代码示例来源:origin: bcdev/beam
@Override
public synchronized void readBandRasterData(int sourceOffsetX, int sourceOffsetY, int sourceWidth, int sourceHeight,
int sourceStepX, int sourceStepY, ProductData destBuffer, ProgressMonitor pm) throws
IOException {
AvhrrFile.RawCoordinates rawCoord = avhrrFile.getRawCoordinates(
sourceOffsetX, sourceOffsetY, sourceWidth, sourceHeight);
final byte[] flagsData = (byte[]) destBuffer.getElems();
int targetIdx = rawCoord.targetStart;
pm.beginTask("Reading AVHRR band '" + getBandName() + "'...", rawCoord.maxY - rawCoord.minY);
try {
for (int sourceY = rawCoord.minY; sourceY <= rawCoord.maxY; sourceY += sourceStepY) {
if (pm.isCanceled()) {
break;
}
final byte flag = readFlags(sourceY);
for (int sourceX = rawCoord.minX; sourceX <= rawCoord.maxX; sourceX += sourceStepX) {
flagsData[targetIdx] = flag;
targetIdx += rawCoord.targetIncrement;
}
pm.done();
}
} finally {
pm.done();
}
}
代码示例来源:origin: bcdev/beam
public synchronized void readBandRasterData(int sourceOffsetX, int sourceOffsetY, int sourceWidth, int sourceHeight,
int sourceStepX, int sourceStepY, ProductData destBuffer, ProgressMonitor pm) throws
IOException {
AvhrrFile.RawCoordinates rawCoord = noaaFile.getRawCoordinates(
sourceOffsetX, sourceOffsetY, sourceWidth, sourceHeight);
final byte[] flagsData = (byte[]) destBuffer.getElems();
pm.beginTask("Reading AVHRR band '" + getBandName() + "'...", rawCoord.maxY - rawCoord.minY); /*I18N*/
int targetIdx = rawCoord.targetStart;
try {
for (int sourceY = rawCoord.minY; sourceY <= rawCoord.maxY; sourceY += sourceStepY) {
if (pm.isCanceled()) {
break;
}
if (hasClouds(sourceY)) {
readClouds(sourceY);
for (int sourceX = rawCoord.minX; sourceX <= rawCoord.maxX; sourceX += sourceStepX) {
flagsData[targetIdx] = flagBuffer[sourceX];
targetIdx += rawCoord.targetIncrement;
}
}
pm.worked(1);
}
} finally {
pm.done();
}
}
代码示例来源:origin: senbox-org/s2tbx
@Override
protected void readBandRasterDataImpl(int sourceOffsetX, int sourceOffsetY, int sourceWidth, int sourceHeight, int sourceStepX, int sourceStepY, Band destBand, int destOffsetX, int destOffsetY, int destWidth, int destHeight, ProductData destBuffer, ProgressMonitor pm) throws IOException {
final int sourceMaxY = sourceOffsetY + sourceHeight - 1;
Product product = destBand.getProduct();
final int elemSize = destBuffer.getElemSize();
final int bandIndex = product.getBandIndex(destBand.getName());
final long lineSizeInBytes = (long)metadata.getRasterWidth() * (long)metadata.getRasterPixelSize();
int numBands = product.getNumBands();
pm.beginTask("Reading band '" + destBand.getName() + "'...", sourceMaxY - sourceOffsetY);
try {
int destPos = 0;
for (int sourceY = sourceOffsetY; sourceY <= sourceMaxY; sourceY += sourceStepY) {
if (pm.isCanceled()) {
break;
}
synchronized (sharedLock) {
long lineStartPos = sourceY * numBands * lineSizeInBytes + bandIndex * lineSizeInBytes;
imageInputStream.seek(lineStartPos + elemSize * sourceOffsetX);
destBuffer.readFrom(destPos, destWidth, imageInputStream);
destPos += destWidth;
}
pm.worked(1);
}
} finally {
pm.done();
}
}
内容来源于网络,如有侵权,请联系作者删除!