r3633 - in trunk/tools/ImgToMap: . nbproject src/imgtomap

savagex at icculus.org savagex at icculus.org
Sun May 18 06:48:33 EDT 2008


Author: savagex
Date: 2008-05-18 06:48:30 -0400 (Sun, 18 May 2008)
New Revision: 3633

Added:
   trunk/tools/ImgToMap/test2.png
   trunk/tools/ImgToMap/test3.png
Modified:
   trunk/tools/ImgToMap/
   trunk/tools/ImgToMap/nbproject/
   trunk/tools/ImgToMap/src/imgtomap/JFrameMain.form
   trunk/tools/ImgToMap/src/imgtomap/JFrameMain.java
   trunk/tools/ImgToMap/src/imgtomap/MapWriter.java
Log:
some UI stuff, some meaningless messages, some test files


Property changes on: trunk/tools/ImgToMap
___________________________________________________________________
Name: svn:ignore
   + build
dist



Property changes on: trunk/tools/ImgToMap/nbproject
___________________________________________________________________
Name: svn:ignore
   + private


Modified: trunk/tools/ImgToMap/src/imgtomap/JFrameMain.form
===================================================================
--- trunk/tools/ImgToMap/src/imgtomap/JFrameMain.form	2008-05-18 10:08:14 UTC (rev 3632)
+++ trunk/tools/ImgToMap/src/imgtomap/JFrameMain.form	2008-05-18 10:48:30 UTC (rev 3633)
@@ -56,17 +56,6 @@
                   <EmptySpace max="-2" attributes="0"/>
                   <Group type="103" groupAlignment="0" attributes="0">
                       <Component id="jTextFieldTexture" alignment="0" pref="465" max="32767" attributes="0"/>
-                      <Group type="102" attributes="0">
-                          <Group type="103" groupAlignment="1" attributes="0">
-                              <Component id="jTextFieldInput" pref="313" max="32767" attributes="1"/>
-                              <Component id="jTextFieldOutput" alignment="1" pref="313" max="32767" attributes="1"/>
-                          </Group>
-                          <EmptySpace min="-2" max="-2" attributes="0"/>
-                          <Group type="103" groupAlignment="1" attributes="0">
-                              <Component id="jButtonOutput" pref="146" max="32767" attributes="2"/>
-                              <Component id="jButtonInput" pref="146" max="32767" attributes="2"/>
-                          </Group>
-                      </Group>
                       <Component id="jButtonOK" alignment="0" min="-2" max="-2" attributes="0"/>
                       <Group type="102" alignment="0" attributes="0">
                           <Group type="103" groupAlignment="0" attributes="0">
@@ -74,22 +63,29 @@
                               <Component id="jSpinnerUnits" alignment="0" min="-2" max="-2" attributes="1"/>
                           </Group>
                           <EmptySpace min="-2" pref="27" max="-2" attributes="0"/>
+                          <Group type="103" groupAlignment="0" attributes="0">
+                              <Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/>
+                              <Component id="jSpinnerHeight" alignment="0" min="-2" max="-2" attributes="1"/>
+                          </Group>
+                          <EmptySpace min="-2" pref="24" max="-2" attributes="0"/>
                           <Group type="103" groupAlignment="0" max="-2" attributes="0">
-                              <Group type="102" alignment="0" attributes="0">
-                                  <Component id="jSpinnerHeight" min="-2" max="-2" attributes="1"/>
-                                  <EmptySpace type="separate" max="-2" attributes="0"/>
-                                  <Component id="jSpinner1" min="-2" max="-2" attributes="0"/>
-                              </Group>
-                              <Group type="102" alignment="0" attributes="0">
-                                  <Component id="jLabel2" min="-2" max="-2" attributes="0"/>
-                                  <EmptySpace type="separate" max="-2" attributes="0"/>
-                                  <Component id="jLabel4" min="-2" max="-2" attributes="0"/>
-                              </Group>
+                              <Component id="jSpinner1" max="32767" attributes="1"/>
+                              <Component id="jLabel4" alignment="0" max="32767" attributes="1"/>
                           </Group>
-                          <EmptySpace min="-2" pref="132" max="-2" attributes="0"/>
                       </Group>
                       <Component id="jLabel3" alignment="0" min="-2" max="-2" attributes="0"/>
                       <Component id="jCheckBoxDetail" alignment="0" min="-2" max="-2" attributes="0"/>
+                      <Group type="102" alignment="0" attributes="0">
+                          <Group type="103" groupAlignment="1" max="-2" attributes="0">
+                              <Component id="jTextFieldOutput" alignment="0" max="32767" attributes="1"/>
+                              <Component id="jTextFieldInput" alignment="0" pref="313" max="32767" attributes="1"/>
+                          </Group>
+                          <EmptySpace max="-2" attributes="0"/>
+                          <Group type="103" groupAlignment="0" attributes="0">
+                              <Component id="jButtonInput" alignment="0" pref="146" max="32767" attributes="2"/>
+                              <Component id="jButtonOutput" pref="146" max="32767" attributes="2"/>
+                          </Group>
+                      </Group>
                   </Group>
                   <EmptySpace max="-2" attributes="0"/>
               </Group>
