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

📄 esrigraphicfactory.java

📁 OpenMap是一个基于JavaBeansTM的开发工具包。利用OpenMap你就能够快速构建用于访问legacy数据库的应用程序与applets。OpenMap提供了允许用户查看和操作地理空间信息的
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
     * Creates a OMGraphic from the shape file data.     *      * @param shapeType the shape file's shape type, enumerated in     *        <code>ShapeUtils</code>     * @param b the buffer pointing to the raw record data     * @param off the offset of the data starting point in the buffer     * @exception IOException if something goes wrong reading the file     * @see ShapeUtils     */    protected OMGraphic makeEsriGraphic(LittleEndianInputStream iStream,                                        DrawingAttributes drawingAttributes,                                        Object pointRepresentation,                                        ReadByteTracker byteTracker)            throws IOException, FormatException {        /*         * SHAPE_TYPE_NULL = 0; SHAPE_TYPE_POINT = 1; SHAPE_TYPE_ARC = 3;         * SHAPE_TYPE_POLYLINE = 3; SHAPE_TYPE_POLYGON = 5;         * SHAPE_TYPE_MULTIPOINT = 8; SHAPE_TYPE_POINTZ = 11;         * SHAPE_TYPE_POLYLINEZ = 13; SHAPE_TYPE_POLYGONZ = 15;         * SHAPE_TYPE_MUILTIPOINTZ = 18; SHAPE_TYPE_POINTM = 21;         * SHAPE_TYPE_POLYLINEM = 23; SHAPE_TYPE_POLYGONM = 25;         * SHAPE_TYPE_MULTIPOINTM = 28; SHAPE_TYPE_MULTIPATCH = 31;         */        EsriGraphic eg = null;        int shapeType = iStream.readLEInt();        byteTracker.addRead(4);        switch (shapeType) {        case SHAPE_TYPE_NULL:            break;        case SHAPE_TYPE_POINT:            eg = createPointGraphic(iStream,                    pointRepresentation,                    drawingAttributes,                    byteTracker);            break;        case SHAPE_TYPE_POLYLINE:            eg = createPolylineGraphic(iStream, drawingAttributes, byteTracker);            break;        case SHAPE_TYPE_POLYGON:            eg = createPolygonGraphic(iStream, drawingAttributes, byteTracker);            break;        case SHAPE_TYPE_MULTIPOINT:            eg = createMultiPointGraphic(iStream,                    pointRepresentation,                    drawingAttributes,                    byteTracker);            break;        case SHAPE_TYPE_POINTZ:            eg = createPointZGraphic(iStream,                    pointRepresentation,                    drawingAttributes,                    byteTracker);            break;        case SHAPE_TYPE_POLYLINEZ:            eg = createPolylineZGraphic(iStream, drawingAttributes, byteTracker);            break;        case SHAPE_TYPE_POLYGONZ:            eg = createPolygonZGraphic(iStream, drawingAttributes, byteTracker);            break;        case SHAPE_TYPE_MULTIPOINTZ:            eg = createMultiPointZGraphic(iStream,                    pointRepresentation,                    drawingAttributes,                    byteTracker);            break;        case SHAPE_TYPE_POINTM:            eg = createPointMGraphic(iStream,                    pointRepresentation,                    drawingAttributes,                    byteTracker);            break;        case SHAPE_TYPE_POLYLINEM:            eg = createPolylineMGraphic(iStream, drawingAttributes, byteTracker);            break;        case SHAPE_TYPE_POLYGONM:            eg = createPolygonMGraphic(iStream, drawingAttributes, byteTracker);            break;        case SHAPE_TYPE_MULTIPOINTM:            eg = createMultiPointMGraphic(iStream,                    pointRepresentation,                    drawingAttributes,                    byteTracker);            break;        case SHAPE_TYPE_MULTIPATCH:        default:        }        return (OMGraphic) eg;    }    // ///////// Point and Multi-Point Shapes    protected EsriGraphic createPointGraphic(double x, double y,                                             Object representation,                                             DrawingAttributes drawingAttributes) {        if (dataTransformation != null) {            LatLonPoint llp = dataTransformation.inverse(x, y);            x = llp.getLongitude();            y = llp.getLatitude();        }        EsriGraphic ret = null;        if (representation == null) {            ret = new EsriPoint((float) y, (float) x);        } else if (representation instanceof ImageIcon) {            ret = new EsriIconPoint((float) y, (float) x, (ImageIcon) representation);        } else if (representation instanceof String) {            ret = new EsriTextPoint((float) y, (float) x, (String) representation, OMText.JUSTIFY_CENTER);        }        if (drawingAttributes != null && ret != null) {            drawingAttributes.setTo((OMGraphic) ret);        }        return ret;    }    /**     * Reads the ShapeFile and creates a OMPoint/OMRaster/OMText from the point     * object.     *      * @param shpFile with the file pointer right after the shape record shape     *        type bytes. It's assumed that the shape type has been read to     *        determine that the shapeType for this record is a Point record.     * @param representation The object to use for representing the Point. If     *        the object is an ImageIcon, that image is used for a scaling icon     *        at this point. If it's a String, and OMText will be created for     *        that Point (center-justified). If it's null, the drawing     *        attributes values will be used for an OMPoint.     * @param drawingAttributes the attributes for the OMGraphic.     * @param byteTracker     * @return OMPoint or OMScalingRaster or OMText     * @throws IOException     */    protected EsriGraphic createPointGraphic(                                             BinaryFile shpFile,                                             Object representation,                                             DrawingAttributes drawingAttributes,                                             ReadByteTracker byteTracker)            throws IOException, FormatException {        double x = shpFile.readDouble();        double y = shpFile.readDouble();        byteTracker.addRead(2 * 8);        return createPointGraphic(x, y, representation, drawingAttributes);    }    protected EsriGraphic createPointGraphic(                                             LittleEndianInputStream iStream,                                             Object representation,                                             DrawingAttributes drawingAttributes,                                             ReadByteTracker byteTracker)            throws IOException, FormatException {        double x = iStream.readLEDouble();        double y = iStream.readLEDouble();        byteTracker.addRead(2 * 8);        return createPointGraphic(x, y, representation, drawingAttributes);    }    protected EsriGraphic createMultiPointGraphic(                                                  BinaryFile shpFile,                                                  Object representation,                                                  DrawingAttributes drawingAttributes,                                                  ReadByteTracker byteTracker)            throws IOException, FormatException {        // Skip reading the bounding box, 4 doubles        shpFile.skipBytes(4 * 8);        byteTracker.addRead(4 * 8);        int numParts = shpFile.readInteger();        EsriPointList multiPart = new EsriPointList();        multiPart.setVague(true);        for (int i = 0; i < numParts; i++) {            EsriGraphic part = createPointGraphic(shpFile,                    representation,                    drawingAttributes,                    byteTracker);            if (part != null) {                multiPart.add((OMGraphic) part);            }        }        return multiPart;    }    protected EsriGraphic createMultiPointGraphic(                                                  LittleEndianInputStream iStream,                                                  Object representation,                                                  DrawingAttributes drawingAttributes,                                                  ReadByteTracker byteTracker)            throws IOException, FormatException {        // Skip reading the bounding box, 4 doubles        iStream.skipBytes(4 * 8);        byteTracker.addRead(4 * 8);        int numParts = iStream.readLEInt();        EsriPointList multiPart = new EsriPointList();        multiPart.setVague(true);        for (int i = 0; i < numParts; i++) {            EsriGraphic part = createPointGraphic(iStream,                    representation,                    drawingAttributes,                    byteTracker);            if (part != null) {                multiPart.add((OMGraphic) part);            }        }        return multiPart;    }    protected EsriGraphic createPointZGraphic(                                              BinaryFile shpFile,                                              Object representation,                                              DrawingAttributes drawingAttributes,                                              ReadByteTracker byteTracker)            throws IOException, FormatException {        double x = shpFile.readDouble();        double y = shpFile.readDouble();        double z = shpFile.readDouble();        double m = shpFile.readDouble();        byteTracker.addRead(4 * 8);        EsriGraphic ret = createPointGraphic(x,                y,                representation,                drawingAttributes);        ret.setType(SHAPE_TYPE_POINTZ);        ((OMGraphic) ret).putAttribute(ShapeConstants.SHAPE_MEASURE_ATTRIBUTE,                new Double(m));        ((OMGraphic) ret).putAttribute(ShapeConstants.SHAPE_Z_ATTRIBUTE,                new Double(z));        return ret;    }    protected EsriGraphic createPointZGraphic(                                              LittleEndianInputStream iStream,                                              Object representation,                                              DrawingAttributes drawingAttributes,                                              ReadByteTracker byteTracker)            throws IOException, FormatException {        double x = iStream.readLEDouble();        double y = iStream.readLEDouble();        double z = iStream.readLEDouble();        double m = iStream.readLEDouble();        byteTracker.addRead(4 * 8);        EsriGraphic ret = createPointGraphic(x,                y,                representation,                drawingAttributes);        ret.setType(SHAPE_TYPE_POINTZ);        ((OMGraphic) ret).putAttribute(ShapeConstants.SHAPE_MEASURE_ATTRIBUTE,                new Double(m));        ((OMGraphic) ret).putAttribute(ShapeConstants.SHAPE_Z_ATTRIBUTE,                new Double(z));        return ret;    }    protected EsriGraphic createMultiPointZGraphic(                                                   BinaryFile shpFile,                                                   Object representation,                                                   DrawingAttributes drawingAttributes,                                                   ReadByteTracker byteTracker)            throws IOException, FormatException {        EsriGraphic multiPart = createMultiPointGraphic(shpFile,                representation,                drawingAttributes,                byteTracker);        if (multiPart != null && multiPart instanceof EsriGraphicList) {            ((EsriGraphicList) multiPart).setType(SHAPE_TYPE_MULTIPOINTZ);            int numPoints = ((EsriGraphicList) multiPart).size();            double minZ = shpFile.readDouble();            double maxZ = shpFile.readDouble();            double[] zs = new double[numPoints];            for (int i = 0; i < numPoints; i++) {                zs[i] = shpFile.readDouble();            }            ((OMGraphic) multiPart).putAttribute(ShapeConstants.SHAPE_MIN_Z_ATTRIBUTE,                    new Double(minZ));            ((OMGraphic) multiPart).putAttribute(ShapeConstants.SHAPE_MAX_Z_ATTRIBUTE,                    new Double(maxZ));            ((OMGraphic) multiPart).putAttribute(ShapeConstants.SHAPE_Z_ATTRIBUTE,                    zs);            byteTracker.addRead((2 + numPoints) * 8);            if (byteTracker.numLeft() > 0) {                double minM = shpFile.readDouble();                double maxM = shpFile.readDouble();                double[] ms = new double[numPoints];                for (int i = 0; i < numPoints; i++) {                    ms[i] = shpFile.readDouble();                }                ((OMGraphic) multiPart).putAttribute(ShapeConstants.SHAPE_MIN_MEASURE_ATTRIBUTE,                        new Double(minM));                ((OMGraphic) multiPart).putAttribute(ShapeConstants.SHAPE_MAX_MEASURE_ATTRIBUTE,                        new Double(maxM));                ((OMGraphic) multiPart).putAttribute(ShapeConstants.SHAPE_MEASURE_ATTRIBUTE,                        ms);                byteTracker.addRead((2 + numPoints) * 8);            }        }        return multiPart;    }    protected EsriGraphic createMultiPointZGraphic(                                                   LittleEndianInputStream iStream,                                                   Object representation,                                                   DrawingAttributes drawingAttributes,                                                   ReadByteTracker byteTracker)            throws IOException, FormatException {        EsriGraphic multiPart = createMultiPointGraphic(iStream,                representation,                drawingAttributes,                byteTracker);        if (multiPart != null && multiPart instanceof EsriGraphicList) {            ((EsriGraphicList) multiPart).setType(SHAPE_TYPE_MULTIPOINTZ);            int numPoints = ((EsriGraphicList) multiPart).size();            double minZ = iStream.readLEDouble();            double maxZ = iStream.readLEDouble();            double[] zs = new double[numPoints];            for (int i = 0; i < numPoints; i++) {                zs[i] = iStream.readLEDouble();            }            ((OMGraphic) multiPart).putAttribute(ShapeConstants.SHAPE_MIN_Z_ATTRIBUTE,                    new Double(minZ));            ((OMGraphic) multiPart).putAttribute(ShapeConstants.SHAPE_MAX_Z_ATTRIBUTE,                    new Double(maxZ));

⌨️ 快捷键说明

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