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.TextArea;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.input.Clipboard;
|
||||
import javafx.scene.input.ClipboardContent;
|
||||
import javafx.scene.text.Text;
|
||||
import javafx.scene.text.TextFlow;
|
||||
import org.lumijiez.monoalpha.util.CharacterSwitcher;
|
||||
@@ -45,13 +47,15 @@ public class MainController {
|
||||
@FXML
|
||||
private CheckBox rainbowCheckbox;
|
||||
|
||||
@FXML
|
||||
private Button copyButton;
|
||||
|
||||
private final Map<String, List<String>> dictionaryMap = new HashMap<>();
|
||||
|
||||
@FXML
|
||||
private void initialize() {
|
||||
analyzeText();
|
||||
PatternGenerator.loadDictionary(dictionaryMap, patternOutput);
|
||||
//barChart.setStyle("-fx-font-size: 18px;");
|
||||
inputArea.textProperty().addListener((observable, oldValue, newValue) -> {
|
||||
analyzeText();
|
||||
applyChanges(ruleArea.getText());
|
||||
@@ -62,6 +66,21 @@ public class MainController {
|
||||
RAINBOW = newValue;
|
||||
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
|
||||
|
||||
@@ -20,9 +20,11 @@ public class InputAnalyzer {
|
||||
|
||||
private static Map<String, Double> createEnglishFrequencies() {
|
||||
Map<String, Double> frequencies = new HashMap<>();
|
||||
String[] letters = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
|
||||
"K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
|
||||
"U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d",
|
||||
String[] letters = {
|
||||
// "A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
|
||||
// "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",
|
||||
"o", "p", "q", "r", "s", "t", "u", "v", "w", "x",
|
||||
"y", "z"};
|
||||
@@ -43,7 +45,7 @@ public class InputAnalyzer {
|
||||
Map<Character, Integer> frequencyMap = new HashMap<>();
|
||||
text.chars()
|
||||
.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;
|
||||
}
|
||||
|
||||
|
||||
@@ -110,8 +110,7 @@
|
||||
<GridPane GridPane.rowIndex="1">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" percentWidth="70.0" prefWidth="100.0" />
|
||||
<ColumnConstraints halignment="CENTER" hgrow="SOMETIMES" minWidth="10.0" percentWidth="30.0"
|
||||
prefWidth="100.0"/>
|
||||
<ColumnConstraints halignment="CENTER" hgrow="SOMETIMES" minWidth="10.0" percentWidth="30.0" prefWidth="100.0" />
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
@@ -121,8 +120,7 @@
|
||||
<Font size="18.0" />
|
||||
</font>
|
||||
</TextField>
|
||||
<Button fx:id="patternButton" alignment="CENTER" contentDisplay="CENTER" mnemonicParsing="false"
|
||||
styleClass="success" text="Search" GridPane.columnIndex="1"/>
|
||||
<Button fx:id="patternButton" alignment="CENTER" contentDisplay="CENTER" mnemonicParsing="false" styleClass="success" text="Search" GridPane.columnIndex="1" />
|
||||
</GridPane>
|
||||
</GridPane>
|
||||
<GridPane>
|
||||
@@ -158,13 +156,21 @@
|
||||
<Font name="SansSerif Regular" size="22.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<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.rowIndex="1" GridPane.vgrow="ALWAYS">
|
||||
<TextFlow fx:id="outputArea" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308"
|
||||
prefHeight="200.0" prefWidth="200.0" style="-fx-padding: 5px;"/>
|
||||
<GridPane GridPane.rowIndex="1">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<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>
|
||||
<Button fx:id="copyButton" maxWidth="1.7976931348623157E308" mnemonicParsing="false" styleClass="accent" text="Copy to clipboard" GridPane.rowIndex="1" />
|
||||
</children>
|
||||
</GridPane>
|
||||
</GridPane>
|
||||
</GridPane>
|
||||
</GridPane>
|
||||
|
||||
Reference in New Issue
Block a user