當前位置: 首頁>>代碼示例>>Java>>正文


Java LineTo.getX方法代碼示例

本文整理匯總了Java中javafx.scene.shape.LineTo.getX方法的典型用法代碼示例。如果您正苦於以下問題:Java LineTo.getX方法的具體用法?Java LineTo.getX怎麽用?Java LineTo.getX使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javafx.scene.shape.LineTo的用法示例。


在下文中一共展示了LineTo.getX方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getBounds

import javafx.scene.shape.LineTo; //導入方法依賴的package包/類
protected Rectangle2D getBounds(int start, int end) {
	PathElement[] shape = getShape(start, end);
	double minX = 0, minY = 0, maxX = 0, maxY = 0;
	for (PathElement pathElement : shape) {
		if (pathElement instanceof MoveTo) {
			MoveTo moveTo = (MoveTo) pathElement;
			minX = maxX = moveTo.getX();
			minY = maxY = moveTo.getY();
		} else if (pathElement instanceof LineTo) {
			LineTo lineTo = (LineTo) pathElement;
			double x = lineTo.getX();
			double y = lineTo.getY();
			minX = Math.min(minX, x);
			minY = Math.min(minY, y);
			maxX = Math.max(maxX, x);
			maxY = Math.max(maxY, y);
		}
	}
	return new Rectangle2D(minX, minY, maxX - minX, maxY - minY);
}
 
開發者ID:JFormDesigner,項目名稱:markdown-writer-fx,代碼行數:21,代碼來源:ParagraphOverlayGraphicFactory.java

示例2: smooth

import javafx.scene.shape.LineTo; //導入方法依賴的package包/類
private void smooth(ObservableList<PathElement> strokeElements, ObservableList<PathElement> fillElements, final double HEIGHT) {
    if (fillElements.isEmpty()) return;
    // as we do not have direct access to the data, first recreate the list of all the data points we have
    final Point2D[] dataPoints = new Point2D[strokeElements.size()];
    for (int i = 0; i < strokeElements.size(); i++) {
        final PathElement element = strokeElements.get(i);
        if (element instanceof MoveTo) {
            final MoveTo move = (MoveTo) element;
            dataPoints[i] = new Point2D(move.getX(), move.getY());
        } else if (element instanceof LineTo) {
            final LineTo line = (LineTo) element;
            final double x = line.getX(), y = line.getY();
            dataPoints[i] = new Point2D(x, y);
        }
    }
    double firstX = dataPoints[0].getX();
    double lastX  = dataPoints[dataPoints.length - 1].getX();

    Point2D[] points = Helper.subdividePoints(dataPoints, getSubDivisions());

    fillElements.clear();
    fillElements.add(new MoveTo(firstX, HEIGHT));

    strokeElements.clear();
    strokeElements.add(new MoveTo(points[0].getX(), points[0].getY()));

    for (Point2D p : points) {
        if (Double.compare(p.getX(), firstX) >= 0) {
            fillElements.add(new LineTo(p.getX(), p.getY()));
            strokeElements.add(new LineTo(p.getX(), p.getY()));
        }
    }

    fillElements.add(new LineTo(lastX, HEIGHT));
    fillElements.add(new LineTo(0, HEIGHT));
    fillElements.add(new ClosePath());
}
 
開發者ID:HanSolo,項目名稱:smoothcharts,代碼行數:38,代碼來源:SmoothedChart.java

示例3: smooth

import javafx.scene.shape.LineTo; //導入方法依賴的package包/類
private void smooth(ObservableList<PathElement> strokeElements, ObservableList<PathElement> fillElements, final double HEIGHT) {
    if (fillElements.isEmpty()) return;
    // as we do not have direct access to the data, first recreate the list of all the data points we have
    final Point[] dataPoints = new Point[strokeElements.size()];
    for (int i = 0; i < strokeElements.size(); i++) {
        final PathElement element = strokeElements.get(i);
        if (element instanceof MoveTo) {
            final MoveTo move = (MoveTo) element;
            dataPoints[i] = new Point(move.getX(), move.getY());
        } else if (element instanceof LineTo) {
            final LineTo line = (LineTo) element;
            final double x = line.getX(), y = line.getY();
            dataPoints[i] = new Point(x, y);
        }
    }
    double firstX = dataPoints[0].getX();
    double lastX  = dataPoints[dataPoints.length - 1].getX();

    Point[] points = Helper.subdividePoints(dataPoints, getSubDivisions());

    fillElements.clear();
    fillElements.add(new MoveTo(firstX, HEIGHT));

    strokeElements.clear();
    strokeElements.add(new MoveTo(points[0].getX(), points[0].getY()));

    for (Point p : points) {
        if (Double.compare(p.getX(), firstX) >= 0) {
            fillElements.add(new LineTo(p.getX(), p.getY()));
            strokeElements.add(new LineTo(p.getX(), p.getY()));
        }
    }

    fillElements.add(new LineTo(lastX, HEIGHT));
    fillElements.add(new LineTo(0, HEIGHT));
    fillElements.add(new ClosePath());
}
 
開發者ID:HanSolo,項目名稱:tilesfx,代碼行數:38,代碼來源:SmoothedChart.java

示例4: smoothPath

