Skip to content

Commit

Permalink
Add stacked icon for JavaFX package
Browse files Browse the repository at this point in the history
  • Loading branch information
aalmiray committed Apr 21, 2016
1 parent 369ceab commit 3b21fff
Show file tree
Hide file tree
Showing 10 changed files with 462 additions and 21 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ buildscript {
classpath 'org.ajoberstar:gradle-git:1.3.2'
classpath 'org.kordamp.gradle:stats-gradle-plugin:0.1.5'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.12.0'
classpath 'net.nemerosa:versioning:1.6.2'
classpath 'net.nemerosa:versioning:1.7.0'
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=1.3.0
version=1.4.0-SNAPSHOT
group=org.kordamp.ikonli
sourceCompatibility=1.7
targetCompatibility=1.7
Expand Down
1 change: 1 addition & 0 deletions subprojects/guide/src/asciidoc/_links.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

:link_devicons: link:http://vorillaz.github.io/devicons/[DevIcons, window="_blank"]
:api_link_fonticon_javafx: link:api/org/kordamp/ikonli/javafx/FontIcon.html[org.kordamp.ikonli.javafx.FontIcon, window="_blank"]
:api_link_stackedfonticon_javafx: link:api/org/kordamp/ikonli/javafx/StackedFontIcon.html[org.kordamp.ikonli.javafx.StackedFontIcon, window="_blank"]
:api_link_fonticon_swing: link:api/org/kordamp/ikonli/swing/FontIcon.html[org.kordamp.ikonli.swing.FontIcon, window="_blank"]

:project-owner: aalmiray
Expand Down
49 changes: 38 additions & 11 deletions subprojects/guide/src/asciidoc/usage.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ compile '{project-group}:ikonli-swing:{project-version}'

The `ikonli-javafx:{project-version}` JAR provides a new Node class: `{api_link_fonticon_javafx}`.
You may use this class with any JavaFX control that accepts a graphic property. You may also use the icon directly as
it is a subclass of `javafx.scene.control.Label`. The icon class can be used inside an FXML file too.
it is a subclass of `javafx.scene.text.Text`. The icon class can be used inside an FXML file too.

[source,xml]
----
Expand All @@ -44,15 +44,13 @@ it is a subclass of `javafx.scene.control.Label`. The icon class can be used ins
<GridPane prefHeight="60.0" prefWidth="200.0"
xmlns:fx="http://javafx.com/fxml"
fx:controller="org.example.AppController">
<children>
<Button GridPane.columnIndex="0" GridPane.rowIndex="0"
mnemonicParsing="false"
prefWidth="200.0">
<graphic>
<FontIcon iconLiteral="di-java" iconSize="64"/>
</graphic>
</Button>
</children>
<Button GridPane.columnIndex="0" GridPane.rowIndex="0"
mnemonicParsing="false"
prefWidth="200.0">
<graphic>
<FontIcon iconLiteral="di-java" iconSize="64"/>
</graphic>
</Button>
</GridPane>
----

Expand All @@ -66,7 +64,6 @@ The `iconLiteral` property accepts any of these formats

where the following rules apply


icon-code:: An icon code literal such as `di-java`.
icon-size:: A number (in pixels) specifying the width of the icon.
icon-color:: A `javafx.scene.paint.Color`, `javafx.scene.paint.LinearGradient`,
Expand All @@ -89,6 +86,36 @@ di-java:64:BLUE
-fx-icon-size:: The size of the icon, in pixels.
-fx-icon-color:: A JavaFX `Paint` definition, such as a plain color or gradient.

A stackable version is also available, `{api_link_stackedfonticon_javafx}`. This is an specialized version of `javafx.scene.layout.StackPane`
that accepts instances of `{api_link_fonticon_javafx}` as child content. You may use this class with FXML, like it's shown
in the following example

[source,xml]
----
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.GridPane?>
<?import org.kordamp.ikonli.javafx.FontIcon?>
<?import org.kordamp.ikonli.javafx.StackedFontIcon?>
<GridPane prefHeight="60.0" prefWidth="200.0"
xmlns:fx="http://javafx.com/fxml"
fx:controller="org.example.AppController">
<StackedFontIcon GridPane.columnIndex="0" GridPane.rowIndex="0" iconSize="48">
<FontIcon iconLiteral="fa-circle-thin" iconColor="red"/>
<FontIcon iconLiteral="fa-camera" StackedFontIcon.iconSize="0.5"/>
</StackedFontIcon>
</GridPane>
----

.Stylable Properties

`{api_link_stackedfonticon_javafx}` exposes properties that can be styled using CSS. It defines a node class named `stacked-ikonli-font-icon`.

[horizontal]
-fx-icon-size:: The size of the icon, in pixels.
-fx-icon-color:: A JavaFX `Paint` definition, such as a plain color or gradient.

=== Installing

[source,groovy]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ public StyleableProperty<Paint> getStyleableProperty(FontIcon icon) {

private static final CssMetaData<FontIcon, Ikon> ICON_CODE =
new CssMetaData<FontIcon, Ikon>("-fx-icon-code",
IconFontConverter.getInstance(), null) {
FontIconConverter.getInstance(), null) {

@Override
public boolean isSettable(FontIcon node) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,27 @@
import javafx.css.StyleConverter;
import javafx.scene.text.Font;
import org.kordamp.ikonli.Ikon;
import org.kordamp.ikonli.javafx.IkonResolver;

/**
* @author Andres Almiray
*/
public class IconFontConverter extends StyleConverter<String, Ikon> {
public class FontIconConverter extends StyleConverter<String, Ikon> {
private static class Holder {
static final IconFontConverter INSTANCE = new IconFontConverter();
static final FontIconConverter INSTANCE = new FontIconConverter();
static final SequenceConverter SEQUENCE_INSTANCE = new SequenceConverter();
}

public static StyleConverter<String, Ikon> getInstance() {
return Holder.INSTANCE;
}

private IconFontConverter() {
private FontIconConverter() {

}

@Override
public String toString() {
return "IconFontConverter";
return "FontIconConverter";
}

@Override
Expand Down Expand Up @@ -106,7 +105,7 @@ public Ikon[] convert(ParsedValue<String, Ikon[]> value, Font font) {

@Override
public String toString() {
return "IconFont.SequenceConverter";
return "FontIcon.SequenceConverter";
}
}
}
Loading

0 comments on commit 3b21fff

Please sign in to comment.