From a73d8a9993c27a942d240b4b34bb3dc62c9f7d43 Mon Sep 17 00:00:00 2001 From: chrisleung Date: Fri, 7 Dec 2007 01:47:22 +0000 Subject: [PATCH] Now the text thickness can be set! --- nbproject/project.properties | 2 +- src/powerreader/ConfigUI.form | 57 ++++++++++++++++++---- src/powerreader/ConfigUI.java | 59 +++++++++++++++++++---- src/powerreader/ConfigurationManager.java | 5 ++ src/util/RawTextParser.java | 5 +- src/util/TextObject3d.java | 8 ++- 6 files changed, 113 insertions(+), 23 deletions(-) diff --git a/nbproject/project.properties b/nbproject/project.properties index cbf4da1..9cdac1e 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -67,7 +67,7 @@ run.classpath=\ # Space-separated list of JVM arguments used when running the project # (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value # or test-sys-prop.name=value to set system properties for unit tests): -run.jvmargs=-Xms256m -Xmx512m +run.jvmargs=-Xms256m -Xmx512m -Dj3d.implicitAntialiasing=true run.test.classpath=\ ${javac.test.classpath}:\ ${build.test.classes.dir} diff --git a/src/powerreader/ConfigUI.form b/src/powerreader/ConfigUI.form index b1af198..00a3e62 100644 --- a/src/powerreader/ConfigUI.form +++ b/src/powerreader/ConfigUI.form @@ -42,11 +42,6 @@ - - - - - @@ -63,16 +58,24 @@ + + - + + - + - + + + + + + @@ -130,11 +133,20 @@ + + + + + + + + + - + @@ -336,5 +348,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/powerreader/ConfigUI.java b/src/powerreader/ConfigUI.java index bf5ae16..2ec462a 100644 --- a/src/powerreader/ConfigUI.java +++ b/src/powerreader/ConfigUI.java @@ -47,6 +47,9 @@ private void initComponents() { m_slider_lineWidth = new javax.swing.JSlider(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); + m_slider_textDepth = new javax.swing.JSlider(); + jLabel3 = new javax.swing.JLabel(); + jLabel4 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Power Reader Options"); @@ -127,6 +130,24 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jLabel2.setText("this change to take effect"); + m_slider_textDepth.setMajorTickSpacing(1); + m_slider_textDepth.setMaximum(10); + m_slider_textDepth.setMinimum(1); + m_slider_textDepth.setPaintLabels(true); + m_slider_textDepth.setPaintTicks(true); + m_slider_textDepth.setSnapToTicks(true); + m_slider_textDepth.setValue(1); + m_slider_textDepth.addChangeListener(new javax.swing.event.ChangeListener() { + public void stateChanged(javax.swing.event.ChangeEvent evt) { + m_slider_textDepthStateChanged(evt); + } + }); + + jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11)); + jLabel3.setText("Text Depth"); + + jLabel4.setText("Sets the 3D Text Depth"); + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( @@ -150,10 +171,6 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addComponent(m_label_dictionarySource) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 43, Short.MAX_VALUE) .addComponent(m_combo_dictionaryLookup, javax.swing.GroupLayout.PREFERRED_SIZE, 182, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(layout.createSequentialGroup() - .addComponent(m_okButton, javax.swing.GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(m_cancelButton, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addComponent(m_label_leftClick) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 92, Short.MAX_VALUE) @@ -167,13 +184,20 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addComponent(m_label_rightClick) .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 139, Short.MAX_VALUE) .addComponent(m_label_rightClick1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 139, Short.MAX_VALUE) - .addComponent(jLabel2)) + .addComponent(jLabel2) + .addComponent(jLabel3) + .addComponent(jLabel4)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_slider_textDepth, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 182, Short.MAX_VALUE) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(m_checkBox_mouseWheel, javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(m_combo_rightClick, javax.swing.GroupLayout.PREFERRED_SIZE, 182, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addComponent(m_slider_lineWidth, 0, 0, Short.MAX_VALUE)))) + .addComponent(m_combo_rightClick, 0, 182, Short.MAX_VALUE)) + .addComponent(m_slider_lineWidth, javax.swing.GroupLayout.Alignment.TRAILING, 0, 0, Short.MAX_VALUE))) + .addGroup(layout.createSequentialGroup() + .addComponent(m_okButton, javax.swing.GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_cancelButton, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap()) ); layout.setVerticalGroup( @@ -219,14 +243,26 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(m_slider_lineWidth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(24, 24, 24) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_slider_textDepth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel3) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 16, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(m_okButton) .addComponent(m_cancelButton)) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGap(24, 24, 24)) ); pack(); }// //GEN-END:initComponents + private void m_slider_textDepthStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_m_slider_textDepthStateChanged + ConfigurationManager.TEXT_DEPTH = m_slider_textDepth.getValue() / 10.0f; + ConfigurationManager.currentRoot.color(false); + }//GEN-LAST:event_m_slider_textDepthStateChanged + private void m_okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_okButtonActionPerformed if (m_slider_lineWidth.getValue() != (int)TextObject3d.getLineWidth()) { // Set the new line width @@ -262,6 +298,8 @@ public void run() { // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; private javax.swing.JButton m_cancelButton; private javax.swing.JCheckBox m_checkBox_mouseWheel; private javax.swing.JComboBox m_combo_dictionaryLookup; @@ -281,6 +319,7 @@ public void run() { private javax.swing.JLabel m_label_voicePersonality; private javax.swing.JButton m_okButton; private javax.swing.JSlider m_slider_lineWidth; + private javax.swing.JSlider m_slider_textDepth; // End of variables declaration//GEN-END:variables } diff --git a/src/powerreader/ConfigurationManager.java b/src/powerreader/ConfigurationManager.java index 8029744..3955304 100644 --- a/src/powerreader/ConfigurationManager.java +++ b/src/powerreader/ConfigurationManager.java @@ -23,6 +23,7 @@ import javax.swing.JSlider; import javax.vecmath.Vector3f; import speech.Speech; +import util.HierarchyObject; /** * @@ -35,6 +36,8 @@ public class ConfigurationManager { public static Color DEFAULT_FG_COLOR = Color.BLUE; public static Color DEFAULT_HL_COLOR = Color.RED; + public static float TEXT_DEPTH = 0.1f; + static float DEFAULT_X = 0.0f; static float DEFAULT_Y = 0.0f; static float DEFAULT_Z = -25.0f; @@ -77,6 +80,8 @@ public class ConfigurationManager { private JSlider m_zoomSlider = null; + public static HierarchyObject currentRoot = null; + static { m_instance = new ConfigurationManager(); diff --git a/src/util/RawTextParser.java b/src/util/RawTextParser.java index ff9babb..7b47f99 100644 --- a/src/util/RawTextParser.java +++ b/src/util/RawTextParser.java @@ -44,7 +44,7 @@ public class RawTextParser { /** Creates a new instance of RawTextParser */ public RawTextParser(String filename) { m_fileName = filename; - ConfigurationManager.setCurrentFileName(filename); + ConfigurationManager.setCurrentFileName(filename); } public BranchGroup getRootNode() { @@ -205,6 +205,9 @@ public void parse() { m_hierarchyRoot = docuObj; m_rootNode = docuObj.getBranchGroup(); + // Save the root in the configuration manager + ConfigurationManager.currentRoot = m_hierarchyRoot; + } catch (FileNotFoundException ex) { ex.printStackTrace(); diff --git a/src/util/TextObject3d.java b/src/util/TextObject3d.java index 046bf0e..ae9a76b 100644 --- a/src/util/TextObject3d.java +++ b/src/util/TextObject3d.java @@ -99,6 +99,10 @@ public TextObject3d(String text) { theText.addChild(m_textShape); rotation_group.addChild( theText ); + // squeeze the text + Transform3D squeeze = new Transform3D(); + squeeze.setScale(new Vector3d(1,1,ConfigurationManager.TEXT_DEPTH)); + theText.setTransform(squeeze); } @@ -153,7 +157,7 @@ public void highLight() { m_textShape.setAppearance(m_textAppearanceHighlight); if(ConfigurationManager.wordsGrow()) { Transform3D scale = new Transform3D(); - scale.setScale(new Vector3d(1.0f,1.6f,1.0f)); + scale.setScale(new Vector3d(1.0f,1.6f,ConfigurationManager.TEXT_DEPTH)); // Alternative method -- have words come out at you // scale.setTranslation(new Vector3f(0,0,10f)); theText.setTransform(scale); @@ -163,7 +167,7 @@ public void unHighLight() { m_textShape.setAppearance(m_textAppearanceBaseColor); Transform3D scale = new Transform3D(); - scale.setScale(new Vector3d(1.0f,1.0f,1.0f)); + scale.setScale(new Vector3d(1.0f,1.0f,ConfigurationManager.TEXT_DEPTH)); theText.setTransform(scale); }