import javafx.scene.shape.LineTo; //導入方法依賴的package包/類
public static final Path smoothPath(final ObservableList<PathElement> ELEMENTS, final boolean FILLED) {
    if (ELEMENTS.isEmpty()) { return new Path(); }
    final Point[] dataPoints = new Point[ELEMENTS.size()];
    for (int i = 0; i < ELEMENTS.size(); i++) {
        final PathElement element = ELEMENTS.get(i);
        if (element instanceof MoveTo) {
            MoveTo move   = (MoveTo) element;
            dataPoints[i] = new Point(move.getX(), move.getY());
        } else if (element instanceof LineTo) {
            LineTo line   = (LineTo) element;
            dataPoints[i] = new Point(line.getX(), line.getY());
        }
    }
    double                 zeroY               = ((MoveTo) ELEMENTS.get(0)).getY();
    List<PathElement>      smoothedElements    = new ArrayList<>();
    Pair<Point[], Point[]> result              = calcCurveControlPoints(dataPoints);
    Point[]                firstControlPoints  = result.getKey();
    Point[]                secondControlPoints = result.getValue();
    // Start path dependent on filled or not
    if (FILLED) {
        smoothedElements.add(new MoveTo(dataPoints[0].getX(), zeroY));
        smoothedElements.add(new LineTo(dataPoints[0].getX(), dataPoints[0].getY()));
    } else {
        smoothedElements.add(new MoveTo(dataPoints[0].getX(), dataPoints[0].getY()));
    }
    // Add curves
    for (int i = 2; i < dataPoints.length; i++) {
        final int ci = i - 1;
        smoothedElements.add(new CubicCurveTo(
            firstControlPoints[ci].getX(), firstControlPoints[ci].getY(),
            secondControlPoints[ci].getX(), secondControlPoints[ci].getY(),
            dataPoints[i].getX(), dataPoints[i].getY()));
    }
    // Close the path if filled
    if (FILLED) {
        smoothedElements.add(new LineTo(dataPoints[dataPoints.length - 1].getX(), zeroY));
        smoothedElements.add(new ClosePath());
    }
    return new Path(smoothedElements);
}
 
開發者ID:HanSolo,項目名稱:tilesfx,代碼行數:41,代碼來源:Helper.java

示例5: interpolate

import javafx.scene.shape.LineTo; //導入方法依賴的package包/類
@Override public LineTo interpolate(LineTo endValue, double t) {
    LineTo rv = new LineTo(this.source.getX() + (endValue.getX() - this.source.getX()) * t,
                           this.source.getY() + (endValue.getY() - this.source.getY()) * t);
    rv.setAbsolute(this.source.isAbsolute());
    return rv;
}
 
開發者ID:HanSolo,項目名稱:bpmgauge,代碼行數:7,代碼來源:PathMorphTransition.java

示例6: smooth

import javafx.scene.shape.LineTo; //導入方法依賴的package包/類
private static void smooth( ObservableList<PathElement> strokeElements,
		ObservableList<PathElement> fillElements )
{
	// as we do not have direct access to the data, first recreate the list
	// of all the data points we have
	final Point2D[] dataPoints = new Point2D[ strokeElements.size() ];
	for ( int i = 0; i < strokeElements.size(); i++ )
	{
		final PathElement element = strokeElements.get( i );
		if ( element instanceof MoveTo )
		{
			final MoveTo move = (MoveTo) element;
			dataPoints[ i ] = new Point2D( move.getX(), move.getY() );
		} else if ( element instanceof LineTo )
		{
			final LineTo line = (LineTo) element;
			final double x = line.getX(), y = line.getY();
			dataPoints[ i ] = new Point2D( x, y );
		}
	}
	// next we need to know the zero Y value
	final double zeroY = ( (MoveTo) fillElements.get( 0 ) ).getY();
	// now clear and rebuild elements
	strokeElements.clear();
	fillElements.clear();
	Pair<Point2D[], Point2D[]> result = calcCurveControlPoints(
			dataPoints );
	Point2D[] firstControlPoints = result.getKey();
	Point2D[] secondControlPoints = result.getValue();
	// start both paths
	strokeElements.add(
			new MoveTo( dataPoints[ 0 ].getX(), dataPoints[ 0 ].getY() ) );
	fillElements.add( new MoveTo( dataPoints[ 0 ].getX(), zeroY ) );
	fillElements.add(
			new LineTo( dataPoints[ 0 ].getX(), dataPoints[ 0 ].getY() ) );
	// add curves
	for ( int i = 1; i < dataPoints.length; i++ )
	{
		final int ci = i - 1;
		strokeElements
				.add( new CubicCurveTo( firstControlPoints[ ci ].getX(),
						firstControlPoints[ ci ].getY(),
						secondControlPoints[ ci ].getX(),
						secondControlPoints[ ci ].getY(),
						dataPoints[ i ].getX(), dataPoints[ i ].getY() ) );
		fillElements.add( new CubicCurveTo( firstControlPoints[ ci ].getX(),
				firstControlPoints[ ci ].getY(),
				secondControlPoints[ ci ].getX(),
				secondControlPoints[ ci ].getY(), dataPoints[ i ].getX(),
				dataPoints[ i ].getY() ) );
	}
	// end the paths
	fillElements.add( new LineTo(
			dataPoints[ dataPoints.length - 1 ].getX(), zeroY ) );
	fillElements.add( new ClosePath() );
}
 
開發者ID:DSheirer,項目名稱:sdrtrunk,代碼行數:57,代碼來源:CurveFittedAreaChart.java


注:本文中的javafx.scene.shape.LineTo.getX方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。