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

📄 omgraphic.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
    /**     * Set the Paint in the given Graphics. If the Graphics is not an     * instance of Graphics2D, then the Color of the graphics is set     * if the Paint is an instance of Color.     *      * @param g java.awt.Graphics     * @param paint java.awt.Paint     */    public void setGraphicsColor(Graphics g, Paint paint) {        if (g instanceof Graphics2D) {            ((Graphics2D) g).setPaint(paint);        } else if (paint instanceof Color) {            g.setColor((Color) paint);        }    }    /**     * Set the line color of the graphic object. The line color is the     * normal display edge color of the object. This color is used as     * the display color when the object is NOT selected     * (hightlighted). The display color is set to the select color in     * this method if <code>selected</code> boolean attribute is     * false.     *      * @param value the real line color     * @deprecated Use setLinePaint instead. Now taking advantage of     *             the Java2D API.     */    public void setLineColor(Color value) {        setLinePaint(value);    }    /**     * Return the normal foreground color of the object.     *      * @return the line color. Returns null if the Paint is not a     *         Color.     */    public Color getLineColor() {        if (linePaint instanceof Color) {            return (Color) linePaint;        } else {            return null;        }    }    /**     * Set the line Paint. The line Paint is the normal display edge     * paint of the graphic. This Paint is used as the display Paint     * when the object is NOT selected (hightlighted). The display     * Paint is set to the select Paint in this method if     * <code>selected</code> boolean attribute is false.     *      * @param paint the real line Paint     */    public void setLinePaint(Paint paint) {        if (paint != null) {            linePaint = paint;        } else {            linePaint = Color.black;        }        if (!selected) {            displayPaint = linePaint;        }        setEdgeMatchesFill();    }    /**     * Get the normal line Paint used for the graphic.     *      * @return Line Paint.     */    public Paint getLinePaint() {        return linePaint;    }    /**     * Set the select color of the graphic object. The selected color     * is used as the display color when the object is selected     * (highlighted). The display color is set to the select color in     * this method if <code>selected</code> boolean attribute is     * true.     *      * @param value the selected color.     * @deprecated Use setSelectPaint instead. Now taking advantage of     *             the Java2D API.     */    public void setSelectColor(Color value) {        setSelectPaint(value);    }    /**     * Return the selected color, which is the line or foreground     * color used when the graphic is "selected".     *      * @return the selected mode line color. Returns null if the     *         select Paint is not a Color.     */    public Color getSelectColor() {        if (selectPaint instanceof Color) {            return (Color) selectPaint;        } else {            return null;        }    }    /**     * Set the select Paint. The select Paint is the display edge     * paint of the graphic. This Paint is used as the display Paint     * when the object IS selected (hightlighted). The display Paint     * is set to the select Paint in this method if     * <code>selected</code> boolean attribute is true.     *      * @param paint the real select Paint     */    public void setSelectPaint(Paint paint) {        if (paint != null) {            selectPaint = paint;        } else {            selectPaint = Color.black;        }        if (selected) {            displayPaint = selectPaint;        }        setEdgeMatchesFill();    }    /**     * Get the normal select Paint used for the graphic.     *      * @return Select Paint.     */    public Paint getSelectPaint() {        return selectPaint;    }    /**     * Return the color that should be used for display. This color     * changes, depending on whether the object is selected or not.     * The display color is also set when the line color or the select     * color is set, depending on the statue of the     * <code>selected</code> boolean attribute.     *      * @return the color used as the edge color or foreground color,     *         in the present selected state. If the displayPaint is     *         not a Color, this method returns null.     */    public Color getDisplayColor() {        if (displayPaint instanceof Color) {            return (Color) displayPaint;        } else {            return null;        }    }    /**     * Return the Paint that should be used for display. This Paint     * changes, depending on whether the object is selected or not.     * The display Paint is also set when the line Paint or the select     * Paint is set, depending on the statue of the     * <code>selected</code> boolean attribute.     *      * @return the Paint used as the edge Paint or foreground Paint,     *         in the present selected state.     */    public Paint getDisplayPaint() {        return displayPaint;    }    /**     * Set the selected attribute to true, and sets the color to the     * select color.     */    public void select() {        selected = true;        displayPaint = getSelectPaint();        setEdgeMatchesFill();    }    /**     * Set the selected attribute to false, sets the color to the line     * color.     */    public void deselect() {        selected = false;        displayPaint = getLinePaint();        setEdgeMatchesFill();    }    /**     * Return whether the OMGraphic is selected.     */    public boolean isSelected() {        return selected;    }    /**     * Calls select() or deselect() depending on the boolean (select     * is true).     */    public void setSelected(boolean set) {        if (set) {            select();        } else {            deselect();        }    }    /**     * Return whether the OMGraphic has matting around the edge.     */    public boolean isMatted() {        return matted;    }    /**     * Set whether the OMGraphic should have matting around the edge.     */    public void setMatted(boolean set) {        matted = set;    }    /**     * Set the background color of the graphic object.     *      * @param value java.awt.Color.     * @deprecated Use setFillPaint instead. Now taking advantage of     *             the Java2D API.     */    public void setFillColor(Color value) {        setFillPaint(value);    }    /**     * Return the background color of the graphic object. If the fill     * Paint is not a color, this method will return null.     *      * @return the color used for the background.     */    public Color getFillColor() {        if (fillPaint instanceof Color) {            return (Color) fillPaint;        } else {            return null;        }    }    /**     * Set the fill Paint for this graphic. If the paint value is     * null, it will be set to OMGraphicConstants.clear.     *      * @param paint the Paint object.     */    public void setFillPaint(Paint paint) {        if (paint != null) {            fillPaint = paint;            if (Debug.debugging("omGraphics")) {                Debug.output("OMGraphic.setFillPaint(): fillPaint= "                        + fillPaint);            }        } else {            fillPaint = clear;            if (Debug.debugging("omGraphics")) {                Debug.output("OMGraphic.setFillPaint(): fillPaint is clear");            }        }        setEdgeMatchesFill();    }    /**     * Set the texture mask for the OMGraphic. If not null, then it     * will be rendered on top of the fill paint. If the fill paint is     * clear, the texture mask will not be used. If you just want to     * render the texture mask as is, set the fill paint of the     * graphic instead. This is really to be used to have a texture     * added to the graphic, with the fill paint still influencing     * appearance.     */    public void setTextureMask(TexturePaint texture) {        textureMask = texture;    }    /**     * Return the fill Paint for this graphic.     */    public Paint getFillPaint() {        return fillPaint;    }    /**     * Return the texture mask Paint for this graphic.     */    public TexturePaint getTextureMask() {        return textureMask;    }    protected void setEdgeMatchesFill() {        Paint paint = getDisplayPaint();        if (fillPaint instanceof Color && paint instanceof Color                && !isClear(fillPaint)) {            edgeMatchesFill = ((Color) fillPaint).equals((Color) paint);        } else {            edgeMatchesFill = false;        }    }    public boolean getEdgeMatchesFill() {        return edgeMatchesFill;    }    /**     * Set the Paint used for matting.     */    public void setMattingPaint(Paint mPaint) {        mattingPaint = mPaint;    }    /**     * Get the Paint used for matting.     */    public Paint getMattingPaint() {        return mattingPaint;    }    /**     * Set the Stroke that should be used for the graphic edges. Using     * a BasicStroke, you can set a stroke that defines the line     * width, the dash interval and phase. If a null value is passed     * in, a default BasicStroke will be used.     *      * @param s the stroke to use for the graphic edge.     * @see java.awt.Stroke     * @see java.awt.BasicStroke     */    public void setStroke(Stroke s) {        if (s != null) {            stroke = s;        } else {            stroke = BASIC_STROKE;        }    }    /**     * Get the Stroke used for the graphic edge.     */    public Stroke getStroke() {        if (stroke == null) {            stroke = BASIC_STROKE;        }        return stroke;    }    /**     * Set whether an EditableOMGraphic modifying this graphic should     * show it's palette.     */    public void setShowEditablePalette(boolean set) {        showEditablePalette = set;    }    /**     * Get whether an EditableOMGraphic modifying this graphic should     * show it's palette.     */    public boolean getShowEditablePalette() {        return showEditablePalette;    }    /**     * A function that takes a float distance, which presumably     * represents the pixel distance from a point to a graphic, and     * subtracts half of the line width of the graphic from the     * distance if the graphic line width is greater than one. This     * should give a true pixel distance from the graphic, taking into     * account an embellished line.     *      * @param distance pixel distance to the graphic edge with a line

⌨️ 快捷键说明

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