Skip to content

Commit 33b340a

Browse files
authored
Merge pull request #10 from reugn/develop
v0.3.0
2 parents a98d81b + f1b9363 commit 33b340a

File tree

16 files changed

+763
-4
lines changed

16 files changed

+763
-4
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Common development tools in one app.
66
* [Epoch Converter](#epoch_converter)
77
* [Regular Expression Tester](#regex)
88
* [Rest API Tester](#rest_api)
9+
* [ASCII Graphics](#ascii)
10+
* [Logs Generator](#logs)
911

1012
## Installation
1113
This is a Maven JavaFX application.
@@ -69,6 +71,22 @@ or download the latest release.
6971

7072
![](./images/rest_api.png)
7173

74+
<a name="ascii"/>
75+
76+
### ASCII Graphics
77+
* Convert text to ASCII
78+
79+
![](./images/ascii.png)
80+
81+
<a name="logs"/>
82+
83+
### Logs Generator
84+
* Generate log using given format and fake data
85+
* Write to console
86+
* Write to file
87+
88+
![](./images/logs.png)
89+
7290
## Contributing
7391
If you find this project useful and want to contribute, please open an issue or create a PR.
7492

images/ascii.png

34.5 KB
Loading

images/logs.png

113 KB
Loading

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.github.reugn</groupId>
88
<artifactId>devtools</artifactId>
9-
<version>0.2.0</version>
9+
<version>0.3.0</version>
1010

1111
<organization>
1212
<name>com.github.reugn</name>
@@ -67,12 +67,12 @@
6767
<dependency>
6868
<groupId>com.fasterxml.jackson.core</groupId>
6969
<artifactId>jackson-core</artifactId>
70-
<version>2.9.10</version>
70+
<version>2.10.0</version>
7171
</dependency>
7272
<dependency>
7373
<groupId>com.fasterxml.jackson.core</groupId>
7474
<artifactId>jackson-databind</artifactId>
75-
<version>2.9.10</version>
75+
<version>2.10.0</version>
7676
</dependency>
7777
<dependency>
7878
<groupId>com.google.guava</groupId>

src/main/java/com/github/reugn/devtools/Main.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static class App extends Application {
1818
@Override
1919
public void start(Stage primaryStage) throws Exception {
2020
Parent root = FXMLLoader.load(getClass().getResource("/views/main.fxml"));
21-
primaryStage.setTitle("Dev-tools");
21+
primaryStage.setTitle("Development tools");
2222
primaryStage.getIcons().add(new Image("/images/icons8-toolbox-64.png"));
2323
Scene scene = new Scene(root, 900, 500);
2424
scene.getStylesheets().addAll("/css/main.css", "/css/json-highlighting.css");
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
package com.github.reugn.devtools.controllers;
2+
3+
import com.github.reugn.devtools.services.AsciiService;
4+
import com.github.reugn.devtools.utils.Elements;
5+
import com.github.reugn.devtools.utils.Logger;
6+
import javafx.event.ActionEvent;
7+
import javafx.fxml.FXML;
8+
import javafx.fxml.Initializable;
9+
import javafx.geometry.Insets;
10+
import javafx.scene.control.*;
11+
import javafx.scene.input.KeyEvent;
12+
import javafx.scene.layout.Border;
13+
import javafx.scene.layout.HBox;
14+
import javafx.scene.text.Font;
15+
import org.apache.commons.lang3.StringUtils;
16+
17+
import java.net.URL;
18+
import java.util.ResourceBundle;
19+
20+
public class AsciiController implements Initializable, Logger {
21+
22+
@FXML
23+
private Label asciiLabel;
24+
@FXML
25+
private TextField asciiField;
26+
@FXML
27+
private Button asciiCalculateButton;
28+
@FXML
29+
private Button asciiClearButton;
30+
@FXML
31+
private Label asciiMessage;
32+
@FXML
33+
private TextArea asciiResult;
34+
@FXML
35+
private Label fontSizeLabel;
36+
@FXML
37+
private Label fontNameLabel;
38+
@FXML
39+
private TextField asciiCharField;
40+
@FXML
41+
private TextField fontSizeField;
42+
@FXML
43+
private ComboBox<String> fontNameComboBox;
44+
@FXML
45+
private ComboBox<String> fontStyleComboBox;
46+
@FXML
47+
private Label asciiCharLabel;
48+
@FXML
49+
private Label fontStyleLabel;
50+
51+
@Override
52+
public void initialize(URL url, ResourceBundle resourceBundle) {
53+
54+
HBox.setMargin(fontSizeLabel, new Insets(15, 5, 10, 0));
55+
HBox.setMargin(fontNameLabel, new Insets(15, 5, 10, 0));
56+
HBox.setMargin(asciiCharField, new Insets(10, 5, 10, 0));
57+
HBox.setMargin(fontSizeField, new Insets(10, 5, 10, 0));
58+
59+
HBox.setMargin(fontNameComboBox, new Insets(10, 5, 10, 0));
60+
HBox.setMargin(fontStyleComboBox, new Insets(10, 5, 10, 0));
61+
HBox.setMargin(asciiCharLabel, new Insets(15, 5, 10, 0));
62+
HBox.setMargin(fontStyleLabel, new Insets(15, 5, 10, 0));
63+
64+
HBox.setMargin(asciiLabel, new Insets(15, 5, 10, 0));
65+
HBox.setMargin(asciiField, new Insets(10, 5, 10, 0));
66+
HBox.setMargin(asciiCalculateButton, new Insets(10, 5, 10, 0));
67+
HBox.setMargin(asciiClearButton, new Insets(10, 5, 10, 0));
68+
HBox.setMargin(asciiMessage, new Insets(10, 5, 10, 0));
69+
70+
asciiResult.setPrefRowCount(128);
71+
asciiResult.setFont(Font.font(java.awt.Font.MONOSPACED, 12));
72+
73+
asciiCharField.setText("*");
74+
fontSizeField.setText("14");
75+
fontNameComboBox.getItems().setAll(javafx.scene.text.Font.getFamilies());
76+
fontNameComboBox.setValue("Arial");
77+
fontStyleComboBox.getItems().setAll("PLAIN", "BOLD", "ITALIC");
78+
fontStyleComboBox.setValue("PLAIN");
79+
}
80+
81+
@FXML
82+
private void handleKeyMatch(final KeyEvent keyEvent) {
83+
doConvert();
84+
}
85+
86+
@FXML
87+
private void handleConvert(final ActionEvent actionEvent) {
88+
doConvert();
89+
}
90+
91+
private void doConvert() {
92+
resetBorders();
93+
asciiResult.setText("");
94+
if (validate()) {
95+
int height = Integer.parseInt(fontSizeField.getText());
96+
int style = AsciiService.getStyleByName(fontStyleComboBox.getSelectionModel().getSelectedItem());
97+
String converted = AsciiService.convert(asciiField.getText(), asciiCharField.getText(),
98+
height, style, fontNameComboBox.getSelectionModel().getSelectedItem());
99+
asciiResult.setText(converted);
100+
}
101+
}
102+
103+
@FXML
104+
private void handleClear(final ActionEvent actionEvent) {
105+
asciiField.setText("");
106+
asciiResult.setText("");
107+
}
108+
109+
private boolean validate() {
110+
if (asciiCharField.getText().length() != 1) {
111+
asciiCharField.setBorder(Elements.alertBorder);
112+
return false;
113+
} else if (!StringUtils.isNumeric(fontSizeField.getText()) ||
114+
Integer.parseInt(fontSizeField.getText()) > 128) {
115+
fontSizeField.setBorder(Elements.alertBorder);
116+
return false;
117+
} else return !asciiField.getText().isEmpty();
118+
}
119+
120+
private void resetBorders() {
121+
asciiCharField.setBorder(Border.EMPTY);
122+
fontSizeField.setBorder(Border.EMPTY);
123+
}
124+
}

src/main/java/com/github/reugn/devtools/controllers/EpochController.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import javafx.scene.layout.Border;
1313
import javafx.scene.layout.GridPane;
1414
import javafx.scene.layout.HBox;
15+
import org.apache.commons.lang3.time.DurationFormatUtils;
1516

1617
import java.net.URL;
1718
import java.time.LocalDateTime;
@@ -31,6 +32,8 @@ public class EpochController implements Initializable, Logger {
3132
@FXML
3233
private Button tsToHumanButton;
3334
@FXML
35+
private Button millisToTimeButton;
36+
@FXML
3437
private TextArea tsToHumanResult;
3538
@FXML
3639
private Button humanToTsButton;
@@ -70,6 +73,19 @@ private void handleTsToHumanEpoch(final ActionEvent event) {
7073
}
7174
}
7275

76+
@FXML
77+
private void handleMillisToTime(final ActionEvent actionEvent) {
78+
tsToHumanField.setBorder(Border.EMPTY);
79+
try {
80+
long millis = Long.parseLong(tsToHumanField.getText());
81+
String result = DurationFormatUtils.formatDurationWords(millis, true, true);
82+
tsToHumanResult.setText(result);
83+
} catch (Exception e) {
84+
tsToHumanField.setBorder(Elements.alertBorder);
85+
tsToHumanResult.setText("");
86+
}
87+
}
88+
7389
@FXML
7490
private void handleHumanToTsEpoch(final ActionEvent event) {
7591
resetBorders();
@@ -120,6 +136,7 @@ public void initialize(URL location, ResourceBundle resources) {
120136
HBox.setMargin(currentEpochRefreshButton, new Insets(10, 5, 10, 0));
121137
HBox.setMargin(tsToHumanField, new Insets(10, 5, 10, 0));
122138
HBox.setMargin(tsToHumanButton, new Insets(10, 5, 10, 0));
139+
HBox.setMargin(millisToTimeButton, new Insets(10, 5, 10, 0));
123140

124141
GridPane.setMargin(epochYear, new Insets(10, 5, 0, 0));
125142
GridPane.setMargin(epochMonth, new Insets(10, 5, 0, 0));

0 commit comments

Comments
 (0)