Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.bbn.openmap.dataAccess.shape
Class EsriShapeExport

    java.lang.Object
      com.bbn.openmap.dataAccess.shape.EsriShapeExport

All Implemented Interfaces:
  OMGraphicConstants, ShapeConstants

public class EsriShapeExport
extends java.lang.Object
implements ShapeConstants, OMGraphicConstants

Provides methods for saving OMGraphicLists as ShapeFiles. This code was originally submitted by Karl Stuempfle of OptiMetrics, and I modified it a little to add a user interface to modify the DBF files if the user wants to.

Since Shape files can only hold one type of graphic, this class will create one to three different lists as needed, for points, lines and polygons.

If the OMGraphicList's AppObject holds a DbfTableModel, it will be used for the shape file database file.

Nested Class Summary
`class` | `EsriShapeExport.ESEInterface` A helper class to manage a specific instance of a EsriGraphicList, it's data model, etc.

Field Summary
`protected boolean` | `dbfHasRenderingInfo` Flad to note whether, if a DbfTableModel is set, to add the rendering information (DrawingAttributes contents) about the OMGraphics to the contents of the DbfTableModel.
`protected boolean` | `DEBUG` Gets set automatically if Debug.debugging("shape");
`protected java.util.ArrayList` | `eseInterfaces` A list of ESEInterface classes, holding information for different type ESRIGraphicLists created from the OMGraphicList.
`protected java.lang.String` | `filePath` The path where the shape files should be written.
`protected javax.swing.JFrame` | `frame`
`protected OMGraphicList` | `graphicList` The source graphics to write to a shape file.
`protected EsriPolylineList` | `lineList`
`protected DbfTableModel` | `masterDBF` The optional DbfTableModel that describes properties for the OMGraphics.
`protected EsriPointList` | `pointList`
`protected EsriPolygonList` | `polyList`
`protected Projection` | `projection` The projection needed to convert other OMGraphicTypes to polygons.
`protected boolean` | `writeDBF` Flag for whether the DBF file should be written when the OMGraphicList is exported to a .shp/.shx file.

Fields inherited from interface com.bbn.openmap.dataAccess.shape.ShapeConstants
`DBF_ATTRIBUTE, DBF_CHARACTER, DBF_DATE, DBF_LOGICAL, DBF_MEMO, DBF_NUMERIC, DBF_TYPE_CHARACTER, DBF_TYPE_DATE, DBF_TYPE_LOGICAL, DBF_TYPE_MEMO, DBF_TYPE_NUMERIC, PARAM_DBF, PARAM_SHP, PARAM_SHX, SHAPE_BOUNDS_ATTRIBUTE, SHAPE_DBF_DASHPATTERN, SHAPE_DBF_DASHPHASE, SHAPE_DBF_DESCRIPTION, SHAPE_DBF_FILLCOLOR, SHAPE_DBF_INFO_ATTRIBUTE, SHAPE_DBF_LINECOLOR, SHAPE_DBF_LINEWIDTH, SHAPE_DBF_SELECTCOLOR, SHAPE_FILE_HEADER_LENGTH, SHAPE_FILE_RECORD_HEADER_LENGTH, SHAPE_INDEX_ATTRIBUTE, SHAPE_MAX_MEASURE_ATTRIBUTE, SHAPE_MAX_Z_ATTRIBUTE, SHAPE_MEASURE_ATTRIBUTE, SHAPE_MIN_MEASURE_ATTRIBUTE, SHAPE_MIN_Z_ATTRIBUTE, SHAPE_TYPE_ARC, SHAPE_TYPE_MULTIPATCH, SHAPE_TYPE_MULTIPOINT, SHAPE_TYPE_MULTIPOINTM, SHAPE_TYPE_MULTIPOINTZ, SHAPE_TYPE_NULL, SHAPE_TYPE_POINT, SHAPE_TYPE_POINTM, SHAPE_TYPE_POINTZ, SHAPE_TYPE_POLYGON, SHAPE_TYPE_POLYGONM, SHAPE_TYPE_POLYGONZ, SHAPE_TYPE_POLYLINE, SHAPE_TYPE_POLYLINEM, SHAPE_TYPE_POLYLINEZ, SHAPE_Z_ATTRIBUTE`

