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

📄 simplerenderedimage.java

📁 It is all about project scheduling. GanttProject is a tool for creating a project schedule by means
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package net.sourceforge.ganttproject.chart;/*Copyright 2001,2003  The Apache Software Foundation Licensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License at    http://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.*/import java.awt.Point;import java.awt.Rectangle;import java.awt.image.ColorModel;import java.awt.image.Raster;import java.awt.image.RenderedImage;import java.awt.image.SampleModel;import java.awt.image.WritableRaster;import java.util.Enumeration;import java.util.Hashtable;import java.util.Iterator;import java.util.Vector;/*** A simple class implemented the <code>RenderedImage</code>* interface.  Only the <code>getTile()</code> method needs to be* implemented by subclasses.  The instance variables must also be* filled in properly.** <p> Normally in JAI <code>PlanarImage</code> is used for this* purpose, but in the interest of modularity the* use of <code>PlanarImage</code> has been avoided.*/public abstract class SimpleRenderedImage implements RenderedImage { /** The X coordinate of the image's upper-left pixel. */ protected int minX;  /** The Y coordinate of the image's upper-left pixel. */ protected int minY;  /** The image's width in pixels. */ protected int width;  /** The image's height in pixels. */ protected int height;  /** The width of a tile. */ protected int tileWidth;  /** The height of a tile. */ protected int tileHeight; /** The X coordinate of the upper-left pixel of tile (0, 0). */ protected int tileGridXOffset = 0;  /** The Y coordinate of the upper-left pixel of tile (0, 0). */ protected int tileGridYOffset = 0;  /** The image's SampleModel. */ protected SampleModel sampleModel = null;  /** The image's ColorModel. */ protected ColorModel colorModel = null;  /** The image's sources, stored in a Vector. */ protected Vector sources = new Vector(); /** A Hashtable containing the image properties. */ protected Hashtable properties = new Hashtable(); public SimpleRenderedImage() {} /** Returns the X coordinate of the leftmost column of the image. */ public int getMinX() {     return minX; } /**  * Returns the X coordinate of the column immediatetely to the  * right of the rightmost column of the image.  getMaxX() is  * implemented in terms of getMinX() and getWidth() and so does  * not need to be implemented by subclasses.  */ public final int getMaxX() {     return getMinX() + getWidth(); } /** Returns the X coordinate of the uppermost row of the image. */ public int getMinY() {     return minY; } /**  * Returns the Y coordinate of the row immediately below the  * bottom row of the image.  getMaxY() is implemented in terms of  * getMinY() and getHeight() and so does not need to be  * implemented by subclasses.  */ public final int getMaxY() {     return getMinY() + getHeight(); } /** Returns the width of the image. */ public int getWidth() {     return width; } /** Returns the height of the image. */ public int getHeight() {     return height; }  /** Returns a Rectangle indicating the image bounds. */ public Rectangle getBounds() {     return new Rectangle(getMinX(), getMinY(),                          getWidth(), getHeight()); }  /** Returns the width of a tile. */ public int getTileWidth() {     return tileWidth; } /** Returns the height of a tile. */ public int getTileHeight() {     return tileHeight; } /**   * Returns the X coordinate of the upper-left pixel of tile (0, 0).  */ public int getTileGridXOffset() {     return tileGridXOffset; } /**   * Returns the Y coordinate of the upper-left pixel of tile (0, 0).  */ public int getTileGridYOffset() {     return tileGridYOffset; } /**  * Returns the horizontal index of the leftmost column of tiles.  * getMinTileX() is implemented in terms of getMinX()  * and so does not need to be implemented by subclasses.  */ public int getMinTileX() {     return XToTileX(getMinX()); } /**  * Returns the horizontal index of the rightmost column of tiles.  * getMaxTileX() is implemented in terms of getMaxX()  * and so does not need to be implemented by subclasses.  */ public int getMaxTileX() {     return XToTileX(getMaxX() - 1); } /**  * Returns the number of tiles along the tile grid in the  * horizontal direction.  getNumXTiles() is implemented in terms  * of getMinTileX() and getMaxTileX() and so does not need to be  * implemented by subclasses.  */ public int getNumXTiles() {     return getMaxTileX() - getMinTileX() + 1; }  /**  * Returns the vertical index of the uppermost row of tiles.  getMinTileY()  * is implemented in terms of getMinY() and so does not need to be  * implemented by subclasses.   */ public int getMinTileY() {     return YToTileY(getMinY()); } /**  * Returns the vertical index of the bottom row of tiles.  getMaxTileY()  * is implemented in terms of getMaxY() and so does not need to  * be implemented by subclasses.  */ public int getMaxTileY() {     return YToTileY(getMaxY() - 1); } /**  * Returns the number of tiles along the tile grid in the vertical  * direction.  getNumYTiles() is implemented in terms  * of getMinTileY() and getMaxTileY() and so does not need to be  * implemented by subclasses.  */ public int getNumYTiles() {     return getMaxTileY() - getMinTileY() + 1; } /** Returns the SampleModel of the image. */ public SampleModel getSampleModel() {     return sampleModel; } /** Returns the ColorModel of the image. */ public ColorModel getColorModel() {     return colorModel; } /**  * Gets a property from the property set of this image.  If the  * property name is not recognized,  * <code>java.awt.Image.UndefinedProperty</code> will be returned.  *  * @param name the name of the property to get, as a  * <code>String</code>.  @return a reference to the property  * <code>Object</code>, or the value  * <code>java.awt.Image.UndefinedProperty.</code>  */ public Object getProperty(String name) {     name = name.toLowerCase();     return properties.get(name); }  /**  * Returns a list of the properties recognized by this image.  If  * no properties are available, <code>null</code> will be  * returned.  *  * @return an array of <code>String</code>s representing valid  *         property names.  */ public String[] getPropertyNames() {     String[] names = new String[properties.size()];     int index = 0;     Enumeration e = properties.keys();     while (e.hasMoreElements()) {         String name = (String)e.nextElement();         names[index++] = name;     }          return names; } /**  * Returns an array of <code>String</code>s recognized as names by  * this property source that begin with the supplied prefix.  If  * no property names match, <code>null</code> will be returned.  * The comparison is done in a case-independent manner.  *  * <p> The default implementation calls  * <code>getPropertyNames()</code> and searches the list of names  * for matches.  *  * @return an array of <code>String</code>s giving the valid  * property names.  */ public String[] getPropertyNames(String prefix) {     String propertyNames[] = getPropertyNames();

⌨️ 快捷键说明

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