From edc7a8b37c351b83487f6838f261bb1a6d16a60c Mon Sep 17 00:00:00 2001 From: "rem..om" Date: Sun, 22 Jan 2012 22:55:43 +0000 Subject: [PATCH] JDK : Font Creator - added support for horizontal and vertical padding - added support for letter spacing - added a field to change the file name - redisigned the UI a bit git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9109 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../gde/angelfont/AngelFontVisualPanel1.form | 22 +- .../gde/angelfont/AngelFontVisualPanel1.java | 17 +- .../gde/angelfont/AngelFontVisualPanel2.form | 293 ++++++++++++++++-- .../gde/angelfont/AngelFontVisualPanel2.java | 242 +++++++++++++-- .../angelfont/AngelFontWizardIterator.java | 16 +- .../gde/angelfont/AngelFontWizardPanel2.java | 5 + .../com/jme3/gde/angelfont/Bundle.properties | 20 ++ .../com/jme3/gde/angelfont/FontCreator.java | 24 +- 8 files changed, 572 insertions(+), 67 deletions(-) diff --git a/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontVisualPanel1.form b/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontVisualPanel1.form index 597e44cc2..b80e50646 100644 --- a/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontVisualPanel1.form +++ b/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontVisualPanel1.form @@ -25,7 +25,7 @@ - + @@ -66,12 +66,21 @@ - + + + + + + - + + + + + @@ -89,6 +98,13 @@ + + + + + + + diff --git a/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontVisualPanel1.java b/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontVisualPanel1.java index 8f6900d29..20d3977ee 100644 --- a/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontVisualPanel1.java +++ b/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontVisualPanel1.java @@ -41,6 +41,7 @@ public final class AngelFontVisualPanel1 extends JPanel { jList1 = new javax.swing.JList(); jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); jList1.setModel(new javax.swing.AbstractListModel() { String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" }; @@ -60,15 +61,24 @@ public final class AngelFontVisualPanel1 extends JPanel { jLabel1.setForeground(new java.awt.Color(255, 255, 255)); org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(AngelFontVisualPanel1.class, "AngelFontVisualPanel1.jLabel1.text")); // NOI18N + org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(AngelFontVisualPanel1.class, "AngelFontVisualPanel1.jLabel2.text")); // NOI18N + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 236, Short.MAX_VALUE) + .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 341, Short.MAX_VALUE) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGap(28, 28, 28) + .addComponent(jLabel2) + .addContainerGap(279, Short.MAX_VALUE)) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 313, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 11, Short.MAX_VALUE) + .addComponent(jLabel2)) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); @@ -82,7 +92,7 @@ public final class AngelFontVisualPanel1 extends JPanel { ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 338, Short.MAX_VALUE) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); }// //GEN-END:initComponents @@ -93,6 +103,7 @@ public final class AngelFontVisualPanel1 extends JPanel { }//GEN-LAST:event_updateFont // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; private javax.swing.JList jList1; private javax.swing.JPanel jPanel1; private javax.swing.JScrollPane jScrollPane1; diff --git a/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontVisualPanel2.form b/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontVisualPanel2.form index e86595324..9e6c8aff6 100644 --- a/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontVisualPanel2.form +++ b/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontVisualPanel2.form @@ -1,6 +1,15 @@
+ + + + + + + + + @@ -16,16 +25,23 @@ - - + + + + + + - + - + + + + @@ -49,14 +65,240 @@ - + - - + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -67,43 +309,50 @@ + + + - + - + - + - - + + - - - - + - + - + - - + + + + + + + + + - + diff --git a/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontVisualPanel2.java b/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontVisualPanel2.java index b87bccad3..da57bca97 100644 --- a/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontVisualPanel2.java +++ b/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontVisualPanel2.java @@ -13,6 +13,10 @@ public final class AngelFontVisualPanel2 extends JPanel { String fontName = ""; int fontSize = 16; int imageSize = 256; + int paddingX = 0; + int paddingY = 0; + int letterSpacing = 0; + String fileName = ""; int style = Font.PLAIN; /** Creates new form AngelFontVisualPanel2 */ @@ -22,6 +26,7 @@ public final class AngelFontVisualPanel2 extends JPanel { jComboBox1.addItem("PLAIN"); jComboBox1.addItem("ITALIC"); jComboBox1.addItem("BOLD"); + } @Override @@ -31,11 +36,17 @@ public final class AngelFontVisualPanel2 extends JPanel { public void setFont(String name) { this.fontName = name; + jTextField1.setText(fontName); + jLabel10.setText(fontName); updateFont(); } + public String getFileName() { + return jTextField1.getText(); + } + private void updateFont() { - jLabel3.setIcon(new ImageIcon(FontCreator.buildFont(fontName, imageSize, fontSize, style, true).getImage())); + jLabel3.setIcon(new ImageIcon(FontCreator.buildFont(fontName, getFileName(), imageSize, fontSize, style, paddingX, paddingY, letterSpacing, true).getImage())); jLabel3.repaint(); jPanel1.repaint(); } @@ -48,14 +59,30 @@ public final class AngelFontVisualPanel2 extends JPanel { // //GEN-BEGIN:initComponents private void initComponents() { + jButton1 = new javax.swing.JButton(); jPanel1 = new javax.swing.JPanel(); jLabel3 = new javax.swing.JLabel(); - jToolBar1 = new javax.swing.JToolBar(); - jComboBox1 = new javax.swing.JComboBox(); - jLabel1 = new javax.swing.JLabel(); - jSpinner1 = new javax.swing.JSpinner(); + jPanel2 = new javax.swing.JPanel(); + jLabel7 = new javax.swing.JLabel(); + jTextField1 = new javax.swing.JTextField(); + jLabel8 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jSpinner2 = new javax.swing.JSpinner(); + jLabel4 = new javax.swing.JLabel(); + jSpinner3 = new javax.swing.JSpinner(); + jLabel5 = new javax.swing.JLabel(); + jSpinner4 = new javax.swing.JSpinner(); + jPanel3 = new javax.swing.JPanel(); + jLabel1 = new javax.swing.JLabel(); + jSpinner1 = new javax.swing.JSpinner(); + jComboBox1 = new javax.swing.JComboBox(); + jLabel6 = new javax.swing.JLabel(); + jLabel9 = new javax.swing.JLabel(); + jLabel10 = new javax.swing.JLabel(); + jLabel11 = new javax.swing.JLabel(); + jSpinner5 = new javax.swing.JSpinner(); + + org.openide.awt.Mnemonics.setLocalizedText(jButton1, org.openide.util.NbBundle.getMessage(AngelFontVisualPanel2.class, "AngelFontVisualPanel2.jButton1.text")); // NOI18N jPanel1.setBackground(new java.awt.Color(0, 0, 0)); jPanel1.setLayout(new javax.swing.BoxLayout(jPanel1, javax.swing.BoxLayout.LINE_AXIS)); @@ -63,52 +90,187 @@ public final class AngelFontVisualPanel2 extends JPanel { org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(AngelFontVisualPanel2.class, "AngelFontVisualPanel2.jLabel3.text")); // NOI18N jPanel1.add(jLabel3); - jToolBar1.setFloatable(false); - jToolBar1.setRollover(true); + jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(AngelFontVisualPanel2.class, "AngelFontVisualPanel2.jPanel2.border.title"))); // NOI18N - jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); - jComboBox1.addActionListener(new java.awt.event.ActionListener() { + org.openide.awt.Mnemonics.setLocalizedText(jLabel7, org.openide.util.NbBundle.getMessage(AngelFontVisualPanel2.class, "AngelFontVisualPanel2.jLabel7.text")); // NOI18N + + jTextField1.setText(org.openide.util.NbBundle.getMessage(AngelFontVisualPanel2.class, "AngelFontVisualPanel2.jTextField1.text")); // NOI18N + jTextField1.setToolTipText(org.openide.util.NbBundle.getMessage(AngelFontVisualPanel2.class, "AngelFontVisualPanel2.jTextField1.toolTipText")); // NOI18N + jTextField1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { - jComboBox1ActionPerformed(evt); + jTextField1ActionPerformed(evt); + } + }); + + org.openide.awt.Mnemonics.setLocalizedText(jLabel8, org.openide.util.NbBundle.getMessage(AngelFontVisualPanel2.class, "AngelFontVisualPanel2.jLabel8.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(AngelFontVisualPanel2.class, "AngelFontVisualPanel2.jLabel2.text")); // NOI18N + + jSpinner2.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(256), Integer.valueOf(64), null, Integer.valueOf(1))); + jSpinner2.setToolTipText(org.openide.util.NbBundle.getMessage(AngelFontVisualPanel2.class, "AngelFontVisualPanel2.jSpinner2.toolTipText")); // NOI18N + jSpinner2.addChangeListener(new javax.swing.event.ChangeListener() { + public void stateChanged(javax.swing.event.ChangeEvent evt) { + updateImageSize(evt); + } + }); + + org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage(AngelFontVisualPanel2.class, "AngelFontVisualPanel2.jLabel4.text")); // NOI18N + + jSpinner3.setToolTipText(org.openide.util.NbBundle.getMessage(AngelFontVisualPanel2.class, "AngelFontVisualPanel2.jSpinner3.toolTipText")); // NOI18N + jSpinner3.addChangeListener(new javax.swing.event.ChangeListener() { + public void stateChanged(javax.swing.event.ChangeEvent evt) { + updatePaddingX(evt); + } + }); + + org.openide.awt.Mnemonics.setLocalizedText(jLabel5, org.openide.util.NbBundle.getMessage(AngelFontVisualPanel2.class, "AngelFontVisualPanel2.jLabel5.text")); // NOI18N + + jSpinner4.setToolTipText(org.openide.util.NbBundle.getMessage(AngelFontVisualPanel2.class, "AngelFontVisualPanel2.jSpinner4.toolTipText")); // NOI18N + jSpinner4.addChangeListener(new javax.swing.event.ChangeListener() { + public void stateChanged(javax.swing.event.ChangeEvent evt) { + updatePaddingY(evt); } }); - jToolBar1.add(jComboBox1); + + javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); + jPanel2.setLayout(jPanel2Layout); + jPanel2Layout.setHorizontalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel2) + .addComponent(jLabel7)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)) + .addComponent(jLabel5) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jSpinner3, javax.swing.GroupLayout.DEFAULT_SIZE, 156, Short.MAX_VALUE) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jSpinner2) + .addComponent(jTextField1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 156, Short.MAX_VALUE)) + .addComponent(jSpinner4, javax.swing.GroupLayout.DEFAULT_SIZE, 156, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel8) + .addGap(45, 45, 45)) + ); + jPanel2Layout.setVerticalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel8) + .addComponent(jLabel7)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jSpinner2, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel2)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jSpinner3, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel4)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jSpinner4, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel5)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(AngelFontVisualPanel2.class, "AngelFontVisualPanel2.jPanel3.border.title"))); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(AngelFontVisualPanel2.class, "AngelFontVisualPanel2.jLabel1.text")); // NOI18N - jToolBar1.add(jLabel1); jSpinner1.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(16), Integer.valueOf(1), null, Integer.valueOf(1))); + jSpinner1.setToolTipText(org.openide.util.NbBundle.getMessage(AngelFontVisualPanel2.class, "AngelFontVisualPanel2.jSpinner1.toolTipText")); // NOI18N jSpinner1.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { updateFontSize(evt); } }); - jToolBar1.add(jSpinner1); - org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(AngelFontVisualPanel2.class, "AngelFontVisualPanel2.jLabel2.text")); // NOI18N - jToolBar1.add(jLabel2); + jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); + jComboBox1.setToolTipText(org.openide.util.NbBundle.getMessage(AngelFontVisualPanel2.class, "AngelFontVisualPanel2.jComboBox1.toolTipText")); // NOI18N + jComboBox1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jComboBox1ActionPerformed(evt); + } + }); - jSpinner2.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(256), Integer.valueOf(64), null, Integer.valueOf(1))); - jSpinner2.addChangeListener(new javax.swing.event.ChangeListener() { + org.openide.awt.Mnemonics.setLocalizedText(jLabel6, org.openide.util.NbBundle.getMessage(AngelFontVisualPanel2.class, "AngelFontVisualPanel2.jLabel6.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(jLabel9, org.openide.util.NbBundle.getMessage(AngelFontVisualPanel2.class, "AngelFontVisualPanel2.jLabel9.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(jLabel10, org.openide.util.NbBundle.getMessage(AngelFontVisualPanel2.class, "AngelFontVisualPanel2.jLabel10.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(jLabel11, org.openide.util.NbBundle.getMessage(AngelFontVisualPanel2.class, "AngelFontVisualPanel2.jLabel11.text")); // NOI18N + + jSpinner5.setToolTipText(org.openide.util.NbBundle.getMessage(AngelFontVisualPanel2.class, "AngelFontVisualPanel2.jSpinner5.toolTipText")); // NOI18N + jSpinner5.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { - updateImageSize(evt); + letterSpacingUpdate(evt); } }); - jToolBar1.add(jSpinner2); + + javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); + jPanel3.setLayout(jPanel3Layout); + jPanel3Layout.setHorizontalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel3Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel11) + .addComponent(jLabel9) + .addComponent(jLabel1) + .addComponent(jLabel6)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jSpinner1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 78, Short.MAX_VALUE) + .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, 78, Short.MAX_VALUE) + .addComponent(jComboBox1, javax.swing.GroupLayout.Alignment.TRAILING, 0, 78, Short.MAX_VALUE) + .addComponent(jSpinner5, javax.swing.GroupLayout.DEFAULT_SIZE, 78, Short.MAX_VALUE)) + .addContainerGap()) + ); + jPanel3Layout.setVerticalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel3Layout.createSequentialGroup() + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel9) + .addComponent(jLabel10)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel6)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel1)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 7, Short.MAX_VALUE) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel11) + .addComponent(jSpinner5, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jToolBar1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 441, Short.MAX_VALUE) - .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 441, Short.MAX_VALUE) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 531, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 307, Short.MAX_VALUE) + .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 404, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) ); }// //GEN-END:initComponents @@ -132,14 +294,46 @@ public final class AngelFontVisualPanel2 extends JPanel { } updateFont(); }//GEN-LAST:event_jComboBox1ActionPerformed + +private void updatePaddingX(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_updatePaddingX + paddingX = (Integer) jSpinner3.getValue(); + updateFont(); +}//GEN-LAST:event_updatePaddingX + +private void updatePaddingY(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_updatePaddingY + paddingY = (Integer) jSpinner4.getValue(); + updateFont(); +}//GEN-LAST:event_updatePaddingY + +private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed + fileName = jTextField1.getText(); +}//GEN-LAST:event_jTextField1ActionPerformed + +private void letterSpacingUpdate(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_letterSpacingUpdate + letterSpacing = (Integer) jSpinner5.getValue(); +}//GEN-LAST:event_letterSpacingUpdate // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton1; private javax.swing.JComboBox jComboBox1; private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel10; + private javax.swing.JLabel jLabel11; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLabel7; + private javax.swing.JLabel jLabel8; + private javax.swing.JLabel jLabel9; private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; private javax.swing.JSpinner jSpinner1; private javax.swing.JSpinner jSpinner2; - private javax.swing.JToolBar jToolBar1; + private javax.swing.JSpinner jSpinner3; + private javax.swing.JSpinner jSpinner4; + private javax.swing.JSpinner jSpinner5; + private javax.swing.JTextField jTextField1; // End of variables declaration//GEN-END:variables } diff --git a/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontWizardIterator.java b/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontWizardIterator.java index cf183984f..4a6720c0f 100644 --- a/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontWizardIterator.java +++ b/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontWizardIterator.java @@ -77,17 +77,23 @@ public final class AngelFontWizardIterator implements WizardDescriptor.Instantia */ @SuppressWarnings("unchecked") public Set instantiate() throws IOException { - String name = (String) wizard.getProperty("font_name"); + + String fontName = (String) wizard.getProperty("font_name"); + String fileName = (String) wizard.getProperty("file_name"); int fontSize = (Integer) wizard.getProperty("font_size"); int imageSize = (Integer) wizard.getProperty("image_size"); int style = (Integer) wizard.getProperty("font_style"); + int paddingX = (Integer) wizard.getProperty("padding_x"); + int paddingY = (Integer) wizard.getProperty("padding_y"); + int letterSpacing = (Integer) wizard.getProperty("letter_spacing"); + Project project = (Project) wizard.getProperty("project"); ProjectAssetManager pm = project.getLookup().lookup(ProjectAssetManager.class); if (pm == null) { Logger.getLogger(AngelFontWizardIterator.class.getName()).log(Level.WARNING, "No ProjectAssetManager found!"); return Collections.EMPTY_SET; } - AngelFont font = FontCreator.buildFont(name, imageSize, fontSize, style); + AngelFont font = FontCreator.buildFont(fontName, fileName, imageSize, fontSize, style, paddingX, paddingY, letterSpacing, false); BufferedImage fontImage = font.getImage(); ByteBuffer scratch = ByteBuffer.allocateDirect(4 * fontImage.getWidth() * fontImage.getHeight()); byte[] data = (byte[]) fontImage.getRaster().getDataElements(0, 0, @@ -95,17 +101,17 @@ public final class AngelFontWizardIterator implements WizardDescriptor.Instantia scratch.clear(); scratch.put(data); scratch.rewind(); - name = name.replaceAll(" ", ""); + fileName = fileName.replaceAll(" ", ""); FileObject imageFile; FileObject descriptionFile; try { //create PNG file - imageFile = FileUtil.createData(pm.getAssetFolder(), "Interface/Fonts/" + name + ".png"); + imageFile = FileUtil.createData(pm.getAssetFolder(), "Interface/Fonts/" + fileName + ".png"); OutputStream out = imageFile.getOutputStream(); ImageIO.write(fontImage, "PNG", out); out.close(); //create fnt file - descriptionFile = FileUtil.createData(pm.getAssetFolder(), "Interface/Fonts/" + name + ".fnt"); + descriptionFile = FileUtil.createData(pm.getAssetFolder(), "Interface/Fonts/" + fileName + ".fnt"); OutputStreamWriter out2 = new OutputStreamWriter(descriptionFile.getOutputStream()); out2.write(font.getDescription()); out2.close(); diff --git a/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontWizardPanel2.java b/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontWizardPanel2.java index a9e9df2e8..c9e31b1bb 100644 --- a/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontWizardPanel2.java +++ b/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontWizardPanel2.java @@ -86,5 +86,10 @@ public class AngelFontWizardPanel2 implements WizardDescriptor.Panel { ((WizardDescriptor)settings).putProperty("font_style", component.style); ((WizardDescriptor)settings).putProperty("font_size", component.fontSize); ((WizardDescriptor)settings).putProperty("image_size", component.imageSize); + ((WizardDescriptor)settings).putProperty("file_name", component.getFileName()); + ((WizardDescriptor)settings).putProperty("padding_x", component.paddingX); + ((WizardDescriptor)settings).putProperty("padding_y", component.paddingY); + ((WizardDescriptor)settings).putProperty("letter_spacing", component.letterSpacing); + } } diff --git a/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/Bundle.properties b/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/Bundle.properties index 74825dbc8..3e53a0607 100644 --- a/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/Bundle.properties +++ b/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/Bundle.properties @@ -8,3 +8,23 @@ AngelFontVisualPanel1.jLabel1.text= AngelFontVisualPanel2.jLabel1.text=Font Size: AngelFontVisualPanel2.jLabel2.text=Image Size: AngelFontVisualPanel2.jLabel3.text=jLabel3 +AngelFontVisualPanel2.jLabel4.text=Padding-x: +AngelFontVisualPanel2.jLabel5.text=Padding-y: +AngelFontVisualPanel1.jLabel2.text=jLabel2 +AngelFontVisualPanel2.jPanel3.border.title=Font +AngelFontVisualPanel2.jButton1.text=jButton1 +AngelFontVisualPanel2.jLabel6.text=Font style: +AngelFontVisualPanel2.jPanel2.border.title=Image +AngelFontVisualPanel2.jLabel7.text=file name: +AngelFontVisualPanel2.jTextField1.text=jTextField1 +AngelFontVisualPanel2.jLabel8.text=.fnt / .png +AngelFontVisualPanel2.jLabel9.text=Font name: +AngelFontVisualPanel2.jLabel10.text=jLabel10 +AngelFontVisualPanel2.jSpinner3.toolTipText=Defines the horizontal padding used for each letter cell +AngelFontVisualPanel2.jSpinner4.toolTipText=Defines the vertical padding used for each letter cell +AngelFontVisualPanel2.jLabel11.text=Letter spacing: +AngelFontVisualPanel2.jSpinner1.toolTipText=The size of the font +AngelFontVisualPanel2.jComboBox1.toolTipText=The style of the font +AngelFontVisualPanel2.jTextField1.toolTipText=The name of the generated files +AngelFontVisualPanel2.jSpinner2.toolTipText=The resulting png image size will be Image Size x Image Size +AngelFontVisualPanel2.jSpinner5.toolTipText=Defines the vertical padding used for each letter cell diff --git a/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/FontCreator.java b/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/FontCreator.java index a743d17ad..eb8091d9d 100644 --- a/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/FontCreator.java +++ b/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/FontCreator.java @@ -41,6 +41,10 @@ public abstract class FontCreator { } public static AngelFont buildFont(String fontName, int bitmapSize, int fontSize, int style, boolean debug) { + return buildFont(fontName, fontName, bitmapSize, fontSize, style, 0, 0, 0, debug); + } + + public static AngelFont buildFont(String fontName, String fileName, int bitmapSize, int fontSize, int style, int paddingX, int paddingY, int letterSpacing, boolean debug) { BufferedImage fontImage; Font font; @@ -74,30 +78,30 @@ public abstract class FontCreator { Rectangle2D bounds = fm.getStringBounds(temp, g); height = fm.getDescent() + fm.getAscent(); if (yPos == 0) { - yPos = height; + yPos = height + (paddingY * 2); } - if (xPos + bounds.getWidth() > bitmapSize) { + if (xPos + bounds.getWidth() + (paddingX * 2) > bitmapSize) { xPos = 0; - yPos += height; + yPos += height + (paddingY * 2); } - g.drawString(temp, xPos, yPos); + g.drawString(temp, xPos + paddingX, yPos + paddingY); if (debug) { g.setColor(Color.BLUE); - g.drawRect(xPos, yPos - fm.getAscent(), (int) bounds.getWidth(), height); + g.drawRect(xPos, yPos - fm.getAscent(), (int) bounds.getWidth() + (paddingX * 2), height + (paddingY * 2)); g.setColor(Color.WHITE); } charLocs = charLocs + "char id=" + i + " x=" + xPos + " y=" + (yPos - fm.getAscent()) - + " width=" + (int) bounds.getWidth() - + " height=" + (int) bounds.getHeight() + + " width=" + ((int) bounds.getWidth() + (paddingX * 2)) + + " height=" + ((int) bounds.getHeight() + (paddingY * 2)) + " xoffset=0" + " yoffset=0" - + " xadvance=" + ((int) bounds.getWidth() - 1) + " " + + " xadvance=" + (((int) bounds.getWidth() + letterSpacing) - 1) + " " + " page=0" + " chnl=0\n"; - xPos += bounds.getWidth(); + xPos += bounds.getWidth() + (paddingX * 2); } charLocs = "info face=null " + "size=" + fontSize + " " @@ -118,7 +122,7 @@ public abstract class FontCreator { + "pages=1 " + "packed=0 " + "\n" - + "page id=0 file=\"" + fontName.replaceAll(" ", "") + ".png\"\n" + + "page id=0 file=\"" + fileName.replaceAll(" ", "") + ".png\"\n" + "chars count=255\n" + charLocs; return new AngelFont(fontImage, charLocs);