Search in sources :

Example 66 with Rectangle

use of javafx.scene.shape.Rectangle in project FXyzLib by Birdasaur.

the class CubeWorld method buildPanels.

private void buildPanels(double size) {
    // @SMP TODO might be easier to just replace the Rectangle side panels with really flat Box 3D objects
    x1AxisRectangle = new Rectangle(size, size, panelWallColor);
    x2AxisRectangle = new Rectangle(size, size, panelWallColor);
    y1AxisRectangle = new Rectangle(size, size, panelWallColor);
    y2AxisRectangle = new Rectangle(size, size, panelWallColor);
    z1AxisRectangle = new Rectangle(size, size, panelFloorColor);
    z2AxisRectangle = new Rectangle(size, size, panelCeilingColor);
    x1AxisRectangle.setTranslateX(-size / 2);
    x1AxisRectangle.setTranslateY(-size / 2);
    x1AxisRectangle.setTranslateZ(-size / 2);
    x2AxisRectangle.setTranslateX(-size / 2);
    x2AxisRectangle.setTranslateY(-size / 2);
    x2AxisRectangle.setTranslateZ(size / 2);
    getChildren().addAll(x1AxisRectangle, x2AxisRectangle);
    y2AxisRectangle.setTranslateY(-size / 2);
    y2AxisRectangle.setRotationAxis(Rotate.Y_AXIS);
    y2AxisRectangle.setRotate(89.9);
    y1AxisRectangle.setTranslateX(-size);
    y1AxisRectangle.setTranslateY(-size / 2);
    y1AxisRectangle.setRotationAxis(Rotate.Y_AXIS);
    y1AxisRectangle.setRotate(89.9);
    getChildren().addAll(y1AxisRectangle, y2AxisRectangle);
    z1AxisRectangle.setTranslateX(-size / 2);
    z1AxisRectangle.setRotationAxis(Rotate.X_AXIS);
    z1AxisRectangle.setRotate(89.9);
    z2AxisRectangle.setTranslateX(-size / 2);
    z2AxisRectangle.setTranslateY(-size);
    z2AxisRectangle.setRotationAxis(Rotate.X_AXIS);
    z2AxisRectangle.setRotate(89.9);
    getChildren().addAll(z1AxisRectangle, z2AxisRectangle);
}
Also used : Rectangle(javafx.scene.shape.Rectangle)

Example 67 with Rectangle

use of javafx.scene.shape.Rectangle in project FXyzLib by Birdasaur.

the class CubeViewer method buildPanels.

private void buildPanels(double size) {
    // @SMP TODO might be easier to just replace the Rectangle side panels with really flat Box 3D objects
    x1AxisRectangle = new Rectangle(size, size, x1AxisRectangleColor);
    x2AxisRectangle = new Rectangle(size, size, x2AxisRectangleColor);
    y1AxisRectangle = new Rectangle(size, size, y1AxisRectangleColor);
    y2AxisRectangle = new Rectangle(size, size, y2AxisRectangleColor);
    z1AxisRectangle = new Rectangle(size, size, z1AxisRectangleColor);
    z2AxisRectangle = new Rectangle(size, size, z2AxisRectangleColor);
    x1AxisRectangle.setTranslateX(-size / 2);
    x1AxisRectangle.setTranslateY(-size / 2);
    x1AxisRectangle.setTranslateZ(-size / 2);
    x2AxisRectangle.setTranslateX(-size / 2);
    x2AxisRectangle.setTranslateY(-size / 2);
    x2AxisRectangle.setTranslateZ(size / 2);
    getChildren().addAll(x1AxisRectangle, x2AxisRectangle);
    y2AxisRectangle.setTranslateY(-size / 2);
    y2AxisRectangle.setRotationAxis(Rotate.Y_AXIS);
    y2AxisRectangle.setRotate(89.9);
    y1AxisRectangle.setTranslateX(-size);
    y1AxisRectangle.setTranslateY(-size / 2);
    y1AxisRectangle.setRotationAxis(Rotate.Y_AXIS);
    y1AxisRectangle.setRotate(89.9);
    getChildren().addAll(y1AxisRectangle, y2AxisRectangle);
    z1AxisRectangle.setTranslateX(-size / 2);
    z1AxisRectangle.setRotationAxis(Rotate.X_AXIS);
    z1AxisRectangle.setRotate(89.9);
    z2AxisRectangle.setTranslateX(-size / 2);
    z2AxisRectangle.setTranslateY(-size);
    z2AxisRectangle.setRotationAxis(Rotate.X_AXIS);
    z2AxisRectangle.setRotate(89.9);
    getChildren().addAll(z1AxisRectangle, z2AxisRectangle);
}
Also used : Rectangle(javafx.scene.shape.Rectangle)

