Java Code Examples for javafx.scene.Parent#layout()

The following examples show how to use javafx.scene.Parent#layout() . 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: BaseController.java    From MyBox with Apache License 2.0 5 votes vote down vote up
public void refreshCurrentStyle() {
    if (getMyScene() == null) {
        return;
    }
    Parent root = myScene.getRoot();
    root.applyCss();
    root.layout();
}
 
Example 2
Source File: FxmlControl.java    From MyBox with Apache License 2.0 4 votes vote down vote up
public static void refreshStyle(Parent node) {
    node.applyCss();
    node.layout();
    applyStyle(node);
}
 
Example 3
Source File: MainViewController.java    From examples-javafx-repos1 with Apache License 2.0 4 votes vote down vote up
private void applySecurity(Scene s, UserSecurity security, Node n) {

        if( n == null ) return;

        if( n.getProperties().containsKey(NodePropertiesKeyType.commandType) ) {

            //
            // This is a Node that should have security applied
            //
            CommandType command = (CommandType) n.getProperties().get(NodePropertiesKeyType.commandType );
            AccessType access = security.getAccess(command);

            if( log.isDebugEnabled() ) {
                log.debug("[APPLY] command={}, access={}", command, access);
            }

            switch( security.getAccess(command) ) {

                case SHOW:
                    n.setVisible(true);
                    n.setDisable(false);
                    n.setManaged(true);
                    break;
                case HIDE:
                    n.setVisible(false);
                    n.setDisable(true);
                    n.setManaged(false);
                    break;
                case DISABLE:
                    n.setVisible(true);
                    n.setDisable(true);
                    n.setManaged(true);
                    break;
            }
        }

        //
        // Menus and MenuItems are not Nodes
        //
        if( n instanceof MenuBar ) {
            MenuBar mb = (MenuBar)n;
            for( Menu toplevel : mb.getMenus() ) {
                applySecurity( s, security, toplevel );
            }
        }

        if( n instanceof Parent) {
            Parent p = (Parent)n;
            for( Node childNode : p.getChildrenUnmodifiable() ) {
                applySecurity( s, security, childNode );
            }
            p.layout();
        }
    }
 
Example 4
Source File: FXTestUtils.java    From graph-editor with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Forces an update of the {@link Parent}'s layout.
 *
 * @param parent the {@link Parent} whose layout should be updated
 */
public static void forceLayoutUpdate(final Parent parent) {
    parent.autosize();
    parent.snapshot(null, null);
    parent.layout();
}
 
Example 5
Source File: JointCleaner.java    From graph-editor with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Adds handlers to remove all joints that are on top of each other after a mouse-released gesture.
 *
 * @param jointSkins the connection's joint skins
 */
public void addCleaningHandlers(final List<GJointSkin> jointSkins) {

    final Map<GJoint, EventHandler<MouseEvent>> oldCleaningHandlers = new HashMap<>(cleaningHandlers);

    cleaningHandlers.clear();

    for (final GJointSkin jointSkin : jointSkins) {

        final GJoint joint = jointSkin.getJoint();
        final Region jointRegion = jointSkin.getRoot();
        final EventHandler<MouseEvent> oldHandler = oldCleaningHandlers.get(joint);

        if (oldHandler != null) {
            jointRegion.removeEventHandler(MouseEvent.MOUSE_RELEASED, oldHandler);
        }

        final EventHandler<MouseEvent> newHandler = event -> {

            final Parent parent = jointRegion.getParent();

            if (jointSkins.size() == 2 || !event.getButton().equals(MouseButton.PRIMARY)) {
                return;
            }

            final List<Point2D> jointPositions = GeometryUtils.getJointPositions(jointSkins);
            final Set<Integer> jointsToCleanUp = findJointsToCleanUp(jointPositions);

            if (!jointsToCleanUp.isEmpty()) {

                final EditingDomain editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(connection);
                final CompoundCommand command = new CompoundCommand();

                final GModel model = graphEditor.getModel();
                final SkinLookup skinLookup = graphEditor.getSkinLookup();

                JointCommands.removeJoints(command, jointsToCleanUp, connection);
                Commands.updateLayoutValues(command, model, skinLookup);

                if (command.canExecute()) {
                    editingDomain.getCommandStack().execute(command);
                }
            }

            parent.layout();
        };

        jointRegion.addEventHandler(MouseEvent.MOUSE_RELEASED, newHandler);
        cleaningHandlers.put(joint, newHandler);
    }
}