Search in sources :

Example 21 with Shape

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();
}
Also used : MouseButton(javafx.scene.input.MouseButton) ViewText(net.sf.latexdraw.view.jfx.ViewText) Command(org.malai.command.Command) BoundingBox(javafx.geometry.BoundingBox) ShapeFactory(net.sf.latexdraw.models.ShapeFactory) SelectShapes(net.sf.latexdraw.commands.shape.SelectShapes) JfXWidgetBinding(org.malai.javafx.binding.JfXWidgetBinding) NonInvertibleTransformException(javafx.scene.transform.NonInvertibleTransformException) ArrayList(java.util.ArrayList) ViewShape(net.sf.latexdraw.view.jfx.ViewShape) Inject(net.sf.latexdraw.util.Inject) IShape(net.sf.latexdraw.models.interfaces.shape.IShape) ListChangeListener(javafx.collections.ListChangeListener) Transform(javafx.scene.transform.Transform) IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint) Canvas(net.sf.latexdraw.view.jfx.Canvas) DnD(org.malai.javafx.interaction.library.DnD) KeyCode(javafx.scene.input.KeyCode) Node(javafx.scene.Node) LSystem(net.sf.latexdraw.util.LSystem) IText(net.sf.latexdraw.models.interfaces.shape.IText) Rectangle(javafx.scene.shape.Rectangle) UpdateToGrid(net.sf.latexdraw.commands.shape.UpdateToGrid) InitTextSetter(net.sf.latexdraw.commands.shape.InitTextSetter) TranslateShapes(net.sf.latexdraw.commands.shape.TranslateShapes) Platform(javafx.application.Platform) Cursor(javafx.scene.Cursor) List(java.util.List) Press(org.malai.javafx.interaction.library.Press) IPlot(net.sf.latexdraw.models.interfaces.shape.IPlot) ViewPlot(net.sf.latexdraw.view.jfx.ViewPlot) Optional(java.util.Optional) DoubleClick(org.malai.javafx.interaction.library.DoubleClick) Collections(java.util.Collections) Shape(javafx.scene.shape.Shape) Bounds(javafx.geometry.Bounds) TranslateShapes(net.sf.latexdraw.commands.shape.TranslateShapes) IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint) DnD(org.malai.javafx.interaction.library.DnD)

Example 22 with Shape

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());
}
Also used : Shape(javafx.scene.shape.Shape) Paint(javafx.scene.paint.Paint) Test(org.junit.Test)

Example 23 with Shape

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);
}
Also used : Ellipse(javafx.scene.shape.Ellipse) Shape(javafx.scene.shape.Shape) Arc(javafx.scene.shape.Arc) GraphicsContext(javafx.scene.canvas.GraphicsContext) Color(javafx.scene.paint.Color) Canvas(javafx.scene.canvas.Canvas) Rectangle(javafx.scene.shape.Rectangle) Glow(javafx.scene.effect.Glow)

Example 24 with Shape

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);
}
Also used : Shape(javafx.scene.shape.Shape) Style(org.geepawhill.contentment.format.Style) StyleApplier(org.geepawhill.contentment.format.StyleApplier)

Example 25 with Shape

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;
}
Also used : Shape(javafx.scene.shape.Shape) Text(javafx.scene.text.Text)

Aggregations

Shape (javafx.scene.shape.Shape)35 Rectangle (javafx.scene.shape.Rectangle)9 Node (javafx.scene.Node)8 Test (org.junit.Test)7 TimeGraphDrawnEventProvider (com.efficios.jabberwocky.views.timegraph.model.provider.drawnevents.TimeGraphDrawnEventProvider)6 Color (javafx.scene.paint.Color)6 Circle (javafx.scene.shape.Circle)6 StubDrawnEventProvider1 (org.lttng.scope.views.timeline.widgets.timegraph.StubDrawnEventProviders.StubDrawnEventProvider1)6 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 Platform (javafx.application.Platform)4 Text (javafx.scene.text.Text)4 Bounds (javafx.geometry.Bounds)3 Parent (javafx.scene.Parent)3 URL (java.net.URL)2 ResourceBundle (java.util.ResourceBundle)2 SimpleIntegerProperty (javafx.beans.property.SimpleIntegerProperty)2 FXML (javafx.fxml.FXML)2 Initializable (javafx.fxml.Initializable)2