@@ -101,14 +97,14 @@
                   <EmptySpace max="-2" attributes="0"/>
                   <Group type="103" groupAlignment="3" attributes="0">
                       <Component id="jButtonInput" alignment="3" min="-2" max="-2" attributes="0"/>
-                      <Component id="jTextFieldInput" alignment="3" min="-2" pref="26" max="-2" attributes="0"/>
+                      <Component id="jTextFieldInput" alignment="3" min="-2" pref="27" max="-2" attributes="0"/>
                   </Group>
                   <EmptySpace max="-2" attributes="0"/>
                   <Group type="103" groupAlignment="3" attributes="0">
                       <Component id="jButtonOutput" alignment="3" min="-2" max="-2" attributes="0"/>
-                      <Component id="jTextFieldOutput" alignment="3" min="-2" pref="24" max="-2" attributes="0"/>
+                      <Component id="jTextFieldOutput" alignment="3" min="-2" pref="26" max="-2" attributes="0"/>
                   </Group>
-                  <EmptySpace type="separate" max="-2" attributes="0"/>
+                  <EmptySpace min="-2" pref="16" max="-2" attributes="0"/>
                   <Group type="103" groupAlignment="3" attributes="0">
                       <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
                       <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
@@ -124,9 +120,9 @@
                   <Component id="jLabel3" min="-2" max="-2" attributes="0"/>
                   <EmptySpace max="-2" attributes="0"/>
                   <Component id="jTextFieldTexture" min="-2" max="-2" attributes="0"/>
-                  <EmptySpace type="unrelated" max="-2" attributes="0"/>
+                  <EmptySpace max="-2" attributes="0"/>
                   <Component id="jCheckBoxDetail" min="-2" max="-2" attributes="0"/>
-                  <EmptySpace pref="18" max="32767" attributes="0"/>
+                  <EmptySpace pref="24" max="32767" attributes="0"/>
                   <Component id="jButtonOK" min="-2" max="-2" attributes="0"/>
                   <EmptySpace max="-2" attributes="0"/>
               </Group>
@@ -150,6 +146,9 @@
           <Properties>
             <Property name="text" type="java.lang.String" value="Select output file"/>
           </Properties>
+          <Events>
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButtonOutputActionPerformed"/>
+          </Events>
         </Component>
         <Component class="javax.swing.JSpinner" name="jSpinnerUnits">
           <Properties>

Modified: trunk/tools/ImgToMap/src/imgtomap/JFrameMain.java
===================================================================
--- trunk/tools/ImgToMap/src/imgtomap/JFrameMain.java	2008-05-18 10:08:14 UTC (rev 3632)
+++ trunk/tools/ImgToMap/src/imgtomap/JFrameMain.java	2008-05-18 10:48:30 UTC (rev 3633)
@@ -8,6 +8,7 @@
 
 import java.io.File;
 import javax.swing.JFileChooser;
