Created
October 22, 2010 07:59
-
-
Save yayugu/640138 to your computer and use it in GitHub Desktop.
hogehiga's somen tairiku patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: test/main/util/DefragUtilTest.java | |
=================================================================== | |
--- test/main/util/DefragUtilTest.java (リビジョン 0) | |
+++ test/main/util/DefragUtilTest.java (リビジョン 5) | |
@@ -0,0 +1,75 @@ | |
+/* | |
+ * To change this template, choose Tools | Templates | |
+ * and open the template in the editor. | |
+ */ | |
+ | |
+package main.util; | |
+ | |
+import org.junit.After; | |
+import org.junit.AfterClass; | |
+import org.junit.Before; | |
+import org.junit.BeforeClass; | |
+import org.junit.Test; | |
+import static org.junit.Assert.*; | |
+ | |
+/** | |
+ * デフラグのテストクラスですよ | |
+ * @author hogehiga | |
+ */ | |
+public class DefragUtilTest { | |
+ | |
+ public DefragUtilTest() { | |
+ } | |
+ | |
+ @BeforeClass | |
+ public static void setUpClass() throws Exception { | |
+ } | |
+ | |
+ @AfterClass | |
+ public static void tearDownClass() throws Exception { | |
+ } | |
+ | |
+ @Before | |
+ public void setUp() { | |
+ } | |
+ | |
+ @After | |
+ public void tearDown() { | |
+ } | |
+ | |
+ /** | |
+ * Test of defrag method, of class DefragUtil. | |
+ */ | |
+ @Test | |
+ public void testDefrag() { | |
+ String before = "defrag"; | |
+ String expResult = "adefgr"; | |
+ String result = DefragUtil.defrag(before); | |
+ assertEquals(expResult, result); | |
+ | |
+ /* null */ | |
+ before = null; | |
+ expResult = null; | |
+ result = DefragUtil.defrag(before); | |
+ assertEquals(expResult, result); | |
+ | |
+ /* 空文字列 */ | |
+ before = ""; | |
+ expResult = ""; | |
+ result = DefragUtil.defrag(before); | |
+ assertEquals(expResult, result); | |
+ | |
+ /* ひらがな */ | |
+ before = "そーめんたいりく"; | |
+ expResult = "いくそためりんー"; | |
+ result = DefragUtil.defrag(before); | |
+ assertEquals(expResult, result); | |
+ | |
+ /* 漢字 */ | |
+ before = "井阿折宇絵"; | |
+ expResult = "阿井宇絵折"; | |
+ result = DefragUtil.defrag(before); | |
+ assertEquals(expResult, result); | |
+ } | |
+ | |
+} | |
\ No newline at end of file | |
Index: nbproject/project.properties | |
=================================================================== | |
--- nbproject/project.properties (リビジョン 2) | |
+++ nbproject/project.properties (リビジョン 5) | |
@@ -1,3 +1,6 @@ | |
+annotation.processing.enabled=true | |
+annotation.processing.enabled.in.editor=false | |
+annotation.processing.run.all.processors=true | |
application.title=SomenTairiku | |
application.vendor=yayugu | |
auxiliary.org-netbeans-modules-projectimport-eclipse-core.key=src=src;file=C:/Users/yayugu/workspace/SomenTairiku/twitter4j-core-2.1.3-SNAPSHOT.jar;output=bin; | |
@@ -36,12 +39,13 @@ | |
# Space-separated list of extra javac options | |
javac.compilerargs= | |
javac.deprecation=false | |
+javac.processorpath=\ | |
+ ${javac.classpath} | |
javac.source=1.6 | |
javac.target=1.6 | |
javac.test.classpath=\ | |
${javac.classpath}:\ | |
${build.classes.dir}:\ | |
- ${libs.junit.classpath}:\ | |
${libs.junit_4.classpath} | |
javadoc.additionalparam= | |
javadoc.author=false | |
@@ -76,3 +80,4 @@ | |
${build.test.classes.dir} | |
source.encoding=UTF-8 | |
src.dir=${file.reference.SomenTairiku-src} | |
+test.test.dir=test | |
Index: nbproject/project.xml | |
=================================================================== | |
--- nbproject/project.xml (リビジョン 2) | |
+++ nbproject/project.xml (リビジョン 5) | |
@@ -7,7 +7,9 @@ | |
<source-roots> | |
<root id="src.dir" name="src"/> | |
</source-roots> | |
- <test-roots/> | |
+ <test-roots> | |
+ <root id="test.test.dir"/> | |
+ </test-roots> | |
</data> | |
</configuration> | |
</project> | |
Index: nbproject/genfiles.properties | |
=================================================================== | |
--- nbproject/genfiles.properties (リビジョン 2) | |
+++ nbproject/genfiles.properties (リビジョン 5) | |
@@ -1,8 +1,8 @@ | |
-nb-build.xml.data.CRC32=32f9a5aa | |
+nb-build.xml.data.CRC32=2db4335d | |
nb-build.xml.script.CRC32=4b18230c | |
[email protected] | |
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. | |
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. | |
-nbproject/build-impl.xml.data.CRC32=32f9a5aa | |
-nbproject/build-impl.xml.script.CRC32=f3ac4b69 | |
+nbproject/build-impl.xml.data.CRC32=2db4335d | |
+nbproject/build-impl.xml.script.CRC32=932cf7fb | |
nbproject/[email protected] | |
Index: nbproject/build-impl.xml | |
=================================================================== | |
--- nbproject/build-impl.xml (リビジョン 2) | |
+++ nbproject/build-impl.xml (リビジョン 5) | |
@@ -120,7 +120,9 @@ | |
</and> | |
</condition> | |
<condition property="have.tests"> | |
- <or/> | |
+ <or> | |
+ <available file="${test.test.dir}"/> | |
+ </or> | |
</condition> | |
<condition property="have.sources"> | |
<or> | |
@@ -181,6 +183,7 @@ | |
</target> | |
<target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check"> | |
<fail unless="src.dir">Must set src.dir</fail> | |
+ <fail unless="test.test.dir">Must set test.test.dir</fail> | |
<fail unless="build.dir">Must set build.dir</fail> | |
<fail unless="dist.dir">Must set dist.dir</fail> | |
<fail unless="build.classes.dir">Must set build.classes.dir</fail> | |
@@ -307,7 +310,11 @@ | |
<attribute default="**" name="testincludes"/> | |
<sequential> | |
<junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true" tempdir="${build.dir}"> | |
- <batchtest todir="${build.test.results.dir}"/> | |
+ <batchtest todir="${build.test.results.dir}"> | |
+ <fileset dir="${test.test.dir}" excludes="@{excludes},${excludes}" includes="@{includes}"> | |
+ <filename name="@{testincludes}"/> | |
+ </fileset> | |
+ </batchtest> | |
<classpath> | |
<path path="${run.test.classpath}"/> | |
</classpath> | |
@@ -719,11 +726,13 @@ | |
<!-- You can override this target in the ../build.xml file. --> | |
</target> | |
<target if="do.depend.true" name="-compile-test-depend"> | |
- <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir=""/> | |
+ <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.test.dir}"/> | |
</target> | |
<target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test"> | |
- <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" processorpath="${javac.test.processorpath}" srcdir=""/> | |
- <copy todir="${build.test.classes.dir}"/> | |
+ <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" processorpath="${javac.test.processorpath}" srcdir="${test.test.dir}"/> | |
+ <copy todir="${build.test.classes.dir}"> | |
+ <fileset dir="${test.test.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/> | |
+ </copy> | |
</target> | |
<target name="-post-compile-test"> | |
<!-- Empty placeholder for easier customization. --> | |
@@ -737,8 +746,10 @@ | |
<target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single"> | |
<fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail> | |
<j2seproject3:force-recompile destdir="${build.test.classes.dir}"/> | |
- <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" processorpath="${javac.test.processorpath}" sourcepath="" srcdir=""/> | |
- <copy todir="${build.test.classes.dir}"/> | |
+ <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" processorpath="${javac.test.processorpath}" sourcepath="${test.test.dir}" srcdir="${test.test.dir}"/> | |
+ <copy todir="${build.test.classes.dir}"> | |
+ <fileset dir="${test.test.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/> | |
+ </copy> | |
</target> | |
<target name="-post-compile-test-single"> | |
<!-- Empty placeholder for easier customization. --> | |
Index: src/main/SettingDialog.form | |
=================================================================== | |
--- src/main/SettingDialog.form (リビジョン 0) | |
+++ src/main/SettingDialog.form (リビジョン 5) | |
@@ -0,0 +1,56 @@ | |
+<?xml version="1.1" encoding="UTF-8" ?> | |
+ | |
+<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> | |
+ <Properties> | |
+ <Property name="defaultCloseOperation" type="int" value="2"/> | |
+ <Property name="title" type="java.lang.String" value="そーめん大陸 - 設定"/> | |
+ </Properties> | |
+ <SyntheticProperties> | |
+ <SyntheticProperty name="formSizePolicy" type="int" value="1"/> | |
+ </SyntheticProperties> | |
+ <AuxValues> | |
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> | |
+ <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> | |
+ <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> | |
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> | |
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> | |
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> | |
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> | |
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> | |
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> | |
+ </AuxValues> | |
+ | |
+ <Layout> | |
+ <DimensionLayout dim="0"> | |
+ <Group type="103" groupAlignment="0" attributes="0"> | |
+ <Group type="102" alignment="0" attributes="0"> | |
+ <EmptySpace max="-2" attributes="0"/> | |
+ <Component id="jToggleButton1" min="-2" max="-2" attributes="0"/> | |
+ <EmptySpace max="32767" attributes="0"/> | |
+ </Group> | |
+ </Group> | |
+ </DimensionLayout> | |
+ <DimensionLayout dim="1"> | |
+ <Group type="103" groupAlignment="0" attributes="0"> | |
+ <Group type="102" alignment="0" attributes="0"> | |
+ <EmptySpace min="-2" pref="21" max="-2" attributes="0"/> | |
+ <Component id="jToggleButton1" min="-2" max="-2" attributes="0"/> | |
+ <EmptySpace pref="23" max="32767" attributes="0"/> | |
+ </Group> | |
+ </Group> | |
+ </DimensionLayout> | |
+ </Layout> | |
+ <SubComponents> | |
+ <Component class="javax.swing.JToggleButton" name="jToggleButton1"> | |
+ <Properties> | |
+ <Property name="text" type="java.lang.String" value="enable/disable defrag(F4)"/> | |
+ </Properties> | |
+ <Events> | |
+ <EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="settingDefrag"/> | |
+ </Events> | |
+ <AuxValues> | |
+ <AuxValue name="JavaCodeGenerator_allCodePost" type="java.lang.String" value="if (Setting.getInstance().configDefragEnabled) {
 jToggleButton1.setSelected(true);
} else {
 jToggleButton1.setSelected(false);
}"/> | |
+ </AuxValues> | |
+ </Component> | |
+ </SubComponents> | |
+</Form> | |
Index: src/main/SomenTairiku.java | |
=================================================================== | |
--- src/main/SomenTairiku.java (リビジョン 2) | |
+++ src/main/SomenTairiku.java (リビジョン 5) | |
@@ -4,6 +4,7 @@ | |
public class SomenTairiku { | |
public static void main(String[] args) { | |
+ Setting.getInstance().load(); | |
java.awt.EventQueue.invokeLater(new Runnable() { | |
public void run() { | |
new MainWindow().setVisible(true); | |
Index: src/main/MainWindow.java | |
=================================================================== | |
--- src/main/MainWindow.java (リビジョン 2) | |
+++ src/main/MainWindow.java (リビジョン 5) | |
@@ -7,6 +7,7 @@ | |
package main; | |
import java.awt.event.KeyEvent; | |
import javax.swing.ImageIcon; | |
+import main.util.DefragUtil; | |
/** | |
* | |
@@ -34,6 +35,7 @@ | |
textArea = new javax.swing.JTextArea(); | |
labelCount = new javax.swing.JLabel(); | |
+ jButton1 = new javax.swing.JButton(); | |
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); | |
setTitle("そーめん大陸"); | |
@@ -58,21 +60,31 @@ | |
} | |
}); | |
+ jButton1.setText("setting"); | |
+ jButton1.addActionListener(new java.awt.event.ActionListener() { | |
+ public void actionPerformed(java.awt.event.ActionEvent evt) { | |
+ openSettingDialog(evt); | |
+ } | |
+ }); | |
+ | |
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); | |
getContentPane().setLayout(layout); | |
layout.setHorizontalGroup( | |
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() | |
- .addContainerGap() | |
+ .addComponent(jButton1) | |
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 152, Short.MAX_VALUE) | |
.addComponent(labelCount)) | |
.addComponent(textArea, javax.swing.GroupLayout.DEFAULT_SIZE, 254, Short.MAX_VALUE) | |
); | |
layout.setVerticalGroup( | |
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() | |
- .addComponent(textArea, javax.swing.GroupLayout.DEFAULT_SIZE, 75, Short.MAX_VALUE) | |
+ .addComponent(textArea, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) | |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | |
- .addComponent(labelCount)) | |
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | |
+ .addComponent(labelCount) | |
+ .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 13, javax.swing.GroupLayout.PREFERRED_SIZE))) | |
); | |
pack(); | |
@@ -104,6 +116,10 @@ | |
textArea.setText(""); | |
} else if(evt.getKeyCode() == KeyEvent.VK_CONTROL) { | |
ctrlPressed = true; | |
+ } else if (evt.getKeyCode() == KeyEvent.VK_F4) { | |
+ if (Setting.getInstance().configDefragEnabled) { | |
+ textArea.setText(DefragUtil.defrag(textArea.getText())); | |
+ } | |
} | |
labelCount.setText(Integer.toString(140 - textArea.getText().length())); | |
}//GEN-LAST:event_keyPressed | |
@@ -114,8 +130,12 @@ | |
} | |
}//GEN-LAST:event_keyReleased | |
+ private void openSettingDialog(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openSettingDialog | |
+ new SettingDialog(this, true).setVisible(true); | |
+ }//GEN-LAST:event_openSettingDialog | |
// Variables declaration - do not modify//GEN-BEGIN:variables | |
+ private javax.swing.JButton jButton1; | |
private javax.swing.JLabel labelCount; | |
private javax.swing.JTextArea textArea; | |
// End of variables declaration//GEN-END:variables | |
Index: src/main/Setting.java | |
=================================================================== | |
--- src/main/Setting.java (リビジョン 0) | |
+++ src/main/Setting.java (リビジョン 5) | |
@@ -0,0 +1,62 @@ | |
+/* | |
+ * To change this template, choose Tools | Templates | |
+ * and open the template in the editor. | |
+ */ | |
+package main; | |
+ | |
+import java.io.FileInputStream; | |
+import java.io.FileOutputStream; | |
+import java.io.IOException; | |
+import java.util.Properties; | |
+ | |
+/** | |
+ * 設定を保持するクラスですよ | |
+ * @author hogehiga | |
+ */ | |
+public final class Setting { | |
+ | |
+ private String configFile = System.getProperty("user.home") + ".somentairiku"; | |
+ private Properties props = new Properties(); | |
+ | |
+ /** | |
+ * 設定をファイルに保存しますよ | |
+ */ | |
+ public void save() { | |
+ props.setProperty("defragEnabled", Boolean.toString(configDefragEnabled)); | |
+ try { | |
+ props.store(new FileOutputStream(configFile), null); | |
+ } catch (IOException e) { | |
+ e.printStackTrace(); | |
+ return; | |
+ } | |
+ } | |
+ | |
+ /** | |
+ * 設定をファイルから読み込みますよ | |
+ */ | |
+ public void load() { | |
+ try { | |
+ props.load(new FileInputStream(configFile)); | |
+ } catch (IOException e) { | |
+ e.printStackTrace(); | |
+ return; | |
+ } | |
+ if (props.containsKey("defragEnabled")) { | |
+ configDefragEnabled = Boolean.parseBoolean(props.getProperty("defragEnabled")); | |
+ } else { | |
+ configDefragEnabled = false; | |
+ } | |
+ } | |
+ | |
+ /** | |
+ * デフラグが有効かどうか | |
+ */ | |
+ public boolean configDefragEnabled; | |
+ | |
+ /* Singleton */ | |
+ private static final Setting instance = new Setting(); | |
+ private Setting() {}; | |
+ public static Setting getInstance() { | |
+ return Setting.instance; | |
+ } | |
+} | |
Index: src/main/SettingDialog.java | |
=================================================================== | |
--- src/main/SettingDialog.java (リビジョン 0) | |
+++ src/main/SettingDialog.java (リビジョン 5) | |
@@ -0,0 +1,90 @@ | |
+/* | |
+ * To change this template, choose Tools | Templates | |
+ * and open the template in the editor. | |
+ */ | |
+ | |
+/* | |
+ * SettingDialog.java | |
+ * | |
+ * Created on 2010/10/22, 1:25:59 | |
+ */ | |
+ | |
+package main; | |
+ | |
+/** | |
+ * 設定ダイアログ | |
+ * @author hogehiga | |
+ */ | |
+public class SettingDialog extends javax.swing.JDialog { | |
+ | |
+ /** Creates new form SettingDialog */ | |
+ public SettingDialog(java.awt.Frame parent, boolean modal) { | |
+ super(parent, modal); | |
+ initComponents(); | |
+ } | |
+ | |
+ /** This method is called from within the constructor to | |
+ * initialize the form. | |
+ * WARNING: Do NOT modify this code. The content of this method is | |
+ * always regenerated by the Form Editor. | |
+ */ | |
+ @SuppressWarnings("unchecked") | |
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents | |
+ private void initComponents() { | |
+ | |
+ jToggleButton1 = new javax.swing.JToggleButton(); | |
+ | |
+ setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); | |
+ setTitle("そーめん大陸 - 設定"); | |
+ | |
+ jToggleButton1.setText("enable/disable defrag(F4)"); | |
+ jToggleButton1.addChangeListener(new javax.swing.event.ChangeListener() { | |
+ public void stateChanged(javax.swing.event.ChangeEvent evt) { | |
+ settingDefrag(evt); | |
+ } | |
+ }); | |
+ | |
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); | |
+ getContentPane().setLayout(layout); | |
+ layout.setHorizontalGroup( | |
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
+ .addGroup(layout.createSequentialGroup() | |
+ .addContainerGap() | |
+ .addComponent(jToggleButton1) | |
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) | |
+ ); | |
+ layout.setVerticalGroup( | |
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
+ .addGroup(layout.createSequentialGroup() | |
+ .addGap(21, 21, 21) | |
+ .addComponent(jToggleButton1) | |
+ .addContainerGap(23, Short.MAX_VALUE)) | |
+ ); | |
+ | |
+ if (Setting.getInstance().configDefragEnabled) { | |
+ jToggleButton1.setSelected(true); | |
+ } else { | |
+ jToggleButton1.setSelected(false); | |
+ } | |
+ | |
+ pack(); | |
+ }// </editor-fold>//GEN-END:initComponents | |
+ | |
+ /** | |
+ * デフラグボタンが押されたら、設定を変更あんど保存するよ | |
+ * @param evt | |
+ */ | |
+ private void settingDefrag(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_settingDefrag | |
+ if (jToggleButton1.isSelected()) { | |
+ Setting.getInstance().configDefragEnabled = true; | |
+ } else { | |
+ Setting.getInstance().configDefragEnabled = false; | |
+ } | |
+ Setting.getInstance().save(); | |
+ }//GEN-LAST:event_settingDefrag | |
+ | |
+ // Variables declaration - do not modify//GEN-BEGIN:variables | |
+ private javax.swing.JToggleButton jToggleButton1; | |
+ // End of variables declaration//GEN-END:variables | |
+ | |
+} | |
Index: src/main/util/DefragUtil.java | |
=================================================================== | |
--- src/main/util/DefragUtil.java (リビジョン 0) | |
+++ src/main/util/DefragUtil.java (リビジョン 5) | |
@@ -0,0 +1,46 @@ | |
+/* | |
+ * To change this template, choose Tools | Templates | |
+ * and open the template in the editor. | |
+ */ | |
+package main.util; | |
+ | |
+import java.text.Collator; | |
+import java.util.ArrayList; | |
+import java.util.Collections; | |
+import java.util.List; | |
+import java.util.Locale; | |
+ | |
+/** | |
+ * デフラグ用ユーティリティクラスですね | |
+ * @author hogehiga | |
+ */ | |
+public final class DefragUtil { | |
+ | |
+ /** | |
+ * 文字列をデフラグして返します。 | |
+ * 例) | |
+ * defrag("そーめんたいりく") => "いくそためりんー" | |
+ * @param before | |
+ * @return beforeをデフラグした文字列 | |
+ */ | |
+ public static String defrag(String before) { | |
+ if (before == null) { | |
+ return before; | |
+ } | |
+ // ソートのためにリストに変換 | |
+ List<String> list = new ArrayList(); | |
+ for (int i = 0; i < before.length(); i++) { | |
+ list.add(String.valueOf(before.charAt(i))); | |
+ } | |
+ | |
+ // ソートして文字列にして返す | |
+ Collections.sort(list, Collator.getInstance(Locale.JAPANESE)); | |
+ StringBuilder sb = new StringBuilder(); | |
+ for (String s : list) { | |
+ sb.append(s); | |
+ } | |
+ return sb.toString(); | |
+ } | |
+ | |
+ private DefragUtil() {} | |
+} | |
Index: src/main/MainWindow.form | |
=================================================================== | |
--- src/main/MainWindow.form (リビジョン 2) | |
+++ src/main/MainWindow.form (リビジョン 5) | |
@@ -1,4 +1,4 @@ | |
-<?xml version="1.0" encoding="UTF-8" ?> | |
+<?xml version="1.1" encoding="UTF-8" ?> | |
<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> | |
<Properties> | |
@@ -24,7 +24,8 @@ | |
<DimensionLayout dim="0"> | |
<Group type="103" groupAlignment="0" attributes="0"> | |
<Group type="102" alignment="1" attributes="0"> | |
- <EmptySpace max="-2" attributes="0"/> | |
+ <Component id="jButton1" min="-2" max="-2" attributes="0"/> | |
+ <EmptySpace pref="152" max="32767" attributes="0"/> | |
<Component id="labelCount" min="-2" max="-2" attributes="0"/> | |
</Group> | |
<Component id="textArea" alignment="0" pref="254" max="32767" attributes="0"/> | |
@@ -33,9 +34,12 @@ | |
<DimensionLayout dim="1"> | |
<Group type="103" groupAlignment="0" attributes="0"> | |
<Group type="102" alignment="1" attributes="0"> | |
- <Component id="textArea" pref="75" max="32767" attributes="0"/> | |
+ <Component id="textArea" max="32767" attributes="0"/> | |
<EmptySpace max="-2" attributes="0"/> | |
- <Component id="labelCount" min="-2" max="-2" attributes="0"/> | |
+ <Group type="103" groupAlignment="3" attributes="0"> | |
+ <Component id="labelCount" alignment="3" min="-2" max="-2" attributes="0"/> | |
+ <Component id="jButton1" alignment="3" min="-2" pref="13" max="-2" attributes="0"/> | |
+ </Group> | |
</Group> | |
</Group> | |
</DimensionLayout> | |
@@ -63,5 +67,13 @@ | |
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="labelCountClick"/> | |
</Events> | |
</Component> | |
+ <Component class="javax.swing.JButton" name="jButton1"> | |
+ <Properties> | |
+ <Property name="text" type="java.lang.String" value="setting"/> | |
+ </Properties> | |
+ <Events> | |
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="openSettingDialog"/> | |
+ </Events> | |
+ </Component> | |
</SubComponents> | |
</Form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment