Java Code Examples for javafx.geometry.Pos#CENTER_LEFT

The following examples show how to use javafx.geometry.Pos#CENTER_LEFT . 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: VSkin.java    From Medusa with Apache License 2.0 6 votes vote down vote up
private void drawGradientBar() {
    TickLabelLocation  tickLabelLocation     = gauge.getTickLabelLocation();
    double             scaledHeight          = height * 0.9;
    double             xy                    = TickLabelLocation.OUTSIDE == tickLabelLocation ? 0.1705 * scaledHeight : 0.107 * scaledHeight;
    double             wh                    = TickLabelLocation.OUTSIDE == tickLabelLocation ? scaledHeight * 0.77 : scaledHeight * 0.897;
    double             offset                = 90 - startAngle;
    double             offsetX               = -0.1 * width;
    double             knobPositionOffsetCW  = Pos.CENTER_LEFT == gauge.getKnobPosition() ? 90 : 270;
    double             knobPositionOffsetCCW = Pos.CENTER_LEFT == gauge.getKnobPosition() ? 180 : 0;
    ScaleDirection     scaleDirection        = gauge.getScaleDirection();
    List<Stop>         stops                 = gauge.getGradientBarStops();
    Map<Double, Color> stopAngleMap          = new HashMap<>(stops.size());
    for (Stop stop : stops) { stopAngleMap.put(stop.getOffset() * angleRange, stop.getColor()); }
    double               offsetFactor = ScaleDirection.CLOCKWISE == scaleDirection ? knobPositionOffsetCW - angleRange * 0.5 : angleRange - (angleRange / 180 * angleRange) + knobPositionOffsetCCW;
    AngleConicalGradient gradient     = new AngleConicalGradient(width * 0.5, width * 0.5, offsetFactor, stopAngleMap, gauge.getScaleDirection());

    double barStartAngle  = ScaleDirection.CLOCKWISE == scaleDirection ? -minValue * angleStep : minValue * angleStep;
    double barAngleExtend = ScaleDirection.CLOCKWISE == scaleDirection ? gauge.getRange() * angleStep : -gauge.getRange() * angleStep;
    tickMarkCtx.save();
    tickMarkCtx.setStroke(gradient.getImagePattern(new Rectangle(xy - 0.026 * height + offsetX, xy - 0.026 * height, wh + 0.052 * height, wh + 0.052 * height)));
    tickMarkCtx.setLineWidth(scaledHeight * 0.052);
    tickMarkCtx.setLineCap(StrokeLineCap.BUTT);
    tickMarkCtx.strokeArc(xy + offsetX, xy, wh, wh, -(offset + barStartAngle), -barAngleExtend, ArcType.OPEN);
    tickMarkCtx.restore();
}
 
Example 3
Source File: DotHTMLLabelJavaFxNode.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
private Pos getAlignPosForAttributeNameAndTag(String attributeName,
		HtmlTag tag) {
	HtmlAttr attr = DotHtmlLabelHelper.getAttributeForTag(tag,
			attributeName);
	if (attr == null) {
		return null;
	}
	switch (unquotedValueForAttr(attr).toLowerCase()) {
	case "right": //$NON-NLS-1$
		return Pos.CENTER_RIGHT;
	case "left": //$NON-NLS-1$
		return Pos.CENTER_LEFT;
	case "center": //$NON-NLS-1$
	default:
		return Pos.CENTER;
	}
}
 
Example 4
Source File: DotRecordBasedJavaFxNode.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Used to initialize this text line with the first line of a record
 * based label
 *
 * @param lines
 *            label of which this object should represent the first line
 * @return remaining string with the first line removed
 */
public String consumeFirstLineOf(String lines) {
	int indexLast = 0;
	do {
		try {
			final int indexNew = lines.indexOf('\\', indexLast);
			if (indexNew < 0)
				throw new IndexOutOfBoundsException();
			switch (lines.charAt(indexNew + 1)) {
			case 'n':
				pos = Pos.CENTER;
				break;
			case 'l':
				pos = Pos.CENTER_LEFT;
				break;
			case 'r':
				pos = Pos.CENTER_RIGHT;
				break;
			default:
				indexLast = indexNew + 1;
				continue;
			}
			line = lines.substring(0, indexNew);
			if (lines.length() > indexNew + 2)
				return lines.substring(indexNew + 2);
			break;
		} catch (IndexOutOfBoundsException e) {
			line = lines;
			break;
		}
	} while (indexLast >= 0);
	return null;
}
 
Example 5
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 6
Source File: JFXTreeTableCellSkin.java    From JFoenix with Apache License 2.0 5 votes vote down vote up
@Override
protected void layoutChildren(double x, double y, double w, double h) {
    updateDisclosureNode();
    double disclosureWidth = 0;
    Node disclosureNode = ((JFXTreeTableCell<S, T>) getSkinnable()).getDisclosureNode();
    if (disclosureNode.isVisible()) {
        Pos alignment = getSkinnable().getAlignment();
        alignment = alignment == null ? Pos.CENTER_LEFT : alignment;
        layoutInArea(disclosureNode, x + 8, y, w, h, 0, Insets.EMPTY, false, false, HPos.LEFT, VPos.CENTER);
        disclosureWidth = disclosureNode.getLayoutBounds().getWidth() + 18;
    }
    super.layoutChildren(x + disclosureWidth, y, w - disclosureWidth, h);
}
 
