本文整理匯總了Java中javafx.scene.shape.LineTo.getY方法的典型用法代碼示例。如果您正苦於以下問題:Java LineTo.getY方法的具體用法?Java LineTo.getY怎麽用?Java LineTo.getY使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.shape.LineTo
的用法示例。
在下文中一共展示了LineTo.getY方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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);
}
示例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());
}
示例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());
}
示例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);
}
示例5: layoutPlotChildren
import javafx.scene.shape.LineTo; //導入方法依賴的package包/類
/** @inheritDoc */
@Override
protected void layoutPlotChildren() {
List<LineTo> constructedPath = new ArrayList<>(getDataSize());
for (int seriesIndex = 0; seriesIndex < getDataSize(); seriesIndex++) {
MultiAxisChart.Series<X, Y> series = getData().get(seriesIndex);
DoubleProperty seriesYAnimMultiplier = seriesYMultiplierMap.get(series);
double lastX = 0;
final ObservableList<Node> children = ((Group) series.getNode()).getChildren();
ObservableList<PathElement> seriesLine = ((Path) children.get(1)).getElements();
ObservableList<PathElement> fillPath = ((Path) children.get(0)).getElements();
seriesLine.clear();
fillPath.clear();
constructedPath.clear();
for (Iterator<Data<X, Y>> it = getDisplayedDataIterator(series); it.hasNext();) {
Data<X, Y> item = it.next();
double x = getXAxis().getDisplayPosition(item.getCurrentX());
double y = -1;
if (item.getExtraValue() == null || (int) item.getExtraValue() == MultiAxisChart.Y1_AXIS) {
y = getY1Axis().getDisplayPosition(getY1Axis().toRealValue(
getY1Axis().toNumericValue(item.getCurrentY()) * seriesYAnimMultiplier.getValue()));
} else {
if (getY2Axis() != null) {
if (getY2Axis().isVisible()) {
y = getY2Axis().getDisplayPosition(getY2Axis().toRealValue(
getY2Axis().toNumericValue(item.getCurrentY()) * seriesYAnimMultiplier.getValue()));
} else {
continue;
}
} else {
throw new NullPointerException("Y2 axis is not defined.");
}
}
constructedPath.add(new LineTo(x, y));
if (Double.isNaN(x) || Double.isNaN(y)) {
continue;
}
lastX = x;
Node symbol = item.getNode();
if (symbol != null) {
final double w = symbol.prefWidth(-1);
final double h = symbol.prefHeight(-1);
symbol.resizeRelocate(x - (w / 2), y - (h / 2), w, h);
}
}
if (!constructedPath.isEmpty()) {
Collections.sort(constructedPath, (e1, e2) -> Double.compare(e1.getX(), e2.getX()));
LineTo first = constructedPath.get(0);
final double displayYPos = first.getY();
final double numericYPos = getY1Axis().toNumericValue(getY1Axis().getValueForDisplay(displayYPos));
// RT-34626: We can't always use getZeroPosition(), as it may be the case
// that the zero position of the y-axis is not visible on the chart. In these
// cases, we need to use the height between the point and the y-axis line.
final double yAxisZeroPos = getY1Axis().getZeroPosition();
final boolean isYAxisZeroPosVisible = !Double.isNaN(yAxisZeroPos);
final double yAxisHeight = getY1Axis().getHeight();
final double yFillPos = isYAxisZeroPosVisible ? yAxisZeroPos
: numericYPos < 0 ? numericYPos - yAxisHeight : yAxisHeight;
seriesLine.add(new MoveTo(first.getX(), displayYPos));
fillPath.add(new MoveTo(first.getX(), yFillPos));
seriesLine.addAll(constructedPath);
fillPath.addAll(constructedPath);
fillPath.add(new LineTo(lastX, yFillPos));
fillPath.add(new ClosePath());
}
}
}
示例6: 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;
}
示例7: 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() );
}