2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2013 - Marcos CARDINOT
5 * This file must be used under the terms of the CeCILL.
6 * This source file is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at
9 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
12 package org.scilab.modules.gui.ged.graphic_objects.properties;
14 import java.awt.Color;
15 import java.awt.event.ActionEvent;
16 import java.awt.event.ActionListener;
17 import java.awt.event.FocusAdapter;
18 import java.awt.event.FocusEvent;
20 import javax.swing.JButton;
21 import javax.swing.JCheckBox;
22 import javax.swing.JColorChooser;
23 import javax.swing.JComboBox;
24 import javax.swing.JDialog;
25 import javax.swing.JLabel;
26 import javax.swing.JPanel;
27 import javax.swing.JTextField;
28 import javax.swing.JToggleButton;
30 import org.scilab.modules.graphic_objects.graphicController.GraphicController;
31 import org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties;
32 import org.scilab.modules.gui.ged.ColorMapHandler;
33 import org.scilab.modules.gui.ged.ContentLayout;
34 import org.scilab.modules.gui.ged.MessagesGED;
40 * @author Marcos CARDINOT <mcardinot@gmail.com>
42 public class Arc extends ContentLayout {
43 private JTextField cULP;
44 private JTextField cULPx;
45 private JTextField cULPy;
46 private JTextField cULPz;
49 * Components of the property: Arc Drawing Method
56 public void arcDrawingMethod(JPanel panel, int ROW, int COLUMN, int LEFTMARGIN, final String UID) {
57 JLabel lArcDrawingMethod = new JLabel();
58 final JComboBox cArcDrawingMethod = new JComboBox();
59 addLabelComboBox(panel, lArcDrawingMethod, MessagesGED.arc_drawing_method,
60 cArcDrawingMethod, new String[] {MessagesGED.nurbs , MessagesGED.lines},
61 LEFTMARGIN, COLUMN, ROW++);
62 cArcDrawingMethod.addActionListener(new ActionListener() {
64 public void actionPerformed(ActionEvent evt) {
65 GraphicController.getController().setProperty(
66 UID, GraphicObjectProperties.__GO_ARC_DRAWING_METHOD__,
67 cArcDrawingMethod.getSelectedIndex());
70 // Get the current status of the property: Arc Drawing Method
71 cArcDrawingMethod.setSelectedIndex((Integer) GraphicController.getController()
72 .getProperty(UID, GraphicObjectProperties.__GO_ARC_DRAWING_METHOD__));
76 * Components of the property: Upper Left Point
83 public void upperLeftPoint(JPanel panel, int ROW, int COLUMN, int LEFTMARGIN, final String UID) {
84 int LEFTMARGINIP = 0; //left margin - inner panel
85 int COLUMNIP = 0; //left column - inner panel
86 final JPanel pULP = new JPanel();
87 final JToggleButton bULP = new JToggleButton();
88 JLabel lULP = new JLabel();
89 JLabel lULPx = new JLabel();
90 JLabel lULPy = new JLabel();
91 JLabel lULPz = new JLabel();
92 cULP = new JTextField();
93 cULPx = new JTextField();
94 cULPy = new JTextField();
95 cULPz = new JTextField();
97 addInnerPanel(panel, pULP, bULP, lULP, cULP, MessagesGED.upper_left_point, ROW);
98 bULP.addActionListener(new ActionListener() {
100 public void actionPerformed(ActionEvent evt) {
101 pULP.setVisible(!bULP.isSelected());
106 addLabelTextField(pULP, lULPx, "X",
107 cULPx, true, LEFTMARGINIP, COLUMNIP, rowULP++);
108 cULPx.addActionListener(new ActionListener() {
110 public void actionPerformed(ActionEvent evt) {
114 cULPx.addFocusListener(new FocusAdapter() {
116 public void focusLost(FocusEvent evt) {
121 addLabelTextField(pULP, lULPy, "Y",
122 cULPy, true, LEFTMARGINIP, COLUMNIP, rowULP++);
123 cULPy.addActionListener(new ActionListener() {
125 public void actionPerformed(ActionEvent evt) {
129 cULPy.addFocusListener(new FocusAdapter() {
131 public void focusLost(FocusEvent evt) {
136 addLabelTextField(pULP, lULPz, "Z",
137 cULPz, true, LEFTMARGINIP, COLUMNIP, rowULP++);
138 cULPz.addActionListener(new ActionListener() {
140 public void actionPerformed(ActionEvent evt) {
144 cULPz.addFocusListener(new FocusAdapter() {
146 public void focusLost(FocusEvent evt) {
154 * Inserts the current situation of the upper left point.
156 private void titleULP() {
157 cULP.setText(" [" + cULPx.getText() + " , " + cULPy.getText() + " , " + cULPz.getText() + "]");
161 * Get status of the property: upper left point.
163 private void getULP(String UID) {
164 Double[] currentULP = (Double []) GraphicController.getController()
165 .getProperty(UID, GraphicObjectProperties.__GO_UPPER_LEFT_POINT__);
166 cULPx.setText(currentULP[0].toString());
167 cULPy.setText(currentULP[1].toString());
168 cULPz.setText(currentULP[2].toString());
173 * Updates the property: upper left point.
175 private void updateULP(String UID) {
177 Double[] value = new Double[3];
178 value[0] = Double.parseDouble(cULPx.getText());
179 value[1] = Double.parseDouble(cULPy.getText());
180 value[2] = Double.parseDouble(cULPz.getText());
181 GraphicController.getController()
182 .setProperty(UID, GraphicObjectProperties.__GO_UPPER_LEFT_POINT__, value);
184 } catch (NumberFormatException e) {
190 * Components of the property: Width
195 * @param UID objectID.
197 public void width(JPanel panel, int ROW, int COLUMN, int LEFTMARGIN, final String UID) {
198 JLabel lWidth = new JLabel();
199 final JTextField cWidth = new JTextField();
201 addLabelTextField(panel, lWidth, MessagesGED.width,
202 cWidth, true, LEFTMARGIN, COLUMN, ROW++);
203 cWidth.addActionListener(new ActionListener() {
205 public void actionPerformed(ActionEvent evt) {
206 setWidth(cWidth, UID);
209 cWidth.addFocusListener(new FocusAdapter() {
211 public void focusLost(FocusEvent evt) {
212 setWidth(cWidth, UID);
215 // Get the current status of the property: Width
216 cWidth.setText(Double.toString((Double) GraphicController.getController()
217 .getProperty(UID, GraphicObjectProperties.__GO_WIDTH__)));
223 * @param cWidth JTextField
226 private void setWidth(JTextField cWidth, String UID) {
228 GraphicController.getController().setProperty(
230 GraphicObjectProperties.__GO_WIDTH__,
231 Double.parseDouble(cWidth.getText()));
232 } catch (NumberFormatException e) {
233 cWidth.setText(Double.toString((Double) GraphicController.getController()
234 .getProperty(UID, GraphicObjectProperties.__GO_WIDTH__)));
239 * Components of the property: Height
244 * @param UID objectID.
246 public void height(JPanel panel, int ROW, int COLUMN, int LEFTMARGIN, final String UID) {
247 JLabel lHeight = new JLabel();
248 final JTextField cHeight = new JTextField();
250 addLabelTextField(panel, lHeight, MessagesGED.height,
251 cHeight, true, LEFTMARGIN, COLUMN, ROW++);
252 cHeight.addActionListener(new ActionListener() {
254 public void actionPerformed(ActionEvent evt) {
255 setHeight(cHeight, UID);
258 cHeight.addFocusListener(new FocusAdapter() {
260 public void focusLost(FocusEvent evt) {
261 setHeight(cHeight, UID);
264 // Get the current status of the property: Height
265 cHeight.setText(Double.toString((Double) GraphicController.getController()
266 .getProperty(UID, GraphicObjectProperties.__GO_HEIGHT__)));
272 * @param cHeight JTextField
275 private void setHeight(JTextField cHeight, String UID) {
277 GraphicController.getController().setProperty(
279 GraphicObjectProperties.__GO_HEIGHT__,
280 Double.parseDouble(cHeight.getText()));
281 } catch (NumberFormatException e) {
282 cHeight.setText(Double.toString((Double) GraphicController.getController()
283 .getProperty(UID, GraphicObjectProperties.__GO_HEIGHT__)));
288 * Components of the property: Start Angle
293 * @param UID objectID.
295 public void startAngle(JPanel panel, int ROW, int COLUMN, int LEFTMARGIN, final String UID) {
296 JLabel lStartAngle = new JLabel();
297 final JTextField cStartAngle = new JTextField();
299 addLabelTextField(panel, lStartAngle, MessagesGED.start_angle,
300 cStartAngle, true, LEFTMARGIN, COLUMN, ROW++);
301 cStartAngle.addActionListener(new ActionListener() {
303 public void actionPerformed(ActionEvent evt) {
304 setStartAngle(cStartAngle, UID);
307 cStartAngle.addFocusListener(new FocusAdapter() {
309 public void focusLost(FocusEvent evt) {
310 setStartAngle(cStartAngle, UID);
313 // Get the current status of the property: Start Angle
314 cStartAngle.setText(Double.toString((Double) GraphicController.getController()
315 .getProperty(UID, GraphicObjectProperties.__GO_START_ANGLE__)));
321 * @param cStartAngle JTextField
324 private void setStartAngle(JTextField cStartAngle, String UID) {
326 GraphicController.getController().setProperty(
328 GraphicObjectProperties.__GO_START_ANGLE__,
329 Double.parseDouble(cStartAngle.getText()));
330 } catch (NumberFormatException e) {
331 cStartAngle.setText(Double.toString((Double) GraphicController.getController()
332 .getProperty(UID, GraphicObjectProperties.__GO_START_ANGLE__)));
337 * Components of the property: End Angle
342 * @param UID objectID.
344 public void endAngle(JPanel panel, int ROW, int COLUMN, int LEFTMARGIN, final String UID) {
345 JLabel lEndAngle = new JLabel();
346 final JTextField cEndAngle = new JTextField();
348 addLabelTextField(panel, lEndAngle, MessagesGED.end_angle,
349 cEndAngle, true, LEFTMARGIN, COLUMN, ROW++);
350 cEndAngle.addActionListener(new ActionListener() {
352 public void actionPerformed(ActionEvent evt) {
353 setEndAngle(cEndAngle, UID);
356 cEndAngle.addFocusListener(new FocusAdapter() {
358 public void focusLost(FocusEvent evt) {
359 setEndAngle(cEndAngle, UID);
362 // Get the current status of the property: End Angle
363 cEndAngle.setText(Double.toString((Double) GraphicController.getController()
364 .getProperty(UID, GraphicObjectProperties.__GO_END_ANGLE__)));
370 * @param cEndAngle JTextField
373 private void setEndAngle(JTextField cEndAngle, String UID) {
375 GraphicController.getController().setProperty(
377 GraphicObjectProperties.__GO_END_ANGLE__,
378 Double.parseDouble(cEndAngle.getText()));
379 } catch (NumberFormatException e) {
380 cEndAngle.setText(Double.toString((Double) GraphicController.getController()
381 .getProperty(UID, GraphicObjectProperties.__GO_END_ANGLE__)));