Example 7
Source File: VSkin.java    From Medusa with Apache License 2.0 4 votes vote down vote up
private void drawAverage() {
    double scaledHeight = height * 0.9;
    double centerX      = Pos.CENTER_LEFT == gauge.getKnobPosition() ? width * 0.1 : width * 0.9;
    double centerY      = height * 0.5;
    // 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 * scaledHeight);
    double sinValue      = Math.sin(Math.toRadians(averageAngle));
    double cosValue      = Math.cos(Math.toRadians(averageAngle));
    switch (tickLabelLocation) {
        case OUTSIDE:
            average.getElements().add(new MoveTo(centerX + scaledHeight * 0.38 * sinValue, centerY + scaledHeight * 0.38 * cosValue));
            sinValue = Math.sin(Math.toRadians(averageAngle - averageSize));
            cosValue = Math.cos(Math.toRadians(averageAngle - averageSize));
            average.getElements().add(new LineTo(centerX + scaledHeight * 0.34 * sinValue, centerY + scaledHeight * 0.34 * cosValue));
            sinValue = Math.sin(Math.toRadians(averageAngle + averageSize));
            cosValue = Math.cos(Math.toRadians(averageAngle + averageSize));
            average.getElements().add(new LineTo(centerX + scaledHeight * 0.34 * sinValue, centerY + scaledHeight * 0.34 * cosValue));
            average.getElements().add(new ClosePath());
            break;
        case INSIDE:
        default:
            average.getElements().add(new MoveTo(centerX + scaledHeight * 0.465 * sinValue, centerY + scaledHeight * 0.465 * cosValue));
            sinValue = Math.sin(Math.toRadians(averageAngle - averageSize));
            cosValue = Math.cos(Math.toRadians(averageAngle - averageSize));
            average.getElements().add(new LineTo(centerX + scaledHeight * 0.425 * sinValue, centerY + scaledHeight * 0.425 * cosValue));
            sinValue = Math.sin(Math.toRadians(averageAngle + averageSize));
            cosValue = Math.cos(Math.toRadians(averageAngle + averageSize));
            average.getElements().add(new LineTo(centerX + scaledHeight * 0.425 * sinValue, centerY + scaledHeight * 0.425 * cosValue));
            average.getElements().add(new ClosePath());
            break;
    }
    average.setFill(gauge.getAverageColor());
    average.setStroke(gauge.getTickMarkColor());
}
 
Example 8
Source File: StringFormatSwitch.java    From helloiot with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Pos alignment() {
    return Pos.CENTER_LEFT;
}
 
Example 9
Source File: StringFormatJSONPretty.java    From helloiot with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Pos alignment() {
    return Pos.CENTER_LEFT;
}
 
Example 10
Source File: StringFormatBase64.java    From helloiot with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Pos alignment() {
    return Pos.CENTER_LEFT;
}
 
Example 11
Source File: StringFormatHex.java    From helloiot with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Pos alignment() {
    return Pos.CENTER_LEFT;
}
 
Example 12
Source File: StringFormatIdentity.java    From helloiot with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Pos alignment() {
    return Pos.CENTER_LEFT;
}
 
Example 13
Source File: Callout.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
protected Animation buildSubTitleAnim(HBox mainTitle, HBox subTitle) {

        // Small rectangle (prompt)
        // Calculate main title width and height upfront
        Rectangle2D mainTitleBounds = getBoundsUpfront(mainTitle);

        double mainTitleWidth = mainTitleBounds.getWidth();
        double mainTitleHeight = mainTitleBounds.getHeight();

        Pos textPos = (LEFT == getEndLeaderLineDirection()) ? Pos.CENTER_LEFT : Pos.CENTER_RIGHT;
        subTitle.setAlignment(textPos);

        Rectangle2D subTitleBounds = getBoundsUpfront(subTitle);

        double subTitleTextWidth = subTitleBounds.getWidth();
        double subTitleTextHeight = subTitleBounds.getHeight();

        Point2D endPointLL = calcEndPointOfLeaderLine();
        int direction = getEndLeaderLineDirection();
        double x = endPointLL.getX() + (5 * direction);
        double y = endPointLL.getY();
        subTitle.setLayoutX( x );
        subTitle.setLayoutY( y + (mainTitleHeight/2) + 4);

        Rectangle subTitleViewPort = new Rectangle();
        subTitleViewPort.setWidth(0);
        subTitleViewPort.setHeight(subTitleTextHeight);
        subTitle.setClip(subTitleViewPort);

        // Animate subtitle from end point to the left.
        if (LEFT == getEndLeaderLineDirection()) {
            return new Timeline(
                    new KeyFrame(Duration.millis(1),
                            new KeyValue(subTitle.visibleProperty(), true),
                            new KeyValue(subTitle.layoutXProperty(), x)), // show
                    new KeyFrame(Duration.millis(200),

                            new KeyValue(subTitle.layoutXProperty(), x - subTitleTextWidth),
                            new KeyValue(subTitleViewPort.widthProperty(), subTitleTextWidth))
            );
        }

        // Animate subtitle from end point to the right.
        return new Timeline(
                new KeyFrame(Duration.millis(1),
                        new KeyValue(subTitle.visibleProperty(), true)), // show
                new KeyFrame(Duration.millis(200),
                        new KeyValue(subTitleViewPort.widthProperty(), subTitleTextWidth))
        );
    }