Skip to content

Commit a6b1926

Browse files
ddamkeddamke
authored andcommitted
Merge branch 'feature/removeFontAwesome2' into feature/#92_word_notes_dialog
2 parents 92cb033 + e7309fa commit a6b1926

File tree

4 files changed

+56
-61
lines changed

4 files changed

+56
-61
lines changed
Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package de.doubleslash.keeptime.common;
22

3-
import javafx.geometry.Bounds;
43
import javafx.scene.Node;
54
import javafx.scene.shape.SVGPath;
65
import org.w3c.dom.Document;
@@ -14,41 +13,40 @@
1413
import java.io.InputStream;
1514

1615
/**
17-
* class loads SvgPath from a SvgFile because Java can not load the original svg file as it is. <p>
16+
* class loads SvgPath from a SvgFile because Java can not load the original svg file as it is.
17+
* <p>
1818
* To load the svg the class extracts the path as string and creates a new SvgPath and returns it.
1919
*/
2020

2121
public class SvgNodeProvider {
2222

23-
private static String getSvgPathWithXMl(Resources.RESOURCE resource) {
24-
String svgPath;
25-
Document document;
26-
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
27-
DocumentBuilder db;
28-
29-
try {
30-
db = dbf.newDocumentBuilder();
31-
} catch (ParserConfigurationException e) {
32-
throw new RuntimeException(e + "Tried to build new document");
33-
}
34-
35-
try (InputStream inputStream = Resources.getResource(resource).openStream()) {
36-
document = db.parse(inputStream);
37-
NodeList nodeList = document.getElementsByTagName("path");
38-
svgPath = nodeList.item(0).getAttributes().getNamedItem("d").getNodeValue();
39-
} catch (IOException | SAXException e) {
40-
throw new RuntimeException(e + " ");
41-
}
42-
return svgPath;
43-
}
44-
45-
public static Node getSvgNode(Resources.RESOURCE resource){
46-
SVGPath IconSvg = new SVGPath();
47-
IconSvg.setContent(getSvgPathWithXMl(resource));
48-
Bounds bounds = IconSvg.getBoundsInParent();
49-
double scale = Math.min(15 / bounds.getWidth(), 15 / bounds.getHeight());
50-
IconSvg.setScaleX(scale);
51-
IconSvg.setScaleY(scale);
52-
return IconSvg;
53-
}
23+
public static String getSvgPathWithXMl(Resources.RESOURCE resource) {
24+
String svgPath;
25+
Document document;
26+
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
27+
DocumentBuilder db;
28+
29+
try {
30+
db = dbf.newDocumentBuilder();
31+
} catch (ParserConfigurationException e) {
32+
throw new RuntimeException("Tried to build new document", e);
33+
}
34+
35+
try (InputStream inputStream = Resources.getResource(resource).openStream()) {
36+
document = db.parse(inputStream);
37+
NodeList nodeList = document.getElementsByTagName("path");
38+
svgPath = nodeList.item(0).getAttributes().getNamedItem("d").getNodeValue();
39+
} catch (IOException | SAXException e) {
40+
throw new RuntimeException("Could not extract SvgPath from resource " + resource, e);
41+
}
42+
return svgPath;
43+
}
44+
45+
public static Node getSvgNodeWithScale(Resources.RESOURCE resource, Double scaleX , Double scaleY) {
46+
SVGPath iconSvg = new SVGPath();
47+
iconSvg.setContent(getSvgPathWithXMl(resource));
48+
iconSvg.setScaleX(scaleX);
49+
iconSvg.setScaleY(scaleY);
50+
return iconSvg;
51+
}
5452
}

