Debian Codegraph @

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