Fields inherited from interface com.bbn.openmap.omGraphics.OMGraphicConstants
`ADD_GRAPHIC_MASK, BASIC_STROKE, CHANGE_APPEARANCE, clear, DECIMAL_DEGREES, DECLUTTERTYPE_LINE, DECLUTTERTYPE_MOVE, DECLUTTERTYPE_NONE, DECLUTTERTYPE_SPACE, DEFAULT_ROTATIONANGLE, DELETE_GRAPHIC_MASK, DESELECT_GRAPHIC_MASK, DESELECTALL_GRAPHIC_MASK, GRAPHICTYPE_ARC, GRAPHICTYPE_BITMAP, GRAPHICTYPE_CIRCLE, GRAPHICTYPE_ELLIPSE, GRAPHICTYPE_GRAPHIC, GRAPHICTYPE_GRID, GRAPHICTYPE_LINE, GRAPHICTYPE_POINT, GRAPHICTYPE_POLY, GRAPHICTYPE_RASTER, GRAPHICTYPE_RECTANGLE, GRAPHICTYPE_TEXT, INFOLINE, LABEL, LINETYPE_GREATCIRCLE, LINETYPE_RHUMB, LINETYPE_STRAIGHT, LINETYPE_UNKNOWN, LOWER_GRAPHIC_MASK, LOWER_TO_BOTTOM_GRAPHIC_MASK, RADIANS, RAISE_GRAPHIC_MASK, RAISE_TO_TOP_GRAPHIC_MASK, REMOVABLE, RENDERTYPE_LATLON, RENDERTYPE_OFFSET, RENDERTYPE_UNKNOWN, RENDERTYPE_XY, SELECT_GRAPHIC_MASK, SORT_GRAPHICS_MASK, TOOLTIP, UPDATE_GRAPHIC_MASK`

Constructor Summary
`EsriShapeExport(EsriGraphicList list, DbfTableModel dbf, java.lang.String pathToFile)` Create an EsriShapeExport object.
`EsriShapeExport(OMGraphicList list, Projection proj, java.lang.String pathToFile)` Create an EsriShapeExport object.

