static String getString(String key) { return getString("io.scif.media.imageioimpl.plugins.jpeg2000.I18N", key); } }
private void checkIndex(int imageIndex) { if (imageIndex != 0) { throw new IndexOutOfBoundsException(I18N.getString("J2KImageReader4")); } }
/** Sets the box extra length length to the provided value. */ public void setExtraLength(long extraLength) { if (length != 1) throw new IllegalArgumentException(I18N.getString("Box1")); this.extraLength = extraLength; }
public void setOutput(Object output) { super.setOutput(output); // validates output if (output != null) { if (!(output instanceof ImageOutputStream)) throw new IllegalArgumentException(I18N.getString("J2KImageWriter0")); this.stream = (ImageOutputStream)output; } else this.stream = null; }
/** Sets the box content. If the content length is not length -8 or * extra length - 16, IllegalArgumentException will be thrown. */ public void setContent(byte[] data) { if (data != null && ((length ==1 && (extraLength - 16 != data.length)) || (length != 1 && length - 8 != data.length))) throw new IllegalArgumentException(I18N.getString("Box2")); this.data = data; if (data != null) parse(data); }
private void checkSampleModel(SampleModel sm) { int type = sm.getDataType(); if (type < DataBuffer.TYPE_BYTE || type > DataBuffer.TYPE_INT) throw new IllegalArgumentException(I18N.getString("J2KImageWriter5")); if (sm.getNumBands() > 16384) throw new IllegalArgumentException(I18N.getString("J2KImageWriter6")); } }
public Node getAsTree(String formatName) { if (formatName == null) { throw new IllegalArgumentException(I18N.getString("J2KMetadata0")); } if (formatName.equals(nativeMetadataFormatName)) { return getNativeTree(); } if (formatName.equals (IIOMetadataFormatImpl.standardMetadataFormatName)) { return getStandardTree(); } throw new IllegalArgumentException(I18N.getString("J2KMetadata1") + " " + formatName); }
public void mergeTree(String formatName, Node root) throws IIOInvalidTreeException { if (formatName == null) { throw new IllegalArgumentException(I18N.getString("J2KMetadata0")); } if (root == null) { throw new IllegalArgumentException(I18N.getString("J2KMetadata2")); } if (formatName.equals(nativeMetadataFormatName) && root.getNodeName().equals(nativeMetadataFormatName)) { mergeNativeTree(root); } else if (formatName.equals (IIOMetadataFormatImpl.standardMetadataFormatName)) { mergeStandardTree(root); } else { throw new IllegalArgumentException(I18N.getString("J2KMetadata1") + " " + formatName); } }
public void setFromTree(String formatName, Node root) throws IIOInvalidTreeException { if (formatName == null) { throw new IllegalArgumentException(I18N.getString("J2KMetadata0")); } if (root == null) { throw new IllegalArgumentException(I18N.getString("J2KMetadata2")); } if (formatName.equals(nativeMetadataFormatName) && root.getNodeName().equals(nativeMetadataFormatName)) { boxes = new ArrayList(); mergeNativeTree(root); } else if (formatName.equals (IIOMetadataFormatImpl.standardMetadataFormatName)) { boxes = new ArrayList(); mergeStandardTree(root); } else { throw new IllegalArgumentException(I18N.getString("J2KMetadata1") + " " + formatName); } }
/** Constructs <code>J2KReadState</code>. * @param iis The input stream. * @param param The reading parameters. * @param reader The <code>J2KImageReader</code> which holds this state. * It is necessary for processing abortion. * @throw IllegalArgumentException If the provided <code>iis</code>, * or <code>param</code> is <code>null</code>. */ public J2KReadState(ImageInputStream iis, J2KImageReadParamJava param, J2KImageReader reader) { if (iis == null || param == null) throw new IllegalArgumentException(I18N.getString("J2KReadState0")); this.iis = iis; this.j2krparam = param; this.reader = reader; initializeRead(0, param, null); }
/** Constructs <code>J2KReadState</code>. * @param iis The input stream. * @param param The reading parameters. * @param metadata The <code>J2KMetadata</code> to cache the metadata read * from the input stream. * @param reader The <code>J2KImageReader</code> which holds this state. * It is necessary for processing abortion. * @throw IllegalArgumentException If the provided <code>iis</code>, * <code>param</code> or <code>metadata</code> is <code>null</code>. */ public J2KReadState(ImageInputStream iis, J2KImageReadParamJava param, J2KMetadata metadata, J2KImageReader reader) { if (iis == null || param == null || metadata == null) throw new IllegalArgumentException(I18N.getString("J2KReadState0")); this.iis = iis; this.j2krparam = param; this.metadata = metadata; this.reader = reader; initializeRead(0, param, metadata); }
/** Sets <code>packetPerTilePart</code> */ public void setPacketPerTilePart(int packetPerTilePart) { if (packetPerTilePart < 0) throw new IllegalArgumentException(I18N.getString("J2KImageWriteParamJava0")); this.packetPerTilePart = packetPerTilePart; if (packetPerTilePart > 0) { setSOP("true"); setEPH("true"); } }
private void createColorSpecificationBoxFromStandardNode(Node node) { if (node.getNodeName() != "ColorSpaceType") throw new IllegalArgumentException(I18N.getString("J2KMetadata4")); String name = (String)Box.getAttribute(node, "name"); int ecs = name.equals("RGB") ? ColorSpecificationBox.ECS_sRGB : (name.equals("Gray") ? ColorSpecificationBox.ECS_GRAY : 0); if (ecs == ColorSpecificationBox.ECS_sRGB || ecs ==ColorSpecificationBox.ECS_GRAY) { replace ("JPEG2000ColorSpecificationBox", new ColorSpecificationBox((byte)1, (byte)0, (byte)0, ecs, null)); } }
private void createResolutionBoxFromStandardNode(Node node) { if (node.getNodeName() != "Dimension") throw new IllegalArgumentException(I18N.getString("J2KMetadata7")); NodeList children = node.getChildNodes(); float hRes = 0.0f;
private void createChannelDefinitionFromStandardNode(Node node) { if (node.getNodeName() != "Transparency") throw new IllegalArgumentException(I18N.getString("J2KMetadata8"));
private void createBitsPerComponentBoxFromStandardNode(Node node) { if (node.getNodeName() != "Data") throw new IllegalArgumentException(I18N.getString("J2KMetadata6"));
throw new IllegalArgumentException(I18N.getString("J2KReadState1"));
/** Creates an <code>IIOMetadataNode</code> from this * box. The format of this node is defined in the XML dtd and xsd * for the JP2 image file. * * This method is designed for the types of boxes whose XML tree * only has 2 levels. */ protected IIOMetadataNode getNativeNodeForSimpleBox() { try { Method m = this.getClass().getMethod("getElementNames", (Class[])null); String[] elementNames = (String[])m.invoke(null, (Object[])null); IIOMetadataNode node = new IIOMetadataNode(Box.getName(getType())); setDefaultAttributes(node); for (int i = 0; i < elementNames.length; i++) { IIOMetadataNode child = new IIOMetadataNode(elementNames[i]); m = this.getClass().getMethod("get" + elementNames[i], (Class[])null); Object obj = m.invoke(this, (Object[])null); child.setUserObject(obj); child.setNodeValue(ImageUtil.convertObjectToString(obj)); node.appendChild(child); } return node; } catch (Exception e) { throw new IllegalArgumentException(I18N.getString("Box0")); } }
/** Creates an <code>IIOMetadataNode</code> from this XML * box. The format of this node is defined in the XML dtd and xsd * for the JP2 image file. */ public IIOMetadataNode getNativeNode() { try { IIOMetadataNode node = new IIOMetadataNode(Box.getName(getType())); setDefaultAttributes(node); IIOMetadataNode child = new IIOMetadataNode("Content"); String value = null; if (data != null) value = new String(data); child.setUserObject(value); child.setNodeValue(value); node.appendChild(child); return node; } catch (Exception e) { throw new IllegalArgumentException(I18N.getString("Box0")); } } }
/** * Creates <code>RenderedImageSrc</code> for encoding a <code>Raster</code>. * * @param raster The <code>Raster</code> to be encoded. * @param param The <code>J2KImageWriteParamJava</code> used in encoding. * @param writer The <code>J2KImageWriter</code> performs the encoding. * * @param IOException If an error occurs while opening the file. */ public RenderedImageSrc(Raster raster, J2KImageWriteParamJava param, J2KImageWriter writer) { this.raster = raster; this.param = param; this.writer = writer; this.inputIsRaster = true; sourceRegion = param.getSourceRegion(); if (sourceRegion == null) sourceRegion = new Rectangle(raster.getMinX(), raster.getMinY(), raster.getWidth(), raster.getHeight()); else sourceRegion = sourceRegion.intersection(raster.getBounds()); if (sourceRegion.isEmpty()) throw new RuntimeException(I18N.getString("J2KImageWriterCodecLib0")); sm = raster.getSampleModel(); getFromParam(); setSampleModelAndMore(); setTile(0, 0); }