class Jpeg2000 extends Image {

    // public static final membervariables

    public static final int JP2_JP = 0x6a502020;
    public static final int JP2_IHDR = 0x69686472;
    public static final int JPIP_JPIP = 0x6a706970;

    public static final int JP2_FTYP = 0x66747970;
    public static final int JP2_JP2H = 0x6a703268;
    public static final int JP2_COLR = 0x636f6c72;
    public static final int JP2_JP2C = 0x6a703263;
    public static final int JP2_URL = 0x75726c20;
    public static final int JP2_DBTL = 0x6474626c;
    public static final int JP2_BPCC = 0x62706363;
    public static final int JP2_JP2 = 0x6a703220;

    InputStream inp;
    int boxLength;
    int boxType;

    // Constructors

    Jpeg2000(Image image) {
        super(image);
    }

    /**
     * Constructs a <CODE>Jpeg2000</CODE>-object, using an <VAR>url</VAR>.
     *
     * @param url the <CODE>URL</CODE> where the image can be found
     * @throws BadElementException on error
     * @throws IOException         on error
     */
    public Jpeg2000(URL url) throws BadElementException, IOException {
        super(url);
        processParameters();
    }

    /**
     * Constructs a <CODE>Jpeg2000</CODE>-object from memory.
     *
     * @param img the memory image
     * @throws BadElementException on error
     * @throws IOException         on error
     */
    public Jpeg2000(byte[] img) throws BadElementException, IOException {
        super((URL) null);
        rawData = img;
        originalData = img;
        processParameters();
    }

    /**
     * Constructs a <CODE>Jpeg2000</CODE>-object from memory.
     *
     * @param img    the memory image.
     * @param width  the width you want the image to have
     * @param height the height you want the image to have
     * @throws BadElementException on error
     * @throws IOException         on error
     */
    public Jpeg2000(byte[] img, float width, float height) throws BadElementException, IOException {
        this(img);
        scaledWidth = width;
        scaledHeight = height;
    }

    private int cio_read(int n) throws IOException {
        int v = 0;
        for (int i = n - 1; i >= 0; i--) {
            v += inp.read() << (i << 3);
        }
        return v;
    }

    public void jp2_read_boxhdr() throws IOException {
        boxLength = cio_read(4);
        boxType = cio_read(4);
        if (boxLength == 1) {
            if (cio_read(4) != 0) {
                throw new IOException(
                        MessageLocalization.getComposedMessage("cannot.handle.box.sizes.higher.than.2.32"));
            }
            boxLength = cio_read(4);
            if (boxLength == 0) {
                throw new IOException(MessageLocalization.getComposedMessage("unsupported.box.size.eq.eq.0"));
            }
        } else if (boxLength == 0) {
            throw new IOException(MessageLocalization.getComposedMessage("unsupported.box.size.eq.eq.0"));
        }
    }

    /**
     * This method checks if the image is a valid JPEG and processes some parameters.
     *
     * @throws IOException on error
     */
    private void processParameters() throws IOException {<FILL_FUNCTION_BODY>}
}

        type = JPEG2000;
        originalType = ORIGINAL_JPEG2000;
        inp = null;
        try {
            String errorID;
            if (rawData == null) {
                inp = url.openStream();
                errorID = url.toString();
            } else {
                inp = new java.io.ByteArrayInputStream(rawData);
                errorID = "Byte array";
            }
            boxLength = cio_read(4);
            if (boxLength == 0x0000000c) {
                boxType = cio_read(4);
                if (JP2_JP != boxType) {
                    throw new IOException(MessageLocalization.getComposedMessage("expected.jp.marker"));
                }
                if (0x0d0a870a != cio_read(4)) {
                    throw new IOException(MessageLocalization.getComposedMessage("error.with.jp.marker"));
                }

                jp2_read_boxhdr();
                if (JP2_FTYP != boxType) {
                    throw new IOException(MessageLocalization.getComposedMessage("expected.ftyp.marker"));
                }
                Utilities.skip(inp, boxLength - 8);
                jp2_read_boxhdr();
                do {
                    if (JP2_JP2H != boxType) {
                        if (boxType == JP2_JP2C) {
                            throw new IOException(MessageLocalization.getComposedMessage("expected.jp2h.marker"));
                        }
                        Utilities.skip(inp, boxLength - 8);
                        jp2_read_boxhdr();
                    }
                } while (JP2_JP2H != boxType);
                jp2_read_boxhdr();
                if (JP2_IHDR != boxType) {
                    throw new IOException(MessageLocalization.getComposedMessage("expected.ihdr.marker"));
                }
                scaledHeight = cio_read(4);
                setTop(scaledHeight);
                scaledWidth = cio_read(4);
                setRight(scaledWidth);
                bpc = -1;
            } else if (boxLength == 0xff4fff51) {
                Utilities.skip(inp, 4);
                int x1 = cio_read(4);
                int y1 = cio_read(4);
                int x0 = cio_read(4);
                int y0 = cio_read(4);
                Utilities.skip(inp, 16);
                colorspace = cio_read(2);
                bpc = 8;
                scaledHeight = y1 - y0;
                setTop(scaledHeight);
                scaledWidth = x1 - x0;
                setRight(scaledWidth);
            } else {
                throw new IOException(MessageLocalization.getComposedMessage("not.a.valid.jpeg2000.file"));
            }
        } finally {
            if (inp != null) {
                try {
                    inp.close();
                } catch (Exception e) {
                }
                inp = null;
            }
        }
        plainWidth = getWidth();
        plainHeight = getHeight();
    
