Search in sources :

Example 1 with FXCollections

use of javafx.collections.FXCollections in project Gargoyle by callakrsos.

the class ComponentClassifier method recursive.

/**
	 *
	 * @param node
	 * @return
	 */
List<Node> recursive(Node node) {
    List<Node> controls = new ArrayList<>();
    if (node == null) {
        return controls;
    }
    if (node instanceof Control) {
        Control c = (Control) node;
        DefaultProperty annotation = c.getClass().getAnnotation(DefaultProperty.class);
        if (annotation != null) {
            String value = annotation.value();
            try {
                Object invoke = getMethod(c, value + "Property");
                if (ReadOnlyProperty.class.isAssignableFrom(invoke.getClass())) {
                    ReadOnlyProperty prop = (ReadOnlyProperty) invoke;
                    Node bean2 = (Node) prop.getBean();
                    if (bean2 == null) {
                        return controls;
                    }
                    System.out.println("컨트롤 : " + bean2);
                    controls.add((Control) bean2);
                } else {
                    System.out.println("컨트롤 : " + c);
                    controls.add(c);
                }
            } catch (Exception e) {
                ObservableList<Node> childrenUnmodifiable = c.getChildrenUnmodifiable();
                ObservableList<Node> collect = childrenUnmodifiable.stream().flatMap(new Function<Node, Stream<Node>>() {

                    @Override
                    public Stream<Node> apply(Node t) {
                        return recursive(t).stream();
                    }
                }).collect(FXCollections::observableArrayList, (collections, item) -> collections.add(item), (collections, item) -> collections.addAll(item));
                controls.addAll(collect);
            }
        } else /*
			 * if (node instanceof ScrollPane || node instanceof TabPane) { //
			 * scrollpane, TabPane은 컨트롤요소에 추가하지않음. // controls.add(c);
			 * ObservableList<Control> recursive = recursive(((ScrollPane)
			 * node).getContent()); controls.addAll(recursive); }
			 */
        {
            controls.add(c);
            ObservableList<Node> childrenUnmodifiable = c.getChildrenUnmodifiable();
            ObservableList<Node> collect = childrenUnmodifiable.stream().flatMap(new Function<Node, Stream<Node>>() {

                @Override
                public Stream<Node> apply(Node t) {
                    return recursive(t).stream();
                }
            }).collect(FXCollections::observableArrayList, (collections, item) -> collections.add(item), (collections, item) -> collections.addAll(item));
            controls.addAll(collect);
        /* 개선 */
        // childrenUnmodifiable.forEach(n -> {
        // ObservableList<Node> recursive = recursive(n);
        // controls.addAll(recursive);
        // });
        }
        return controls;
    } else if (node instanceof Parent) {
        Parent p = (Parent) node;
        // ObservableList<Node> collect =
        // childrenUnmodifiable.stream().map(n->this).collect(FXCollections::observableArrayList,
        // (collections, item) -> collections.add(item), (collections, item)
        // -> collections.addAll(item));
        // controls.addAll(collect);
        ObservableList<Node> childrenUnmodifiable = p.getChildrenUnmodifiable();
        // childrenUnmodifiable.forEach(n -> {
        // ObservableList<Node> recursive = recursive(n);
        // controls.addAll(recursive);
        // });
        ObservableList<Node> collect = childrenUnmodifiable.stream().flatMap(new Function<Node, Stream<Node>>() {

            @Override
            public Stream<Node> apply(Node t) {
                return recursive(t).stream();
            }
        }).collect(FXCollections::observableArrayList, (collections, item) -> collections.add(item), (collections, item) -> collections.addAll(item));
        controls.addAll(collect);
    } else {
        System.err.println("her.! : " + node);
    }
    return controls;
}
Also used : Button(javafx.scene.control.Button) SystemLayoutViewController(com.kyj.fx.voeditor.visual.main.layout.SystemLayoutViewController) Scene(javafx.scene.Scene) TextArea(javafx.scene.control.TextArea) Control(javafx.scene.control.Control) FXCollections(javafx.collections.FXCollections) Skin(javafx.scene.control.Skin) Function(java.util.function.Function) ArrayList(java.util.ArrayList) Application(javafx.application.Application) Parent(javafx.scene.Parent) ScrollPane(javafx.scene.control.ScrollPane) FXMLLoader(javafx.fxml.FXMLLoader) ReadOnlyProperty(javafx.beans.property.ReadOnlyProperty) Method(java.lang.reflect.Method) HBox(javafx.scene.layout.HBox) Node(javafx.scene.Node) IOException(java.io.IOException) List(java.util.List) Stream(java.util.stream.Stream) Stage(javafx.stage.Stage) FxControlTreeView(com.kyj.fx.voeditor.visual.component.FxControlTreeView) DefaultProperty(javafx.beans.DefaultProperty) HTMLEditor(javafx.scene.web.HTMLEditor) ObservableList(javafx.collections.ObservableList) BorderPane(javafx.scene.layout.BorderPane) ReadOnlyProperty(javafx.beans.property.ReadOnlyProperty) Parent(javafx.scene.Parent) Node(javafx.scene.Node) ArrayList(java.util.ArrayList) FXCollections(javafx.collections.FXCollections) DefaultProperty(javafx.beans.DefaultProperty) IOException(java.io.IOException) Function(java.util.function.Function) Control(javafx.scene.control.Control) ObservableList(javafx.collections.ObservableList) Stream(java.util.stream.Stream)

