Revision 10959

View differences:

trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/styles/MarkerFillStyle.java
1 1
package com.iver.cit.gvsig.fmap.core.styles;
2 2

  
3
import java.awt.BasicStroke;
3
import java.awt.Graphics;
4 4
import java.awt.Graphics2D;
5 5
import java.awt.Paint;
6 6
import java.awt.Rectangle;
......
36 36
			sampleSymbol.draw(g, null, p);
37 37
			break;
38 38
		case GRID_FILL:
39
		{
39 40
			int size = (int) sampleSymbol.getSize();
40 41

  
41
			// patch
42
			if (size == 0) {
43
				System.err.println("[MarkerFillStyle] recorda de donar al farciment el tamany del s?mbol (no l'has inicialitzat)");
44
				size = 7;
45
			}
46
			// end patch
47

  
48 42
			Rectangle rProv = new Rectangle();
49 43

  
50 44
			rProv.setFrame(0, 0,size,size);
51

  
52

  
53 45
			Paint resulPatternFill = null;
54 46
			BufferedImage bi = null;
55 47
			bi= new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB);
......
61 53
					RenderingHints.VALUE_ANTIALIAS_ON);
62 54
			g.setPaint(resulPatternFill);
63 55
			g.fill(r);
56
		}
64 57
			break;
65 58
		case RANDOM_FILL:
66
			throw new Error("Not yet implemented");
59
			int x = r.x;
60
			int y = r.y;
61
			int width = r.width;
62
			int height= r.height;
63
			g.setBackground(null);
64

  
65
			sampleSymbol.draw(g, null, new FPoint2D((x+width*0.2), (y+height*0.8)));
66
			sampleSymbol.draw(g, null, new FPoint2D((x+width*0.634), (y+height*0.3)));
67
			sampleSymbol.draw(g, null, new FPoint2D((x+width*0.26), (y+height*0.35)));
68
			sampleSymbol.draw(g, null, new FPoint2D((x+width*0.45), (y+height*0.98)));
69
			sampleSymbol.draw(g, null, new FPoint2D((x+width*0.9), (y+height*0.54)));
70
			sampleSymbol.draw(g, null, new FPoint2D((x+width*1.1), (y+height*0.7)));
71
			break;
67 72
		}
68 73
	}
69 74

  
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/styles/PointLabelPositioneer.java
1
package com.iver.cit.gvsig.fmap.core.styles;
2

  
3
import java.awt.Color;
4
import java.awt.Font;
5
import java.awt.Graphics2D;
6
import java.awt.Rectangle;
7
import java.awt.RenderingHints;
8

  
9
import com.iver.cit.gvsig.fmap.core.FShape;
10
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol;
11
import com.iver.utiles.XMLEntity;
12

  
13
public class PointLabelPositioneer extends AbstractStyle {
14
	private byte[] preferenceVector = new byte[8];
15
	private static final Color[] colorVector = new Color[] {
16
		new Color(140, 140, 140), // gray
17
		new Color(140, 245, 130), // green
18
		new Color(130, 170, 245), // light blue
19
		new Color(100, 100, 255),   // dark blue
20
	};
21

  
22
	public PointLabelPositioneer() {}
23

  
24
	public PointLabelPositioneer(byte[] preferenceVector, String description) {
25
		this.preferenceVector = preferenceVector;
26
		setDescription(description);
27
	}
28

  
29
	public void drawInsideRectangle(Graphics2D g, Rectangle r) {
30
		int size = Math.min(r.width, r.height) / 3;
31
		int j = -1;
32
		final int fontSize = (int) (size * 0.8);
33
		final Font font = new Font("Arial", Font.PLAIN, fontSize);
34
		RenderingHints old = g.getRenderingHints();
35
		g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
36
		for (int i = 0; i < 9; i++) {
37
			if (i == 4) continue;
38
			j++;
39
			int value = Math.abs(preferenceVector[j] % colorVector.length);
40
			int col = i % 3;
41
			int row = i / 3;
42

  
43
			g.setColor(colorVector[value]);
44
			g.fillRect(size * col, size*row, size, size);
45
			g.setColor(Color.BLACK);
46
			g.drawRect(size * col, size*row, size, size);
47
			g.setFont(font);
48
			g.drawString(String.valueOf(value),
49
					(float) ((size/2) - (fontSize/4)) + size * col,
50
					(float) (size * 0.8) + size*row);
51
		}
52
		g.setRenderingHints(old);
53
	}
54

  
55
	public boolean isSuitableFor(ISymbol symbol) {
56
		return symbol.getSymbolType() == FShape.POINT;
57
	}
58

  
59
	public String getClassName() {
60
		return getClass().getName();
61
	}
62

  
63
	public XMLEntity getXMLEntity() {
64
		XMLEntity xml = new XMLEntity();
65
		xml.putProperty("desc", getDescription());
66
		StringBuffer sb = new StringBuffer();
67
		for (int i = 0; i < preferenceVector.length; i++) {
68
			sb.append(preferenceVector[i]+",");
69
		}
70
		String s = sb.substring(0, sb.length()-1);
71
		xml.putProperty("preferenceVector", s);
72
		return xml;
73
	}
74

  
75
	public void setXMLEntity(XMLEntity xml) {
76
		setDescription(xml.getStringProperty("desc"));
77
		String[] ss = xml.getStringArrayProperty("preferenceVector");
78
		for (int i = 0; i < ss.length; i++) {
79
			preferenceVector[i] = (byte) Integer.parseInt(ss[i]);
80
		}
81
	}
82

  
83
}
0 84

  
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/MarkerFillSymbol.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.7  2007-03-26 14:25:17  jaume
46
* Revision 1.8  2007-03-28 16:48:14  jaume
47
* *** empty log message ***
48
*
49
* Revision 1.7  2007/03/26 14:25:17  jaume
47 50
* implements IPrintable
48 51
*
49 52
* Revision 1.6  2007/03/21 17:36:22  jaume
......
107 110
*/
108 111
package com.iver.cit.gvsig.fmap.core.symbols;
109 112

  
110
import java.awt.BasicStroke;
111 113
import java.awt.Graphics2D;
112 114
import java.awt.Paint;
113 115
import java.awt.Rectangle;
......
116 118
import java.awt.TexturePaint;
117 119
import java.awt.geom.AffineTransform;
118 120
import java.awt.geom.Point2D;
121
import java.awt.geom.Rectangle2D;
119 122
import java.awt.image.BufferedImage;
120 123
import java.util.ArrayList;
124
import java.util.Random;
121 125

  
122
import javax.print.attribute.PrintRequestAttribute;
123 126
import javax.print.attribute.PrintRequestAttributeSet;
124 127

  
125 128
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
......
208 211
	}
