use of com.jfoenix.svg.SVGGlyph in project JFoenix by jfoenixadmin.
the class ScrollPaneController method init.
/**
* init fxml when loaded.
*/
@PostConstruct
public void init() {
for (int i = 0; i < 100; i++) {
contentList.getItems().add("Item " + i);
}
contentList.setMaxHeight(3400);
JFXScrollPane.smoothScrolling((ScrollPane) scroll.getChildren().get(0));
SVGGlyph arrow = new SVGGlyph(0, "FULLSCREEN", "M402.746 877.254l-320-320c-24.994-24.992-24.994-65.516 0-90.51l320-320c24.994-24.992 65.516-24.992 90.51 0 24.994 24.994 " + "24.994 65.516 0 90.51l-210.746 210.746h613.49c35.346 0 64 28.654 64 64s-28.654 64-64 64h-613.49l210.746 210.746c12.496 " + "12.496 18.744 28.876 18.744 45.254s-6.248 32.758-18.744 45.254c-24.994 24.994-65.516 24.994-90.51 0z", Color.WHITE);
arrow.setSize(20, 16);
backButton.setGraphic(arrow);
backButton.setRipplerFill(Color.WHITE);
}
use of com.jfoenix.svg.SVGGlyph in project JFoenix by jfoenixadmin.
the class ChipViewController method init.
@PostConstruct
public void init() throws Exception {
chipView.setChipFactory((emailJFXChipView, email) -> new JFXDefaultChip<MyShape>(emailJFXChipView, email) {
{
if (getItem().image != null) {
getItem().image.getStyleClass().add("chip-icon");
root.getChildren().add(0, getItem().image);
}
}
});
HashMap<String, MyShape> suggestions = new HashMap<>();
suggestions.put("Glass", new MyShape("Glass", SVGGlyphLoader.getIcoMoonGlyph("icomoon.svg.glass")));
suggestions.put("Star", new MyShape("Star", SVGGlyphLoader.getIcoMoonGlyph("icomoon.svg.star")));
suggestions.put("Music", new MyShape("Music", SVGGlyphLoader.getIcoMoonGlyph("icomoon.svg.music")));
final SVGGlyph icoMoonGlyph = SVGGlyphLoader.getIcoMoonGlyph("icomoon.svg.heart");
icoMoonGlyph.getStyleClass().add("heart");
suggestions.put("Heart", new MyShape("Heart", icoMoonGlyph));
suggestions.put("Film", new MyShape("Film", SVGGlyphLoader.getIcoMoonGlyph("icomoon.svg.film")));
chipView.setConverter(new StringConverter<MyShape>() {
@Override
public String toString(MyShape object) {
return object.toString();
}
@Override
public MyShape fromString(String string) {
MyShape found = suggestions.get(string);
return found == null ? new MyShape(string, null) : found;
}
});
chipView.getSuggestions().addAll(suggestions.values());
chipView.setSuggestionsCellFactory(param -> new JFXListCell<>());
JFXDepthManager.setDepth(chipView, 2);
}
use of com.jfoenix.svg.SVGGlyph in project JFoenix by jfoenixadmin.
the class MainDemo method start.
@Override
public void start(Stage stage) throws Exception {
new Thread(() -> {
try {
SVGGlyphLoader.loadGlyphsFont(MainDemo.class.getResourceAsStream("/fonts/icomoon.svg"), "icomoon.svg");
} catch (IOException ioExc) {
ioExc.printStackTrace();
}
}).start();
Flow flow = new Flow(MainController.class);
DefaultFlowContainer container = new DefaultFlowContainer();
flowContext = new ViewFlowContext();
flowContext.register("Stage", stage);
flow.createHandler(flowContext).start(container);
JFXDecorator decorator = new JFXDecorator(stage, container.getView());
decorator.setCustomMaximize(true);
decorator.setGraphic(new SVGGlyph(""));
stage.setTitle("JFoenix Demo");
double width = 800;
double height = 600;
try {
Rectangle2D bounds = Screen.getScreens().get(0).getBounds();
width = bounds.getWidth() / 2.5;
height = bounds.getHeight() / 1.35;
} catch (Exception e) {
}
Scene scene = new Scene(decorator, width, height);
final ObservableList<String> stylesheets = scene.getStylesheets();
stylesheets.addAll(JFoenixResources.load("css/jfoenix-fonts.css").toExternalForm(), JFoenixResources.load("css/jfoenix-design.css").toExternalForm(), MainDemo.class.getResource("/css/jfoenix-main-demo.css").toExternalForm());
stage.setScene(scene);
stage.show();
}
use of com.jfoenix.svg.SVGGlyph in project JFoenix by jfoenixadmin.
the class JFXListCell method updateItem.
/**
* {@inheritDoc}
*/
@Override
protected void updateItem(T item, boolean empty) {
super.updateItem(item, empty);
if (empty) {
setText(null);
setGraphic(null);
// remove empty (Trailing cells)
setMouseTransparent(true);
setStyle("-fx-background-color:TRANSPARENT;");
} else {
setMouseTransparent(false);
setStyle(null);
if (item instanceof Node) {
setText(null);
Node currentNode = getGraphic();
Node newNode = (Node) item;
if (currentNode == null || !currentNode.equals(newNode)) {
cellContent = newNode;
cellRippler.rippler.cacheRippleClip(false);
// RIPPLER ITEM : in case if the list item has its own rippler bind the list rippler and item rippler properties
if (newNode instanceof JFXRippler) {
// build cell container from exisiting rippler
cellRippler.ripplerFillProperty().bind(((JFXRippler) newNode).ripplerFillProperty());
cellRippler.maskTypeProperty().bind(((JFXRippler) newNode).maskTypeProperty());
cellRippler.positionProperty().bind(((JFXRippler) newNode).positionProperty());
cellContent = ((JFXRippler) newNode).getControl();
} else // SUBLIST ITEM : build the Cell node as sublist the sublist
if (newNode instanceof JFXListView<?>) {
// add the sublist to the parent and style the cell as sublist item
((JFXListView<?>) getListView()).addSublist((JFXListView<?>) newNode, this.getIndex());
this.getStyleClass().add("sublist-item");
if (this.getPadding() != null) {
this.setPadding(new Insets(this.getPadding().getTop(), 0, this.getPadding().getBottom(), 0));
}
// First build the group item used to expand / hide the sublist
StackPane groupNode = new StackPane();
groupNode.getStyleClass().add("sublist-header");
SVGGlyph dropIcon = new SVGGlyph(0, "ANGLE_RIGHT", "M340 548.571q0 7.429-5.714 13.143l-266.286 266.286q-5.714 5.714-13.143 5.714t-13.143-5.714l-28.571-28.571q-5.714-5.714-5.714-13.143t5.714-13.143l224.571-224.571-224.571-224.571q-5.714-5.714-5.714-13.143t5.714-13.143l28.571-28.571q5.714-5.714 13.143-5.714t13.143 5.714l266.286 266.286q5.714 5.714 5.714 13.143z", Color.BLACK);
dropIcon.setStyle("-fx-min-width:0.4em;-fx-max-width:0.4em;-fx-min-height:0.6em;-fx-max-height:0.6em;");
dropIcon.getStyleClass().add("drop-icon");
// alignment of the group node can be changed using the following css selector
// .jfx-list-view .sublist-header{ }
groupNode.getChildren().setAll(((JFXListView<?>) newNode).getGroupnode(), dropIcon);
// the margin is needed when rotating the angle
StackPane.setMargin(dropIcon, new Insets(0, 19, 0, 0));
StackPane.setAlignment(dropIcon, Pos.CENTER_RIGHT);
// Second build the sublist container
StackPane sublistContainer = new StackPane();
sublistContainer.setMinHeight(0);
sublistContainer.setMaxHeight(0);
sublistContainer.getChildren().setAll(newNode);
sublistContainer.setTranslateY(this.snappedBottomInset());
sublistContainer.setOpacity(0);
StackPane.setMargin(newNode, new Insets(-1, -1, 0, -1));
// Third, create container of group title and the sublist
VBox contentHolder = new VBox();
contentHolder.getChildren().setAll(groupNode, sublistContainer);
contentHolder.getStyleClass().add("sublist-container");
VBox.setVgrow(groupNode, Priority.ALWAYS);
cellContent = contentHolder;
cellRippler.ripplerPane.addEventHandler(MouseEvent.ANY, e -> e.consume());
contentHolder.addEventHandler(MouseEvent.ANY, e -> {
if (!e.isConsumed()) {
cellRippler.ripplerPane.fireEvent(e);
e.consume();
}
});
cellRippler.ripplerPane.addEventHandler(MouseEvent.MOUSE_CLICKED, e -> {
if (!e.isConsumed()) {
e.consume();
contentHolder.fireEvent(e);
}
});
// cache rippler clip in subnodes
cellRippler.rippler.cacheRippleClip(true);
this.setOnMouseClicked(e -> e.consume());
// Finally, add sublist animation
contentHolder.setOnMouseClicked((click) -> {
click.consume();
// stop the animation or change the list height
if (expandAnimation != null && expandAnimation.getStatus() == Status.RUNNING) {
expandAnimation.stop();
}
// invert the expand property
expandedProperty.set(!expandedProperty.get());
double newAnimatedHeight = newNode.prefHeight(-1) * (expandedProperty.get() ? 1 : -1);
double newHeight = expandedProperty.get() ? this.getHeight() + newAnimatedHeight : this.prefHeight(-1);
// animate showing/hiding the sublist
double contentHeight = expandedProperty.get() ? newAnimatedHeight : 0;
if (expandedProperty.get()) {
updateClipHeight(newHeight);
getListView().setPrefHeight(getListView().getHeight() + newAnimatedHeight + animatedHeight);
}
// update the animated height
animatedHeight = newAnimatedHeight;
int opacity = expandedProperty.get() ? 1 : 0;
expandAnimation = new Timeline(new KeyFrame(Duration.millis(320), new KeyValue(sublistContainer.minHeightProperty(), contentHeight, Interpolator.EASE_BOTH), new KeyValue(sublistContainer.maxHeightProperty(), contentHeight, Interpolator.EASE_BOTH), new KeyValue(sublistContainer.opacityProperty(), opacity, Interpolator.EASE_BOTH)));
if (!expandedProperty.get()) {
expandAnimation.setOnFinished((finish) -> {
updateClipHeight(newHeight);
getListView().setPrefHeight(getListView().getHeight() + newAnimatedHeight);
animatedHeight = 0;
});
}
expandAnimation.play();
});
// animate arrow
expandedProperty.addListener((o, oldVal, newVal) -> {
if (newVal) {
new Timeline(new KeyFrame(Duration.millis(160), new KeyValue(dropIcon.rotateProperty(), 90, Interpolator.EASE_BOTH))).play();
} else {
new Timeline(new KeyFrame(Duration.millis(160), new KeyValue(dropIcon.rotateProperty(), 0, Interpolator.EASE_BOTH))).play();
}
});
}
((Region) cellContent).setMaxHeight(cellContent.prefHeight(-1));
setGraphic(cellContent);
}
} else {
setText(item == null ? "null" : item.toString());
setGraphic(null);
}
boolean isJFXListView = getListView() instanceof JFXListView;
// show cell tooltip if its toggled in JFXListView
if (isJFXListView && ((JFXListView<?>) getListView()).isShowTooltip()) {
if (item instanceof Label) {
setTooltip(new Tooltip(((Label) item).getText()));
} else if (getText() != null) {
setTooltip(new Tooltip(getText()));
}
}
}
}
use of com.jfoenix.svg.SVGGlyph in project JFoenix by jfoenixadmin.
the class JFXDecorator method initializeButtons.
private void initializeButtons() {
SVGGlyph full = new SVGGlyph(0, "FULLSCREEN", "M598 214h212v212h-84v-128h-128v-84zM726 726v-128h84v212h-212v-84h128zM214 426v-212h212v84h-128v128h-84zM298 598v128h128v84h-212v-212h84z", Color.WHITE);
full.setSize(16, 16);
SVGGlyph minus = new SVGGlyph(0, "MINUS", "M804.571 420.571v109.714q0 22.857-16 38.857t-38.857 16h-694.857q-22.857 0-38.857-16t-16-38.857v-109.714q0-22.857 16-38.857t38.857-16h694.857q22.857 0 38.857 16t16 38.857z", Color.WHITE);
minus.setSize(12, 2);
minus.setTranslateY(4);
SVGGlyph resizeMax = new SVGGlyph(0, "RESIZE_MAX", "M726 810v-596h-428v596h428zM726 44q34 0 59 25t25 59v768q0 34-25 60t-59 26h-428q-34 0-59-26t-25-60v-768q0-34 25-60t59-26z", Color.WHITE);
resizeMax.setSize(12, 12);
SVGGlyph resizeMin = new SVGGlyph(0, "RESIZE_MIN", "M80.842 943.158v-377.264h565.894v377.264h-565.894zM0 404.21v619.79h727.578v-619.79h-727.578zM377.264 161.684h565.894v377.264h-134.736v80.842h215.578v-619.79h-727.578v323.37h80.842v-161.686z", Color.WHITE);
resizeMin.setSize(12, 12);
SVGGlyph close = new SVGGlyph(0, "CLOSE", "M810 274l-238 238 238 238-60 60-238-238-238 238-60-60 238-238-238-238 60-60 238 238 238-238z", Color.WHITE);
close.setSize(12, 12);
btnFull = new JFXButton();
btnFull.getStyleClass().add("jfx-decorator-button");
btnFull.setCursor(Cursor.HAND);
btnFull.setOnAction((action) -> primaryStage.setFullScreen(!primaryStage.isFullScreen()));
btnFull.setGraphic(full);
btnFull.setTranslateX(-30);
btnFull.setRipplerFill(Color.WHITE);
btnClose = new JFXButton();
btnClose.getStyleClass().add("jfx-decorator-button");
btnClose.setCursor(Cursor.HAND);
btnClose.setOnAction((action) -> onCloseButtonAction.get().run());
btnClose.setGraphic(close);
btnClose.setRipplerFill(Color.WHITE);
btnMin = new JFXButton();
btnMin.getStyleClass().add("jfx-decorator-button");
btnMin.setCursor(Cursor.HAND);
btnMin.setOnAction((action) -> primaryStage.setIconified(true));
btnMin.setGraphic(minus);
btnMin.setRipplerFill(Color.WHITE);
btnMax = new JFXButton();
btnMax.getStyleClass().add("jfx-decorator-button");
btnMax.setCursor(Cursor.HAND);
btnMax.setRipplerFill(Color.WHITE);
btnMax.setOnAction((action) -> maximize(resizeMin, resizeMax));
btnMax.setGraphic(resizeMax);
}
Aggregations