Revision 1671
org.gvsig.legend.aggregate/trunk/org.gvsig.legend.aggregate/pom.xml | ||
---|---|---|
9 | 9 |
<parent> |
10 | 10 |
<groupId>org.gvsig</groupId> |
11 | 11 |
<artifactId>org.gvsig.desktop</artifactId> |
12 |
<version>2.0.195</version>
|
|
12 |
<version>2.0.198-SNAPSHOT</version>
|
|
13 | 13 |
</parent> |
14 | 14 |
|
15 | 15 |
<url>https://devel.gvsig.org/sites/org.gvsig.legend.aggregate/${project.version}</url> |
org.gvsig.legend.aggregate/trunk/org.gvsig.legend.aggregate/org.gvsig.legend.aggregate.lib/org.gvsig.legend.aggregate.lib.api/src/main/java/org/gvsig/legend/aggregate/lib/api/AggregateLegendManager.java | ||
---|---|---|
22 | 22 |
*/ |
23 | 23 |
package org.gvsig.legend.aggregate.lib.api; |
24 | 24 |
|
25 |
import org.gvsig.tools.service.Manager;
|
|
25 |
import org.gvsig.fmap.mapcontext.rendering.symbols.styles.ILabelStyle;
|
|
26 | 26 |
|
27 | 27 |
|
28 | 28 |
public interface AggregateLegendManager { |
... | ... | |
32 | 32 |
* |
33 | 33 |
* @return the aggregate legend |
34 | 34 |
*/ |
35 |
public AggregateLegend create(); |
|
35 |
public AggregateLegend createAggregateLegend();
|
|
36 | 36 |
|
37 | 37 |
public Class<? extends AggregateLegend> getLegendClass(); |
38 |
|
|
39 |
public ILabelStyle getDefaultLabelStyle(); |
|
40 |
|
|
41 |
public void setDefaultLabelStyle(ILabelStyle defaultLabelStyle); |
|
38 | 42 |
} |
org.gvsig.legend.aggregate/trunk/org.gvsig.legend.aggregate/org.gvsig.legend.aggregate.lib/org.gvsig.legend.aggregate.lib.api/src/main/java/org/gvsig/legend/aggregate/lib/api/AggregateLegend.java | ||
---|---|---|
1 | 1 |
package org.gvsig.legend.aggregate.lib.api; |
2 | 2 |
|
3 | 3 |
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend; |
4 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ITextSymbol; |
|
5 |
import org.gvsig.fmap.mapcontext.rendering.symbols.styles.ILabelStyle; |
|
4 | 6 |
|
5 | 7 |
public interface AggregateLegend extends IVectorLegend { |
6 | 8 |
|
7 | 9 |
public int getDistance(); |
8 | 10 |
public void setDistance(int distance); |
11 |
|
|
12 |
public ILabelStyle getLabelStyle(); |
|
13 |
public void setLabelStyle(ILabelStyle labelStyle); |
|
14 |
|
|
15 |
public ITextSymbol getTextSymbol(); |
|
16 |
public void setTextSymbol(ITextSymbol textSymbol); |
|
9 | 17 |
} |
10 | 18 |
|
11 | 19 |
|
org.gvsig.legend.aggregate/trunk/org.gvsig.legend.aggregate/org.gvsig.legend.aggregate.lib/org.gvsig.legend.aggregate.lib.api/src/main/java/org/gvsig/legend/aggregate/lib/api/AggregateLegendLocator.java | ||
---|---|---|
22 | 22 |
*/ |
23 | 23 |
package org.gvsig.legend.aggregate.lib.api; |
24 | 24 |
|
25 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
|
25 | 26 |
import org.gvsig.tools.locator.AbstractLocator; |
26 | 27 |
import org.gvsig.tools.locator.Locator; |
27 | 28 |
import org.gvsig.tools.locator.LocatorException; |
28 | 29 |
org.gvsig.legend.aggregate/trunk/org.gvsig.legend.aggregate/org.gvsig.legend.aggregate.lib/org.gvsig.legend.aggregate.lib.impl/src/main/java/org/gvsig/legend/aggregate/lib/impl/DefaultAggregateLegend.java | ||
---|---|---|
1 | 1 |
package org.gvsig.legend.aggregate.lib.impl; |
2 | 2 |
|
3 |
import java.awt.Color; |
|
3 | 4 |
import java.awt.Graphics2D; |
5 |
import java.awt.Rectangle; |
|
6 |
import java.awt.Shape; |
|
7 |
import java.awt.Stroke; |
|
4 | 8 |
import java.awt.geom.AffineTransform; |
5 | 9 |
import java.awt.geom.Rectangle2D; |
6 | 10 |
import java.awt.image.BufferedImage; |
11 |
import static java.lang.invoke.MethodHandles.identity; |
|
7 | 12 |
import java.util.ArrayList; |
8 | 13 |
import java.util.List; |
9 | 14 |
import java.util.Map; |
... | ... | |
21 | 26 |
import org.gvsig.fmap.mapcontext.rendering.legend.LegendException; |
22 | 27 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
23 | 28 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ITextSymbol; |
29 |
import org.gvsig.fmap.mapcontext.rendering.symbols.styles.ILabelStyle; |
|
24 | 30 |
import org.gvsig.legend.aggregate.lib.api.AggregateLegend; |
31 |
import org.gvsig.legend.aggregate.lib.api.AggregateLegendLocator; |
|
25 | 32 |
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.AbstractVectorialLegend; |
26 | 33 |
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.DefaultFeatureDrawnNotification; |
27 | 34 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.text.impl.SimpleTextSymbol; |
28 | 35 |
import org.gvsig.tools.exception.BaseException; |
36 |
import org.gvsig.tools.logger.FilteredLogger; |
|
29 | 37 |
import org.gvsig.tools.task.Cancellable; |
30 | 38 |
import org.gvsig.tools.visitor.VisitCanceledException; |
31 | 39 |
import org.gvsig.tools.visitor.Visitor; |
40 |
import org.slf4j.Logger; |
|
41 |
import org.slf4j.LoggerFactory; |
|
32 | 42 |
|
33 | 43 |
public class DefaultAggregateLegend extends AbstractVectorialLegend implements AggregateLegend { |
34 | 44 |
|
35 |
private static class Marker {
|
|
45 |
private static class Group {
|
|
36 | 46 |
|
37 | 47 |
private final Point pointGeo; |
38 | 48 |
private final Point pointPixels; |
39 | 49 |
private int count; |
40 | 50 |
private final Rectangle2D rectangle; |
41 | 51 |
|
42 |
public Marker(Point pointGeo, Point pointPixels, double distance) {
|
|
52 |
public Group(Point pointGeo, Point pointPixels, double distance) {
|
|
43 | 53 |
this.count = 1; |
44 | 54 |
this.pointGeo = pointGeo; |
45 | 55 |
this.pointPixels = pointPixels; |
... | ... | |
56 | 66 |
} |
57 | 67 |
} |
58 | 68 |
|
69 |
private static final Logger LOG = LoggerFactory.getLogger(DefaultAggregateLegend.class); |
|
70 |
|
|
59 | 71 |
private int distance; // Pixels |
60 |
private List<Marker> markers; |
|
61 |
private final ITextSymbol defaultSymbol; |
|
62 |
|
|
72 |
private List<Group> groups; |
|
73 |
private ITextSymbol textSymbol; |
|
74 |
private ILabelStyle labelStyle; |
|
75 |
|
|
63 | 76 |
public DefaultAggregateLegend() { |
64 |
this.defaultSymbol = new SimpleTextSymbol(); |
|
65 |
this.markers = null; |
|
77 |
this.textSymbol = new SimpleTextSymbol(); |
|
78 |
this.labelStyle = null; |
|
79 |
this.groups = null; |
|
66 | 80 |
this.distance = 30; |
67 | 81 |
} |
68 | 82 |
|
69 | 83 |
@Override |
70 | 84 |
protected String[] getRequiredFeatureAttributeNames(FeatureStore featureStore) throws DataException { |
71 |
return new String[] { featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName() }; |
|
85 |
return new String[]{ |
|
86 |
featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName()}; |
|
72 | 87 |
} |
73 | 88 |
|
74 | 89 |
@Override |
75 | 90 |
public ISymbol getDefaultSymbol() { |
76 |
return this.defaultSymbol;
|
|
91 |
return this.textSymbol;
|
|
77 | 92 |
} |
78 | 93 |
|
79 | 94 |
@Override |
... | ... | |
82 | 97 |
|
83 | 98 |
@Override |
84 | 99 |
public ISymbol getSymbolByFeature(Feature ftr) throws MapContextException { |
85 |
return this.defaultSymbol;
|
|
100 |
return this.textSymbol;
|
|
86 | 101 |
} |
87 | 102 |
|
88 | 103 |
@Override |
... | ... | |
110 | 125 |
|
111 | 126 |
@Override |
112 | 127 |
protected void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale, Map queryParameters, ICoordTrans coordTrans, FeatureStore featureStore, FeatureQuery featureQuery, double dpi) throws LegendException { |
113 |
super.draw(image, g, viewPort, cancel, scale, queryParameters, coordTrans, featureStore, featureQuery, dpi);
|
|
128 |
super.draw(image, g, viewPort, cancel, scale, queryParameters, coordTrans, featureStore, featureQuery, dpi); |
|
114 | 129 |
this.drawMarkers(image, g, cancel, viewPort.getAffineTransform()); |
115 | 130 |
} |
116 | 131 |
|
117 | 132 |
@Override |
118 | 133 |
protected void drawFeatures( |
119 |
BufferedImage image,
|
|
120 |
Graphics2D g,
|
|
121 |
final ViewPort viewPort,
|
|
122 |
final Cancellable cancel,
|
|
123 |
final ICoordTrans coordTrans,
|
|
124 |
double dpi,
|
|
125 |
DefaultFeatureDrawnNotification drawnNotification,
|
|
126 |
FeatureSet featureSet,
|
|
134 |
BufferedImage image, |
|
135 |
Graphics2D g, |
|
136 |
final ViewPort viewPort, |
|
137 |
final Cancellable cancel, |
|
138 |
final ICoordTrans coordTrans, |
|
139 |
double dpi, |
|
140 |
DefaultFeatureDrawnNotification drawnNotification, |
|
141 |
FeatureSet featureSet, |
|
127 | 142 |
FeatureSelection selection |
128 |
) throws BaseException {
|
|
129 |
this.markers = new ArrayList<>();
|
|
143 |
) throws BaseException { |
|
144 |
this.groups = new ArrayList<>();
|
|
130 | 145 |
featureSet.accept(new Visitor() { |
131 | 146 |
@Override |
132 | 147 |
public void visit(Object o) throws VisitCanceledException, BaseException { |
... | ... | |
137 | 152 |
Geometry geom = feature.getDefaultGeometry(); |
138 | 153 |
if( geom != null ) { |
139 | 154 |
Point pointGeo = geom.centroid(); |
140 |
if( coordTrans!=null ) {
|
|
155 |
if( coordTrans != null ) {
|
|
141 | 156 |
pointGeo.reProject(coordTrans); |
142 | 157 |
} |
143 | 158 |
Point pointPixels = (Point) pointGeo.cloneGeometry(); |
144 | 159 |
pointPixels.transform(viewPort.getAffineTransform()); |
145 |
boolean newMarker = true; |
|
146 |
for( Marker marker : markers ) { |
|
147 |
if( marker.contains(pointPixels) ) { |
|
148 |
marker.add(feature); |
|
149 |
newMarker = false; |
|
160 |
boolean inGroup = false; |
|
161 |
for( Group group : groups ) { |
|
162 |
if( group.contains(pointPixels) ) { |
|
163 |
group.add(feature); |
|
164 |
inGroup = true; |
|
165 |
break; |
|
150 | 166 |
} |
151 | 167 |
} |
152 |
if( newMarker ) {
|
|
153 |
markers.add(new Marker(pointGeo, pointPixels, getDistance()));
|
|
168 |
if( !inGroup ) {
|
|
169 |
groups.add(new Group(pointGeo, pointPixels, getDistance()));
|
|
154 | 170 |
} |
155 | 171 |
} |
156 | 172 |
} |
157 | 173 |
}); |
158 | 174 |
} |
159 | 175 |
|
160 |
private void drawMarkers(BufferedImage image, Graphics2D g, Cancellable cancel, AffineTransform affineTransform) { |
|
161 |
ITextSymbol symbol = this.defaultSymbol; |
|
162 |
for( Marker marker : markers ) { |
|
176 |
private void drawMarkers(BufferedImage image, Graphics2D g1, Cancellable cancel, AffineTransform affineTransform) { |
|
177 |
FilteredLogger logger = new FilteredLogger(LOG, "", 10); |
|
178 |
AffineTransform identity = new AffineTransform(); |
|
179 |
Stroke stroke = g1.getStroke(); |
|
180 |
Color circlebg = new Color(0xe29ea8); |
|
181 |
for( Group group : groups ) { |
|
163 | 182 |
if( cancel.isCanceled() ) { |
164 | 183 |
return; |
165 | 184 |
} |
166 |
symbol.setDrawWithHalo(true); |
|
167 |
symbol.setText(String.valueOf(marker.count)); |
|
168 |
symbol.draw(g, affineTransform, marker.pointGeo, null, cancel); |
|
185 |
final Graphics2D g = (Graphics2D)g1.create(); |
|
186 |
try { |
|
187 |
int x = (int) group.pointPixels.getX(); |
|
188 |
int y = (int) group.pointPixels.getY(); |
|
189 |
this.textSymbol.setDrawWithHalo(false); |
|
190 |
this.textSymbol.setText(String.valueOf(group.count)); |
|
191 |
if( this.labelStyle != null ) { |
|
192 |
Rectangle bounds = this.textSymbol.getBounds(); |
|
193 |
this.labelStyle.setTextFields(new String[]{ |
|
194 |
String.valueOf(group.count)} |
|
195 |
); |
|
196 |
bounds = new Rectangle( |
|
197 |
bounds.width + 6, |
|
198 |
bounds.height + 6 |
|
199 |
); |
|
200 |
g.setTransform(identity); |
|
201 |
g.translate(x, -y); |
|
202 |
this.labelStyle.drawInsideRectangle(g, bounds); |
|
203 |
} else { |
|
204 |
int r = distance/2 + 6; |
|
205 |
g.setStroke(stroke); |
|
206 |
g.setColor(circlebg); |
|
207 |
g.fillOval( x-(r/2), y-(r/2), r, r); |
|
208 |
g.setColor(Color.BLACK); |
|
209 |
g.drawOval( x-(r/2), y-(r/2), r, r); |
|
210 |
g.translate(- distance/4, distance/4); // ?4? |
|
211 |
this.textSymbol.draw(g, affineTransform, group.pointGeo, null, cancel); |
|
212 |
} |
|
213 |
} catch (Exception ex) { |
|
214 |
logger.warn("Can't draw group",ex); |
|
215 |
} finally { |
|
216 |
g.dispose(); |
|
217 |
} |
|
169 | 218 |
} |
170 | 219 |
} |
171 | 220 |
|
172 |
|
|
173 |
/** |
|
174 |
* @return the distance |
|
175 |
*/ |
|
221 |
@Override |
|
176 | 222 |
public int getDistance() { |
177 | 223 |
return distance; |
178 | 224 |
} |
179 | 225 |
|
180 |
/** |
|
181 |
* @param distance the distance to set |
|
182 |
*/ |
|
226 |
@Override |
|
183 | 227 |
public void setDistance(int distance) { |
184 | 228 |
this.distance = distance; |
185 | 229 |
} |
186 | 230 |
|
231 |
@Override |
|
232 |
public ILabelStyle getLabelStyle() { |
|
233 |
return this.labelStyle; |
|
234 |
} |
|
235 |
|
|
236 |
@Override |
|
237 |
public void setLabelStyle(ILabelStyle labelStyle) { |
|
238 |
this.labelStyle = labelStyle; |
|
239 |
} |
|
240 |
|
|
241 |
@Override |
|
242 |
public ITextSymbol getTextSymbol() { |
|
243 |
return this.textSymbol; |
|
244 |
} |
|
245 |
|
|
246 |
@Override |
|
247 |
public void setTextSymbol(ITextSymbol textSymbol) { |
|
248 |
this.textSymbol = textSymbol; |
|
249 |
} |
|
250 |
|
|
187 | 251 |
} |
org.gvsig.legend.aggregate/trunk/org.gvsig.legend.aggregate/org.gvsig.legend.aggregate.lib/org.gvsig.legend.aggregate.lib.impl/src/main/java/org/gvsig/legend/aggregate/lib/impl/DefaultAggregateLegendManager.java | ||
---|---|---|
22 | 22 |
*/ |
23 | 23 |
package org.gvsig.legend.aggregate.lib.impl; |
24 | 24 |
|
25 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
|
26 |
import org.gvsig.fmap.mapcontext.rendering.symbols.styles.ILabelStyle; |
|
25 | 27 |
import org.gvsig.legend.aggregate.lib.api.AggregateLegend; |
26 | 28 |
import org.gvsig.legend.aggregate.lib.api.AggregateLegendManager; |
29 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.SimpleLabelStyle; |
|
27 | 30 |
|
28 | 31 |
|
29 | 32 |
public class DefaultAggregateLegendManager implements AggregateLegendManager { |
30 | 33 |
|
34 |
private ILabelStyle defaultLabelStyle = null; |
|
35 |
|
|
36 |
public DefaultAggregateLegendManager() { |
|
37 |
this.defaultLabelStyle = new SimpleLabelStyle(); |
|
38 |
} |
|
39 |
|
|
31 | 40 |
@Override |
32 |
public AggregateLegend create() { |
|
41 |
public AggregateLegend createAggregateLegend() {
|
|
33 | 42 |
return new DefaultAggregateLegend(); |
34 | 43 |
} |
35 | 44 |
|
... | ... | |
38 | 47 |
return DefaultAggregateLegend.class; |
39 | 48 |
} |
40 | 49 |
|
50 |
@Override |
|
51 |
public ILabelStyle getDefaultLabelStyle() { |
|
52 |
return this.defaultLabelStyle; |
|
53 |
} |
|
54 |
|
|
55 |
@Override |
|
56 |
public void setDefaultLabelStyle(ILabelStyle defaultLabelStyle) { |
|
57 |
this.defaultLabelStyle = defaultLabelStyle; |
|
58 |
} |
|
59 |
|
|
41 | 60 |
} |
42 | 61 |
org.gvsig.legend.aggregate/trunk/org.gvsig.legend.aggregate/org.gvsig.legend.aggregate.swing/org.gvsig.legend.aggregate.swing.impl/src/main/java/org/gvsig/legend/aggregate/swing/impl/DefaultAggregateLegendEditorView.java | ||
---|---|---|
4 | 4 |
import com.jgoodies.forms.layout.CellConstraints; |
5 | 5 |
import com.jgoodies.forms.layout.FormLayout; |
6 | 6 |
import java.awt.BorderLayout; |
7 |
import java.awt.Color; |
|
7 | 8 |
import java.awt.ComponentOrientation; |
8 | 9 |
import java.awt.Container; |
9 | 10 |
import java.awt.Dimension; |
10 | 11 |
import javax.swing.Box; |
11 | 12 |
import javax.swing.ImageIcon; |
13 |
import javax.swing.JButton; |
|
12 | 14 |
import javax.swing.JFrame; |
13 | 15 |
import javax.swing.JLabel; |
14 | 16 |
import javax.swing.JPanel; |
... | ... | |
19 | 21 |
{ |
20 | 22 |
JLabel lblDistance = new JLabel(); |
21 | 23 |
JTextField txtDistance = new JTextField(); |
24 |
JLabel lblStyle = new JLabel(); |
|
25 |
JTextField txtStyle = new JTextField(); |
|
26 |
JButton btnStyle = new JButton(); |
|
22 | 27 |
|
23 | 28 |
/** |
24 | 29 |
* Default constructor |
... | ... | |
110 | 115 |
public JPanel createPanel() |
111 | 116 |
{ |
112 | 117 |
JPanel jpanel1 = new JPanel(); |
113 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE");
|
|
118 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE");
|
|
114 | 119 |
CellConstraints cc = new CellConstraints(); |
115 | 120 |
jpanel1.setLayout(formlayout1); |
116 | 121 |
|
... | ... | |
119 | 124 |
jpanel1.add(lblDistance,cc.xy(2,2)); |
120 | 125 |
|
121 | 126 |
txtDistance.setName("txtDistance"); |
122 |
jpanel1.add(txtDistance,cc.xy(4,2));
|
|
127 |
jpanel1.add(txtDistance,cc.xywh(4,2,3,1));
|
|
123 | 128 |
|
124 |
addFillComponents(jpanel1,new int[]{ 1,2,3,4,5 },new int[]{ 1,2,3 }); |
|
129 |
lblStyle.setName("lblStyle"); |
|
130 |
lblStyle.setText("Style"); |
|
131 |
jpanel1.add(lblStyle,cc.xy(2,4)); |
|
132 |
|
|
133 |
txtStyle.setBackground(new Color(236,233,216)); |
|
134 |
txtStyle.setEditable(false); |
|
135 |
txtStyle.setName("txtStyle"); |
|
136 |
jpanel1.add(txtStyle,cc.xy(4,4)); |
|
137 |
|
|
138 |
btnStyle.setActionCommand("..."); |
|
139 |
btnStyle.setName("btnStyle"); |
|
140 |
btnStyle.setText("..."); |
|
141 |
jpanel1.add(btnStyle,cc.xy(6,4)); |
|
142 |
|
|
143 |
addFillComponents(jpanel1,new int[]{ 1,2,3,4,5,6,7 },new int[]{ 1,2,3,4,5 }); |
|
125 | 144 |
return jpanel1; |
126 | 145 |
} |
127 | 146 |
|
org.gvsig.legend.aggregate/trunk/org.gvsig.legend.aggregate/org.gvsig.legend.aggregate.swing/org.gvsig.legend.aggregate.swing.impl/src/main/java/org/gvsig/legend/aggregate/swing/impl/DefaultAggregateLegendEditor.java | ||
---|---|---|
1 | 1 |
|
2 | 2 |
package org.gvsig.legend.aggregate.swing.impl; |
3 | 3 |
|
4 |
import java.awt.event.ActionEvent; |
|
5 |
import java.awt.event.ActionListener; |
|
4 | 6 |
import javax.swing.ImageIcon; |
5 | 7 |
import javax.swing.JPanel; |
8 |
import org.gvsig.app.gui.styling.StyleSelector; |
|
9 |
import org.gvsig.fmap.geom.Geometry; |
|
6 | 10 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
7 | 11 |
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend; |
12 |
import org.gvsig.fmap.mapcontext.rendering.symbols.styles.ILabelStyle; |
|
8 | 13 |
import org.gvsig.legend.aggregate.lib.api.AggregateLegend; |
9 | 14 |
import org.gvsig.legend.aggregate.lib.api.AggregateLegendLocator; |
10 | 15 |
import org.gvsig.legend.aggregate.swing.api.AggregateLegendEditor; |
11 | 16 |
import org.gvsig.tools.ToolsLocator; |
12 | 17 |
import org.gvsig.tools.i18n.I18nManager; |
18 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
19 |
import org.gvsig.tools.swing.api.windowmanager.Dialog; |
|
20 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
|
21 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager_v2; |
|
13 | 22 |
|
14 | 23 |
|
15 | 24 |
public class DefaultAggregateLegendEditor extends DefaultAggregateLegendEditorView implements AggregateLegendEditor { |
16 | 25 |
|
17 | 26 |
private static final long serialVersionUID = 4307714097793669675L; |
18 | 27 |
|
28 |
private final Class<? extends AggregateLegend> legendClass; |
|
19 | 29 |
private AggregateLegend legend; |
20 | 30 |
private FLayer layer; |
21 |
private final Class<? extends AggregateLegend> legendClass;
|
|
31 |
private ILabelStyle style;
|
|
22 | 32 |
|
23 | 33 |
public DefaultAggregateLegendEditor() { |
24 | 34 |
this.legendClass = AggregateLegendLocator.getAggregateLegendManager().getLegendClass(); |
35 |
this.btnStyle.addActionListener(new ActionListener() { |
|
36 |
@Override |
|
37 |
public void actionPerformed(ActionEvent e) { |
|
38 |
doSelectLabelStyle(); |
|
39 |
} |
|
40 |
}); |
|
25 | 41 |
} |
26 | 42 |
|
27 | 43 |
@Override |
... | ... | |
30 | 46 |
if( this.getLegendClass().isInstance(legend) ) { |
31 | 47 |
this.legend = (AggregateLegend) legend; |
32 | 48 |
} else { |
33 |
this.legend = AggregateLegendLocator.getAggregateLegendManager().create(); |
|
49 |
this.legend = AggregateLegendLocator.getAggregateLegendManager().createAggregateLegend();
|
|
34 | 50 |
} |
35 | 51 |
this.txtDistance.setText(String.valueOf(this.legend.getDistance())); |
52 |
if( this.legend.getLabelStyle()!=null ) { |
|
53 |
this.txtStyle.setText(this.legend.getLabelStyle().getDescription()); |
|
54 |
} |
|
36 | 55 |
} |
37 | 56 |
|
38 | 57 |
@Override |
... | ... | |
42 | 61 |
try { |
43 | 62 |
d = Integer.parseUnsignedInt(this.txtDistance.getText()); |
44 | 63 |
} catch(Throwable th) { |
45 |
d = 20;
|
|
64 |
d = 30;
|
|
46 | 65 |
} |
47 | 66 |
if( d<10 ) { |
48 | 67 |
d = 10; |
49 | 68 |
} |
50 | 69 |
legend.setDistance(d); |
70 |
legend.setLabelStyle(this.style); |
|
51 | 71 |
return legend; |
52 | 72 |
} |
53 | 73 |
|
... | ... | |
89 | 109 |
return true; |
90 | 110 |
} |
91 | 111 |
|
112 |
private void doSelectLabelStyle() { |
|
113 |
WindowManager_v2 winmanager = (WindowManager_v2) ToolsSwingLocator.getWindowManager(); |
|
114 |
final StyleSelector styleSelector = new StyleSelector(this.style, Geometry.TYPES.POINT); |
|
115 |
winmanager.showWindow( |
|
116 |
styleSelector, |
|
117 |
"Select style", |
|
118 |
WindowManager.MODE.DIALOG |
|
119 |
); |
|
120 |
ILabelStyle x = (ILabelStyle) styleSelector.getSelectedObject(); |
|
121 |
if( x != null ) { |
|
122 |
this.style = x; |
|
123 |
} |
|
124 |
} |
|
92 | 125 |
} |
org.gvsig.legend.aggregate/trunk/org.gvsig.legend.aggregate/org.gvsig.legend.aggregate.swing/org.gvsig.legend.aggregate.swing.impl/src/main/java/org/gvsig/legend/aggregate/swing/impl/DefaultAggregateLegendSwingLibrary.java | ||
---|---|---|
47 | 47 |
@Override |
48 | 48 |
protected void doInitialize() throws LibraryException { |
49 | 49 |
AggregateLegendSwingLocator.registerAggregateLegendSwingManager(DefaultAggregateLegendSwingManager.class); |
50 |
SymbologySwingManager symmnager = SymbologySwingLocator.getSwingManager(); |
|
51 |
symmnager.registerLegendEditor(DefaultAggregateLegendEditor.class); |
|
52 | 50 |
} |
53 | 51 |
|
54 | 52 |
@Override |
55 | 53 |
protected void doPostInitialize() throws LibraryException { |
56 |
|
|
54 |
SymbologySwingManager symmnager = SymbologySwingLocator.getSwingManager(); |
|
55 |
symmnager.registerLegendEditor(DefaultAggregateLegendEditor.class); |
|
57 | 56 |
} |
58 | 57 |
|
59 | 58 |
} |
org.gvsig.legend.aggregate/trunk/org.gvsig.legend.aggregate/org.gvsig.legend.aggregate.swing/org.gvsig.legend.aggregate.swing.impl/src/main/java/org/gvsig/legend/aggregate/swing/impl/DefaultAggregateLegendEditorView.xml | ||
---|---|---|
25 | 25 |
<at name="componentclass">com.jeta.forms.gui.form.FormComponent</at> |
26 | 26 |
</super> |
27 | 27 |
<at name="id">/home/jjdelcerro/datos/devel/org.gvsig.legend.aggregate/org.gvsig.legend.aggregate.swing/org.gvsig.legend.aggregate.swing.impl/src/main/java/org/gvsig/legend/aggregate/swing/impl/DefaultAggregateLegendEditorView.xml</at> |
28 |
<at name="rowspecs">CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE</at> |
|
29 |
<at name="colspecs">FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE</at> |
|
28 |
<at name="rowspecs">CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE</at>
|
|
29 |
<at name="colspecs">FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE</at>
|
|
30 | 30 |
<at name="components"> |
31 | 31 |
<object classname="java.util.LinkedList"> |
32 | 32 |
<item > |
... | ... | |
97 | 97 |
<object classname="com.jeta.forms.store.memento.CellConstraintsMemento"> |
98 | 98 |
<at name="column">4</at> |
99 | 99 |
<at name="row">2</at> |
100 |
<at name="colspan">1</at>
|
|
100 |
<at name="colspan">3</at>
|
|
101 | 101 |
<at name="rowspan">1</at> |
102 | 102 |
<at name="halign">default</at> |
103 | 103 |
<at name="valign">default</at> |
... | ... | |
143 | 143 |
</object> |
144 | 144 |
</at> |
145 | 145 |
</item> |
146 |
<item > |
|
147 |
<at name="value"> |
|
148 |
<object classname="com.jeta.forms.store.memento.BeanMemento"> |
|
149 |
<super classname="com.jeta.forms.store.memento.ComponentMemento"> |
|
150 |
<at name="cellconstraints"> |
|
151 |
<object classname="com.jeta.forms.store.memento.CellConstraintsMemento"> |
|
152 |
<at name="column">2</at> |
|
153 |
<at name="row">4</at> |
|
154 |
<at name="colspan">1</at> |
|
155 |
<at name="rowspan">1</at> |
|
156 |
<at name="halign">default</at> |
|
157 |
<at name="valign">default</at> |
|
158 |
<at name="insets" object="insets">0,0,0,0</at> |
|
159 |
</object> |
|
160 |
</at> |
|
161 |
<at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at> |
|
162 |
</super> |
|
163 |
<at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at> |
|
164 |
<at name="beanclass">com.jeta.forms.components.label.JETALabel</at> |
|
165 |
<at name="beanproperties"> |
|
166 |
<object classname="com.jeta.forms.store.memento.PropertiesMemento"> |
|
167 |
<at name="classname">com.jeta.forms.components.label.JETALabel</at> |
|
168 |
<at name="properties"> |
|
169 |
<object classname="com.jeta.forms.store.support.PropertyMap"> |
|
170 |
<at name="border"> |
|
171 |
<object classname="com.jeta.forms.store.properties.CompoundBorderProperty"> |
|
172 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
173 |
<at name="name">border</at> |
|
174 |
</super> |
|
175 |
<at name="borders"> |
|
176 |
<object classname="java.util.LinkedList"> |
|
177 |
<item > |
|
178 |
<at name="value"> |
|
179 |
<object classname="com.jeta.forms.store.properties.DefaultBorderProperty"> |
|
180 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
181 |
<at name="name">border</at> |
|
182 |
</super> |
|
183 |
</object> |
|
184 |
</at> |
|
185 |
</item> |
|
186 |
</object> |
|
187 |
</at> |
|
188 |
</object> |
|
189 |
</at> |
|
190 |
<at name="name">lblStyle</at> |
|
191 |
<at name="width">49</at> |
|
192 |
<at name="text">Style</at> |
|
193 |
<at name="fill"> |
|
194 |
<object classname="com.jeta.forms.store.properties.effects.PaintProperty"> |
|
195 |
<at name="name">fill</at> |
|
196 |
</object> |
|
197 |
</at> |
|
198 |
<at name="height">14</at> |
|
199 |
</object> |
|
200 |
</at> |
|
201 |
</object> |
|
202 |
</at> |
|
203 |
</object> |
|
204 |
</at> |
|
205 |
</item> |
|
206 |
<item > |
|
207 |
<at name="value"> |
|
208 |
<object classname="com.jeta.forms.store.memento.BeanMemento"> |
|
209 |
<super classname="com.jeta.forms.store.memento.ComponentMemento"> |
|
210 |
<at name="cellconstraints"> |
|
211 |
<object classname="com.jeta.forms.store.memento.CellConstraintsMemento"> |
|
212 |
<at name="column">4</at> |
|
213 |
<at name="row">4</at> |
|
214 |
<at name="colspan">1</at> |
|
215 |
<at name="rowspan">1</at> |
|
216 |
<at name="halign">default</at> |
|
217 |
<at name="valign">default</at> |
|
218 |
<at name="insets" object="insets">0,0,0,0</at> |
|
219 |
</object> |
|
220 |
</at> |
|
221 |
<at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at> |
|
222 |
</super> |
|
223 |
<at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at> |
|
224 |
<at name="beanclass">javax.swing.JTextField</at> |
|
225 |
<at name="beanproperties"> |
|
226 |
<object classname="com.jeta.forms.store.memento.PropertiesMemento"> |
|
227 |
<at name="classname">javax.swing.JTextField</at> |
|
228 |
<at name="properties"> |
|
229 |
<object classname="com.jeta.forms.store.support.PropertyMap"> |
|
230 |
<at name="border"> |
|
231 |
<object classname="com.jeta.forms.store.properties.CompoundBorderProperty"> |
|
232 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
233 |
<at name="name">border</at> |
|
234 |
</super> |
|
235 |
<at name="borders"> |
|
236 |
<object classname="java.util.LinkedList"> |
|
237 |
<item > |
|
238 |
<at name="value"> |
|
239 |
<object classname="com.jeta.forms.store.properties.DefaultBorderProperty"> |
|
240 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
241 |
<at name="name">border</at> |
|
242 |
</super> |
|
243 |
</object> |
|
244 |
</at> |
|
245 |
</item> |
|
246 |
</object> |
|
247 |
</at> |
|
248 |
</object> |
|
249 |
</at> |
|
250 |
<at name="background" object="color">236,233,216</at> |
|
251 |
<at name="editable">false</at> |
|
252 |
<at name="name">txtStyle</at> |
|
253 |
<at name="width">382</at> |
|
254 |
<at name="height">20</at> |
|
255 |
</object> |
|
256 |
</at> |
|
257 |
</object> |
|
258 |
</at> |
|
259 |
</object> |
|
260 |
</at> |
|
261 |
</item> |
|
262 |
<item > |
|
263 |
<at name="value"> |
|
264 |
<object classname="com.jeta.forms.store.memento.BeanMemento"> |
|
265 |
<super classname="com.jeta.forms.store.memento.ComponentMemento"> |
|
266 |
<at name="cellconstraints"> |
|
267 |
<object classname="com.jeta.forms.store.memento.CellConstraintsMemento"> |
|
268 |
<at name="column">6</at> |
|
269 |
<at name="row">4</at> |
|
270 |
<at name="colspan">1</at> |
|
271 |
<at name="rowspan">1</at> |
|
272 |
<at name="halign">default</at> |
|
273 |
<at name="valign">default</at> |
|
274 |
<at name="insets" object="insets">0,0,0,0</at> |
|
275 |
</object> |
|
276 |
</at> |
|
277 |
<at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at> |
|
278 |
</super> |
|
279 |
<at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at> |
|
280 |
<at name="beanclass">javax.swing.JButton</at> |
|
281 |
<at name="beanproperties"> |
|
282 |
<object classname="com.jeta.forms.store.memento.PropertiesMemento"> |
|
283 |
<at name="classname">javax.swing.JButton</at> |
|
284 |
<at name="properties"> |
|
285 |
<object classname="com.jeta.forms.store.support.PropertyMap"> |
|
286 |
<at name="border"> |
|
287 |
<object classname="com.jeta.forms.store.properties.CompoundBorderProperty"> |
|
288 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
289 |
<at name="name">border</at> |
|
290 |
</super> |
|
291 |
<at name="borders"> |
|
292 |
<object classname="java.util.LinkedList"> |
|
293 |
<item > |
|
294 |
<at name="value"> |
|
295 |
<object classname="com.jeta.forms.store.properties.DefaultBorderProperty"> |
|
296 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
297 |
<at name="name">border</at> |
|
298 |
</super> |
|
299 |
</object> |
|
300 |
</at> |
|
301 |
</item> |
|
302 |
</object> |
|
303 |
</at> |
|
304 |
</object> |
|
305 |
</at> |
|
306 |
<at name="actionCommand">...</at> |
|
307 |
<at name="name">btnStyle</at> |
|
308 |
<at name="width">44</at> |
|
309 |
<at name="text">...</at> |
|
310 |
<at name="height">22</at> |
|
311 |
</object> |
|
312 |
</at> |
|
313 |
</object> |
|
314 |
</at> |
|
315 |
</object> |
|
316 |
</at> |
|
317 |
</item> |
|
146 | 318 |
</object> |
147 | 319 |
</at> |
148 | 320 |
<at name="properties"> |
... | ... | |
160 | 332 |
</at> |
161 | 333 |
</object> |
162 | 334 |
</at> |
163 |
<at name="name"/>
|
|
335 |
<at name="name"></at>
|
|
164 | 336 |
<at name="fill"> |
165 | 337 |
<object classname="com.jeta.forms.store.properties.effects.PaintProperty"> |
166 | 338 |
<at name="name">fill</at> |
... | ... | |
200 | 372 |
<at name="cellpainters"> |
201 | 373 |
<object classname="com.jeta.forms.store.support.Matrix"> |
202 | 374 |
<at name="rows"> |
203 |
<object classname="[Ljava.lang.Object;" size="3">
|
|
375 |
<object classname="[Ljava.lang.Object;" size="5">
|
|
204 | 376 |
<at name="item" index="0"> |
205 |
<object classname="[Ljava.lang.Object;" size="5"/>
|
|
377 |
<object classname="[Ljava.lang.Object;" size="7"/>
|
|
206 | 378 |
</at> |
207 | 379 |
<at name="item" index="1"> |
208 |
<object classname="[Ljava.lang.Object;" size="5"/>
|
|
380 |
<object classname="[Ljava.lang.Object;" size="7"/>
|
|
209 | 381 |
</at> |
210 | 382 |
<at name="item" index="2"> |
211 |
<object classname="[Ljava.lang.Object;" size="5"/>
|
|
383 |
<object classname="[Ljava.lang.Object;" size="7"/>
|
|
212 | 384 |
</at> |
385 |
<at name="item" index="3"> |
|
386 |
<object classname="[Ljava.lang.Object;" size="7"/> |
|
387 |
</at> |
|
388 |
<at name="item" index="4"> |
|
389 |
<object classname="[Ljava.lang.Object;" size="7"/> |
|
390 |
</at> |
|
213 | 391 |
</object> |
214 | 392 |
</at> |
215 | 393 |
</object> |
216 | 394 |
Also available in: Unified diff