Revision 12805 trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/styling/ArrowDecorator.java

View differences:

ArrowDecorator.java
42 42

  
43 43
import java.awt.BorderLayout;
44 44
import java.awt.FlowLayout;
45
import java.awt.event.ActionEvent;
46
import java.awt.event.ActionListener;
45 47

  
46 48
import javax.swing.BorderFactory;
47 49
import javax.swing.ButtonGroup;
......
50 52
import javax.swing.JPanel;
51 53
import javax.swing.JRadioButton;
52 54

  
55
import org.gvsig.gui.beans.DefaultBean;
53 56
import org.gvsig.gui.beans.swing.GridBagLayoutPanel;
54 57
import org.gvsig.gui.beans.swing.JButton;
55 58
import org.gvsig.gui.beans.swing.JIncrementalNumberField;
56 59
import org.gvsig.gui.beans.swing.ValidatingTextField;
60
import org.opengis.go.display.style.ArrowStyle;
57 61

  
58 62
import com.iver.andami.PluginServices;
59 63
import com.iver.cit.gvsig.fmap.core.styles.ArrowDecoratorStyle;
64
import com.iver.cit.gvsig.fmap.core.symbols.ArrowMarkerSymbol;
65
import com.iver.cit.gvsig.fmap.core.symbols.IMarkerSymbol;
60 66

  
61 67
/**
62 68
 * @autor jaume dominguez faus - jaume.dominguez@iver.es
63 69
 */
