Revision 10450 branches/simbologia/applications/appgvSIG/src/com/iver/cit/gvsig/gui/styling/SimpleFill.java

View differences:

SimpleFill.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.1.2.3  2007-02-21 07:35:14  jaume
46
* Revision 1.1.2.4  2007-02-21 16:09:35  jaume
47 47
* *** empty log message ***
48 48
*
49
* Revision 1.1.2.3  2007/02/21 07:35:14  jaume
50
* *** empty log message ***
51
*
49 52
* Revision 1.1.2.2  2007/02/08 15:43:05  jaume
50 53
* some bug fixes in the editor and removed unnecessary imports
51 54
*
......
71 74
*/
72 75
package com.iver.cit.gvsig.gui.styling;
73 76

  
77
import java.awt.Color;
74 78
import java.awt.Dimension;
75 79
import java.awt.FlowLayout;
76 80
import java.awt.event.ActionEvent;
......
78 82
import java.util.ArrayList;
79 83

  
80 84
import javax.swing.JPanel;
85
import javax.swing.JSlider;
86
import javax.swing.event.ChangeEvent;
87
import javax.swing.event.ChangeListener;
81 88

  
82 89
import org.gvsig.gui.beans.swing.GridBagLayoutPanel;
90
import org.gvsig.gui.beans.swing.JBlank;
83 91

  
84
import sun.security.action.GetBooleanAction;
85

  
86 92
import com.iver.andami.PluginServices;
87 93
import com.iver.andami.messages.NotificationManager;
88 94
import com.iver.cit.gvsig.fmap.core.FShape;
......
91 97
import com.iver.cit.gvsig.fmap.core.symbols.SimpleFillSymbol;
92 98
import com.iver.cit.gvsig.gui.panels.ColorChooserPanel;
93 99
import com.iver.cit.gvsig.project.documents.view.legend.gui.JSymbolPreviewButton;
100
import com.lowagie.tools.plugins.treeview.OutlinelistTreeNode;
94 101

  
95 102
import de.ios.framework.swing.JDecimalField;
96 103

  
97
public class SimpleFill extends AbstractTypeSymbolEditorPanel implements ActionListener {
104
public class SimpleFill extends AbstractTypeSymbolEditorPanel implements ActionListener, ChangeListener {
98 105
	private static final String NAME = PluginServices.
99 106
		getText(SimpleFill.class, "simple_fill");
100 107
	private ColorChooserPanel jccFillColor;
101 108
	private JDecimalField txtOutlineWidth;
102 109
	private ArrayList tabs = new ArrayList();
103 110
	private JSymbolPreviewButton btnOutline;
111
	private JSlider sldFillTransparency;
112
	private JSlider sldOutlineTransparency;
113
	private int outlineAlpha, fillAlpha;
104 114
	
105 115
	public SimpleFill(SymbolEditor owner) {
106 116
		super(owner);
......
119 129
		JPanel myTab = new JPanel(new FlowLayout(FlowLayout.LEADING, 5,5));
120 130
		myTab.setName(PluginServices.getText(this, "simple_fill"));
121 131
		GridBagLayoutPanel aux = new GridBagLayoutPanel();
132
		
122 133
		jccFillColor = new ColorChooserPanel();
123 134
		jccFillColor.setAlpha(255);
124

  
135
		sldFillTransparency = new JSlider();
136
		sldFillTransparency.setValue(100);
137
		aux.addComponent(PluginServices.getText(this, "fill_color"), jccFillColor);
138
		aux.addComponent(PluginServices.getText(this, "fill_opacity"), sldFillTransparency);
139
		aux.addComponent(new JBlank(30, 30));
140
		
125 141
		btnOutline = new JSymbolPreviewButton(FShape.LINE);
126 142
		btnOutline.setPreferredSize(new Dimension(100, 35));
127
		
143
		sldOutlineTransparency = new JSlider();
144
		sldOutlineTransparency.setValue(100);
128 145
		aux.addComponent(PluginServices.getText(this, "outline")+":",
129 146
				btnOutline	);
147
		aux.addComponent(PluginServices.getText(this, "transparency_opacity"), sldOutlineTransparency);
130 148
		txtOutlineWidth = new JDecimalField(25);
131 149
		// TODO restore previous outline width
132 150
		aux.addComponent(PluginServices.getText(this, "outline_width")+":",
......
135 153
		myTab.add(aux);
136 154

  
137 155
		jccFillColor.addActionListener(this);
156
		sldFillTransparency.addChangeListener(this);
138 157
		btnOutline.addActionListener(this);
139 158
		txtOutlineWidth.addActionListener(this);
159
		sldOutlineTransparency.addChangeListener(this);
140 160
		tabs.add(myTab);
141 161
	}
142 162

  
143 163
	public ISymbol getLayer() {
144 164
		SimpleFillSymbol sfs = new SimpleFillSymbol();
145
		sfs.setOutline((ILineSymbol) btnOutline.getSymbol());
146
		sfs.setFillColor(jccFillColor.getColor());
165
		ILineSymbol outline =(ILineSymbol) btnOutline.getSymbol(); 
166
		
167
		if (outline!=null) {
168
			outline.setAlpha(outlineAlpha);
169
			sfs.setOutline(outline);
170
		}
171
		
172
		Color c = jccFillColor.getColor();
173
		c = new Color(c.getRed(), c.getBlue(), c.getGreen(), fillAlpha);
174
		sfs.setFillColor(c);
147 175
		return sfs;
148 176
	}
149 177

  
......
155 183
			} else {
156 184
				sym = (SimpleFillSymbol) layer;
157 185
				jccFillColor.setColor(sym.getFillColor());
186
				sldFillTransparency.setValue((sym.getFillColor().getAlpha()/255)*100);
158 187
				btnOutline.setSymbol(sym.getOutline());
188
				ILineSymbol outline = sym.getOutline();
189
				if (outline != null) {
190
					outlineAlpha = outline.getAlpha(); 
191
					sldOutlineTransparency.setValue((outlineAlpha/255)*100);
192
				} else {
193
					sldOutlineTransparency.setValue(100);
194
				}
159 195
			}
160 196
		} catch (IndexOutOfBoundsException ioEx) {
161 197
			NotificationManager.addWarning("Symbol layer index out of bounds", ioEx);
......
174 210
	public void actionPerformed(ActionEvent e) {
175 211
		fireSymbolChangedEvent();
176 212
	}
213

  
214
	public void stateChanged(ChangeEvent e) {
215
		Object s = e.getSource();
216
		if (s.equals(sldFillTransparency)) {
217
			fillAlpha = (int) (255*(sldFillTransparency.getValue()/100.0));
218
		} else if (s.equals(sldOutlineTransparency)) {
219
			outlineAlpha = (int) (255*(sldOutlineTransparency.getValue()/100.0));
220
		}
221
		fireSymbolChangedEvent();
222
	}
177 223
}

Also available in: Unified diff