本文整理汇总了Java中javafx.scene.shape.MoveTo.getY方法的典型用法代码示例。如果您正苦于以下问题:Java MoveTo.getY方法的具体用法?Java MoveTo.getY怎么用?Java MoveTo.getY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.shape.MoveTo
的用法示例。
在下文中一共展示了MoveTo.getY方法的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);
}
示例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());
}
示例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());
}
示例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);
}
示例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;
}
示例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;
}
示例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() );
}