1 | //////////////////////////////////////////////////////////////////////// |
---|
2 | // |
---|
3 | // This file AboutFrame.java is part of SURFEX. |
---|
4 | // |
---|
5 | //////////////////////////////////////////////////////////////////////// |
---|
6 | |
---|
7 | //////////////////////////////////////////////////////////////////////// |
---|
8 | // |
---|
9 | // SURFEX version 0.90.00 |
---|
10 | // ================= |
---|
11 | // |
---|
12 | // Saarland University at Saarbruecken, Germany |
---|
13 | // Department of Mathematics and Computer Science |
---|
14 | // |
---|
15 | // SURFEX on the web: www.surfex.AlgebraicSurface.net |
---|
16 | // |
---|
17 | // Authors: Oliver Labs (2001-2008), Stephan Holzer (2004-2005) |
---|
18 | // |
---|
19 | // Copyright (C) 2001-2008 |
---|
20 | // |
---|
21 | // |
---|
22 | // *NOTICE* |
---|
23 | // ======== |
---|
24 | // |
---|
25 | // This program is free software; you can redistribute it and/or modify it |
---|
26 | // under the terms of the GNU General Public License as published by the |
---|
27 | // Free Software Foundation ( version 3 or later of the License ). |
---|
28 | // |
---|
29 | // See LICENCE.TXT for details. |
---|
30 | // |
---|
31 | ///////////////////////////////////////////////////////////////////////// |
---|
32 | |
---|
33 | import java.awt.BorderLayout; |
---|
34 | import java.awt.Color; |
---|
35 | import java.awt.GridLayout; |
---|
36 | import java.awt.event.ActionEvent; |
---|
37 | import java.awt.event.ActionListener; |
---|
38 | import java.io.PrintWriter; |
---|
39 | |
---|
40 | import javax.swing.JButton; |
---|
41 | import javax.swing.JCheckBox; |
---|
42 | import javax.swing.JColorChooser; |
---|
43 | import javax.swing.JComboBox; |
---|
44 | import javax.swing.JLabel; |
---|
45 | import javax.swing.JPanel; |
---|
46 | |
---|
47 | ////////////////////////////////////////////////////////////// |
---|
48 | // |
---|
49 | //class Curve |
---|
50 | // |
---|
51 | ////////////////////////////////////////////////////////////// |
---|
52 | public class Curve extends JPanel { |
---|
53 | |
---|
54 | // Anfang Variablen |
---|
55 | |
---|
56 | // GUI |
---|
57 | |
---|
58 | public JComboBox C[] = { new JComboBox(), new JComboBox(), new JComboBox(), |
---|
59 | new JComboBox(), new JComboBox(), new JComboBox(), new JComboBox(), |
---|
60 | new JComboBox(), new JComboBox(), new JComboBox() };//new |
---|
61 | // JComboBox[10]; |
---|
62 | |
---|
63 | //JPanel configPanel = new JPanel(); |
---|
64 | |
---|
65 | JButton optionButton = new JButton("opts"); |
---|
66 | |
---|
67 | JButton deleteCurveButton = new JButton("del"); |
---|
68 | |
---|
69 | JLabel label1, label2; |
---|
70 | |
---|
71 | String eindeutigeCuNr; |
---|
72 | |
---|
73 | JButton colorButton_i, colorButton_o; |
---|
74 | |
---|
75 | //JPanel labelpanel = new JPanel(new GridLayout(2, 1)); |
---|
76 | |
---|
77 | int cunr; |
---|
78 | |
---|
79 | JCheckBox cbox = new JCheckBox(); |
---|
80 | |
---|
81 | Project project; |
---|
82 | |
---|
83 | CurveAdmin cuAdm; |
---|
84 | |
---|
85 | OptionButtonPane optionButtonPane; |
---|
86 | |
---|
87 | // zum rechnen |
---|
88 | // pcalc polyCalc = new pcalc(); |
---|
89 | |
---|
90 | // Ende Variablen |
---|
91 | // Konstruktor |
---|
92 | Curve(int internalCunr, int cunr, CurveAdmin ca, Project pro) { |
---|
93 | //System.out.println("testpl" ); |
---|
94 | |
---|
95 | // polyCalc.doPrint = false; |
---|
96 | cuAdm = ca; |
---|
97 | this.project = pro; |
---|
98 | this.cunr = cunr; |
---|
99 | eindeutigeCuNr = cuAdm.ProjectNumber + "_" |
---|
100 | + (new Integer(cunr)).toString(); |
---|
101 | |
---|
102 | cbox.setSelected(true); |
---|
103 | final OptionButtonPane tempOptionButtonPane = new OptionButtonPane( |
---|
104 | true, 10, 0); |
---|
105 | optionButtonPane = tempOptionButtonPane; |
---|
106 | deleteCurveButton.setActionCommand("deleteCurveButton" + internalCunr); |
---|
107 | deleteCurveButton.setToolTipText("Delete this Curve"); |
---|
108 | deleteCurveButton.setEnabled(false); |
---|
109 | //deleteCurveButton.addActionListener(new ActionListener() { |
---|
110 | //public void actionPerformed(ActionEvent evt) { |
---|
111 | //cunList.removeElementAt(internalEqnr - 1); |
---|
112 | //updateCurvePanel(); |
---|
113 | //} |
---|
114 | //}); |
---|
115 | |
---|
116 | optionButton.addActionListener(new ActionListener() { |
---|
117 | public void actionPerformed(ActionEvent evt) { |
---|
118 | tempOptionButtonPane.setVisible(true); |
---|
119 | } |
---|
120 | }); |
---|
121 | optionButton.setToolTipText("More options for the appearence"); |
---|
122 | // ??? for the moment: |
---|
123 | // because curves need other options than surfaces!!! |
---|
124 | optionButton.setEnabled(false); |
---|
125 | // label1=new JLabel("Equation"); |
---|
126 | |
---|
127 | // this.add(label1); |
---|
128 | |
---|
129 | JPanel configPanel = new JPanel();//new GridLayout(1,4)); |
---|
130 | JPanel labelPanel = new JPanel(new GridLayout(1, 1)); |
---|
131 | JPanel centerPanel = new JPanel(new GridLayout(1, 10)); |
---|
132 | // Vector eqNrs=project.eqAdm.getEqNrs(); |
---|
133 | int i; |
---|
134 | /* |
---|
135 | * String cunrT; ListIterator |
---|
136 | * li=project.eqAdm.getEqNrs().listIterator(); while(li.hasNext()){ |
---|
137 | * cunrT=((Integer)li.next()).toString(); for(i=0;i <=9;i++){ |
---|
138 | * C[i].addItem(cunrT);//=(new JComboBox(eqNrs)); centerPanel.add(C[i]); } } |
---|
139 | */ |
---|
140 | for (i = 0; i <= 9; i++) { |
---|
141 | C[i] = new JComboBox(project.eqAdm.getEqNrs()); |
---|
142 | centerPanel.add(C[i]); |
---|
143 | } |
---|
144 | |
---|
145 | setLayout(new BorderLayout()); |
---|
146 | //this.add(labelPanel, BorderLayout.WEST); |
---|
147 | this.add(centerPanel, BorderLayout.CENTER); |
---|
148 | this.add(configPanel, BorderLayout.WEST); |
---|
149 | |
---|
150 | label2 = new JLabel("C" + cunr); |
---|
151 | labelPanel.add(label2); |
---|
152 | //this.add(baseCurveButton); |
---|
153 | configPanel.add(cbox); |
---|
154 | colorButton_i = new JButton(); |
---|
155 | colorButton_i.setBackground(new Color(0, 0, 0)); |
---|
156 | colorButton_i.setToolTipText("Select the Curves color"); |
---|
157 | colorButton_i.addActionListener(new ActionListener() { |
---|
158 | public void actionPerformed(ActionEvent evt) { |
---|
159 | colorButton_i.setBackground(JColorChooser.showDialog(null, |
---|
160 | "Change curfe's color", colorButton_i.getBackground())); |
---|
161 | } |
---|
162 | }); |
---|
163 | |
---|
164 | configPanel.add(colorButton_i); |
---|
165 | |
---|
166 | //this.add(colorButton_i); |
---|
167 | configPanel.add(deleteCurveButton); |
---|
168 | configPanel.add(optionButton); |
---|
169 | configPanel.add(label2); |
---|
170 | } |
---|
171 | |
---|
172 | //Methoden |
---|
173 | public boolean isSelected() { |
---|
174 | return (cbox.isSelected()); |
---|
175 | } |
---|
176 | |
---|
177 | public void setCurveNo(int no) { |
---|
178 | cunr = no; |
---|
179 | eindeutigeCuNr = cuAdm.ProjectNumber + "_" |
---|
180 | + (new Integer(cunr)).toString(); |
---|
181 | label2.setText("C" + cunr); |
---|
182 | } |
---|
183 | |
---|
184 | public int getCurveNo() { |
---|
185 | return (cunr); |
---|
186 | } |
---|
187 | |
---|
188 | public void updateActionCommands(int internalCunr) { |
---|
189 | deleteCurveButton.setActionCommand("deleteCurveButton" + internalCunr); |
---|
190 | } |
---|
191 | |
---|
192 | public String getSurfCode(String polyname, int surface_no, double ang[]) { |
---|
193 | //System.out.println("surf_no:"+surface_no); |
---|
194 | |
---|
195 | String str = ""; |
---|
196 | str += "curve_red = " + (colorButton_i.getBackground().getRed()) + ";" |
---|
197 | + "curve_green = " + (colorButton_i.getBackground().getGreen()) |
---|
198 | + ";" + "curve_blue = " |
---|
199 | + (colorButton_i.getBackground().getBlue()) + ";"; |
---|
200 | //str += "surface" + strSurfNo + "=rotate(surface" + strSurfNo + "," |
---|
201 | //+ ang[0] + ",yAxis);"; |
---|
202 | //str += "surface" + strSurfNo + "=rotate(surface" + strSurfNo + "," |
---|
203 | //+ ang[1] + ",xAxis);"; |
---|
204 | //str += "surface" + strSurfNo + "=rotate(surface" + strSurfNo + "," |
---|
205 | //+ ang[2] + ",zAxis);"; |
---|
206 | int i; |
---|
207 | //System.out.println((C[0].getSelectedItem()).toString()); |
---|
208 | |
---|
209 | str += "surf_nr = " + surface_no + ";\n"; |
---|
210 | str += "cut_distance = 0.0001;\n"; |
---|
211 | str += "curve_width = 2.5;\n"; |
---|
212 | |
---|
213 | for (i = 1; i <= 8; i++) { |
---|
214 | if (((C[i].getSelectedItem()).toString()).equals("-")) { |
---|
215 | str += "cutsurface" + (i) + " = 0;"; |
---|
216 | } else { |
---|
217 | str += "cutsurface" + (i) + " = f" |
---|
218 | + ((C[i].getSelectedItem()).toString()) + ";"; |
---|
219 | str += "cutsurface" + (i) + "=rotate(cutsurface" + (i) + "," |
---|
220 | + ang[0] + ",yAxis);\n"; |
---|
221 | str += "cutsurface" + (i) + "=rotate(cutsurface" + (i) + "," |
---|
222 | + ang[1] + ",xAxis);\n"; |
---|
223 | str += "cutsurface" + (i) + "=rotate(cutsurface" + (i) + "," |
---|
224 | + ang[2] + ",zAxis);\n"; |
---|
225 | } |
---|
226 | } |
---|
227 | str += "cut_with_surface;\n"; |
---|
228 | |
---|
229 | return (str); |
---|
230 | } |
---|
231 | |
---|
232 | public void savesurfCode(PrintWriter pw, String polyname, int surface_no, |
---|
233 | double ang[]) { |
---|
234 | //mach surfcode |
---|
235 | } |
---|
236 | |
---|
237 | public void savePOVCode(PrintWriter pw) { |
---|
238 | // mach pov-code |
---|
239 | } |
---|
240 | |
---|
241 | public void saveYourself(PrintWriter pw) { |
---|
242 | String str = ""; |
---|
243 | pw.println("////////////////// Curve: /////////////////////////"); |
---|
244 | int i; |
---|
245 | pw.println("" + eindeutigeCuNr + "\n"); |
---|
246 | for (i = 0; i <= 9; i++) { |
---|
247 | pw.println(C[i].getSelectedIndex()); |
---|
248 | } |
---|
249 | pw.println(colorButton_i.getBackground().getRed()); |
---|
250 | pw.println(colorButton_i.getBackground().getGreen()); |
---|
251 | pw.println(colorButton_i.getBackground().getBlue()); |
---|
252 | pw.println(cbox.isSelected()); |
---|
253 | //optionButtonPane.saveYourself(pw); |
---|
254 | } |
---|
255 | |
---|
256 | public String saveYourself() { |
---|
257 | String str = ""; |
---|
258 | str += "////////////////// Curve: /////////////////////////\n"; |
---|
259 | int i; |
---|
260 | str += ("" + cunr + "\n"); |
---|
261 | for (i = 0; i <= 9; i++) { |
---|
262 | str += C[i].getSelectedIndex() + "\n"; |
---|
263 | } |
---|
264 | str += colorButton_i.getBackground().getRed() + "\n"; |
---|
265 | str += colorButton_i.getBackground().getGreen() + "\n"; |
---|
266 | str += colorButton_i.getBackground().getBlue() + "\n"; |
---|
267 | str += cbox.isSelected() + "\n"; |
---|
268 | //optionButtonPane.saveYourself(pw); |
---|
269 | return (str); |
---|
270 | } |
---|
271 | } // end class Curve |
---|
272 | |
---|