Example 2 with FXCollections

use of javafx.collections.FXCollections in project FXyzLib by Birdasaur.

the class Text3DMesh method updateMesh.

protected final void updateMesh() {
    // 1. Full Text to get position of each letter
    Text3DHelper helper = new Text3DHelper(text3D.get(), font.get(), fontSize.get());
    offset = helper.getOffset();
    // 2. Create mesh for each LineSegment
    meshes = FXCollections.<TexturedMesh>observableArrayList();
    indLetters = new AtomicInteger();
    indSegments = new AtomicInteger();
    letterPath = new Path();
    text3D.get().chars().mapToObj(i -> (char) i).filter(c -> c != SPACE).forEach(letter -> createLetter(letter.toString()));
    getChildren().setAll(meshes);
    updateTransforms();
}
Also used : Path(javafx.scene.shape.Path) IntStream(java.util.stream.IntStream) Path(javafx.scene.shape.Path) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) FXCollections(javafx.collections.FXCollections) DoubleProperty(javafx.beans.property.DoubleProperty) Function(java.util.function.Function) IntegerProperty(javafx.beans.property.IntegerProperty) CullFace(javafx.scene.shape.CullFace) TriangleMesh(javafx.scene.shape.TriangleMesh) ArrayList(java.util.ArrayList) LineSegment(org.fxyz.shapes.primitives.helper.LineSegment) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty) ColorPalette(org.fxyz.utils.Palette.ColorPalette) Mesh(javafx.scene.shape.Mesh) Patterns(org.fxyz.utils.Patterns) Text3DHelper(org.fxyz.shapes.primitives.helper.Text3DHelper) Color(javafx.scene.paint.Color) Translate(javafx.scene.transform.Translate) TextureMode(org.fxyz.shapes.primitives.helper.TextureMode) Group(javafx.scene.Group) DrawMode(javafx.scene.shape.DrawMode) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) List(java.util.List) BooleanProperty(javafx.beans.property.BooleanProperty) Stream(java.util.stream.Stream) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) DepthTest(javafx.scene.DepthTest) MeshHelper(org.fxyz.shapes.primitives.helper.MeshHelper) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) ObservableList(javafx.collections.ObservableList) StringProperty(javafx.beans.property.StringProperty) Shape(javafx.scene.shape.Shape) Point3D(org.fxyz.geometry.Point3D) Bounds(javafx.geometry.Bounds) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Text3DHelper(org.fxyz.shapes.primitives.helper.Text3DHelper)

Aggregations

ArrayList (java.util.ArrayList)2 List (java.util.List)2 Function (java.util.function.Function)2 Stream (java.util.stream.Stream)2 FXCollections (javafx.collections.FXCollections)2 ObservableList (javafx.collections.ObservableList)2 FxControlTreeView (com.kyj.fx.voeditor.visual.component.FxControlTreeView)1 SystemLayoutViewController (com.kyj.fx.voeditor.visual.main.layout.SystemLayoutViewController)1 IOException (java.io.IOException)1 Method (java.lang.reflect.Method)1 Objects (java.util.Objects)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Collectors (java.util.stream.Collectors)1 IntStream (java.util.stream.IntStream)1 Application (javafx.application.Application)1 DefaultProperty (javafx.beans.DefaultProperty)1 BooleanProperty (javafx.beans.property.BooleanProperty)1 DoubleProperty (javafx.beans.property.DoubleProperty)1 IntegerProperty (javafx.beans.property.IntegerProperty)1 ReadOnlyProperty (javafx.beans.property.ReadOnlyProperty)1