当前位置: 首页>>代码示例>>Java>>正文


Java MoveTo.getX方法代码示例

本文整理汇总了Java中javafx.scene.shape.MoveTo.getX方法的典型用法代码示例。如果您正苦于以下问题:Java MoveTo.getX方法的具体用法?Java MoveTo.getX怎么用?Java MoveTo.getX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.shape.MoveTo的用法示例。


在下文中一共展示了MoveTo.getX方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getBounds

import javafx.scene.shape.MoveTo; //导入方法依赖的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.MoveTo; //导入方法依赖的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.MoveTo; //导入方法依赖的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.MoveTo; //导入方法依赖的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: getCaretShape

import javafx.scene.shape.MoveTo; //导入方法依赖的package包/类
public PathElement[] getCaretShape(int index, boolean leading)
{
	PathElement[] pe = FxHacks.get().getCaretShape(this, index, leading);
	
	// empty line generates a simple dot shape which is not what we need
	if(pe.length == 2)
	{
		PathElement p0 = pe[0];
		PathElement p1 = pe[1];
		if((p0 instanceof MoveTo) && (p1 instanceof LineTo))
		{
			MoveTo m0 = (MoveTo)p0;
			LineTo m1 = (LineTo)p1;
			
			// close enough?
			if(Math.abs(m0.getY() - m1.getY()) < 0.01)
			{
				double x = m0.getX();
				double y = m0.getY();
				
				// little hack: using the text flow height
				pe[1] = new LineTo(x, y + getHeight());
			}
		}
	}
	return pe;
}
 
开发者ID:andy-goryachev,项目名称:FxEditor,代码行数:28,代码来源:CTextFlow.java

示例6: interpolate

import javafx.scene.shape.MoveTo; //导入方法依赖的package包/类
@Override public MoveTo interpolate(MoveTo endValue, double t) {
    MoveTo rv = new MoveTo(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

示例7: smooth

import javafx.scene.shape.MoveTo; //导入方法依赖的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.MoveTo.getX方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。