src/main/java/de/doubleslash/keeptime/view/ReportController.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,11 +270,10 @@ public void updateItem(final LocalDate item, final boolean empty) {
270270

271271
private Button createDeleteWorkButton(final Work w) {
272272
final Button deleteButton;
273-
deleteButton = new Button("", SvgNodeProvider.getSvgNode(RESOURCE.SVG_TRASH_ICON));
273+
deleteButton = new Button("", SvgNodeProvider.getSvgNodeWithScale(RESOURCE.SVG_TRASH_ICON,0.03,0.03));
274274
deleteButton.setMaxSize(20, 18);
275275
deleteButton.setMinSize(20, 18);
276276
deleteButton.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
277-
278277
deleteButton.setOnAction(e -> {
279278
LOG.info("Delete work clicked.");
280279
final Alert alert = new Alert(AlertType.CONFIRMATION);
@@ -296,7 +295,7 @@ private Button createDeleteWorkButton(final Work w) {
296295
}
297296

298297
private Button createEditWorkButton(final Work work) {
299-
final Button editButton = new Button("",SvgNodeProvider.getSvgNode(RESOURCE.SVG_PENCIL_ICON));
298+
final Button editButton = new Button("",SvgNodeProvider.getSvgNodeWithScale(RESOURCE.SVG_PENCIL_ICON, 0.03 ,0.03));
300299
editButton.setMaxSize(20, 18);
301300
editButton.setMinSize(20, 18);
302301
editButton.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
@@ -356,7 +355,7 @@ private GridPane setUpEditWorkGridPane(final Work work, final Dialog<Work> dialo
356355
}
357356

358357
private Button createCopyProjectButton(final List<Work> projectWork) {
359-
final Button copyButton = new Button("", SvgNodeProvider.getSvgNode(RESOURCE.SVG_FLOPPY_DISK_ICON));
358+
final Button copyButton = new Button("", SvgNodeProvider.getSvgNodeWithScale(RESOURCE.SVG_FLOPPY_DISK_ICON, 0.03 ,0.03));
360359
copyButton.setMaxSize(20, 18);
361360
copyButton.setMinSize(20, 18);
362361
copyButton.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
@@ -379,7 +378,7 @@ private Button createCopyProjectButton(final List<Work> projectWork) {
379378
}
380379

381380
private Node createCopyWorkButton(final Work w) {
382-
final Button copyButton = new Button("", SvgNodeProvider.getSvgNode(RESOURCE.SVG_FLOPPY_DISK_ICON));
381+
final Button copyButton = new Button("", SvgNodeProvider.getSvgNodeWithScale(RESOURCE.SVG_FLOPPY_DISK_ICON, 0.03 ,0.03));
383382
copyButton.setMaxSize(20, 18);
384383
copyButton.setMinSize(20, 18);
385384
copyButton.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);

src/main/java/de/doubleslash/keeptime/view/ViewController.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,18 @@ public class ViewController {
113113
@FXML
114114
private Button calendarButton;
115115

116+
@FXML
117+
private SVGPath calendarIcon;
118+
119+
@FXML
120+
private SVGPath settingsIcon;
121+
122+
@FXML
123+
private SVGPath minimizeIcon;
124+
125+
@FXML
126+
private SVGPath closeIcon;
127+
116128
@FXML
117129
private TextArea textArea;
118130

@@ -185,28 +197,16 @@ private void initialize() {
185197
calendarButton.setOnAction(ae -> calendarClicked());
186198

187199
calendarButton.textFillProperty().bind(fontColorProperty);
188-
calendarButton.setMaxSize(30, 30);
189-
calendarButton.setMinSize(30, 30);
190-
calendarButton.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
191-
calendarButton.setGraphic(SvgNodeProvider.getSvgNode(RESOURCE.SVG_CALENDAR_DAYS_ICON));
200+
calendarButton.setGraphic(SvgNodeProvider.getSvgNodeWithScale(RESOURCE.SVG_CALENDAR_DAYS_ICON, 0.03 ,0.03));
192201

193202
closeButton.textFillProperty().bind(fontColorProperty);
194-
closeButton.setMaxSize(30, 30);
195-
closeButton.setMinSize(30, 30);
196-
closeButton.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
197-
closeButton.setGraphic(SvgNodeProvider.getSvgNode(RESOURCE.SVG_CLOSE_ICON));
203+
closeButton.setGraphic(SvgNodeProvider.getSvgNodeWithScale(RESOURCE.SVG_CLOSE_ICON, 0.03 ,0.03));
198204

199205
settingsButton.textFillProperty().bind(fontColorProperty);
200-
settingsButton.setMaxSize(30, 30);
201-
settingsButton.setMinSize(30, 30);
202-
settingsButton.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
203-
settingsButton.setGraphic(SvgNodeProvider.getSvgNode(RESOURCE.SVG_SETTINGS_ICON));
206+
settingsButton.setGraphic(SvgNodeProvider.getSvgNodeWithScale(RESOURCE.SVG_SETTINGS_ICON, 0.03 ,0.03));
204207

205208
minimizeButton.textFillProperty().bind(fontColorProperty);
206-
minimizeButton.setMaxSize(30, 30);
207-
minimizeButton.setMinSize(30, 30);
208-
minimizeButton.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
209-
minimizeButton.setGraphic(SvgNodeProvider.getSvgNode(RESOURCE.SVG_MINUS_ICON));
209+
minimizeButton.setGraphic(SvgNodeProvider.getSvgNodeWithScale(RESOURCE.SVG_MINUS_ICON , 0.03 ,0.03));
210210

211211
final Runnable updateMainBackgroundColor = this::runUpdateMainBackgroundColor;
212212

src/main/resources/layouts/ViewLayout.fxml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<?import javafx.scene.layout.VBox?>
3131
<?import javafx.scene.text.Font?>
3232

33-
<Pane fx:id="pane" prefHeight="175.0" style="-fx-background-color: rgba(54,143,179,0.01); -fx-background-radius: 10 10 10 10; -fx-border-radius: 10 10 10 10; -fx-border-color: rgba(54,143,179,.0.01);" xmlns="http://javafx.com/javafx/8.0.202-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.doubleslash.keeptime.view.ViewController">
33+
<Pane fx:id="pane" prefHeight="175.0" style="-fx-background-color: rgba(54,143,179,0.01); -fx-background-radius: 10 10 10 10; -fx-border-radius: 10 10 10 10; -fx-border-color: rgba(54,143,179,.0.01);" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.doubleslash.keeptime.view.ViewController">
3434
<children>
3535
<BorderPane fx:id="borderPane" layoutX="5.0" layoutY="-15.0">
3636
<center>
@@ -50,10 +50,8 @@
5050
<center>
5151
<HBox alignment="CENTER" prefHeight="36.0">
5252
<children>
53-
<Button fx:id="calendarButton" mnemonicParsing="false" prefHeight="25.0" prefWidth="22.0" stylesheets="@../css/application.css">
54-
</Button>
55-
<Button fx:id="settingsButton" mnemonicParsing="false" prefHeight="25.0" prefWidth="22.0" stylesheets="@../css/application.css">
56-
</Button>
53+
<Button fx:id="calendarButton" contentDisplay="GRAPHIC_ONLY" maxHeight="30.0" maxWidth="30.0" minHeight="30" minWidth="30" mnemonicParsing="false" prefHeight="25.0" prefWidth="22.0" stylesheets="@../css/application.css" />
54+
<Button fx:id="settingsButton" contentDisplay="GRAPHIC_ONLY" maxHeight="30.0" maxWidth="30.0" minHeight="30.0" minWidth="30.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="22.0" stylesheets="@../css/application.css" />
5755
</children>
5856
</HBox>
5957
</center>
@@ -78,12 +76,12 @@
7876
<Font name="Open Sans Regular" size="14.0" />
7977
</font>
8078
</TextArea>
81-
<Button fx:id="minimizeButton" layoutX="243.0" layoutY="8.0" mnemonicParsing="false" stylesheets="@../css/application.css">
79+
<Button fx:id="minimizeButton" layoutX="239.0" layoutY="9.0" maxHeight="30.0" maxWidth="30.0" minHeight="20.0" minWidth="20.0" mnemonicParsing="false" prefHeight="30.0" prefWidth="30.0" stylesheets="@../css/application.css">
8280
<font>
8381
<Font name="Open Sans Regular" size="12.0" />
8482
</font>
8583
</Button>
86-
<Button fx:id="closeButton" layoutX="266.0" layoutY="8.0" mnemonicParsing="false" stylesheets="@../css/application.css">
84+
<Button fx:id="closeButton" layoutX="262.0" layoutY="9.0" maxHeight="30.0" maxWidth="30.0" minHeight="20.0" minWidth="20.0" mnemonicParsing="false" prefHeight="30.0" prefWidth="30.0" stylesheets="@../css/application.css">
8785
<font>
8886
<Font name="Open Sans Regular" size="12.0" />
8987
</font>

0 commit comments

Comments
 (0)