Debian Codegraph @

fontawesomefx-materialdesignfont/src/main/java/de/jensd/fx/glyphs/materialdesignicons/MaterialDesignIconView.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.materialdesignicons;
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 ([email protected])
25 */
26 public class MaterialDesignIconView extends GlyphIcon<MaterialDesignIcon> {
27
28 public final static String TTF_PATH = "/de/jensd/fx/glyphs/materialdesignicons/materialdesignicons-webfont.ttf";
29
30 static {
31 try {
32 Font.loadFont(MaterialDesignIconView.class.getResource(TTF_PATH).openStream(), 10.0d);
33 } catch (IOException ex) {
34 Logger.getLogger(MaterialDesignIconView.class.getName()).log(Level.SEVERE, null, ex);
35 }
36
37 }
38
39 public MaterialDesignIconView(MaterialDesignIcon icon, String iconSize) {
40 super(MaterialDesignIcon.class);
41 setIcon(icon);
42 setStyle(String.format("-fx-font-family: %s; -fx-font-size: %s;", icon.fontFamily(), iconSize));
43 }
44
45 public MaterialDesignIconView(MaterialDesignIcon icon) {
46 this(icon, "1em");
47 }
48
49 public MaterialDesignIconView() {
50 this(MaterialDesignIcon.ANDROID);
51 }
52
53 @Override
54 public MaterialDesignIcon getDefaultGlyph() {
55 return MaterialDesignIcon.ANDROID;
56 }
57
58 }