Skip to content

Commit

Permalink
Now the text thickness can be set!
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisleung committed Dec 7, 2007
1 parent 3928cfe commit a73d8a9
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 23 deletions.
2 changes: 1 addition & 1 deletion nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
57 changes: 48 additions & 9 deletions src/powerreader/ConfigUI.form
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@
<EmptySpace pref="43" max="32767" attributes="0"/>
<Component id="m_combo_dictionaryLookup" min="-2" pref="182" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="m_okButton" pref="153" max="32767" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="m_cancelButton" min="-2" pref="166" max="-2" attributes="1"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="m_label_leftClick" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="92" max="32767" attributes="0"/>
Expand All @@ -63,16 +58,24 @@
<Component id="jLabel1" alignment="1" pref="139" max="32767" attributes="0"/>
<Component id="m_label_rightClick1" alignment="1" pref="139" max="32767" attributes="0"/>
<Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel3" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel4" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="m_slider_textDepth" alignment="1" pref="182" max="32767" attributes="0"/>
<Group type="103" alignment="1" groupAlignment="1" max="-2" attributes="0">
<Component id="m_checkBox_mouseWheel" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="m_combo_rightClick" alignment="1" min="-2" pref="182" max="-2" attributes="1"/>
<Component id="m_combo_rightClick" alignment="1" pref="182" max="32767" attributes="1"/>
</Group>
<Component id="m_slider_lineWidth" min="0" pref="0" max="32767" attributes="1"/>
<Component id="m_slider_lineWidth" alignment="1" min="0" pref="0" max="32767" attributes="1"/>
</Group>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="m_okButton" pref="153" max="32767" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="m_cancelButton" min="-2" pref="166" max="-2" attributes="1"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
Expand Down Expand Up @@ -130,11 +133,20 @@
<Component id="m_slider_lineWidth" min="-2" max="-2" attributes="1"/>
</Group>
<EmptySpace min="-2" pref="24" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="m_slider_textDepth" min="-2" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel4" min="-2" pref="14" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace pref="16" max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="m_okButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="m_cancelButton" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
<EmptySpace min="-2" pref="24" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
Expand Down Expand Up @@ -336,5 +348,32 @@
<Property name="text" type="java.lang.String" value="this change to take effect"/>
</Properties>
</Component>
<Component class="javax.swing.JSlider" name="m_slider_textDepth">
<Properties>
<Property name="majorTickSpacing" type="int" value="1"/>
<Property name="maximum" type="int" value="10"/>
<Property name="minimum" type="int" value="1"/>
<Property name="paintLabels" type="boolean" value="true"/>
<Property name="paintTicks" type="boolean" value="true"/>
<Property name="snapToTicks" type="boolean" value="true"/>
<Property name="value" type="int" value="1"/>
</Properties>
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="m_slider_textDepthStateChanged"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel3">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="11" style="1"/>
</Property>
<Property name="text" type="java.lang.String" value="Text Depth"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel4">
<Properties>
<Property name="text" type="java.lang.String" value="Sets the 3D Text Depth"/>
</Properties>
</Component>
</SubComponents>
</Form>
59 changes: 49 additions & 10 deletions src/powerreader/ConfigUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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(
Expand All @@ -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)
Expand All @@ -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(
Expand Down Expand Up @@ -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();
}// </editor-fold>//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
Expand Down Expand Up @@ -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;
Expand All @@ -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

}
5 changes: 5 additions & 0 deletions src/powerreader/ConfigurationManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import javax.swing.JSlider;
import javax.vecmath.Vector3f;
import speech.Speech;
import util.HierarchyObject;

/**
*
Expand All @@ -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;
Expand Down Expand Up @@ -77,6 +80,8 @@ public class ConfigurationManager {

private JSlider m_zoomSlider = null;

public static HierarchyObject currentRoot = null;

static {
m_instance = new ConfigurationManager();

Expand Down
5 changes: 4 additions & 1 deletion src/util/RawTextParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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();
Expand Down
8 changes: 6 additions & 2 deletions src/util/TextObject3d.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}

Expand Down Expand Up @@ -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);
Expand All @@ -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);
}

Expand Down

0 comments on commit a73d8a9

Please sign in to comment.