/******************************************************************************************************************* * * DO NOT USE THIS. This method is only used by the module implementation. * ******************************************************************************************************************/ public final ImageModel getImageModel() { return imageModelHolder.get(); }
@Override public String toString() { final StringBuffer buffer = new StringBuffer(getClass().getName() + "["); final ImageModel model = get(); buffer.append((model != null) ? model.getId() : "null"); if (model != null) { final String nickName = getNickName(); if (nickName != null) { buffer.append(", " + nickName); } } buffer.append("]"); return buffer.toString(); } }
/******************************************************************************************************************* * * Returns true if the image has a raster (EditableImages can be loaded with * metadata only). * * @return true if the image has a raster * ******************************************************************************************************************/ public final boolean hasRaster() { return imageModelHolder.get() != null; }
/******************************************************************************************************************* * * Returns the width of this image. * * @return the width * ******************************************************************************************************************/ public final int getWidth() { return imageModelHolder.get().getWidth(); }
/******************************************************************************************************************* * * Returns the dataType used by this image. * * @return the data type * ******************************************************************************************************************/ public final DataType getDataType() { return imageModelHolder.get().getDataType(); }
/******************************************************************************************************************* * * Returns the ColorModel of this image. * * @return the color model * ******************************************************************************************************************/ public final ColorModel getColorModel() // FIXME: to be removed { return imageModelHolder.get().getColorModel(); }
/******************************************************************************************************************* * * Returns the height of this image. * * @return the height * ******************************************************************************************************************/ public final int getHeight() { return imageModelHolder.get().getHeight(); }
/******************************************************************************************************************* * * Returns an estimate of the memory allocated by this image. * * @return the memory allocated for this image * ******************************************************************************************************************/ public final long getMemorySize() { final ImageModel imageModel = imageModelHolder.get(); return (imageModel != null) ? imageModel.getMemorySize() : 0; }
/******************************************************************************************************************* * * Returns the number of bands this EditableImage is composed of. * * @return the band count * ******************************************************************************************************************/ public final int getBandCount() { return imageModelHolder.get().getBandCount(); }
/******************************************************************************************************************* * * Clones this image. * ******************************************************************************************************************/ public final EditableImage cloneImage() { final EditableImage imageCopy = imageModelHolder.get().createCopy(true); imageCopy.attributeMapByName = new HashMap<String, Object>(attributeMapByName); return imageCopy; }
/******************************************************************************************************************* * * Removes all the resources bound to this image. * ******************************************************************************************************************/ public final void dispose() { imageModelHolder.get().dispose(); imageModelHolder = null; attributeMapByName.clear(); }
/******************************************************************************************************************* * * This is only for testing purposes. * ******************************************************************************/ public final <T> T getInnerProperty (final Class<T> propertyClass) { if (IIOMetadata.class.equals(propertyClass)) { return (T)iioMetadata; } return imageModelHolder.get().getInnerProperty(propertyClass); }
public void setNickName (final String nickName) { get().setNickName(nickName); }
public String getNickName() { return get().getNickName(); }
/******************************************************************************************************************* * * Creates a similar image, that is a blank image with the same characteristics * of this image (width, height, data type, color model). * @deprecated will be merged with create(AbstractCreateOp) * * @return a new, similar image * ******************************************************************************************************************/ public final EditableImage createSimilarImage() { final EditableImage imageCopy = imageModelHolder.get().createCopy(false); imageCopy.attributeMapByName = new HashMap<String, Object>(attributeMapByName); return imageCopy; }
/******************************************************************************************************************* * * Executes an operation. The original image is lost and replaced by results. * * @param operation the operation to perform * @return the operation (as a convenience in case it carries * results) * ******************************************************************************************************************/ @Nonnull public final <T extends Operation> T execute (final @Nonnull T operation) { long time = System.currentTimeMillis(); Object image = internalExecute(operation); imageModelHolder.get().setImage(image); latestOperationTime = System.currentTimeMillis() - time; return operation; }
/******************************************************************************************************************* * * Executes an operation. The original image is untouched as the results are * placed in a brand new instance of EditableImage. * * @param operation the operation to perform * @return the result * ******************************************************************************************************************/ @Nonnull public final EditableImage execute2 (final @Nonnull Operation operation) { try { long time = System.currentTimeMillis(); Object image = internalExecute(operation); Class modelClass = imageModelHolder.get().getClass(); Constructor constructor = modelClass.getConstructor(Object.class); ImageModel newModel = (ImageModel)constructor.newInstance(image); EditableImage result = new EditableImage(newModel); result.attributeMapByName = new HashMap<String, Object>(attributeMapByName); result.latestOperationTime = System.currentTimeMillis() - time; return result; } catch (Exception e) { throw new RuntimeException(e); } }
final ImageModel imageModel = imageModelHolder.get(); Object image = (imageModel != null) ? imageModel.getImage() : null; OperationImplementation implementation = null; implementation = implementationFactoryRegistry.findImplementation(operation, imageModelHolder.get(), false); implementation = implementationFactoryRegistry.findImplementation(operation, imageModelHolder.get(), true); log.info("Found alternate implementation: {}", implementation); image = imageModelHolder.get().getImage(); else if (imageModelHolder.get().getFactory().canConvertTo(implementation.getFactory().getModelClass())) image = imageModelHolder.get().getFactory().convertTo(implementation.getFactory().getModelClass());