Revision 25802 trunk/extensions/extSymbology/src/org/gvsig/symbology/fmap/labeling/GeneralLabelingStrategy.java
GeneralLabelingStrategy.java | ||
---|---|---|
108 | 108 |
package org.gvsig.symbology.fmap.labeling; |
109 | 109 |
|
110 | 110 |
import java.awt.Graphics2D; |
111 |
import java.awt.geom.NoninvertibleTransformException; |
|
112 |
import java.awt.geom.PathIterator; |
|
113 |
import java.awt.geom.Point2D; |
|
114 | 111 |
import java.awt.geom.Rectangle2D; |
115 | 112 |
import java.awt.image.BufferedImage; |
116 |
import java.io.CharArrayReader; |
|
117 | 113 |
import java.io.StringReader; |
118 | 114 |
import java.text.NumberFormat; |
119 | 115 |
import java.util.ArrayList; |
... | ... | |
126 | 122 |
import org.cresques.cts.ICoordTrans; |
127 | 123 |
import org.gvsig.symbology.fmap.labeling.parse.LabelExpressionParser; |
128 | 124 |
import org.gvsig.symbology.fmap.labeling.parse.ParseException; |
129 |
import org.gvsig.symbology.fmap.labeling.placements.AbstractPlacementConstraints; |
|
130 | 125 |
import org.gvsig.symbology.fmap.labeling.placements.ILabelPlacement; |
131 | 126 |
import org.gvsig.symbology.fmap.labeling.placements.LinePlacementConstraints; |
132 | 127 |
import org.gvsig.symbology.fmap.labeling.placements.MultiShapePlacementConstraints; |
133 | 128 |
import org.gvsig.symbology.fmap.labeling.placements.PointPlacementConstraints; |
134 | 129 |
import org.gvsig.symbology.fmap.labeling.placements.PolygonPlacementConstraints; |
135 |
import org.gvsig.symbology.fmap.labeling.placements.PolygonPlacementOnCentroid; |
|
136 |
import org.gvsig.symbology.fmap.labeling.placements.PolygonPlacementParallel; |
|
137 | 130 |
import org.gvsig.symbology.fmap.labeling.placements.RemoveDuplicatesComparator; |
138 | 131 |
import org.gvsig.symbology.fmap.rendering.filter.operations.Expression; |
139 | 132 |
import org.gvsig.symbology.fmap.rendering.filter.operations.ExpressionException; |
... | ... | |
148 | 141 |
import com.iver.cit.gvsig.fmap.core.CartographicSupportToolkit; |
149 | 142 |
import com.iver.cit.gvsig.fmap.core.FNullGeometry; |
150 | 143 |
import com.iver.cit.gvsig.fmap.core.FShape; |
151 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
|
152 | 144 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
153 | 145 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
154 |
import com.iver.cit.gvsig.fmap.core.SymbologyFactory; |
|
155 |
import com.iver.cit.gvsig.fmap.core.symbols.ITextSymbol; |
|
156 | 146 |
import com.iver.cit.gvsig.fmap.core.v02.FConstant; |
157 |
import com.iver.cit.gvsig.fmap.core.v02.FConverter; |
|
158 | 147 |
import com.iver.cit.gvsig.fmap.drivers.IFeatureIterator; |
159 | 148 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
160 | 149 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
... | ... | |
440 | 429 |
for (i = 0; !cancel.isCanceled() && i < llm.size(); i++) { |
441 | 430 |
LabelLocationMetrics labelMetrics = llm.get(i); |
442 | 431 |
|
432 |
lc.getTextSymbol().setFontSize(sizeAfter * FConstant.FONT_HEIGHT_SCALE_FACTOR); |
|
443 | 433 |
if (bLabelsReallocatable) { |
444 | 434 |
if (!isOverlapping(bi, lc.getShape(labelMetrics))) { |
445 |
lc.getTextSymbol().setFontSize(sizeAfter * FConstant.FONT_HEIGHT_SCALE_FACTOR); |
|
446 | 435 |
if(!getPlacementConstraints().isFollowingLine()){ |
447 | 436 |
lc.draw(g, labelMetrics, (FShape) geom.getInternalShape()); |
448 | 437 |
} |
... | ... | |
457 | 446 |
return true; |
458 | 447 |
} |
459 | 448 |
} else { |
460 |
lc.getTextSymbol().setFontSize(sizeAfter * FConstant.FONT_HEIGHT_SCALE_FACTOR); |
|
461 | 449 |
if(!getPlacementConstraints().isFollowingLine()){ |
462 | 450 |
lc.draw(g, labelMetrics, null); |
463 | 451 |
} |
... | ... | |
559 | 547 |
private boolean isOverlapping(BufferedImage bi, FShape labelShape) { |
560 | 548 |
|
561 | 549 |
Rectangle2D rPixels = labelShape.getBounds2D(); |
562 |
for (int i= (int) rPixels.getX(); i<rPixels.getMaxX(); i++){ |
|
563 |
for (int j= (int) rPixels.getY(); j<rPixels.getMaxY(); j++){ |
|
564 |
if (!labelShape.contains(i, j)) { |
|
550 |
for (int i= (int) rPixels.getX(); i<=rPixels.getMaxX(); i++){ |
|
551 |
for (int j= (int) rPixels.getY(); j<=rPixels.getMaxY(); j++){ |
|
552 |
|
|
553 |
if (!labelShape.contains(i, j) // contains seems to don't detect points placed in the rectangle boundaries |
|
554 |
&& !labelShape.intersects(i, j, i, j)) { |
|
565 | 555 |
continue; |
566 | 556 |
} |
567 | 557 |
|
Also available in: Unified diff