Method Summary
`protected void` | `addGraphic(EsriGraphicList egl, OMGraphic graphic, java.util.ArrayList record)` Add a graphic to the list, and add the record to the list's DbfTableModel if both exist.
`protected void` | `addLine(OMGraphic graphic, java.util.ArrayList record)` Scoping method to call addGraphic with the right list.
`protected void` | `addPoint(OMGraphic graphic, java.util.ArrayList record)` Scoping method to call addGraphic with the right list.
`protected void` | `addPolygon(OMGraphic graphic, java.util.ArrayList record)` Scoping method to call addGraphic with the right list.
`static DbfTableModel` | `createDefaultModel(EsriGraphicList list)` Prepares and returns a 7 column DbfTableModel to accept input for columns of TYPE_CHARACTER.
`void` | `export()` Separates the graphics from the OMGraphicList into Polygon, Polyline and Point lists, then passes the desired shape lists to their respective export functions to be added to an EsriLayer of the same type and prepared for export.
`protected void` | `export(EsriGraphicList egList)` Writes out EsriGraphicLists as shape files, assumes that the DbfTableModel representing the attribute data for the list objects is stored as an attribute in the EsriGraphicList under the DBF_ATTRIBUTE key.
`protected void` | `export(OMGraphicList list, java.util.ArrayList record)` Deprecated. use export(OMGraphicList, ArrayList, boolean) instead.
`protected void` | `export(OMGraphicList list, java.util.ArrayList masterRecord, boolean writeFiles)` This method is intended to allow embedded OMGraphicLists to be handled.
`boolean` | `getDBFHasRenderingInfo()` Get whether the DBF file should have the DrawingAttributes information added to the DbfTableModel if it isn't already there.
`java.lang.String` | `getFilePath()`
`java.lang.String` | `getFilePathFromUser()` Fetches a file path from the user, via a JFileChooser.
`OMGraphicList` | `getGraphicList()`
`java.awt.Component` | `getGUI()` Create the GUI for managing the different ESEIterators.
`protected java.util.Iterator` | `getInterfaces()` The the Iterator of ESEIterators.
`protected EsriPolylineList` | `getLineList()` Return the line list, create it if needed.
`DbfTableModel` | `getMasterDBF()` Get the DbfTableModel representing the dbf file for the main OMGraphicList.
`protected DbfTableModel` | `getMasterDBFHeaderClone()` If the OMGraphicList has a DbfTableModel in its AppObject slot, a new DbfTableModel is created that has the same structure.
`protected java.util.ArrayList` | `getMasterDBFRecord(int index)` Gets the DbfTableModel record at the index.
`protected EsriPointList` | `getPointList()` Return the point list, create it if needed.
`protected EsriPolygonList` | `getPolyList()` Return the polygon list, create it if needed.
`Projection` | `getProjection()`
`boolean` | `getWriteDBF()` Get whether the DBF file should be written when the OMGraphicList is exported to a .shp/.shx file.
`protected void` | `handleException(java.lang.Exception e)` Generic error handling, puts up an error window.
`void` | `hideGUI()` Hide the Frame holding the GUI.
`static boolean` | `isPolygon(OMPoly omPoly)` Takes an OMPoly as the parameter and checks whether or not it is a polygon or polyline.
`static void` | `main(java.lang.String[] argv)` The main function is a test, reads in a Shape file (with the .shx and .dbf files) and writes them back out.
`void` | `setDBFHasRenderingInfo(boolean value)` Get whether the DBF file should have the DrawingAttributes information added to the DbfTableModel if it isn't already there.
`void` | `setFilePath(java.lang.String pathToFile)`
`void` | `setGraphicList(OMGraphicList list)` Set the OMGraphicList to use for export.
`void` | `setMasterDBF(DbfTableModel dbf)` Set the DbfTableModel representing the dbf file for the main OMGraphicList.
`void` | `setProjection(Projection proj)`
`void` | `setWriteDBF(boolean value)` Set whether the DBF file should be written when the OMGraphicList is exported to a .shp/.shx file.
`void` | `showGUI()` Show the GUI for saving the Shape files.
`protected void` | `writeFiles()` Just write the files from the ESEInterfaces.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### graphicList

    protected OMGraphicList graphicList

  The source graphics to write to a shape file.

### masterDBF

    protected DbfTableModel masterDBF

  The optional DbfTableModel that describes properties for the OMGraphics. This should be set in the AppObject of the OMGraphicList.

### projection

    protected Projection projection

  The projection needed to convert other OMGraphicTypes to polygons.

### filePath

    protected java.lang.String filePath

  The path where the shape files should be written.

### DEBUG

    protected boolean DEBUG

  Gets set automatically if Debug.debugging("shape");

### eseInterfaces

    protected java.util.ArrayList eseInterfaces

  A list of ESEInterface classes, holding information for different type ESRIGraphicLists created from the OMGraphicList.

### writeDBF

    protected boolean writeDBF

  Flag for whether the DBF file should be written when the OMGraphicList is exported to a .shp/.shx file. The .dbf file will be created if set to true, and this is true by default.

### dbfHasRenderingInfo

    protected boolean dbfHasRenderingInfo

  Flad to note whether, if a DbfTableModel is set, to add the rendering information (DrawingAttributes contents) about the OMGraphics to the contents of the DbfTableModel. False by default. Doesn't do anything yet.

### polyList

    protected EsriPolygonList polyList

### lineList

    protected EsriPolylineList lineList

### pointList

    protected EsriPointList pointList

### frame

    protected javax.swing.JFrame frame

Constructor Detail

### EsriShapeExport

    public EsriShapeExport(OMGraphicList list,
                           Projection proj,
                           java.lang.String pathToFile)

  Create an EsriShapeExport object.

Parameters:
  `list` - the OMGraphicList to export.
  `proj` - the Projection of the map, needed to convert some OMGraphic types to OMPolys.
  `pathToFile` - the file path of the shape file to save to. If null, the user will be queried. If not null, the files will be saved without any GUI confirmation.

### EsriShapeExport

    public EsriShapeExport(EsriGraphicList list,
                           DbfTableModel dbf,
                           java.lang.String pathToFile)

  Create an EsriShapeExport object.