209 212

  
210 213
	public void draw(Graphics2D g, AffineTransform affineTransform, FShape shp) {
214
		g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
215
				RenderingHints.VALUE_ANTIALIAS_ON);
211 216

  
212 217
		switch (markerFillStyle.getFillStyle()) {
213 218
		case MarkerFillStyle.SINGLE_CENTERED_SYMBOL:
......
218 223
			markerSymbol.draw(g, affineTransform, p);
219 224
			break;
220 225
		case MarkerFillStyle.GRID_FILL:
221

  
222 226
			// case a grid fill is used
227
			{
223 228

  
224
			int w=7;
225
			int h=7;
226

  
229
			int s = (int) markerSymbol.getSize();
227 230
			Rectangle rProv = new Rectangle();
228
			rProv.setFrame(0, 0,w,h);
229

  
231
			rProv.setFrame(0, 0, s, s);
230 232
			Paint resulPatternFill = null;
231 233
			BufferedImage bi = null;
232
			bi= new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
234
			bi= new BufferedImage(s, s, BufferedImage.TYPE_INT_ARGB);
233 235
			Graphics2D gAux = bi.createGraphics();
234 236
			markerSymbol.drawInsideRectangle(gAux, new AffineTransform(), rProv);
235 237
			resulPatternFill = new TexturePaint(bi,rProv);
236 238
			g.setColor(null);
237 239
			g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
238
					RenderingHints.VALUE_ANTIALIAS_ON);
239

  
240
				RenderingHints.VALUE_ANTIALIAS_ON);
240 241
			g.setPaint(resulPatternFill);
241 242
			g.fill(shp);
243

  
244
			}
242 245
			break;
243 246
		case MarkerFillStyle.RANDOM_FILL:
244
			throw new Error("Not Yet Implemented!");
247
			{
248
			double s = markerSymbol.getSize();
249
			Rectangle r = shp.getBounds();
250
			int drawCount = (int) (Math.min(r.getWidth(), r.getHeight())/s);
251
			Random random = new Random();
252

  
253
			int minx = r.x;
254
			int miny = r.y;
255
			int width = r.width;
256
			int height = r.height;
257

  
258
			r = new Rectangle();
259
			g.setClip(shp);
260

  
261
			for (int i = 0; i < drawCount; i++) {
262
				int x = (int) Math.abs(random.nextDouble() * width);
263
				int y = (int) Math.abs(random.nextDouble() * height);
264
				x = x + minx;
265
				y = y + miny;
266
				markerSymbol.draw(g, new AffineTransform(), new FPoint2D(x, y));
267

  
268
			}
269
			g.setClip(null);
270
			}
271
			break;
245 272
		}
246 273
	}
247 274

  
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/SmartTextSymbol.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.2  2007-03-21 17:36:22  jaume
46
* Revision 1.3  2007-03-28 16:48:14  jaume
47 47
* *** empty log message ***
48 48
*
49
* Revision 1.2  2007/03/21 17:36:22  jaume
50
* *** empty log message ***
51
*
49 52
* Revision 1.1  2007/03/09 11:20:56  jaume
50 53
* Advanced symbology (start committing)
51 54
*
......
158 161
	 * be rendered from there and following the rotation previously set.
159 162
	 */
