001 /** 002 ############################################################################## 003 ## ## 004 ## Appearance3DChooser ## 005 ## ## 006 ## Copyright (C) 2009 Frederic Roudaut <frederic.roudaut@free.fr> ## 007 ## ## 008 ## ## 009 ## This program is free software: you can redistribute it and/or modify ## 010 ## it under the terms of the GNU General Public License as published by ## 011 ## the Free Software Foundation, either version 3 of the License, or ## 012 ## (at your option) any later version. ## 013 ## ## 014 ## This program is distributed in the hope that it will be useful, ## 015 ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## 016 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## 017 ## GNU General Public License for more details. ## 018 ## ## 019 ## You should have received a copy of the GNU General Public License ## 020 ## along with this program. If not, see <http://www.gnu.org/licenses/>. ## 021 ## ## 022 ## ## 023 ############################################################################## 024 **/ 025 026 027 028 package com.appearance3Dchooser; 029 030 import javax.swing.*; 031 import java.awt.Dimension; 032 import java.awt.GridBagConstraints; 033 import java.awt.Font; 034 import java.awt.Insets; 035 import java.awt.GridBagLayout; 036 import java.awt.BorderLayout; 037 import java.awt.event.*; 038 039 import javax.vecmath.Matrix4d; 040 import javax.media.j3d.Transform3D; 041 import javax.media.j3d.TransparencyAttributes; 042 import javax.media.j3d.TextureAttributes; 043 import javax.media.j3d.Material; 044 045 import com.awt.GridBagLayoutConstraint; 046 047 048 /** 049 * Create a Frame with all the Parameters Values 050 * It will dynamically update them every 500ms. 051 * 052 */ 053 public class Appearance3DChooserInfo 054 { 055 private static final long serialVersionUID = 1L; 056 057 protected JLabel entryTextSPECULAR = null; 058 protected JLabel entryTextAMBIENT = null; 059 protected JLabel entryTextEMISSIVE = null; 060 protected JLabel entryTextDIFFUSE = null; 061 protected JLabel entryTextCOLORTARGET = null; 062 protected JLabel entryTextSHININESS = null; 063 protected JLabel entryTextLIGHTING = null; 064 protected JLabel entryTextTRANSPARENCY = null; 065 protected JLabel entryTextTRANSPARENCY_MODE = null; 066 protected JLabel entryTextTRANSPARENCY_SRC_BLEND_FUNCTION = null; 067 protected JLabel entryTextTRANSPARENCY_DST_BLEND_FUNCTION = null; 068 protected JLabel entryTextTEXTURE_USE = null; 069 protected JLabel entryTextTEXTURE_FILE = null; 070 protected JLabel entryTextTEXTURE_TRANSFORM1 = null; 071 protected JLabel entryTextTEXTURE_TRANSFORM2 = null; 072 protected JLabel entryTextTEXTURE_TRANSFORM3 = null; 073 protected JLabel entryTextRotation = null; 074 protected JLabel entryTextScale = null; 075 protected JLabel entryTextTranslation = null; 076 protected JLabel entryTextTEXTURE_PERSPECTIVE_CORRECTION_MODE = null; 077 protected JLabel entryTextTEXTURE_MODE = null; 078 protected JLabel entryTextTEXTURE_BLEND = null; 079 protected JLabel entryTextTEXTURE_COMBINE_RGB_MODE = null; 080 protected JLabel entryTextTEXTURE_COMBINE_RGB_SOURCE = null; 081 protected JLabel entryTextTEXTURE_COMBINE_RGB_FUNCTION = null; 082 protected JLabel entryTextTEXTURE_COMBINE_RGB_SCALE = null; 083 protected JLabel entryTextTEXTURE_COMBINE_ALPHA_MODE = null; 084 protected JLabel entryTextTEXTURE_COMBINE_ALPHA_SOURCE = null; 085 protected JLabel entryTextTEXTURE_COMBINE_ALPHA_FUNCTION = null; 086 protected JLabel entryTextTEXTURE_COMBINE_ALPHA_SCALE = null; 087 088 protected Appearance3DChooser app; 089 090 /** 091 * Constructor that draw a Frame with all the Appearance3DChooser Parameters values. 092 * @param appear the Appearance3DChooser Object 093 * 094 */ 095 public Appearance3DChooserInfo(Appearance3DChooser appear) 096 { 097 this(appear, new Dimension(900,520)); 098 } 099 100 101 /** 102 * Constructor that draw a Frame with all the Appearance3DChooser Parameters values. 103 * @param appear the Appearance3DChooser Object 104 * @param d the text Panel Dimension 105 * 106 */ 107 public Appearance3DChooserInfo(Appearance3DChooser appear, Dimension d) 108 { 109 this.app = appear; 110 111 /** 112 * Class used to update the Parameters Info every 500ms. 113 * 114 */ 115 class updateAppearance3DChooserInfo extends Thread 116 { 117 118 /** 119 * Start a thread for updating Appareance3DChooser Parameters Info every 500ms. 120 * 121 */ 122 public void run() 123 { 124 while(true) 125 { 126 try { 127 Thread.sleep(500); 128 } 129 catch (Exception e) 130 { 131 } 132 133 updateAppearance3DChooserInfo(); 134 135 } 136 } 137 } 138 139 final updateAppearance3DChooserInfo updtInfo = new updateAppearance3DChooserInfo(); 140 141 final JFrame parametersInfoBox = new JFrame(Info.ressources.getObject("Parameters_Info").toString()); 142 parametersInfoBox.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); 143 parametersInfoBox.setVisible(true); 144 145 JPanel parametersInfoBoxPanel = new JPanel(new BorderLayout()); 146 GridBagLayout gbmain = new GridBagLayout(); 147 parametersInfoBoxPanel.setLayout(gbmain); 148 parametersInfoBox.getContentPane().add(parametersInfoBoxPanel, BorderLayout.CENTER); 149 150 JPanel textPanel = new JPanel(); 151 GridBagLayout gbtextPanel = new GridBagLayout(); 152 textPanel.setLayout(gbtextPanel); 153 JScrollPane textScrolled = new JScrollPane(textPanel); 154 textScrolled.setPreferredSize(d); 155 156 JLabel entryText; 157 GridBagLayout gb; 158 159 // Create Material Panel 160 JPanel materialPanel = new JPanel(); 161 materialPanel.setBorder(BorderFactory.createTitledBorder(Info.ressources.getObject("Material").toString())); 162 gb = new GridBagLayout(); 163 materialPanel.setLayout(gb); 164 165 entryText = new JLabel("EMISSIVE"); 166 entryText.setFont(new Font("SansSerif", Font.BOLD, 11)); 167 materialPanel.add(entryText); 168 gb.setConstraints(entryText, new GridBagLayoutConstraint(GridBagConstraints.EAST,0,1, 169 new Insets(0,8,0,15))); 170 171 entryTextEMISSIVE = new JLabel(); 172 entryTextEMISSIVE.setFont(new Font("SansSerif", Font.PLAIN, 10)); 173 materialPanel.add(entryTextEMISSIVE); 174 gb.setConstraints(entryTextEMISSIVE, new GridBagLayoutConstraint(GridBagConstraints.WEST,1,1, 175 new Insets(0,8,0,15))); 176 177 entryText = new JLabel("AMBIENT"); 178 entryText.setFont(new Font("SansSerif", Font.BOLD, 11)); 179 materialPanel.add(entryText); 180 gb.setConstraints(entryText, new GridBagLayoutConstraint(GridBagConstraints.EAST,0,2, 181 new Insets(0,8,0,15))); 182 183 entryTextAMBIENT = new JLabel(); 184 entryTextAMBIENT.setFont(new Font("SansSerif", Font.PLAIN, 10)); 185 materialPanel.add(entryTextAMBIENT); 186 gb.setConstraints(entryTextAMBIENT, new GridBagLayoutConstraint(GridBagConstraints.WEST,1,2, 187 new Insets(0,8,0,15))); 188 189 entryText = new JLabel("DIFFUSE"); 190 entryText.setFont(new Font("SansSerif", Font.BOLD, 11)); 191 materialPanel.add(entryText); 192 gb.setConstraints(entryText, new GridBagLayoutConstraint(GridBagConstraints.EAST,0,3, 193 new Insets(0,8,0,15))); 194 195 entryTextDIFFUSE = new JLabel(); 196 entryTextDIFFUSE.setFont(new Font("SansSerif", Font.PLAIN, 10)); 197 materialPanel.add(entryTextDIFFUSE); 198 gb.setConstraints(entryTextDIFFUSE, new GridBagLayoutConstraint(GridBagConstraints.WEST,1,3, 199 new Insets(0,8,0,15))); 200 201 entryText = new JLabel("SPECULAR"); 202 entryText.setFont(new Font("SansSerif", Font.BOLD, 11)); 203 materialPanel.add(entryText); 204 gb.setConstraints(entryText, new GridBagLayoutConstraint(GridBagConstraints.EAST,0,4, 205 new Insets(0,8,0,15))); 206 207 entryTextSPECULAR = new JLabel(); 208 entryTextSPECULAR.setFont(new Font("SansSerif", Font.PLAIN, 10)); 209 materialPanel.add(entryTextSPECULAR); 210 gb.setConstraints(entryTextSPECULAR, new GridBagLayoutConstraint(GridBagConstraints.WEST,1,4, 211 new Insets(0,8,0,15))); 212 213 entryText = new JLabel("LIGHTING"); 214 entryText.setFont(new Font("SansSerif", Font.BOLD, 11)); 215 materialPanel.add(entryText); 216 gb.setConstraints(entryText, new GridBagLayoutConstraint(GridBagConstraints.EAST,0,5, 217 new Insets(0,8,0,15))); 218 219 entryTextLIGHTING = new JLabel(); 220 entryTextLIGHTING.setFont(new Font("SansSerif", Font.PLAIN, 10)); 221 materialPanel.add(entryTextLIGHTING); 222 gb.setConstraints(entryTextLIGHTING, new GridBagLayoutConstraint(GridBagConstraints.WEST,1,5, 223 new Insets(0,8,0,15))); 224 225 entryText = new JLabel("SHININESS"); 226 entryText.setFont(new Font("SansSerif", Font.BOLD, 11)); 227 materialPanel.add(entryText); 228 gb.setConstraints(entryText, new GridBagLayoutConstraint(GridBagConstraints.EAST,0,6, 229 new Insets(0,8,0,15))); 230 231 entryTextSHININESS = new JLabel(); 232 entryTextSHININESS.setFont(new Font("SansSerif", Font.PLAIN, 10)); 233 materialPanel.add(entryTextSHININESS); 234 gb.setConstraints(entryTextSHININESS, new GridBagLayoutConstraint(GridBagConstraints.WEST,1,6, 235 new Insets(0,8,0,15))); 236 237 entryText = new JLabel("COLORTARGET"); 238 entryText.setFont(new Font("SansSerif", Font.BOLD, 11)); 239 materialPanel.add(entryText); 240 gb.setConstraints(entryText, new GridBagLayoutConstraint(GridBagConstraints.EAST,0,7, 241 new Insets(0,8,0,15))); 242 243 entryTextCOLORTARGET = new JLabel(); 244 entryTextCOLORTARGET.setFont(new Font("SansSerif", Font.PLAIN, 10)); 245 materialPanel.add(entryTextCOLORTARGET); 246 gb.setConstraints(entryTextCOLORTARGET, new GridBagLayoutConstraint(GridBagConstraints.WEST,1,7, 247 new Insets(0,8,0,15))); 248 249 // Add Material Panel 250 textPanel.add(materialPanel); 251 gbtextPanel.setConstraints(materialPanel, new GridBagLayoutConstraint(GridBagConstraints.EAST,0,0, 252 new Insets(0,15,0,0))); 253 254 // Create Transparency Panel 255 JPanel transparencyPanel = new JPanel(); 256 transparencyPanel.setBorder(BorderFactory.createTitledBorder(Info.ressources.getObject("Transparency").toString())); 257 gb = new GridBagLayout(); 258 transparencyPanel.setLayout(gb); 259 260 entryText = new JLabel("TRANSPARENCY_MODE"); 261 entryText.setFont(new Font("SansSerif", Font.BOLD, 11)); 262 transparencyPanel.add(entryText); 263 gb.setConstraints(entryText, new GridBagLayoutConstraint(GridBagConstraints.EAST,0,8, 264 new Insets(0,8,0,15))); 265 266 entryTextTRANSPARENCY_MODE = new JLabel(); 267 entryTextTRANSPARENCY_MODE.setFont(new Font("SansSerif", Font.PLAIN, 10)); 268 transparencyPanel.add(entryTextTRANSPARENCY_MODE); 269 gb.setConstraints(entryTextTRANSPARENCY_MODE, new GridBagLayoutConstraint(GridBagConstraints.WEST,1,8, 270 new Insets(0,8,0,15))); 271 272 entryText = new JLabel("TRANSPARENCY_SRC_BLEND_FUNCTION"); 273 entryText.setFont(new Font("SansSerif", Font.BOLD, 11)); 274 transparencyPanel.add(entryText); 275 gb.setConstraints(entryText, new GridBagLayoutConstraint(GridBagConstraints.EAST,0,9, 276 new Insets(0,8,0,15))); 277 278 entryTextTRANSPARENCY_SRC_BLEND_FUNCTION = new JLabel(); 279 entryTextTRANSPARENCY_SRC_BLEND_FUNCTION.setFont(new Font("SansSerif", Font.PLAIN, 10)); 280 transparencyPanel.add(entryTextTRANSPARENCY_SRC_BLEND_FUNCTION); 281 gb.setConstraints(entryTextTRANSPARENCY_SRC_BLEND_FUNCTION, new GridBagLayoutConstraint(GridBagConstraints.WEST,1,9, 282 new Insets(0,8,0,15))); 283 284 entryText = new JLabel("TRANSPARENCY_DST_BLEND_FUNCTION"); 285 entryText.setFont(new Font("SansSerif", Font.BOLD, 11)); 286 transparencyPanel.add(entryText); 287 gb.setConstraints(entryText, new GridBagLayoutConstraint(GridBagConstraints.EAST,0,10, 288 new Insets(0,8,0,15))); 289 290 entryTextTRANSPARENCY_DST_BLEND_FUNCTION = new JLabel(); 291 entryTextTRANSPARENCY_DST_BLEND_FUNCTION.setFont(new Font("SansSerif", Font.PLAIN, 10)); 292 transparencyPanel.add(entryTextTRANSPARENCY_DST_BLEND_FUNCTION); 293 gb.setConstraints(entryTextTRANSPARENCY_DST_BLEND_FUNCTION, new GridBagLayoutConstraint(GridBagConstraints.WEST,1,10, 294 new Insets(0,8,0,15))); 295 296 entryText = new JLabel("TRANSPARENCY"); 297 entryText.setFont(new Font("SansSerif", Font.BOLD, 11)); 298 transparencyPanel.add(entryText); 299 gb.setConstraints(entryText, new GridBagLayoutConstraint(GridBagConstraints.EAST,0,7, 300 new Insets(0,8,0,15))); 301 302 entryTextTRANSPARENCY = new JLabel(); 303 entryTextTRANSPARENCY.setFont(new Font("SansSerif", Font.PLAIN, 10)); 304 transparencyPanel.add(entryTextTRANSPARENCY); 305 gb.setConstraints(entryTextTRANSPARENCY, new GridBagLayoutConstraint(GridBagConstraints.WEST,1,7, 306 new Insets(0,8,0,15))); 307 308 // Add Transparency Panel 309 textPanel.add(transparencyPanel); 310 gbtextPanel.setConstraints(transparencyPanel, new GridBagLayoutConstraint(GridBagConstraints.WEST,1,0, 311 new Insets(0,15,0,0))); 312 313 // Create Texture Panel 314 JPanel texturePanel = new JPanel(); 315 texturePanel.setBorder(BorderFactory.createTitledBorder(Info.ressources.getObject("Texture").toString())); 316 gb = new GridBagLayout(); 317 texturePanel.setLayout(gb); 318 319 entryText = new JLabel("TEXTURE_USE"); 320 entryText.setFont(new Font("SansSerif", Font.BOLD, 11)); 321 texturePanel.add(entryText); 322 gb.setConstraints(entryText, new GridBagLayoutConstraint(GridBagConstraints.EAST,0,11, 323 new Insets(0,8,0,15))); 324 325 entryTextTEXTURE_USE = new JLabel(); 326 entryTextTEXTURE_USE.setFont(new Font("SansSerif", Font.PLAIN, 10)); 327 texturePanel.add(entryTextTEXTURE_USE); 328 gb.setConstraints(entryTextTEXTURE_USE, new GridBagLayoutConstraint(GridBagConstraints.WEST,1,11, 329 new Insets(0,8,0,15))); 330 331 entryText = new JLabel("TEXTURE_FILE"); 332 entryText.setFont(new Font("SansSerif", Font.BOLD, 11)); 333 texturePanel.add(entryText); 334 gb.setConstraints(entryText, new GridBagLayoutConstraint(GridBagConstraints.EAST,0,12, 335 new Insets(0,8,0,15))); 336 337 entryTextTEXTURE_FILE = new JLabel(); 338 entryTextTEXTURE_FILE.setFont(new Font("SansSerif", Font.PLAIN, 10)); 339 texturePanel.add(entryTextTEXTURE_FILE); 340 gb.setConstraints(entryTextTEXTURE_FILE, new GridBagLayoutConstraint(GridBagConstraints.WEST,1,12, 341 new Insets(0,8,0,15))); 342 343 entryText = new JLabel("TEXTURE_TRANSFORM"); 344 entryText.setFont(new Font("SansSerif", Font.BOLD, 11)); 345 texturePanel.add(entryText); 346 gb.setConstraints(entryText, new GridBagLayoutConstraint(GridBagConstraints.EAST,0,13, 347 new Insets(0,8,0,15))); 348 349 entryTextTEXTURE_TRANSFORM1 = new JLabel(); 350 entryTextTEXTURE_TRANSFORM1.setFont(new Font("Courier", Font.PLAIN, 10)); 351 texturePanel.add(entryTextTEXTURE_TRANSFORM1); 352 gb.setConstraints(entryTextTEXTURE_TRANSFORM1, new GridBagLayoutConstraint(GridBagConstraints.WEST,1,13, 353 new Insets(0,8,0,15))); 354 entryTextTEXTURE_TRANSFORM2 = new JLabel(); 355 entryTextTEXTURE_TRANSFORM2.setFont(new Font("Courier", Font.PLAIN, 10)); 356 texturePanel.add(entryTextTEXTURE_TRANSFORM2); 357 gb.setConstraints(entryTextTEXTURE_TRANSFORM2, new GridBagLayoutConstraint(GridBagConstraints.WEST,1,14, 358 new Insets(0,8,0,15))); 359 360 entryTextTEXTURE_TRANSFORM3 = new JLabel(); 361 entryTextTEXTURE_TRANSFORM3.setFont(new Font("Courier", Font.PLAIN, 10)); 362 texturePanel.add(entryTextTEXTURE_TRANSFORM3); 363 gb.setConstraints(entryTextTEXTURE_TRANSFORM3, new GridBagLayoutConstraint(GridBagConstraints.WEST,1,15, 364 new Insets(0,8,0,15))); 365 366 entryTextRotation = new JLabel(); 367 entryTextRotation.setFont(new Font("SansSerif", Font.PLAIN, 10)); 368 texturePanel.add(entryTextRotation); 369 gb.setConstraints(entryTextRotation, new GridBagLayoutConstraint(GridBagConstraints.WEST,1,17, 370 new Insets(8,8,0,15))); 371 372 entryTextScale = new JLabel(); 373 entryTextScale.setFont(new Font("SansSerif", Font.PLAIN, 10)); 374 texturePanel.add(entryTextScale); 375 gb.setConstraints(entryTextScale, new GridBagLayoutConstraint(GridBagConstraints.WEST,1,18, 376 new Insets(0,8,0,15))); 377 378 entryTextTranslation = new JLabel(); 379 entryTextTranslation.setFont(new Font("SansSerif", Font.PLAIN, 10)); 380 texturePanel.add(entryTextTranslation); 381 gb.setConstraints(entryTextTranslation, new GridBagLayoutConstraint(GridBagConstraints.WEST,1,19, 382 new Insets(0,8,0,15))); 383 384 entryText = new JLabel("TEXTURE_PERSPECTIVE_CORRECTION_MODE"); 385 entryText.setFont(new Font("SansSerif", Font.BOLD, 11)); 386 texturePanel.add(entryText); 387 gb.setConstraints(entryText, new GridBagLayoutConstraint(GridBagConstraints.EAST,0,20, 388 new Insets(0,8,0,15))); 389 390 entryTextTEXTURE_PERSPECTIVE_CORRECTION_MODE = new JLabel(); 391 entryTextTEXTURE_PERSPECTIVE_CORRECTION_MODE.setFont(new Font("SansSerif", Font.PLAIN, 10)); 392 texturePanel.add(entryTextTEXTURE_PERSPECTIVE_CORRECTION_MODE); 393 gb.setConstraints(entryTextTEXTURE_PERSPECTIVE_CORRECTION_MODE, new GridBagLayoutConstraint(GridBagConstraints.WEST,1,20, 394 new Insets(0,8,0,15))); 395 396 entryText = new JLabel("TEXTURE_MODE"); 397 entryText.setFont(new Font("SansSerif", Font.BOLD, 11)); 398 texturePanel.add(entryText); 399 gb.setConstraints(entryText, new GridBagLayoutConstraint(GridBagConstraints.EAST,0,21, 400 new Insets(0,8,0,15))); 401 402 entryTextTEXTURE_MODE = new JLabel(); 403 entryTextTEXTURE_MODE.setFont(new Font("SansSerif", Font.PLAIN, 10)); 404 texturePanel.add(entryTextTEXTURE_MODE); 405 gb.setConstraints(entryTextTEXTURE_MODE, new GridBagLayoutConstraint(GridBagConstraints.WEST,1,21, 406 new Insets(0,8,0,15))); 407 408 entryText = new JLabel("TEXTURE_BLEND"); 409 entryText.setFont(new Font("SansSerif", Font.BOLD, 11)); 410 texturePanel.add(entryText); 411 gb.setConstraints(entryText, new GridBagLayoutConstraint(GridBagConstraints.EAST,0,22, 412 new Insets(0,8,0,15))); 413 414 entryTextTEXTURE_BLEND = new JLabel(); 415 entryTextTEXTURE_BLEND.setFont(new Font("SansSerif", Font.PLAIN, 10)); 416 texturePanel.add(entryTextTEXTURE_BLEND); 417 gb.setConstraints(entryTextTEXTURE_BLEND, new GridBagLayoutConstraint(GridBagConstraints.WEST,1,22, 418 new Insets(0,8,0,15))); 419 420 entryText = new JLabel("TEXTURE_COMBINE_RGB_MODE"); 421 entryText.setFont(new Font("SansSerif", Font.BOLD, 11)); 422 texturePanel.add(entryText); 423 gb.setConstraints(entryText, new GridBagLayoutConstraint(GridBagConstraints.EAST,0,23, 424 new Insets(0,8,0,15))); 425 426 entryTextTEXTURE_COMBINE_RGB_MODE = new JLabel(); 427 entryTextTEXTURE_COMBINE_RGB_MODE.setFont(new Font("SansSerif", Font.PLAIN, 10)); 428 texturePanel.add(entryTextTEXTURE_COMBINE_RGB_MODE); 429 gb.setConstraints(entryTextTEXTURE_COMBINE_RGB_MODE, new GridBagLayoutConstraint(GridBagConstraints.WEST,1,23, 430 new Insets(0,8,0,15))); 431 432 433 entryText = new JLabel("TEXTURE_COMBINE_RGB_SOURCE"); 434 entryText.setFont(new Font("SansSerif", Font.BOLD, 11)); 435 texturePanel.add(entryText); 436 gb.setConstraints(entryText, new GridBagLayoutConstraint(GridBagConstraints.EAST,0,24, 437 new Insets(0,8,0,15))); 438 439 entryTextTEXTURE_COMBINE_RGB_SOURCE = new JLabel(); 440 entryTextTEXTURE_COMBINE_RGB_SOURCE.setFont(new Font("SansSerif", Font.PLAIN, 10)); 441 texturePanel.add(entryTextTEXTURE_COMBINE_RGB_SOURCE); 442 gb.setConstraints(entryTextTEXTURE_COMBINE_RGB_SOURCE, new GridBagLayoutConstraint(GridBagConstraints.WEST,1,24, 443 new Insets(0,8,0,15))); 444 445 446 entryText = new JLabel("TEXTURE_COMBINE_RGB_FUNCTION"); 447 entryText.setFont(new Font("SansSerif", Font.BOLD, 11)); 448 texturePanel.add(entryText); 449 gb.setConstraints(entryText, new GridBagLayoutConstraint(GridBagConstraints.EAST,0,25, 450 new Insets(0,8,0,15))); 451 452 entryTextTEXTURE_COMBINE_RGB_FUNCTION = new JLabel(); 453 entryTextTEXTURE_COMBINE_RGB_FUNCTION.setFont(new Font("SansSerif", Font.PLAIN, 10)); 454 texturePanel.add(entryTextTEXTURE_COMBINE_RGB_FUNCTION); 455 gb.setConstraints(entryTextTEXTURE_COMBINE_RGB_FUNCTION, new GridBagLayoutConstraint(GridBagConstraints.WEST,1,25, 456 new Insets(0,8,0,15))); 457 458 459 460 entryText = new JLabel("TEXTURE_COMBINE_RGB_SCALE"); 461 entryText.setFont(new Font("SansSerif", Font.BOLD, 11)); 462 texturePanel.add(entryText); 463 gb.setConstraints(entryText, new GridBagLayoutConstraint(GridBagConstraints.EAST,0,26, 464 new Insets(0,8,0,15))); 465 466 entryTextTEXTURE_COMBINE_RGB_SCALE = new JLabel(); 467 entryTextTEXTURE_COMBINE_RGB_SCALE.setFont(new Font("SansSerif", Font.PLAIN, 10)); 468 texturePanel.add(entryTextTEXTURE_COMBINE_RGB_SCALE); 469 gb.setConstraints(entryTextTEXTURE_COMBINE_RGB_SCALE, new GridBagLayoutConstraint(GridBagConstraints.WEST,1,26, 470 new Insets(0,8,0,15))); 471 472 entryText = new JLabel("TEXTURE_COMBINE_ALPHA_MODE"); 473 entryText.setFont(new Font("SansSerif", Font.BOLD, 11)); 474 texturePanel.add(entryText); 475 gb.setConstraints(entryText, new GridBagLayoutConstraint(GridBagConstraints.EAST,0,27, 476 new Insets(0,8,0,15))); 477 478 entryTextTEXTURE_COMBINE_ALPHA_MODE = new JLabel(); 479 entryTextTEXTURE_COMBINE_ALPHA_MODE.setFont(new Font("SansSerif", Font.PLAIN, 10)); 480 texturePanel.add(entryTextTEXTURE_COMBINE_ALPHA_MODE); 481 gb.setConstraints(entryTextTEXTURE_COMBINE_ALPHA_MODE, new GridBagLayoutConstraint(GridBagConstraints.WEST,1,27, 482 new Insets(0,8,0,15))); 483 484 entryText = new JLabel("TEXTURE_COMBINE_ALPHA_SOURCE"); 485 entryText.setFont(new Font("SansSerif", Font.BOLD, 11)); 486 texturePanel.add(entryText); 487 gb.setConstraints(entryText, new GridBagLayoutConstraint(GridBagConstraints.EAST,0,28, 488 new Insets(0,8,0,15))); 489 490 entryTextTEXTURE_COMBINE_ALPHA_SOURCE = new JLabel(); 491 entryTextTEXTURE_COMBINE_ALPHA_SOURCE.setFont(new Font("SansSerif", Font.PLAIN, 10)); 492 texturePanel.add(entryTextTEXTURE_COMBINE_ALPHA_SOURCE); 493 gb.setConstraints(entryTextTEXTURE_COMBINE_ALPHA_SOURCE, new GridBagLayoutConstraint(GridBagConstraints.WEST,1,28, 494 new Insets(0,8,0,15))); 495 496 entryText = new JLabel("TEXTURE_COMBINE_ALPHA_FUNCTION"); 497 entryText.setFont(new Font("SansSerif", Font.BOLD, 11)); 498 texturePanel.add(entryText); 499 gb.setConstraints(entryText, new GridBagLayoutConstraint(GridBagConstraints.EAST,0,29, 500 new Insets(0,8,0,15))); 501 502 entryTextTEXTURE_COMBINE_ALPHA_FUNCTION = new JLabel(); 503 entryTextTEXTURE_COMBINE_ALPHA_FUNCTION.setFont(new Font("SansSerif", Font.PLAIN, 10)); 504 texturePanel.add(entryTextTEXTURE_COMBINE_ALPHA_FUNCTION); 505 gb.setConstraints(entryTextTEXTURE_COMBINE_ALPHA_FUNCTION, new GridBagLayoutConstraint(GridBagConstraints.WEST,1,29, 506 new Insets(0,8,0,15))); 507 508 entryText = new JLabel("TEXTURE_COMBINE_ALPHA_SCALE"); 509 entryText.setFont(new Font("SansSerif", Font.BOLD, 11)); 510 texturePanel.add(entryText); 511 gb.setConstraints(entryText, new GridBagLayoutConstraint(GridBagConstraints.EAST,0,30, 512 new Insets(0,8,0,15))); 513 514 entryTextTEXTURE_COMBINE_ALPHA_SCALE = new JLabel(); 515 entryTextTEXTURE_COMBINE_ALPHA_SCALE.setFont(new Font("SansSerif", Font.PLAIN, 10)); 516 texturePanel.add(entryTextTEXTURE_COMBINE_ALPHA_SCALE); 517 gb.setConstraints(entryTextTEXTURE_COMBINE_ALPHA_SCALE, new GridBagLayoutConstraint(GridBagConstraints.WEST,1,30, 518 new Insets(0,8,0,15))); 519 520 //Add Texture Panel 521 textPanel.add(texturePanel); 522 GridBagConstraints gc = new GridBagLayoutConstraint(GridBagConstraints.WEST,0,1, 523 new Insets(15,15,0,0)); 524 gc.gridwidth=2; 525 gbtextPanel.setConstraints(texturePanel, gc); 526 527 parametersInfoBoxPanel.add(textScrolled); 528 gbmain.setConstraints(textScrolled, new GridBagLayoutConstraint(GridBagConstraints.WEST,0,0, 529 new Insets(8,8,8,8))); 530 531 JButton okbutton = new JButton(Info.ressources.getObject("OK").toString()); 532 parametersInfoBoxPanel.add(okbutton); 533 gbmain.setConstraints(okbutton, new GridBagLayoutConstraint(GridBagConstraints.EAST,0,1, 534 new Insets(15,8,8,8))); 535 okbutton.addActionListener(new ActionListener() { 536 public void actionPerformed(ActionEvent e) { 537 updtInfo.stop(); 538 parametersInfoBox.setVisible(false); 539 parametersInfoBox.dispose(); 540 } 541 }); 542 543 updtInfo.start(); 544 545 parametersInfoBox.pack(); 546 parametersInfoBox.setResizable(false); 547 parametersInfoBox.setVisible(true); 548 549 } 550 551 552 /** 553 * Function that updates all the parameters info. 554 * 555 */ 556 protected void updateAppearance3DChooserInfo() 557 { 558 entryTextSPECULAR.setText("= " + "(" + app.getSpecularColor()[0]+ ", " 559 + app.getSpecularColor()[1]+ ", " 560 + app.getSpecularColor()[2]+")"); 561 562 entryTextAMBIENT.setText("= " + "(" + app.getAmbientColor()[0]+ ", " 563 + app.getAmbientColor()[1]+ ", " 564 + app.getAmbientColor()[2]+")"); 565 566 entryTextEMISSIVE.setText("= " + "(" + app.getEmissiveColor()[0]+ ", " 567 + app.getEmissiveColor()[1]+ ", " 568 + app.getEmissiveColor()[2]+")"); 569 570 entryTextDIFFUSE.setText("= " + "(" + app.getDiffuseColor()[0]+ ", " 571 + app.getDiffuseColor()[1]+ ", " 572 + app.getDiffuseColor()[2]+")"); 573 574 entryTextCOLORTARGET.setText("= " + colorTargetToString(app.getColorTarget())); 575 576 entryTextSHININESS.setText("= " + app.getShininess()); 577 578 entryTextLIGHTING.setText("= " + app.getLighting()); 579 580 entryTextTRANSPARENCY.setText("= " + app.getTransparency()); 581 582 entryTextTRANSPARENCY_MODE.setText("= " + transparencyModeToString(app.getTransparencyMode())); 583 584 entryTextTRANSPARENCY_SRC_BLEND_FUNCTION.setText("= " + transparencyBlendFunctionToString(app.getTransparencySrcBlendFunction())); 585 586 entryTextTRANSPARENCY_DST_BLEND_FUNCTION.setText("= " + transparencyBlendFunctionToString(app.getTransparencyDstBlendFunction())); 587 588 entryTextTEXTURE_USE.setText("= " + app.isTextureSet()); 589 590 entryTextTEXTURE_FILE.setText("= " + app.getTextureFile()); 591 592 Matrix4d m = new Matrix4d(); 593 Transform3D t3d = new Transform3D(app.getTextureTransform()); 594 t3d.get(m); 595 596 String str=" "; 597 598 entryTextTEXTURE_TRANSFORM1.setText("= " + 599 str.substring(String.valueOf((float)Math.round(m.getElement(0,0) * 100) / 100).length()) 600 + (float)Math.round(m.getElement(0,0) * 100) / 100 + ", " + 601 str.substring(String.valueOf((float)Math.round(m.getElement(0,1) * 100) / 100).length()) 602 + (float)Math.round(m.getElement(0,1) * 100) / 100 + ", " + 603 str.substring(String.valueOf((float)Math.round(m.getElement(0,2) * 100) / 100).length()) 604 + (float)Math.round(m.getElement(0,2) * 100) / 100 605 ); 606 607 entryTextTEXTURE_TRANSFORM2.setText(" " + 608 str.substring(String.valueOf((float)Math.round(m.getElement(1,0) * 100) / 100).length()) 609 + (float)Math.round(m.getElement(1,0) * 100) / 100 + ", " + 610 str.substring(String.valueOf((float)Math.round(m.getElement(1,1) * 100) / 100).length()) 611 + (float)Math.round(m.getElement(1,1) * 100) / 100 + ", " + 612 str.substring(String.valueOf((float)Math.round(m.getElement(1,2) * 100) / 100).length()) 613 + (float)Math.round(m.getElement(1,2) * 100) / 100 614 ); 615 616 entryTextTEXTURE_TRANSFORM3.setText(" " + 617 str.substring(String.valueOf((float)Math.round(m.getElement(2,0) * 100) / 100).length()) 618 + (float)Math.round(m.getElement(2,0) * 100) / 100 + ", " + 619 str.substring(String.valueOf((float)Math.round(m.getElement(2,1) * 100) / 100).length()) 620 + (float)Math.round(m.getElement(2,1) * 100) / 100 + ", " + 621 str.substring(String.valueOf((float)Math.round(m.getElement(2,2) * 100) / 100).length()) 622 + (float)Math.round(m.getElement(2,2) * 100) / 100 623 ); 624 625 entryTextRotation.setText("Rotation : z= " + app.getTextureTransformRotZ()); 626 627 entryTextScale.setText("Scale : x= " + app.getTextureTransformScaleX() + ", y= " +app.getTextureTransformScaleY()); 628 629 entryTextTranslation.setText("Translation : x= " + app.getTextureTransformTranslatX() + ", y= " +app.getTextureTransformTranslatY()); 630 631 entryTextTEXTURE_PERSPECTIVE_CORRECTION_MODE.setText("= " + texturePerspectiveCorrectionModeToString(app.getTexturePerspectiveCorrectionMode())); 632 633 entryTextTEXTURE_MODE.setText("= " + textureModeToString(app.getTextureMode())); 634 635 entryTextTEXTURE_BLEND.setText("= " + "(" + 636 app.getTextureBlendColor()[0] + ", " + 637 app.getTextureBlendColor()[1] + ", " + 638 app.getTextureBlendColor()[2] + ", " + 639 app.getTextureBlendColor()[3] 640 + ")"); 641 642 entryTextTEXTURE_COMBINE_RGB_MODE.setText("= " + textureCombineModeToString(app.getTextureCombineRGBMode())); 643 644 entryTextTEXTURE_COMBINE_RGB_SOURCE.setText("= " +"(" + 645 textureCombineSourceToString(app.getTextureCombineRGBSource()[0]) + ", " + 646 textureCombineSourceToString(app.getTextureCombineRGBSource()[1]) + ", " + 647 textureCombineSourceToString(app.getTextureCombineRGBSource()[2]) 648 + ")"); 649 650 entryTextTEXTURE_COMBINE_RGB_FUNCTION.setText("= " +"(" + 651 textureCombineFunctionToString(app.getTextureCombineRGBFunction()[0]) + ", " + 652 textureCombineFunctionToString(app.getTextureCombineRGBFunction()[1]) + ", " + 653 textureCombineFunctionToString(app.getTextureCombineRGBFunction()[2]) 654 + ")"); 655 656 entryTextTEXTURE_COMBINE_RGB_SCALE.setText("= " + app.getTextureCombineRGBScale()); 657 658 entryTextTEXTURE_COMBINE_ALPHA_MODE.setText("= " + textureCombineModeToString(app.getTextureCombineAlphaMode())); 659 660 entryTextTEXTURE_COMBINE_ALPHA_SOURCE.setText("= " + "(" + 661 textureCombineSourceToString(app.getTextureCombineAlphaSource()[0]) + ", " + 662 textureCombineSourceToString(app.getTextureCombineAlphaSource()[1]) + ", " + 663 textureCombineSourceToString(app.getTextureCombineAlphaSource()[2]) 664 + ")"); 665 666 entryTextTEXTURE_COMBINE_ALPHA_FUNCTION.setText("= " + "(" + 667 textureCombineFunctionToString(app.getTextureCombineAlphaFunction()[0]) + ", " + 668 textureCombineFunctionToString(app.getTextureCombineAlphaFunction()[1]) + ", " + 669 textureCombineFunctionToString(app.getTextureCombineAlphaFunction()[2]) 670 + ")"); 671 672 entryTextTEXTURE_COMBINE_ALPHA_SCALE.setText("= " + app.getTextureCombineAlphaScale()); 673 } 674 675 676 /** 677 * Convert TransparencyAttributes Mode to String. 678 * @return a String for the TransparencyAttributes Mode. 679 */ 680 public static String transparencyModeToString (int m) 681 { 682 switch (m) 683 { 684 case TransparencyAttributes.BLENDED: 685 return "BLENDED"; 686 case TransparencyAttributes.FASTEST: 687 return "FASTEST"; 688 case TransparencyAttributes.NICEST: 689 return "NICEST"; 690 case TransparencyAttributes.NONE: 691 return "NONE"; 692 case TransparencyAttributes.SCREEN_DOOR: 693 return "SCREEN_DOOR"; 694 default : 695 return "-1"; 696 } 697 } 698 699 700 /** 701 * Convert TransparencyAttributes Source or Destination Blend Function to String. 702 * @return the corresponding String. 703 */ 704 public static String transparencyBlendFunctionToString (int f) 705 { 706 switch (f) 707 { 708 case TransparencyAttributes.BLEND_ZERO: 709 return "BLEND_ZERO"; 710 case TransparencyAttributes.BLEND_ONE: 711 return "BLEND_ONE"; 712 case TransparencyAttributes.BLEND_SRC_ALPHA: 713 return "BLEND_SRC_ALPHA"; 714 case TransparencyAttributes.BLEND_ONE_MINUS_SRC_ALPHA: 715 return "BLEND_ONE_MINUS_SRC_ALPHA"; 716 case TransparencyAttributes.BLEND_DST_COLOR: 717 return "BLEND_DST_COLOR"; 718 case TransparencyAttributes.BLEND_ONE_MINUS_DST_COLOR: 719 return "BLEND_ONE_MINUS_DST_COLOR"; 720 case TransparencyAttributes.BLEND_SRC_COLOR: 721 return "BLEND_SRC_COLOR"; 722 case TransparencyAttributes.BLEND_ONE_MINUS_SRC_COLOR: 723 return "BLEND_ONE_MINUS_SRC_COLOR"; 724 default : 725 return "-1"; 726 } 727 } 728 729 730 /** 731 * Convert TextureAttributes Perspective Correction Mode to String. 732 * @return the corresponding String. 733 */ 734 public static String texturePerspectiveCorrectionModeToString (int m) 735 { 736 switch (m) 737 { 738 case TextureAttributes.NICEST: 739 return "NICEST"; 740 case TextureAttributes.FASTEST: 741 return "FASTEST"; 742 default : 743 return "-1"; 744 } 745 } 746 747 748 /** 749 * Convert TextureAttributes Mode to String. 750 * @return the corresponding String. 751 */ 752 public static String textureModeToString (int m) 753 { 754 switch (m) 755 { 756 case TextureAttributes.MODULATE: 757 return "MODULATE"; 758 case TextureAttributes.DECAL: 759 return "DECAL"; 760 case TextureAttributes.BLEND: 761 return "BLEND"; 762 case TextureAttributes.REPLACE: 763 return "REPLACE"; 764 case TextureAttributes.COMBINE: 765 return "COMBINE"; 766 default : 767 return "-1"; 768 } 769 } 770 771 772 /** 773 * Convert TextureAttributes Combine Mode to String. 774 * @return the corresponding String. 775 */ 776 public static String textureCombineModeToString (int m) 777 { 778 switch (m) 779 { 780 case TextureAttributes.COMBINE_REPLACE: 781 return "COMBINE_REPLACE"; 782 case TextureAttributes.COMBINE_MODULATE: 783 return "COMBINE_MODULATE"; 784 case TextureAttributes.COMBINE_ADD: 785 return "COMBINE_ADD"; 786 case TextureAttributes.COMBINE_ADD_SIGNED: 787 return "COMBINE_ADD_SIGNED"; 788 case TextureAttributes.COMBINE_SUBTRACT: 789 return "COMBINE_SUBTRACT"; 790 case TextureAttributes.COMBINE_INTERPOLATE: 791 return "COMBINE_INTERPOLATE"; 792 case TextureAttributes.COMBINE_DOT3: 793 return "COMBINE_DOT3"; 794 default : 795 return "-1"; 796 } 797 } 798 799 800 /** 801 * Convert TextureAttributes Combine Source to String. 802 * @return the corresponding String. 803 */ 804 public static String textureCombineSourceToString (int m) 805 { 806 switch (m) 807 { 808 case TextureAttributes.COMBINE_OBJECT_COLOR: 809 return "COMBINE_OBJECT_COLOR"; 810 case TextureAttributes.COMBINE_TEXTURE_COLOR: 811 return "COMBINE_TEXTURE_COLOR"; 812 case TextureAttributes.COMBINE_CONSTANT_COLOR: 813 return "COMBINE_CONSTANT_COLOR"; 814 case TextureAttributes.COMBINE_PREVIOUS_TEXTURE_UNIT_STATE: 815 return "COMBINE_PREVIOUS_TEXTURE_UNIT_STATE"; 816 default : 817 return "-1"; 818 } 819 } 820 821 822 /** 823 * Convert TextureAttributes Combine Function to String. 824 * @return the corresponding String. 825 */ 826 public static String textureCombineFunctionToString (int m) 827 { 828 switch (m) 829 { 830 case TextureAttributes.COMBINE_SRC_COLOR: 831 return "COMBINE_SRC_COLOR"; 832 case TextureAttributes.COMBINE_ONE_MINUS_SRC_COLOR: 833 return "COMBINE_ONE_MINUS_SRC_COLOR"; 834 case TextureAttributes.COMBINE_SRC_ALPHA: 835 return "COMBINE_SRC_ALPHA"; 836 case TextureAttributes.COMBINE_ONE_MINUS_SRC_ALPHA: 837 return "COMBINE_ONE_MINUS_SRC_ALPHA"; 838 default : 839 return "-1"; 840 } 841 } 842 843 844 /** 845 * Convert Material Color Target to String. 846 * @return the corresponding String. 847 */ 848 public static String colorTargetToString (int m) 849 { 850 switch (m) 851 { 852 case Material.AMBIENT: 853 return "AMBIENT"; 854 case Material.EMISSIVE: 855 return "EMISSIVE"; 856 case Material.DIFFUSE: 857 return "DIFFUSE"; 858 case Material.SPECULAR: 859 return "SPECULAR"; 860 case Material.AMBIENT_AND_DIFFUSE: 861 return "AMBIENT_AND_DIFFUSE"; 862 default : 863 return "-1"; 864 } 865 } 866 867 }