Java Code Examples for javafx.geometry.Pos#TOP_CENTER

The following examples show how to use javafx.geometry.Pos#TOP_CENTER . 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: DisplayPositionSelector.java    From Quelea with GNU General Public License v3.0 6 votes vote down vote up
public static Pos getPosFromIndex(int index) {
    switch (index) {
        case -1:
            return Pos.CENTER;
        case 0:
            return Pos.TOP_LEFT;
        case 1:
            return Pos.TOP_CENTER;
        case 2:
            return Pos.TOP_RIGHT;
        case 3:
            return Pos.CENTER_LEFT;
        case 4:
            return Pos.CENTER;
        case 5:
            return Pos.CENTER_RIGHT;
        case 6:
            return Pos.BOTTOM_LEFT;
        case 7:
            return Pos.BOTTOM_CENTER;
        case 8:
            return Pos.BOTTOM_RIGHT;
        default:
            return Pos.CENTER;
    }
}
 
Example 2
Source File: DotHTMLLabelJavaFxNode.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
private Pos posForTd(String hAlign, String vAlign) {
	switch (hAlign != null ? hAlign.toLowerCase() : "") { //$NON-NLS-1$
	case "left": //$NON-NLS-1$
		switch (vAlign != null ? vAlign.toLowerCase() : "") { //$NON-NLS-1$
		case "top": //$NON-NLS-1$
			return Pos.TOP_LEFT;
		case "bottom": //$NON-NLS-1$
			return Pos.BOTTOM_LEFT;
		case "middle": //$NON-NLS-1$
		default:
			return Pos.CENTER_LEFT;
		}
	case "right": //$NON-NLS-1$
		switch (vAlign != null ? vAlign.toLowerCase() : "") { //$NON-NLS-1$
		case "top": //$NON-NLS-1$
			return Pos.TOP_RIGHT;
		case "bottom": //$NON-NLS-1$
			return Pos.BOTTOM_RIGHT;
		case "middle": //$NON-NLS-1$
		default:
			return Pos.CENTER_RIGHT;
		}
	case "center": //$NON-NLS-1$
	case "text": //$NON-NLS-1$
	default:
		switch (vAlign != null ? vAlign.toLowerCase() : "") { //$NON-NLS-1$
		case "top": //$NON-NLS-1$
			return Pos.TOP_CENTER;
		case "bottom": //$NON-NLS-1$
			return Pos.BOTTOM_CENTER;
		case "middle": //$NON-NLS-1$
		default:
			return Pos.CENTER;
		}
	}
}
 
Example 3
Source File: BorderSlideBar.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a sidebar panel in a BorderPane, containing an horizontal alignment
 * of the given nodes.
 *
 * <pre>
 * <code>
 *  Example:
 *
 *  BorderSlideBar topFlapBar = new BorderSlideBar(
 *                  100, button, Pos.TOP_LEFT, new contentController());
 *  mainBorderPane.setTop(topFlapBar);
 * </code>
 * </pre>
 *
 * @param expandedSize The size of the panel.
 * @param controlButton The button responsible to open/close slide bar.
 * @param location The location of the panel (TOP_LEFT, BOTTOM_LEFT, BASELINE_RIGHT, BASELINE_LEFT).
 * @param nodes Nodes inside the panel.
 */
public BorderSlideBar(double expandedSize,
        final Button controlButton, Pos location, Node... nodes) {

    getStyleClass().add("sidebar");
    getStylesheets().add(CSS);        
    setExpandedSize(expandedSize);
    setVisible(false);

    // Set location 
    if (location == null) {
        flapbarLocation = Pos.TOP_CENTER; // Set default location 
    }
    flapbarLocation = location;
    
    initPosition();        

    // Add nodes in the vbox
    getChildren().addAll(nodes);

    controlButton.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent actionEvent) {
        	slide();
        }
    });
}
 
