org.controlsfx.glyphfont.GlyphFontRegistry Java Examples

The following examples show how to use org.controlsfx.glyphfont.GlyphFontRegistry. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: QuestProgress.java    From logbook-kai with MIT License 6 votes vote down vote up
private static void setConditionIcon(TreeItem<String> item, Boolean result) {
    GlyphFont fontAwesome = GlyphFontRegistry.font("FontAwesome");

    StackPane pane = new StackPane();
    pane.setPrefWidth(18);

    if (result != null) {
        if (result) {
            pane.getChildren().add(fontAwesome.create(FontAwesome.Glyph.CHECK).color(Color.GREEN));
        } else {
            pane.getChildren().add(fontAwesome.create(FontAwesome.Glyph.EXCLAMATION).color(Color.RED));
        }
    } else {
        pane.getChildren().add(fontAwesome.create(FontAwesome.Glyph.QUESTION).color(Color.GRAY));
    }
    item.setGraphic(pane);
}
 
Example #2
Source File: MissionCheck.java    From logbook-kai with MIT License 6 votes vote down vote up
private void setIcon(TreeItem<String> item, Boolean result) {
    GlyphFont fontAwesome = GlyphFontRegistry.font("FontAwesome");

    StackPane pane = new StackPane();
    pane.setPrefWidth(18);

    if (result != null) {
        if (result) {
            pane.getChildren().add(fontAwesome.create(FontAwesome.Glyph.CHECK).color(Color.GREEN));
        } else {
            pane.getChildren().add(fontAwesome.create(FontAwesome.Glyph.EXCLAMATION).color(Color.RED));
        }
    } else {
        pane.getChildren().add(fontAwesome.create(FontAwesome.Glyph.QUESTION).color(Color.GRAY));
    }
    item.setGraphic(pane);
}
 
Example #3
Source File: GlyphFactory.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a glyph for given identifier
 *
 * @param icon one of the font code available in {@link FontAwesome} Glyph enum.
 * @return created glyph
 */
public static synchronized Glyph create(final FontAwesome.Glyph icon) {
    if (GlyphFactory.fontAwesome == null) {
        try (InputStream is = GlyphFactory.class.getResourceAsStream("FONT_AWESOME-webfont")) {
            GlyphFactory.fontAwesome = new FontAwesome(is);
            GlyphFontRegistry.register(GlyphFactory.fontAwesome);
        } catch (final IOException e) {
            e.printStackTrace();
        }
    }
    return GlyphFactory.fontAwesome.create(icon);
}
 
Example #4
Source File: NavigationView.java    From PreferencesFX with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the TextField and sets the search icon.
 */
private void setupTextField() {
  searchFld = new CustomTextField();
  GlyphFont fontAwesome = GlyphFontRegistry.font("FontAwesome");
  Glyph glyph = fontAwesome.create(FontAwesome.Glyph.SEARCH).color(Color.GRAY);
  glyph.setPadding(new Insets(0, 3, 0, 5));
  searchFld.setLeft(glyph);
}
 
Example #5
Source File: QuestProgress.java    From logbook-kai with MIT License 5 votes vote down vote up
private static void setFilterIcon(TreeItem<String> item) {
    GlyphFont fontAwesome = GlyphFontRegistry.font("FontAwesome");
    StackPane pane = new StackPane();
    pane.setPrefWidth(18);
    pane.getChildren().add(fontAwesome.create(FontAwesome.Glyph.FILTER).color(Color.ROYALBLUE));
    item.setGraphic(pane);
}
 
Example #6
Source File: QuestProgress.java    From logbook-kai with MIT License 5 votes vote down vote up
private static void setFilterListIcon(TreeItem<String> item) {
    GlyphFont fontAwesome = GlyphFontRegistry.font("FontAwesome");
    StackPane pane = new StackPane();
    pane.setPrefWidth(18);
    pane.getChildren().add(fontAwesome.create(FontAwesome.Glyph.ANGLE_RIGHT).color(Color.ROYALBLUE));
    item.setGraphic(pane);
}
 
Example #7
Source File: MissionCheck.java    From logbook-kai with MIT License 5 votes vote down vote up
private TreeItem<String> buildTree0(Mission mission, List<Ship> fleet) {
    try {
        TreeItem<String> item;
        Optional<MissionCondition> condition = Missions.getMissionCondition(mission.getId());
        if (condition.isPresent()) {
            MissionCondition cond = condition.get();
            cond.test(fleet);
            item = this.buildLeaf(cond);
        } else if (mission.getSampleFleet() != null) {
            item = new TreeItem<>();
            setIcon(item, null);
        } else {
            return null;
        }
        item.setValue(mission.toString());
        if (mission.getSampleFleet() != null) {
            TreeItem<String> sample = new TreeItem<>("サンプル編成");

            GlyphFont fontAwesome = GlyphFontRegistry.font("FontAwesome");

            StackPane pane = new StackPane();
            pane.setPrefWidth(18);
            pane.getChildren().add(fontAwesome.create(FontAwesome.Glyph.INFO));
            sample.setGraphic(pane);

            for (Integer type : mission.getSampleFleet()) {
                Optional.ofNullable(StypeCollection.get()
                        .getStypeMap()
                        .get(type))
                        .map(Stype::getName)
                        .ifPresent(name -> sample.getChildren().add(new TreeItem<>(name)));
            }
            item.getChildren().add(sample);
        }
        return item;
    } catch (Exception e) {
        LoggerHolder.get().error("遠征確認画面で例外", e);
    }
    return null;
}
 
Example #8
Source File: IconUtils.java    From PeerWasp with MIT License 5 votes vote down vote up
/**
 * Returns an error icon (glyph created using font awesome).
 *
 * @return graphic node
 */
public static Node createErrorIcon() {
	GlyphFont fontAwesome = GlyphFontRegistry.font("FontAwesome");
	Glyph graphic = fontAwesome.create(FontAwesome.Glyph.EXCLAMATION_TRIANGLE);
	graphic.setFontSize(20.0);
	graphic.setColor(Color.RED);
	return graphic;
}
 
Example #9
Source File: IconUtils.java    From PeerWasp with MIT License 5 votes vote down vote up
public static void init() {
	InputStream input = FontAwesomeOffline.class.getResourceAsStream(fontLocation);
	if (input != null) {
		font = new FontAwesome(input);
		GlyphFontRegistry.register(font);
		// Note: if we would close the input stream, icons would not be displayed anymore!
	} else {
		logger.warn("Could not initialize font awesome: ''.", fontLocation);
	}
}
 
Example #10
Source File: IconUtilsTest.java    From PeerWasp with MIT License 5 votes vote down vote up
@Test
public void testInitFontAwesomeOffline() {
	// this test may fail if already initialized due to other tests.
	assertNull(IconUtils.getFontAwesome());

	IconUtils.initFontAwesomeOffline();
	GlyphFont font = IconUtils.getFontAwesome();
	assertNotNull(font);

	GlyphFont registeredFont = GlyphFontRegistry.font("FontAwesome");
	assertNotNull(registeredFont);
	assertEquals(font, registeredFont);
}
 
Example #11
Source File: RepoManagerView.java    From gluon-samples with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private Glyph getGitIcon() {
    return GlyphFontRegistry.font("FontAwesome").create(FontAwesome.Glyph.GIT_SQUARE);
}
 
Example #12
Source File: UITools.java    From gluon-samples with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public static Node getIcon(Octicons.Glyph iconType ) {
    Glyph icon = GlyphFontRegistry.font(Octicons.NAME).create(iconType).size(14);
    icon.getStyleClass().add("ref-icon");
    return icon;
}