160 163
	public void draw(Graphics2D g, AffineTransform affineTransform, FShape shp) {
164
		if (!isShapeVisible()) return;
161 165
		g.setFont(getFont());
162 166

  
163 167
		g.setColor(Color.BLACK);
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/SimpleTextSymbol.java
29 29
	private double rotation;
30 30

  
31 31
	public void draw(Graphics2D g, AffineTransform affineTransform, FShape shp) {
32
		if (!isShapeVisible()) return;
33

  
32 34
		Point2D p = null;
33 35
		shp.transform(affineTransform);
34 36
		double rot=0;
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/AbstractFillSymbol.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.7  2007-03-21 11:37:00  jaume
46
* Revision 1.8  2007-03-28 16:48:14  jaume
47 47
* *** empty log message ***
48 48
*
49
* Revision 1.7  2007/03/21 11:37:00  jaume
50
* *** empty log message ***
51
*
49 52
* Revision 1.6  2007/03/13 16:58:36  jaume
50 53
* Added QuantityByCategory (Multivariable legend) and some bugfixes in symbols
51 54
*
......
111 114
	}
112 115

  
113 116
	public int getOnePointRgb() {
114
		return (outline != null) ? outline.getOnePointRgb() : color.getRGB();
117
		int rgb = 0;
118
		if (outline != null) {
119
			rgb = outline.getOnePointRgb();
120
		} else if (color != null) {
121
			rgb = color.getRGB();
122
		}
123
		return rgb;
115 124
	}
116 125

  
117 126
	public void setFillColor(Color color) {
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/SimpleLabeling.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.2  2007-03-26 14:40:38  jaume
46
* Revision 1.3  2007-03-28 16:48:01  jaume
47
* *** empty log message ***
48
*
49
* Revision 1.2  2007/03/26 14:40:38  jaume
47 50
* added print method (BUT UNIMPLEMENTED)
48 51
*
49 52
* Revision 1.1  2007/03/20 16:16:20  jaume
......
124 127
		} else {
125 128
			throw new Error("Layer type not yet supported");
126 129
		}
127

  
128
		method = new DefaultLabelingMethod();
129 130
	}
130 131

  
131 132
	public ILabelingMethod getLabelingMethod() {
132 133
		return method;
133 134
	}
134 135

  
135
	public void setLabelingMethod(ILabelingMethod method) {}
136
	public void setLabelingMethod(ILabelingMethod method) {
137
		this.method = method;
138
	}
136 139

  
137 140
	public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort,
138 141
					 Cancellable cancel)
......
140 143

  
141 144
		 Rectangle2D theExtent = viewPort.getAdjustedExtent();
142 145

  
146
		 if (method == null) {
147
			 Logger.getAnonymousLogger().warning("Layer '"+layer.getName()+"'. No labeling method was set, labels will not be drawn");
148
			 return;
149
		 }
150

  
143 151
		 if (zoomConstraints != null) {
144 152
			 double scale = viewPort.getScale();
145 153
			 if (scale < zoomConstraints.getMinScale() ||
......
205 213
		return tp;
206 214
	}
207 215

  
208

  
209

  
210 216
	public String getClassName() {
211 217
		return getClass().getName();
212 218
	}
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/LabelingFactory.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.4  2007-03-20 16:16:20  jaume
46
* Revision 1.5  2007-03-28 16:48:01  jaume
47
* *** empty log message ***
48
*
49
* Revision 1.4  2007/03/20 16:16:20  jaume
47 50
* refactored to use ISymbol instead of FSymbol
48 51
*
49 52
* Revision 1.3  2007/03/09 11:20:57  jaume
......
179 182
		if (method == null && placement == null && zoom == null)
180 183
			return createDefaultStrategy(layer);
181 184

  
182
		return createDefaultStrategy(layer);
185
		ILabelingStrategy strat = createDefaultStrategy(layer);
186
		strat.setLabelingMethod(method);
187
		return strat;
183 188
		/* solament per a proves, ac? falta muntar el sistema expert que
184 189
		 * decidisca quina estrat?gia ?s la millor a partir dels par?metres.
185 190
		 */
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/AttrInTableLabeling.java
8 8
import javax.print.attribute.PrintRequestAttributeSet;
9 9

  
10 10
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
11
import com.hardcode.gdbms.engine.values.NullValue;
11 12
import com.hardcode.gdbms.engine.values.NumericValue;
12 13
import com.hardcode.gdbms.engine.values.StringValue;
13 14
import com.hardcode.gdbms.engine.values.Value;
......
69 70
		this.zoom = constraints;
70 71
	}
71 72

  
72
	public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, Cancellable cancel) throws ReadDriverException {
73
	public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, Cancellable cancel)
