Revision 11138
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/PolygonPlacementConstraints.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.3 2007-04-02 16:34:56 jaume |
|
46 |
* Revision 1.4 2007-04-11 16:01:08 jaume |
|
47 |
* maybe a label placer refactor |
|
48 |
* |
|
49 |
* Revision 1.3 2007/04/02 16:34:56 jaume |
|
47 | 50 |
* Styled labeling (start commiting) |
48 | 51 |
* |
49 | 52 |
* Revision 1.2 2007/03/09 08:33:43 jaume |
... | ... | |
56 | 59 |
*/ |
57 | 60 |
package com.iver.cit.gvsig.fmap.rendering.styling; |
58 | 61 |
|
62 |
import java.awt.geom.AffineTransform; |
|
63 |
|
|
59 | 64 |
import org.cresques.px.gml.MultiPolygon; |
60 | 65 |
|
61 | 66 |
import com.iver.cit.gvsig.fmap.core.FShape; |
62 | 67 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
63 | 68 |
import com.iver.cit.gvsig.fmap.core.symbols.ITextSymbol; |
64 |
|
|
69 |
/** |
|
70 |
* |
|
71 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
|
72 |
* |
|
73 |
*/ |
|
65 | 74 |
public class PolygonPlacementConstraints extends AbstractPlacementConstraints { |
66 | 75 |
|
67 | 76 |
public FShape[] getLocationsFor(IGeometry geom, FShape labelShape, MultiPolygon exclusionZone) { |
... | ... | |
69 | 78 |
throw new Error("Not yet implemented!"); |
70 | 79 |
|
71 | 80 |
} |
81 |
|
|
82 |
public void placeLabel(IGeometry geom, LabelClass lc, MultiPolygon exclusionZone, AffineTransform transform) { |
|
83 |
// TODO Implement it |
|
84 |
throw new Error("Not yet implemented!"); |
|
85 |
|
|
86 |
} |
|
72 | 87 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/LinePlacementConstraints.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.3 2007-04-02 16:34:56 jaume |
|
46 |
* Revision 1.4 2007-04-11 16:01:08 jaume |
|
47 |
* maybe a label placer refactor |
|
48 |
* |
|
49 |
* Revision 1.3 2007/04/02 16:34:56 jaume |
|
47 | 50 |
* Styled labeling (start commiting) |
48 | 51 |
* |
49 | 52 |
* Revision 1.2 2007/03/09 08:33:43 jaume |
... | ... | |
56 | 59 |
*/ |
57 | 60 |
package com.iver.cit.gvsig.fmap.rendering.styling; |
58 | 61 |
|
62 |
import java.awt.Point; |
|
63 |
import java.awt.geom.AffineTransform; |
|
64 |
|
|
59 | 65 |
import org.cresques.px.gml.MultiPolygon; |
60 | 66 |
|
61 | 67 |
import com.iver.cit.gvsig.fmap.core.FShape; |
62 | 68 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
63 |
import com.iver.cit.gvsig.fmap.core.symbols.ITextSymbol; |
|
64 |
|
|
69 |
/** |
|
70 |
* |
|
71 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
|
72 |
* |
|
73 |
*/ |
|
65 | 74 |
public class LinePlacementConstraints extends AbstractPlacementConstraints { |
66 | 75 |
public FShape[] getLocationsFor(IGeometry geom, FShape labelShape, MultiPolygon exclusionZone) { |
67 | 76 |
return new FShape[] { (FShape) geom.getInternalShape() }; |
68 | 77 |
} |
78 |
public void placeLabel(IGeometry geom, LabelClass labelShape, MultiPolygon exclusionZone, AffineTransform at) { |
|
79 |
Point startingPoint; |
|
80 |
if (isFollowingLine()) { |
|
81 |
throw new Error("following line option not yet implemented"); |
|
82 |
// 1. create text path |
|
83 |
// 2. convert text symbol to SmartTextSymbol if need |
|
69 | 84 |
|
85 |
} else { |
|
86 |
if (isAtTheBeginingOfLine()) { |
|
87 |
|
|
88 |
} else if (isAtTheEndOfLine()) { |
|
89 |
|
|
90 |
} else { |
|
91 |
|
|
92 |
} |
|
93 |
} |
|
94 |
|
|
95 |
/* |
|
96 |
* Now we have the starting point for the text, we will apply the |
|
97 |
* offset to place the text either over, under or above the line |
|
98 |
*/ |
|
99 |
if (exclusionZone == null) { |
|
100 |
// no check for overlapping is needed |
|
101 |
|
|
102 |
if (isBellowTheLine()) { |
|
103 |
// Offset to be on bellow of the line. |
|
104 |
} else if (isAboveTheLine()) { |
|
105 |
// Offset to be above the line (inverse offset to under the line) |
|
106 |
|
|
107 |
} else { |
|
108 |
// No offset. |
|
109 |
} |
|
110 |
|
|
111 |
/* |
|
112 |
* Now, we'll need to see who is defining the orientation |
|
113 |
* either the line or the page. |
|
114 |
*/ |
|
115 |
if (isPageOriented()) { |
|
116 |
|
|
117 |
} else { |
|
118 |
// The line defines the orientation. |
|
119 |
} |
|
120 |
|
|
121 |
if (isParallel()) { |
|
122 |
// get the line theta and apply it |
|
123 |
} else if (isPerpendicular()) { |
|
124 |
// get the line theta with 90 degrees |
|
125 |
} |
|
126 |
|
|
127 |
} else { |
|
128 |
throw new Error("overlapping detection option not yet implemented"); |
|
129 |
} |
|
130 |
} |
|
131 |
|
|
70 | 132 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/IPlacementConstraints.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.3 2007-04-02 16:34:56 jaume |
|
46 |
* Revision 1.4 2007-04-11 16:01:08 jaume |
|
47 |
* maybe a label placer refactor |
|
48 |
* |
|
49 |
* Revision 1.3 2007/04/02 16:34:56 jaume |
|
47 | 50 |
* Styled labeling (start commiting) |
48 | 51 |
* |
49 | 52 |
* Revision 1.2 2007/03/09 08:33:43 jaume |
... | ... | |
60 | 63 |
|
61 | 64 |
package com.iver.cit.gvsig.fmap.rendering.styling; |
62 | 65 |
|
66 |
import java.awt.geom.AffineTransform; |
|
67 |
|
|
63 | 68 |
import org.cresques.px.gml.MultiPolygon; |
64 | 69 |
|
65 | 70 |
import com.iver.cit.gvsig.fmap.core.FShape; |
... | ... | |
72 | 77 |
public interface IPlacementConstraints { |
73 | 78 |
|
74 | 79 |
// constants regarding label duplication |
75 |
public static final int REMOVE_DUPLICATE_LABELS = 2;
|
|
76 |
public static final int ONE_LABEL_PER_FEATURE = 3;
|
|
77 |
public static final int ONE_LABEL_PER_FEATURE_PART = 4;
|
|
80 |
public static final int REMOVE_DUPLICATE_LABELS = 2;
|
|
81 |
public static final int ONE_LABEL_PER_FEATURE = 3;
|
|
82 |
public static final int ONE_LABEL_PER_FEATURE_PART = 4;
|
|
78 | 83 |
|
79 | 84 |
// constants regarding point settings |
80 |
public static final int OFFSET_HORIZONTALY_AROUND_THE_POINT = 5; |
|
81 |
public static final int ON_TOP_OF_THE_POINT = 6;
|
|
82 |
public static final int AT_SPECIFIED_ANGLE = 7;
|
|
83 |
public static final int AT_ANGLE_SPECIFIED_BY_A_FIELD = 8;
|
|
85 |
public static final int OFFSET_HORIZONTALY_AROUND_THE_POINT = 5;
|
|
86 |
public static final int ON_TOP_OF_THE_POINT = 6;
|
|
87 |
public static final int AT_SPECIFIED_ANGLE = 7;
|
|
88 |
public static final int AT_ANGLE_SPECIFIED_BY_A_FIELD = 8;
|
|
84 | 89 |
|
85 | 90 |
// constants regarding polygon settings (also apply for lines) |
86 |
public static final int HORIZONTAL = 9;
|
|
87 |
public static final int PARALLEL = 10;
|
|
91 |
public static final int HORIZONTAL = 9;
|
|
92 |
public static final int PARALLEL = 10;
|
|
88 | 93 |
|
89 | 94 |
// constants regarding line settings |
90 |
public static final int FOLLOWING_LINE = 11;
|
|
91 |
public static final int PERPENDICULAR = 12;
|
|
95 |
public static final int FOLLOWING_LINE = 11;
|
|
96 |
public static final int PERPENDICULAR = 12;
|
|
92 | 97 |
|
93 | 98 |
// constants regarding label position along the line |
94 |
public static final int ABOVE_THE_LINE = 1000; |
|
95 |
public static final int ON_THE_LINE = 1100; |
|
96 |
public static final int BELLOW_THE_LINE = 1200; |
|
99 |
public static final int ABOVE_THE_LINE = 1000; |
|
100 |
public static final int ON_THE_LINE = 1100; |
|
101 |
public static final int BELLOW_THE_LINE = 1200; |
|
102 |
public static final int AT_THE_BEGINING = 10000; |
|
103 |
public static final int AT_THE_END = 20000; |
|
104 |
public static final int PAGE_ORIENTED = 100000; |
|
105 |
public static final int LINE_ORIENTED = 200000; |
|
97 | 106 |
|
98 | 107 |
public abstract void setDuplicateLabelsMode(int mode); |
99 | 108 |
|
... | ... | |
110 | 119 |
public abstract int getDuplicateLabelsMode(); |
111 | 120 |
|
112 | 121 |
/** |
122 |
* Tells if the place mode selected is to put the label over the <b>POINT</b> |
|
123 |
* @return boolean |
|
124 |
*/ |
|
125 |
public abstract boolean isOnTopOfThePoint(); |
|
126 |
|
|
127 |
public abstract boolean isAtTheBeginingOfLine(); |
|
128 |
public abstract boolean isAtTheEndOfLine(); |
|
129 |
public abstract boolean isBellowTheLine(); |
|
130 |
public abstract boolean isAboveTheLine(); |
|
131 |
public abstract boolean isPageOriented(); |
|
132 |
public abstract boolean isLineOriented(); |
|
133 |
|
|
134 |
|
|
135 |
/** |
|
113 | 136 |
* Calculates the position where the next label will be placed. Or null |
114 | 137 |
* if the label does not have to be placed. |
115 | 138 |
* |
... | ... | |
121 | 144 |
public abstract FShape[] getLocationsFor(IGeometry geom, FShape labelShape, |
122 | 145 |
MultiPolygon exclusionZone); |
123 | 146 |
|
147 |
public abstract void placeLabel(IGeometry geom, LabelClass lc, MultiPolygon exclusionZone, AffineTransform transform); |
|
148 |
|
|
124 | 149 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/PointPlacementConstraints.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.4 2007-04-05 16:07:13 jaume |
|
46 |
* Revision 1.5 2007-04-11 16:01:08 jaume |
|
47 |
* maybe a label placer refactor |
|
48 |
* |
|
49 |
* Revision 1.4 2007/04/05 16:07:13 jaume |
|
47 | 50 |
* Styled labeling stuff |
48 | 51 |
* |
49 | 52 |
* Revision 1.3 2007/04/02 16:34:56 jaume |
... | ... | |
68 | 71 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
69 | 72 |
/** |
70 | 73 |
* |
71 |
* @author jaume |
|
74 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
|
72 | 75 |
* |
73 | 76 |
*/ |
74 | 77 |
public class PointPlacementConstraints extends AbstractPlacementConstraints { |
75 | 78 |
|
76 | 79 |
public FShape[] getLocationsFor(IGeometry geom, FShape labelShape, MultiPolygon exclusionZone) { |
77 |
FPoint2D p = (FPoint2D) geom.getInternalShape(); |
|
78 |
FShape myShape = labelShape.cloneFShape(); |
|
79 |
myShape.transform(AffineTransform.getTranslateInstance(p.getX(), p.getY())); |
|
80 |
return new FShape[] { myShape }; |
|
80 |
if (isOnTopOfThePoint()) { |
|
81 |
FPoint2D p = (FPoint2D) geom.getInternalShape(); |
|
82 |
FShape myShape = labelShape.cloneFShape(); |
|
83 |
myShape.transform(AffineTransform.getTranslateInstance(p.getX(), p.getY())); |
|
84 |
return new FShape[] { myShape }; |
|
85 |
} else { |
|
86 |
throw new Error("Placement mode not yet implemented"); |
|
87 |
} |
|
81 | 88 |
} |
82 | 89 |
|
90 |
public void placeLabel(IGeometry geom, LabelClass lc, MultiPolygon exclusionZone, AffineTransform transform) { |
|
91 |
// TODO Implement it |
|
92 |
throw new Error("Not yet implemented!"); |
|
93 |
|
|
94 |
} |
|
83 | 95 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/AbstractPlacementConstraints.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.2 2007-03-09 08:33:43 jaume |
|
46 |
* Revision 1.3 2007-04-11 16:01:08 jaume |
|
47 |
* maybe a label placer refactor |
|
48 |
* |
|
49 |
* Revision 1.2 2007/03/09 08:33:43 jaume |
|
47 | 50 |
* *** empty log message *** |
48 | 51 |
* |
49 | 52 |
* Revision 1.1.2.2 2007/02/15 16:23:44 jaume |
... | ... | |
125 | 128 |
} |
126 | 129 |
|
127 | 130 |
public boolean isHorizontal() { |
128 |
return placementMode%100 == HORIZONTAL;
|
|
131 |
return placementMode % 100 == HORIZONTAL;
|
|
129 | 132 |
} |
130 | 133 |
|
131 | 134 |
public boolean isPerpendicular() { |
132 |
return placementMode%100 == PERPENDICULAR;
|
|
135 |
return placementMode % 100 == PERPENDICULAR;
|
|
133 | 136 |
} |
134 | 137 |
|
135 | 138 |
public boolean isFollowingLine() { |
136 |
return placementMode%100 == FOLLOWING_LINE;
|
|
139 |
return placementMode % 100 == FOLLOWING_LINE;
|
|
137 | 140 |
} |
138 | 141 |
|
139 | 142 |
public boolean isParallel() { |
140 |
return placementMode%100 == PARALLEL;
|
|
143 |
return placementMode % 100 == PARALLEL;
|
|
141 | 144 |
} |
142 | 145 |
|
143 | 146 |
public int getDuplicateLabelsMode() { |
144 | 147 |
return duplicateLabelsMode; |
145 | 148 |
} |
149 |
|
|
150 |
/** |
|
151 |
* Tells if the place mode selected is to put the label over the <b>POINT</b> |
|
152 |
* @return boolean |
|
153 |
*/ |
|
154 |
public boolean isOnTopOfThePoint() { |
|
155 |
return placementMode == ON_TOP_OF_THE_POINT; |
|
156 |
} |
|
157 |
|
|
158 |
public boolean isAtTheBeginingOfLine() { |
|
159 |
return placementMode / 10000 == 1; |
|
160 |
} |
|
161 |
|
|
162 |
public boolean isAtTheEndOfLine() { |
|
163 |
return placementMode / 10000 == 2; |
|
164 |
} |
|
165 |
|
|
166 |
public boolean isBellowTheLine() { |
|
167 |
return placementMode / 1000 == 12; |
|
168 |
} |
|
169 |
|
|
170 |
public boolean isAboveTheLine() { |
|
171 |
return placementMode / 100 == 10; |
|
172 |
} |
|
173 |
|
|
174 |
public boolean isPageOriented() { |
|
175 |
return placementMode / 100000 == 1; |
|
176 |
} |
|
177 |
|
|
178 |
public boolean isLineOriented() { |
|
179 |
return placementMode / 100000 == 2; |
|
180 |
} |
|
146 | 181 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/SimpleLabeling.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.5 2007-04-10 16:34:01 jaume |
|
46 |
* Revision 1.6 2007-04-11 16:01:08 jaume |
|
47 |
* maybe a label placer refactor |
|
48 |
* |
|
49 |
* Revision 1.5 2007/04/10 16:34:01 jaume |
|
47 | 50 |
* towards a styled labeling |
48 | 51 |
* |
49 | 52 |
* Revision 1.4 2007/04/02 16:34:56 jaume |
... | ... | |
84 | 87 |
package com.iver.cit.gvsig.fmap.rendering.styling; |
85 | 88 |
|
86 | 89 |
import java.awt.Color; |
90 |
import java.awt.Font; |
|
87 | 91 |
import java.awt.Graphics2D; |
88 | 92 |
import java.awt.geom.AffineTransform; |
89 | 93 |
import java.awt.geom.Rectangle2D; |
... | ... | |
174 | 178 |
IGeometry geom; |
175 | 179 |
Integer index = new Integer(i); |
176 | 180 |
|
177 |
String[] texts = getText(index, sds); |
|
178 | 181 |
geom = rv.getShape(i); |
179 | 182 |
FShape labelShape = lc.getShape(g, geom); |
180 |
if (labelShape != null) { |
|
183 |
|
|
184 |
// refactor |
|
185 |
// if (labelShape is big enough) |
|
186 |
{ |
|
187 |
String[] texts = getText(index, sds); |
|
188 |
|
|
189 |
placementConstraints.placeLabel(geom, lc, null, viewPort.getAffineTransform()); |
|
190 |
} |
|
191 |
|
|
192 |
/* |
|
193 |
String[] texts = getText(index, sds); |
|
194 |
|
|
195 |
if (labelShape != null) { |
|
181 | 196 |
FShape[] places = placementConstraints.getLocationsFor( |
182 | 197 |
geom, labelShape, |
183 | 198 |
null); |
... | ... | |
185 | 200 |
for (int j = 0; j < places.length; j++) { |
186 | 201 |
places[j].transform(viewPort.getAffineTransform()); |
187 | 202 |
lc.drawInsideRectangle(g, places[j].getBounds(), texts); |
188 |
g.setColor(Color.BLUE); |
|
189 |
g.draw(places[j]); |
|
190 |
|
|
191 | 203 |
} |
192 |
} |
|
204 |
}*/
|
|
193 | 205 |
} |
194 | 206 |
} catch (ExpansionFileReadException e) { |
195 |
// TODO Auto-generated catch block |
|
196 | 207 |
logger.log(Level.SEVERE, e.getMessage()); |
197 | 208 |
} catch (ReadDriverException e) { |
198 | 209 |
logger.log(Level.SEVERE, "Getting label text for "+i+"th shape of "+layer.getName()); |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/LabelClass.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.5 2007-04-10 16:34:01 jaume |
|
46 |
* Revision 1.6 2007-04-11 16:01:08 jaume |
|
47 |
* maybe a label placer refactor |
|
48 |
* |
|
49 |
* Revision 1.5 2007/04/10 16:34:01 jaume |
|
47 | 50 |
* towards a styled labeling |
48 | 51 |
* |
49 | 52 |
* Revision 1.4 2007/04/05 16:07:14 jaume |
... | ... | |
77 | 80 |
*/ |
78 | 81 |
package com.iver.cit.gvsig.fmap.rendering.styling; |
79 | 82 |
|
83 |
import java.awt.Color; |
|
80 | 84 |
import java.awt.Graphics2D; |
81 | 85 |
import java.awt.Point; |
82 | 86 |
import java.awt.Rectangle; |
... | ... | |
160 | 164 |
public void drawInsideRectangle(Graphics2D graphics, Rectangle bounds, |
161 | 165 |
String[] texts) { |
162 | 166 |
if (labelStyle != null) { |
167 |
// apply the offset to the markerPoint |
|
168 |
|
|
169 |
graphics.setColor(Color.RED); |
|
170 |
graphics.draw(bounds); |
|
163 | 171 |
labelStyle.drawInsideRectangle(graphics, bounds); |
164 |
Point2D offset = new Point2D.Double(bounds.getMinX(), bounds |
|
165 |
.getMinY()); |
|
166 |
graphics.translate(offset.getX(), offset.getY()); |
|
172 |
|
|
167 | 173 |
for (int i = 0; i < texts.length; i++) { |
168 | 174 |
getLabelSymbol().setText(texts[i]); |
175 |
|
|
176 |
// textArea is the area for such text field in relative units |
|
169 | 177 |
Rectangle2D textArea = labelStyle.getTextBounds()[i]; |
170 | 178 |
|
171 |
Rectangle textRect = new Rectangle((int) (bounds.x * textArea |
|
172 |
.getX()), (int) (bounds.y * textArea.getY()), |
|
173 |
(int) (bounds.width * textArea.getWidth()), |
|
174 |
(int) (bounds.height * textArea.getHeight())); |
|
179 |
// let's build the text rectangle in screen units |
|
175 | 180 |
|
181 |
//TODO segueix calculant-se mal |
|
182 |
int x = (int) (bounds.getX() + textArea.getWidth()*textArea.getMinX()); |
|
183 |
int y = (int) (bounds.getY() + textArea.getHeight()*textArea.getMinY()); |
|
184 |
int width = (int) (bounds.getWidth() - (1-textArea.getWidth())); |
|
185 |
int height = (int) (bounds.getHeight() - (1-textArea.getHeight())); |
|
186 |
|
|
187 |
Rectangle textRect = new Rectangle(x, y, width, height); |
|
176 | 188 |
getLabelSymbol().drawInsideRectangle(graphics, null, textRect); |
177 | 189 |
} |
178 |
graphics.translate(-bounds.getX(), -bounds.getY()); |
|
179 | 190 |
} else { |
180 | 191 |
getLabelSymbol().setText(texts[0]); |
181 | 192 |
getLabelSymbol().drawInsideRectangle(graphics, null, bounds); |
Also available in: Unified diff