Search in sources :

Example 11 with Shape

use of javafx.scene.shape.Shape in project contentment by GeePawHill.

the class TypeFace method color.

public static Style color(Paint stroke, Paint fill, Double opacity) {
    StyleApplier applier = new StyleApplier() {

        @Override
        public void apply(Shape shape) {
            shape.setStroke(stroke);
            shape.setFill(fill);
            shape.setOpacity(opacity);
        }
    };
    String value = "Stroke: " + stroke.toString() + " Fill: " + fill.toString() + " Opacity: " + opacity;
    return new Style(COLOR, applier, value);
}
Also used : Shape(javafx.scene.shape.Shape) Style(org.geepawhill.contentment.format.Style) StyleApplier(org.geepawhill.contentment.format.StyleApplier)

Example 12 with Shape

use of javafx.scene.shape.Shape in project lttng-scope by lttng.

the class TimeGraphWidgetDrawnEventsTest method testRegisteredButNotEnabledProvider.

/**
 * Test that a provider that is not registered but (somehow) enabled does
 * not paint its event.
 */
@Test
public void testRegisteredButNotEnabledProvider() {
    TimeGraphDrawnEventProvider provider1 = new StubDrawnEventProvider1();
    TimeGraphDrawnEventProvider provider2 = new StubDrawnEventProvider2();
    MANAGER.getRegisteredProviders().add(provider1);
    MANAGER.getRegisteredProviders().add(provider2);
    provider1.enabledProperty().set(false);
    provider2.enabledProperty().set(true);
    repaint();
    Collection<Shape> events = getRenderedEvents();
    assertEquals(StubDrawnEventProvider2.NB_SYMBOLS, events.size());
}
Also used : StubDrawnEventProvider1(org.lttng.scope.views.timeline.widgets.timegraph.StubDrawnEventProviders.StubDrawnEventProvider1) StubDrawnEventProvider2(org.lttng.scope.views.timeline.widgets.timegraph.StubDrawnEventProviders.StubDrawnEventProvider2) Shape(javafx.scene.shape.Shape) TimeGraphDrawnEventProvider(com.efficios.jabberwocky.views.timegraph.model.provider.drawnevents.TimeGraphDrawnEventProvider) Test(org.junit.Test)

Example 13 with Shape

use of javafx.scene.shape.Shape in project lttng-scope by lttng.

the class TimeGraphWidgetDrawnEventsTest method testEnabledButNotRegisteredProvider.

/**
 * Test that a provider that is registered but not enabled does not paint
 * its events.
 */
@Test
public void testEnabledButNotRegisteredProvider() {
    TimeGraphDrawnEventProvider provider = new StubDrawnEventProvider1();
    provider.enabledProperty().set(true);
    repaint();
    Collection<Shape> events = getRenderedEvents();
    assertTrue(events.isEmpty());
}
Also used : StubDrawnEventProvider1(org.lttng.scope.views.timeline.widgets.timegraph.StubDrawnEventProviders.StubDrawnEventProvider1) Shape(javafx.scene.shape.Shape) TimeGraphDrawnEventProvider(com.efficios.jabberwocky.views.timegraph.model.provider.drawnevents.TimeGraphDrawnEventProvider) Test(org.junit.Test)

Example 14 with Shape

use of javafx.scene.shape.Shape in project lttng-scope by lttng.

the class TimeGraphWidgetDrawnEventsTest method testManyProviders.

/**
 * Test several enabled+registered providers at the same time. They should
 * all paint their own events.
 */
@Test
public void testManyProviders() {
    TimeGraphDrawnEventProvider provider1 = new StubDrawnEventProvider1();
    TimeGraphDrawnEventProvider provider2 = new StubDrawnEventProvider2();
    MANAGER.getRegisteredProviders().add(provider1);
    MANAGER.getRegisteredProviders().add(provider2);
    provider1.enabledProperty().set(true);
    provider2.enabledProperty().set(true);
    repaint();
    Collection<Shape> events = getRenderedEvents();
    assertEquals(StubDrawnEventProvider1.NB_SYMBOLS + StubDrawnEventProvider2.NB_SYMBOLS, events.size());
}
Also used : StubDrawnEventProvider1(org.lttng.scope.views.timeline.widgets.timegraph.StubDrawnEventProviders.StubDrawnEventProvider1) StubDrawnEventProvider2(org.lttng.scope.views.timeline.widgets.timegraph.StubDrawnEventProviders.StubDrawnEventProvider2) Shape(javafx.scene.shape.Shape) TimeGraphDrawnEventProvider(com.efficios.jabberwocky.views.timegraph.model.provider.drawnevents.TimeGraphDrawnEventProvider) Test(org.junit.Test)

Example 15 with Shape

use of javafx.scene.shape.Shape in project latexdraw by arnobl.

the class ViewShape method getActivatedGroupNodes.

private static Collection<Shape> getActivatedGroupNodes(final Group gp) {
    // Adding all the shape children
    final Collection<Shape> shapes = gp.getChildren().stream().filter(node -> node instanceof Shape && node.isVisible() && !node.isDisable()).map(node -> (Shape) node).collect(Collectors.toList());
    // Adding all the view shape children
    shapes.addAll(gp.getChildren().stream().filter(node -> node instanceof ViewShape<?> && node.isVisible() && !node.isDisable()).map(vs -> ((ViewShape<?>) vs).getActivatedShapes()).flatMap(st -> st.stream()).collect(Collectors.toList()));
    // Adding the shapes contained in groups that are not view shapes
    shapes.addAll(gp.getChildren().stream().filter(node -> node instanceof Group && !(node instanceof ViewShape<?>)).map(node -> getActivatedGroupNodes((Group) node)).flatMap(st -> st.stream()).collect(Collectors.toList()));
    // Adding the images contained in the group
    shapes.addAll(gp.getChildren().stream().filter(node -> node instanceof ImageView && node.isVisible() && !node.isDisable()).map(node -> {
        final Bounds bounds = node.getBoundsInParent();
        Rectangle rec = new Rectangle(bounds.getMinX(), bounds.getMinY(), bounds.getWidth(), bounds.getHeight());
        rec.setFill(Color.WHITE);
        rec.getTransforms().setAll(gp.getLocalToSceneTransform());
        return rec;
    }).collect(Collectors.toList()));
    return shapes;
}
Also used : Platform(javafx.application.Platform) Parent(javafx.scene.Parent) Color(javafx.scene.paint.Color) IShape(net.sf.latexdraw.models.interfaces.shape.IShape) ImageView(javafx.scene.image.ImageView) Collection(java.util.Collection) Optional(java.util.Optional) Rectangle(javafx.scene.shape.Rectangle) Group(javafx.scene.Group) Collectors(java.util.stream.Collectors) Shape(javafx.scene.shape.Shape) Bounds(javafx.geometry.Bounds) Group(javafx.scene.Group) IShape(net.sf.latexdraw.models.interfaces.shape.IShape) Shape(javafx.scene.shape.Shape) Bounds(javafx.geometry.Bounds) Rectangle(javafx.scene.shape.Rectangle) ImageView(javafx.scene.image.ImageView)

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