| 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.octicons; |
| 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 |
* @author Naoghuman (https://github.com/Naoghuman) |
| 29 |
*/ |
| 30 |
public class OctIconView extends GlyphIcon<OctIcon> { |
| 31 |
|
| 32 |
public final static String TTF_PATH = "/de/jensd/fx/glyphs/octicons/octicons.ttf"; |
| 33 |
|
| 34 |
static { |
| 35 |
try { |
| 36 |
Font.loadFont(OctIconView.class.getResource(TTF_PATH).openStream(), 10.0d); |
| 37 |
} catch (IOException ex) { |
| 38 |
Logger.getLogger(OctIconView.class.getName()).log(Level.SEVERE, null, ex); |
| 39 |
} |
| 40 |
} |
| 41 |
|
| 42 |
public OctIconView(OctIcon icon, String iconSize) { |
| 43 |
super(OctIcon.class); |
| 44 |
setIcon(icon); |
| 45 |
setStyle(String.format("-fx-font-family: %s; -fx-font-size: %s;", icon.fontFamily(), iconSize)); |
| 46 |
} |
| 47 |
|
| 48 |
public OctIconView(OctIcon icon) { |
| 49 |
this(icon, "1em"); |
| 50 |
} |
| 51 |
|
| 52 |
public OctIconView() { |
| 53 |
this(OctIcon.MARK_GITHUB); |
| 54 |
} |
| 55 |
|
| 56 |
@Override |
| 57 |
public OctIcon getDefaultGlyph() { |
| 58 |
return OctIcon.MARK_GITHUB; |
| 59 |
} |
| 60 |
|
| 61 |
} |