Revision 10436 branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/LabelingFactory.java
LabelingFactory.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.1.2.3 2007-02-12 15:15:20 jaume |
|
46 |
* Revision 1.1.2.4 2007-02-21 07:34:08 jaume |
|
47 |
* labeling starts working |
|
48 |
* |
|
49 |
* Revision 1.1.2.3 2007/02/12 15:15:20 jaume |
|
47 | 50 |
* refactored interval legend and added graduated symbol legend |
48 | 51 |
* |
49 | 52 |
* Revision 1.1.2.2 2007/02/09 07:47:05 jaume |
... | ... | |
73 | 76 |
public class LabelingFactory { |
74 | 77 |
private static Logger logger = Logger.getLogger(SymbologyFactory.class.getName()); |
75 | 78 |
|
76 |
|
|
79 |
/** |
|
80 |
* Instantiates an object from an instance of XMLEntity. The XMLEntity |
|
81 |
* must follow the XMLEntity contract in IPersistence. It at least must |
|
82 |
* contain a className that allow create objects via instrospection. It |
|
83 |
* also should have the set of attributes that the instantiated object's |
|
84 |
* setXMLEntity(XMLEntity) method expects. |
|
85 |
* @param xml |
|
86 |
* @return |
|
87 |
*/ |
|
77 | 88 |
private static Object createFromXML(XMLEntity xml) { |
78 | 89 |
String className = null; |
79 | 90 |
try { |
... | ... | |
111 | 122 |
return obj; |
112 | 123 |
} |
113 | 124 |
|
125 |
/** |
|
126 |
* Creates a new instance of a ILabelingStrategy from an XMLEntity. |
|
127 |
* @param xml |
|
128 |
* @return ILabelingStrategy |
|
129 |
*/ |
|
114 | 130 |
public static ILabelingStrategy createStrategyFromXML(XMLEntity xml) { |
115 | 131 |
return (ILabelingStrategy) createFromXML(xml); |
116 | 132 |
} |
117 | 133 |
|
134 |
/** |
|
135 |
* Creates a new instance of ILabelingMethod from an XMLEntity. |
|
136 |
* @param xml |
|
137 |
* @return ILabelingMethod |
|
138 |
*/ |
|
118 | 139 |
public static ILabelingMethod createMethodFromXML(XMLEntity xml) { |
119 | 140 |
return (ILabelingMethod) createFromXML(xml); |
120 | 141 |
} |
121 | 142 |
|
143 |
/** |
|
144 |
* Creates a default labeling strategy from an XMLEntity. |
|
145 |
* @param layer |
|
146 |
* @return an instance of DefaultStrategy |
|
147 |
* @throws DriverException |
|
148 |
*/ |
|
122 | 149 |
public static ILabelingStrategy createDefaultStrategy(FLayer layer) throws DriverException { |
123 | 150 |
return new DefaultLabelingStrategy(layer); |
124 | 151 |
} |
125 | 152 |
|
153 |
/** |
|
154 |
* Given a layer, a labeling method, a label placements constraints, and a label |
|
155 |
* zoom constraints it will figure out the best ILabelingStrategy that meets all |
|
156 |
* the needs. |
|
157 |
* @param layer, the target layer |
|
158 |
* @param method, the desired methods |
|
159 |
* @param placement, the desired placement constraints |
|
160 |
* @param zoom, the desired zoom constraints |
|
161 |
* @return ILabelingStrategy |
|
162 |
* @throws DriverException |
|
163 |
*/ |
|
126 | 164 |
public static ILabelingStrategy createStrategy(FLayer layer, ILabelingMethod method, IPlacementConstraints placement, IZoomConstraints zoom) throws DriverException { |
127 | 165 |
if (method == null && placement == null && zoom == null) |
128 | 166 |
return createDefaultStrategy(layer); |
... | ... | |
133 | 171 |
*/ |
134 | 172 |
} |
135 | 173 |
|
174 |
/** |
|
175 |
* Creates a new instance of placement constraints from a vector layer. The |
|
176 |
* placement constraints are created according the layer shape type. |
|
177 |
* @param layerDest |
|
178 |
* @return |
|
179 |
* @throws DriverException |
|
180 |
*/ |
|
136 | 181 |
public static IPlacementConstraints createPlacementConstraints(FLyrVect layerDest) throws DriverException { |
137 | 182 |
int shapeType = layerDest.getShapeType(); |
138 | 183 |
switch (shapeType) { |
139 | 184 |
case FShape.LINE: |
140 | 185 |
return new LinePlacementConstraints(); |
141 | 186 |
case FShape.POLYGON: |
187 |
return new PolygonPlacementConstraints(); |
|
142 | 188 |
case FShape.POINT: |
189 |
return new PointPlacementConstraints(); |
|
143 | 190 |
} |
144 | 191 |
throw new Error("Shape type not yet supported"); |
145 | 192 |
} |
Also available in: Unified diff