use of javafx.scene.shape.Shape in project latexdraw by arnobl.
the class Hand method bindDnDTranslate.
/**
* A DnD on a shape view allows to translate the underlying shape.
*/
private void bindDnDTranslate() {
nodeBinder(TranslateShapes.class, new DnD(true, true)).on(canvas.getViews().getChildren()).on(canvas.getSelectionBorder()).map(i -> new TranslateShapes(canvas.getDrawing(), canvas.getDrawing().getSelection().duplicateDeep(false))).then((c, i) -> {
final IPoint startPt = grid.getTransformedPointToGrid(i.getSrcScenePoint());
final IPoint endPt = grid.getTransformedPointToGrid(i.getEndScenePt());
c.setT(endPt.getX() - startPt.getX(), endPt.getY() - startPt.getY());
}).when(i -> i.getButton() == MouseButton.PRIMARY && !canvas.getDrawing().getSelection().isEmpty()).exec().first((c, i) -> {
i.getSrcObject().ifPresent(node -> Platform.runLater(() -> node.requestFocus()));
canvas.setCursor(Cursor.MOVE);
}).cancel((c, i) -> canvas.update()).strictStart().bind();
}
use of javafx.scene.shape.Shape in project latexdraw by arnobl.
the class TestViewGrid method testChangeLabelsColour.
@Test
public void testChangeLabelsColour() {
final Paint strokeBefore = ((Shape) view.getLabels().getChildren().get(0)).getStroke();
model.setGridLabelsColour(DviPsColors.CARNATIONPINK);
WaitForAsyncUtils.waitForFxEvents();
assertNotEquals(strokeBefore, ((Shape) view.getLabels().getChildren().get(0)).getStroke());
}
use of javafx.scene.shape.Shape in project blue by kunstmusik.
the class KnobSkin method initComponents.
private void initComponents(double w) {
getChildren().clear();
double width = snapSize(w);
double radius = width / 2;
double innerRadius = snapSize(radius * 0.5);
final Color trackColor = getSkinnable().getTrackColor();
Ellipse outer = new Ellipse(radius, radius, radius, radius);
Ellipse inner = new Ellipse(radius, radius, innerRadius, innerRadius);
Shape shape = Path.subtract(outer, inner);
Rectangle rect = new Rectangle(radius, radius);
Shape trackBG = Path.subtract(shape, rect);
trackBG.setRotate(-135.0);
trackBG.setStroke(getSkinnable().getTrackBackgroundColor());
trackBG.setStrokeType(StrokeType.INSIDE);
trackBG.setFill(getSkinnable().getTrackBackgroundColor().darker());
Arc mask = new Arc(radius, radius, radius + 2, radius + 2, -270, -270);
mask.setType(ArcType.ROUND);
mask.lengthProperty().bind(percent.multiply(-ARC_LENGTH));
track = Path.subtract(shape, rect);
track.setRotate(-135.0);
track.setStroke(trackColor);
track.setStrokeType(StrokeType.INSIDE);
track.setFill(trackColor.deriveColor(1.0, 1.0, 1.0, 0.5));
track.setClip(mask);
track.setEffect(new Glow(1.0));
Canvas c = new Canvas(width, width);
GraphicsContext gc = c.getGraphicsContext2D();
gc.setStroke(trackColor.brighter().brighter().brighter());
gc.setLineWidth(2.0);
gc.strokeLine(radius, 0, radius, radius - innerRadius - 1);
gc.setFill(Color.BLACK);
gc.fillOval(width * 0.25, width * 0.25, width * 0.5, width * 0.5);
gc.setFill(trackColor);
double notchWidth = width / 10.0;
double notchAdj = notchWidth / 2.0;
gc.fillRoundRect(radius - notchAdj, (width * .25) - notchAdj, notchWidth, (width * .25) + notchWidth, notchWidth, notchWidth);
gc.setStroke(Color.BLACK);
gc.strokeRoundRect(radius - notchAdj, (width * .25) - notchAdj, notchWidth, (width * .25) + notchWidth, notchWidth, notchWidth);
c.rotateProperty().bind(percent.multiply(ARC_LENGTH).subtract(135.0));
getChildren().addAll(trackBG, track, c);
}
use of javafx.scene.shape.Shape in project contentment by GeePawHill.
the class Frames method frame.
public static Style frame(Paint stroke, Paint fill, Double width, Double opacity, Dash dash) {
StyleApplier applier = new StyleApplier() {
@Override
public void apply(Shape shape) {
shape.setStroke(stroke);
shape.setFill(fill);
shape.setStrokeWidth(width);
shape.setOpacity(opacity);
shape.getStrokeDashArray().clear();
shape.getStrokeDashArray().addAll(dash.array);
}
};
String value = "Frame: " + stroke.toString() + " Fill: " + fill.toString() + " Width: " + width + " Opacity: " + opacity + " Dash: " + dash;
return new Style(KEY, applier, value);
}
use of javafx.scene.shape.Shape in project contentment by GeePawHill.
the class ColorChanger method accept.
@Override
public boolean accept(Node node) {
if (node instanceof Shape) {
Shape shape = (Shape) node;
if (result == null)
result = shape.getStroke();
shape.setStroke(paint);
}
if (node instanceof Text) {
Text text = (Text) node;
text.setFill(paint);
}
return true;
}
Aggregations