Example 4
Source File: HSkin.java    From Medusa with Apache License 2.0 4 votes vote down vote up
private void drawAverage() {
    double scaledWidth = width * 0.9;
    double centerX     = width * 0.5;
    double centerY     = Pos.TOP_CENTER == gauge.getKnobPosition() ? height * 0.1 : height * 0.9;
    // Draw average
    average.getElements().clear();
    double averageAngle;
    if (ScaleDirection.CLOCKWISE == scaleDirection) {
        averageAngle = startAngle - (gauge.getAverage() - minValue) * angleStep;
    } else {
        averageAngle = startAngle + (gauge.getAverage() - minValue) * angleStep;
    }
    double averageSize = Helper.clamp(3.0, 3.5, 0.01 * scaledWidth);
    double sinValue      = Math.sin(Math.toRadians(averageAngle));
    double cosValue      = Math.cos(Math.toRadians(averageAngle));
    switch (tickLabelLocation) {
        case OUTSIDE:
            average.getElements().add(new MoveTo(centerX + scaledWidth * 0.38 * sinValue, centerY + scaledWidth * 0.38 * cosValue));
            sinValue = Math.sin(Math.toRadians(averageAngle - averageSize));
            cosValue = Math.cos(Math.toRadians(averageAngle - averageSize));
            average.getElements().add(new LineTo(centerX + scaledWidth * 0.34 * sinValue, centerY + scaledWidth * 0.34 * cosValue));
            sinValue = Math.sin(Math.toRadians(averageAngle + averageSize));
            cosValue = Math.cos(Math.toRadians(averageAngle + averageSize));
            average.getElements().add(new LineTo(centerX + scaledWidth * 0.34 * sinValue, centerY + scaledWidth * 0.34 * cosValue));
            average.getElements().add(new ClosePath());
            break;
        case INSIDE:
        default:
            average.getElements().add(new MoveTo(centerX + scaledWidth * 0.465 * sinValue, centerY + scaledWidth * 0.465 * cosValue));
            sinValue = Math.sin(Math.toRadians(averageAngle - averageSize));
            cosValue = Math.cos(Math.toRadians(averageAngle - averageSize));
            average.getElements().add(new LineTo(centerX + scaledWidth * 0.425 * sinValue, centerY + scaledWidth * 0.425 * cosValue));
            sinValue = Math.sin(Math.toRadians(averageAngle + averageSize));
            cosValue = Math.cos(Math.toRadians(averageAngle + averageSize));
            average.getElements().add(new LineTo(centerX + scaledWidth * 0.425 * sinValue, centerY + scaledWidth * 0.425 * cosValue));
            average.getElements().add(new ClosePath());
            break;
    }
    average.setFill(gauge.getAverageColor());
    average.setStroke(gauge.getTickMarkColor());
}
 
Example 5
Source File: JFXNodesList.java    From JFoenix with Apache License 2.0 4 votes vote down vote up
@Override
protected void layoutChildren() {
    performingLayout = true;

    List<Node> children = getChildren();

    Insets insets = getInsets();
    double width = getWidth();
    double rotate = getRotate();
    double height = getHeight();
    double left = snapSpace(insets.getLeft());
    double right = snapSpace(insets.getRight());
    double space = snapSpace(getSpacing());
    boolean isFillWidth = isFillWidth();
    double contentWidth = width - left - right;


    Pos alignment = getAlignment();
    alignment = alignment == null ? Pos.TOP_CENTER : alignment;
    final HPos hpos = alignment.getHpos();
    final VPos vpos = alignment.getVpos();

    double y = 0;

    for (int i = 0, size = children.size(); i < size; i++) {
        Node child = children.get(i);
        child.autosize();
        child.setRotate(rotate % 180 == 0 ? rotate : -rotate);

        // init child node if not added using addAnimatedChild method
        if (!animationsMap.containsKey(child)) {
            if (child instanceof JFXNodesList) {
                StackPane container = new StackPane(child);
                container.setPickOnBounds(false);
                getChildren().set(i, container);
            }
            initChild(child, i, null, true);
        }

        double x = 0;
        double childWidth = child.getLayoutBounds().getWidth();
        double childHeight = child.getLayoutBounds().getHeight();


        if(childWidth > width){
            switch (hpos) {
                case CENTER:
                    x = snapPosition(contentWidth - childWidth) / 2;
                    break;
            }
            Node alignToChild = getAlignNodeToChild(child);
            if (alignToChild != null && child instanceof Parent) {
                ((Parent) child).layout();
                double alignedWidth = alignToChild.getLayoutBounds().getWidth();
                double alignedX = alignToChild.getLayoutX();
                if(childWidth / 2 > alignedX + alignedWidth){
                    alignedWidth = -(childWidth / 2 - (alignedWidth/2 + alignedX));
                }else{
                    alignedWidth = alignedWidth/2 + alignedX - childWidth / 2;
                }
                child.setTranslateX(-alignedWidth * Math.cos(Math.toRadians(rotate)));
                child.setTranslateY(alignedWidth * Math.cos(Math.toRadians(90 - rotate)));
            }
        }else{
            childWidth = contentWidth;
        }

        final Insets margin = getMargin(child);
        if (margin != null) {
            childWidth += margin.getLeft() + margin.getRight();
            childHeight += margin.getTop() + margin.getRight();
        }

        layoutInArea(child, x, y, childWidth, childHeight,
            /* baseline shouldn't matter */0,
            margin, isFillWidth, true, hpos, vpos);

        y += child.getLayoutBounds().getHeight() + space;
        if (margin != null) {
            y += margin.getTop() + margin.getBottom();
        }
        y = snapPosition(y);
    }

    performingLayout = false;
}