<methods>public void <init>(java.net.URL) ,public float getAbsoluteX() ,public float getAbsoluteY() ,public com.lowagie.text.pdf.PdfDictionary getAdditional() ,public int getAlignment() ,public java.lang.String getAlt() ,public com.lowagie.text.Annotation getAnnotation() ,public int getBpc() ,public int getColorspace() ,public int getCompressionLevel() ,public com.lowagie.text.pdf.PdfIndirectReference getDirectReference() ,public int getDpiX() ,public int getDpiY() ,public java.awt.color.ICC_Profile getICCProfile() ,public com.lowagie.text.Image getImageMask() ,public float getImageRotation() ,public float getIndentationLeft() ,public float getIndentationRight() ,public float getInitialRotation() ,public static com.lowagie.text.Image getInstance(java.net.URL) throws com.lowagie.text.BadElementException, java.io.IOException,public static com.lowagie.text.Image getInstance(java.lang.String) throws com.lowagie.text.BadElementException, java.io.IOException,public static com.lowagie.text.Image getInstance(byte[]) throws com.lowagie.text.BadElementException, java.io.IOException,public static com.lowagie.text.Image getInstance(int, int, int, int, byte[]) throws com.lowagie.text.BadElementException,public static com.lowagie.text.Image getInstance(int, int, byte[], byte[]) ,public static com.lowagie.text.Image getInstance(int, int, boolean, int, int, byte[]) throws com.lowagie.text.BadElementException,public static com.lowagie.text.Image getInstance(int, int, boolean, int, int, byte[], int[]) throws com.lowagie.text.BadElementException,public static com.lowagie.text.Image getInstance(int, int, int, int, byte[], int[]) throws com.lowagie.text.BadElementException,public static com.lowagie.text.Image getInstance(com.lowagie.text.pdf.PdfTemplate) throws com.lowagie.text.BadElementException,public static com.lowagie.text.Image getInstance(java.awt.Image, java.awt.Color, boolean) throws com.lowagie.text.BadElementException, java.io.IOException,public static com.lowagie.text.Image getInstance(java.awt.Image, java.awt.Color) throws com.lowagie.text.BadElementException, java.io.IOException,public static com.lowagie.text.Image getInstance(com.lowagie.text.pdf.PdfWriter, java.awt.Image, float) throws com.lowagie.text.BadElementException, java.io.IOException,public static com.lowagie.text.Image getInstance(com.lowagie.text.pdf.PdfContentByte, java.awt.Image, float) throws com.lowagie.text.BadElementException, java.io.IOException,public static com.lowagie.text.Image getInstance(com.lowagie.text.pdf.PRIndirectReference) throws com.lowagie.text.BadElementException,public static com.lowagie.text.Image getInstance(com.lowagie.text.Image) ,public static com.lowagie.text.Image getInstanceFromClasspath(java.lang.String) throws com.lowagie.text.BadElementException, java.io.IOException,public com.lowagie.text.pdf.PdfOCG getLayer() ,public java.lang.Long getMySerialId() ,public byte[] getOriginalData() ,public int getOriginalType() ,public float getPlainHeight() ,public float getPlainWidth() ,public byte[] getRawData() ,public float getScaledHeight() ,public float getScaledWidth() ,public float getSpacingAfter() ,public float getSpacingBefore() ,public com.lowagie.text.pdf.PdfTemplate getTemplateData() ,public int[] getTransparency() ,public java.net.URL getUrl() ,public float getWidthPercentage() ,public float getXYRatio() ,public boolean hasAbsoluteX() ,public boolean hasAbsoluteY() ,public boolean hasICCProfile() ,public boolean isDeflated() ,public boolean isImgRaw() ,public boolean isImgTemplate() ,public boolean isInterpolation() ,public boolean isInverted() ,public boolean isJpeg() ,public boolean isMask() ,public boolean isMaskCandidate() ,public boolean isNestable() ,public boolean isSmask() ,public void makeMask() throws com.lowagie.text.DocumentException,public float[] matrix() ,public void scaleAbsolute(float, float) ,public void scaleAbsoluteHeight(float) ,public void scaleAbsoluteWidth(float) ,public void scalePercent(float) ,public void scalePercent(float, float) ,public void scaleToFit(float, float) ,public void setAbsolutePosition(float, float) ,public void setAdditional(com.lowagie.text.pdf.PdfDictionary) ,public void setAlignment(int) ,public void setAlt(java.lang.String) ,public void setAnnotation(com.lowagie.text.Annotation) ,public void setCompressionLevel(int) ,public void setDeflated(boolean) ,public void setDirectReference(com.lowagie.text.pdf.PdfIndirectReference) ,public void setDpi(int, int) ,public void setImageMask(com.lowagie.text.Image) throws com.lowagie.text.DocumentException,public void setIndentationLeft(float) ,public void setIndentationRight(float) ,public void setInitialRotation(float) ,public void setInterpolation(boolean) ,public void setInverted(boolean) ,public void setLayer(com.lowagie.text.pdf.PdfOCG) ,public void setOriginalData(byte[]) ,public void setOriginalType(int) ,public void setRotation(float) ,public void setRotationDegrees(float) ,public void setSmask(boolean) ,public void setSpacingAfter(float) ,public void setSpacingBefore(float) ,public void setTemplateData(com.lowagie.text.pdf.PdfTemplate) ,public void setTransparency(int[]) ,public void setUrl(java.net.URL) ,public void setWidthPercentage(float) ,public void setXYRatio(float) ,public void simplifyColorspace() ,public void tagICC(java.awt.color.ICC_Profile) ,public int type() <variables>public static final int AX,public static final int AY,public static final int BX,public static final int BY,public static final int CX,public static final int CY,public static final int DEFAULT,public static final int DX,public static final int DY,public static final int LEFT,public static final int MIDDLE,public static final int ORIGINAL_BMP,public static final int ORIGINAL_GIF,public static final int ORIGINAL_JBIG2,public static final int ORIGINAL_JPEG,public static final int ORIGINAL_JPEG2000,public static final int ORIGINAL_NONE,public static final int ORIGINAL_PNG,public static final int ORIGINAL_PS,public static final int ORIGINAL_TIFF,public static final int ORIGINAL_WMF,public static final int[] PNGID,public static final int RIGHT,public static final int TEXTWRAP,public static final int UNDERLYING,private float XYRatio,protected float absoluteX,protected float absoluteY,private com.lowagie.text.pdf.PdfDictionary additional,protected int alignment,protected java.lang.String alt,protected com.lowagie.text.Annotation annotation,protected int bpc,protected int colorspace,protected int compressionLevel,protected boolean deflated,private com.lowagie.text.pdf.PdfIndirectReference directReference,protected int dpiX,protected int dpiY,protected com.lowagie.text.Image imageMask,protected float indentationLeft,protected float indentationRight,private float initialRotation,protected boolean interpolation,protected boolean invert,protected com.lowagie.text.pdf.PdfOCG layer,protected boolean mask,protected java.lang.Long mySerialId,protected byte[] originalData,protected int originalType,protected float plainHeight,protected float plainWidth,protected java.awt.color.ICC_Profile profile,protected byte[] rawData,protected float rotationRadians,protected float scaledHeight,protected float scaledWidth,static long serialId,private boolean smask,protected float spacingAfter,protected float spacingBefore,protected com.lowagie.text.pdf.PdfTemplate[] template,protected int[] transparency,protected int type,protected java.net.URL url,private float widthPercentage