@LcdService(service=ILcdModelDecoder.class, priority=20000) public class TLcdDWGModelDecoder extends Object implements ILcdDWGModelDecoder, ILcdInputStreamFactoryCapable
File | Required | Entry point | Description |
---|---|---|---|
*.dwg/*.dxf | x | x | Drawing file containing vector data |
inputStreamFactory
of this decoder.ILcd2DBoundsIndexedModel
.TLcdDWGModelDescriptor
. Among other information, the descriptor
contains the list of DWG layers and line styles.TLcdDataModelDescriptor
.
Its data model exposes the DWG extended entities in a uniform way.ILcdModelReferenceDecoder
. The default reference decoder set on this
model decoder is based on all model reference decoders annotated with the LcdService
annotation, and can handle
<filename>.epsg
): see TLcdEPSGModelReferenceDecoder
for more info.<filename>.prj
): see TLcdWKTModelReferenceDecoder
for more info.<filename>.ref
): see TLcdModelReferenceDecoder
for more info.ILcdDWGShape
.ILcdDataObject
s. If the element has any
extended data associated with it, the data object is an "ExtendedEntitiesList" that has
a property "entities" that is the list of entries.DWG element type | DWG element name | Decoded object |
---|---|---|
1 | TEXT |
|
2 | ATTRIB |
|
4 | BLOCK | |
5 | ENDBLK | |
6 | SEQEND | |
7 | INSERT |
|
8 | MINSERT |
|
10 | VERTEX_2D |
|
11 | VERTEX_3D |
|
15 | POLYLINE_2D |
|
16 | POLYLINE_3D |
|
17 | ARC |
|
18 | CIRCLE |
|
19 | LINE |
|
27 | POINT |
|
28 | FACE_3D |
|
31 | SOLID |
|
35 | ELLIPSE |
|
36 | SPLINE |
|
44 | MTEXT |
|
45 | LEADER |
|
47 | MLINE |
|
48 | BLOCK_CONTROL | |
49 | BLOCK_HEADER | |
50 | LAYER_CONTROL | |
51 | LAYER |
|
57 | LTYPE |
|
77/varies | LWPLINE |
|
78/varies | HATCH |
|
TLcdDWGSolid
. If it contains more paths, the decoder will
return a TLcdDWGBlock
containing one TLcdDWGSolid
for each path. TLcdDWGCompositeRing
and TLcdDWGCompositeCurve
objects are
created for solids, polylines and hatches containing bulges. Also, the
extended entity info item types are correctly filled in and layer
reference and registered application name items are decoded.
You can enable backwards compatibility mode using the system property
dwg.decoder.compatibility=true
.
dwg.decoder.legacy=true
system property, but it will not be able to
decode Autocad 2018+ DWG data files.
ILcdModelDecoder decoder =
new TLcdDWGModelDecoder(new TLcdEPSGModelReferenceDecoder(),
new TLcdGeodeticReference(new TLcdGeodeticDatum()));
ILcdModel model = decoder.decode("vectordata.dwg");
Constructor and Description |
---|
TLcdDWGModelDecoder()
Creates a new
TLcdDWGModelDecoder . |
TLcdDWGModelDecoder(ILcdModelReference aDefaultModelReference)
Creates a new
TLcdDWGModelDecoder . |
TLcdDWGModelDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder)
Creates a new
TLcdDWGModelDecoder . |
TLcdDWGModelDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder,
ILcdModelReference aDefaultModelReference)
Creates a new
TLcdDWGModelDecoder . |
Modifier and Type | Method and Description |
---|---|
void |
addExtendedEntityString(String aStringPrefix)
Adds a string prefix to the set of prefixes that determine which extended
entity strings are decoded.
|
void |
addExtendedEntityType(int aType)
Adds a DWG extended entity type to the set of types that is decoded.
|
boolean |
canDecodeSource(String s)
Checks whether this model decoder can decode the specified data source.
|
void |
clearExtendedEntityStringSelection()
Clears the set of DWG extended entity strings that is decoded.
|
void |
clearExtendedEntityTypeSelection()
Clears the set of DWG extended entity types that is decoded.
|
ILcdModel |
decode(String s)
Creates a new model from the given data source.
|
String |
getDefaultExtension() |
ILcdModelReference |
getDefaultModelReference()
Returns the default model reference for decoded models.
|
String |
getDisplayName()
Returns a short, displayable name for the format that is decoded by this
ILcdModelDecoder . |
ILcdInputStreamFactory |
getInputStreamFactory()
Returns the input stream factory that is used.
|
ILcdModelReferenceDecoder |
getModelReferenceDecoder()
Returns the model reference decoder that is for creating model references
for decoded models.
|
boolean |
isDecodeFrozenLayers()
Returns whether DWG layers that are marked as frozen are decoded.
|
boolean |
isDecodeInvisibleLayers()
Returns whether DWG layers that are marked as invisible are decoded.
|
boolean |
isDecodeInvisibleObjects()
Returns whether DWG objects that are marked as invisible are decoded.
|
void |
resetExtendedEntityStringSelection()
Resets the set of DWG extended entity strings that is decoded.
|
void |
resetExtendedEntityTypeSelection()
Resets the set of DWG extended entity types that is decoded.
|
void |
setDecodeFrozenLayers(boolean aDecodeFrozenLayers)
Specifies whether DWG layers that are marked as frozen should be
decoded.
|
void |
setDecodeInvisibleLayers(boolean aDecodeInvisibleLayers)
Specifies whether DWG layers that are marked as invisible should be
decoded.
|
void |
setDecodeInvisibleObjects(boolean aDecodeInvisibleObjects)
Specifies whether DWG objects that are marked as invisible should be
decoded.
|
void |
setDefaultModelReference(ILcdModelReference aDefaultModelReference)
Sets the default model reference for decoded models, in case the model
reference decoder doesn't provide one.
|
void |
setExtendedEntityStringSelection(String[] aStringPrefixes)
Sets the set of DWG extended entity strings that is decoded.
|
void |
setExtendedEntityTypeSelection(int[] aTypes)
Sets the set of DWG extended entity types that is decoded.
|
void |
setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
Sets the input stream factory to be used.
|
void |
setModelReferenceDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder)
Sets the model reference decoder that will be used for creating model
references for decoded models.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
canDecodeSource, decodeModelMetadata, decodeModelMetadata, decodeSource, discoverDataSources
public TLcdDWGModelDecoder()
TLcdDWGModelDecoder
.public TLcdDWGModelDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder)
TLcdDWGModelDecoder
.aModelReferenceDecoder
- the model reference decoder that can assign
references to decoded models.public TLcdDWGModelDecoder(ILcdModelReference aDefaultModelReference)
TLcdDWGModelDecoder
.aDefaultModelReference
- the model reference that decoded models will
get if the model reference decoder can't
decode one.public TLcdDWGModelDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder, ILcdModelReference aDefaultModelReference)
TLcdDWGModelDecoder
.aModelReferenceDecoder
- the model reference decoder that can assign
references to decoded models.aDefaultModelReference
- the model reference that decoded models will
get if the model reference decoder can't
decode one.public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
ILcdInputStreamFactoryCapable
setInputStreamFactory
in interface ILcdInputStreamFactoryCapable
aInputStreamFactory
- the input stream factory to be used.public ILcdInputStreamFactory getInputStreamFactory()
ILcdInputStreamFactoryCapable
getInputStreamFactory
in interface ILcdInputStreamFactoryCapable
public String getDefaultExtension()
public void setModelReferenceDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder)
ILcdDWGModelDecoder
null
.setModelReferenceDecoder
in interface ILcdDWGModelDecoder
public ILcdModelReferenceDecoder getModelReferenceDecoder()
ILcdDWGModelDecoder
getModelReferenceDecoder
in interface ILcdDWGModelDecoder
public void setDefaultModelReference(ILcdModelReference aDefaultModelReference)
ILcdDWGModelDecoder
null
.setDefaultModelReference
in interface ILcdDWGModelDecoder
public ILcdModelReference getDefaultModelReference()
ILcdDWGModelDecoder
getDefaultModelReference
in interface ILcdDWGModelDecoder
public void setDecodeInvisibleObjects(boolean aDecodeInvisibleObjects)
ILcdDWGModelDecoder
false
.setDecodeInvisibleObjects
in interface ILcdDWGModelDecoder
public boolean isDecodeInvisibleObjects()
ILcdDWGModelDecoder
isDecodeInvisibleObjects
in interface ILcdDWGModelDecoder
public void setDecodeInvisibleLayers(boolean aDecodeInvisibleLayers)
ILcdDWGModelDecoder
false
.setDecodeInvisibleLayers
in interface ILcdDWGModelDecoder
public boolean isDecodeInvisibleLayers()
ILcdDWGModelDecoder
isDecodeInvisibleLayers
in interface ILcdDWGModelDecoder
public void setDecodeFrozenLayers(boolean aDecodeFrozenLayers)
ILcdDWGModelDecoder
false
.setDecodeFrozenLayers
in interface ILcdDWGModelDecoder
public boolean isDecodeFrozenLayers()
ILcdDWGModelDecoder
isDecodeFrozenLayers
in interface ILcdDWGModelDecoder
public void resetExtendedEntityTypeSelection()
ILcdDWGModelDecoder
resetExtendedEntityTypeSelection
in interface ILcdDWGModelDecoder
ILcdDWGModelDecoder.clearExtendedEntityTypeSelection()
public void clearExtendedEntityTypeSelection()
ILcdDWGModelDecoder
clearExtendedEntityTypeSelection
in interface ILcdDWGModelDecoder
ILcdDWGModelDecoder.resetExtendedEntityTypeSelection()
,
ILcdDWGModelDecoder.addExtendedEntityType(int)
public void setExtendedEntityTypeSelection(int[] aTypes)
ILcdDWGModelDecoder
setExtendedEntityTypeSelection
in interface ILcdDWGModelDecoder
aTypes
- a list of extended entity types.TLcdDWGExtendedEntityData
public void addExtendedEntityType(int aType)
ILcdDWGModelDecoder
addExtendedEntityType
in interface ILcdDWGModelDecoder
aType
- an extended entity type.TLcdDWGExtendedEntityData
public void resetExtendedEntityStringSelection()
ILcdDWGModelDecoder
resetExtendedEntityStringSelection
in interface ILcdDWGModelDecoder
ILcdDWGModelDecoder.clearExtendedEntityStringSelection()
public void clearExtendedEntityStringSelection()
ILcdDWGModelDecoder
clearExtendedEntityStringSelection
in interface ILcdDWGModelDecoder
ILcdDWGModelDecoder.resetExtendedEntityStringSelection()
,
ILcdDWGModelDecoder.addExtendedEntityString(String)
public void setExtendedEntityStringSelection(String[] aStringPrefixes)
ILcdDWGModelDecoder
setExtendedEntityStringSelection
in interface ILcdDWGModelDecoder
aStringPrefixes
- a list of string prefixes.public void addExtendedEntityString(String aStringPrefix)
ILcdDWGModelDecoder
addExtendedEntityString
in interface ILcdDWGModelDecoder
aStringPrefix
- a list of string prefixes.public String getDisplayName()
ILcdModelDecoder
ILcdModelDecoder
.getDisplayName
in interface ILcdModelDecoder
ILcdModelDecoder
.public boolean canDecodeSource(String s)
ILcdModelDecoder
true
for a source name while decode
throws an exception for that same source name.
For performance reasons, we strongly recommend that this will only be a simple test. For example: check the file extension of a file, but not that the file exists or contains expected content.
canDecodeSource
in interface ILcdModelDecoder
s
- the data source to be verified; typically a file name or a URL.true
if this decoder can likely decode the data specified by the source name, false
otherwise.ILcdModelDecoder.decode(String)
,
ILcdModelDecoder.decodeModelMetadata(String)
public ILcdModel decode(String s) throws IOException
ILcdModelDecoder
decode
in interface ILcdModelDecoder
s
- the data source to be decoded; typically a file name or a URL.null
is allowed, implementors are advised to throw an error instead.IOException
- for any exceptions caused by IO problems or invalid data. Since decoding invalid data almost
always results in RunTimeExceptions (NullPointerException, IndexOutOfBoundsException,
IllegalArgumentException, ...) on unexpected places, implementations are advised to catch
RuntimeExceptions in their decode() method, and wrap them into an IOException, as illustrated
in the code snippet below.
public ILcdModel decode( String aSourceName ) throws IOException {
try (InputStream input = fInputStreamFactory.createInputStream(aSourceName)) {
// Perform decoding ...
} catch (RuntimeException e) {
throw new IOException(e);
}
}
InterruptedIOException
- When the thread on which this method is called is interrupted: it is recommended to stop the decoding
and throw an InterruptedIOException
.
This same exception can also be used if the decoder shows UI to the user, and the user cancels the decoding
through the UI.ILcdModelDecoder.canDecodeSource(String)