package com.ximple.io.dgn7; //~--- non-JDK imports -------------------------------------------------------- /*----------------------------------------------------------------------+ | | | Type Description | | 1 Cell Library Header | | 2 Cell (complex) | | 3 Line | | 4 Line String | | 5 Group Data | | 6 Shape | | 7 Text Node (complex) | | 8 Digitizer Setup Data | | 9 Design File Header if level 8 | | 10 Level Symbology | | 11 Curve | | 12 Complex String (complex) | | 13 Conic | | 14 Complex Shape (complex) | | 15 Ellipse | | 16 Arc | | 17 Text | | 18 Surface (complex) | | 19 Solid (complex) | | 20 not used | | 21 B-Spline Pole | | 22 Point String | | 23 Circular Truncated Cone | | 24 B-Spline Surface (complex) | | 25 B-Spline Surface boundary | | 26 B-Spline Knot Record | | 27 B-Spline Curve (complex) | | 28 B-Spline Weight Factor | | 33 Dimension Record | | 34 Shared Cell Definition Record | | 35 Shared Cell Record | | 36 Multiline Record | | 37 Attribute Record | | 38 DgnStore Component | | 39 DgnStore Header | | 66 MicroStation Application | | 87 Raster Header | | 88 Raster Component | | 90 Raster Reference Attachment | | 91 Raster Reference Component | | 92 Raster Hierarchy Record | | 93 Raster Hierarchy Component | | 94 Raster Frame Record | | 95 Table Entry Record | | 96 Table Header Record | | 97 View Group Record | | 98 View Record | | 99 Level Mask Record | | 100 Reference Attach Record | | 101 Matrix Header | | 102 Matrix Int Data | | 103 Matrix Double Data | | 105 Mesh Header | | 106 Extended Record (graphic) (complex) | | 107 Extended Record (non-graphic) (complex) | | 108 Reference Override Record | | 110 Named Group Header | | 111 Named Group Component | | | +----------------------------------------------------------------------*/ /** * ElementType * * @author Ulysses * @version 0.1 * @since 2006/5/17 下午 01:26:49 */ public final class ElementType { /** * Represents a Null shape (id = 0). */ public static final ElementType NULL = new ElementType(0, "Null"); /** * Represents a Line shape (id = 3). */ public static final ElementType LINE = new ElementType(3, "Line"); /** * Represents a LineString shape (id = 4). */ public static final ElementType LINESTRING = new ElementType(4, "LineString"); /** * Represents a Shape shape (id = 6). */ public static final ElementType SHAPE = new ElementType(6, "Shape"); /** * Represents an TextNode shape (id = 7). */ public static final ElementType TEXTNODE = new ElementType(7, "TextNode"); /** * Represents an IGDSDIGITIZER shape (id = 8). */ public static final ElementType IGDSDIGITIZER = new ElementType(8, "IGDSDigitizer"); /** * Represents an TCB shape (id = 9). */ public static final ElementType TCB = new ElementType(9, "Tcb"); /** * Represents a LevelSymbology shape (id = 5). */ public static final ElementType LEVELSYMBOLOGY = new ElementType(10, "LevelSymbology"); /** * Represents a ComplexChain shape (id = 15). */ public static final ElementType COMPLEXCHAIN = new ElementType(12, "ComplexChain"); /** * Represents a ComplexShape shape (id = 25). */ public static final ElementType COMPLEXSHAPE = new ElementType(14, "ComplexShape"); /** * Represents a Ellipse shape (id = 8). */ public static final ElementType ELLIPSE = new ElementType(15, "Ellipse"); /** * Represents a Arc shape (id = 28). */ public static final ElementType ARC = new ElementType(16, "Arc"); /** * Represents a Arc shape (id = 28). */ public static final ElementType TEXT = new ElementType(17, "Text"); /** * Represents a Arc shape (id = 28). */ public static final ElementType POINTSTRING = new ElementType(22, "PointString"); /** * Represents an Undefined shape (id = -1). */ public static final ElementType UNDEFINED = new ElementType(-1, "Undefined"); /** * The integer id of this ElementType. */ public final int id; /** * The human-readable name for this ElementType.
* Could easily use ResourceBundle for internationialization. */ public final String name; /** * Creates a new instance of ElementType. Hidden on purpose. * * @param id The id. * @param name The name. */ protected ElementType(int id, String name) { this.id = id; this.name = name; } /** * Get the name of this ElementType. * * @return The name. */ public String toString() { return name; } /** * Is this a multipoint shape? Hint- all shapes are multipoint except NULL, * UNDEFINED, and the POINTs. * * @return true if multipoint, false otherwise. */ public boolean isMultiPoint() { boolean mp = true; if (this == UNDEFINED) { mp = false; } else if (this == NULL) { mp = false; } else if (this == IGDSDIGITIZER) { mp = false; } else if (this == TCB) { mp = false; } else if (this == LEVELSYMBOLOGY) { mp = false; } return mp; } public boolean isComplexElement() { if (id == 2) { return true; } if (id == 7) { return true; } if (id == 12) { return true; } if (id == 14) { return true; } if (id == 18) { return true; } if (id == 19) { return true; } if (id == 106) { return true; } if (id == 107) { return true; } return false; } public boolean isPointType() { if (id == 7) { return true; } if (id == 17) { return true; } return false; } public boolean isLineType() { if (id == 3) { return true; } if (id == 4) { return true; } if (id == 11) { return true; } if (id == 12) { return true; } if (id == 16) { return true; } return false; } public boolean isPolygonType() { if (id == 6) { return true; } if (id == 14) { return true; } return false; } public boolean isMultiPointType() { if (id == 3) { return true; } if (id == 4) { return true; } if (id == 6) { return true; } if (id == 11) { return true; } if (id == 12) { return true; } if (id == 13) { return true; } if (id == 14) { return true; } if (id == 15) { return true; } if (id == 16) { return true; } if (id == 22) { return true; } return false; } /** * Determine the ElementType for the id. * * @param id The id to search for. * @return The ElementType for the id. */ public static ElementType forID(int id) { ElementType t; switch (id) { case 0 : t = NULL; break; case 3 : t = LINE; break; case 4 : t = LINESTRING; break; case 6 : t = SHAPE; break; case 7 : t = TEXTNODE; break; case 8 : t = IGDSDIGITIZER; break; case 9 : t = TCB; break; case 10 : t = LEVELSYMBOLOGY; break; case 12 : t = COMPLEXCHAIN; break; case 14 : t = COMPLEXSHAPE; break; case 15 : t = ELLIPSE; break; case 16 : t = ARC; break; case 17 : t = TEXT; break; default : t = UNDEFINED; break; } return t; } public IElementHandler getElementHandler() throws Dgn7fileException { IElementHandler handler; switch (id) { case 3 : handler = LineElement.ElementHandler.getInstance(); break; case 4 : handler = LineStringElement.ElementHandler.getInstance(); break; case 6 : handler = ShapeElement.ElementHandler.getInstance(); break; case 7 : handler = TextNodeElement.ElementHandler.getInstance(); break; case 8 : handler = new Element.ElementHandler(this); break; case 9 : handler = new Element.ElementHandler(this); break; case 10 : handler = new Element.ElementHandler(this); break; case 12 : handler = ComplexChainElement.ElementHandler.getInstance(); break; case 14 : handler = ComplexShapeElement.ElementHandler.getInstance(); break; case 15 : handler = new Element.ElementHandler(this); break; case 16 : handler = ArcElement.ElementHandler.getInstance(); break; case 17 : handler = TextElement.ElementHandler.getInstance(); break; default : handler = null; } return handler; } }