Revision 11073
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/styles/ILabelStyle.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.6 2007-04-04 15:42:03 jaume |
|
46 |
* Revision 1.7 2007-04-05 16:07:14 jaume |
|
47 |
* Styled labeling stuff |
|
48 |
* |
|
49 |
* Revision 1.6 2007/04/04 15:42:03 jaume |
|
47 | 50 |
* *** empty log message *** |
48 | 51 |
* |
49 | 52 |
* Revision 1.5 2007/04/04 15:41:05 jaume |
... | ... | |
68 | 71 |
*/ |
69 | 72 |
package com.iver.cit.gvsig.fmap.core.styles; |
70 | 73 |
|
71 |
import java.awt.Dimension; |
|
72 | 74 |
import java.awt.Rectangle; |
73 | 75 |
import java.awt.geom.Point2D; |
76 |
import java.awt.geom.Rectangle2D; |
|
74 | 77 |
|
75 | 78 |
/** |
76 | 79 |
* Defines the style that a Label symbol can contain which typically define |
... | ... | |
104 | 107 |
* placed. |
105 | 108 |
* @return |
106 | 109 |
*/ |
107 |
public Rectangle[] getTextBounds(); |
|
110 |
public Rectangle2D[] getTextBounds();
|
|
108 | 111 |
|
109 | 112 |
/** |
110 | 113 |
* The complete bounds of this ILabelStyle |
... | ... | |
127 | 130 |
*/ |
128 | 131 |
public void setMarkerPoint(Point2D p) throws IllegalArgumentException; |
129 | 132 |
|
133 |
public void setTextFieldArea(int index, Rectangle2D rect); |
|
134 |
|
|
135 |
public void addTextFieldArea(Rectangle2D rect); |
|
136 |
|
|
137 |
public void deleteTextFieldArea(int index); |
|
138 |
|
|
130 | 139 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/styles/SimpleLabelStyle.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.7 2007-04-04 15:42:03 jaume |
|
46 |
* Revision 1.8 2007-04-05 16:07:14 jaume |
|
47 |
* Styled labeling stuff |
|
48 |
* |
|
49 |
* Revision 1.7 2007/04/04 15:42:03 jaume |
|
47 | 50 |
* *** empty log message *** |
48 | 51 |
* |
49 | 52 |
* Revision 1.6 2007/04/04 15:41:05 jaume |
... | ... | |
72 | 75 |
package com.iver.cit.gvsig.fmap.core.styles; |
73 | 76 |
|
74 | 77 |
import java.awt.Color; |
75 |
import java.awt.Dimension; |
|
76 | 78 |
import java.awt.Graphics2D; |
77 |
import java.awt.Point; |
|
78 | 79 |
import java.awt.Rectangle; |
79 |
import java.awt.geom.AffineTransform; |
|
80 | 80 |
import java.awt.geom.Point2D; |
81 | 81 |
import java.awt.geom.Rectangle2D; |
82 |
import java.util.ArrayList; |
|
82 | 83 |
|
83 | 84 |
import com.iver.cit.gvsig.fmap.Messages; |
85 |
import com.iver.cit.gvsig.fmap.core.FPolygon2D; |
|
86 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
87 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
|
84 | 88 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
89 |
import com.iver.cit.gvsig.fmap.core.symbols.SimpleFillSymbol; |
|
90 |
import com.iver.cit.gvsig.fmap.core.symbols.SimpleLineSymbol; |
|
85 | 91 |
import com.iver.utiles.XMLEntity; |
86 | 92 |
|
87 | 93 |
|
88 | 94 |
/** |
89 | 95 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
90 | 96 |
*/ |
91 |
public class SimpleLabelStyle extends SVGStyle implements ILabelStyle{ |
|
97 |
public class SimpleLabelStyle extends SVGStyle implements ILabelStyle {
|
|
92 | 98 |
private String text; |
93 | 99 |
private Point2D markerPoint = new Point2D.Double(); |
100 |
// conertir a?? a Rectangle2D[] ja que pot arribar a gastar-se masivament |
|
101 |
// en el pintat |
|
102 |
private ArrayList textFieldAreas = new ArrayList(); |
|
94 | 103 |
|
95 | 104 |
public int getFieldCount() { |
96 | 105 |
return 1; |
... | ... | |
123 | 132 |
xml.putProperty("className", getClassName()); |
124 | 133 |
xml.putProperty("desc", getDescription()); |
125 | 134 |
xml.putProperty("text", text); |
135 |
xml.putProperty("markerPointX", markerPoint.getX()); |
|
136 |
xml.putProperty("markerPointY", markerPoint.getY()); |
|
137 |
|
|
138 |
int size = getFieldCount(); |
|
139 |
String[] minx = new String[size]; |
|
140 |
String[] miny = new String[size]; |
|
141 |
String[] widths = new String[size]; |
|
142 |
String[] heights = new String[size]; |
|
143 |
|
|
144 |
Rectangle2D[] rects = getTextBounds(); |
|
145 |
for (int i = 0; i < rects.length; i++) { |
|
146 |
minx[i] = String.valueOf(rects[i].getMinX()); |
|
147 |
miny[i] = String.valueOf(rects[i].getMinY()); |
|
148 |
widths[i] = String.valueOf(rects[i].getHeight()); |
|
149 |
heights[i] = String.valueOf(rects[i].getWidth()); |
|
150 |
} |
|
151 |
|
|
152 |
xml.putProperty("minXArray", minx); |
|
153 |
xml.putProperty("minYArray", miny); |
|
154 |
xml.putProperty("widthArray", widths); |
|
155 |
xml.putProperty("heightArray", heights); |
|
126 | 156 |
return xml; |
127 | 157 |
} |
128 | 158 |
|
... | ... | |
130 | 160 |
super.setXMLEntity(xml); |
131 | 161 |
setDescription(xml.getStringProperty("desc")); |
132 | 162 |
text = xml.getStringProperty("text"); |
163 |
double x = xml.getDoubleProperty("markerPointX"); |
|
164 |
double y = xml.getDoubleProperty("markerPointY"); |
|
165 |
|
|
166 |
double[] minx = xml.getDoubleArrayProperty("minXArray"); |
|
167 |
double[] miny = xml.getDoubleArrayProperty("minYArray"); |
|
168 |
double[] widths = xml.getDoubleArrayProperty("widthArray"); |
|
169 |
double[] heights = xml.getDoubleArrayProperty("heightArray"); |
|
170 |
for (int i = 0; i < minx.length; i++) { |
|
171 |
addTextFieldArea(new Rectangle2D.Double(minx[i], miny[i], widths[i], heights[i])); |
|
172 |
} |
|
173 |
markerPoint.setLocation(x, y); |
|
133 | 174 |
} |
134 | 175 |
|
135 |
public Rectangle[] getTextBounds() { |
|
136 |
return new Rectangle[] {new Rectangle(0,0,300,-60)};
|
|
176 |
public Rectangle2D[] getTextBounds() {
|
|
177 |
return (Rectangle2D[]) textFieldAreas.toArray(new Rectangle2D[textFieldAreas.size()]);
|
|
137 | 178 |
} |
138 | 179 |
|
139 | 180 |
public void drawInsideRectangle(Graphics2D g, Rectangle r) { |
... | ... | |
166 | 207 |
double ratioLabel = labelSz.getWidth()/labelSz.getHeight(); |
167 | 208 |
double ratioViewPort = r.getWidth() / r.getWidth(); |
168 | 209 |
|
169 |
int x; |
|
170 |
int y; |
|
171 |
if (ratioViewPort > ratioLabel) { |
|
172 |
// size is defined by the viewport height |
|
173 |
y = (int) (r.height*markerPoint.getY()); |
|
174 |
x = (int) ((0.5*r.width) - (0.5-markerPoint.getX())*(ratioLabel*r.height)); |
|
175 |
} else { |
|
176 |
// size is defined by the viewport width |
|
177 |
x = (int) (r.width * markerPoint.getX()); |
|
178 |
y = (int) ((0.5 * r.height) - (0.5-markerPoint.getY())*(r.width/ratioLabel)); |
|
210 |
// draw the pointer |
|
211 |
{ |
|
212 |
int x; |
|
213 |
int y; |
|
214 |
if (ratioViewPort > ratioLabel) { |
|
215 |
// size is defined by the viewport height |
|
216 |
y = (int) (r.height*markerPoint.getY()); |
|
217 |
x = (int) ((0.5*r.width) - (0.5-markerPoint.getX())*(ratioLabel*r.height)); |
|
218 |
} else { |
|
219 |
// size is defined by the viewport width |
|
220 |
x = (int) (r.width * markerPoint.getX()); |
|
221 |
y = (int) ((0.5 * r.height) - (0.5-markerPoint.getY())*(r.width/ratioLabel)); |
|
222 |
} |
|
223 |
y = r.height - y; |
|
224 |
|
|
225 |
int size = 7; |
|
226 |
g.setColor(Color.ORANGE.darker()); |
|
227 |
g.fillOval(x, y, size, size); |
|
228 |
g.setColor(Color.BLACK.brighter()); |
|
229 |
g.drawString(Messages.getString("labeled_point"), x + size + 10, y + size); |
|
230 |
g.setColor(Color.BLACK); |
|
231 |
g.drawLine(x-size, (int) (y+(size*0.5)), x+2*size-1, (int) (y+(size*0.5))); |
|
232 |
g.drawLine((int) (x+(size*0.5)), y-size, (int) (x+(size*0.5)), y+2*size-1); |
|
179 | 233 |
} |
180 |
y = r.height - y; |
|
181 | 234 |
|
182 |
int size = 3; |
|
183 |
g.setColor(Color.RED); |
|
184 |
g.fillOval(x, y, size, size); |
|
185 |
g.drawString(Messages.getString("labeled_point"), x + size + 5, y); |
|
235 |
// draw the text fields |
|
236 |
if (textFieldAreas.size() > 0) { |
|
237 |
SimpleFillSymbol sym = new SimpleFillSymbol(); |
|
238 |
Color c = Color.YELLOW; |
|
239 |
|
|
240 |
sym.setFillColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), 100)); |
|
241 |
SimpleLineSymbol outline = new SimpleLineSymbol(); |
|
242 |
c = Color.BLACK; |
|
243 |
outline.setLineColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), 100)); |
|
244 |
sym.setOutline(outline); |
|
245 |
for (int i = 0; i < textFieldAreas.size(); i++) { |
|
246 |
Rectangle2D textFieldArea = (Rectangle2D) textFieldAreas.get(i); |
|
247 |
|
|
248 |
int x = (int) (r.width * textFieldArea.getX()); |
|
249 |
int y = (int) (r.height * textFieldArea.getY()); |
|
250 |
int width = (int) (r.width * textFieldArea.getWidth()); |
|
251 |
int height = (int) (r.width * textFieldArea.getHeight()); |
|
252 |
Rectangle aux = new Rectangle(x, y, width, height); |
|
253 |
FShape shp = new FPolygon2D(new GeneralPathX(aux)); |
|
254 |
sym.draw(g, null, shp); |
|
255 |
g.setColor(Color.BLACK); |
|
256 |
g.drawString(String.valueOf(i), x+5, y + 10); |
|
257 |
} |
|
258 |
} |
|
186 | 259 |
} |
260 |
public void setTextFieldArea(int index, Rectangle2D rect) { |
|
261 |
// patch, please remove it |
|
262 |
if (textFieldAreas.size()==0) |
|
263 |
textFieldAreas.add(new Rectangle2D.Double()); |
|
264 |
// end patch |
|
265 |
textFieldAreas.set(index, rect); |
|
266 |
} |
|
187 | 267 |
|
268 |
public void addTextFieldArea(Rectangle2D rect) { |
|
269 |
textFieldAreas.add(rect); |
|
270 |
} |
|
271 |
|
|
272 |
public void deleteTextFieldArea(int index) { |
|
273 |
textFieldAreas.remove(index); |
|
274 |
} |
|
275 |
|
|
188 | 276 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/SimpleTextSymbol.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
1 | 41 |
package com.iver.cit.gvsig.fmap.core.symbols; |
2 | 42 |
|
3 | 43 |
import java.awt.Color; |
... | ... | |
23 | 63 |
import com.iver.cit.gvsig.fmap.core.FShape; |
24 | 64 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
25 | 65 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
66 |
import com.iver.cit.gvsig.fmap.core.TextPath; |
|
26 | 67 |
import com.iver.cit.gvsig.fmap.core.v02.FConverter; |
27 | 68 |
import com.iver.utiles.StringUtilities; |
28 | 69 |
import com.iver.utiles.XMLEntity; |
29 | 70 |
import com.vividsolutions.jts.geom.Geometry; |
30 | 71 |
import com.vividsolutions.jts.geom.Point; |
31 | 72 |
|
73 |
/** |
|
74 |
* |
|
75 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
|
76 |
* |
|
77 |
*/ |
|
32 | 78 |
public class SimpleTextSymbol extends AbstractSymbol implements ITextSymbol { |
33 | 79 |
private String text = ""; |
34 | 80 |
private Font font = new Font("Arial", Font.PLAIN, 10); |
... | ... | |
59 | 105 |
Geometry geo = FConverter.java2d_to_jts(shp); |
60 | 106 |
|
61 | 107 |
if (geo == null) { |
62 |
// return;
|
|
108 |
return; |
|
63 | 109 |
} |
64 | 110 |
|
65 | 111 |
Point pJTS = geo.getCentroid(); |
... | ... | |
89 | 135 |
|
90 | 136 |
public void drawInsideRectangle(Graphics2D g, |
91 | 137 |
AffineTransform scaleInstance, Rectangle r) { |
92 |
g.drawString("Not yet implemented", 0, r.height); |
|
138 |
FontRenderContext frc = g.getFontRenderContext(); |
|
139 |
GlyphVector gv = font.createGlyphVector(frc, text); |
|
140 |
gv. |
|
141 |
float fontSize = getFont().getSize(); |
|
142 |
float fontScaleFactor = (float) ((getText().length()*fontSize) * 0.8) // text length with a 20% margin |
|
143 |
/ r.width; |
|
93 | 144 |
|
145 |
fontSize = fontSize * fontScaleFactor; |
|
146 |
g.setFont(getFont().deriveFont(fontSize)); |
|
147 |
System.out.println(r); |
|
148 |
g.drawString(getText(), r.x*0.9F, ( r.height*0.5F) + (fontSize*0.5F)); |
|
149 |
|
|
150 |
|
|
94 | 151 |
} |
95 | 152 |
|
96 | 153 |
public int getOnePointRgb() { |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/FLayers.java | ||
---|---|---|
424 | 424 |
///// CHEMA ComposedLayer |
425 | 425 |
long tg1 = System.currentTimeMillis(); |
426 | 426 |
ComposedLayer group = null; |
427 |
ArrayList pendingEvents= new ArrayList();
|
|
427 |
ArrayList pendingEvents= new ArrayList(); |
|
428 | 428 |
boolean fireAfterDrawEvent = true; |
429 | 429 |
///// CHEMA ComposedLayer |
430 | 430 |
|
431 |
|
|
432 |
|
|
431 |
|
|
432 |
|
|
433 | 433 |
// while (iter.hasNext()) |
434 | 434 |
// { |
435 | 435 |
for (int i=0; i < layers.size(); i++) { |
... | ... | |
439 | 439 |
FLayer lyr = (FLayer) layers.get(i); |
440 | 440 |
|
441 | 441 |
|
442 |
///// CHEMA ComposedLayer
|
|
442 |
///// CHEMA ComposedLayer |
|
443 | 443 |
fireAfterDrawEvent = true; |
444 | 444 |
///// CHEMA ComposedLayer |
445 |
|
|
446 |
|
|
445 |
|
|
446 |
|
|
447 | 447 |
/* if (lyr instanceof FLyrVect && ((FLyrVect)lyr).isBroken()){ |
448 | 448 |
continue; |
449 | 449 |
} |
... | ... | |
452 | 452 |
fmap.fireLayerDrawingEvent(beforeEvent); |
453 | 453 |
if ((lyr.isDirty()) || (lyr.isCachingDrawnLayers() == false)) |
454 | 454 |
bNeedRecalculateCache = true; |
455 |
|
|
455 |
|
|
456 | 456 |
if (lyr.isVisible()) { |
457 | 457 |
|
458 | 458 |
long t1 = System.currentTimeMillis(); |
... | ... | |
490 | 490 |
group = null; |
491 | 491 |
} |
492 | 492 |
///// CHEMA ComposedLayer |
493 |
|
|
494 | 493 |
|
494 |
|
|
495 | 495 |
// Copiamos la imagen actual |
496 | 496 |
BufferedImage buff = new BufferedImage(image.getWidth(), image.getHeight(), image.getType()); |
497 | 497 |
WritableRaster w = buff.getRaster(); |
... | ... | |
509 | 509 |
// prepareDrawing de FMap. |
510 | 510 |
if (lyr.isDirty()) |
511 | 511 |
{ |
512 |
|
|
513 |
|
|
512 |
|
|
513 |
|
|
514 | 514 |
///// CHEMA ComposedLayer |
515 | 515 |
// Checks for draw group (ComposedLayer) |
516 | 516 |
if (group != null) { |
... | ... | |
521 | 521 |
group = null; |
522 | 522 |
} |
523 | 523 |
///// CHEMA ComposedLayer |
524 |
|
|
525 | 524 |
|
525 |
|
|
526 | 526 |
g.drawImage(lyr.getCacheImageDrawnLayers(), 0, 0, null); |
527 | 527 |
System.err.println("Pinto con acelerado lo que hab?a antes de " + lyr.getName()); |
528 | 528 |
} |
... | ... | |
552 | 552 |
|
553 | 553 |
// gets a new group instance |
554 | 554 |
group = lyr.newComposedLayer(); |
555 |
// if layer hasn't group, draws it inmediately
|
|
555 |
// if layer hasn't group, draws it inmediately |
|
556 | 556 |
if (group == null) { |
557 | 557 |
lyr.draw(image, g, viewPort, cancel,scale); |
558 | 558 |
} else { |
... | ... | |
565 | 565 |
} else { |
566 | 566 |
// gets a new group instance |
567 | 567 |
group = lyr.newComposedLayer(); |
568 |
// if layer hasn't group, draws it inmediately
|
|
568 |
// if layer hasn't group, draws it inmediately |
|
569 | 569 |
if (group == null) { |
570 | 570 |
lyr.draw(image, g, viewPort, cancel,scale); |
571 | 571 |
} else { |
... | ... | |
576 | 576 |
} |
577 | 577 |
} |
578 | 578 |
///// CHEMA ComposedLayer |
579 |
|
|
580 |
/*
|
|
579 |
|
|
580 |
/* |
|
581 | 581 |
* (Jaume) |
582 | 582 |
* If the layer is instance of ILabelable then it may have labels. |
583 | 583 |
*/ |
584 | 584 |
if (lyr instanceof ILabelable && ((ILabelable) lyr).isLabeled()) { |
585 |
|
|
586 |
///// CHEMA ComposedLayer
|
|
585 |
|
|
586 |
///// CHEMA ComposedLayer |
|
587 | 587 |
if (group != null) { |
588 | 588 |
//si tenemos un grupo pendiente de pintar, pintamos |
589 | 589 |
// para que se pinten correctamente las etiquetas |
... | ... | |
594 | 594 |
} |
595 | 595 |
///// CHEMA ComposedLayer |
596 | 596 |
|
597 |
|
|
597 |
|
|
598 | 598 |
((ILabelable) lyr).drawLabels(image, g, viewPort, cancel, scale); |
599 | 599 |
} |
600 | 600 |
bNeedRecalculateCache = true; |
... | ... | |
622 | 622 |
///// CHEMA ComposedLayer |
623 | 623 |
LayerDrawEvent afterEvent = new LayerDrawEvent(lyr, g, viewPort, LayerDrawEvent.LAYER_AFTER_DRAW); |
624 | 624 |
fmap.fireLayerDrawingEvent(afterEvent); |
625 |
///// CHEMA ComposedLayer
|
|
625 |
///// CHEMA ComposedLayer |
|
626 | 626 |
} |
627 | 627 |
///// CHEMA ComposedLayer |
628 | 628 |
} |
629 |
|
|
630 |
///// CHEMA ComposedLayer
|
|
629 |
|
|
630 |
///// CHEMA ComposedLayer |
|
631 | 631 |
if (group != null) { |
632 |
//si tenemos un grupo pendiente de pintar, pintamos
|
|
632 |
//si tenemos un grupo pendiente de pintar, pintamos |
|
633 | 633 |
group.draw(image, g, viewPort, cancel,scale); |
634 | 634 |
fireLayerDrawingEvents(pendingEvents); |
635 | 635 |
|
... | ... | |
644 | 644 |
// System.err.println(e.getMessage()); |
645 | 645 |
// } |
646 | 646 |
long tg2 = System.currentTimeMillis(); |
647 |
|
|
647 |
|
|
648 | 648 |
System.out.println("Draw all layer " |
649 | 649 |
+ (tg2-tg1) + " milisecs."); |
650 |
|
|
650 |
|
|
651 | 651 |
} |
652 |
|
|
652 |
|
|
653 | 653 |
private void fireLayerDrawingEvents(Collection events) { |
654 | 654 |
Iterator iter = events.iterator(); |
655 | 655 |
LayerDrawEvent afterEvent; |
... | ... | |
659 | 659 |
fmap.fireLayerDrawingEvent(afterEvent); |
660 | 660 |
} |
661 | 661 |
} |
662 |
|
|
662 |
|
|
663 | 663 |
/** |
664 | 664 |
* @see com.iver.cit.gvsig.fmap.layers.FLayer#print(java.awt.Graphics2D, |
665 | 665 |
* com.iver.cit.gvsig.fmap.ViewPort, |
... | ... | |
674 | 674 |
for (int i=0; i < layers.size(); i++) { |
675 | 675 |
FLayer lyr = (FLayer) layers.get(i); |
676 | 676 |
lyr.print(g, viewPort, cancel, scale, properties); |
677 |
if (lyr instanceof ILabelable) { |
|
678 |
ILabelable lLayer = (ILabelable) lyr; |
|
677 | 679 |
|
680 |
lLayer.drawLabels(null, g, viewPort, cancel, scale); |
|
681 |
} |
|
678 | 682 |
} |
679 | 683 |
if (getVirtualLayers() != null) { |
680 | 684 |
getVirtualLayers().print( g, viewPort, cancel,scale, properties); |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/PointPlacementConstraints.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-05 16:07:13 jaume |
|
47 |
* Styled labeling stuff |
|
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 |
... | ... | |
63 | 66 |
import com.iver.cit.gvsig.fmap.core.FPoint2D; |
64 | 67 |
import com.iver.cit.gvsig.fmap.core.FShape; |
65 | 68 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
66 |
|
|
69 |
/** |
|
70 |
* |
|
71 |
* @author jaume |
|
72 |
* |
|
73 |
*/ |
|
67 | 74 |
public class PointPlacementConstraints extends AbstractPlacementConstraints { |
68 | 75 |
|
69 | 76 |
public FShape[] getLocationsFor(IGeometry geom, FShape labelShape, MultiPolygon exclusionZone) { |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/LabelClass.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-05 16:07:14 jaume |
|
47 |
* Styled labeling stuff |
|
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 |
... | ... | |
71 | 74 |
*/ |
72 | 75 |
package com.iver.cit.gvsig.fmap.rendering.styling; |
73 | 76 |
|
74 |
import java.awt.Graphics; |
|
75 | 77 |
import java.awt.Graphics2D; |
76 | 78 |
import java.awt.Point; |
77 | 79 |
import java.awt.Rectangle; |
78 |
import java.awt.geom.AffineTransform;
|
|
80 |
import java.awt.geom.Rectangle2D;
|
|
79 | 81 |
|
80 | 82 |
import com.iver.cit.gvsig.fmap.core.FPoint2D; |
81 | 83 |
import com.iver.cit.gvsig.fmap.core.FPolygon2D; |
... | ... | |
153 | 155 |
labelStyle.drawInsideRectangle(graphics, bounds); |
154 | 156 |
for (int i = 0; i < texts.length; i++) { |
155 | 157 |
getLabelSymbol().setText(texts[i]); |
156 |
getLabelSymbol().drawInsideRectangle(graphics, null, labelStyle.getTextBounds()[i]); |
|
158 |
Rectangle2D textArea = labelStyle.getTextBounds()[i]; |
|
159 |
Rectangle textRect = new Rectangle( |
|
160 |
(int) (bounds.x * textArea.getX()), |
|
161 |
(int) (bounds.y * textArea.getY()), |
|
162 |
(int) (bounds.width * textArea.getWidth()), |
|
163 |
(int) (bounds.height * textArea.getHeight()) |
|
164 |
); |
|
165 |
|
|
166 |
getLabelSymbol().drawInsideRectangle(graphics, null, textRect); |
|
157 | 167 |
} |
158 | 168 |
} else { |
159 | 169 |
getLabelSymbol().setText(texts[0]); |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/AttrInTableLabeling.java | ||
---|---|---|
141 | 141 |
g.setColor(Color.GREEN); |
142 | 142 |
for (int j = 0; j < aux.length; j++) { |
143 | 143 |
FPoint2D p = new FPoint2D(aux[j].getOrig()); |
144 |
FPoint2D p2 = (FPoint2D)p.cloneFShape(); |
|
145 |
p2.transform(viewPort.getAffineTransform()); |
|
146 |
FShape s = sym.getTextWrappingShape(g, p2); |
|
147 | 144 |
sym.draw(g, viewPort.getAffineTransform(), p); |
148 |
g.draw(s); |
|
149 |
|
|
150 |
|
|
151 | 145 |
} |
152 |
|
|
153 | 146 |
} |
154 | 147 |
} catch (VisitorException e) { |
155 | 148 |
Logger.getAnonymousLogger().log(Level.SEVERE, "Could not get the layer extent.\n" + |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/styling/SimpleMarker.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.3 2007-04-04 16:01:14 jaume |
|
46 |
* Revision 1.4 2007-04-05 16:08:34 jaume |
|
47 |
* Styled labeling stuff |
|
48 |
* |
|
49 |
* Revision 1.3 2007/04/04 16:01:14 jaume |
|
47 | 50 |
* *** empty log message *** |
48 | 51 |
* |
49 | 52 |
* Revision 1.2 2007/03/09 11:25:00 jaume |
... | ... | |
202 | 205 |
fireSymbolChangedEvent(); |
203 | 206 |
} |
204 | 207 |
|
208 |
public EditorTool getEditorTool() { |
|
209 |
return null; |
|
210 |
} |
|
205 | 211 |
} |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/styling/CharacterMarker.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.4 2007-04-04 16:01:13 jaume |
|
46 |
* Revision 1.5 2007-04-05 16:08:34 jaume |
|
47 |
* Styled labeling stuff |
|
48 |
* |
|
49 |
* Revision 1.4 2007/04/04 16:01:13 jaume |
|
47 | 50 |
* *** empty log message *** |
48 | 51 |
* |
49 | 52 |
* Revision 1.3 2007/03/30 12:54:11 jaume |
... | ... | |
303 | 306 |
} |
304 | 307 |
} |
305 | 308 |
|
309 |
public EditorTool getEditorTool() { |
|
310 |
return null; |
|
311 |
} |
|
306 | 312 |
} |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/styling/SymbolPreviewer.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.3 2007-04-04 16:01:14 jaume |
|
46 |
* Revision 1.4 2007-04-05 16:08:34 jaume |
|
47 |
* Styled labeling stuff |
|
48 |
* |
|
49 |
* Revision 1.3 2007/04/04 16:01:14 jaume |
|
47 | 50 |
* *** empty log message *** |
48 | 51 |
* |
49 | 52 |
* Revision 1.2 2007/03/09 11:25:00 jaume |
... | ... | |
101 | 104 |
import java.awt.Graphics; |
102 | 105 |
import java.awt.Graphics2D; |
103 | 106 |
import java.awt.Rectangle; |
107 |
import java.awt.event.MouseListener; |
|
108 |
import java.awt.event.MouseMotionListener; |
|
104 | 109 |
import java.awt.geom.AffineTransform; |
105 | 110 |
|
106 | 111 |
import javax.swing.JPanel; |
... | ... | |
119 | 124 |
|
120 | 125 |
|
121 | 126 |
public SymbolPreviewer() { |
122 |
super(); |
|
127 |
super(true);
|
|
123 | 128 |
setBackground(Color.WHITE); |
124 | 129 |
} |
125 | 130 |
|
... | ... | |
153 | 158 |
g2.drawString(noneSelected, (r.x*scale) - (hGap/2), r.height/2+vGap*scale); |
154 | 159 |
} |
155 | 160 |
} |
161 |
|
|
162 |
|
|
163 |
public void setEditorTool(EditorTool l) { |
|
164 |
MouseListener[] ml = getMouseListeners(); |
|
165 |
for (int i = 0; i < ml.length; i++) { |
|
166 |
super.removeMouseListener(ml[i]); |
|
167 |
} |
|
168 |
MouseMotionListener[] mml = getMouseMotionListeners(); |
|
169 |
for (int i = 0; i < mml.length; i++) { |
|
170 |
super.removeMouseMotionListener(mml[i]); |
|
171 |
} |
|
172 |
|
|
173 |
if (l!= null) { |
|
174 |
super.addMouseListener(l); |
|
175 |
setCursor(l.getCursor()); |
|
176 |
super.addMouseMotionListener(l); |
|
177 |
} |
|
178 |
} |
|
179 |
|
|
180 |
|
|
156 | 181 |
} |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/styling/SimpleFill.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.5 2007-04-04 16:01:14 jaume |
|
46 |
* Revision 1.6 2007-04-05 16:08:34 jaume |
|
47 |
* Styled labeling stuff |
|
48 |
* |
|
49 |
* Revision 1.5 2007/04/04 16:01:14 jaume |
|
47 | 50 |
* *** empty log message *** |
48 | 51 |
* |
49 | 52 |
* Revision 1.4 2007/03/30 09:39:45 jaume |
... | ... | |
241 | 244 |
} |
242 | 245 |
fireSymbolChangedEvent(); |
243 | 246 |
} |
247 |
|
|
248 |
public EditorTool getEditorTool() { |
|
249 |
return null; |
|
250 |
} |
|
244 | 251 |
} |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/styling/SimpleLine.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.5 2007-04-04 16:01:13 jaume |
|
46 |
* Revision 1.6 2007-04-05 16:08:34 jaume |
|
47 |
* Styled labeling stuff |
|
48 |
* |
|
49 |
* Revision 1.5 2007/04/04 16:01:13 jaume |
|
47 | 50 |
* *** empty log message *** |
48 | 51 |
* |
49 | 52 |
* Revision 1.4 2007/03/26 15:05:26 jaume |
... | ... | |
218 | 221 |
cmbLineStyles.setLineWidth((int) txtWidth.getValue().floatValue()); |
219 | 222 |
fireSymbolChangedEvent(); |
220 | 223 |
} |
224 |
|
|
225 |
public EditorTool getEditorTool() { |
|
226 |
return null; |
|
227 |
} |
|
221 | 228 |
} |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/styling/StyleSelector.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.4 2007-04-04 16:01:14 jaume |
|
46 |
* Revision 1.5 2007-04-05 16:08:34 jaume |
|
47 |
* Styled labeling stuff |
|
48 |
* |
|
49 |
* Revision 1.4 2007/04/04 16:01:14 jaume |
|
47 | 50 |
* *** empty log message *** |
48 | 51 |
* |
49 | 52 |
* Revision 1.2 2007/03/09 11:25:00 jaume |
... | ... | |
68 | 71 |
import java.awt.Color; |
69 | 72 |
import java.awt.Component; |
70 | 73 |
import java.awt.Dimension; |
74 |
import java.awt.FlowLayout; |
|
71 | 75 |
import java.io.File; |
72 | 76 |
import java.io.FileFilter; |
77 |
import java.io.FileWriter; |
|
73 | 78 |
import java.util.prefs.Preferences; |
74 | 79 |
|
75 | 80 |
import javax.swing.BoxLayout; |
76 | 81 |
import javax.swing.JComponent; |
82 |
import javax.swing.JFileChooser; |
|
77 | 83 |
import javax.swing.JLabel; |
78 | 84 |
import javax.swing.JList; |
79 | 85 |
import javax.swing.JPanel; |
86 |
import javax.swing.JTextField; |
|
80 | 87 |
import javax.swing.ListCellRenderer; |
81 | 88 |
import javax.swing.event.ListSelectionEvent; |
82 | 89 |
import javax.swing.event.ListSelectionListener; |
... | ... | |
84 | 91 |
import javax.swing.tree.TreeModel; |
85 | 92 |
import javax.swing.tree.TreePath; |
86 | 93 |
|
94 |
import org.exolab.castor.xml.Marshaller; |
|
87 | 95 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
88 | 96 |
|
89 | 97 |
import com.iver.andami.PluginServices; |
98 |
import com.iver.andami.messages.NotificationManager; |
|
90 | 99 |
import com.iver.cit.gvsig.fmap.core.styles.IStyle; |
91 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol;
|
|
100 |
import com.iver.utiles.XMLEntity;
|
|
92 | 101 |
|
93 | 102 |
/** |
94 | 103 |
* |
... | ... | |
258 | 267 |
protected void propertiesPressed() { |
259 | 268 |
StyleEditor se = new StyleEditor((IStyle) selectedElement); |
260 | 269 |
PluginServices.getMDIManager().addWindow(se); |
270 |
setStyle(se.getStyle()); |
|
261 | 271 |
} |
262 | 272 |
|
273 |
protected void savePressed() { |
|
274 |
if (getSelectedObject() ==null) |
|
275 |
return; |
|
276 |
|
|
277 |
|
|
278 |
JFileChooser jfc = new JFileChooser(rootDir); |
|
279 |
javax.swing.filechooser.FileFilter ff = new javax.swing.filechooser.FileFilter() { |
|
280 |
public boolean accept(File f) { |
|
281 |
return f.getAbsolutePath(). |
|
282 |
toLowerCase(). |
|
283 |
endsWith(StyleSelectorListModel.STYLE_FILE_EXTENSION); |
|
284 |
} |
|
285 |
|
|
286 |
public String getDescription() { |
|
287 |
return PluginServices.getText( |
|
288 |
this, "gvSIG_symbol_definition_file")+ " (*.sym)"; |
|
289 |
} |
|
290 |
}; |
|
291 |
jfc.setFileFilter(ff); |
|
292 |
JPanel accessory = new JPanel(new FlowLayout(FlowLayout.LEADING, 5, 5)); |
|
293 |
accessory.add(new JLabel(PluginServices.getText(this, "enter_description"))); |
|
294 |
JTextField txtDesc = new JTextField(25); |
|
295 |
accessory.add(txtDesc); |
|
296 |
jfc.setAccessory(accessory); |
|
297 |
if (jfc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) { |
|
298 |
File targetFile = jfc.getSelectedFile(); |
|
299 |
|
|
300 |
String fExtension = StyleSelectorListModel.STYLE_FILE_EXTENSION; |
|
301 |
|
|
302 |
// apply description |
|
303 |
String desc; |
|
304 |
if (txtDesc.getText()==null || txtDesc.getText().trim().equals("")) { |
|
305 |
// default to file name |
|
306 |
String s = targetFile.getAbsolutePath(); |
|
307 |
desc = s.substring(s.lastIndexOf(File.separator)+1).replaceAll(fExtension, ""); |
|
308 |
} else { |
|
309 |
desc = txtDesc.getText().trim(); |
|
310 |
} |
|
311 |
IStyle s = (IStyle) getSelectedObject(); |
|
312 |
s.setDescription(desc); |
|
313 |
|
|
314 |
// save it |
|
315 |
XMLEntity xml = s.getXMLEntity(); |
|
316 |
if (!targetFile. |
|
317 |
getAbsolutePath(). |
|
318 |
toLowerCase(). |
|
319 |
endsWith(fExtension)) |
|
320 |
targetFile = new File(targetFile.getAbsolutePath() + fExtension); |
|
321 |
FileWriter writer; |
|
322 |
try { |
|
323 |
writer = new FileWriter(targetFile.getAbsolutePath()); |
|
324 |
Marshaller m = new Marshaller(writer); |
|
325 |
m.setEncoding("ISO-8859-1"); |
|
326 |
m.marshal(xml.getXmlTag()); |
|
327 |
|
|
328 |
} catch (Exception ex) { |
|
329 |
NotificationManager.addError( |
|
330 |
PluginServices.getText(this, "save_error"), ex); |
|
331 |
} |
|
332 |
getJListSymbols().setModel(newListModel()); |
|
333 |
} |
|
334 |
} |
|
335 |
|
|
263 | 336 |
/** |
264 | 337 |
* This method initializes jPanel1 |
265 | 338 |
* |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/styling/StyleEditor.java | ||
---|---|---|
42 | 42 |
package com.iver.cit.gvsig.gui.styling; |
43 | 43 |
|
44 | 44 |
import java.awt.BorderLayout; |
45 |
import java.awt.Color; |
|
45 | 46 |
import java.awt.Component; |
46 |
import java.awt.Dimension;
|
|
47 |
import java.awt.Cursor;
|
|
47 | 48 |
import java.awt.FlowLayout; |
49 |
import java.awt.Graphics2D; |
|
50 |
import java.awt.Point; |
|
51 |
import java.awt.Rectangle; |
|
52 |
import java.awt.event.ActionEvent; |
|
53 |
import java.awt.event.ActionListener; |
|
54 |
import java.awt.event.MouseEvent; |
|
55 |
import java.awt.geom.Point2D; |
|
56 |
import java.awt.geom.Rectangle2D; |
|
48 | 57 |
|
49 | 58 |
import javax.swing.BorderFactory; |
50 | 59 |
import javax.swing.BoxLayout; |
51 | 60 |
import javax.swing.ButtonGroup; |
61 |
import javax.swing.ImageIcon; |
|
52 | 62 |
import javax.swing.JLabel; |
53 | 63 |
import javax.swing.JPanel; |
54 | 64 |
import javax.swing.JSeparator; |
... | ... | |
58 | 68 |
import org.gvsig.gui.beans.AcceptCancelPanel; |
59 | 69 |
import org.gvsig.gui.beans.swing.JButton; |
60 | 70 |
|
71 |
import sun.awt.windows.WCustomCursor; |
|
72 |
|
|
61 | 73 |
import com.iver.andami.PluginServices; |
62 | 74 |
import com.iver.andami.ui.mdiManager.IWindow; |
63 | 75 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
76 |
import com.iver.cit.gvsig.fmap.core.FPolygon2D; |
|
77 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
78 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
|
64 | 79 |
import com.iver.cit.gvsig.fmap.core.SymbologyFactory; |
65 |
import com.iver.cit.gvsig.fmap.core.styles.ILabelStyle; |
|
66 | 80 |
import com.iver.cit.gvsig.fmap.core.styles.IStyle; |
81 |
import com.iver.cit.gvsig.fmap.core.styles.SimpleLabelStyle; |
|
82 |
import com.iver.cit.gvsig.fmap.core.symbols.SimpleFillSymbol; |
|
83 |
import com.iver.cit.gvsig.fmap.core.symbols.SimpleLineSymbol; |
|
67 | 84 |
|
68 | 85 |
/** |
69 |
* |
|
70 | 86 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
71 |
* |
|
72 | 87 |
*/ |
73 |
/** |
|
74 |
* |
|
75 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
|
76 |
* |
|
77 |
*/ |
|
78 |
public class StyleEditor extends JPanel implements IWindow { |
|
88 |
public class StyleEditor extends JPanel implements IWindow, ActionListener { |
|
79 | 89 |
|
80 | 90 |
private JPanel pnlNorth = null; |
81 | 91 |
private JPanel jPanel = null; |
... | ... | |
84 | 94 |
private JLabel lblTitle; |
85 | 95 |
private StylePreviewer preview; |
86 | 96 |
private JPanel pnlTools; |
87 |
private JToggleButton btnPan; |
|
88 |
private JToggleButton btnNewTextArea; |
|
89 | 97 |
private JTextField txtDesc; |
90 |
private JButton btnBackground; |
|
98 |
private ActionListener okAction = new ActionListener() { |
|
99 |
public void actionPerformed(ActionEvent e) { |
|
100 |
PluginServices.getMDIManager().closeWindow(StyleEditor.this); |
|
101 |
} |
|
102 |
}; |
|
103 |
private ActionListener cancelAction = new ActionListener() { |
|
104 |
public void actionPerformed(ActionEvent e) { |
|
105 |
getStylePreviewer().setStyle(null); |
|
106 |
PluginServices.getMDIManager().closeWindow(StyleEditor.this); |
|
107 |
}; |
|
108 |
}; |
|
91 | 109 |
|
92 |
|
|
93 | 110 |
public StyleEditor(IStyle style) { |
94 | 111 |
if (style!=null) { |
95 | 112 |
IStyle sty = SymbologyFactory.createStyleFromXML(style.getXMLEntity(), style.getDescription()); |
... | ... | |
156 | 173 |
return pnlCenter; |
157 | 174 |
} |
158 | 175 |
|
176 |
private StylePreviewer getStylePreviewer() { |
|
177 |
if (preview == null) { |
|
178 |
preview = new StylePreviewer(); |
|
179 |
preview.setShowOutline(true); |
|
180 |
} |
|
181 |
|
|
182 |
return preview; |
|
183 |
} |
|
184 |
|
|
185 |
/** |
|
186 |
* This method initializes pnlButtons |
|
187 |
* |
|
188 |
* @return javax.swing.JPanel |
|
189 |
*/ |
|
190 |
private JPanel getPnlButtons() { |
|
191 |
if (pnlButtons == null) { |
|
192 |
pnlButtons = new AcceptCancelPanel(okAction, cancelAction); |
|
193 |
} |
|
194 |
return pnlButtons; |
|
195 |
} |
|
196 |
|
|
197 |
public WindowInfo getWindowInfo() { |
|
198 |
WindowInfo wi = new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE); |
|
199 |
wi.setTitle(PluginServices.getText(this, "edit_style")); |
|
200 |
wi.setWidth(getWidth()+10); |
|
201 |
wi.setHeight(getHeight()); |
|
202 |
return wi; |
|
203 |
} |
|
204 |
|
|
205 |
public IStyle getStyle() { |
|
206 |
return getStylePreviewer().getStyle(); |
|
207 |
} |
|
208 |
|
|
209 |
public void actionPerformed(ActionEvent e) { |
|
210 |
Component c = (Component) e.getSource(); |
|
211 |
if (c.equals(getBtnPan())) { |
|
212 |
getStylePreviewer().setEditorTool(panTool); |
|
213 |
} else if (c.equals(getBtnNewTextArea())) { |
|
214 |
getStylePreviewer().setEditorTool(newTextTool); |
|
215 |
} |
|
216 |
} |
|
217 |
|
|
218 |
|
|
219 |
// to be extracted to a specific toolkit class |
|
220 |
private JToggleButton btnPan; |
|
221 |
private JToggleButton btnNewTextArea; |
|
222 |
private JButton btnBackground; |
|
223 |
private EditorTool panTool = new EditorTool(StyleEditor.this) { |
|
224 |
private Cursor cursor; |
|
225 |
private Point pIni, pEnd; |
|
226 |
public Cursor getCursor() { |
|
227 |
if (cursor == null) { |
|
228 |
ImageIcon cursorImage = new ImageIcon(getClass().getClassLoader().getResource("images/Hand.gif")); |
|
229 |
Point p = new Point(cursorImage.getIconWidth()/2, cursorImage.getIconHeight()/2); |
|
230 |
cursor = new WCustomCursor(cursorImage.getImage(), p, "as?dlfk"); |
|
231 |
|
|
232 |
} |
|
233 |
return cursor; |
|
234 |
} |
|
235 |
|
|
236 |
public void mousePressed(MouseEvent e) { |
|
237 |
Rectangle bounds = getStylePreviewer().getBounds(); |
|
238 |
SimpleLabelStyle sty = (SimpleLabelStyle) getStylePreviewer().getStyle(); |
|
239 |
Point2D marker = sty.getMarkerPoint(); |
|
240 |
pIni = new Point((int) (marker.getX()*bounds.width), bounds.height - (int) (marker.getY()*bounds.height)); |
|
241 |
pEnd = e.getPoint(); |
|
242 |
|
|
243 |
} |
|
244 |
|
|
245 |
public void mouseReleased(MouseEvent e) { |
|
246 |
|
|
247 |
} |
|
248 |
|
|
249 |
public void mouseDragged(MouseEvent e) { |
|
250 |
pEnd = e.getPoint(); |
|
251 |
Rectangle bounds = getStylePreviewer().getBounds(); |
|
252 |
double xOffset = (pEnd.getX() - pIni.getX())/bounds.getWidth(); |
|
253 |
double yOffset = (pEnd.getY() - pIni.getY())/bounds.getHeight(); |
|
254 |
SimpleLabelStyle sty = (SimpleLabelStyle) getStylePreviewer().getStyle(); |
|
255 |
Point2D marker = sty.getMarkerPoint(); |
|
256 |
marker.setLocation(xOffset, -yOffset); |
|
257 |
|
|
258 |
repaint(); |
|
259 |
} |
|
260 |
|
|
261 |
}; |
|
262 |
private EditorTool newTextTool = new EditorTool(StyleEditor.this) { |
|
263 |
private /*static*/ final Cursor cursor = Cursor.getDefaultCursor(); |
|
264 |
private Point pIni, pEnd; |
|
265 |
public Cursor getCursor() { |
|
266 |
return cursor; |
|
267 |
} |
|
268 |
|
|
269 |
public void mousePressed(MouseEvent e) { |
|
270 |
pIni = e.getPoint(); |
|
271 |
pEnd = e.getPoint(); |
|
272 |
|
|
273 |
} |
|
274 |
public void mouseReleased(MouseEvent e) { |
|
275 |
|
|
276 |
} |
|
277 |
|
|
278 |
public void mouseDragged(MouseEvent e) { |
|
279 |
pEnd = e.getPoint(); |
|
280 |
|
|
281 |
int minx = pIni.x; |
|
282 |
int miny = pIni.y; |
|
283 |
int width = pEnd.x-pIni.x; |
|
284 |
int height = pEnd.y - pIni.y; |
|
285 |
if (width < 0) { |
|
286 |
minx += width; |
|
287 |
width = -width; |
|
288 |
} |
|
289 |
if (height <0) { |
|
290 |
miny += height; |
|
291 |
height = -height; |
|
292 |
} |
|
293 |
|
|
294 |
|
|
295 |
SimpleLabelStyle sty = (SimpleLabelStyle) getStylePreviewer().getStyle(); |
|
296 |
Rectangle bounds = getStylePreviewer().getBounds(); |
|
297 |
Rectangle2D rect = new Rectangle2D.Double( |
|
298 |
minx/bounds.getWidth(), |
|
299 |
miny/bounds.getHeight(), |
|
300 |
width/bounds.getWidth(), |
|
301 |
height/bounds.getHeight() |
|
302 |
); |
|
303 |
sty.setTextFieldArea(0, rect); |
|
304 |
repaint(); |
|
305 |
} |
|
306 |
}; |
|
307 |
|
|
159 | 308 |
private JPanel getPnlTools() { |
160 | 309 |
if (pnlTools == null) { |
161 | 310 |
pnlTools = new JPanel(); |
... | ... | |
186 | 335 |
private JToggleButton getBtnNewTextArea() { |
187 | 336 |
if (btnNewTextArea == null) { |
188 | 337 |
btnNewTextArea = new JToggleButton("new_text"); |
338 |
btnNewTextArea.addActionListener(this); |
|
189 | 339 |
} |
190 | 340 |
return btnNewTextArea; |
191 | 341 |
} |
... | ... | |
193 | 343 |
private JToggleButton getBtnPan() { |
194 | 344 |
if (btnPan == null) { |
195 | 345 |
btnPan = new JToggleButton("pan"); |
196 |
|
|
346 |
btnPan.addActionListener(this); |
|
197 | 347 |
} |
198 | 348 |
|
199 | 349 |
return btnPan; |
200 | 350 |
} |
201 | 351 |
|
202 |
private StylePreviewer getStylePreviewer() { |
|
203 |
if (preview == null) { |
|
204 |
preview = new StylePreviewer(); |
|
205 |
preview.setShowOutline(true); |
|
206 |
} |
|
207 |
|
|
208 |
return preview; |
|
209 |
} |
|
210 |
|
|
211 |
/** |
|
212 |
* This method initializes pnlButtons |
|
213 |
* |
|
214 |
* @return javax.swing.JPanel |
|
215 |
*/ |
|
216 |
private JPanel getPnlButtons() { |
|
217 |
if (pnlButtons == null) { |
|
218 |
pnlButtons = new AcceptCancelPanel(); |
|
219 |
} |
|
220 |
return pnlButtons; |
|
221 |
} |
|
222 |
|
|
223 |
public WindowInfo getWindowInfo() { |
|
224 |
WindowInfo wi = new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE); |
|
225 |
wi.setTitle(PluginServices.getText(this, "edit_style")); |
|
226 |
wi.setWidth(getWidth()+10); |
|
227 |
wi.setHeight(getHeight()); |
|
228 |
return wi; |
|
229 |
} |
|
230 | 352 |
} // @jve:decl-index=0:visual-constraint="10,10" |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/styling/AbstractTypeSymbolEditorPanel.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.2 2007-03-09 11:25:00 jaume |
|
46 |
* Revision 1.3 2007-04-05 16:08:34 jaume |
|
47 |
* Styled labeling stuff |
|
48 |
* |
|
49 |
* Revision 1.2 2007/03/09 11:25:00 jaume |
|
47 | 50 |
* Advanced symbology (start committing) |
48 | 51 |
* |
49 | 52 |
* Revision 1.1.2.3 2007/02/21 07:35:14 jaume |
... | ... | |
80 | 83 |
*/ |
81 | 84 |
package com.iver.cit.gvsig.gui.styling; |
82 | 85 |
|
83 |
import java.awt.event.ActionEvent; |
|
84 |
import java.awt.event.ActionListener; |
|
85 |
|
|
86 | 86 |
import javax.swing.JPanel; |
87 | 87 |
|
88 | 88 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
89 |
import com.iver.utiles.XMLEntity; |
|
90 | 89 |
/** |
91 | 90 |
* Abstract class that all the Symbol settings interface must extend. |
92 | 91 |
* |
... | ... | |
160 | 159 |
* @return <b>Class</b> (of the concrete ISymbol that this configuration panel deals with) |
161 | 160 |
*/ |
162 | 161 |
public abstract Class getSymbolClass(); |
162 |
|
|
163 |
public abstract EditorTool getEditorTool(); |
|
164 |
|
|
165 |
|
|
163 | 166 |
} |
164 | 167 |
|
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/styling/EditorTool.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package com.iver.cit.gvsig.gui.styling; |
|
42 |
|
|
43 |
import java.awt.Cursor; |
|
44 |
import java.awt.event.MouseEvent; |
|
45 |
import java.awt.event.MouseListener; |
|
46 |
import java.awt.event.MouseMotionListener; |
|
47 |
|
|
48 |
import javax.swing.JComponent; |
|
49 |
|
|
50 |
/** |
|
51 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
|
52 |
*/ |
|
53 |
public abstract class EditorTool implements MouseListener, MouseMotionListener { |
|
54 |
|
|
55 |
private JComponent owner; |
|
56 |
|
|
57 |
public EditorTool(JComponent targetEditor) { |
|
58 |
super(); |
|
59 |
owner = targetEditor; |
|
60 |
} |
|
61 |
public abstract Cursor getCursor(); |
|
62 |
|
|
63 |
public void mouseClicked(MouseEvent e) {} |
|
64 |
|
|
65 |
public void mouseEntered(MouseEvent e) { |
|
66 |
owner.setCursor(getCursor()); |
|
67 |
} |
|
68 |
|
|
69 |
public void mouseExited(MouseEvent e) { |
|
70 |
owner.setCursor(Cursor.getDefaultCursor()); |
|
71 |
} |
|
72 |
|
|
73 |
public void mouseMoved(MouseEvent e) { } |
|
74 |
} |
|
0 | 75 |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/styling/MarkerFill.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.6 2007-04-04 16:01:14 jaume |
|
46 |
* Revision 1.7 2007-04-05 16:08:34 jaume |
|
47 |
* Styled labeling stuff |
|
48 |
* |
|
49 |
* Revision 1.6 2007/04/04 16:01:14 jaume |
|
47 | 50 |
* *** empty log message *** |
48 | 51 |
* |
49 | 52 |
* Revision 1.5 2007/03/28 16:44:08 jaume |
... | ... | |
335 | 338 |
return mfs; |
336 | 339 |
} |
337 | 340 |
|
341 |
public EditorTool getEditorTool() { |
|
342 |
return null; |
|
343 |
} |
|
338 | 344 |
} |
Also available in: Unified diff