Revision 11051
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/styles/ILabelStyle.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.4 2007-04-02 16:34:56 jaume |
|
46 |
* Revision 1.5 2007-04-04 15:41:05 jaume |
|
47 |
* *** empty log message *** |
|
48 |
* |
|
49 |
* Revision 1.4 2007/04/02 16:34:56 jaume |
|
47 | 50 |
* Styled labeling (start commiting) |
48 | 51 |
* |
49 | 52 |
* Revision 1.3 2007/03/29 16:02:01 jaume |
... | ... | |
62 | 65 |
*/ |
63 | 66 |
package com.iver.cit.gvsig.fmap.core.styles; |
64 | 67 |
|
68 |
import java.awt.Dimension; |
|
65 | 69 |
import java.awt.Rectangle; |
70 |
import java.awt.geom.Point2D; |
|
66 | 71 |
|
67 | 72 |
/** |
68 | 73 |
* Defines the style that a Label symbol can contain which typically define |
... | ... | |
98 | 103 |
*/ |
99 | 104 |
public Rectangle[] getTextBounds(); |
100 | 105 |
|
106 |
/** |
|
107 |
* The complete bounds of this ILabelStyle |
|
108 |
* @return |
|
109 |
*/ |
|
101 | 110 |
public Rectangle getBounds(); |
102 | 111 |
|
112 |
/** |
|
113 |
* Returns the position of the point labeled by this label in percent units relative |
|
114 |
* to the label bounds. It determines the offset to be applied to the label to be |
|
115 |
* placed and allows the user to use custom styles. |
|
116 |
*/ |
|
117 |
public Point2D getMarkerPoint(); |
|
118 |
|
|
119 |
/** |
|
120 |
* Sets the position of the point labeled by this in percent units relative to the |
|
121 |
* label bounds |
|
122 |
* @param p |
|
123 |
* @throws IllegalArgumentException if the point coordinates are >0.0 or <1.0 |
|
124 |
*/ |
|
125 |
public void setMarkerPoint(Point2D p) throws IllegalArgumentException; |
|
126 |
|
|
127 |
public Dimension getPreferredSize(); |
|
103 | 128 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/styles/IStyle.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.1 2007-03-09 11:20:56 jaume |
|
46 |
* Revision 1.2 2007-04-04 15:41:05 jaume |
|
47 |
* *** empty log message *** |
|
48 |
* |
|
49 |
* Revision 1.1 2007/03/09 11:20:56 jaume |
|
47 | 50 |
* Advanced symbology (start committing) |
48 | 51 |
* |
49 | 52 |
* Revision 1.1.2.2 2007/02/15 16:23:44 jaume |
... | ... | |
84 | 87 |
|
85 | 88 |
public abstract boolean isSuitableFor(ISymbol symbol); |
86 | 89 |
|
90 |
/** |
|
91 |
* Used to show an outline of the style to graphically show its properties. |
|
92 |
* @param g, the Graphics2D where to draw |
|
93 |
* @param r, the bounds of the style inside such Graphics2D |
|
94 |
*/ |
|
95 |
public abstract void drawOutline(Graphics2D g, Rectangle r); |
|
87 | 96 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/styles/MarkerFillStyle.java | ||
---|---|---|
122 | 122 |
this.fillStyle = fillStyle; |
123 | 123 |
} |
124 | 124 |
|
125 |
public void drawOutline(Graphics2D g, Rectangle r) { |
|
126 |
drawInsideRectangle(g, r); |
|
127 |
} |
|
125 | 128 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/styles/PointLabelPositioneer.java | ||
---|---|---|
80 | 80 |
} |
81 | 81 |
} |
82 | 82 |
|
83 |
public void drawOutline(Graphics2D g, Rectangle r) { |
|
84 |
drawInsideRectangle(g, r); |
|
85 |
} |
|
86 |
|
|
83 | 87 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/styles/SimpleLabelStyle.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.5 2007-04-02 16:34:56 jaume |
|
46 |
* Revision 1.6 2007-04-04 15:41:05 jaume |
|
47 |
* *** empty log message *** |
|
48 |
* |
|
49 |
* Revision 1.5 2007/04/02 16:34:56 jaume |
|
47 | 50 |
* Styled labeling (start commiting) |
48 | 51 |
* |
49 | 52 |
* Revision 1.4 2007/04/02 00:10:04 jaume |
... | ... | |
65 | 68 |
*/ |
66 | 69 |
package com.iver.cit.gvsig.fmap.core.styles; |
67 | 70 |
|
71 |
import java.awt.Color; |
|
72 |
import java.awt.Dimension; |
|
68 | 73 |
import java.awt.Graphics2D; |
74 |
import java.awt.Point; |
|
69 | 75 |
import java.awt.Rectangle; |
76 |
import java.awt.geom.AffineTransform; |
|
77 |
import java.awt.geom.Point2D; |
|
70 | 78 |
import java.awt.geom.Rectangle2D; |
71 | 79 |
|
80 |
import com.iver.cit.gvsig.fmap.Messages; |
|
72 | 81 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
73 | 82 |
import com.iver.utiles.XMLEntity; |
74 | 83 |
|
... | ... | |
78 | 87 |
*/ |
79 | 88 |
public class SimpleLabelStyle extends SVGStyle implements ILabelStyle{ |
80 | 89 |
private String text; |
90 |
private Point2D markerPoint = new Point2D.Double(); |
|
81 | 91 |
|
82 | 92 |
public int getFieldCount() { |
83 | 93 |
return 1; |
... | ... | |
132 | 142 |
public Rectangle getBounds() { |
133 | 143 |
return super.getBounds(); |
134 | 144 |
} |
145 |
|
|
146 |
public Point2D getMarkerPoint() { |
|
147 |
return markerPoint; |
|
148 |
} |
|
149 |
|
|
150 |
public void setMarkerPoint(Point2D p) throws IllegalArgumentException { |
|
151 |
if (p.getX()<0 || p.getX()>1) |
|
152 |
throw new IllegalArgumentException("X must be >=0 and <=1 ("+p.getX()+")"); |
|
153 |
if (p.getY()<0 || p.getY()>1) |
|
154 |
throw new IllegalArgumentException("Y must be >=0 and <=1 ("+p.getY()+")"); |
|
155 |
// the marker represents the point labeled in relative percent units |
|
156 |
this.markerPoint = p; |
|
157 |
} |
|
158 |
|
|
159 |
public void drawOutline(Graphics2D g, Rectangle r) { |
|
160 |
super.drawOutline(g, r); |
|
161 |
Rectangle labelSz = getBounds(); |
|
162 |
|
|
163 |
double ratioLabel = labelSz.getWidth()/labelSz.getHeight(); |
|
164 |
double ratioViewPort = r.getWidth() / r.getWidth(); |
|
165 |
|
|
166 |
int x; |
|
167 |
int y; |
|
168 |
if (ratioViewPort > ratioLabel) { |
|
169 |
// size is defined by the viewport height |
|
170 |
y = (int) (r.height*markerPoint.getY()); |
|
171 |
x = (int) ((0.5*r.width) - (0.5-markerPoint.getX())*(ratioLabel*r.height)); |
|
172 |
} else { |
|
173 |
// size is defined by the viewport width |
|
174 |
x = (int) (r.width * markerPoint.getX()); |
|
175 |
y = (int) ((0.5 * r.height) - (0.5-markerPoint.getY())*(r.width/ratioLabel)); |
|
176 |
} |
|
177 |
y = r.height - y; |
|
178 |
|
|
179 |
int size = 3; |
|
180 |
g.setColor(Color.RED); |
|
181 |
g.fillOval(x, y, size, size); |
|
182 |
g.drawString(Messages.getString("labeled_point"), x + size + 5, y); |
|
183 |
} |
|
184 |
|
|
185 |
public Dimension getPreferredSize() { |
|
186 |
return new Dimension(getBounds().width, getBounds().height); |
|
187 |
} |
|
135 | 188 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/styles/SVGStyle.java | ||
---|---|---|
42 | 42 |
import java.awt.Graphics2D; |
43 | 43 |
import java.awt.Rectangle; |
44 | 44 |
import java.awt.RenderingHints; |
45 |
import java.awt.geom.AffineTransform; |
|
45 | 46 |
import java.awt.geom.Rectangle2D; |
46 | 47 |
import java.io.File; |
47 | 48 |
import java.io.IOException; |
... | ... | |
91 | 92 |
renderer.setDoubleBuffered(true); |
92 | 93 |
} |
93 | 94 |
|
94 |
public void drawInsideRectangle(Graphics2D g, Rectangle r) { |
|
95 |
long t1, t2; |
|
96 |
Graphics2D g2 = (Graphics2D) g; |
|
97 |
RenderingHints renderingHints = new RenderingHints(defaultRenderingHints); |
|
98 |
g2.setRenderingHints(renderingHints); |
|
99 |
gvtRoot.setTransform((ViewBox.getViewTransform(null, elt, (float) r.getWidth()-1, (float) r.getHeight()-1))); |
|
100 |
gvtRoot.paint(g2); |
|
95 |
public void drawInsideRectangle(Graphics2D g, Rectangle rect) { |
|
96 |
AffineTransform ataux = new AffineTransform(); |
|
97 |
|
|
98 |
ataux.translate(0,0);//rect.getX(), rect.getY()); |
|
99 |
|
|
100 |
ataux.concatenate(ViewBox.getViewTransform(null, elt, |
|
101 |
(float) rect.getWidth(), (float) rect.getHeight())); |
|
102 |
|
|
103 |
RenderingHints renderingHints = new RenderingHints(defaultRenderingHints); |
|
104 |
g.setRenderingHints(renderingHints); |
|
105 |
gvtRoot.setTransform(ataux); |
|
106 |
gvtRoot.paint(g); |
|
101 | 107 |
} |
102 | 108 |
|
103 | 109 |
public boolean isSuitableFor(ISymbol symbol) { |
... | ... | |
142 | 148 |
(int) r.getHeight()); |
143 | 149 |
} |
144 | 150 |
|
151 |
public void drawOutline(Graphics2D g, Rectangle r) { |
|
152 |
drawInsideRectangle(g, r); |
|
153 |
} |
|
145 | 154 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/styles/SimpleLineStyle.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.2 2007-03-09 11:20:56 jaume |
|
46 |
* Revision 1.3 2007-04-04 15:41:05 jaume |
|
47 |
* *** empty log message *** |
|
48 |
* |
|
49 |
* Revision 1.2 2007/03/09 11:20:56 jaume |
|
47 | 50 |
* Advanced symbology (start committing) |
48 | 51 |
* |
49 | 52 |
* Revision 1.1.2.4 2007/02/21 07:34:09 jaume |
... | ... | |
207 | 210 |
} |
208 | 211 |
} |
209 | 212 |
|
213 |
public void drawOutline(Graphics2D g, Rectangle r) { |
|
214 |
drawInsideRectangle(g, r); |
|
215 |
} |
|
210 | 216 |
|
211 | 217 |
} |
Also available in: Unified diff