本文整理了Java中com.bc.ceres.core.ProgressMonitor
类的一些代码示例,展示了ProgressMonitor
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ProgressMonitor
类的具体详情如下:
包路径:com.bc.ceres.core.ProgressMonitor
类名称:ProgressMonitor
暂无
代码示例来源:origin: bcdev/beam
@Override
public Map<String, Product> findProducts(String path, ProgressMonitor pm) {
final File[] files = listFiles(path);
Map<String, Product> result = new HashMap<String, Product>();
pm.beginTask("Scanning for products...", files.length);
try {
for (File file : files) {
if (!file.isDirectory()) {
addProductToResult(result, file);
}
pm.worked(1);
}
} finally {
pm.done();
}
return result;
}
},
代码示例来源: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: 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 {
pm.beginTask("Reading band data...", 3);
try {
reader.readBandData(sourceOffsetX, sourceOffsetY, sourceWidth, sourceHeight, sourceStepX, sourceStepY, destBuffer, pm);
} finally {
pm.done();
}
}
代码示例来源: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/s2tbx
@Override
public void computeTileStack(Map<Band, Tile> targetTiles, Rectangle targetRectangle, ProgressMonitor pm) throws OperatorException {
Rectangle srcRec = getSourceRectangle(targetRectangle, pixelWindow);
if (!containsTileValidData(srcRec)) {
setInvalidTargetSamples(targetTiles);
return;
}
Map<String, Tile> sourceTiles = new HashMap<>();
sourceTiles.putAll(getSourceTiles(reflectanceBandNames, srcRec, borderExt));
sourceTiles.putAll(getSourceTiles(InstrumentConsts.GEOM_NAMES, srcRec, borderExt));
sourceTiles.putAll(getSourceTiles(auxRasterDataNodeNames, srcRec, borderExt));
for (int y = targetRectangle.y; y < targetRectangle.y + targetRectangle.height; y++) {
checkForCancellation();
for (int x = targetRectangle.x; x < targetRectangle.x + targetRectangle.width; x++) {
processSuperPixel(sourceTiles, x, y, targetTiles);
}
pm.worked(1);
}
pm.done();
}
代码示例来源:origin: bcdev/beam
/**
* Scans recursivley for resources in the location given by the constructor.
* Afterwards you can retrieve the resource by the multiple getter methods
*/
public void scan(ProgressMonitor pm) {
pm.beginTask("Scanning for resources...", scanLocations.length);
for (int i = 0; i < scanLocations.length; i++) {
URL scanLocation = scanLocations[i];
ArrayList<URL> resourceUrls = new ArrayList<URL>();
collectResources(scanLocation, relPath, resourceUrls);
resourcesMap.putAll(splitResourceUrls(scanLocation, relPath, resourceUrls));
pm.worked(1);
}
}
代码示例来源:origin: senbox-org/s1tbx
/**
* Called by the framework in order to compute the stack of tiles for the given target bands.
* <p>The default implementation throws a runtime exception with the message "not implemented".</p>
*
* @param targetTiles The current tiles to be computed for each target band.
* @param targetRectangle The area in pixel coordinates to be computed (same for all rasters in <code>targetRasters</code>).
* @param pm A progress monitor which should be used to determine computation cancelation requests.
* @throws OperatorException if an error occurs during computation of the target rasters.
*/
@Override
public void computeTileStack(Map<Band, Tile> targetTiles, Rectangle targetRectangle, ProgressMonitor pm) throws OperatorException {
try {
polDecomp.computeTile(targetTiles, targetRectangle, this);
} catch (Throwable e) {
OperatorUtils.catchOperatorException(getId(), e);
} finally {
pm.done();
}
}
代码示例来源:origin: bcdev/beam
@Override
public void tileComputed(Object eventSource, TileRequest[] requests, PlanarImage image, int tileX, int tileY,
Raster raster) {
semaphore.release();
pm.worked(1);
}
代码示例来源: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 static void checkCanceled(ProgressMonitor pm) throws IOException {
if (pm.isCanceled()) {
throw new IOException("Process terminated by user.");
}
}
代码示例来源: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 {
if (this.gdalReader == null) {
pm.beginTask("Reading band data...", 3);
NITFReaderWrapper reader = readerMap.get(destBand);
try {
reader.readBandData(sourceOffsetX, sourceOffsetY, sourceWidth, sourceHeight, sourceStepX, sourceStepY, destBuffer, pm);
} 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
private void addTimeSeriesProductToVisat(TimeSeriesAssistantModel assistantModel, ProgressMonitor pm) {
pm.beginTask("Creating Time Series", 50);
final ProductLocationsPaneModel locationsModel = assistantModel.getProductLocationsModel();
pm.worked(1);
final VariableSelectionPaneModel variablesModel = assistantModel.getVariableSelectionModel();
pm.worked(1);
final AbstractTimeSeries timeSeries = TimeSeriesFactory.create(assistantModel.getTimeSeriesName(),
locationsModel.getProductLocations(),
variablesModel.getSelectedVariableNames());
pm.worked(42);
ProductManager productManager = VisatApp.getApp().getProductManager();
Product tsProduct = timeSeries.getTsProduct();
productManager.addProduct(tsProduct);
pm.worked(6);
}
代码示例来源:origin: senbox-org/s1tbx
/**
* Called by the framework in order to compute the stack of tiles for the given target bands.
* <p>The default implementation throws a runtime exception with the message "not implemented".</p>
*
* @param targetTiles The current tiles to be computed for each target band.
* @param targetRectangle The area in pixel coordinates to be computed (same for all rasters in <code>targetRasters</code>).
* @param pm A progress monitor which should be used to determine computation cancelation requests.
* @throws org.esa.snap.core.gpf.OperatorException if an error occurs during computation of the target rasters.
*/
@Override
public void computeTileStack(Map<Band, Tile> targetTiles, Rectangle targetRectangle, ProgressMonitor pm) throws OperatorException {
try {
polDecomp.computeTile(targetTiles, targetRectangle, this);
} catch (Throwable e) {
OperatorUtils.catchOperatorException(getId(), e);
} finally {
pm.done();
}
}
代码示例来源:origin: bcdev/beam
@Override
public void tileComputed(Object eventSource, TileRequest[] requests, PlanarImage image, int tileX, int tileY,
Raster raster) {
for (PlanarImage planarImage : images) {
if (image != planarImage) {
BeamLogManager.getSystemLogger().finest(String.format("Scheduling tile x=%d/%d y=%d/%d for %s",
tileX + 1, tileCountX, tileY + 1, tileCountY, planarImage));
planarImage.getTile(tileX, tileY);
}
pm.worked(1);
}
semaphore.release();
}
代码示例来源:origin: bcdev/beam
private static void checkForCancelation(ProgressMonitor pm) {
if (pm.isCanceled()) {
throw new OperatorException("Operation canceled.");
}
}
代码示例来源:origin: bcdev/beam
@Override
void setUpRows(ProgressMonitor pm) {
pm.beginTask("Exporting pin data as csv-file...", pins.size());
for (Placemark pin : pins) {
for (List<Band> bandList : variablesList) {
if (!bandList.isEmpty()) {
rows.add(setUpRow(pin, bandList));
}
}
pm.worked(1);
}
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
@Override
protected Product doInBackground(ProgressMonitor pm) throws Exception {
pm.beginTask("Binning...", 100);
final Map<String, Object> parameters = new HashMap<>();
updateParameterMap(parameters);
final Product targetProduct = GPF.createProduct("Binning", parameters, formModel.getSourceProducts());
pm.done();
return targetProduct;
}
}
代码示例来源: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();
}
}
内容来源于网络,如有侵权,请联系作者删除!