Revision 11138 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/LabelClass.java
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