Parameters:
  `list` - the EsriGraphicList to export.
  `dbf` - the DbfTableModel holding the attributes for the list objects.
  `pathToFile` - the file path of the shape file to save to. If null, the user will be queried. If not null, the files will be saved without any GUI confirmation.

Method Detail

### setGraphicList

    public void setGraphicList(OMGraphicList list)

  Set the OMGraphicList to use for export. If the AppObject in the OMGraphicList holds a DbfTableModel, it will be used in the export.

### getGraphicList

    public OMGraphicList getGraphicList()

### setProjection

    public void setProjection(Projection proj)

### getProjection

    public Projection getProjection()

### setFilePath

    public void setFilePath(java.lang.String pathToFile)

### getFilePath

    public java.lang.String getFilePath()

### getPolyList

    protected EsriPolygonList getPolyList()

  Return the polygon list, create it if needed.

### getLineList

    protected EsriPolylineList getLineList()

  Return the line list, create it if needed.

### getPointList

    protected EsriPointList getPointList()

  Return the point list, create it if needed. If the masterDBF object exists, then a new one is created, which matching structure, and put in the AppObject of the new list that is returned. If there isn't a masterDBF object, then the AppObject is set to null, and a default one will be created.

### addGraphic

    protected void addGraphic(EsriGraphicList egl,
                              OMGraphic graphic,
                              java.util.ArrayList record)

  Add a graphic to the list, and add the record to the list's DbfTableModel if both exist.

### addPolygon

    protected void addPolygon(OMGraphic graphic,
                              java.util.ArrayList record)

  Scoping method to call addGraphic with the right list.

### addLine

    protected void addLine(OMGraphic graphic,
                           java.util.ArrayList record)

  Scoping method to call addGraphic with the right list.

### addPoint

    protected void addPoint(OMGraphic graphic,
                            java.util.ArrayList record)

  Scoping method to call addGraphic with the right list.

### setMasterDBF

    public void setMasterDBF(DbfTableModel dbf)

  Set the DbfTableModel representing the dbf file for the main OMGraphicList. Can also be passed to this object as an attribute in the EsriGraphicList under the DBF_ATTRIBUTE key.

### getMasterDBF

    public DbfTableModel getMasterDBF()

  Get the DbfTableModel representing the dbf file for the main OMGraphicList.

### setWriteDBF

    public void setWriteDBF(boolean value)

  Set whether the DBF file should be written when the OMGraphicList is exported to a .shp/.shx file. The .dbf file will be created if set to true, and this is true by default.

### getWriteDBF

    public boolean getWriteDBF()

  Get whether the DBF file should be written when the OMGraphicList is exported to a .shp/.shx file.

### setDBFHasRenderingInfo

    public void setDBFHasRenderingInfo(boolean value)

  Get whether the DBF file should have the DrawingAttributes information added to the DbfTableModel if it isn't already there.

### getDBFHasRenderingInfo

    public boolean getDBFHasRenderingInfo()

  Get whether the DBF file should have the DrawingAttributes information added to the DbfTableModel if it isn't already there.

### getMasterDBFHeaderClone

    protected DbfTableModel getMasterDBFHeaderClone()

  If the OMGraphicList has a DbfTableModel in its AppObject slot, a new DbfTableModel is created that has the same structure.

  Returns:
    DbfTableModel that matches the structure that is in the OMGraphicList AppObject.

### getMasterDBFRecord

    protected java.util.ArrayList getMasterDBFRecord(int index)

  Gets the DbfTableModel record at the index. Used when the OMGraphicList contents are being split up into different type EsriGraphicLists, and the records are being split into different tables, too.

### export

    public void export()

  Separates the graphics from the OMGraphicList into Polygon, Polyline and Point lists, then passes the desired shape lists to their respective export functions to be added to an EsriLayer of the same type and prepared for export. OMGraphics that are on sublists within the top-level OMGraphicList will be simply written to the appropriate list at the top level of that list. They will be handled as multi-part geometries.

  Separating the graphics into the three types is necessary due to shape file specification limitations which will only allow shape files to be of one type.

  For OMGraphicLists that are actually EsriGraphicLists, this export method will be redirected to a different method that will handle sub-OMGraphicLists as multi-part geometries.

  If you want to write out multi-part geometries and have a regular OMGraphicList, you have to convert them to EsriGraphicLists first (and OMGraphics to EsriGraphics), which forces you to group shapes into like types (points, polylines and polygons).

