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

📄 omrasterobject.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
            Debug.error("OMRasterObject.render: Attempting to draw a Image that is not ready! Image probably wasn't available.");        }        if (g instanceof Graphics2D && rotationAngle != DEFAULT_ROTATIONANGLE) {            //rotate about our image center point            rotate((Graphics2D) g);        }        if (bitmap != null) {            if (isSelected() || Debug.debugging("rasterobjects")) {                super.render(g);            }            if (DEBUG) {                Debug.output("OMRasterObject.render() | drawing " + width + "x"                        + height + " image at " + point1.x + ", " + point1.y);            }            if (g instanceof Graphics2D && bitmap instanceof RenderedImage) {                // Affine translation for placement...                ((Graphics2D) g).drawRenderedImage((BufferedImage) bitmap,                        new AffineTransform(1f, 0f, 0f, 1f, point1.x, point1.y));                // Undo the affine translation for future graphics??                ((Graphics2D) g).translate(-point1.x, -point1.y);            } else {                g.drawImage(bitmap, point1.x, point1.y, this);            }        } else {            if (DEBUG)                Debug.output("OMRasterObject.render: ignoring null bitmap");        }    }    /**     * Set the rectangle, based on the location and size of the image.     */    public void setShape() {        // generate shape that is a boundary of the generated image.        // We'll make it a GeneralPath rectangle.        int w = width;        int h = height;        if (imageFilter != null) {            w = filteredWidth;            h = filteredHeight;        }        setShape(createBoxShape(point1.x, point1.y, w, h));    }    /**     * Since the image doesn't necessarily need to be regenerated when     * it is merely moved, raster objects have this function, called     * from generate() and when a placement attribute is changed.     *      * @return true if enough information is in the object for proper     *         placement.     * @param proj projection of window.     */    protected boolean position(Projection proj) {        if (proj == null) {            Debug.error("OMRasterObject: null projection in position!");            return false;        }        projWidth = proj.getWidth();        projHeight = proj.getHeight();        switch (renderType) {        case RENDERTYPE_LATLON:            if (!proj.isPlotable(lat, lon)) {                if (DEBUG) {                    Debug.error("OMRasterObject: point is not plotable!");                }                setNeedToReposition(true);//so we don't render it!                return false;            }            point1 = proj.forward(lat, lon);            break;        case RENDERTYPE_XY:            point1 = new Point(x, y);            break;        case RENDERTYPE_OFFSET:            if (!proj.isPlotable(lat, lon)) {                if (DEBUG) {                    Debug.error("OMRasterObject: point is not plotable!");                }                setNeedToReposition(true);//so we don't render it!                return false;            }            point1 = proj.forward(lat, lon);            point1.x += x;            point1.y += y;            break;        case RENDERTYPE_UNKNOWN:            if (DEBUG) {                Debug.output("OMRasterObject.position(): ignoring unknown rendertype, wingin' it");            }            if (lat == 0 && lon == 0) {                if (x == 0 && y == 0) {                    if (DEBUG) {                        Debug.output("OMRasterObject.position(): Not enough info in object to place it reasonably.");                    }                    point1 = new Point(-width, -height);                    point2 = new Point(0, 0);                    return false;                } else {                    point1 = new Point(x, y);                }            } else {                if (!proj.isPlotable(lat, lon)) {                    Debug.error("OMRasterObject: point is not plotable!");                    return false;                }                point1 = proj.forward(lat, lon);            }            break;        }        point2 = new Point(0, 0);        point2.x = point1.x + width;        point2.y = point1.y + height;        setNeedToReposition(false);        return true;    }    /**     * Set the image to be drawn, if the color model is     * COLORMODEL_IMAGEICON.     *      * @param ii the image icon to use.     */    public void setImage(Image ii) {        if (ii == null) {            Debug.error("OMRasterObject.setImage(): image is null!");            return;        }        colorModel = COLORMODEL_IMAGEICON;        bitmap = ii;        // Make sure the image is ready to draw. If not, this method        // will be called again by the ImageObserver method        // imageUpdate. Set the height and width anyway. If they are        // -1, you know the image isn't ready - another way to find        // out.        width = bitmap.getWidth(this);        height = bitmap.getHeight(this);        if (!(ii instanceof RenderedImage)) {            Toolkit.getDefaultToolkit().prepareImage(bitmap, -1, -1, this);        }    }    /**     * Get the image that will be put on the window.     *      * @return the Image created by computePixels and generate().     */    public Image getImage() {        return bitmap;    }    /**     * Always true for images, affects distance measurements. Forces     * the omGraphics package to treat the OMRasterObject as a filled     * shape.     */    public boolean shouldRenderFill() {        return true;    }    /**     * Set the pixels for the image for direct color model images.     * Checks to see of the length matches the height * width, but     * doesn't do anything if they don't match. Make sure it does.     *      * @param values the pixel values.     */    public void setPixels(int[] values) {        if (values.length != (height * width))            Debug.error("OMRasterObject: new pixel[] size (" + +values.length                    + ") doesn't" + " match [height*width (" + height * width                    + ")]");        pixels = values;        setNeedToRegenerate(true);    }    /**     * Return the pixels used for the image.     *      * @return the integer array of ints used as integer colors for     *         each pixel of the image.     */    public int[] getPixels() {        return pixels;    }    /**     * Change the x attribute, which matters only if the render type     * is RENDERTYPE_XY or RENDERTYPE_OFFSET.     *      * @param value the x location in pixels.     */    public void setX(int value) {        if (x == value)            return;        x = value;        setNeedToReposition(true);    }    /**     * Returns the x attribute.     *      * @return the x value, pixels from left of window or image     *         origin.     */    public int getX() {        return x;    }    /**     * Change the y attribute, which matters only if the render type     * is RENDERTYPE_XY or RENDERTYPE_OFFSET.     *      * @param value the y location in pixels     */    public void setY(int value) {        if (y == value)            return;        y = value;        setNeedToReposition(true);    }    /**     * Return the y attribute.     *      * @return the y value, pixels from top or image origin.     */    public int getY() {        return y;    }    /**     * Return the map location of the image, after generation.     *      * @return Point, null if not projected yet.     */    public Point getMapLocation() {        return point1;    }    /**     * Change the latitude attribute, which matters only if the render     * type is RENDERTYPE_LATLON or RENDERTYPE_OFFSET.     *      * @param value latitude in decimal degrees.     */    public void setLat(float value) {        if (lat == value)            return;        lat = value;        setNeedToReposition(true);    }    /**     * Get the latitude.     *      * @return the latitude in decimal degrees.     */    public float getLat() {        return lat;    }    /**     * Change the longitude attribute, which matters only if the     * render type is RENDERTYPE_LATLON or RENDERTYPE_OFFSET.     *      * @param value the longitude in decimal degrees.     */    public void setLon(float value) {        if (lon == value)            return;        lon = value;        setNeedToReposition(true);    }    /**     * Get the longitude.     *      * @return longitude in decimal degrees.     */    public float getLon() {        return lon;    }    /**     * Set the height of the image, in pixels.     *      * @param value height in pixels.     */    public void setHeight(int value) {        if (height == value)            return;        setNeedToRegenerate(true);        height = value;    }    /**     * Get the height of image.     *      * @return height in pixels.     */    public int getHeight() {        return height;    }    /**     * Get the height of image after a filter was applied.     *      * @return filteredHeight in pixels.     */    public int getFilteredHeight() {        return filteredHeight;    }    /**     * Set width of image.     *      * @param value width in pixels.     */    public void setWidth(int value) {        if (width == value)            return;        setNeedToRegenerate(true);        width = value;    }    /**     * Get width of image.     *      * @return width of image in pixels.     */

⌨️ 快捷键说明

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