64
public class ArrowDecorator extends JPanel {
70
public class ArrowDecorator extends DefaultBean implements ActionListener {
65 71

  
66 72
	private JCheckBox chkFlipAll;
67 73
	private JCheckBox chkFlipFirst;
68 74
	private JRadioButton rdBtnFollowLine;
69 75
	private JRadioButton rdBtnFixedAngle;
70 76
	private JIncrementalNumberField incrPositionCount;
77
	private JIncrementalNumberField incrSharpeness;
71 78
	private JCheckBox chkUseDecorator;
79
	private IMarkerSymbol marker;
80
	private JIncrementalNumberField incrSize;
72 81

  
73 82
	public ArrowDecorator() {
74 83
		super();
......
80 89
		setLayout(new BorderLayout(10, 10));
81 90
		
82 91
		chkUseDecorator = new JCheckBox(PluginServices.getText(this, "use_decorator"));
92
		
83 93
		JPanel aux = new JPanel(new FlowLayout(FlowLayout.LEFT));
84
		aux.add(chkUseDecorator);
85
		add(aux, BorderLayout.NORTH);
86
		
87
		aux = new JPanel(new BorderLayout(5,5));
88
		
89
		JPanel aux2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
90
		JLabel lblPositionCount = new JLabel(PluginServices.getText(this, "number_of_positions")+":");
91
		aux2.add(lblPositionCount);
92
		
93
		incrPositionCount = new JIncrementalNumberField(
94
		GridBagLayoutPanel pnlTopOptions = new GridBagLayoutPanel();
95
		pnlTopOptions.addComponent(chkUseDecorator);
96
		pnlTopOptions.addComponent(PluginServices.getText(this, "size"),
97
				incrSize = new  JIncrementalNumberField(
98
						"0", 
99
						5,
100
						ValidatingTextField.DOUBLE_VALIDATOR,
101
						ValidatingTextField.NUMBER_CLEANER,
102
						0,
103
						Integer.MAX_VALUE,
104
						1)
105
		);
106
		pnlTopOptions.addComponent(PluginServices.getText(this, "arrow_sharpeness"),
107
				incrSharpeness = new  JIncrementalNumberField(
108
						"0", 
109
						5,
110
						ValidatingTextField.DOUBLE_VALIDATOR,
111
						ValidatingTextField.NUMBER_CLEANER,
112
						0,
113
						Integer.MAX_VALUE,
114
						1)
115
		);
116
		JPanel aux2 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
117
		aux2.add(	incrPositionCount = new JIncrementalNumberField(
94 118
				"0", 
95 119
				5,
96 120
				ValidatingTextField.INTEGER_VALIDATOR,
97 121
				ValidatingTextField.NUMBER_CLEANER,
98 122
				0,
99 123
				Integer.MAX_VALUE,
100
				1);
101
		
102
		aux2.add(incrPositionCount, BorderLayout.NORTH);
103
		
124
				1)
125
		);
104 126
		JButton btnChooseSymbol = new JButton(PluginServices.getText(this, "symbol"));
105
		aux2.add(btnChooseSymbol, BorderLayout.NORTH);
106
		aux.add(aux2, BorderLayout.NORTH);
127
		JPanel aux3 = new JPanel(new FlowLayout(FlowLayout.LEFT,5, 0));
128
		aux3.add(btnChooseSymbol);
129
		aux2.add(aux3);
130
		pnlTopOptions.addComponent(PluginServices.getText(this, "number_of_positions")+":", aux2);
131
		aux.add(pnlTopOptions);
132
		add(aux, BorderLayout.NORTH);
107 133
		
134
		aux = new JPanel(new BorderLayout(5,5));
108 135
		aux2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
109 136
		GridBagLayoutPanel pnlFlip = new GridBagLayoutPanel();
110 137
		pnlFlip.setBorder(BorderFactory.createTitledBorder(PluginServices.getText(this, "flip")+":"));
111 138
		pnlFlip.addComponent(chkFlipAll = new JCheckBox(PluginServices.getText(this, "flip_all")));
112 139
		pnlFlip.addComponent(chkFlipFirst = new JCheckBox(PluginServices.getText(this, "flip_first")));
113 140
		
141
			
114 142
		aux2.add(pnlFlip);
115 143
		
116 144
		GridBagLayoutPanel pnlRotation = new GridBagLayoutPanel();
......
122 150
		group.add(rdBtnFollowLine);
123 151
		aux2.add(pnlRotation);
124 152
		
153
		chkUseDecorator.addActionListener(this);
154
		incrPositionCount.addActionListener(this);
155
		incrSharpeness.addActionListener(this);
156
		incrSize.addActionListener(this);
157
		chkFlipFirst.addActionListener(this);
158
		chkFlipAll.addActionListener(this);
159
		rdBtnFixedAngle.addActionListener(this);
160
		rdBtnFollowLine.addActionListener(this);
161
	
125 162
		aux.add(aux2, BorderLayout.CENTER);
126 163
		add(aux, BorderLayout.CENTER);
127 164
	}
......
133 170
			ads = new ArrowDecoratorStyle();
134 171
		}
135 172
		
173
		marker = ads.getMarker();
174
		if (marker instanceof ArrowMarkerSymbol) {
175
			ArrowMarkerSymbol arrow = (ArrowMarkerSymbol) marker;
176
			incrSharpeness.setDouble(arrow.getSharpeness());
177
		}
178
		incrSize.setDouble(marker.getSize());
136 179
		incrPositionCount.setInteger(ads.getArrowMarkerCount());
137 180
		chkFlipAll.setSelected(ads.isFlipAll());
138 181
		chkFlipFirst.setSelected(ads.isFlipFirst());
......
144 187
		if (!chkUseDecorator.isSelected()) return null;
145 188
		
146 189
		ArrowDecoratorStyle ads = new ArrowDecoratorStyle();
190
		
191
		if (marker instanceof ArrowMarkerSymbol) {
192
			ArrowMarkerSymbol arrow = (ArrowMarkerSymbol) marker;
193
			arrow.setSharpeness(incrSharpeness.getDouble());
194
		}
195
		marker.setSize(incrSize.getDouble());
196
		ads.setMarker(marker);
147 197
		ads.setArrowMarkerCount(incrPositionCount.getInteger());
148 198
		ads.setFlipAll(chkFlipAll.isSelected());
149 199
		ads.setFlipFirst(chkFlipFirst.isSelected());
150 200
		ads.setFollowLineAngle(rdBtnFollowLine.isSelected());
151 201
		return ads;
152 202
	}
203
	
204
	public void actionPerformed(ActionEvent e) {
205
		boolean isArrow = marker instanceof ArrowMarkerSymbol;
206
		incrSharpeness.setEnabled(isArrow);
207
		
208
		callValueChanged(getArrowDecoratorStyle());
209
	}
153 210
}

Also available in: Unified diff