Example 68 with Rectangle

use of javafx.scene.shape.Rectangle in project FXyzLib by Birdasaur.

the class Patterns method createPattern.

public Image createPattern(CarbonPatterns cp, boolean save) {
    ImagePattern pattern;
    switch(cp) {
        case DARK_CARBON:
            pattern = createCarbonPattern();
            break;
        case LIGHT_CARBON:
            pattern = createLightCarbonPattern();
            break;
        case CARBON_KEVLAR:
            pattern = createCarbonKevlarPattern();
            break;
        default:
            pattern = createCarbonPattern();
            break;
    }
    Rectangle rectangle = new Rectangle(width, height);
    if (pattern != null) {
        rectangle.setFill(pattern);
    }
    rectangle.setStrokeWidth(0);
    imgPattern = rectangle.snapshot(new SnapshotParameters(), null);
    if (save) {
        saveImage();
    }
    return imgPattern;
}
Also used : SnapshotParameters(javafx.scene.SnapshotParameters) ImagePattern(javafx.scene.paint.ImagePattern) Rectangle(javafx.scene.shape.Rectangle)

Example 69 with Rectangle

use of javafx.scene.shape.Rectangle in project JFoenix by jfoenixadmin.

the class JFXTabPaneSkin method addTabContentHolder.

private void addTabContentHolder(Tab tab) {
    // create new content place holder
    TabContentHolder tabContentHolder = new TabContentHolder(tab);
    tabContentHolder.setClip(new Rectangle());
    tabContentHolders.add(tabContentHolder);
    // always add tab content holder below its header
    tabsContainer.getChildren().add(0, tabContentHolder);
}
Also used : Rectangle(javafx.scene.shape.Rectangle)

Example 70 with Rectangle

use of javafx.scene.shape.Rectangle in project JFoenix by jfoenixadmin.

the class JFXTabPaneSkin method layoutChildren.

