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

📄 omgeometrylist.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
// **********************************************************************// // <copyright>// //  BBN Technologies//  10 Moulton Street//  Cambridge, MA 02138//  (617) 873-8000// //  Copyright (C) BBNT Solutions LLC. All rights reserved.// // </copyright>// **********************************************************************// // $Source: /cvs/distapps/openmap/src/openmap/com/bbn/openmap/omGraphics/OMGeometryList.java,v $// $RCSfile: OMGeometryList.java,v $// $Revision: 1.8.2.3 $// $Date: 2005/08/09 21:17:44 $// $Author: dietrick $// // **********************************************************************package com.bbn.openmap.omGraphics;import java.awt.BasicStroke;import java.awt.Color;import java.awt.Graphics;import java.awt.Graphics2D;import java.awt.Paint;import java.awt.Shape;import java.awt.Stroke;import java.awt.TexturePaint;import java.awt.geom.GeneralPath;import java.io.EOFException;import java.io.IOException;import java.io.ObjectInputStream;import java.io.OptionalDataException;import java.io.Serializable;import java.util.ListIterator;import com.bbn.openmap.proj.Projection;import com.bbn.openmap.util.GraphicList;import com.bbn.openmap.util.Debug;/** * This class encapsulates a List of OMGeometries. It's an OMGraphic, * so it contains information on how to draw them. It's also a * subclass to the OMGraphicList, and relies on many OMGraphicList * methods. *  * <p> * The OMGeometryList assumes that all OMGeometries on it should be * rendered the same - same fill color, same edge color and stroke, * and will create one java.awt.Shape object from all the projected * OMGeometries for more efficient rendering. If your individual * OMGeometries have independing rendering characteristics, use the * OMGraphicList and OMGraphics. *  * <p> * Because the OMGeometryList creates a single java.awt.Shape object * for all of its contents, it needs to be generated() if an * OMGeometry is added or removed from the list. If you don't * regenerate the OMGeometryList, the list will iterate through its * contents and render each piece separately. */public class OMGeometryList extends OMGraphicList implements GraphicList,        Serializable {    /**     * Flag to mark that the parts should be connected, making this     * OMGeometryList a combination OMGraphic that sums disparate     * parts. False by default.     */    protected boolean connectParts = false;    /**     * Construct an OMGeometryList.     */    public OMGeometryList() {        super(10);    };    /**     * Construct an OMGeometryList with an initial capacity.     *      * @param initialCapacity the initial capacity of the list     */    public OMGeometryList(int initialCapacity) {        super(initialCapacity);    };    /**     * Construct an OMGeometryList around a List of OMGeometries. The     * OMGeometryList assumes that all the objects on the list are     * OMGeometries, and never does checking. Live with the     * consequences if you put other stuff in there.     *      * @param list List of OMGeometries.     */    public OMGeometryList(java.util.List list) {        super(list);    }    /**     * Add an OMGeometry to the GraphicList. The OMGeometry must not     * be null.     *      * @param g the non-null OMGeometry to add     * @exception IllegalArgumentException if OMGeometry is null     */    public void add(OMGeometry g) {        setNeedToRegenerate(true);        _add(g);    }    /**     * Remove the geometry from the list.     *      * @param geometry the geometry to remove.     * @return true if geometry was on the list, false if otherwise.     */    public boolean remove(OMGeometry geometry) {        setNeedToRegenerate(true);        return _remove(geometry);    }    /**     * Return the index of the OMGeometry in the list.     *      * @param geometry the geometry to look for     * @return the index in the list of the geometry, -1 if the object     *         is not found.     */    public int indexOf(OMGeometry geometry) {        return _indexOf(geometry);    }    /**     * Set the geometry at the specified location. The OMGeometry must     * not be null.     *      * @param geometry OMGeometry     * @param index index of the OMGeometry to return     * @exception ArrayIndexOutOfBoundsException if index is     *            out-of-bounds     */    public void setAt(OMGeometry geometry, int index) {        setNeedToRegenerate(true);        _setAt(geometry, index);    }    /**     * Get the geometry at the location number on the list.     *      * @param location the location of the OMGeometry to return     * @return OMGeometry or null if location &gt; list size     * @exception ArrayIndexOutOfBoundsException if     *            <code>location &lt; 0</code> or     *            <code>location &gt;=     * this.size()</code>     */    public OMGeometry getAt(int location) {        return _getAt(location);    }    /**     * Get the geometry with the appObject. Traverse mode doesn't     * matter. Tests object identity first, then tries equality.     *      * @param appObj appObject of the wanted geometry.     * @return OMGeometry or null if not found     * @see Object#equals     * @see OMGeometry#setAppObject     * @see OMGeometry#getAppObject     */    public OMGeometry getWithAppObject(Object appObj) {        return _getWithAppObject(appObj);    }    /**     * Remove the geometry at the location number.     *      * @param location the location of the OMGeometry to remove     */    public Object removeAt(int location) {        Object obj = _remove(location);        if (obj != null) {            setNeedToRegenerate(true);        }        return obj;    }    /**     * Insert the geometry at the location number. The OMGeometry must     * not be null.     *      * @param geometry the OMGeometry to insert.     * @param location the location of the OMGeometry to insert     * @exception ArrayIndexOutOfBoundsException if index is     *            out-of-bounds     */    public void insertAt(OMGeometry geometry, int location) {        setNeedToRegenerate(true);        _insert(geometry, location);    }    /**     * Set the stroke for this list object. All geometries will be     * rendered with this stroke.     *      * @param s the stroke object to use.     */    public void setStroke(Stroke s) {        if (s != null) {            stroke = s;        } else {            stroke = new BasicStroke();        }    }    /**     * Set the fill paint for this list object. All the geometries     * will be rendered with this fill paint.     *      * @param paint java.awt.Paint     */    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 OMGeometries on the list. 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 graphics, with the fill paint still     * influencing appearance.     */    public void setTextureMask(TexturePaint texture) {        textureMask = texture;    }    /**     * Set the line paint for this list object. All the geometries     * will be rendered with this fill paint.     *      * @param paint Set the line paint for all the objects on the     *        list.     */    public void setLinePaint(Paint paint) {        if (paint != null) {            linePaint = paint;        } else {            linePaint = Color.black;        }        if (!selected) {            displayPaint = linePaint;        }        setEdgeMatchesFill();    }    /**     * Set the select paint for this list object. All the geometries     * will be rendered with this fill paint.     *      * @param paint java.awt.Paint     */    public void setSelectPaint(Paint paint) {        if (paint != null) {            selectPaint = paint;        } else {            selectPaint = Color.black;        }        if (selected) {            displayPaint = selectPaint;        }        setEdgeMatchesFill();    }    /**     * Set the matting paint for all the objects on the list.     *      * @param paint java.awt.Paint     */    public void setMattingPaint(Paint paint) {        if (paint != null) {            mattingPaint = paint;        } else {            mattingPaint = Color.black;        }    }    /**     * Set the matting flag for all the list.     */    public void setMatted(boolean value) {        matted = value;    }    /**     * Renders all the objects in the list a geometries context. This     * is the same as <code>paint()</code> for AWT components. The     * geometries are rendered in the order of traverseMode. Any     * geometries where <code>isVisible()</code> returns false are     * not rendered.     *      * @param gr the AWT Graphics context     */    public synchronized void render(Graphics gr) {        Shape shp = getShape();        if (shp != null) {            if (matted) {                if (gr instanceof Graphics2D && stroke instanceof BasicStroke) {                    ((Graphics2D) gr).setStroke(new BasicStroke(((BasicStroke) stroke).getLineWidth() + 2f));                    setGraphicsColor(gr, mattingPaint);                    draw(gr);                }            }            setGraphicsForFill(gr);            ((Graphics2D) gr).fill(shp);            setGraphicsForEdge(gr);            ((Graphics2D) gr).draw(shp);        } else {            ListIterator iterator;            java.util.List targets = getTargets();            OMGeometry geometry;            if (traverseMode == FIRST_ADDED_ON_TOP) {                iterator = targets.listIterator(targets.size());                while (iterator.hasPrevious()) {                    geometry = (OMGeometry) iterator.previous();                    if (geometry.isVisible()) {                        renderGeometry(geometry, gr);                    }                }

⌨️ 快捷键说明

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