⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 image.java

📁 处理PDF
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
	/**	 * Gets the raw data for the image.	 * <P>	 * Remark: this only makes sense for Images of the type <CODE>RawImage	 * </CODE>.	 * 	 * @return the raw data	 */	public byte[] getRawData() {		return rawData;	}	/**	 * Gets the bpc for the image.	 * <P>	 * Remark: this only makes sense for Images of the type <CODE>RawImage	 * </CODE>.	 * 	 * @return a bpc value	 */	public int getBpc() {		return bpc;	}	/**	 * Gets the template to be used as an image.	 * <P>	 * Remark: this only makes sense for Images of the type <CODE>ImgTemplate	 * </CODE>.	 * 	 * @return the template	 */	public PdfTemplate getTemplateData() {		return template[0];	}	/**	 * Sets data from a PdfTemplate	 * 	 * @param template	 *            the template with the content	 */	public void setTemplateData(PdfTemplate template) {		this.template[0] = template;	}	/**	 * Gets the alignment for the image.	 * 	 * @return a value	 */	public int getAlignment() {		return alignment;	}	/**	 * Sets the alignment for the image.	 * 	 * @param alignment	 *            the alignment	 */	public void setAlignment(int alignment) {		this.alignment = alignment;	}	/**	 * Gets the alternative text for the image.	 * 	 * @return a <CODE>String</CODE>	 */	public String getAlt() {		return alt;	}	/**	 * Sets the alternative information for the image.	 * 	 * @param alt	 *            the alternative information	 */	public void setAlt(String alt) {		this.alt = alt;	}	/**	 * Sets the absolute position of the <CODE>Image</CODE>.	 * 	 * @param absoluteX	 * @param absoluteY	 */	public void setAbsolutePosition(float absoluteX, float absoluteY) {		this.absoluteX = absoluteX;		this.absoluteY = absoluteY;	}	/**	 * Checks if the <CODE>Images</CODE> has to be added at an absolute X	 * position.	 * 	 * @return a boolean	 */	public boolean hasAbsoluteX() {		return !Float.isNaN(absoluteX);	}	/**	 * Returns the absolute X position.	 * 	 * @return a position	 */	public float getAbsoluteX() {		return absoluteX;	}	/**	 * Checks if the <CODE>Images</CODE> has to be added at an absolute	 * position.	 * 	 * @return a boolean	 */	public boolean hasAbsoluteY() {		return !Float.isNaN(absoluteY);	}	/**	 * Returns the absolute Y position.	 * 	 * @return a position	 */	public float getAbsoluteY() {		return absoluteY;	}	// width and height	/**	 * Gets the scaled width of the image.	 * 	 * @return a value	 */	public float getScaledWidth() {		return scaledWidth;	}	/**	 * Gets the scaled height of the image.	 * 	 * @return a value	 */	public float getScaledHeight() {		return scaledHeight;	}	/**	 * Gets the plain width of the image.	 * 	 * @return a value	 */	public float getPlainWidth() {		return plainWidth;	}	/**	 * Gets the plain height of the image.	 * 	 * @return a value	 */	public float getPlainHeight() {		return plainHeight;	}		/**	 * Scale the image to an absolute width and an absolute height.	 * 	 * @param newWidth	 *            the new width	 * @param newHeight	 *            the new height	 */	public void scaleAbsolute(float newWidth, float newHeight) {		plainWidth = newWidth;		plainHeight = newHeight;		float[] matrix = matrix();		scaledWidth = matrix[DX] - matrix[CX];		scaledHeight = matrix[DY] - matrix[CY];		setWidthPercentage(0);	}	/**	 * Scale the image to an absolute width.	 * 	 * @param newWidth	 *            the new width	 */	public void scaleAbsoluteWidth(float newWidth) {		plainWidth = newWidth;		float[] matrix = matrix();		scaledWidth = matrix[DX] - matrix[CX];		scaledHeight = matrix[DY] - matrix[CY];		setWidthPercentage(0);	}	/**	 * Scale the image to an absolute height.	 * 	 * @param newHeight	 *            the new height	 */	public void scaleAbsoluteHeight(float newHeight) {		plainHeight = newHeight;		float[] matrix = matrix();		scaledWidth = matrix[DX] - matrix[CX];		scaledHeight = matrix[DY] - matrix[CY];		setWidthPercentage(0);	}	/**	 * Scale the image to a certain percentage.	 * 	 * @param percent	 *            the scaling percentage	 */	public void scalePercent(float percent) {		scalePercent(percent, percent);	}	/**	 * Scale the width and height of an image to a certain percentage.	 * 	 * @param percentX	 *            the scaling percentage of the width	 * @param percentY	 *            the scaling percentage of the height	 */	public void scalePercent(float percentX, float percentY) {		plainWidth = (getWidth() * percentX) / 100f;		plainHeight = (getHeight() * percentY) / 100f;		float[] matrix = matrix();		scaledWidth = matrix[DX] - matrix[CX];		scaledHeight = matrix[DY] - matrix[CY];		setWidthPercentage(0);	}	/**	 * Scales the image so that it fits a certain width and height.	 * 	 * @param fitWidth	 *            the width to fit	 * @param fitHeight	 *            the height to fit	 */	public void scaleToFit(float fitWidth, float fitHeight) {        scalePercent(100);		float percentX = (fitWidth * 100) / getScaledWidth();		float percentY = (fitHeight * 100) / getScaledHeight();		scalePercent(percentX < percentY ? percentX : percentY);		setWidthPercentage(0);	}	/**	 * Returns the transformation matrix of the image.	 * 	 * @return an array [AX, AY, BX, BY, CX, CY, DX, DY]	 */	public float[] matrix() {		float[] matrix = new float[8];		float cosX = (float) Math.cos(rotationRadians);		float sinX = (float) Math.sin(rotationRadians);		matrix[AX] = plainWidth * cosX;		matrix[AY] = plainWidth * sinX;		matrix[BX] = (-plainHeight) * sinX;		matrix[BY] = plainHeight * cosX;		if (rotationRadians < Math.PI / 2f) {			matrix[CX] = matrix[BX];			matrix[CY] = 0;			matrix[DX] = matrix[AX];			matrix[DY] = matrix[AY] + matrix[BY];		} else if (rotationRadians < Math.PI) {			matrix[CX] = matrix[AX] + matrix[BX];			matrix[CY] = matrix[BY];			matrix[DX] = 0;			matrix[DY] = matrix[AY];		} else if (rotationRadians < Math.PI * 1.5f) {			matrix[CX] = matrix[AX];			matrix[CY] = matrix[AY] + matrix[BY];			matrix[DX] = matrix[BX];			matrix[DY] = 0;		} else {			matrix[CX] = 0;			matrix[CY] = matrix[AY];			matrix[DX] = matrix[AX] + matrix[BX];			matrix[DY] = matrix[BY];		}		return matrix;	}	// serial stamping	/** a static that is used for attributing a unique id to each image. */	static long serialId = 0;		/** Creates a new serial id. */	static protected synchronized Long getSerialId() {		++serialId;		return new Long(serialId);	}	/**	 * Returns a serial id for the Image (reuse the same image more than once)	 * 	 * @return a serialId	 */	public Long getMySerialId() {		return mySerialId;	}    // rotation, note that the superclass also has a rotation value.	/** This is the rotation of the image in radians. */	protected float rotationRadians;        /** Holds value of property initialRotation. */    private float initialRotation;    /**     * Gets the current image rotation in radians.     * @return the current image rotation in radians     */    public float getImageRotation() {		double d = 2.0 * Math.PI;		float rot = (float) ((rotationRadians - initialRotation) % d);		if (rot < 0) {			rot += d;		}        return rot;    }    	/**	 * Sets the rotation of the image in radians.	 * 	 * @param r	 *            rotation in radians	 */	public void setRotation(float r) {		double d = 2.0 * Math.PI;		rotationRadians = (float) ((r + initialRotation) % d);		if (rotationRadians < 0) {			rotationRadians += d;		}		float[] matrix = matrix();		scaledWidth = matrix[DX] - matrix[CX];		scaledHeight = matrix[DY] - matrix[CY];	}	/**	 * Sets the rotation of the image in degrees.	 * 	 * @param deg	 *            rotation in degrees	 */	public void setRotationDegrees(float deg) {		double d = Math.PI;		setRotation(deg / 180 * (float) d);	}        /**     * Getter for property initialRotation.     * @return Value of property initialRotation.     */    public float getInitialRotation() {        return this.initialRotation;    }        /**     * Some image formats, like TIFF may present the images rotated that have     * to be compensated.     * @param initialRotation New value of property initialRotation.     */    public void setInitialRotation(float initialRotation) {        float old_rot = rotationRadians - this.initialRotation;        this.initialRotation = initialRotation;        setRotation(old_rot);    }        // indentations	/** the indentation to the left. */	protected float indentationLeft = 0;	/** the indentation to the right. */	protected float indentationRight = 0;	/** The spacing before the image. */	protected float spacingBefore;	/** The spacing after the image. */	protected float spacingAfter;	/**	 * Gets the left indentation.	 * 	 * @return the left indentation	 */	public float getIndentationLeft() {		return indentationLeft;	}	/**	 * Sets the left indentation.	 * 	 * @param f	 */	public void setIndentationLeft(float f) {		indentationLeft = f;	}	/**	 * Gets the right indentation.	 * 	 * @return the right indentation	 */	public float getIndentationRight() {		return indentationRight;	}	/**	 * Sets the right indentation.	 * 	 * @param f	 */	public void setIndentationRight(float f) {		indentationRight = f;	}	/**	 * Gets the spacing before this image.	 * 	 * @return the spacing	 */	public float getSpacingBefore() {		return spacingBefore;	}	/**	 * Sets the spacing before this image.	 * 	 * @param spacing	 *            the new spacing	 */	public void setSpacingBefore(float spacing) {		this.spacingBefore = spacing;	}	/**	 * Gets the spacing before this image.	 * 	 * @return the spacing	 */	public float getSpacingAfter() {		return spacingAfter;	}	/**	 * Sets the spacing after this image.	 * 	 * @param spacing	 *            the new spacing	 */	public void setSpacingAfter(float spacing) {		this.spacingAfter = spacing;	}    // widthpercentage (for the moment only used in ColumnText)	/**	 * Holds value of property widthPercentage.	 */	private float widthPercentage = 100;		/**	 * Getter for property widthPercentage.	 * 	 * @return Value of property widthPercentage.	 */	public float getWidthPercentage() {		return this.widthPercentage;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -