Revision 29131 trunk/extensions/extSymbology/src/org/gvsig/symbology/fmap/labeling/PlacementManager.java
PlacementManager.java | ||
---|---|---|
61 | 61 |
import com.iver.utiles.XMLEntity; |
62 | 62 |
|
63 | 63 |
/** |
64 |
*
|
|
64 |
* |
|
65 | 65 |
* PlacementManager.java |
66 | 66 |
* |
67 |
*
|
|
67 |
* |
|
68 | 68 |
* @author jaume dominguez faus - jaume.dominguez@iver.es Jan 3, 2008 |
69 | 69 |
* |
70 | 70 |
*/ |
... | ... | |
72 | 72 |
private static Logger logger = Logger.getLogger(PlacementManager.class.getName()); |
73 | 73 |
private static ArrayList<Class<?>> installedLabelPlacements = new ArrayList<Class<?>>(); |
74 | 74 |
private static ArrayList<ILabelPlacement> availableLabelPlacements; |
75 |
private static final CannotPlaceLabel cantPlaceLabel = new CannotPlaceLabel();
|
|
75 |
private static final CannotPlaceLabel cantPlaceLabel = new CannotPlaceLabel(); |
|
76 | 76 |
private PlacementManager() {} |
77 |
|
|
77 |
|
|
78 | 78 |
public static ILabelPlacement getPlacement(IPlacementConstraints placementConstraints, int shapeType) { |
79 |
|
|
79 |
|
|
80 | 80 |
ArrayList<ILabelPlacement> suitablePlacements = new ArrayList<ILabelPlacement>(); |
81 | 81 |
if (placementConstraints.getClass().equals(MultiShapePlacementConstraints.class)) { |
82 | 82 |
MultiShapePlacementConstraints msp = (MultiShapePlacementConstraints) placementConstraints; |
... | ... | |
93 | 93 |
suitablePlacements.add(placement); |
94 | 94 |
} |
95 | 95 |
} |
96 |
|
|
96 |
|
|
97 | 97 |
if (suitablePlacements.size() == 0) |
98 | 98 |
return cantPlaceLabel; |
99 | 99 |
else if (suitablePlacements.size() == 1) |
... | ... | |
108 | 108 |
} |
109 | 109 |
|
110 | 110 |
public static void addLabelPlacement(Class<?> labelPlacementClass) { |
111 |
// if (!labelPlacementClass.isInstance(ILabelPlacement.class))
|
|
111 |
// if (!labelPlacementClass.isInstance(ILabelPlacement.class)) |
|
112 | 112 |
// throw new IllegalArgumentException( |
113 |
// labelPlacementClass.getName()+" is not an valid label placement algorithm.");
|
|
113 |
// labelPlacementClass.getName()+" is not an valid label placement algorithm."); |
|
114 | 114 |
installedLabelPlacements.add(labelPlacementClass); |
115 |
|
|
115 |
|
|
116 | 116 |
// invalidate current list of available placements |
117 | 117 |
if (availableLabelPlacements != null) |
118 | 118 |
availableLabelPlacements.clear(); |
119 | 119 |
availableLabelPlacements = null; |
120 | 120 |
} |
121 |
|
|
121 |
|
|
122 | 122 |
private static ArrayList<ILabelPlacement> getAvailablePlacements() { |
123 | 123 |
if (availableLabelPlacements == null) { |
124 | 124 |
availableLabelPlacements = new ArrayList<ILabelPlacement>(installedLabelPlacements.size()); |
... | ... | |
135 | 135 |
|
136 | 136 |
return availableLabelPlacements; |
137 | 137 |
} |
138 |
|
|
139 | 138 |
|
139 |
|
|
140 | 140 |
/** |
141 | 141 |
* Creates a new instance of placement constraints from a vector layer. The |
142 | 142 |
* placement constraints are created according the layer shape type. |
... | ... | |
145 | 145 |
* @throws DriverException |
146 | 146 |
*/ |
147 | 147 |
public static IPlacementConstraints createPlacementConstraints(int shapeType) { |
148 |
switch (shapeType) { |
|
148 |
switch (shapeType % FShape.Z) {
|
|
149 | 149 |
case FShape.LINE: |
150 | 150 |
return new LinePlacementConstraints(); |
151 | 151 |
case FShape.POLYGON: |
Also available in: Unified diff