Revision 10679 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/SimpleLabelingStrategy.java
SimpleLabelingStrategy.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.1 2007-03-09 08:33:43 jaume |
|
46 |
* Revision 1.2 2007-03-09 11:20:57 jaume |
|
47 |
* Advanced symbology (start committing) |
|
48 |
* |
|
49 |
* Revision 1.1 2007/03/09 08:33:43 jaume |
|
47 | 50 |
* *** empty log message *** |
48 | 51 |
* |
49 | 52 |
* Revision 1.1.2.5 2007/02/21 07:34:08 jaume |
... | ... | |
73 | 76 |
import java.util.logging.Level; |
74 | 77 |
import java.util.logging.Logger; |
75 | 78 |
|
76 |
import com.iver.cit.gvsig.fmap.DriverException; |
|
79 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
80 |
import com.hardcode.gdbms.engine.data.driver.DriverException; |
|
81 |
import com.iver.cit.gvsig.exceptions.expansionfile.ExpansionFileReadException; |
|
82 |
import com.iver.cit.gvsig.exceptions.visitors.VisitorException; |
|
77 | 83 |
import com.iver.cit.gvsig.fmap.ViewPort; |
78 |
import com.iver.cit.gvsig.fmap.core.FPoint2D; |
|
79 | 84 |
import com.iver.cit.gvsig.fmap.core.FShape; |
80 | 85 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
81 | 86 |
import com.iver.cit.gvsig.fmap.core.TextPath; |
82 | 87 |
import com.iver.cit.gvsig.fmap.core.symbols.ITextSymbol; |
83 |
import com.iver.cit.gvsig.fmap.core.symbols.SimpleTextSymbol; |
|
84 | 88 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
85 | 89 |
import com.iver.cit.gvsig.fmap.layers.FBitSet; |
86 | 90 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
... | ... | |
102 | 106 |
private IZoomConstraints zoomConstraints; |
103 | 107 |
private Hashtable textPaths = new Hashtable(), texts = new Hashtable(); |
104 | 108 |
|
105 |
protected SimpleLabelingStrategy(FLayer layer) throws DriverException { |
|
109 |
protected SimpleLabelingStrategy(FLayer layer) throws ReadDriverException {
|
|
106 | 110 |
FLyrVect l = (FLyrVect) layer; |
107 | 111 |
this.layer = l; |
108 | 112 |
if (layer instanceof FLyrVect) { |
... | ... | |
121 | 125 |
|
122 | 126 |
public void setLabelingMethod(ILabelingMethod method) {} |
123 | 127 |
|
124 |
public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, Cancellable cancel) throws DriverException { |
|
128 |
public void draw(BufferedImage image, |
|
129 |
Graphics2D g, ViewPort viewPort, Cancellable cancel) |
|
130 |
throws ReadDriverException { |
|
125 | 131 |
Rectangle2D theExtent = viewPort.getAdjustedExtent(); |
126 | 132 |
|
127 | 133 |
if (zoomConstraints != null) { |
... | ... | |
130 | 136 |
scale > zoomConstraints.getMaxScale()) |
131 | 137 |
return; |
132 | 138 |
} |
133 |
FBitSet bs = layer.queryByRect(theExtent); |
|
134 |
LabelClass lc = method.getDefaultLabelClass(); |
|
139 |
FBitSet bs; |
|
140 |
int i = -1; |
|
141 |
try { |
|
142 |
bs = layer.queryByRect(theExtent); |
|
143 |
LabelClass lc = method.getDefaultLabelClass(); |
|
135 | 144 |
|
136 |
ReadableVectorial rv = layer.getSource(); |
|
137 |
SelectableDataSource sds = rv.getRecordset(); |
|
145 |
ReadableVectorial rv = layer.getSource();
|
|
146 |
SelectableDataSource sds = rv.getRecordset();
|
|
138 | 147 |
|
139 |
ITextSymbol sym = lc.getLabelSymbol(); |
|
140 |
for(int i=bs.nextSetBit(0); i>=0 && !cancel.isCanceled(); i=bs.nextSetBit(i+1)) { |
|
141 |
IGeometry geom; |
|
142 |
try { |
|
148 |
ITextSymbol sym = lc.getLabelSymbol(); |
|
149 |
for(i=bs.nextSetBit(0); i>=0 && !cancel.isCanceled(); i=bs.nextSetBit(i+1)) { |
|
150 |
IGeometry geom; |
|
143 | 151 |
Integer index = new Integer(i); |
144 | 152 |
|
145 | 153 |
String text = getText(index, sds); |
... | ... | |
152 | 160 |
sym.draw(g, at, shp[i]); |
153 | 161 |
} |
154 | 162 |
|
155 |
} catch (DriverIOException e) {
|
|
156 |
logger.log(Level.SEVERE, "Draw label for "+i+"th shape of "+layer.getName());
|
|
157 |
|
|
158 |
} catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
|
|
159 |
logger.log(Level.SEVERE, "Getting label text for "+i+"th shape of "+layer.getName());
|
|
160 |
|
|
161 |
}
|
|
162 |
|
|
163 |
} |
|
164 |
} catch (ExpansionFileReadException e) {
|
|
165 |
// TODO Auto-generated catch block |
|
166 |
logger.log(Level.SEVERE, e.getMessage());
|
|
167 |
} catch (ReadDriverException e) {
|
|
168 |
logger.log(Level.SEVERE, "Getting label text for "+i+"th shape of "+layer.getName()); |
|
169 |
} catch (VisitorException e) {
|
|
170 |
logger.log(Level.SEVERE, "Getting label text for "+i+"th shape of "+layer.getName()); |
|
163 | 171 |
} |
164 | 172 |
} |
165 | 173 |
|
166 |
private String getText(Integer index, SelectableDataSource sds) throws com.hardcode.gdbms.engine.data.driver.DriverException {
|
|
174 |
private String getText(Integer index, SelectableDataSource sds) throws ReadDriverException {
|
|
167 | 175 |
String text = (String) texts.get(index); |
168 | 176 |
if (text == null) { |
169 | 177 |
String expr = method.getDefaultLabelClass().getLabelExpression(); |
Also available in: Unified diff