added copy to clipboard button
This commit is contained in:
@@ -6,6 +6,8 @@ import javafx.scene.control.Button;
|
|||||||
import javafx.scene.control.CheckBox;
|
import javafx.scene.control.CheckBox;
|
||||||
import javafx.scene.control.TextArea;
|
import javafx.scene.control.TextArea;
|
||||||
import javafx.scene.control.TextField;
|
import javafx.scene.control.TextField;
|
||||||
|
import javafx.scene.input.Clipboard;
|
||||||
|
import javafx.scene.input.ClipboardContent;
|
||||||
import javafx.scene.text.Text;
|
import javafx.scene.text.Text;
|
||||||
import javafx.scene.text.TextFlow;
|
import javafx.scene.text.TextFlow;
|
||||||
import org.lumijiez.monoalpha.util.CharacterSwitcher;
|
import org.lumijiez.monoalpha.util.CharacterSwitcher;
|
||||||
@@ -45,13 +47,15 @@ public class MainController {
|
|||||||
@FXML
|
@FXML
|
||||||
private CheckBox rainbowCheckbox;
|
private CheckBox rainbowCheckbox;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Button copyButton;
|
||||||
|
|
||||||
private final Map<String, List<String>> dictionaryMap = new HashMap<>();
|
private final Map<String, List<String>> dictionaryMap = new HashMap<>();
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void initialize() {
|
private void initialize() {
|
||||||
analyzeText();
|
analyzeText();
|
||||||
PatternGenerator.loadDictionary(dictionaryMap, patternOutput);
|
PatternGenerator.loadDictionary(dictionaryMap, patternOutput);
|
||||||
//barChart.setStyle("-fx-font-size: 18px;");
|
|
||||||
inputArea.textProperty().addListener((observable, oldValue, newValue) -> {
|
inputArea.textProperty().addListener((observable, oldValue, newValue) -> {
|
||||||
analyzeText();
|
analyzeText();
|
||||||
applyChanges(ruleArea.getText());
|
applyChanges(ruleArea.getText());
|
||||||
@@ -62,6 +66,21 @@ public class MainController {
|
|||||||
RAINBOW = newValue;
|
RAINBOW = newValue;
|
||||||
analyzeText();
|
analyzeText();
|
||||||
});
|
});
|
||||||
|
copyButton.setOnAction(e -> {
|
||||||
|
StringBuilder contentBuilder = new StringBuilder();
|
||||||
|
outputArea.getChildren().forEach(node -> {
|
||||||
|
if (node instanceof Text) {
|
||||||
|
contentBuilder.append(((Text) node).getText());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
String textFlowContent = contentBuilder.toString();
|
||||||
|
|
||||||
|
|
||||||
|
Clipboard clipboard = Clipboard.getSystemClipboard();
|
||||||
|
ClipboardContent clipboardContent = new ClipboardContent();
|
||||||
|
clipboardContent.putString(textFlowContent);
|
||||||
|
clipboard.setContent(clipboardContent);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
|
|||||||
@@ -20,9 +20,11 @@ public class InputAnalyzer {
|
|||||||
|
|
||||||
private static Map<String, Double> createEnglishFrequencies() {
|
private static Map<String, Double> createEnglishFrequencies() {
|
||||||
Map<String, Double> frequencies = new HashMap<>();
|
Map<String, Double> frequencies = new HashMap<>();
|
||||||
String[] letters = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
|
String[] letters = {
|
||||||
"K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
|
// "A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
|
||||||
"U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d",
|
// "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
|
||||||
|
// "U", "V", "W", "X", "Y", "Z",
|
||||||
|
"a", "b", "c", "d",
|
||||||
"e", "f", "g", "h", "i", "j", "k", "l", "m", "n",
|
"e", "f", "g", "h", "i", "j", "k", "l", "m", "n",
|
||||||
"o", "p", "q", "r", "s", "t", "u", "v", "w", "x",
|
"o", "p", "q", "r", "s", "t", "u", "v", "w", "x",
|
||||||
"y", "z"};
|
"y", "z"};
|
||||||
@@ -43,7 +45,7 @@ public class InputAnalyzer {
|
|||||||
Map<Character, Integer> frequencyMap = new HashMap<>();
|
Map<Character, Integer> frequencyMap = new HashMap<>();
|
||||||
text.chars()
|
text.chars()
|
||||||
.filter(Character::isLetter)
|
.filter(Character::isLetter)
|
||||||
.forEach(ch -> frequencyMap.merge((char) ch, 1, Integer::sum));
|
.forEach(ch -> frequencyMap.merge(Character.toLowerCase((char) ch), 1, Integer::sum));
|
||||||
return frequencyMap;
|
return frequencyMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -110,8 +110,7 @@
|
|||||||
<GridPane GridPane.rowIndex="1">
|
<GridPane GridPane.rowIndex="1">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" percentWidth="70.0" prefWidth="100.0" />
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" percentWidth="70.0" prefWidth="100.0" />
|
||||||
<ColumnConstraints halignment="CENTER" hgrow="SOMETIMES" minWidth="10.0" percentWidth="30.0"
|
<ColumnConstraints halignment="CENTER" hgrow="SOMETIMES" minWidth="10.0" percentWidth="30.0" prefWidth="100.0" />
|
||||||
prefWidth="100.0"/>
|
|
||||||
</columnConstraints>
|
</columnConstraints>
|
||||||
<rowConstraints>
|
<rowConstraints>
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
@@ -121,8 +120,7 @@
|
|||||||
<Font size="18.0" />
|
<Font size="18.0" />
|
||||||
</font>
|
</font>
|
||||||
</TextField>
|
</TextField>
|
||||||
<Button fx:id="patternButton" alignment="CENTER" contentDisplay="CENTER" mnemonicParsing="false"
|
<Button fx:id="patternButton" alignment="CENTER" contentDisplay="CENTER" mnemonicParsing="false" styleClass="success" text="Search" GridPane.columnIndex="1" />
|
||||||
styleClass="success" text="Search" GridPane.columnIndex="1"/>
|
|
||||||
</GridPane>
|
</GridPane>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
<GridPane>
|
<GridPane>
|
||||||
@@ -158,13 +156,21 @@
|
|||||||
<Font name="SansSerif Regular" size="22.0" />
|
<Font name="SansSerif Regular" size="22.0" />
|
||||||
</font>
|
</font>
|
||||||
</Label>
|
</Label>
|
||||||
<ScrollPane fitToHeight="true" fitToWidth="true" maxWidth="1.7976931348623157E308" prefHeight="200.0"
|
<GridPane GridPane.rowIndex="1">
|
||||||
prefWidth="200.0"
|
<columnConstraints>
|
||||||
style="-fx-border-color: lightgray; -fx-border-width: 1; -fx-border-radius: 5px;"
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
GridPane.hgrow="ALWAYS" GridPane.rowIndex="1" GridPane.vgrow="ALWAYS">
|
</columnConstraints>
|
||||||
<TextFlow fx:id="outputArea" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308"
|
<rowConstraints>
|
||||||
prefHeight="200.0" prefWidth="200.0" style="-fx-padding: 5px;"/>
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
</rowConstraints>
|
||||||
|
<children>
|
||||||
|
<ScrollPane fitToHeight="true" fitToWidth="true" maxWidth="1.7976931348623157E308" prefHeight="200.0" prefWidth="200.0" style="-fx-border-color: lightgray; -fx-border-width: 1; -fx-border-radius: 5px;" GridPane.hgrow="ALWAYS" GridPane.vgrow="ALWAYS">
|
||||||
|
<TextFlow fx:id="outputArea" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="200.0" prefWidth="200.0" style="-fx-padding: 5px;" />
|
||||||
</ScrollPane>
|
</ScrollPane>
|
||||||
|
<Button fx:id="copyButton" maxWidth="1.7976931348623157E308" mnemonicParsing="false" styleClass="accent" text="Copy to clipboard" GridPane.rowIndex="1" />
|
||||||
|
</children>
|
||||||
|
</GridPane>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
|
|||||||
Reference in New Issue
Block a user