74
	throws ReadDriverException {
73 75
		double scale = viewPort.getScale();
74 76
		double fontScaleFactor = FConstant.FONT_HEIGHT_SCALE_FACTOR;
75 77

  
......
101 103
						size = fixedSize * fontScaleFactor;
102 104
					} else if (idHeightField != -1) {
103 105
						// text size is defined in the table
104
						size = ((NumericValue) vv[idHeightField]).doubleValue() * fontScaleFactor;
106
						try {
107
							size = ((NumericValue) vv[idHeightField]).doubleValue() * fontScaleFactor;
108
						} catch (ClassCastException ccEx) {
109
							if (!NullValue.class.equals(vv[idHeightField].getClass())) {
110
								throw new ReadDriverException("Unknown", ccEx);
111
							}
112
							// a null value
113
							Logger.getAnonymousLogger().
114
								warning("Null text height value for text '"+vv[idTextField].toString()+"'");
115
							continue;
116
						}
105 117
					} else {
106 118
						// otherwise will use the size in the symbol
107 119
						size = sym.getFont().getSize();
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/styling/LabelStyleSelector.java
1
package com.iver.cit.gvsig.gui.styling;
2

  
3
import java.awt.Color;
4
import java.awt.Component;
5
import java.awt.Dimension;
6
import java.io.File;
7
import java.util.prefs.Preferences;
8

  
9
import javax.swing.BoxLayout;
10
import javax.swing.JLabel;
11
import javax.swing.JList;
12
import javax.swing.JPanel;
13
import javax.swing.ListCellRenderer;
14
import javax.swing.event.ListSelectionEvent;
15
import javax.swing.event.ListSelectionListener;
16

  
17
import org.gvsig.gui.beans.swing.GridBagLayoutPanel;
18

  
19
import com.iver.andami.PluginServices;
20
import com.iver.cit.gvsig.fmap.core.styles.IStyle;
21
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol;
22

  
23
public class LabelStyleSelector extends SymbolSelector {
24

  
25
	public LabelStyleSelector(ISymbol symbol, int shapeType) {
26
		super(symbol, shapeType, new SelectorFilter() {
27
			public boolean accepts(Object obj) {
28
				return obj instanceof IStyle;
29
			}
30
		});
31
    	Preferences prefs = Preferences.userRoot().node( "gvsig.foldering" );
32
		rootDir = new File(prefs.get("SymbolStylesFolder", System.getProperty("user.home")+"/gvSIG/Styles"));
33
		if (!rootDir.exists())
34
			rootDir.mkdir();
35
		lblTitle.setText(PluginServices.getText(this, "label_styles"));
36
		treeRootName = PluginServices.getText(this, "style_library");
37
	}
38

  
39
	protected SelectorListModel newListModel() {
40
		SelectorListModel listModel = new SelectorListModel(
41
				dir,
42
				selectedElement,
43
				sFilter,
44
				SelectorListModel.STYLE_FILE_EXTENSION);
45
		return listModel;
46

  
47
	}
48
	
49
	protected JPanel getJPanelOptions() {
50
		if (jPanelOptions == null) {
51
			jPanelOptions = new GridBagLayoutPanel();
52
			// nothing in the panel
53

  
54
		}
55
    	return jPanelOptions;
56
    }
57
	
58
    /**
59
     * This method initializes jList
60
     *
61
     * @return javax.swing.JList
62
     */
63
    protected JList getJListSymbols() {
64
    	if (jListSymbols == null) {
65
    		jListSymbols = new JList();
66
    		jListSymbols.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
67
            jListSymbols.setLayoutOrientation(JList.HORIZONTAL_WRAP);
68
            jListSymbols.setVisibleRowCount(-1);
69
            jListSymbols.addListSelectionListener(new ListSelectionListener() {
70
            	public void valueChanged(ListSelectionEvent e) {
71
            		setSymbol(jListSymbols.getSelectedValue());
72
            		updateOptionsPanel();
73
            	}
74
            });
75
            ListCellRenderer renderer = new ListCellRenderer() {
76
        		private Color mySelectedBGColor = new Color(255,145,100,255);
77
    			public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
78
    				IStyle sym = (IStyle) value;
79
    				JPanel pnl = new JPanel();
80
    				BoxLayout layout = new BoxLayout(pnl, BoxLayout.Y_AXIS);
81
    				pnl.setLayout(layout);
82
    				Color bgColor = (isSelected) ? mySelectedBGColor
83
    							 : getJListSymbols().getBackground();
84

  
85
    				pnl.setBackground(bgColor);
86
    				StylePreviewer sp = new StylePreviewer();
87
    				sp.setAlignmentX(Component.CENTER_ALIGNMENT);
88
    				sp.setPreferredSize(new Dimension(50, 50));
89
    				sp.setStyle(sym);
90
    				sp.setBackground(bgColor);
91
    				pnl.add(sp);
92
    				JLabel lbl = new JLabel(sym.getDescription());
93
    				lbl.setBackground(bgColor);
94
    				lbl.setAlignmentX(Component.CENTER_ALIGNMENT);
95
    				pnl.add(lbl);
96

  
97
    				return pnl;
98
    			}
99

  
100
        	};
101
        	jListSymbols.setCellRenderer(renderer);
102
    	}
103
    	return jListSymbols;
104
    }
105

  
106
}
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/styling/MarkerFill.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.4  2007-03-13 16:57:35  jaume
46
* Revision 1.5  2007-03-28 16:44:08  jaume
47
* *** empty log message ***
48
*
49
* Revision 1.4  2007/03/13 16:57:35  jaume
47 50
* Added MultiVariable legend
48 51
*
49 52
* Revision 1.3  2007/03/09 11:25:00  jaume
......
178 181
            aux = new JPanel(new FlowLayout(FlowLayout.LEADING, 5, 5));
179 182
            aux.add(rdGrid);
180 183
            aux.add(rdRandom);
181
            rdGrid.setEnabled(true);
184
            rdGrid.setSelected(true);
182 185
            p.addComponent("", aux);
183 186

  
184 187
            myTab.add(p);
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/styling/SelectorListModel.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.1  2007-03-09 11:25:00  jaume
46
* Revision 1.2  2007-03-28 16:44:08  jaume
47
* *** empty log message ***
48
*
49
* Revision 1.1  2007/03/09 11:25:00  jaume
47 50
* Advanced symbology (start committing)
48 51
*
49 52
* Revision 1.4.2.4  2007/02/21 07:35:14  jaume
......
114 117
import com.iver.utiles.xmlEntity.generate.XmlTag;
115 118

  
116 119
public class SelectorListModel implements ListModel {
117
	
120

  
118 121
	private String fileExtension;
119 122
	public static final String SYMBOL_FILE_EXTENSION = ".sym";
120 123
	public static final String STYLE_FILE_EXTENSION = ".style";
......
125 128
		}
