use of javafx.scene.shape.CubicCurveTo in project latexdraw by arnobl.
the class TestViewShape method duplicatePath.
protected static List<PathElement> duplicatePath(final List<PathElement> path) {
return path.stream().map(elt -> {
PathElement dupelt;
if (elt instanceof MoveTo) {
final MoveTo moveTo = (MoveTo) elt;
dupelt = ViewFactory.INSTANCE.createMoveTo(moveTo.getX(), moveTo.getY());
} else if (elt instanceof LineTo) {
final LineTo lineTo = (LineTo) elt;
dupelt = ViewFactory.INSTANCE.createLineTo(lineTo.getX(), lineTo.getY());
} else if (elt instanceof ClosePath) {
dupelt = ViewFactory.INSTANCE.createClosePath();
} else if (elt instanceof CubicCurveTo) {
final CubicCurveTo cct = (CubicCurveTo) elt;
dupelt = ViewFactory.INSTANCE.createCubicCurveTo(cct.getControlX1(), cct.getControlY1(), cct.getControlX2(), cct.getControlY2(), cct.getX(), cct.getY());
} else {
throw new IllegalArgumentException();
}
dupelt.setAbsolute(elt.isAbsolute());
return dupelt;
}).collect(Collectors.toList());
}
use of javafx.scene.shape.CubicCurveTo 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.CubicCurveTo in project latexdraw by arnobl.
the class ViewArrowableTraitPath method clipPath.
@Override
protected void clipPath(final Path path) {
final Path clip = ViewFactory.INSTANCE.clonePath(path);
clip.setFill(path.getFill());
clip.setStrokeWidth(path.getStrokeWidth());
if (!clip.getElements().isEmpty()) {
// Defensive programming
final Optional<IPoint> pt1 = getArrowReducedPoint(arrows.get(0).arrow);
final Optional<IPoint> pt2 = getArrowReducedPoint(arrows.get(arrows.size() - 1).arrow);
if (pt1.isPresent() && clip.getElements().get(0) instanceof MoveTo) {
// Defensive programming
// Changing the first point to the one at the beginning of the arrow.
final MoveTo moveTo = (MoveTo) clip.getElements().get(0);
moveTo.setX(pt1.get().getX());
moveTo.setY(pt1.get().getY());
}
pt2.ifPresent(pt -> {
if (clip.getElements().get(clip.getElements().size() - 1) instanceof LineTo) {
final LineTo lineTo = (LineTo) clip.getElements().get(clip.getElements().size() - 1);
lineTo.setX(pt.getX());
lineTo.setY(pt.getY());
} else if (clip.getElements().get(clip.getElements().size() - 1) instanceof CubicCurveTo) {
final CubicCurveTo ccTo = (CubicCurveTo) clip.getElements().get(clip.getElements().size() - 1);
ccTo.setX(pt.getX());
ccTo.setY(pt.getY());
}
});
}
clip.setStrokeWidth(path.getStrokeWidth());
clip.setStrokeLineCap(path.getStrokeLineCap());
path.setClip(clip);
}
use of javafx.scene.shape.CubicCurveTo in project latexdraw by arnobl.
the class ViewBezierCurve method addCurveTo.
private CubicCurveTo addCurveTo(final IPoint pt, final IPoint ctrl1, final IPoint ctrl2) {
final CubicCurveTo curveto = ViewFactory.INSTANCE.createCubicCurveTo(0d, 0d, 0d, 0d, 0d, 0d);
curveto.xProperty().bind(pt.xProperty());
curveto.yProperty().bind(pt.yProperty());
curveto.controlX1Property().bind(ctrl1.xProperty());
curveto.controlY1Property().bind(ctrl1.yProperty());
curveto.controlX2Property().bind(ctrl2.xProperty());
curveto.controlY2Property().bind(ctrl2.yProperty());
border.getElements().add(curveto);
return curveto;
}
use of javafx.scene.shape.CubicCurveTo in project Board-Instrumentation-Framework by intel.
the class SimpleGaugeSkin method resize.
private void resize() {
size = getSkinnable().getWidth() < getSkinnable().getHeight() ? getSkinnable().getWidth() : getSkinnable().getHeight();
if (size > 0) {
pane.setMaxSize(size, size);
pane.relocate((getSkinnable().getWidth() - size) * 0.5, (getSkinnable().getHeight() - size) * 0.5);
sectionsCanvas.setWidth(size);
sectionsCanvas.setHeight(size);
drawSections();
sectionsCanvas.setCache(true);
sectionsCanvas.setCacheHint(CacheHint.QUALITY);
measuredRangeCanvas.setWidth(size);
measuredRangeCanvas.setHeight(size);
drawMeasuredRange();
double currentValue = (needleRotate.getAngle() + getSkinnable().getStartAngle() - 180) / angleStep + getSkinnable().getMinValue();
value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", currentValue) + getSkinnable().getUnit());
value.setVisible(getSkinnable().isValueVisible());
title.setText(getSkinnable().getTitle());
title.setVisible(getSkinnable().isTitleVisible());
needle.getElements().clear();
needle.getElements().add(new MoveTo(0.275 * size, 0.5 * size));
needle.getElements().add(new CubicCurveTo(0.275 * size, 0.62426575 * size, 0.37573425 * size, 0.725 * size, 0.5 * size, 0.725 * size));
needle.getElements().add(new CubicCurveTo(0.62426575 * size, 0.725 * size, 0.725 * size, 0.62426575 * size, 0.725 * size, 0.5 * size));
needle.getElements().add(new CubicCurveTo(0.725 * size, 0.3891265 * size, 0.6448105 * size, 0.296985 * size, 0.5392625 * size, 0.2784125 * size));
needle.getElements().add(new LineTo(0.5 * size, 0.0225 * size));
needle.getElements().add(new LineTo(0.4607375 * size, 0.2784125 * size));
needle.getElements().add(new CubicCurveTo(0.3551895 * size, 0.296985 * size, 0.275 * size, 0.3891265 * size, 0.275 * size, 0.5 * size));
needle.getElements().add(new ClosePath());
needle.setStrokeWidth(size * 0.025);
needle.relocate(needle.getLayoutBounds().getMinX(), needle.getLayoutBounds().getMinY());
needleRotate.setPivotX(size * 0.5);
needleRotate.setPivotY(size * 0.5);
resizeText();
}
}
Aggregations