com.bc.ceres.core.Assert.state()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(10.8k)|赞(0)|评价(0)|浏览(146)

本文整理了Java中com.bc.ceres.core.Assert.state()方法的一些代码示例,展示了Assert.state()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert.state()方法的具体详情如下:
包路径:com.bc.ceres.core.Assert
类名称:Assert
方法名:state

Assert.state介绍

暂无

代码示例

代码示例来源:origin: bcdev/beam

private void validate() {
  Assert.state(config.raster != null, "raster == null");
  Assert.state(config.path != null || pointData != null, "path != null || pointData != null");
  Assert.state(config.path == null && pointData != null
         || config.path != null && pointData == null,
         "path == null && pointData != null || path != null && pointData == null");
}

代码示例来源:origin: bcdev/beam

private void assertDescriptorSet() {
  Assert.state(descriptor != null, "descriptor != null");
}

代码示例来源:origin: senbox-org/snap-desktop

public WWLayer createWWLayer() {
    Assert.state(WWLayerClass != null, "WWLayerClass != null");
    Object object;
    try {
      object = WWLayerClass.newInstance();
    } catch (Throwable e) {
      throw new IllegalStateException("WWLayerClass.newInstance()", e);
    }
    Assert.state(object instanceof WWLayer, "object instanceof WWLayer");
    return (WWLayer) object;
  }
}

代码示例来源:origin: bcdev/beam

@Override
public RecordSource loadSource() throws IOException {
  Assert.state(reader != null, "reader != null");
  Assert.state(dateFormat != null, "dateFormat != null");
  return new CsvRecordSource(reader, dateFormat);
}

代码示例来源:origin: bcdev/beam

protected ToolView createToolView() {
  Assert.state(toolViewClass != null, "toolViewClass != null");
  Object object;
  try {
    object = toolViewClass.newInstance();
  } catch (Throwable e) {
    throw new IllegalStateException("viewClass.newInstance()", e);
  }
  Assert.state(object instanceof ToolView, "object instanceof ToolView");
  ToolView toolView = (ToolView) object;
  toolView.setDescriptor(this);
  return toolView;
}

代码示例来源:origin: bcdev/beam

private static int computePreferredTileSize(int imageSize, int granularity) {
  if (imageSize <= MAX_TILE_SIZE) {
    return imageSize;
  }
  for (int u = MAX_TILE_SIZE; u >= MIN_TILE_SIZE; u -= TILE_SIZE_STEP) {
    if (imageSize % u == 0) {
      return u;
    }
  }
  int minDelta = Integer.MAX_VALUE;
  int tileSize = -1;
  for (int u = MAX_TILE_SIZE; u >= MIN_TILE_SIZE; u -= granularity) {
    int n = imageSize / u;
    if (n * u == imageSize) {
      return u;
    } else if (n * u < imageSize) {
      n++;
    }
    final int delta = Math.abs(n * u - imageSize);
    if (delta < minDelta) {
      minDelta = delta;
      tileSize = u;
    }
  }
  Assert.state(tileSize != -1);
  return tileSize;
}

代码示例来源:origin: bcdev/beam

@Override
public final void setDescriptor(PageComponentDescriptor descriptor) {
  Assert.notNull(descriptor, "descriptor");
  Assert.state(this.descriptor == null, "this.descriptor == null");
  this.descriptor = descriptor;
}

代码示例来源:origin: bcdev/beam

@Override
protected synchronized void readBandRasterDataImpl(int sourceOffsetX,
                          int sourceOffsetY,
                          int sourceWidth,
                          int sourceHeight,
                          int sourceStepX,
                          int sourceStepY,
                          Band targetBand,
                          int targetOffsetX,
                          int targetOffsetY,
                          int targetWidth,
                          int targetHeight,
                          ProductData targetBuffer,
                          ProgressMonitor pm) throws IOException {
  Assert.state(sourceOffsetX == targetOffsetX, "sourceOffsetX != targetOffsetX");
  Assert.state(sourceOffsetY == targetOffsetY, "sourceOffsetY != targetOffsetY");
  Assert.state(sourceStepX == 1, "sourceStepX != 1");
  Assert.state(sourceStepY == 1, "sourceStepY != 1");
  Assert.state(sourceWidth == targetWidth, "sourceWidth != targetWidth");
  Assert.state(sourceHeight == targetHeight, "sourceHeight != targetHeight");
  final int index = targetBand.getSpectralBandIndex();
  if (targetBand.equals(rciBands[index])) {
    readRciBandRasterData(index, targetBuffer, sourceOffsetX, sourceOffsetY, targetWidth, targetHeight, pm);
  } else {
    readMaskBandRasterData(index, targetBuffer, sourceOffsetX, sourceOffsetY, targetWidth, targetHeight, pm);
  }
}