@Override
protected void layoutChildren(final double x, final double y, final double w, final double h) {
    final double headerHeight = snapSize(header.prefHeight(-1));
    final Side side = getSkinnable().getSide();
    double tabsX = side == Side.RIGHT ? x + w - headerHeight : x;
    double tabsY = side == Side.BOTTOM ? y + h - headerHeight : y;
    final int rotation = getRotation(side);
    // update header
    switch(side) {
        case TOP:
            header.resize(w, headerHeight);
            header.relocate(tabsX, tabsY);
            break;
        case LEFT:
            header.resize(h, headerHeight);
            header.relocate(tabsX + headerHeight, h - headerHeight);
            break;
        case RIGHT:
            header.resize(h, headerHeight);
            header.relocate(tabsX, y - headerHeight);
            break;
        case BOTTOM:
            header.resize(w, headerHeight);
            header.relocate(w, tabsY - headerHeight);
            break;
    }
    header.getTransforms().setAll(new Rotate(rotation, 0, headerHeight, 1));
    // update header clip
    // header.clip.setX(0);
    // header.clip.setY(0);
    // header.clip.setWidth(isHorizontal() ? w : h);
    // header.clip.setHeight(headerHeight + 10); // 10 is the height of the shadow effect
    // position the tab content of the current selected tab
    double contentStartX = x + (side == Side.LEFT ? headerHeight : 0);
    double contentStartY = y + (side == Side.TOP ? headerHeight : 0);
    double contentWidth = w - (isHorizontal() ? 0 : headerHeight);
    double contentHeight = h - (isHorizontal() ? headerHeight : 0);
    // update tabs container
    tabsClip.setWidth(contentWidth);
    tabsClip.setHeight(contentHeight);
    tabsContainerHolder.resize(contentWidth, contentHeight);
    tabsContainerHolder.relocate(contentStartX, contentStartY);
    tabsContainer.resize(contentWidth * tabContentHolders.size(), contentHeight);
    for (int i = 0, max = tabContentHolders.size(); i < max; i++) {
        TabContentHolder tabContentHolder = tabContentHolders.get(i);
        tabContentHolder.setVisible(true);
        tabContentHolder.setTranslateX(contentWidth * i);
        if (tabContentHolder.getClip() != null) {
            ((Rectangle) tabContentHolder.getClip()).setWidth(contentWidth);
            ((Rectangle) tabContentHolder.getClip()).setHeight(contentHeight);
        }
        if (tabContentHolder.tab == selectedTab) {
            int index = getSkinnable().getTabs().indexOf(selectedTab);
            if (index != i) {
                tabsContainer.setTranslateX(-contentWidth * i);
                diffTabsIndices = i - index;
            } else {
                // fix X translation after changing the tabs
                if (diffTabsIndices != 0) {
                    tabsContainer.setTranslateX(tabsContainer.getTranslateX() + contentWidth * diffTabsIndices);
                    diffTabsIndices = 0;
                }
                // animate upon tab selection only otherwise just translate the selected tab
                if (isSelectingTab && !((JFXTabPane) getSkinnable()).isDisableAnimation()) {
                    new CachedTransition(tabsContainer, new Timeline(new KeyFrame(Duration.millis(1000), new KeyValue(tabsContainer.translateXProperty(), -contentWidth * index, Interpolator.EASE_BOTH)))) {

                        {
                            setCycleDuration(Duration.seconds(0.320));
                            setDelay(Duration.seconds(0));
                        }
                    }.play();
                } else {
                    tabsContainer.setTranslateX(-contentWidth * index);
                }
            }
        }
        tabContentHolder.resize(contentWidth, contentHeight);
    // tabContentHolder.relocate(contentStartX, contentStartY);
    }
}
Also used : Rotate(javafx.scene.transform.Rotate) JFXTabPane(com.jfoenix.controls.JFXTabPane) Rectangle(javafx.scene.shape.Rectangle) CachedTransition(com.jfoenix.transitions.CachedTransition)

Aggregations

Rectangle (javafx.scene.shape.Rectangle)190 Point2D (javafx.geometry.Point2D)33 Text (javafx.scene.text.Text)28 Entity (com.almasb.fxgl.entity.Entity)27 Circle (javafx.scene.shape.Circle)20 Color (javafx.scene.paint.Color)18 HitBox (com.almasb.fxgl.physics.HitBox)16 Pane (javafx.scene.layout.Pane)16 Group (javafx.scene.Group)15 Node (javafx.scene.Node)14 PhysicsComponent (com.almasb.fxgl.physics.PhysicsComponent)12 Scene (javafx.scene.Scene)12 EntityView (com.almasb.fxgl.entity.view.EntityView)10 Label (javafx.scene.control.Label)10 List (java.util.List)8 Collectors (java.util.stream.Collectors)8 TextFlow (javafx.scene.text.TextFlow)8 CollidableComponent (com.almasb.fxgl.entity.component.CollidableComponent)7 Bounds (javafx.geometry.Bounds)7 KeyCode (javafx.scene.input.KeyCode)7