126 129
	};
127 130
	private SelectorFilter sfilter;
128
	private Vector symbols;
131
	private Vector elements;
129 132
	private ArrayList listeners;
130
	private Object currentSymbol;
133
	private Object currentElement;
131 134
	private File dir;
132
	
133
	public SelectorListModel(File dir, Object currentSymbol, SelectorFilter filter, String fileExtension) {
135

  
136
	public SelectorListModel(File dir, Object currentElemet, SelectorFilter filter, String fileExtension) {
134 137
		this.fileExtension = fileExtension;
135 138
		this.dir = dir;
136
		this.currentSymbol = currentSymbol;
139
		this.currentElement = currentElemet;
137 140
		this.sfilter = filter;
138 141
	}
139 142

  
140 143
	public Object remove(int i) throws ArrayIndexOutOfBoundsException {
141
		return symbols.remove(i);
144
		return elements.remove(i);
142 145
	}
143 146

  
144 147
	public void insertAt(int i, Object o) {
......
150 153

  
151 154
			public int compare(Object o1, Object o2) {
152 155
				// first will always be the current symbol
153
				if (o1.equals(currentSymbol)) return -1;
154
				if (o2.equals(currentSymbol)) return 1;
155
				
156
				if (o1.equals(currentElement)) return -1;
157
				if (o2.equals(currentElement)) return 1;
158

  
156 159
				ISymbol sym1 = (ISymbol) o1;
157 160
				ISymbol sym2 = (ISymbol) o2;
158 161
				if (sym1.getDescription() == null && sym2.getDescription() != null) return -1;
......
167 170

  
168 171
		});
169 172

  
170
		map.addAll(symbols);
173
		map.addAll(elements);
171 174
		map.add(o);
172
		symbols = new Vector(map);
175
		elements = new Vector(map);
173 176

  
174 177
	}
