Debian Codegraph @

fontawesomefx-fontawesome/src/test/java/de/jensd/fx/glyphs/fontawesome/App.java

raw
1 package de.jensd.fx.glyphs.fontawesome;
2
3 /**
4 * Copyright (c) 2015 Jens Deters http://www.jensd.de
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
7 * use this file except in compliance with the License. You may obtain a copy of
8 * the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15 * License for the specific language governing permissions and limitations under
16 * the License.
17 *
18 */
19
20
21 import de.jensd.fx.glyphs.fontawesome.utils.FontAwesomeIconFactory;
22 import de.jensd.fx.glyphs.GlyphsBuilder;
23 import de.jensd.fx.glyphs.GlyphsStack;
24 import de.jensd.fx.glyphs.GlyphsStyle;
25 import javafx.application.Application;
26 import javafx.geometry.Insets;
27 import javafx.geometry.Pos;
28 import javafx.scene.Scene;
29 import javafx.scene.control.Button;
30 import javafx.scene.control.ContentDisplay;
31 import javafx.scene.control.Menu;
32 import javafx.scene.control.MenuBar;
33 import javafx.scene.control.MenuItem;
34 import javafx.scene.control.SeparatorMenuItem;
35 import javafx.scene.control.ToggleButton;
36 import javafx.scene.layout.HBox;
37 import javafx.scene.layout.Region;
38 import javafx.scene.layout.VBox;
39 import javafx.scene.text.Text;
40 import javafx.stage.Stage;
41
42 /**
43 *
44 * @author Jens Deters
45 */
46 public class App extends Application {
47
48 @Override
49 public void start(Stage primaryStage) throws Exception {
50
51 VBox root = new VBox();
52 root.setSpacing(10.0);
53
54 Text icon = FontAwesomeIconFactory.get().createIcon(FontAwesomeIcon.ANGELLIST, "10em");
55
56
57 Button testButton = new Button();
58 testButton.getStyleClass().setAll("exit-button");
59 FontAwesomeIconFactory.get().setIcon(testButton, FontAwesomeIcon.POWER_OFF, "6em");
60
61 Button testButton2 = new Button();
62 testButton2.getStyleClass().add("alien-button");
63
64 FontAwesomeIconView fontAwesomeIcon = new FontAwesomeIconView(FontAwesomeIcon.AMBULANCE);
65 fontAwesomeIcon.setStyleClass("my-style");
66
67 ToggleButton iconToggleButton = new ToggleButton("");
68 iconToggleButton.setGraphic(fontAwesomeIcon);
69
70
71 /*
72 .thumbs-up-icon{
73 -glyph-name: "THUMBS_UP";
74 -glyph-size: 6em;
75 }
76
77 .thumbs-down-icon{
78 -glyph-name: "THUMBS_DOWN";
79 -glyph-size: 6em;
80 }
81 */
82 FontAwesomeIconView thumbsUpIcon = new FontAwesomeIconView();
83 thumbsUpIcon.setStyleClass("thumbs-up-icon");
84
85 FontAwesomeIconView thumbsDownIcon = new FontAwesomeIconView();
86 thumbsDownIcon.setStyleClass("thumbs-down-icon");
87
88 Text githubLabel = FontAwesomeIconFactory.get().createIcon(FontAwesomeIcon.GITHUB);
89 Text ambulanceLabel = FontAwesomeIconFactory.get().createIcon(FontAwesomeIcon.PLUS_SQUARE_ALT, "60.0");
90 Button starButton = FontAwesomeIconFactory.get().createIconButton(FontAwesomeIcon.STAR, "Nice!", "48.0", "20.0", ContentDisplay.TOP);
91 Button cloudButton = FontAwesomeIconFactory.get().createIconButton(FontAwesomeIcon.CLOUD, "Download");
92 ToggleButton toggleButton = FontAwesomeIconFactory.get().createIconToggleButton(FontAwesomeIcon.LOCK, "Lock", "60.0", ContentDisplay.TOP);
93 Region stackedIcon1 = GlyphsStack.create().add(GlyphsBuilder.create(FontAwesomeIconView.class).glyph(FontAwesomeIcon.AMBULANCE).build());
94
95 Region stackedIcon2 = GlyphsStack.create()
96 .add(GlyphsBuilder.create(FontAwesomeIconView.class)
97 .glyph(FontAwesomeIcon.SQUARE)
98 .size("3em")
99 .styleClass("stack-base")
100 .build()
101 )
102 .add(GlyphsBuilder.create(FontAwesomeIconView.class)
103 .glyph(FontAwesomeIcon.STAR)
104 .size("2em")
105 .styleClass("stack-top")
106 .build()
107 );
108
109 Region stackedIcon3 = GlyphsStack.create()
110 .add(GlyphsBuilder.create(FontAwesomeIconView.class)
111 .glyph(FontAwesomeIcon.SQUARE)
112 .style("-fx-font-size: 4em; -fx-fill: yellowgreen;")
113 .build()
114 )
115 .add(GlyphsBuilder.create(FontAwesomeIconView.class)
116 .glyph(FontAwesomeIcon.APPLE)
117 .style("-fx-font-size: 3em; -fx-fill: white;")
118 .build()
119 );
120
121 Region stackedIcon4 = GlyphsStack.create()
122 .add(GlyphsBuilder.create(FontAwesomeIconView.class)
123 .glyph(FontAwesomeIcon.SQUARE)
124 .style("-fx-font-size: 4em; -fx-fill: yellowgreen;")
125 .build()
126 )
127 .add(GlyphsBuilder.create(FontAwesomeIconView.class)
128 .glyph(FontAwesomeIcon.APPLE)
129 .style("-fx-font-size: 3em; -fx-fill: black;")
130 .build()
131 );
132
133 Region stackedIcon5 = GlyphsStack.create()
134 .add(GlyphsBuilder.create(FontAwesomeIconView.class)
135 .glyph(FontAwesomeIcon.BUG)
136 .style("-fx-font-size: 2em; -fx-fill: black;")
137 .build()
138 )
139 .add(GlyphsBuilder.create(FontAwesomeIconView.class)
140 .glyph(FontAwesomeIcon.BAN)
141 .style("-fx-font-size: 6em; -fx-fill: red; -fx-opacity: 0.5;")
142 .build()
143 );
144
145 Region stackedIcon6 = GlyphsStack.create()
146 .add(GlyphsBuilder.create(FontAwesomeIconView.class)
147 .glyph(FontAwesomeIcon.CIRCLE)
148 .style("-fx-font-size: 10em; -fx-fill: linear-gradient(#70b4e5 0%, #247cbc 70%, #2c85c1 85%);")
149 .build()
150 )
151 .add(GlyphsBuilder.create(FontAwesomeIconView.class)
152 .glyph(FontAwesomeIcon.TWITTER)
153 .style("-fx-font-size: 6em; -fx-fill: white;")
154 .build()
155 );
156
157 Region stackedIcon7 = GlyphsStack.create()
158 .add(GlyphsBuilder.create(FontAwesomeIconView.class)
159 .glyph(FontAwesomeIcon.CIRCLE)
160 .style("-fx-font-size: 10em; -fx-fill: linear-gradient(#70b4e5 0%, #247cbc 70%, #2c85c1 85%);")
161 .build()
162 )
163 .add(GlyphsBuilder.create(FontAwesomeIconView.class)
164 .glyph(FontAwesomeIcon.BITBUCKET)
165 .style("-fx-font-size: 6em; "
166 + "-fx-fill: linear-gradient(#ffffff, #d2d2d2); "
167 + "-fx-effect: dropshadow( one-pass-box , rgba(0,0,0,0.8) , 4 , 0.0 , 1 , 1 );")
168 .build()
169 );
170 HBox stackIconBox1 = new HBox();
171 stackIconBox1.setSpacing(5.0);
172 stackIconBox1.setPadding(new Insets(10.0));
173 //stackIconBox1.getChildren().addAll(stackedIcon1, stackedIcon2, stackedIcon3, stackedIcon4, stackedIcon5, stackedIcon6, stackedIcon7);
174
175 Region iconStack1 = GlyphsStack.create()
176 .add(GlyphsBuilder.create(FontAwesomeIconView.class)
177 .glyph(FontAwesomeIcon.CIRCLE)
178 .style("-fx-font-size: 12em; -fx-fill: linear-gradient(#70b4e5 0%, #247cbc 70%, #2c85c1 85%);")
179 .build()
180 )
181 .add(GlyphsBuilder.create(FontAwesomeIconView.class)
182 .glyph(FontAwesomeIcon.BITBUCKET)
183 .style("-fx-font-size: 6em; "
184 + "-fx-fill: linear-gradient(#ffffff 0%, #d2d2d2); "
185 + "-fx-effect: dropshadow( one-pass-box , rgba(0,0,0,0.8) , 4 , 0.0 , 1 , 1 );")
186 .build()
187 )
188 .add(GlyphsBuilder.create(FontAwesomeIconView.class)
189 .glyph(FontAwesomeIcon.BAN)
190 .style("-fx-font-size: 12em; -fx-fill: red; -fx-opacity: 0.5;")
191 .build()
192 );
193
194 Region iconStack3 = GlyphsStack.create()
195 .add(GlyphsBuilder.create(FontAwesomeIconView.class)
196 .glyph(FontAwesomeIcon.CIRCLE)
197 .size("12em")
198 .style("-fx-fill: linear-gradient(#70b4e5 0%, #247cbc 70%, #2c85c1 85%);")
199 .build()
200 )
201 .add(GlyphsBuilder.create(FontAwesomeIconView.class)
202 .glyph(FontAwesomeIcon.BAN)
203 .size("12em")
204 .style("-fx-fill: red; -fx-opacity: 0.5;")
205 .build()
206 );
207
208
209 HBox stackIconBox2 = new HBox();
210 stackIconBox2.setSpacing(5.0);
211 stackIconBox2.setPadding(new Insets(10.0));
212 // stackIconBox2.getChildren().addAll(iconStack1, iconStack3);
213
214 HBox basicIconBox = new HBox();
215 basicIconBox.setAlignment(Pos.CENTER);
216 basicIconBox.setSpacing(20.0);
217 basicIconBox.getChildren().addAll(icon, thumbsUpIcon, thumbsDownIcon, iconToggleButton, testButton, testButton2, githubLabel, ambulanceLabel);
218
219 root.getChildren().addAll(createMenubar(), basicIconBox, starButton, cloudButton, toggleButton, stackIconBox1, stackIconBox2);
220
221 Scene scene = new Scene(root);
222 scene.getStylesheets().addAll(GlyphsStyle.DEFAULT.getStylePath());
223
224 primaryStage.setScene(scene);
225 primaryStage.setTitle("FontAwesomeFX demo");
226 primaryStage.show();
227
228 }
229
230 private MenuBar createMenubar() {
231
232 MenuBar menuBar = new MenuBar();
233
234 MenuItem openItem = new MenuItem("Open");
235 FontAwesomeIconFactory.get().setIcon(openItem, FontAwesomeIcon.FILE);
236 MenuItem saveItem = new MenuItem("Save");
237 FontAwesomeIconFactory.get().setIcon(saveItem, FontAwesomeIcon.DOWNLOAD);
238 MenuItem saveAsItem = new MenuItem("Save As...");
239 FontAwesomeIconFactory.get().setIcon(saveAsItem, FontAwesomeIcon.DOWNLOAD);
240 MenuItem exitItem = new MenuItem("Exit");
241 FontAwesomeIconFactory.get().setIcon(exitItem, FontAwesomeIcon.SIGN_OUT);
242
243 Menu menuFile = new Menu("File");
244 menuFile.getItems().add(openItem);
245 menuFile.getItems().add(saveItem);
246 menuFile.getItems().add(saveAsItem);
247 menuFile.getItems().add(new SeparatorMenuItem());
248 menuFile.getItems().add(exitItem);
249
250 Menu menuEdit = new Menu("Edit");
251 Menu menuView = new Menu("View");
252
253 menuBar.getMenus().addAll(menuFile, menuEdit, menuView);
254
255 return menuBar;
256 }
257
258 public static void main(String[] args) {
259 System.setProperty("prism.lcdtext", "false");
260 launch(args);
261 }
262 }