Revision 11170
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/legend/gui/PlacementProperties.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.3 2007-03-28 15:38:56 jaume |
|
46 |
* Revision 1.4 2007-04-12 16:01:32 jaume |
|
47 |
* *** empty log message *** |
|
48 |
* |
|
49 |
* Revision 1.3 2007/03/28 15:38:56 jaume |
|
47 | 50 |
* GUI for lines, points and polygons |
48 | 51 |
* |
49 | 52 |
* Revision 1.2 2007/03/09 11:25:00 jaume |
... | ... | |
388 | 391 |
PluginServices.getText(this, "line"), |
389 | 392 |
PluginServices.getText(this, "page") |
390 | 393 |
}); |
391 |
|
|
394 |
cmbOrientationSystem.setSelectedIndex(0); |
|
392 | 395 |
} |
393 | 396 |
|
394 | 397 |
return cmbOrientationSystem; |
... | ... | |
541 | 544 |
} |
542 | 545 |
|
543 | 546 |
constraints.setPlacementMode(mode); |
547 |
constraints.setAboveTheLine(getChkAbove().isSelected()); |
|
548 |
constraints.setBellowTheLine(getChkBelow().isSelected()); |
|
549 |
// ON THE LINE?? |
|
550 |
|
|
551 |
constraints.setPageOriented(getCmbOrientationSystem().getSelectedIndex() ==1); |
|
552 |
constraints.setLocationAlongTheLine() |
|
544 | 553 |
break; |
545 | 554 |
case FShape.POLYGON: |
546 | 555 |
break; |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/LinePlacementConstraints.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.5 2007-04-12 14:28:43 jaume |
|
46 |
* Revision 1.6 2007-04-12 16:01:11 jaume |
|
47 |
* *** empty log message *** |
|
48 |
* |
|
49 |
* Revision 1.5 2007/04/12 14:28:43 jaume |
|
47 | 50 |
* basic labeling support for lines |
48 | 51 |
* |
49 | 52 |
* Revision 1.4 2007/04/11 16:01:08 jaume |
... | ... | |
78 | 81 |
* |
79 | 82 |
*/ |
80 | 83 |
public class LinePlacementConstraints extends AbstractPlacementConstraints { |
84 |
private static final double HALF_PI = Math.PI * 0.5; |
|
85 |
|
|
81 | 86 |
public FShape[] getLocationsFor(IGeometry geom, FShape labelShape, MultiPolygon exclusionZone) { |
82 | 87 |
return new FShape[] { (FShape) geom.getInternalShape() }; |
83 | 88 |
} |
84 | 89 |
public void placeLabel(Graphics2D g, IGeometry geom, LabelClass lc, MultiPolygon exclusionZone, AffineTransform at, String[] labelTexts) { |
85 |
Point2D startingPoint; |
|
86 |
double rot; |
|
90 |
Point2D startingPoint = null;
|
|
91 |
double rot = 0;
|
|
87 | 92 |
if (isFollowingLine()) { |
88 | 93 |
throw new Error("following line option not yet implemented"); |
89 | 94 |
// 1. create text path |
... | ... | |
92 | 97 |
} else { |
93 | 98 |
PathLength pathLen = new PathLength(geom.getInternalShape()); |
94 | 99 |
float distance; |
100 |
|
|
95 | 101 |
if (isAtTheBeginingOfLine()) { |
96 | 102 |
distance = 0; |
97 | 103 |
} else if (isAtTheEndOfLine()) { |
... | ... | |
102 | 108 |
} |
103 | 109 |
|
104 | 110 |
startingPoint = pathLen.pointAtLength(distance); |
105 |
rot = pathLen.angleAtLength(distance); |
|
106 | 111 |
|
112 |
if (isParallel()) { |
|
113 |
// get the line theta and apply it |
|
114 |
rot = pathLen.angleAtLength(distance); |
|
115 |
|
|
116 |
} else if (isPerpendicular()) { |
|
117 |
// get the line theta with 90 degrees |
|
118 |
rot = pathLen.angleAtLength(distance) + HALF_PI; |
|
119 |
} |
|
107 | 120 |
} |
108 | 121 |
|
109 | 122 |
/* |
... | ... | |
124 | 137 |
} |
125 | 138 |
|
126 | 139 |
|
127 |
if (isParallel()) { |
|
128 |
// get the line theta and apply it |
|
129 |
} else if (isPerpendicular()) { |
|
130 |
// get the line theta with 90 degrees |
|
131 |
} |
|
132 | 140 |
|
133 | 141 |
/* |
134 | 142 |
* Now, we'll need to see who is defining the orientation |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/IPlacementConstraints.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.5 2007-04-12 14:28:43 jaume |
|
46 |
* Revision 1.6 2007-04-12 16:01:11 jaume |
|
47 |
* *** empty log message *** |
|
48 |
* |
|
49 |
* Revision 1.5 2007/04/12 14:28:43 jaume |
|
47 | 50 |
* basic labeling support for lines |
48 | 51 |
* |
49 | 52 |
* Revision 1.4 2007/04/11 16:01:08 jaume |
... | ... | |
97 | 100 |
|
98 | 101 |
// constants regarding line settings |
99 | 102 |
public static final int FOLLOWING_LINE = 11; |
100 |
public static final int PERPENDICULAR = 12;
|
|
103 |
public static final int PERPENDICULAR = 12;
|
|
101 | 104 |
|
102 |
// constants regarding label position along the line |
|
103 |
public static final int ABOVE_THE_LINE = 1000; |
|
104 |
public static final int ON_THE_LINE = 1100; |
|
105 |
public static final int BELLOW_THE_LINE = 1200; |
|
106 |
public static final int AT_THE_BEGINING = 10000; |
|
107 |
public static final int AT_THE_END = 20000; |
|
108 |
public static final int PAGE_ORIENTED = 100000; |
|
109 |
public static final int LINE_ORIENTED = 200000; |
|
105 |
// constants regarding the location along the line |
|
106 |
public static final int AT_THE_END_OF_THE_LINE = 13; |
|
107 |
public static final int AT_THE_MIDDLE_OF_THE_LINE = 14; |
|
108 |
public static final int AT_THE_BEGINING_OF_THE_LINE = 15; |
|
110 | 109 |
|
111 |
public abstract void setDuplicateLabelsMode(int mode); |
|
112 |
|
|
113 | 110 |
public abstract void setPlacementMode(int mode); |
114 | 111 |
|
115 |
public abstract boolean isHorizontal(); |
|
116 |
|
|
117 |
public abstract boolean isPerpendicular(); |
|
118 |
|
|
119 |
public abstract boolean isFollowingLine(); |
|
120 |
|
|
121 |
public abstract boolean isParallel(); |
|
122 |
|
|
123 |
public abstract int getDuplicateLabelsMode(); |
|
124 |
|
|
125 |
/** |
|
126 |
* Tells if the place mode selected is to put the label over the <b>POINT</b> |
|
127 |
* @return boolean |
|
128 |
*/ |
|
129 |
public abstract boolean isOnTopOfThePoint(); |
|
130 |
|
|
112 |
// regarding label position along the line |
|
131 | 113 |
public abstract boolean isAtTheBeginingOfLine(); |
114 |
public abstract void setAtTheBeginingOfLine(boolean b); |
|
132 | 115 |
public abstract boolean isAtTheEndOfLine(); |
116 |
public abstract void setAtTheEndOfLine(boolean b); |
|
133 | 117 |
public abstract boolean isBellowTheLine(); |
118 |
public abstract void setBellowTheLine(boolean b); |
|
134 | 119 |
public abstract boolean isAboveTheLine(); |
120 |
public abstract void setAboveTheLine(boolean b); |
|
121 |
|
|
122 |
// regarding the orientation system |
|
135 | 123 |
public abstract boolean isPageOriented(); |
136 |
public abstract boolean isLineOriented();
|
|
124 |
public abstract void setPageOriented(boolean b);
|
|
137 | 125 |
|
126 |
// regarding the label duplication |
|
127 |
public abstract void setDuplicateLabelsMode(int mode); |
|
128 |
public abstract int getDuplicateLabelsMode(); |
|
138 | 129 |
|
130 |
|
|
139 | 131 |
/** |
140 | 132 |
* Calculates the position where the next label will be placed. Or null |
141 | 133 |
* if the label does not have to be placed. |
... | ... | |
151 | 143 |
public abstract void placeLabel(Graphics2D g, IGeometry geom, |
152 | 144 |
LabelClass lc, MultiPolygon exclusionZone, AffineTransform transform, String[] labelTexts); |
153 | 145 |
|
146 |
public abstract boolean isParallel(); |
|
147 |
|
|
148 |
public abstract boolean isFollowingLine(); |
|
149 |
|
|
150 |
public abstract boolean isPerpendicular(); |
|
151 |
|
|
152 |
public abstract boolean isHorizontal(); |
|
153 |
|
|
154 | 154 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/AbstractPlacementConstraints.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.3 2007-04-11 16:01:08 jaume |
|
46 |
* Revision 1.4 2007-04-12 16:01:11 jaume |
|
47 |
* *** empty log message *** |
|
48 |
* |
|
49 |
* Revision 1.3 2007/04/11 16:01:08 jaume |
|
47 | 50 |
* maybe a label placer refactor |
48 | 51 |
* |
49 | 52 |
* Revision 1.2 2007/03/09 08:33:43 jaume |
... | ... | |
83 | 86 |
private int duplicateLabelsMode = ONE_LABEL_PER_FEATURE_PART; // default duplicate treatment |
84 | 87 |
private int placementMode; |
85 | 88 |
|
89 |
private boolean atTheBeginingOfLine; |
|
90 |
|
|
91 |
private boolean atTheEndOfLine; |
|
92 |
|
|
93 |
private boolean bellowTheLine; |
|
94 |
|
|
95 |
private boolean aboveTheLine; |
|
96 |
|
|
97 |
private boolean pageOriented; |
|
98 |
|
|
86 | 99 |
public void setDuplicateLabelsMode(int mode) { |
87 | 100 |
if (mode != REMOVE_DUPLICATE_LABELS && |
88 | 101 |
mode != ONE_LABEL_PER_FEATURE && |
... | ... | |
128 | 141 |
} |
129 | 142 |
|
130 | 143 |
public boolean isHorizontal() { |
131 |
return placementMode % 100 == HORIZONTAL;
|
|
144 |
return placementMode == HORIZONTAL; |
|
132 | 145 |
} |
133 | 146 |
|
134 | 147 |
public boolean isPerpendicular() { |
135 |
return placementMode % 100 == PERPENDICULAR;
|
|
148 |
return placementMode == PERPENDICULAR; |
|
136 | 149 |
} |
137 | 150 |
|
138 | 151 |
public boolean isFollowingLine() { |
139 |
return placementMode % 100 == FOLLOWING_LINE;
|
|
152 |
return placementMode == FOLLOWING_LINE; |
|
140 | 153 |
} |
141 | 154 |
|
142 | 155 |
public boolean isParallel() { |
143 |
return placementMode % 100 == PARALLEL;
|
|
156 |
return placementMode == PARALLEL; |
|
144 | 157 |
} |
145 | 158 |
|
146 | 159 |
public int getDuplicateLabelsMode() { |
... | ... | |
156 | 169 |
} |
157 | 170 |
|
158 | 171 |
public boolean isAtTheBeginingOfLine() { |
159 |
return placementMode / 10000 == 1;
|
|
172 |
return atTheBeginingOfLine;
|
|
160 | 173 |
} |
161 | 174 |
|
162 | 175 |
public boolean isAtTheEndOfLine() { |
163 |
return placementMode / 10000 == 2;
|
|
176 |
return atTheEndOfLine;
|
|
164 | 177 |
} |
165 | 178 |
|
166 | 179 |
public boolean isBellowTheLine() { |
167 |
return placementMode / 1000 == 12;
|
|
180 |
return bellowTheLine;
|
|
168 | 181 |
} |
169 | 182 |
|
170 | 183 |
public boolean isAboveTheLine() { |
171 |
return placementMode / 100 == 10;
|
|
184 |
return aboveTheLine;
|
|
172 | 185 |
} |
173 | 186 |
|
174 | 187 |
public boolean isPageOriented() { |
175 |
return placementMode / 100000 == 1;
|
|
188 |
return pageOriented;
|
|
176 | 189 |
} |
190 |
public void setPageOriented(boolean b) { |
|
191 |
this.pageOriented = pageOriented; |
|
192 |
} |
|
177 | 193 |
|
178 |
public boolean isLineOriented() { |
|
179 |
return placementMode / 100000 == 2; |
|
194 |
|
|
195 |
public void setAtTheBeginingOfLine(boolean b) { |
|
196 |
this.atTheBeginingOfLine = b; |
|
180 | 197 |
} |
198 |
|
|
199 |
public void setAtTheEndOfLine(boolean b) { |
|
200 |
this.atTheEndOfLine = b; |
|
201 |
} |
|
202 |
|
|
203 |
public void setBellowTheLine(boolean b) { |
|
204 |
this.bellowTheLine = b; |
|
205 |
} |
|
206 |
|
|
207 |
public void setAboveTheLine(boolean b) { |
|
208 |
this.aboveTheLine = b; |
|
209 |
} |
|
181 | 210 |
} |
Also available in: Unified diff