Revision 11055 trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/styling/JLineStyleComboBox.java

View differences:

JLineStyleComboBox.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

  
1 42
package com.iver.cit.gvsig.gui.styling;
2 43

  
3 44
import java.awt.BasicStroke;
......
11 52
import com.iver.cit.gvsig.fmap.core.styles.IStyle;
12 53
import com.iver.cit.gvsig.fmap.core.styles.SimpleLineStyle;
13 54
import com.iver.utiles.swing.JComboBox;
14

  
55
/**
56
 *
57
 * @author jaume dominguez faus - jaume.dominguez@iver.es
58
 *
59
 */
15 60
public class JLineStyleComboBox extends JComboBox {
16 61
	private static final int PREDEFINED_STYLE_COUNT = 6;
17 62
	private static final int LINE_WIDTH = 10;
......
42 87
								DOT_WIDTH,
43 88
								DOT_WIDTH	}; // line + line + dot + dot
44 89
	}
45
	
90

  
46 91
	{
47 92
		BasicStroke dummy = new BasicStroke();
48 93
		endCap = dummy.getEndCap();
49 94
		lineJoin = dummy.getLineJoin();
50 95
		miterlimit = dummy.getMiterLimit();
51 96
	}
52
	
97

  
53 98
	ILineStyle[] styles = new ILineStyle[PREDEFINED_STYLE_COUNT];
54
	
99

  
55 100
	private ListCellRenderer renderer = new DefaultListCellRenderer() {
56 101
		public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
57 102
			Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
58 103
			if (value == null)
59 104
				return c;
60
			
105

  
61 106
			final IStyle style = (IStyle) value;
62 107
			StylePreviewer sp = new StylePreviewer();
63 108
			sp.setPreferredSize(getSize());
......
65 110
			return sp;
66 111
		};
67 112
	};
68
	
113

  
69 114
	private void refreshStyles() {
70 115
		for (int i = 0; i < styles.length; i++) {
71 116
			styles[i] = new SimpleLineStyle(width, endCap, lineJoin, miterlimit, dash[i], width*5);
......
82 127
		setRenderer(renderer);
83 128
		refreshStyles();
84 129
	}
85
	
130

  
86 131
	public JLineStyleComboBox(Object[] elements) {
87 132
		super(elements);
88 133
		setRenderer(renderer);
89 134
		refreshStyles();
90 135
	}
91
	
136

  
92 137
	public void setLineWidth(int width) {
93 138
		this.width = width;
94 139
		refreshStyles();
95 140
	}
96
	
97
	
141

  
142

  
98 143
}

Also available in: Unified diff