+import javax.swing.JOptionPane;
 
 /**
  *
@@ -66,6 +67,11 @@
         });
 
         jButtonOutput.setText("Select output file");
+        jButtonOutput.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                jButtonOutputActionPerformed(evt);
+            }
+        });
 
         jSpinnerUnits.setModel(new javax.swing.SpinnerNumberModel(256, 1, 2048, 1));
 
@@ -101,32 +107,29 @@
                 .addContainerGap()
                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addComponent(jTextFieldTexture, javax.swing.GroupLayout.DEFAULT_SIZE, 465, Short.MAX_VALUE)
-                    .addGroup(jPanel1Layout.createSequentialGroup()
-                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
-                            .addComponent(jTextFieldInput, javax.swing.GroupLayout.DEFAULT_SIZE, 313, Short.MAX_VALUE)
-                            .addComponent(jTextFieldOutput, javax.swing.GroupLayout.DEFAULT_SIZE, 313, Short.MAX_VALUE))
-                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
-                            .addComponent(jButtonOutput, javax.swing.GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE)
-                            .addComponent(jButtonInput, javax.swing.GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE)))
                     .addComponent(jButtonOK)
                     .addGroup(jPanel1Layout.createSequentialGroup()
                         .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                             .addComponent(jLabel1)
                             .addComponent(jSpinnerUnits, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                         .addGap(27, 27, 27)
+                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                            .addComponent(jLabel2)
+                            .addComponent(jSpinnerHeight, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+                        .addGap(24, 24, 24)
                         .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
-                            .addGroup(jPanel1Layout.createSequentialGroup()
-                                .addComponent(jSpinnerHeight, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
-                                .addGap(18, 18, 18)
-                                .addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
-                            .addGroup(jPanel1Layout.createSequentialGroup()
-                                .addComponent(jLabel2)
-                                .addGap(18, 18, 18)
-                                .addComponent(jLabel4)))
-                        .addGap(132, 132, 132))
+                            .addComponent(jSpinner1)
+                            .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                     .addComponent(jLabel3)
-                    .addComponent(jCheckBoxDetail))
+                    .addComponent(jCheckBoxDetail)
+                    .addGroup(jPanel1Layout.createSequentialGroup()
+                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
+                            .addComponent(jTextFieldOutput, javax.swing.GroupLayout.Alignment.LEADING)
+                            .addComponent(jTextFieldInput, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 313, Short.MAX_VALUE))
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                            .addComponent(jButtonInput, javax.swing.GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE)
+                            .addComponent(jButtonOutput, javax.swing.GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE))))
                 .addContainerGap())
         );
         jPanel1Layout.setVerticalGroup(
@@ -135,12 +138,12 @@
                 .addContainerGap()
                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                     .addComponent(jButtonInput)
-                    .addComponent(jTextFieldInput, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))
+                    .addComponent(jTextFieldInput, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE))
                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                     .addComponent(jButtonOutput)
-                    .addComponent(jTextFieldOutput, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
-                .addGap(18, 18, 18)
+                    .addComponent(jTextFieldOutput, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))
+                .addGap(16, 16, 16)
                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                     .addComponent(jLabel1)
                     .addComponent(jLabel2)
@@ -154,9 +157,9 @@
                 .addComponent(jLabel3)
                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                 .addComponent(jTextFieldTexture, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                 .addComponent(jCheckBoxDetail)
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 18, Short.MAX_VALUE)
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 24, Short.MAX_VALUE)
                 .addComponent(jButtonOK)
                 .addContainerGap())
         );
@@ -194,6 +197,7 @@
 }//GEN-LAST:event_jButtonInputActionPerformed
 
 private void jButtonOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOKActionPerformed
+    this.setVisible(false);
     Parameters p = new Parameters();
     p.infile = jTextFieldInput.getText();
     p.outfile = jTextFieldOutput.getText();
@@ -202,9 +206,27 @@
     p.height = (Integer)jSpinnerHeight.getValue();
     p.texturescale = (Double)jSpinner1.getValue();
     p.detail = jCheckBoxDetail.isSelected();
-    new MapWriter().writeMap(p);
+    int ret = new MapWriter().writeMap(p);
+    if(ret == 0) {
+        JOptionPane.showMessageDialog(this, "Map successfully generated!", "Success!", JOptionPane.INFORMATION_MESSAGE);
+    } else {
+        JOptionPane.showMessageDialog(this, "Error occured! Oh no!", "Error!", JOptionPane.ERROR_MESSAGE);
+    }
+    
+    
+    this.setVisible(true);
 }//GEN-LAST:event_jButtonOKActionPerformed
 
+private void jButtonOutputActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOutputActionPerformed
+    JFileChooser fc = new JFileChooser();
+    int ret = fc.showOpenDialog(this);
+    
+    if(ret == fc.APPROVE_OPTION) {
+        File f = fc.getSelectedFile();
+        jTextFieldOutput.setText(f.getAbsolutePath());
+    }
+}//GEN-LAST:event_jButtonOutputActionPerformed
+
     /**
     * @param args the command line arguments
     */

Modified: trunk/tools/ImgToMap/src/imgtomap/MapWriter.java
===================================================================
--- trunk/tools/ImgToMap/src/imgtomap/MapWriter.java	2008-05-18 10:08:14 UTC (rev 3632)
+++ trunk/tools/ImgToMap/src/imgtomap/MapWriter.java	2008-05-18 10:48:30 UTC (rev 3633)
@@ -20,9 +20,9 @@
  */
 public class MapWriter {
 
-    public void writeMap(Parameters p) {
+    public int writeMap(Parameters p) {
         if (!(new File(p.infile).exists())) {
-            return;
+            return 1;
         }
 
         FileOutputStream fos;
@@ -30,7 +30,7 @@
             fos = new FileOutputStream(new File(p.outfile));
         } catch (FileNotFoundException ex) {
             Logger.getLogger(MapWriter.class.getName()).log(Level.SEVERE, null, ex);
-            return;
+            return 1;
         }
 
         double[][] height = getHeightmap(p.infile);
@@ -99,7 +99,9 @@
             fos.write(buf.toString().getBytes());
         } catch (IOException ex) {
             Logger.getLogger(MapWriter.class.getName()).log(Level.SEVERE, null, ex);
+            return 1;
         }
+        return 0;
     }
 
     private String getMapPlaneString(Vector3D p1, Vector3D p2, Vector3D p3, boolean detail, String material, double scale) {

Added: trunk/tools/ImgToMap/test2.png
===================================================================
(Binary files differ)


Property changes on: trunk/tools/ImgToMap/test2.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/tools/ImgToMap/test3.png
===================================================================
(Binary files differ)


Property changes on: trunk/tools/ImgToMap/test3.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream




More information about the nexuiz-commits mailing list