Add glyph font support
This commit is contained in:
@@ -8,6 +8,7 @@ import javafx.stage.Stage;
|
|||||||
import org.controlsfx.control.action.Action;
|
import org.controlsfx.control.action.Action;
|
||||||
import org.controlsfx.dialog.Dialogs;
|
import org.controlsfx.dialog.Dialogs;
|
||||||
import ru.trader.model.*;
|
import ru.trader.model.*;
|
||||||
|
import ru.trader.view.support.CustomBuilderFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@@ -28,8 +29,14 @@ public class Screeners {
|
|||||||
private static OffersEditorController oEditorController;
|
private static OffersEditorController oEditorController;
|
||||||
private static OrdersController ordersController;
|
private static OrdersController ordersController;
|
||||||
|
|
||||||
|
private static FXMLLoader initLoader(URL url){
|
||||||
|
FXMLLoader loader = new FXMLLoader(url);
|
||||||
|
loader.setBuilderFactory(new CustomBuilderFactory());
|
||||||
|
return loader;
|
||||||
|
}
|
||||||
|
|
||||||
public static Parent newScreeners(URL main, String stylesheet) throws IOException {
|
public static Parent newScreeners(URL main, String stylesheet) throws IOException {
|
||||||
FXMLLoader loader = new FXMLLoader(main);
|
FXMLLoader loader = initLoader(main);
|
||||||
mainScreen = loader.load();
|
mainScreen = loader.load();
|
||||||
if (stylesheet!=null)
|
if (stylesheet!=null)
|
||||||
mainScreen.getStylesheets().add(stylesheet);
|
mainScreen.getStylesheets().add(stylesheet);
|
||||||
@@ -42,14 +49,14 @@ public class Screeners {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void loadItemDescStage(URL fxml) throws IOException {
|
public static void loadItemDescStage(URL fxml) throws IOException {
|
||||||
FXMLLoader loader = new FXMLLoader(fxml);
|
FXMLLoader loader = initLoader(fxml);
|
||||||
itemDescScreen = loader.load();
|
itemDescScreen = loader.load();
|
||||||
addStylesheet(itemDescScreen);
|
addStylesheet(itemDescScreen);
|
||||||
itemDescController = loader.getController();
|
itemDescController = loader.getController();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadVEditorStage(URL fxml) throws IOException {
|
public static void loadVEditorStage(URL fxml) throws IOException {
|
||||||
FXMLLoader loader = new FXMLLoader(fxml);
|
FXMLLoader loader = initLoader(fxml);
|
||||||
vEditorScreen = loader.load();
|
vEditorScreen = loader.load();
|
||||||
addStylesheet(vEditorScreen);
|
addStylesheet(vEditorScreen);
|
||||||
vEditorController = loader.getController();
|
vEditorController = loader.getController();
|
||||||
@@ -58,7 +65,7 @@ public class Screeners {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void loadAddOfferStage(URL fxml) throws IOException {
|
public static void loadAddOfferStage(URL fxml) throws IOException {
|
||||||
FXMLLoader loader = new FXMLLoader(fxml);
|
FXMLLoader loader = initLoader(fxml);
|
||||||
editOffersScreen = loader.load();
|
editOffersScreen = loader.load();
|
||||||
addStylesheet(editOffersScreen);
|
addStylesheet(editOffersScreen);
|
||||||
oEditorController = loader.getController();
|
oEditorController = loader.getController();
|
||||||
@@ -67,7 +74,7 @@ public class Screeners {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void loadOrdersStage(URL fxml) throws IOException {
|
public static void loadOrdersStage(URL fxml) throws IOException {
|
||||||
FXMLLoader loader = new FXMLLoader(fxml);
|
FXMLLoader loader = initLoader(fxml);
|
||||||
ordersScreen = loader.load();
|
ordersScreen = loader.load();
|
||||||
addStylesheet(ordersScreen);
|
addStylesheet(ordersScreen);
|
||||||
ordersController = loader.getController();
|
ordersController = loader.getController();
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package ru.trader.view.support;
|
||||||
|
|
||||||
|
import javafx.fxml.JavaFXBuilderFactory;
|
||||||
|
import javafx.util.Builder;
|
||||||
|
import javafx.util.BuilderFactory;
|
||||||
|
import org.controlsfx.glyphfont.Glyph;
|
||||||
|
|
||||||
|
public class CustomBuilderFactory implements BuilderFactory {
|
||||||
|
private BuilderFactory baseFactory;
|
||||||
|
|
||||||
|
public CustomBuilderFactory() {
|
||||||
|
baseFactory = new JavaFXBuilderFactory();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder<?> getBuilder(Class<?> aClass) {
|
||||||
|
if (Glyph.class.equals(aClass)) {
|
||||||
|
return new GlyphBuilder();
|
||||||
|
} else {
|
||||||
|
return baseFactory.getBuilder(aClass);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package ru.trader.view.support;
|
||||||
|
|
||||||
|
import javafx.util.Builder;
|
||||||
|
import org.controlsfx.glyphfont.Glyph;
|
||||||
|
import org.controlsfx.glyphfont.GlyphFontRegistry;
|
||||||
|
|
||||||
|
public class GlyphBuilder implements Builder<Glyph> {
|
||||||
|
|
||||||
|
public String getText() {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setText(String text) {
|
||||||
|
this.text = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String text;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Glyph build() {
|
||||||
|
return (Glyph) GlyphFontRegistry.glyph(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user