├── .gitignore ├── LICENSE.md ├── README.md └── src └── main ├── Help.java ├── InputConsole.java ├── Logger.java ├── Main.java ├── Settings.java ├── help.txt └── methods ├── CombinatoricsPermutations.java ├── Helpers.java ├── ProcessInput.java └── WordOptions.java /.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | .classpath 3 | .project 4 | wordList.txt 5 | changelog.txt 6 | log.txt -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Alberto Poljak 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FireCracker word list generator 2 | 3 | Create word list by combining words and permuting characters. 4 | Many options avaiable - program is very usefull if you know a part of the password. 5 | 6 | ## Getting Started 7 | 8 | Fork/download/copy&paste code in any java IDE and it will work. 9 | 10 | ## Installing 11 | 12 | App is still in the making. 13 | 14 | ### Prerequisites 15 | 16 | For running app you will need JRE installed: 17 | 18 | http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html 19 | 20 | ## Usage 21 | 22 | For extensive usage info read the [Wiki](https://github.com/albertopoljak/Word-List/wiki) 23 | 24 | Also usage is detailed explained inside the program by clicking "Help". 25 | 26 | ## License 27 | 28 | This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/main/Help.java: -------------------------------------------------------------------------------- 1 | package main; 2 | import java.awt.EventQueue; 3 | import javax.swing.JFrame; 4 | import javax.swing.JPanel; 5 | import javax.swing.border.EmptyBorder; 6 | import main.methods.Helpers; 7 | import javax.swing.JTextArea; 8 | import java.awt.Font; 9 | import javax.swing.JScrollPane; 10 | import javax.swing.BoxLayout; 11 | import java.awt.Color; 12 | 13 | public class Help extends JFrame { 14 | 15 | private static JPanel contentPane; 16 | 17 | /** 18 | * Launch the application. 19 | */ 20 | public static void newScreen() { 21 | EventQueue.invokeLater(new Runnable() { 22 | public void run() { 23 | try { 24 | Help frame = new Help(); 25 | frame.setVisible(true); 26 | } catch (Exception e) { 27 | e.printStackTrace(); 28 | } 29 | } 30 | }); 31 | } 32 | 33 | /** 34 | * Create the frame. 35 | */ 36 | public Help() { 37 | setTitle("Info (resizable)"); 38 | setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 39 | setBounds(100, 100, 800, 600); 40 | contentPane = new JPanel(); 41 | contentPane.setBorder(new EmptyBorder(0, 0, 0, 0)); 42 | setContentPane(contentPane); 43 | contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.X_AXIS)); 44 | 45 | final JScrollPane scrollPane = new JScrollPane(); 46 | contentPane.add(scrollPane); 47 | 48 | JTextArea txtrT = new JTextArea(); 49 | txtrT.setForeground(Color.LIGHT_GRAY); 50 | txtrT.setBackground(Color.DARK_GRAY); 51 | txtrT.setWrapStyleWord(true); 52 | txtrT.setLineWrap(true); 53 | scrollPane.setViewportView(txtrT); 54 | txtrT.setFont(new Font("Monospaced", Font.PLAIN, 12)); 55 | txtrT.setText( Helpers.readTextFromFile("help.txt") ); 56 | 57 | /* 58 | * Move scroll bar up to the starting position (it goes to bottom after adding help text) 59 | */ 60 | javax.swing.SwingUtilities.invokeLater( new Runnable() { 61 | public void run() { 62 | scrollPane.getVerticalScrollBar().setValue(0); 63 | } 64 | }); 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /src/main/InputConsole.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Arrays; 5 | import java.util.LinkedHashSet; 6 | import java.util.Set; 7 | import javax.swing.JTextPane; 8 | 9 | public class InputConsole extends JTextPane { 10 | private String newLine = System.getProperty("line.separator"); 11 | 12 | /* 13 | * Extract inputed words into ArrayList 14 | * Recognizes words based on variable wordSeparator (newline is considered as word separator.) 15 | * Blank words are eliminated 16 | * Duplicates are not eliminated 17 | * String input can't be null 18 | */ 19 | public ArrayList extractInput(String input ,char wordSeparator){ 20 | ArrayList returnedWords = new ArrayList(); 21 | String tempWord = ""; 22 | char currentChar; 23 | int inputLength = input.length(); 24 | 25 | if (inputLength == 0) { 26 | Main.txtrLog.append("Input is empty!" , 'W'); 27 | return null; 28 | } 29 | 30 | 31 | for (int i=0; i0) 37 | returnedWords.add(tempWord); 38 | else 39 | Main.txtrLog.appendDebug("Skipping empty word (you probably typed word separator twice)..." ); 40 | 41 | tempWord = ""; 42 | } 43 | } 44 | 45 | //Add last word if there is NO newline at the end 46 | if ( !compareCharForNewline( input.charAt( inputLength-1 ) , newLine) ) 47 | returnedWords.add(tempWord); 48 | 49 | Main.txtrLog.appendDebug("Extracted input: " + Arrays.toString(returnedWords.toArray()) ); 50 | 51 | return returnedWords; 52 | } 53 | 54 | private boolean compareCharForNewline( char charInput , String stringInput ){ 55 | String temp = Character.toString(charInput); 56 | //Check if contains because newline(stringInput) can be 2 chars (on windows \r\n) 57 | if ( stringInput.contains(temp)){ 58 | return true; 59 | }else{ 60 | return false; 61 | } 62 | } 63 | 64 | 65 | 66 | /* 67 | * Returns a string of all characters that are between char 'between' 68 | * Example input is: word\\ab"prefix" ,and between is '"' 69 | * then the returned characters are 'prefix' 70 | * Duplicates are not eliminated (we called other method to do it) 71 | * If char between doesn't exist it returns empty string "" 72 | * If there is an odd number of chars between it returns empty string "" 73 | */ 74 | public static String getCharactersFromOptions(String text, char between){ 75 | int i; 76 | int j; 77 | String temp = ""; 78 | String tempChars = ""; 79 | int length = text.length(); 80 | int tempLength; 81 | 82 | if ( !(text != null && !text.isEmpty()) ) 83 | return ""; 84 | 85 | int count = text.length() - text.replace( String.valueOf(between), "").length(); 86 | if ( (count & 1) != 0 ){ 87 | Main.txtrLog.append("There can't be an odd number of '"+between+"' characters!" , 'E' ); 88 | return ""; 89 | } 90 | 91 | for ( i=0; i0 ) 102 | for ( j=0; j charSet = new LinkedHashSet(); 118 | for (char c : chars) { 119 | charSet.add(c); 120 | } 121 | 122 | StringBuilder sb = new StringBuilder(); 123 | for (Character character : charSet) { 124 | sb.append(character); 125 | } 126 | 127 | return sb.toString(); 128 | } 129 | 130 | 131 | } 132 | -------------------------------------------------------------------------------- /src/main/Logger.java: -------------------------------------------------------------------------------- 1 | package main; 2 | import java.awt.Color; 3 | import java.awt.Toolkit; 4 | import java.io.BufferedWriter; 5 | import java.io.FileWriter; 6 | import java.io.IOException; 7 | import java.io.PrintWriter; 8 | import javax.swing.JTextPane; 9 | import javax.swing.text.BadLocationException; 10 | import javax.swing.text.StyleConstants; 11 | import javax.swing.text.StyledDocument; 12 | 13 | import main.methods.Helpers; 14 | 15 | public class Logger extends JTextPane { 16 | 17 | private String newLine = System.getProperty("line.separator");; 18 | private String logFileName; 19 | private PrintWriter logOut; 20 | 21 | 22 | public Logger(){ 23 | this.logFileName = "log.txt"; 24 | }; 25 | 26 | public Logger(String logFileName){ 27 | this.logFileName = logFileName; 28 | }; 29 | 30 | 31 | public void append(String text){ 32 | appendToTextPanel(text, 'I'); 33 | writeToFile(text); 34 | } 35 | 36 | public void append(String text, char color){ 37 | appendToTextPanel(text, color); 38 | writeToFile(text); 39 | } 40 | 41 | public void appendDebug(String text){ 42 | if( Settings.chckbxDebugMode.isSelected() ){ 43 | appendToTextPanel(text, 'D'); 44 | writeToFile(text); 45 | } 46 | } 47 | 48 | public void changeSavePath(String logFileName){ 49 | this.logFileName = logFileName; 50 | } 51 | 52 | private void writeToFile(String text){ 53 | try{ 54 | openPrintWriter(logFileName) ; 55 | writeStringToFile(text); 56 | closePrintWriter(); 57 | }catch (IOException e){ 58 | appendToTextPanel("Error creating file for saving!\n"+e, 'E'); 59 | } 60 | } 61 | 62 | private void openPrintWriter(String filePath) throws IOException{ 63 | try { 64 | logOut = new PrintWriter(new BufferedWriter(new FileWriter(filePath, true))); 65 | } catch (IOException e) { 66 | throw new IOException(e); 67 | } 68 | } 69 | 70 | private void writeStringToFile(String write){ 71 | logOut.print( Helpers.getDate() + write + newLine ); 72 | } 73 | 74 | private void closePrintWriter(){ 75 | if( logOut!=null ) 76 | logOut.close(); 77 | } 78 | 79 | /* 80 | * Appends string message to the textPanel. Importance colors the message: 81 | * E or R = ERROR red 82 | * S or G = SUCCES green 83 | * W or B = WARNING blue 84 | * I or anything else = INFO black 85 | * D = debug 86 | */ 87 | public void appendToTextPanel(String message, char importance){ 88 | StyledDocument doc = this.getStyledDocument(); 89 | //String date = new SimpleDateFormat("[HH:mm:ss] ").format(Calendar.getInstance().getTime()); 90 | javax.swing.text.Style style = this.addStyle("I'm a Style", null); 91 | 92 | if (importance == 'I' || importance== 'S' ) 93 | StyleConstants.setForeground(style, Color.darkGray); 94 | else if (importance == 'W' || importance== 'B' ) 95 | StyleConstants.setForeground(style, Color.blue); 96 | else if (importance == 'S' || importance== 'G' ){ 97 | StyleConstants.setForeground(style, Color.green); 98 | }else if (importance == 'E' || importance== 'R' ){ 99 | StyleConstants.setForeground(style, Color.red); 100 | Toolkit.getDefaultToolkit().beep(); // play beep sound 101 | }else if (importance == 'D' ){ 102 | StyleConstants.setForeground(style, Color.PINK); 103 | } 104 | 105 | try { 106 | doc.insertString(doc.getLength(), Helpers.getDate() + message + newLine ,style); 107 | }catch (BadLocationException e){ 108 | this.setText("ERROR WITH ADDING STRING TO LOG! "+e); 109 | } 110 | } 111 | 112 | 113 | } 114 | -------------------------------------------------------------------------------- /src/main/Main.java: -------------------------------------------------------------------------------- 1 | package main; 2 | import java.awt.EventQueue; 3 | import javax.swing.JFrame; 4 | import javax.swing.JScrollPane; 5 | import javax.swing.JTextArea; 6 | import main.methods.CombinatoricsPermutations; 7 | import main.methods.Helpers; 8 | import main.methods.ProcessInput; 9 | import java.awt.BorderLayout; 10 | import java.awt.Font; 11 | import javax.swing.JButton; 12 | import java.awt.event.MouseAdapter; 13 | import java.awt.event.MouseEvent; 14 | import java.io.BufferedWriter; 15 | import java.io.FileWriter; 16 | import java.io.IOException; 17 | import java.io.PrintWriter; 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | import java.util.Timer; 21 | import java.util.TimerTask; 22 | import javax.swing.JLabel; 23 | import java.awt.Color; 24 | 25 | public class Main { 26 | //Basic elements 27 | private static JFrame frmDecypherInStyle; 28 | private static Settings windowSettings; 29 | private static InputConsole txtWords; 30 | public static Logger txtrLog; 31 | public static JLabel txtComplexity; 32 | private static JLabel textCurrentMemUsage; 33 | private static PrintWriter out; 34 | private static Timer timer; 35 | public static int test = 0; 36 | 37 | /** 38 | * Launch new screen. 39 | */ 40 | public static void main(String[] args) { 41 | EventQueue.invokeLater(new Runnable() { 42 | public void run() { 43 | try { 44 | Main window = new Main(); 45 | window.frmDecypherInStyle.setVisible(true); 46 | windowSettings = new Settings(); 47 | windowSettings.setVisible(false); 48 | 49 | } catch (Exception e) { 50 | e.printStackTrace(); 51 | } 52 | 53 | } 54 | }); 55 | } 56 | 57 | /** 58 | * Create screen elements. 59 | */ 60 | public Main() { 61 | initialize(); 62 | printMemoryUsageInInterval(3); 63 | autoMemoryDetection(); 64 | } 65 | 66 | 67 | /** 68 | * Initialize the contents of the frame. 69 | */ 70 | private static void initialize() { 71 | //Set up the window 72 | frmDecypherInStyle = new JFrame(); 73 | frmDecypherInStyle.getContentPane().setBackground(Color.DARK_GRAY); 74 | frmDecypherInStyle.setResizable(false); 75 | frmDecypherInStyle.setTitle("Hackerman"); 76 | frmDecypherInStyle.setBounds(100, 100, 780, 580); 77 | frmDecypherInStyle.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 78 | frmDecypherInStyle.getContentPane().setLayout(null); 79 | 80 | JLabel txtEnter = new JLabel(); 81 | txtEnter.setForeground(Color.LIGHT_GRAY); 82 | txtEnter.setFont(new Font("Tahoma", Font.PLAIN, 11)); 83 | txtEnter.setBounds(14, 11, 600, 18); 84 | txtEnter.setText("Enter set of possible words with their options"); 85 | txtEnter.setOpaque(false); 86 | frmDecypherInStyle.getContentPane().add(txtEnter); 87 | 88 | txtrLog = new Logger(); 89 | txtrLog.setEditable(false); 90 | txtrLog.setBackground(Color.GRAY); 91 | txtrLog.setText("Log:\n"); 92 | txtrLog.setFont(new Font("Calibri", Font.PLAIN, 18)); 93 | txtrLog.setBounds(20, 49, 399, 482); 94 | 95 | JScrollPane sp = new JScrollPane(txtrLog); 96 | sp.setLocation(14, 240); 97 | sp.setSize(600, 300); 98 | frmDecypherInStyle.getContentPane().add(sp, BorderLayout.CENTER); 99 | 100 | JButton btnGetSavePath = new JButton("Print save path"); 101 | btnGetSavePath.setBackground(Color.DARK_GRAY); 102 | btnGetSavePath.setForeground(Color.GRAY); 103 | btnGetSavePath.setFocusPainted(false); 104 | btnGetSavePath.setFont(new Font("Tahoma", Font.PLAIN, 11)); 105 | btnGetSavePath.addMouseListener(new MouseAdapter() { 106 | @Override 107 | public void mouseReleased(MouseEvent e) { 108 | txtrLog.append("Save path location:\n"+Settings.savePath , 'I'); 109 | } 110 | }); 111 | btnGetSavePath.setBounds(624, 390, 140, 23); 112 | frmDecypherInStyle.getContentPane().add(btnGetSavePath); 113 | 114 | JScrollPane scrollPane = new JScrollPane(); 115 | scrollPane.setBounds(14, 29, 750, 139); 116 | frmDecypherInStyle.getContentPane().add(scrollPane); 117 | 118 | //Add JTextArea for inputting words 119 | txtWords = new InputConsole(); 120 | txtWords.setForeground(Color.BLACK); 121 | txtWords.setBackground(Color.LIGHT_GRAY); 122 | scrollPane.setViewportView(txtWords); 123 | txtWords.setFont(new Font("Monospaced", Font.PLAIN, 12)); 124 | txtWords.setToolTipText(""); 125 | 126 | JButton btnClearWords = new JButton("Clear Words"); 127 | btnClearWords.addMouseListener(new MouseAdapter() { 128 | @Override 129 | public void mouseReleased(MouseEvent e) { 130 | txtWords.setText(""); 131 | } 132 | }); 133 | btnClearWords.setBackground(Color.DARK_GRAY); 134 | btnClearWords.setForeground(Color.GRAY); 135 | btnClearWords.setFocusPainted(false); 136 | btnClearWords.setFont(new Font("Tahoma", Font.PLAIN, 11)); 137 | btnClearWords.setBounds(624, 6, 140, 20); 138 | frmDecypherInStyle.getContentPane().add(btnClearWords); 139 | 140 | JButton btnClearLog = new JButton("Clear Log"); 141 | btnClearLog.setBackground(Color.DARK_GRAY); 142 | btnClearLog.setForeground(Color.GRAY); 143 | btnClearLog.setFocusPainted(false); 144 | btnClearLog.setFont(new Font("Tahoma", Font.PLAIN, 11)); 145 | btnClearLog.addMouseListener(new MouseAdapter() { 146 | @Override 147 | public void mouseReleased(MouseEvent arg0) { 148 | txtrLog.setText("Log:\n"); 149 | } 150 | }); 151 | btnClearLog.setBounds(624, 420, 140, 22); 152 | frmDecypherInStyle.getContentPane().add(btnClearLog); 153 | 154 | JButton btnInfo = new JButton("Help"); 155 | btnInfo.setBackground(Color.DARK_GRAY); 156 | btnInfo.setForeground(Color.GRAY); 157 | btnInfo.setFocusPainted(false); 158 | btnInfo.setFont(new Font("Tahoma", Font.PLAIN, 11)); 159 | btnInfo.addMouseListener(new MouseAdapter() { 160 | @Override 161 | public void mouseReleased(MouseEvent arg0) { 162 | Help.newScreen(); 163 | } 164 | }); 165 | btnInfo.setBounds(624, 449, 140, 22); 166 | frmDecypherInStyle.getContentPane().add(btnInfo); 167 | 168 | JButton btnHack = new JButton("Hack!"); 169 | btnHack.setBackground(Color.DARK_GRAY); 170 | btnHack.setForeground(Color.GRAY); 171 | btnHack.setFocusPainted(false); 172 | btnHack.setFont(new Font("Tahoma", Font.PLAIN, 11)); 173 | btnHack.addMouseListener(new MouseAdapter() { 174 | @Override 175 | public void mouseReleased(MouseEvent e) { 176 | try{ 177 | openPrintWriter("wordList.txt"); 178 | List> tempOutput = new ArrayList>(); 179 | tempOutput = ProcessInput.buildWords( txtWords.extractInput(txtWords.getText() , Settings.wordSeparator) ) ; 180 | CombinatoricsPermutations.combinations2D( Helpers.convertListToStringArray(tempOutput) ); 181 | closePrintWriter(); 182 | txtrLog.appendToTextPanel("Finished!" , 'G'); 183 | txtrLog.appendToTextPanel("Test: "+test, 'I'); 184 | test=0; 185 | 186 | }catch(Exception exc){ 187 | txtrLog.append("Error: "+exc , 'E'); 188 | } 189 | } 190 | }); 191 | btnHack.setBounds(624, 507, 140, 33); 192 | frmDecypherInStyle.getContentPane().add(btnHack); 193 | 194 | JLabel txtrOptions = new JLabel(); 195 | txtrOptions.setForeground(Color.LIGHT_GRAY); 196 | txtrOptions.setText("Post-process options:"); 197 | txtrOptions.setOpaque(false); 198 | txtrOptions.setFont(new Font("Tahoma", Font.PLAIN, 11)); 199 | txtrOptions.setBounds(14, 179, 120, 18); 200 | frmDecypherInStyle.getContentPane().add(txtrOptions); 201 | 202 | JLabel lblMemoryUsage = new JLabel("Current RAM usage:"); 203 | lblMemoryUsage.setForeground(Color.LIGHT_GRAY); 204 | lblMemoryUsage.setFont(new Font("Tahoma", Font.PLAIN, 11)); 205 | lblMemoryUsage.setBounds(624, 240, 140, 14); 206 | frmDecypherInStyle.getContentPane().add(lblMemoryUsage); 207 | 208 | textCurrentMemUsage = new JLabel("MB:"); 209 | textCurrentMemUsage.setToolTipText("In short this is approximately the amount of RAM that this program uses. \r\nYou will not see changes in its usage until you pass a certain memory usage , then Java Virtual Mahine will automatically allocate more memory."); 210 | textCurrentMemUsage.setForeground(Color.LIGHT_GRAY); 211 | textCurrentMemUsage.setFont(new Font("Monospaced", Font.PLAIN, 14)); 212 | textCurrentMemUsage.setBounds(624, 264, 140, 25); 213 | frmDecypherInStyle.getContentPane().add(textCurrentMemUsage); 214 | 215 | JTextArea txtrT = new JTextArea(); 216 | txtrT.setBackground(Color.LIGHT_GRAY); 217 | txtrT.setToolTipText("Example: \\\\sbc\"1234567890AAa\" \\\\sec\"1234567890AAa\""); 218 | txtrT.setFont(new Font("Monospaced", Font.PLAIN, 12)); 219 | txtrT.setBounds(134, 179, 630, 22); 220 | frmDecypherInStyle.getContentPane().add(txtrT); 221 | 222 | JLabel lblAlgorithmComplexity = new JLabel("Algorithm complexity:"); 223 | lblAlgorithmComplexity.setForeground(Color.LIGHT_GRAY); 224 | lblAlgorithmComplexity.setFont(new Font("Tahoma", Font.PLAIN, 11)); 225 | lblAlgorithmComplexity.setBounds(14, 208, 110, 14); 226 | frmDecypherInStyle.getContentPane().add(lblAlgorithmComplexity); 227 | 228 | txtComplexity = new JLabel("Click to refresh or click \"Refresh variables\""); 229 | txtComplexity.addMouseListener(new MouseAdapter() { 230 | @Override 231 | public void mouseReleased(MouseEvent arg0) { 232 | updateComplexityText(); 233 | } 234 | }); 235 | txtComplexity.setForeground(Color.LIGHT_GRAY); 236 | txtComplexity.setFont(new Font("Monospaced", Font.PLAIN, 14)); 237 | txtComplexity.setBounds(134, 204, 630, 25); 238 | frmDecypherInStyle.getContentPane().add(txtComplexity); 239 | 240 | JLabel lblEstimatedMemoryUsage = new JLabel("Estimated filesize on disk:"); 241 | lblEstimatedMemoryUsage.setForeground(Color.LIGHT_GRAY); 242 | lblEstimatedMemoryUsage.setFont(new Font("Tahoma", Font.PLAIN, 11)); 243 | lblEstimatedMemoryUsage.setBounds(624, 300, 140, 14); 244 | frmDecypherInStyle.getContentPane().add(lblEstimatedMemoryUsage); 245 | 246 | JLabel txtEstimatedMemUsage = new JLabel("MB:"); 247 | txtEstimatedMemUsage.setForeground(Color.LIGHT_GRAY); 248 | txtEstimatedMemUsage.setFont(new Font("Monospaced", Font.PLAIN, 14)); 249 | txtEstimatedMemUsage.setBounds(624, 324, 140, 25); 250 | frmDecypherInStyle.getContentPane().add(txtEstimatedMemUsage); 251 | 252 | JButton btnRefreshVariables = new JButton("Refresh variables"); 253 | btnRefreshVariables.setBackground(Color.DARK_GRAY); 254 | btnRefreshVariables.setForeground(Color.GRAY); 255 | btnRefreshVariables.setFocusPainted(false); 256 | btnRefreshVariables.addMouseListener(new MouseAdapter() { 257 | @Override 258 | public void mouseReleased(MouseEvent arg0) { 259 | textCurrentMemUsage.setText("MB: " + getMemoryUsage()); 260 | updateComplexityText(); 261 | 262 | } 263 | }); 264 | btnRefreshVariables.setFont(new Font("Tahoma", Font.PLAIN, 11)); 265 | btnRefreshVariables.setBounds(624, 360, 140, 23); 266 | frmDecypherInStyle.getContentPane().add(btnRefreshVariables); 267 | 268 | JButton btnSettings = new JButton("Settings"); 269 | btnSettings.setBackground(Color.DARK_GRAY); 270 | btnSettings.setForeground(Color.GRAY); 271 | btnSettings.setFocusPainted(false); 272 | btnSettings.addMouseListener(new MouseAdapter() { 273 | @Override 274 | public void mouseReleased(MouseEvent arg0) { 275 | windowSettings.setVisible(true); 276 | } 277 | }); 278 | btnSettings.setFont(new Font("Tahoma", Font.PLAIN, 11)); 279 | btnSettings.setBounds(624, 478, 140, 22); 280 | frmDecypherInStyle.getContentPane().add(btnSettings); 281 | 282 | 283 | } 284 | 285 | 286 | private static void printMemoryUsageInInterval( int intervalSeconds){ 287 | timer = new Timer(); 288 | timer.scheduleAtFixedRate(new TimerTask() { 289 | @Override 290 | public void run() { 291 | textCurrentMemUsage.setText("MB: " + getMemoryUsage()); 292 | } 293 | }, 0, intervalSeconds*1000); 294 | 295 | } 296 | 297 | public static long getMemoryUsage(){ 298 | Runtime instance = Runtime.getRuntime(); 299 | return (instance.totalMemory() - instance.freeMemory()) / 1024 / 1024; 300 | } 301 | 302 | public static long getMaxMemoryUsage(){ 303 | Runtime instance = Runtime.getRuntime(); 304 | return instance.maxMemory() / 1024 / 1024; 305 | } 306 | 307 | public static void changeUpdateVariable(int newInterval){ 308 | timer.cancel(); 309 | if(newInterval>0) 310 | printMemoryUsageInInterval(newInterval); 311 | } 312 | 313 | public static void openPrintWriter(String filePath) throws IOException{ 314 | try { 315 | out = new PrintWriter(new BufferedWriter(new FileWriter(filePath, true))); 316 | } catch (IOException e) { 317 | txtrLog.appendToTextPanel("Error creating file for saving!\n"+e , 'E'); 318 | throw new IOException(e); 319 | } 320 | } 321 | 322 | public static void closePrintWriter(){ 323 | if( out!=null ) 324 | out.close(); 325 | } 326 | 327 | public static void writeStringToPrintWriter(String write[]){ 328 | int n = write.length; 329 | for (int i=0; i> tempOutput = new ArrayList>(); 355 | tempOutput = ProcessInput.buildWords( txtWords.extractInput(txtWords.getText() , Settings.wordSeparator) ) ; 356 | long tempCount = Helpers.totalExpectedGeneratedWords(tempOutput); 357 | txtComplexity.setText( Helpers.getAlgorithmComplexityString(tempCount) + " Words:" + tempCount ); 358 | }catch(Exception exc){ 359 | txtrLog.append("Can't update algorithm complexity text, error: "+exc , 'E'); 360 | } 361 | } 362 | 363 | 364 | } 365 | -------------------------------------------------------------------------------- /src/main/Settings.java: -------------------------------------------------------------------------------- 1 | package main; 2 | import java.awt.EventQueue; 3 | import javax.swing.JFrame; 4 | import javax.swing.JPanel; 5 | import javax.swing.border.EmptyBorder; 6 | import javax.swing.JButton; 7 | import javax.swing.JLabel; 8 | import javax.swing.JRadioButton; 9 | import javax.swing.JCheckBox; 10 | import javax.swing.JTextField; 11 | import javax.swing.JComboBox; 12 | import javax.swing.JFileChooser; 13 | import javax.swing.ButtonGroup; 14 | import javax.swing.DefaultComboBoxModel; 15 | import java.awt.Font; 16 | import java.awt.event.MouseAdapter; 17 | import java.awt.event.MouseEvent; 18 | import java.io.File; 19 | import java.awt.event.ActionListener; 20 | import java.awt.event.ActionEvent; 21 | import java.awt.Color; 22 | import javax.swing.JSeparator; 23 | 24 | public class Settings extends JFrame { 25 | private static JPanel contentPane; 26 | private static JTextField textFieldSavePath; 27 | private static JTextField txtrWordSeparator; 28 | private static JComboBox comboUpdate; 29 | private static JCheckBox chckbxMeasureTimeNeeded; 30 | private static JRadioButton rdbtnIHaveLow; 31 | private static JRadioButton rdbtnIHaveHigh; 32 | private static JRadioButton rdbtnAutoRamDetection; 33 | private static JTextField txtrOptionSeparator; 34 | private final JFileChooser fileChooser; 35 | private static JTextField txtrWordCombinator; 36 | public static JCheckBox chckbxDebugMode ; 37 | /* 38 | * Reserved characters represent a set of characters that can't be chosen as: 39 | * wordSeparator, wordCombine, optionSeparator and subOptionSeparator 40 | * It should contain all letters from options and their sub-options 41 | */ 42 | private static String reservedCharacters = "ABCEFIJOPSUX\\1234567890,-+ "; 43 | public static char wordSeparator = ' '; 44 | public static char wordCombinator = '+'; 45 | public static char optionSeparator = '-'; 46 | private static char subOptionSeparator = ','; 47 | private static String basePath = new File("").getAbsolutePath(); 48 | public static String savePath = basePath; 49 | public static boolean measureVariables = true; 50 | public static boolean lowMemory = true; 51 | 52 | /** 53 | * Launch the application. 54 | */ 55 | public static void newScreen() { 56 | EventQueue.invokeLater(new Runnable() { 57 | public void run() { 58 | try { 59 | Settings frame = new Settings(); 60 | frame.setVisible(true); 61 | } catch (Exception e) { 62 | e.printStackTrace(); 63 | } 64 | } 65 | }); 66 | } 67 | 68 | 69 | /** 70 | * Create the frame. 71 | */ 72 | public Settings() { 73 | setResizable(false); 74 | //Initialize file chooser 75 | basePath = new File("").getAbsolutePath(); 76 | fileChooser = new JFileChooser(basePath); 77 | fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); 78 | 79 | setTitle("Settings"); 80 | setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 81 | setBounds(100, 100, 600, 580); 82 | contentPane = new JPanel(); 83 | contentPane.setBackground(Color.DARK_GRAY); 84 | contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); 85 | setContentPane(contentPane); 86 | contentPane.setLayout(null); 87 | 88 | JButton btnKillTheMusic = new JButton("Kill the music"); 89 | btnKillTheMusic.setEnabled(false); 90 | btnKillTheMusic.setForeground(Color.GRAY); 91 | btnKillTheMusic.setBackground(Color.DARK_GRAY); 92 | btnKillTheMusic.setFocusPainted(false); 93 | btnKillTheMusic.setFont(new Font("Tahoma", Font.PLAIN, 11)); 94 | btnKillTheMusic.setBounds(10, 114, 120, 21); 95 | contentPane.add(btnKillTheMusic); 96 | 97 | JLabel lblPerfomanceOptions = new JLabel("Perfomance options:"); 98 | lblPerfomanceOptions.setForeground(Color.LIGHT_GRAY); 99 | lblPerfomanceOptions.setFont(new Font("Tahoma", Font.PLAIN, 11)); 100 | lblPerfomanceOptions.setBounds(10, 11, 120, 14); 101 | contentPane.add(lblPerfomanceOptions); 102 | 103 | rdbtnIHaveLow = new JRadioButton("Disk"); 104 | rdbtnIHaveLow.setEnabled(false); 105 | rdbtnIHaveLow.setForeground(Color.LIGHT_GRAY); 106 | rdbtnIHaveLow.setBackground(Color.DARK_GRAY); 107 | rdbtnIHaveLow.setFocusPainted(false); 108 | rdbtnIHaveLow.addMouseListener(new MouseAdapter() { 109 | @Override 110 | public void mouseReleased(MouseEvent e) { 111 | memorySettings(); 112 | } 113 | }); 114 | rdbtnIHaveLow.setFont(new Font("Tahoma", Font.PLAIN, 11)); 115 | rdbtnIHaveLow.setBounds(257, 31, 110, 23); 116 | contentPane.add(rdbtnIHaveLow); 117 | 118 | rdbtnIHaveHigh = new JRadioButton("RAM"); 119 | rdbtnIHaveHigh.setEnabled(false); 120 | rdbtnIHaveHigh.setForeground(Color.LIGHT_GRAY); 121 | rdbtnIHaveHigh.setBackground(Color.DARK_GRAY); 122 | rdbtnIHaveHigh.setFocusPainted(false); 123 | rdbtnIHaveHigh.setToolTipText("If the program uses more RAM than you have it will stall and you will have to forcefully close it."); 124 | rdbtnIHaveHigh.addMouseListener(new MouseAdapter() { 125 | @Override 126 | public void mouseReleased(MouseEvent e) { 127 | memorySettings(); 128 | } 129 | }); 130 | rdbtnIHaveHigh.setFont(new Font("Tahoma", Font.PLAIN, 11)); 131 | rdbtnIHaveHigh.setBounds(369, 31, 110, 23); 132 | contentPane.add(rdbtnIHaveHigh); 133 | 134 | rdbtnAutoRamDetection = new JRadioButton("Auto detection"); 135 | rdbtnAutoRamDetection.setEnabled(false); 136 | rdbtnAutoRamDetection.setForeground(Color.LIGHT_GRAY); 137 | rdbtnAutoRamDetection.setBackground(Color.DARK_GRAY); 138 | rdbtnAutoRamDetection.setFocusPainted(false); 139 | rdbtnAutoRamDetection.addMouseListener(new MouseAdapter() { 140 | @Override 141 | public void mouseReleased(MouseEvent e) { 142 | memorySettings(); 143 | } 144 | }); 145 | rdbtnAutoRamDetection.setFont(new Font("Tahoma", Font.PLAIN, 11)); 146 | rdbtnAutoRamDetection.setSelected(true); 147 | rdbtnAutoRamDetection.setBounds(145, 31, 110, 23); 148 | contentPane.add(rdbtnAutoRamDetection); 149 | 150 | ButtonGroup group = new ButtonGroup(); 151 | group.add(rdbtnIHaveLow); 152 | group.add(rdbtnIHaveHigh); 153 | group.add(rdbtnAutoRamDetection); 154 | 155 | JLabel lblDiskUsage = new JLabel("Disk usage:"); 156 | lblDiskUsage.setForeground(Color.LIGHT_GRAY); 157 | lblDiskUsage.setFont(new Font("Tahoma", Font.PLAIN, 11)); 158 | lblDiskUsage.setBounds(10, 457, 120, 14); 159 | contentPane.add(lblDiskUsage); 160 | 161 | textFieldSavePath = new JTextField(); 162 | textFieldSavePath.setEditable(false); 163 | textFieldSavePath.setFont(new Font("Tahoma", Font.PLAIN, 11)); 164 | textFieldSavePath.setBounds(10, 508, 465, 20); 165 | contentPane.add(textFieldSavePath); 166 | textFieldSavePath.setColumns(10); 167 | 168 | JButton btnSetPath = new JButton("Edit path"); 169 | btnSetPath.setBackground(Color.DARK_GRAY); 170 | btnSetPath.setForeground(Color.GRAY); 171 | btnSetPath.setFocusPainted(false); 172 | btnSetPath.addMouseListener(new MouseAdapter() { 173 | @Override 174 | public void mouseReleased(MouseEvent arg0) { 175 | editFileSavePath(); 176 | } 177 | }); 178 | btnSetPath.setFont(new Font("Tahoma", Font.PLAIN, 11)); 179 | btnSetPath.setBounds(485, 507, 89, 23); 180 | contentPane.add(btnSetPath); 181 | 182 | comboUpdate = new JComboBox(); 183 | comboUpdate.setForeground(Color.BLACK); 184 | comboUpdate.setBackground(Color.GRAY); 185 | comboUpdate.setToolTipText("0 = don't update"); 186 | comboUpdate.setFont(new Font("Tahoma", Font.PLAIN, 11)); 187 | comboUpdate.setModel(new DefaultComboBoxModel(new String[] {"0", "1", "2", "3", "4", "5"})); 188 | comboUpdate.setSelectedIndex(3); 189 | comboUpdate.addActionListener(new ActionListener() { 190 | public void actionPerformed(ActionEvent arg0) { 191 | Main.changeUpdateVariable( Integer.parseInt((String)comboUpdate.getSelectedItem())); 192 | } 193 | }); 194 | comboUpdate.setBounds(184, 58, 54, 20); 195 | contentPane.add(comboUpdate); 196 | 197 | JButton btnFreeAllMemory = new JButton("Free all memory"); 198 | btnFreeAllMemory.setEnabled(false); 199 | btnFreeAllMemory.setBackground(Color.DARK_GRAY); 200 | btnFreeAllMemory.setForeground(Color.GRAY); 201 | btnFreeAllMemory.setFocusPainted(false); 202 | btnFreeAllMemory.setFont(new Font("Tahoma", Font.PLAIN, 11)); 203 | btnFreeAllMemory.setToolTipText("This will destroy already generated words that are in memory, it will delete all inputed text, kill the music"); 204 | btnFreeAllMemory.setBounds(140, 114, 110, 21); 205 | contentPane.add(btnFreeAllMemory); 206 | 207 | chckbxMeasureTimeNeeded = new JCheckBox("Measure time needed for each task"); 208 | chckbxMeasureTimeNeeded.setEnabled(false); 209 | chckbxMeasureTimeNeeded.setBackground(Color.DARK_GRAY); 210 | chckbxMeasureTimeNeeded.setForeground(Color.LIGHT_GRAY); 211 | chckbxMeasureTimeNeeded.setFocusPainted(false); 212 | chckbxMeasureTimeNeeded.addActionListener(new ActionListener() { 213 | public void actionPerformed(ActionEvent arg0) { 214 | measureVariables = chckbxMeasureTimeNeeded.isSelected(); 215 | } 216 | }); 217 | chckbxMeasureTimeNeeded.setFont(new Font("Tahoma", Font.PLAIN, 11)); 218 | chckbxMeasureTimeNeeded.setSelected(true); 219 | chckbxMeasureTimeNeeded.setBounds(6, 84, 242, 23); 220 | contentPane.add(chckbxMeasureTimeNeeded); 221 | 222 | txtrWordSeparator = new JTextField(); 223 | txtrWordSeparator.setForeground(Color.BLACK); 224 | txtrWordSeparator.setBackground(Color.LIGHT_GRAY); 225 | txtrWordSeparator.setFont(new Font("Tahoma", Font.PLAIN, 11)); 226 | txtrWordSeparator.setToolTipText("Enter 1 character that symbolises new word. NOTE THAT ALL CHARACTERS FROM OPTION STRING \"\" ARE RESERVED!"); 227 | txtrWordSeparator.setBounds(300, 183, 25, 20); 228 | contentPane.add(txtrWordSeparator); 229 | 230 | JLabel lblMiscOptions = new JLabel("Program execution options:"); 231 | lblMiscOptions.setForeground(Color.LIGHT_GRAY); 232 | lblMiscOptions.setFont(new Font("Tahoma", Font.PLAIN, 11)); 233 | lblMiscOptions.setBounds(10, 161, 150, 14); 234 | contentPane.add(lblMiscOptions); 235 | 236 | JButton btnSetWordSeparator = new JButton("Set"); 237 | btnSetWordSeparator.setBackground(Color.DARK_GRAY); 238 | btnSetWordSeparator.setForeground(Color.GRAY); 239 | btnSetWordSeparator.setFocusPainted(false); 240 | btnSetWordSeparator.addMouseListener(new MouseAdapter() { 241 | @Override 242 | public void mouseReleased(MouseEvent arg0) { 243 | if( txtrWordSeparator.getText()!=null && txtrWordSeparator.getText().length()>0 ){ 244 | String newWordSeparator = String.valueOf(txtrWordSeparator.getText().charAt(0)); 245 | 246 | if( inputContainsCharFromString( newWordSeparator, reservedCharacters ) ) 247 | Main.txtrLog.append("Can't set word separator because that character is reserved! Reserved characters are(inside the quotes, including their lowercase):" + System.getProperty("line.separator") 248 | + "\"" + reservedCharacters + "\"" , 'W'); 249 | else{ 250 | updateReservedCharacters( String.valueOf(wordSeparator), newWordSeparator ); 251 | changeWordSeparator( txtrWordSeparator.getText().charAt(0) ); 252 | Main.txtrLog.append("Word separator has been changed! Note than you can use this character ONLY as word combinator. Using it in any other way (like in your words) will lead to incorrect program functionality." , 'W'); 253 | } 254 | }else 255 | Main.txtrLog.appendToTextPanel("Input a character first!" , 'W'); 256 | } 257 | }); 258 | btnSetWordSeparator.setFont(new Font("Tahoma", Font.PLAIN, 11)); 259 | btnSetWordSeparator.setBounds(330, 183, 50, 20); 260 | contentPane.add(btnSetWordSeparator); 261 | 262 | JLabel lblDontUseSpace = new JLabel("Don't use space as word separator, use this instead:"); 263 | lblDontUseSpace.setForeground(Color.LIGHT_GRAY); 264 | lblDontUseSpace.setFont(new Font("Tahoma", Font.PLAIN, 11)); 265 | lblDontUseSpace.setBounds(10, 186, 270, 14); 266 | contentPane.add(lblDontUseSpace); 267 | 268 | JLabel lblUpdateVariablesEach = new JLabel("Update variables each X seconds:"); 269 | lblUpdateVariablesEach.setForeground(Color.LIGHT_GRAY); 270 | lblUpdateVariablesEach.setFont(new Font("Tahoma", Font.PLAIN, 11)); 271 | lblUpdateVariablesEach.setBounds(10, 61, 176, 14); 272 | contentPane.add(lblUpdateVariablesEach); 273 | 274 | JLabel lblNewLabel = new JLabel("Save word list to the following path:"); 275 | lblNewLabel.setForeground(Color.LIGHT_GRAY); 276 | lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 11)); 277 | lblNewLabel.setBounds(10, 482, 230, 14); 278 | contentPane.add(lblNewLabel); 279 | 280 | JLabel lblDontUseQuotes = new JLabel("Don't use slash as option separator, use this instead:"); 281 | lblDontUseQuotes.setForeground(Color.LIGHT_GRAY); 282 | lblDontUseQuotes.setFont(new Font("Tahoma", Font.PLAIN, 11)); 283 | lblDontUseQuotes.setBounds(10, 207, 294, 14); 284 | contentPane.add(lblDontUseQuotes); 285 | 286 | txtrOptionSeparator = new JTextField(); 287 | txtrOptionSeparator.setForeground(Color.BLACK); 288 | txtrOptionSeparator.setBackground(Color.LIGHT_GRAY); 289 | txtrOptionSeparator.setText("-"); 290 | txtrOptionSeparator.setToolTipText(""); 291 | txtrOptionSeparator.setFont(new Font("Tahoma", Font.PLAIN, 11)); 292 | txtrOptionSeparator.setColumns(10); 293 | txtrOptionSeparator.setBounds(300, 205, 25, 20); 294 | contentPane.add(txtrOptionSeparator); 295 | 296 | JButton btnSetOptionSeparator = new JButton("Set"); 297 | btnSetOptionSeparator.setBackground(Color.DARK_GRAY); 298 | btnSetOptionSeparator.setForeground(Color.GRAY); 299 | btnSetOptionSeparator.setFocusPainted(false); 300 | btnSetOptionSeparator.addMouseListener(new MouseAdapter() { 301 | @Override 302 | public void mouseReleased(MouseEvent arg0) { 303 | if( txtrOptionSeparator.getText()!=null && txtrOptionSeparator.getText().length()>0 ){ 304 | String newOptionSeparator = String.valueOf(txtrOptionSeparator.getText().charAt(0)); 305 | 306 | if( inputContainsCharFromString( newOptionSeparator, reservedCharacters ) ) 307 | Main.txtrLog.append("Can't set option separator because that character is reserved! Reserved characters are(inside the quotes, including their lowercase):" + System.getProperty("line.separator") 308 | + "\"" + reservedCharacters + "\"" , 'W'); 309 | else{ 310 | updateReservedCharacters( String.valueOf(optionSeparator), newOptionSeparator ); 311 | changeOptionSeparator( txtrOptionSeparator.getText().charAt(0) ); 312 | Main.txtrLog.append("Word separator has been changed! " 313 | + "Note than you can use this character ONLY as word separator. " 314 | + "Using it in any other way (like in your words) will lead to incorrect program functionality. " 315 | + "Also note that double word separator means option while single word separator means sub-option of previous option" , 'W'); 316 | } 317 | }else 318 | Main.txtrLog.appendToTextPanel("Input a character first!" , 'W'); 319 | } 320 | }); 321 | btnSetOptionSeparator.setFont(new Font("Tahoma", Font.PLAIN, 11)); 322 | btnSetOptionSeparator.setBounds(330, 205, 50, 20); 323 | contentPane.add(btnSetOptionSeparator); 324 | 325 | JSeparator separator = new JSeparator(); 326 | separator.setBackground(Color.GRAY); 327 | separator.setForeground(Color.LIGHT_GRAY); 328 | separator.setBounds(10, 25, 564, 2); 329 | contentPane.add(separator); 330 | 331 | JSeparator separator_1 = new JSeparator(); 332 | separator_1.setForeground(Color.LIGHT_GRAY); 333 | separator_1.setBackground(Color.GRAY); 334 | separator_1.setBounds(10, 472, 564, 2); 335 | contentPane.add(separator_1); 336 | 337 | JLabel lblNewLabel_1 = new JLabel("Save temporary words to:"); 338 | lblNewLabel_1.setForeground(Color.LIGHT_GRAY); 339 | lblNewLabel_1.setFont(new Font("Tahoma", Font.PLAIN, 11)); 340 | lblNewLabel_1.setBounds(10, 36, 136, 14); 341 | contentPane.add(lblNewLabel_1); 342 | 343 | JLabel lblNewLabel_2 = new JLabel("Advanced:"); 344 | lblNewLabel_2.setForeground(Color.LIGHT_GRAY); 345 | lblNewLabel_2.setFont(new Font("Tahoma", Font.PLAIN, 11)); 346 | lblNewLabel_2.setBounds(10, 357, 60, 14); 347 | contentPane.add(lblNewLabel_2); 348 | 349 | JSeparator separator_2 = new JSeparator(); 350 | separator_2.setForeground(Color.LIGHT_GRAY); 351 | separator_2.setBackground(Color.GRAY); 352 | separator_2.setBounds(10, 371, 564, 2); 353 | contentPane.add(separator_2); 354 | 355 | JLabel lblPrintToLog = new JLabel("Print to log:"); 356 | lblPrintToLog.setForeground(Color.LIGHT_GRAY); 357 | lblPrintToLog.setFont(new Font("Tahoma", Font.PLAIN, 11)); 358 | lblPrintToLog.setBounds(10, 382, 76, 14); 359 | contentPane.add(lblPrintToLog); 360 | 361 | JButton btnCurrentWordsReady = new JButton("Current words ready for permutation"); 362 | btnCurrentWordsReady.setEnabled(false); 363 | btnCurrentWordsReady.setBackground(Color.DARK_GRAY); 364 | btnCurrentWordsReady.setForeground(Color.GRAY); 365 | btnCurrentWordsReady.setFocusPainted(false); 366 | btnCurrentWordsReady.setFont(new Font("Tahoma", Font.PLAIN, 11)); 367 | btnCurrentWordsReady.setBounds(96, 378, 230, 23); 368 | contentPane.add(btnCurrentWordsReady); 369 | 370 | JButton btnRefreshComplexityText = new JButton("Refresh complexity text"); 371 | btnRefreshComplexityText.setEnabled(false); 372 | btnRefreshComplexityText.setBackground(Color.DARK_GRAY); 373 | btnRefreshComplexityText.setForeground(Color.GRAY); 374 | btnRefreshComplexityText.setFocusPainted(false); 375 | btnRefreshComplexityText.setFont(new Font("Tahoma", Font.PLAIN, 11)); 376 | btnRefreshComplexityText.setBounds(96, 403, 229, 23); 377 | contentPane.add(btnRefreshComplexityText); 378 | 379 | JLabel lblNewLabel_3 = new JLabel("Don't use plus as word combinator, use this instead:"); 380 | lblNewLabel_3.setForeground(Color.LIGHT_GRAY); 381 | lblNewLabel_3.setFont(new Font("Tahoma", Font.PLAIN, 11)); 382 | lblNewLabel_3.setBounds(10, 228, 270, 14); 383 | contentPane.add(lblNewLabel_3); 384 | 385 | txtrWordCombinator = new JTextField(); 386 | txtrWordCombinator.setForeground(Color.BLACK); 387 | txtrWordCombinator.setBackground(Color.LIGHT_GRAY); 388 | txtrWordCombinator.setText("+"); 389 | txtrWordCombinator.setBounds(300, 227, 25, 20); 390 | contentPane.add(txtrWordCombinator); 391 | txtrWordCombinator.setColumns(10); 392 | 393 | JButton btnSetWordCombinator = new JButton("Set"); 394 | btnSetWordCombinator.addMouseListener(new MouseAdapter() { 395 | @Override 396 | public void mouseReleased(MouseEvent arg0) { 397 | if( txtrWordCombinator.getText()!=null && txtrWordCombinator.getText().length()>0 ){ 398 | String newWordCombinator = String.valueOf(txtrWordCombinator.getText().charAt(0)); 399 | 400 | if( inputContainsCharFromString( newWordCombinator, reservedCharacters ) ) 401 | Main.txtrLog.append("Can't set word combinator because that character is reserved! Reserved characters are(inside the quotes, including their lowercase):" + System.getProperty("line.separator") 402 | + "\"" + reservedCharacters + "\"" , 'W'); 403 | else{ 404 | updateReservedCharacters( String.valueOf(wordCombinator), newWordCombinator ); 405 | changeWordCombinator( txtrWordCombinator.getText().charAt(0) ); 406 | Main.txtrLog.append("Word combinator has been changed! Note than you can use this character ONLY as word combinator. Using it in any other way (like in your words) will lead to incorrect program functionality." , 'W'); 407 | } 408 | }else 409 | Main.txtrLog.appendToTextPanel("Input a character first!" , 'W'); 410 | } 411 | }); 412 | btnSetWordCombinator.setBackground(Color.DARK_GRAY); 413 | btnSetWordCombinator.setForeground(Color.GRAY); 414 | btnSetWordCombinator.setFocusPainted(false); 415 | btnSetWordCombinator.setFont(new Font("Tahoma", Font.PLAIN, 11)); 416 | btnSetWordCombinator.setBounds(330, 227, 50, 20); 417 | contentPane.add(btnSetWordCombinator); 418 | 419 | JSeparator separator_3 = new JSeparator(); 420 | separator_3.setForeground(Color.LIGHT_GRAY); 421 | separator_3.setBackground(Color.GRAY); 422 | separator_3.setBounds(10, 294, 564, 2); 423 | contentPane.add(separator_3); 424 | 425 | JLabel lblNewLabel_4 = new JLabel("Look and feel"); 426 | lblNewLabel_4.setForeground(Color.LIGHT_GRAY); 427 | lblNewLabel_4.setFont(new Font("Tahoma", Font.PLAIN, 11)); 428 | lblNewLabel_4.setBounds(10, 280, 76, 14); 429 | contentPane.add(lblNewLabel_4); 430 | 431 | JLabel lblTheme = new JLabel("Theme:"); 432 | lblTheme.setForeground(Color.LIGHT_GRAY); 433 | lblTheme.setFont(new Font("Tahoma", Font.PLAIN, 11)); 434 | lblTheme.setBounds(10, 307, 46, 14); 435 | contentPane.add(lblTheme); 436 | 437 | JRadioButton rdbtnDark = new JRadioButton("Dark"); 438 | rdbtnDark.setEnabled(false); 439 | rdbtnDark.setForeground(Color.LIGHT_GRAY); 440 | rdbtnDark.setBackground(Color.DARK_GRAY); 441 | rdbtnDark.setFocusPainted(false); 442 | rdbtnDark.setFont(new Font("Tahoma", Font.PLAIN, 11)); 443 | rdbtnDark.setBounds(62, 303, 65, 23); 444 | rdbtnDark.setSelected(true); 445 | contentPane.add(rdbtnDark); 446 | 447 | JRadioButton rdbtnNewRadioButton = new JRadioButton("Bright"); 448 | rdbtnNewRadioButton.setEnabled(false); 449 | rdbtnNewRadioButton.setBackground(Color.DARK_GRAY); 450 | rdbtnNewRadioButton.setForeground(Color.LIGHT_GRAY); 451 | rdbtnNewRadioButton.setFocusPainted(false); 452 | rdbtnNewRadioButton.setFont(new Font("Tahoma", Font.PLAIN, 11)); 453 | rdbtnNewRadioButton.setBounds(129, 303, 109, 23); 454 | contentPane.add(rdbtnNewRadioButton); 455 | 456 | //Group the radio buttons. 457 | ButtonGroup group2 = new ButtonGroup(); 458 | group2.add(rdbtnDark); 459 | group2.add(rdbtnNewRadioButton); 460 | 461 | JSeparator separator_4 = new JSeparator(); 462 | separator_4.setForeground(Color.LIGHT_GRAY); 463 | separator_4.setBackground(Color.GRAY); 464 | separator_4.setBounds(10, 175, 564, 2); 465 | contentPane.add(separator_4); 466 | 467 | chckbxDebugMode = new JCheckBox("Debug mode"); 468 | chckbxDebugMode.setToolTipText("Debug messages will appear in log"); 469 | chckbxDebugMode.setForeground(Color.LIGHT_GRAY); 470 | chckbxDebugMode.setBackground(Color.DARK_GRAY); 471 | chckbxDebugMode.setFocusPainted(false); 472 | chckbxDebugMode.setBounds(349, 380, 97, 23); 473 | contentPane.add(chckbxDebugMode); 474 | } 475 | 476 | 477 | private void memorySettings(){ 478 | if(rdbtnIHaveLow.isSelected()) 479 | lowMemory = true; 480 | else if(rdbtnIHaveHigh.isSelected()) 481 | lowMemory = false; 482 | else if(rdbtnAutoRamDetection.isSelected()) 483 | Main.autoMemoryDetection(); 484 | } 485 | 486 | private void editFileSavePath(){ 487 | int returnValue = fileChooser.showSaveDialog(contentPane); 488 | 489 | if (returnValue == JFileChooser.APPROVE_OPTION) { 490 | File selectedFile = fileChooser.getSelectedFile(); 491 | textFieldSavePath.setText(selectedFile.getAbsolutePath()); 492 | savePath = selectedFile.getAbsolutePath(); 493 | }else 494 | Main.txtrLog.append("File not selected!", 'E'); 495 | } 496 | 497 | public static void changeWordSeparator(char newSeparator){ 498 | wordSeparator = newSeparator; 499 | } 500 | 501 | public static void changeOptionSeparator(char newSeparator){ 502 | optionSeparator = newSeparator; 503 | } 504 | 505 | public static void changeWordCombinator(char newCombinator){ 506 | wordCombinator = newCombinator; 507 | } 508 | 509 | private static boolean inputContainsCharFromString(String input , String characterSet){ 510 | int length = characterSet.length(); 511 | for( int i=0; i1000000000 Impossible 162 | <1000000000 Very high 163 | <500000000 High 164 | <50000000 Medium 165 | <5000000 Low 166 | <100000 Very low 167 | -------------------------------------------------------------------------------- /src/main/methods/CombinatoricsPermutations.java: -------------------------------------------------------------------------------- 1 | package main.methods; 2 | import main.Main; 3 | 4 | public class CombinatoricsPermutations { 5 | 6 | private CombinatoricsPermutations(){}; 7 | 8 | /* 9 | * Method requires a clean string array (with no nulls) 10 | * Number of generated words: multiply number of words in 1D array block with each number of words from next block 11 | * Example input {{"apple","Apple"},{"banana","Banana",}} will result in: applebanana , appleBanana , Applebanana , AppleBanana 12 | */ 13 | public static void combinations2D(String [][] g) { 14 | int n = 1; 15 | int length = g.length; 16 | 17 | for (int j = 0; j < length; j++) { 18 | n *= g[j].length; 19 | } 20 | 21 | int i[] = new int[length]; 22 | String tempWords[] = new String[length]; 23 | int tempPos = 0; 24 | for (int k = 0; k < n; k++) { 25 | for (int rr = 0; rr < length; rr++) { 26 | tempWords[tempPos] = g[rr][i[rr]]; 27 | tempPos++; 28 | } 29 | //Immediately permute word so we don't have to store it and waste memory 30 | heapPermutation(tempWords , length); 31 | 32 | tempWords = new String[length]; 33 | tempPos = 0; 34 | 35 | i[length-1]++; 36 | for (int j = length-1; j > 0; j--) { 37 | if (i[j] >= g[j].length) { 38 | i[j] = 0; 39 | i[j - 1]++; 40 | } else 41 | break; 42 | } 43 | 44 | } 45 | 46 | } 47 | 48 | 49 | 50 | /* 51 | * Returns total number of generated words for method combinations2D 52 | */ 53 | public static long combinations2DCount(String [][] g) { 54 | int length = g.length; 55 | long totalCombinationCount = 1; 56 | 57 | for(int i = 0; i < length; ++i) 58 | totalCombinationCount *= g[i].length; 59 | 60 | return totalCombinationCount; 61 | } 62 | 63 | 64 | 65 | /* 66 | * Number of generated words is N! where N is number of input words 67 | * Value size needs to be passed as a.length 68 | * Example input {"apple","banana"} will result in: applebanana , bananaapple 69 | */ 70 | public static void heapPermutation(String a[], int size){ 71 | // if size becomes 1 then save the obtained permutation 72 | if (size == 1){ 73 | Main.writeStringToPrintWriter(a); 74 | Main.test++; 75 | } 76 | 77 | for (int i=0; i clearList() { 66 | ArrayList newList = new ArrayList(); 67 | return newList; 68 | } 69 | 70 | 71 | 72 | /* 73 | * Convert List> to String[][] 74 | * Only temporal solution until method combinations2d is reworked so it can work with lists instead of arrays 75 | */ 76 | 77 | public static String[][] convertListToStringArray( List> theStrings ){ 78 | String[][] stringsAsArray = new String[theStrings.size()][]; 79 | for (int i=0; i aList = theStrings.get(i); 81 | stringsAsArray[i] = aList.toArray(new String[aList.size()]); 82 | } 83 | return stringsAsArray; 84 | } 85 | 86 | 87 | public static long totalNumOfElementsIn2DList( List> input, int rows ){ 88 | long counter = 0; 89 | for( int i=0; i> input ){ 104 | long multiplier = 1; 105 | int rows = input.size(); 106 | for( int i=0; i> buildWords( ArrayList inputWords ){ 26 | int i; 27 | int X; 28 | int Y = inputWords.size(); 29 | List> tempOutput = new ArrayList>(); 30 | updateSeparators(); 31 | 32 | //Add Y words and start adding words and their options 33 | for( i=0; i()); 35 | extractWords( tempOutput, i, inputWords.get(i).toString() ); 36 | } 37 | 38 | Main.txtrLog.appendDebug( "Base words that were extracted from input(without their options):" ); 39 | if( Settings.chckbxDebugMode.isSelected() ){ 40 | long tempSize = Helpers.totalNumOfElementsIn2DList(tempOutput, Y); 41 | if( tempSize<50 ) 42 | for( i=0; i> inputList , int index , String extractString ){ 62 | String baseString; 63 | String optionString; 64 | int indexCombining = extractString.indexOf(combiningSeparator); 65 | 66 | if( indexCombining!=-1 ){ 67 | /* 68 | * There is combining separator in string so we will break the word 69 | * in 2 parts and call this function again with each part 70 | */ 71 | Main.txtrLog.appendDebug("Found combining separator in string: " + extractString ); 72 | String tempInput = extractString ; 73 | StringBuilder temp = new StringBuilder(); 74 | for( int i=0; i list = new ArrayList(Arrays.asList(input)); 158 | list.removeAll(Arrays.asList("", null)); 159 | return list.toArray(new String[0]); 160 | } 161 | 162 | 163 | private static void updateSeparators(){ 164 | combiningSeparator = Settings.wordCombinator ; 165 | optionSeparator = Settings.optionSeparator; 166 | } 167 | 168 | 169 | } 170 | -------------------------------------------------------------------------------- /src/main/methods/WordOptions.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albertopoljak/FireCracker/b2eb1229b970ff5bab6ba720fc5446b2b3f6f1c3/src/main/methods/WordOptions.java --------------------------------------------------------------------------------