### export

    protected void export(OMGraphicList list,
                          java.util.ArrayList record)

  Deprecated. use export(OMGraphicList, ArrayList, boolean) instead.

  This method is intended to allow embedded OMGraphicLists to be handled. The record should be set if the list is an embedded list, reusing a record from the top level interation. Set the record to null at the top level iteration to cause the method to fetch the record from the masterDBF, if it exists.

  Parameters:
    `list` - the OMGraphicList to write
    `record` - the record for the current list, used if the list is actually a multipart geometry for the overall list. May be null anyway, though.
  See Also:
    `export(OMGraphicList list, ArrayList record, boolean writeFiles)`

### export

    protected void export(OMGraphicList list,
                          java.util.ArrayList masterRecord,
                          boolean writeFiles)

  This method is intended to allow embedded OMGraphicLists to be handled. The record should be set if the list is an embedded list, reusing a record from the top level interation. Set the record to null at the top level iteration to cause the method to fetch the record from the masterDBF, if it exists. If the list is an EsriGraphicList, then the export for EsriGraphicLists will be called. The DbfTableModel for the list should be stored as an attribute in the EsriGraphicList under the DBF_ATTRIBUTE key.

  Parameters:
    `list` - the OMGraphicList to write.
    `masterRecord` - the record for the current list, used if the list is actually a multipart geometry for the overall list. May be null anyway, though.
    `writeFiles` - Flag to note when this method is being called iteratively, which is when record is not null. If it is iterative, then the writing of the files should not be performed on this round of the method call.

### export

    protected void export(EsriGraphicList egList)

  Writes out EsriGraphicLists as shape files, assumes that the DbfTableModel representing the attribute data for the list objects is stored as an attribute in the EsriGraphicList under the DBF_ATTRIBUTE key. This export handles multi-part geometries, because it's assumed that the sorting of the graphic types have been handled and that any sub-lists are meant to be multi-part geometries. If the filePath hasn't been set in the EsriShapeExport class, the user will be asked to provide it.

### getInterfaces

    protected java.util.Iterator getInterfaces()

  The the Iterator of ESEIterators.

### writeFiles

    protected void writeFiles()

  Just write the files from the ESEInterfaces.

### showGUI

    public void showGUI()

  Show the GUI for saving the Shape files.

### hideGUI

    public void hideGUI()

  Hide the Frame holding the GUI.

### getGUI

    public java.awt.Component getGUI()

  Create the GUI for managing the different ESEIterators.

### createDefaultModel

    public static DbfTableModel createDefaultModel(EsriGraphicList list)

  Prepares and returns a 7 column DbfTableModel to accept input for columns of TYPE_CHARACTER.
  The default model used holds most of the DrawingAttributes of the OMGraphics.

  Parameters:
    `list` - the EsriGraphicList to create a DbfTableModel from.
  Returns:
    The completed DbfTableModel.

### isPolygon

    public static boolean isPolygon(OMPoly omPoly)

  Takes an OMPoly as the parameter and checks whether or not it is a polygon or polyline.
  This method incorporates the OMPoly.isPolygon() method which returns true if the fill color is not clear, but also checks the first set and last set of lat/lon points of the float[] defined by OMPoly.getLatLonArray(). Returns true for a polygon and false for a polyline.

  Parameters:
    `omPoly` - the OMPoly object to be verified
  Returns:
    The polygon value

### handleException

    protected void handleException(java.lang.Exception e)

  Generic error handling, puts up an error window.

### getFilePathFromUser

    public java.lang.String getFilePathFromUser()

  Fetches a file path from the user, via a JFileChooser. Returns null if the user cancels.

  See Also:
    `com.bbn.openmap.util.FileUtils.getFilePathFromUser`

### main

    public static void main(java.lang.String[] argv)

  The main function is a test, reads in a Shape file (with the .shx and .dbf files) and writes them back out.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details