代码示例来源:origin: senbox-org/snap-desktop

public OperatorUI createOperatorUI() {
    if(operatorUIClass == null) {
      return new DefaultUI();
    }
    Object object;
    try {
      object = operatorUIClass.newInstance();
    } catch (Throwable e) {
      throw new IllegalStateException("operatorUIClass.newInstance()", e);
    }
    Assert.state(object instanceof OperatorUI, "object instanceof operatorUI");
    return (OperatorUI) object;
  }
}

代码示例来源:origin: senbox-org/snap-desktop

private ColorCodes() {
  nameList = new ArrayList<>(512);
  nameMap = new HashMap<>(512);
  colorMap = new HashMap<>(512);
  try {
    Path path = FileUtils.getPathFromURI(ColorComboBox.class.getResource("color-codes.txt").toURI());
    List<String> lines = Files.readAllLines(path);
    for (String line : lines) {
      int i = line.indexOf('\t');
      Color color = Color.decode(line.substring(0, i).trim());
      String name = line.substring(i).trim();
      //System.out.println("color = " + color + ", name = " + name);
      Assert.state(!nameMap.containsKey(color), String.format("color '%s' already added", color));
      Assert.state(!colorMap.containsKey(name), String.format("color '%s' already added", name));
      nameList.add(name);
      nameMap.put(color, name);
      colorMap.put(name, color);
    }
  } catch (URISyntaxException | IOException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: senbox-org/snap-desktop

public ProductLibraryActionExt createActionExt(final ProductLibraryActions actionHandler) {
    if(isSeperator()) {
      return null;
    }
    Object object;
    try {
      object = actionExtClass.newInstance();
      ((ProductLibraryActionExt) object).setActionHandler(actionHandler);
    } catch (Throwable e) {
      throw new IllegalStateException("actionExtClass.newInstance()", e);
    }
    Assert.state(object instanceof ProductLibraryActionExt, "object instanceof ProductLibraryActionExt");
    return (ProductLibraryActionExt) object;
  }
}

代码示例来源:origin: bcdev/beam

private static void repopulatePopMenu(JPopupMenu popupMenu, ArrayList<Command> commands, Map<String, JMenuItem> menuItemMap) {
  popupMenu.removeAll();
  for (int i = 0; i < commands.size(); i++) {
    Command command = commands.get(i);
    JMenuItem menuItem = menuItemMap.get(command.getCommandID());
    Assert.state(menuItem != null);
    int componentCount = popupMenu.getComponentCount();
    if (command.isSeparatorBefore() && componentCount > 0 && !(popupMenu.getComponent(componentCount - 1) instanceof JSeparator)) {
      popupMenu.addSeparator();
    }
    popupMenu.add(menuItem);
    if (command.isSeparatorAfter() && i < commands.size() - 1) {
      popupMenu.addSeparator();
    }
  }
}

代码示例来源:origin: bcdev/beam

/**
 * Sets the tool window's context.
 * <p/>
 * <p>Clients may override this method in order configure their tool window.
 * However, after calling this method,
 * {@link #getContext()} shall return the same {@code context}.</p>
 * <p/>
 * <p>Clients must not call this method directly, it is called only once by the framework after a {@link PageComponentContext}
 * has been created for this tool window.</p>
 *
 * @param context The tool window part.
 */
@Override
public final void setContext(PageComponentContext context) {
  Assert.notNull(context, "context");
  Assert.state(this.context == null, "this.context == null");
  this.context = context;
  registerLocalCommandExecutors(context);
}

代码示例来源:origin: senbox-org/snap-desktop

/**
 * Create a panel that allows the user to set the parameters in the given {@link BindingContext}. Clients that want
 * to create their own panel representation on the given properties need to overwrite this method.
 *
 * @param context The {@link BindingContext} for the panel.
 *
 * @return A JPanel instance for the given {@link BindingContext}, never {@code null}.
 */
protected JPanel createPanel(BindingContext context) {
  Assert.state(isInitialised());
  return new PreferencesPanel(null, bindingContext).getComponent();
}

代码示例来源:origin: bcdev/beam

private void loadToolViews() {
  ToolViewDescriptor[] toolViewDescriptors = VisatActivator.getInstance().getToolViewDescriptors();
  for (ToolViewDescriptor toolViewDescriptor : toolViewDescriptors) {
    applicationPage.addToolView(toolViewDescriptor);
  }
  productsToolView = (ProductsToolView) applicationPage.getToolView(ProductsToolView.ID);
  Assert.state(productsToolView != null, "productsToolView != null");
}

代码示例来源:origin: bcdev/beam

public RenderedImage createColoredBandImage(RasterDataNode[] rasterDataNodes,
                      ImageInfo imageInfo,
                      int level) {
  Assert.notNull(rasterDataNodes, "rasterDataNodes");
  Assert.state(rasterDataNodes.length == 1
             || rasterDataNodes.length == 3
             || rasterDataNodes.length == 4,
         "invalid number of bands");
  prepareImageInfos(rasterDataNodes, ProgressMonitor.NULL);
  if (rasterDataNodes.length == 1) {
    return createColored1BandImage(rasterDataNodes[0], imageInfo, level);
  } else {
    return createColored3BandImage(rasterDataNodes, imageInfo, level);
  }
}

代码示例来源:origin: bcdev/beam

private WritableRaster getWritableRaster(Band band, WritableRaster targetTileRaster) {
  WritableRaster tileRaster;
  if (band == getTargetBand()) {
    tileRaster = targetTileRaster;
  } else {
    OperatorContext operatorContext = getOperatorContext();
    // casting to access "getWritableRaster" method
    OperatorImageTileStack operatorImage = (OperatorImageTileStack) operatorContext.getTargetImage(band);
    Assert.state(operatorImage != this);
    tileRaster = operatorImage.getWritableRaster(targetTileRaster.getBounds());
  }
  return tileRaster;
}

代码示例来源:origin: bcdev/beam

private void initializeOperator() throws OperatorException {
  Assert.state(targetProduct == null, "targetProduct == null");
  Assert.state(!initialising, "!initialising, attempt to call getTargetProduct() from within initialise()?");
  try {
    initialising = true;
    if (!(operator instanceof GraphOp)) {
      initSourceProductFields();
      updatePropertyDescriptors();
      injectConfiguration();
    }
    operator.initialize();
    initTargetProduct();
    initTargetProperties();
    initTargetImages();
    initGraphMetadata();
    targetProduct.setModified(false);
  } finally {
    initialising = false;
  }
}

代码示例来源:origin: bcdev/beam

private static VirtualBandOpImage create(String expression,
                     int dataType,
                     Number fillValue,
                     boolean mask,
                     Product product,
                     ResolutionLevel level) {
  Assert.notNull(product, "product");
  Assert.notNull(level, "level");
  final Product[] products;
  final int defaultProductIndex;
  if (product.getProductManager() != null) {
    products = product.getProductManager().getProducts();
    defaultProductIndex = product.getProductManager().getProductIndex(product);
  } else {
    products = new Product[]{product};
    defaultProductIndex = 0;
  }
  Assert.state(defaultProductIndex >= 0 && defaultProductIndex < products.length);
  Assert.state(products[defaultProductIndex] == product);
  return create(expression,
         dataType,
         fillValue,
         mask,
         products,
         defaultProductIndex,
         level);
}

代码示例来源:origin: bcdev/beam

public ImageInfo getImageInfo(RasterDataNode[] rasters) {
  Assert.notNull(rasters, "rasters");
  Assert.argument(rasters.length == 1 || rasters.length == 3, "rasters.length == 1 || rasters.length == 3");
  if (rasters.length == 1) {
    RasterDataNode raster = rasters[0];
    Assert.state(raster.getImageInfo() != null, "raster.getImageInfo() != null");
    return raster.getImageInfo();
  } else {
    final RGBChannelDef rgbChannelDef = new RGBChannelDef();
    for (int i = 0; i < rasters.length; i++) {
      RasterDataNode raster = rasters[i];
      Assert.state(rasters[i].getImageInfo() != null, "rasters[i].getImageInfo() != null");
      ImageInfo imageInfo = raster.getImageInfo();
      rgbChannelDef.setSourceName(i, raster.getName());
      rgbChannelDef.setMinDisplaySample(i, imageInfo.getColorPaletteDef().getMinDisplaySample());
      rgbChannelDef.setMaxDisplaySample(i, imageInfo.getColorPaletteDef().getMaxDisplaySample());
    }
    return new ImageInfo(rgbChannelDef);
  }
}

相关文章