Revision 11104 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/LabelClass.java
LabelClass.java | ||
---|---|---|
40 | 40 |
*/ |
41 | 41 |
|
42 | 42 |
/* CVS MESSAGES: |
43 |
* |
|
44 |
* $Id$ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.4 2007-04-05 16:07:14 jaume |
|
47 |
* Styled labeling stuff |
|
48 |
* |
|
49 |
* Revision 1.3 2007/04/02 16:34:56 jaume |
|
50 |
* Styled labeling (start commiting) |
|
51 |
* |
|
52 |
* Revision 1.2 2007/03/09 08:33:43 jaume |
|
53 |
* *** empty log message *** |
|
54 |
* |
|
55 |
* Revision 1.1.2.6 2007/02/15 16:23:44 jaume |
|
56 |
* *** empty log message *** |
|
57 |
* |
|
58 |
* Revision 1.1.2.5 2007/02/09 07:47:05 jaume |
|
59 |
* Isymbol moved |
|
60 |
* |
|
61 |
* Revision 1.1.2.4 2007/02/02 16:21:24 jaume |
|
62 |
* start commiting labeling stuff |
|
63 |
* |
|
64 |
* Revision 1.1.2.3 2007/02/01 17:46:49 jaume |
|
65 |
* *** empty log message *** |
|
66 |
* |
|
67 |
* Revision 1.1.2.2 2007/02/01 11:42:47 jaume |
|
68 |
* *** empty log message *** |
|
69 |
* |
|
70 |
* Revision 1.1.2.1 2007/01/30 18:10:45 jaume |
|
71 |
* start commiting labeling stuff |
|
72 |
* |
|
73 |
* |
|
74 |
*/ |
|
43 |
* |
|
44 |
* $Id$ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.5 2007-04-10 16:34:01 jaume |
|
47 |
* towards a styled labeling |
|
48 |
* |
|
49 |
* Revision 1.4 2007/04/05 16:07:14 jaume |
|
50 |
* Styled labeling stuff |
|
51 |
* |
|
52 |
* Revision 1.3 2007/04/02 16:34:56 jaume |
|
53 |
* Styled labeling (start commiting) |
|
54 |
* |
|
55 |
* Revision 1.2 2007/03/09 08:33:43 jaume |
|
56 |
* *** empty log message *** |
|
57 |
* |
|
58 |
* Revision 1.1.2.6 2007/02/15 16:23:44 jaume |
|
59 |
* *** empty log message *** |
|
60 |
* |
|
61 |
* Revision 1.1.2.5 2007/02/09 07:47:05 jaume |
|
62 |
* Isymbol moved |
|
63 |
* |
|
64 |
* Revision 1.1.2.4 2007/02/02 16:21:24 jaume |
|
65 |
* start commiting labeling stuff |
|
66 |
* |
|
67 |
* Revision 1.1.2.3 2007/02/01 17:46:49 jaume |
|
68 |
* *** empty log message *** |
|
69 |
* |
|
70 |
* Revision 1.1.2.2 2007/02/01 11:42:47 jaume |
|
71 |
* *** empty log message *** |
|
72 |
* |
|
73 |
* Revision 1.1.2.1 2007/01/30 18:10:45 jaume |
|
74 |
* start commiting labeling stuff |
|
75 |
* |
|
76 |
* |
|
77 |
*/ |
|
75 | 78 |
package com.iver.cit.gvsig.fmap.rendering.styling; |
76 | 79 |
|
77 | 80 |
import java.awt.Graphics2D; |
78 | 81 |
import java.awt.Point; |
79 | 82 |
import java.awt.Rectangle; |
83 |
import java.awt.geom.AffineTransform; |
|
84 |
import java.awt.geom.Point2D; |
|
80 | 85 |
import java.awt.geom.Rectangle2D; |
81 | 86 |
|
82 | 87 |
import com.iver.cit.gvsig.fmap.core.FPoint2D; |
... | ... | |
89 | 94 |
import com.iver.cit.gvsig.fmap.core.symbols.ITextSymbol; |
90 | 95 |
import com.iver.cit.gvsig.fmap.core.symbols.SimpleTextSymbol; |
91 | 96 |
|
92 |
|
|
93 | 97 |
/** |
94 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
|
98 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
|
95 | 99 |
*/ |
96 | 100 |
public final class LabelClass { |
97 | 101 |
private String name; |
102 |
|
|
98 | 103 |
private ITextSymbol label; |
104 |
|
|
99 | 105 |
private String labelExpression; |
106 |
|
|
100 | 107 |
private boolean isVisible; |
108 |
|
|
101 | 109 |
private ILabelStyle labelStyle; |
102 | 110 |
|
103 | 111 |
public boolean isVisible() { |
... | ... | |
124 | 132 |
} |
125 | 133 |
|
126 | 134 |
public void setSymbol(ITextSymbol textSymbol) { |
127 |
label = textSymbol;
|
|
135 |
label = textSymbol; |
|
128 | 136 |
if (label == null) |
129 | 137 |
label = new SimpleTextSymbol(); |
130 | 138 |
} |
... | ... | |
149 | 157 |
return name; |
150 | 158 |
} |
151 | 159 |
|
152 |
public void drawInsideRectangle(Graphics2D graphics, Rectangle bounds, String[] texts) {
|
|
153 |
bounds.y = bounds.y - bounds.height;
|
|
160 |
public void drawInsideRectangle(Graphics2D graphics, Rectangle bounds, |
|
161 |
String[] texts) {
|
|
154 | 162 |
if (labelStyle != null) { |
155 | 163 |
labelStyle.drawInsideRectangle(graphics, bounds); |
164 |
Point2D offset = new Point2D.Double(bounds.getMinX(), bounds |
|
165 |
.getMinY()); |
|
166 |
graphics.translate(offset.getX(), offset.getY()); |
|
156 | 167 |
for (int i = 0; i < texts.length; i++) { |
157 | 168 |
getLabelSymbol().setText(texts[i]); |
158 | 169 |
Rectangle2D textArea = labelStyle.getTextBounds()[i]; |
159 |
Rectangle textRect = new Rectangle( |
|
160 |
(int) (bounds.x * textArea.getX()),
|
|
161 |
(int) (bounds.y * textArea.getY()), |
|
170 |
|
|
171 |
Rectangle textRect = new Rectangle((int) (bounds.x * textArea
|
|
172 |
.getX()), (int) (bounds.y * textArea.getY()),
|
|
162 | 173 |
(int) (bounds.width * textArea.getWidth()), |
163 |
(int) (bounds.height * textArea.getHeight()) |
|
164 |
); |
|
174 |
(int) (bounds.height * textArea.getHeight())); |
|
165 | 175 |
|
166 | 176 |
getLabelSymbol().drawInsideRectangle(graphics, null, textRect); |
167 | 177 |
} |
178 |
graphics.translate(-bounds.getX(), -bounds.getY()); |
|
168 | 179 |
} else { |
169 | 180 |
getLabelSymbol().setText(texts[0]); |
170 | 181 |
getLabelSymbol().drawInsideRectangle(graphics, null, bounds); |
171 | 182 |
} |
172 | 183 |
} |
173 | 184 |
|
174 |
public FShape getShape(Graphics2D g, /*AffineTransform at,*/ IGeometry geom) {
|
|
185 |
public FShape getShape(Graphics2D g, /* AffineTransform at, */IGeometry geom) {
|
|
175 | 186 |
if (labelStyle == null) { |
176 | 187 |
// shape is defined by the symbol |
177 | 188 |
FShape shp = null; |
Also available in: Unified diff