175 178

  
176 179
	public Vector getObjects() {
177
		if (symbols == null) {
178
			symbols = new Vector();
179
			
180
			if (currentSymbol!= null)
181
				symbols.add(currentSymbol);
182
			
180
		if (elements == null) {
181
			elements = new Vector();
182

  
183
			if (currentElement!= null)
184
				elements.add(currentElement);
185

  
183 186
			File[] ff = dir.listFiles(ffilter);
184 187
			for (int i = 0; i < ff.length; i++) {
185 188

  
......
204 207

  
205 208
			}
206 209
		}
207
		return symbols;
210
		return elements;
208 211
	}
209 212

  
210 213
	public int getSize() {
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/styling/SimpleFill.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-03-28 16:44:08  jaume
47
* *** empty log message ***
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.4  2007/02/21 16:09:35  jaume
......
114 117
	private JSlider sldFillTransparency;
115 118
	private JSlider sldOutlineTransparency;
116 119
	private int outlineAlpha, fillAlpha;
117
	
120

  
118 121
	public SimpleFill(SymbolEditor owner) {
119 122
		super(owner);
120 123
		initialize();
......
132 135
		JPanel myTab = new JPanel(new FlowLayout(FlowLayout.LEADING, 5,5));
133 136
		myTab.setName(PluginServices.getText(this, "simple_fill"));
134 137
		GridBagLayoutPanel aux = new GridBagLayoutPanel();
135
		
138

  
136 139
		jccFillColor = new ColorChooserPanel();
137 140
		jccFillColor.setAlpha(255);
138 141
		sldFillTransparency = new JSlider();
......
140 143
		aux.addComponent(PluginServices.getText(this, "fill_color"), jccFillColor);
141 144
		aux.addComponent(PluginServices.getText(this, "fill_opacity"), sldFillTransparency);
142 145
		aux.addComponent(new JBlank(30, 30));
143
		
146

  
144 147
		btnOutline = new JSymbolPreviewButton(FShape.LINE);
145 148
		btnOutline.setPreferredSize(new Dimension(100, 35));
146 149
		sldOutlineTransparency = new JSlider();
......
165 168

  
166 169
	public ISymbol getLayer() {
167 170
		SimpleFillSymbol sfs = new SimpleFillSymbol();
168
		ILineSymbol outline =(ILineSymbol) btnOutline.getSymbol(); 
169
		
171
		ILineSymbol outline =(ILineSymbol) btnOutline.getSymbol();
172

  
170 173
		if (outline!=null) {
171 174
			outline.setAlpha(outlineAlpha);
172 175
			sfs.setOutline(outline);
173 176
		}
174
		
177

  
175 178
		Color c = jccFillColor.getColor();
176
		c = new Color(c.getRed(), c.getBlue(), c.getGreen(), fillAlpha);
179
		c = new Color(c.getRed(), c.getGreen(), c.getBlue(), fillAlpha);
177 180
		sfs.setFillColor(c);
178 181
		return sfs;
179 182
	}
......
190 193
				btnOutline.setSymbol(sym.getOutline());
191 194
				ILineSymbol outline = sym.getOutline();
192 195
				if (outline != null) {
193
					outlineAlpha = outline.getAlpha(); 
196
					outlineAlpha = outline.getAlpha();
194 197
					sldOutlineTransparency.setValue((outlineAlpha/255)*100);
195 198
				} else {
196 199
					sldOutlineTransparency.setValue(100);
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/styling/StyleSelector.java
1
package com.iver.cit.gvsig.gui.styling;
2

  
3
import java.awt.Color;
4
import java.awt.Component;
5
import java.awt.Dimension;
6
import java.io.File;
7
import java.util.prefs.Preferences;
8

  
9
import javax.swing.BoxLayout;
10
import javax.swing.JLabel;
11
import javax.swing.JList;
12
import javax.swing.JPanel;
13
import javax.swing.ListCellRenderer;
14
import javax.swing.event.ListSelectionEvent;
15
import javax.swing.event.ListSelectionListener;
16

  
17
import org.gvsig.gui.beans.swing.GridBagLayoutPanel;
18

  
19
import com.iver.andami.PluginServices;
20
import com.iver.cit.gvsig.fmap.core.styles.IStyle;
21
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol;
22

  
23
/**
24
 *
25
 * @author jaume dominguez faus - jaume.dominguez@iver.es
26
 *
27
 */
28
public class StyleSelector extends SymbolSelector {
29

  
30
	public StyleSelector(IStyle style, int shapeType) {
31
		this(style, shapeType, new SelectorFilter() {
32
			public boolean accepts(Object obj) {
33
				return obj instanceof IStyle;
34
			}
35
		});
36
	}
37

  
38
	public StyleSelector(IStyle style, int shapeType, SelectorFilter filter) {
39
		super(null, shapeType, filter);
40
		selectedElement = style;
41
    	Preferences prefs = Preferences.userRoot().node( "gvsig.foldering" );
42
		rootDir = new File(prefs.get("SymbolStylesFolder", System.getProperty("user.home")+"/gvSIG/Styles"));
43
		if (!rootDir.exists())
44
			rootDir.mkdir();
45
		lblTitle.setText(PluginServices.getText(this, "label_styles"));
46
		treeRootName = PluginServices.getText(this, "style_library");
47

  
48
	}
49

  
50
	protected SelectorListModel newListModel() {
51
		SelectorListModel listModel = new SelectorListModel(
52
				dir,
53
				selectedElement,
54
				sFilter,
55
				SelectorListModel.STYLE_FILE_EXTENSION);
56
		return listModel;
57

  
58
	}
59

  
60
	protected JPanel getJPanelOptions() {
61
		if (jPanelOptions == null) {
62
			jPanelOptions = new GridBagLayoutPanel();
63
			// nothing in the panel
64

  
65
		}
66
    	return jPanelOptions;
67
    }
68

  
69
    /**
70
     * This method initializes jList
71
     *
72
     * @return javax.swing.JList
73
     */
74
    protected JList getJListSymbols() {
75
    	if (jListSymbols == null) {
76
    		jListSymbols = new JList();
77
    		jListSymbols.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
78
            jListSymbols.setLayoutOrientation(JList.HORIZONTAL_WRAP);
79
            jListSymbols.setVisibleRowCount(-1);
80
            jListSymbols.addListSelectionListener(new ListSelectionListener() {
81
            	public void valueChanged(ListSelectionEvent e) {
82
            		setStyle(jListSymbols.getSelectedValue());
83
            		updateOptionsPanel();
84
            	}
85
            });
86
            ListCellRenderer renderer = new ListCellRenderer() {
87
        		private Color mySelectedBGColor = new Color(255,145,100,255);
88
    			public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
89
    				IStyle sym = (IStyle) value;
90
    				JPanel pnl = new JPanel();
91
    				BoxLayout layout = new BoxLayout(pnl, BoxLayout.Y_AXIS);
92
    				pnl.setLayout(layout);
93
    				Color bgColor = (isSelected) ? mySelectedBGColor
94
    							 : getJListSymbols().getBackground();
95

  
96
    				pnl.setBackground(bgColor);
97
    				StylePreviewer sp = new StylePreviewer();
98
    				sp.setAlignmentX(Component.CENTER_ALIGNMENT);
99
    				sp.setPreferredSize(new Dimension(50, 50));
100
    				sp.setStyle(sym);
101
    				sp.setBackground(bgColor);
102
    				pnl.add(sp);
103
    				JLabel lbl = new JLabel(sym.getDescription());
104
    				lbl.setBackground(bgColor);
105
    				lbl.setAlignmentX(Component.CENTER_ALIGNMENT);
106
    				pnl.add(lbl);
107

  
108
    				return pnl;
109
    			}
110

  
111
        	};
112
        	jListSymbols.setCellRenderer(renderer);
113
    	}
114
    	return jListSymbols;
115
    }
116

  
117
	protected void setStyle(Object selectedValue) {
118
		// TODO missing change SymbolPreviewer by a StylePrevier and apply it
119
		// the new style
120
	}
121

  
122
}
0 123

  
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/styling/SymbolEditor.java
43 43
 *
44 44
 * $Id$
45 45
 * $Log$
46
 * Revision 1.3  2007-03-27 09:49:03  jaume
46
 * Revision 1.4  2007-03-28 16:44:08  jaume
47 47
 * *** empty log message ***
48 48
 *
49
 * Revision 1.3  2007/03/27 09:49:03  jaume
50
 * *** empty log message ***
51
 *
49 52
 * Revision 1.2  2007/03/09 11:25:00  jaume
50 53
 * Advanced symbology (start committing)
51 54
 *
......
128 131
import com.iver.cit.gvsig.fmap.core.symbols.MultiLayerLineSymbol;
129 132
import com.iver.cit.gvsig.fmap.core.symbols.MultiLayerMarkerSymbol;
130 133
import com.iver.cit.gvsig.fmap.core.v02.FSymbol;
134
import com.iver.cit.gvsig.project.documents.layout.Attributes;
131 135
import com.iver.utiles.XMLEntity;
132 136

  
133 137
/**
......
172 176
			case FShape.POLYGON:
173 177
				nSym = new MultiLayerFillSymbol();
174 178
				break;
179
			case FShape.TEXT:
180

  
175 181
			default:
176 182
				throw new Error(PluginServices.getText(this,
177 183
						"shape_type_not_supported"));
......
381 387

  
382 388
	private JComboBox getCmbUnits() {
383 389
		if (cmbUnits == null) {
384
			cmbUnits = new JComboBox(new String[] { "unidad1", "unidad2" });
390
			String[] units = new String[Attributes.NAMES.length+1];
391
			for (int i = 0; i < Attributes.NAMES.length; i++) {
392
				units[i] = PluginServices.getText(this, Attributes.NAMES[i]);
393
			}
394
			units[units.length-1] = PluginServices.getText(this, "pixels");
395

  
396
			cmbUnits = new JComboBox(units);
397
			cmbUnits.setSelectedIndex(units.length-1);
385 398
		}
386 399
		return cmbUnits;
387 400
	}
trunk/applications/appgvSIG/config/text.properties
729 729
dot_value=Valor del punto
730 730
outline_color=Color del borde
731 731
densities=Densidades
732
high=High
733
medium=Medium
734
low=Low
732
high=Alta
733
medium=Media
734
low=Baja
735 735
Defines_a_dot_density_symbol_based_on_a_field_value=Define una leyenda de densidad de puntos basada en el valor de un determinado campo.
736 736
dot_density=Densidad de puntos
737 737
features=Objetos
......
743 743
exception_cloning_legend=Excepci?n clonando leyenda.
744 744
character_marker=Marcador de car?cter
745 745
character_marker_symbol=S?mbolo Marcador de car?cter
746
marker_fill=Rellenado con marcadores
746
marker_fill=Relleno con marcadores
747 747
choose_marker=Seleccionar marcador
748 748
outline=Borde
749 749
grid=Malla
......
753 753
separation=Separaci?n
754 754
simple_fill=Relleno simple
755 755
fill_color=Color de relleno
756
outline_color=Color de borde
757 756
outline_width=Ancho del borde
758 757
trying_to_add_a_non_TypeSymbolEditor_panel=Intentando a?adir un panel que no es de tipo TypeSymbolEditor.
759 758
two_panels_with_the_same_name=Dos paneles con el mismo nombre.
......
866 865
label_attributes_defined_in_table=Atributos de la etiqueta definidos en tabla
867 866
current=Actual
868 867
text_symbols=S?mbolos textuales
869
label_expression_help=Ayuda expresiones para etiquetas
868
label_expression_help=
869
fixed_height=Tama?o fijo
870
location=Ubicaci?n
871
location_along_the_lines=Ubicaci?n a lo largo de las l?neas
872
at_best=En la mejor
873
at_begin=Al principio
874
at_end=Al final
875
label-point-priority-help=Prioridad: 0 = Bloqueado, 1 = M?s alta, 3 = M?s baja
876
change_location=Cambiar ubicaci?n
877
offset_labels_on_top_of_the_points=Situar etiquetas sobre los puntos.
878
offset_labels_horizontally=Desplazar etiquetas horizontalmente alrededor del punto.
879
always_straight=Siempre recto
880
always_horizontal=Siempre horizontal
881
orientation_system=Orientaci?n
882
line=L?nea
883
page=P?gina
884
below=Abajo
885
on_the_line=Sobre la l?nea
886
above=Arriba
887
getting_shape_type=Determinando el tipo de shape
trunk/applications/appgvSIG/config/text_en.properties
718 718
Zoom_Real=1\:1 Zoom
719 719
Zoom_Select=Zoom to selection
720 720
too_large_border=Too large border
721

  
722
categories=Categories
723
cannot_apply_to_a_non_polygon_layer=Cannot apply to a non-polygon layer
724
looks_like_too_low_value_for_this_field_may_cause_system_to_run_slow=Looks like too low value for this field. May cause the system to run slow.
725
in_layer=in layer
726
could_not_setup_legend=Could not setup legend
727
labelling_field=Labeling field
728
dot_size=Dot size
729
dot_value=Dot value
730
outline_color=Border color
731
densities=Densities
732
high=High
733
medium=Medium
734
low=Low
735
Defines_a_dot_density_symbol_based_on_a_field_value=Defines a dot density symbol based on the value of a field
736
dot_density=Dot density
737
features=Features
738
preview=Preview
739
quantities=Quantities
740
choose_symbol=Choose symbol
741
legend=Legend
742
label_text_in_the_TOC=Label text that will appear in the TOC
743
exception_cloning_legend=Exception cloning legend.
744
character_marker=Character marker
745
character_marker_symbol=Character marker symbol
746
marker_fill=Marker fill
747
choose_marker=Choose marker
748
outline=Border
749
grid=Grid
750
random=Random
751
fill_properties=Fill properties
752
offset=Offset
753
separation=Separation
754
simple_fill=Simple fill
755
fill_color=Fill color
756
outline_width=Border width
757
trying_to_add_a_non_TypeSymbolEditor_panel=Trying to add a non SymbolEditor panel.
758
two_panels_with_the_same_name=Two panels with the same name.
759
symbol_property_editor=Symbol property editor
760
properties=Properties
761
layers=Layers
762
type=Type
763
units=Units
764
layer=Layers
765
preview_not_available=Preview is not available
766
point_symbols=Marker symbols
767
line_symbols=Line symbols
768
polygon_symbols=Polygon symbols
769
shape_type_not_yet_supported=Shapetype not yet supported
770
symbol_library=Symbol library
771
could_not_find_symbol_directory=Could not find symbols directory
772
options=Options
773
new=New
774
reset=Reset
775
save=Save
776
size=Size
777
angle=Angle
778
width=Width
779
save_error=Save error
780
marker_fill=Marker fill
781
simple_line=Simple line
782
simple_marker=Simple marker
783
x_offset=X offset
784
y_offset=Y offset
785
simple_marker_symbol=Simple marker symbol
786
enter_description=Enter description
787
syntax_error=Syntax error
788
error=Error
789
label_expression_help=
790
expression=Expression
791
label_expression_editor=Label expression editor
792
method=Method
793
class=Class
794
classes=Classes
795
text_string=Text
796
text_symbol=Text symbol
797
font_color=Font color
798
enable_labelling=Enable labeling
799
visualization=Visualization
800
label_styles=Label styles
801
placement=Placement
802
edit_expression=Edit expression
803
SQL_query=SQL query
804
remane_class=Rename class
805
delete_class=Delete class
806
add_class=Add class
807
label_features_in_this_class=Label features in this class
808
labeling=Labeling
809
shape_type_error=Shape type error.
810
enter_new_name=Enter new name
811
placement_properties=Placement properties
812
point_settings=Point settings
813
line_settings=Line settings
814
polygon_settings=Polygon settings
815
position=Position
816
orientation=Orientation
817
parallel=Parallel
818
following_line=Following the line
819
perpedicular=Perpendicular
820
duplicate_labels=Duplicate layers
821
place_one_label_per_feature_part=Place one label per feature part
822
place_one_label_per_feature=Place one label per feature
823
remove_duplicate_labels=Remove duplicate labels
824
label_features_in_the_same_way=Label features in the way
825
define_classes_of_features_and_label_each_differently=Define classes of features and label each differently
826
label_only_when_selected=Label only when the feature is selected
827
could_not_apply_legend=Could not apply legend
828
quantity_by_category=Quantity by category
829
graduated_symbols=Graduated symbols
830
multiple_atributes=Multiple attribute
831
too_large_border=Too large border
832
file=File
833
file_not_found=File not found
834
file_corrupt=File corrupt
835
unsupported_legend=Unsupported legend
836
symbol=Symbol
837
from=From
838
to=To
839
template=Template
840
generating_intervals=Generating intervals
841
draw_quantities_using_symbol_size_to_show_relative_values=Draws quantities using symbol size to show relative values.
842
could_not_get_shape_type=Could not get shape type.
843
general=General
844
text_field=Text
845
text_height_field=Text height field
846
rotation_height=Rotation field
847
accessing_file_structure=Acessing file structure
848
could_not_restore_text_height_field=Could not restore text height field.
849
could_not_restore_rotation_field=Could not restore rotation field.
850
could_not_restore_text_field=Could not restore text field.
851
font=Font
852
usupported_layer_type=Unsupported layer type
853
driver_exception=Driver exception
854
legend_exception=Legend exception
855
variation_by=Variation by
856
color_ramp=Color ramp
857
values_field=Value fields
858
color_field=Color field
859
symbol_field=Symbol field
860
getting_layer_shape_type=Getting layer shape type
861
draw_quantities_for_each_category=Draw quantities for each category.
862
recovering_recordset=Recovering recordset.
863
fields=fields
864
user_defined_labels=User defined labels
865
label_attributes_defined_in_table=Label attributes defined in table
866
current=Current
867
text_symbols=Text symbols
868
label_expression_help=
869
fixed_height=Fixed height
870
location=Location
871
location_along_the_lines=Location along the lines
872
at_best=At best
873
at_begin=At begin
874
at_end=At end
875
label-point-priority-help=Priority: 0 = Blocked, 1 = Highest, 3 = Lowest
876
change_location=Change location
877
offset_labels_on_top_of_the_points=Offset labels on top of the points
878
offset_labels_horizontally=Offest labels horizontally around the point.
879
always_straight=Always straight
880
always_horizontal=Always horizontal
881
orientation_system=Orientation system
882
line=Line
883
page=Page
884
below=Below
885
on_the_line=On the line
886
above=Above
887
getting_shape_type=Getting shape type

Also available in: Unified diff