本文整理汇总了Java中com.bc.ceres.core.ProgressMonitor.isCanceled方法的典型用法代码示例。如果您正苦于以下问题:Java ProgressMonitor.isCanceled方法的具体用法?Java ProgressMonitor.isCanceled怎么用?Java ProgressMonitor.isCanceled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.bc.ceres.core.ProgressMonitor
的用法示例。
在下文中一共展示了ProgressMonitor.isCanceled方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reprojectProducts
import com.bc.ceres.core.ProgressMonitor; //导入方法依赖的package包/类
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<>();
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();
}
}
示例2: getAllProducts
import com.bc.ceres.core.ProgressMonitor; //导入方法依赖的package包/类
private List<Product> getAllProducts(ProgressMonitor pm) {
List<Product> result = new ArrayList<>();
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;
}
示例3: readBandRasterDataImpl
import com.bc.ceres.core.ProgressMonitor; //导入方法依赖的package包/类
@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();
}
}
示例4: performAction
import com.bc.ceres.core.ProgressMonitor; //导入方法依赖的package包/类
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();
}
}
示例5: exportTransectPixels
import com.bc.ceres.core.ProgressMonitor; //导入方法依赖的package包/类
/**
* Writes all pixel values of the given product within the given ROI to the specified out.
*
* @param out the data output writer
* @param product the product providing the pixel values
* @return {@code true} for success, {@code false} if export has been terminated (by user)
*/
private boolean exportTransectPixels(final PrintWriter out,
final Product product,
final TransectProfileData transectProfileData,
final int numTransectPixels,
ProgressMonitor pm) {
final Band[] bands = product.getBands();
final TiePointGrid[] tiePointGrids = product.getTiePointGrids();
final GeoCoding geoCoding = product.getSceneGeoCoding();
if (mustCreateHeader) {
writeFileHeader(out, bands);
}
writeTableHeader(out, geoCoding, bands, mustExportTiePoints, tiePointGrids, mustExportWavelengthsAndSF);
final Point2D[] pixelPositions = transectProfileData.getPixelPositions();
pm.beginTask("Writing pixel data...", numTransectPixels);
try {
for (Point2D pixelPosition : pixelPositions) {
int x = (int) Math.floor(pixelPosition.getX());
int y = (int) Math.floor(pixelPosition.getY());
if (x >= 0 && x < product.getSceneRasterWidth()
&& y >= 0 && y < product.getSceneRasterHeight()) {
writeDataLine(out, geoCoding, bands, mustExportTiePoints, tiePointGrids, x, y);
pm.worked(1);
if (pm.isCanceled()) {
return false;
}
}
}
} finally {
pm.done();
}
return true;
}
示例6: computeTileStack
import com.bc.ceres.core.ProgressMonitor; //导入方法依赖的package包/类
@Override
public void computeTileStack(Map<Band, Tile> targetTiles, Rectangle targetRectangle, ProgressMonitor pm) throws OperatorException {
Tile tileFLH = targetTiles.get(flhBand);
Tile tileFLHQF = targetTiles.get(flhQfBand);
pm.beginTask("Computing FLH", targetRectangle.height);
Tile tileL1 = getSourceTile(band1, targetRectangle);
Tile tileL2 = getSourceTile(band2, targetRectangle);
Tile tileL3 = getSourceTile(band3, targetRectangle);
Tile tileMask = getSourceTile(valid, targetRectangle);
try {
for (int y = targetRectangle.y; y < targetRectangle.y + targetRectangle.height; y++) {
if (pm.isCanceled()) {
return;
}
for (int x = targetRectangle.x; x < targetRectangle.x + targetRectangle.width; x++) {
float FLH;
byte flags = 0;
if (tileMask.getSampleBoolean(x, y)) {
float L1 = tileL1.getSampleFloat(x, y);
float L2 = tileL2.getSampleFloat(x, y);
float L3 = tileL3.getSampleFloat(x, y);
FLH = L2 - k * (L1 + (L3 - L1) * wavelengthsRatio);
} else {
FLH = Float.NaN;
}
tileFLH.setSample(x, y, FLH);
if (FLH < 0) {
flags |= 0x01;
}
if (FLH > 1) {
flags |= 0x02;
}
if (Float.isNaN(FLH)) {
flags |= 0x04;
}
tileFLHQF.setSample(x, y, flags);
}
pm.worked(1); // Report to the progress monitor that we have completed 1 work unit
}
} finally {
pm.done(); // Report to the progress monitor that we are done
}
}
示例7: readBandData
import com.bc.ceres.core.ProgressMonitor; //导入方法依赖的package包/类
public void readBandData(int sourceOffsetX, int sourceOffsetY, int sourceWidth, int sourceHeight,
int sourceStepX, int sourceStepY, ProductData destBuffer, ProgressMonitor pm) throws IOException {
pm.beginTask("Reading band ...", sourceHeight);
try {
ImageReadParam readParam = reader.getDefaultReadParam();
readParam.setSourceBands(new int[]{0});
readParam.setSourceSubsampling(sourceStepX, sourceStepY, 0, 0);
readParam.setSourceRegion(new Rectangle(sourceOffsetX, sourceOffsetY, sourceWidth, sourceHeight));
Raster raster;
synchronized (lock) {
raster = reader.readRaster(0, readParam);
}
DataBuffer dataBuffer = raster.getDataBuffer();
int bufferSize = dataBuffer.getSize();
switch (destBuffer.getType()) {
case ProductData.TYPE_UINT8:
case ProductData.TYPE_INT8:
case ProductData.TYPE_INT32:
for (int i = 0; i < bufferSize; i++) {
if (pm.isCanceled()) {
break;
}
destBuffer.setElemIntAt(i, dataBuffer.getElem(i));
}
break;
case ProductData.TYPE_UINT16:
case ProductData.TYPE_INT16:
for (int i = 0; i < bufferSize; i++) {
if (pm.isCanceled()) {
break;
}
destBuffer.setElemUIntAt(i, swapBytes((short) dataBuffer.getElem(i)));
}
break;
case ProductData.TYPE_UINT32:
for (int i = 0; i < bufferSize; i++) {
if (pm.isCanceled()) {
break;
}
destBuffer.setElemUIntAt(i, dataBuffer.getElem(i));
}
break;
case ProductData.TYPE_FLOAT32:
for (int i = 0; i < bufferSize; i++) {
if (pm.isCanceled()) {
break;
}
destBuffer.setElemFloatAt(i, dataBuffer.getElemFloat(i));
}
break;
}
pm.worked(1);
} catch (IOException e) {
logger.severe(e.getMessage());
throw e;
} finally {
pm.done();
}
}
示例8: performAction
import com.bc.ceres.core.ProgressMonitor; //导入方法依赖的package包/类
public void performAction(final ProgressMonitor pm) {
final ProductEntry[] selections = actionHandler.getSelectedProductEntries();
//System.out.println("JointSearchActionExt.performAction: joint search selected for " + selections[0].getMission());
final JointSearchDialog dlg = new JointSearchDialog("Joint Search Criteria", selections[0].getMission());
dlg.show();
if (!dlg.IsOK()) {
return;
}
final DBQuery dbQuery = new DBQuery();
// Search for products close in space to the selected product
dbQuery.setSelectionRect(selections[0].getGeoBoundary());
// Search for products from the missions the user has selected
dbQuery.setSelectedMissions(dlg.getMissions()); //
// Search for products within the time range that is +/- number of days from the date of the selected product
final int daysMinus = dlg.getDaysMinus();
final int daysPlus = dlg.getDaysPlus();
if (daysMinus < 0 || daysPlus < 0) {
Dialogs.showError("Joint search: invalid number of days\n (must be 0 or +ve integer)");
return;
}
//SystemUtils.LOG.info("Joint Search -" + daysMinus + " days and +" + daysPlus + " days");
Calendar startDate = selections[0].getFirstLineTime().getAsCalendar();
startDate.add(Calendar.DAY_OF_MONTH, -daysMinus);
Calendar endDate = selections[0].getFirstLineTime().getAsCalendar();
endDate.add(Calendar.DAY_OF_MONTH, daysPlus);
dbQuery.setStartEndDate(startDate, endDate);
// Search for optical products based on cloud cover percentage
dbQuery.setSelectedCloudCover(dlg.getCloudCover());
// Search for products with this particular acquisition mode
dbQuery.setSelectedAcquisitionMode(dlg.getAcquisitionMode());
// Search for products of these product types
dbQuery.setSelectedProductTypes(dlg.getProductTypes());
ProductQueryInterface productQueryInterface = CopernicusProductQuery.instance();
try {
productQueryInterface.fullQuery(dbQuery, pm);
if (!pm.isCanceled()) {
actionHandler.getToolView().setSelectedRepositoryToSciHub();
}
} catch (Exception e) {
Dialogs.showError("unable to do joint search: " + e.getMessage());
} finally {
pm.done();
}
}
示例9: createXYDisplacementBands
import com.bc.ceres.core.ProgressMonitor; //导入方法依赖的package包/类
private static Band[] createXYDisplacementBands(final Product product, ProgressMonitor pm) {
final int width = product.getSceneRasterWidth();
final int height = product.getSceneRasterHeight();
ImageInfo blueToRedGrad = new ImageInfo(new ColorPaletteDef(new ColorPaletteDef.Point[]{
new ColorPaletteDef.Point(-1.0, Color.BLUE),
new ColorPaletteDef.Point(0.0, Color.WHITE),
new ColorPaletteDef.Point(1.0, Color.RED),
}));
ImageInfo amplGrad = new ImageInfo(new ColorPaletteDef(new ColorPaletteDef.Point[]{
new ColorPaletteDef.Point(0.0, Color.WHITE),
new ColorPaletteDef.Point(1.0, Color.RED),
}));
ImageInfo phaseGrad = new ImageInfo(new ColorPaletteDef(new ColorPaletteDef.Point[]{
new ColorPaletteDef.Point(-Math.PI, Color.WHITE),
new ColorPaletteDef.Point(0.0, Color.BLUE),
new ColorPaletteDef.Point(+Math.PI, Color.WHITE),
}));
final Band bandX = new Band("gc_displ_x", ProductData.TYPE_FLOAT64, width, height);
configureBand(bandX, blueToRedGrad.clone(), "pixels", "Geo-coding X-displacement");
final Band bandY = new Band("gc_displ_y", ProductData.TYPE_FLOAT64, width, height);
configureBand(bandY, blueToRedGrad.clone(), "pixels", "Geo-coding Y-displacement");
final Band bandAmpl = new VirtualBand("gc_displ_ampl",
ProductData.TYPE_FLOAT64, width, height,
"ampl(gc_displ_x, gc_displ_y)");
configureBand(bandAmpl, amplGrad.clone(), "pixels", "Geo-coding displacement amplitude");
final Band bandPhase = new VirtualBand("gc_displ_phase",
ProductData.TYPE_FLOAT64, width, height,
"phase(gc_displ_x, gc_displ_y)");
configureBand(bandPhase, phaseGrad.clone(), "radians", "Geo-coding displacement phase");
final double[] dataX = new double[width * height];
final double[] dataY = new double[width * height];
bandX.setRasterData(ProductData.createInstance(dataX));
bandY.setRasterData(ProductData.createInstance(dataY));
pm.beginTask("Computing geo-coding displacements for product '" + product.getName() + "'...", height);
try {
final GeoPos geoPos = new GeoPos();
final PixelPos pixelPos1 = new PixelPos();
final PixelPos pixelPos2 = new PixelPos();
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
double maxX = 0;
double maxY = 0;
double valueX = 0;
double valueY = 0;
for (float[] offset : OFFSETS) {
pixelPos1.setLocation(x + offset[0], y + offset[1]);
product.getSceneGeoCoding().getGeoPos(pixelPos1, geoPos);
product.getSceneGeoCoding().getPixelPos(geoPos, pixelPos2);
double dx = pixelPos2.x - pixelPos1.x;
double dy = pixelPos2.y - pixelPos1.y;
if (Math.abs(dx) > maxX) {
maxX = Math.abs(dx);
valueX = dx;
}
if (Math.abs(dy) > maxY) {
maxY = Math.abs(dy);
valueY = dy;
}
}
dataX[y * width + x] = valueX;
dataY[y * width + x] = valueY;
}
if (pm.isCanceled()) {
return null;
}
pm.worked(1);
}
} finally {
pm.done();
}
return new Band[]{bandX, bandY, bandAmpl, bandPhase};
}
示例10: exportMaskPixels
import com.bc.ceres.core.ProgressMonitor; //导入方法依赖的package包/类
private static boolean exportMaskPixels(final PrintWriter out,
final Product product,
final RenderedImage maskImage,
String maskName,
boolean mustCreateHeader,
boolean mustExportTiePoints,
boolean mustExportWavelengthsAndSF,
ProgressMonitor pm) throws IOException {
final Band[] bands = product.getBands();
final TiePointGrid[] tiePointGrids = product.getTiePointGrids();
final GeoCoding geoCoding = product.getSceneGeoCoding();
final int minTileX = maskImage.getMinTileX();
final int minTileY = maskImage.getMinTileY();
final int numXTiles = maskImage.getNumXTiles();
final int numYTiles = maskImage.getNumYTiles();
final int w = product.getSceneRasterWidth();
final int h = product.getSceneRasterHeight();
final Rectangle imageRect = new Rectangle(0, 0, w, h);
pm.beginTask("Writing pixel data...", numXTiles * numYTiles + 2);
try {
if (mustCreateHeader) {
createHeader(out, product, maskName, mustExportWavelengthsAndSF);
}
pm.worked(1);
writeColumnNames(out, geoCoding, bands, mustExportTiePoints, tiePointGrids);
pm.worked(1);
for (int tileX = minTileX; tileX < minTileX + numXTiles; ++tileX) {
for (int tileY = minTileY; tileY < minTileY + numYTiles; ++tileY) {
if (pm.isCanceled()) {
return false;
}
final Rectangle tileRectangle = new Rectangle(maskImage.getTileGridXOffset() + tileX * maskImage.getTileWidth(),
maskImage.getTileGridYOffset() + tileY * maskImage.getTileHeight(),
maskImage.getTileWidth(), maskImage.getTileHeight());
final Rectangle r = imageRect.intersection(tileRectangle);
if (!r.isEmpty()) {
Raster maskTile = maskImage.getTile(tileX, tileY);
for (int y = r.y; y < r.y + r.height; y++) {
for (int x = r.x; x < r.x + r.width; x++) {
if (maskTile.getSample(x, y, 0) != 0) {
writeDataLine(out, geoCoding, bands, mustExportTiePoints, tiePointGrids, x, y);
}
}
}
}
pm.worked(1);
}
}
} finally {
pm.done();
}
return true;
}
示例11: computeMaskAreaStatistics
import com.bc.ceres.core.ProgressMonitor; //导入方法依赖的package包/类
private MaskAreaStatistics computeMaskAreaStatistics(ProgressMonitor pm) {
final MultiLevelImage maskImage = mask.getSourceImage();
final int minTileX = maskImage.getMinTileX();
final int minTileY = maskImage.getMinTileY();
final int numXTiles = maskImage.getNumXTiles();
final int numYTiles = maskImage.getNumYTiles();
final int w = mask.getRasterWidth();
final int h = mask.getRasterHeight();
final Rectangle imageRect = new Rectangle(0, 0, w, h);
final PixelPos[] pixelPoints = new PixelPos[5];
final GeoPos[] geoPoints = new GeoPos[5];
for (int i = 0; i < geoPoints.length; i++) {
pixelPoints[i] = new PixelPos();
geoPoints[i] = new GeoPos();
}
GeoCoding geoCoding = mask.getGeoCoding();
AreaCalculator areaCalculator = new AreaCalculator(geoCoding);
MaskAreaStatistics areaStatistics = new MaskAreaStatistics(areaCalculator.getEarthRadius() / 1000.0);
pm.beginTask("Computing Mask area...", numXTiles * numYTiles);
try {
for (int tileX = minTileX; tileX < minTileX + numXTiles; ++tileX) {
for (int tileY = minTileY; tileY < minTileY + numYTiles; ++tileY) {
if (pm.isCanceled()) {
break;
}
final Rectangle tileRectangle = new Rectangle(
maskImage.getTileGridXOffset() + tileX * maskImage.getTileWidth(),
maskImage.getTileGridYOffset() + tileY * maskImage.getTileHeight(),
maskImage.getTileWidth(), maskImage.getTileHeight());
final Rectangle r = imageRect.intersection(tileRectangle);
if (!r.isEmpty()) {
Raster maskTile = maskImage.getTile(tileX, tileY);
for (int y = r.y; y < r.y + r.height; y++) {
for (int x = r.x; x < r.x + r.width; x++) {
if (maskTile.getSample(x, y, 0) != 0) {
double pixelArea = areaCalculator.calculatePixelSize(x, y) / Math.pow(1000.0, 2);
areaStatistics.setPixelAreaMin(Math.min(areaStatistics.getPixelAreaMin(), pixelArea));
areaStatistics.setPixelAreaMax(Math.max(areaStatistics.getPixelAreaMax(), pixelArea));
areaStatistics.setMaskArea(areaStatistics.getMaskArea() + pixelArea);
areaStatistics.setNumPixels(areaStatistics.getNumPixels() + 1);
}
}
}
}
pm.worked(1);
}
}
} finally {
pm.done();
}
return areaStatistics;
}