use of javafx.scene.shape.MoveTo in project FXyzLib by Birdasaur.
the class Text3DHelper method generatePath.
private Path generatePath() {
Path path = new Path(new MoveTo(list.get(0).x, list.get(0).y));
list.stream().skip(1).forEach(p -> path.getElements().add(new LineTo(p.x, p.y)));
path.getElements().add(new ClosePath());
path.setStroke(Color.GREEN);
// Path must be filled to allow Shape.intersect
path.setFill(Color.RED);
return path;
}
use of javafx.scene.shape.MoveTo in project FXyzLib by Birdasaur.
the class Text3DHelper method getPoints.
private void getPoints(PathElement elem) {
if (elem instanceof MoveTo) {
list = new ArrayList<>();
p0 = new Point3D((float) ((MoveTo) elem).getX(), (float) ((MoveTo) elem).getY(), 0f);
list.add(p0);
} else if (elem instanceof LineTo) {
list.add(new Point3D((float) ((LineTo) elem).getX(), (float) ((LineTo) elem).getY(), 0f));
} else if (elem instanceof CubicCurveTo) {
Point3D ini = (list.size() > 0 ? list.get(list.size() - 1) : p0);
IntStream.rangeClosed(1, POINTS_CURVE).forEach(i -> list.add(evalCubicBezier((CubicCurveTo) elem, ini, ((double) i) / POINTS_CURVE)));
} else if (elem instanceof QuadCurveTo) {
Point3D ini = (list.size() > 0 ? list.get(list.size() - 1) : p0);
IntStream.rangeClosed(1, POINTS_CURVE).forEach(i -> list.add(evalQuadBezier((QuadCurveTo) elem, ini, ((double) i) / POINTS_CURVE)));
} else if (elem instanceof ClosePath) {
list.add(p0);
// stored in a LineSegment: a continuous line that can change direction
if (Math.abs(getArea()) > 0.001) {
LineSegment line = new LineSegment(text);
line.setHole(isHole());
line.setPoints(list);
line.setPath(generatePath());
line.setOrigen(p0);
polis.add(line);
}
}
}
use of javafx.scene.shape.MoveTo in project fxexperience2 by EricCanull.
the class SplineEditor method layoutPlotChildren.
@Override
protected void layoutPlotChildren() {
double cp1x = getXAxis().getDisplayPosition(controlPoint1x.get());
double cp1y = getYAxis().getDisplayPosition(controlPoint1y.get());
double cp2x = getXAxis().getDisplayPosition(controlPoint2x.get());
double cp2y = getYAxis().getDisplayPosition(controlPoint2y.get());
double minx = getXAxis().getZeroPosition();
double miny = getYAxis().getZeroPosition();
double maxx = getXAxis().getDisplayPosition(1);
double maxy = getYAxis().getDisplayPosition(1);
controlPoint1Circle.setLayoutX(cp1x);
controlPoint1Circle.setLayoutY(cp1y);
controlPoint2Circle.setLayoutX(cp2x);
controlPoint2Circle.setLayoutY(cp2y);
cp1Line.setStartX(minx);
cp1Line.setStartY(miny);
cp1Line.setEndX(cp1x);
cp1Line.setEndY(cp1y);
cp2Line.setStartX(maxx);
cp2Line.setStartY(maxy);
cp2Line.setEndX(cp2x);
cp2Line.setEndY(cp2y);
dottedLinesPath.getElements().setAll(new MoveTo(minx - 0.5, cp1y - 0.5), new LineTo(cp1x - 0.5, cp1y - 0.5), new LineTo(cp1x - 0.5, miny - 0.5), new MoveTo(minx - 0.5, cp2y - 0.5), new LineTo(cp2x - 0.5, cp2y - 0.5), new LineTo(cp2x - 0.5, miny - 0.5));
splinePath.getElements().setAll(new MoveTo(minx, miny), new CubicCurveTo(cp1x, cp1y, cp2x, cp2y, maxx, maxy));
}
use of javafx.scene.shape.MoveTo in project bitsquare by bitsquare.
the class CandleStickChart method layoutPlotChildren.
// -------------- METHODS ------------------------------------------------------------------------------------------
/**
* Called to update and layout the content for the plot
*/
@Override
protected void layoutPlotChildren() {
// we have nothing to layout if no data is present
if (getData() == null) {
return;
}
// update candle positions
for (int seriesIndex = 0; seriesIndex < getData().size(); seriesIndex++) {
XYChart.Series<Number, Number> series = getData().get(seriesIndex);
Iterator<XYChart.Data<Number, Number>> iter = getDisplayedDataIterator(series);
Path seriesPath = null;
if (series.getNode() instanceof Path) {
seriesPath = (Path) series.getNode();
seriesPath.getElements().clear();
}
while (iter.hasNext()) {
XYChart.Data<Number, Number> item = iter.next();
double x = getXAxis().getDisplayPosition(getCurrentDisplayedXValue(item));
double y = getYAxis().getDisplayPosition(getCurrentDisplayedYValue(item));
Node itemNode = item.getNode();
CandleData candleData = (CandleData) item.getExtraValue();
if (itemNode instanceof Candle && candleData != null) {
Candle candle = (Candle) itemNode;
double close = getYAxis().getDisplayPosition(candleData.close);
double high = getYAxis().getDisplayPosition(candleData.high);
double low = getYAxis().getDisplayPosition(candleData.low);
// calculate candle width
double candleWidth = -1;
if (getXAxis() instanceof NumberAxis) {
NumberAxis xa = (NumberAxis) getXAxis();
// use 90% width between ticks
candleWidth = xa.getDisplayPosition(xa.getTickUnit()) * 0.90;
}
// update candle
candle.update(close - y, high - y, low - y, candleWidth);
candle.updateTooltip(candleData);
// position the candle
candle.setLayoutX(x);
candle.setLayoutY(y);
}
if (seriesPath != null && candleData != null) {
final double displayPosition = getYAxis().getDisplayPosition(candleData.average);
if (seriesPath.getElements().isEmpty())
seriesPath.getElements().add(new MoveTo(x, displayPosition));
else
seriesPath.getElements().add(new LineTo(x, displayPosition));
}
}
}
}
Aggregations