Debian Codegraph @

fontawesomefx-fontawesome/src/main/java/de/jensd/fx/glyphs/fontawesome/FontAwesomeIconView.java

raw
1 /**
2 * Copyright (c) 2013-2016 Jens Deters http://www.jensd.de
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
5 * License. You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
10 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
11 * governing permissions and limitations under the License.
12 *
13 */
14 package de.jensd.fx.glyphs.fontawesome;
15
16 import de.jensd.fx.glyphs.GlyphIcon;
17 import java.io.IOException;
18 import java.util.logging.Level;
19 import java.util.logging.Logger;
20 import javafx.scene.text.Font;
21
22 /**
23 *
24 * @author Jens Deters
25 */
26 public class FontAwesomeIconView extends GlyphIcon<FontAwesomeIcon> {
27
28 public final static String TTF_PATH = "/de/jensd/fx/glyphs/fontawesome/fontawesome-webfont.ttf";
29
30 static {
31 try {
32 Font.loadFont(FontAwesomeIconView.class.getResource(TTF_PATH).openStream(), 10.0d);
33 } catch (IOException ex) {
34 Logger.getLogger(FontAwesomeIconView.class.getName()).log(Level.SEVERE, null, ex);
35 }
36 }
37
38 public FontAwesomeIconView(FontAwesomeIcon icon, String iconSize) {
39 super(FontAwesomeIcon.class);
40 setIcon(icon);
41 setStyle(String.format("-fx-font-family: %s; -fx-font-size: %s;", icon.fontFamily(), iconSize));
42 }
43
44 public FontAwesomeIconView(FontAwesomeIcon icon) {
45 this(icon, "1em");
46 }
47
48 public FontAwesomeIconView() {
49 this(FontAwesomeIcon.ANCHOR);
50 }
51
52 @Override
53 public FontAwesomeIcon getDefaultGlyph() {
54 return FontAwesomeIcon.ANCHOR;
55 }
56
57 }