javafx.scene.shape.Shape Java Examples

The following examples show how to use javafx.scene.shape.Shape. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CallEdgeViewer.java    From JetUML with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected Shape getShape(Edge pEdge)
{
	Point[] points = getPoints(pEdge);
	Path path = new Path();
	Point point = points[points.length - 1];
	MoveTo moveTo = new MoveTo(point.getX(), point.getY());
	path.getElements().add(moveTo);
	for(int i = points.length - 2; i >= 0; i--)
	{
		point = points[i];
		LineTo lineTo = new LineTo(point.getX(), point.getY());
		path.getElements().add(lineTo);
	}
	return path;
}
 
Example #2
Source File: OrganView.java    From narjillos with MIT License 6 votes vote down vote up
@Override
public Node toNode(double zoomLevel, boolean infraredOn, boolean effectsOn) {
	if (organ.isAtrophic())
		return null;

	double alpha = getAlpha(zoomLevel);
	if (alpha == 0)
		return null; // perfectly transparent. don't draw.

	Shape shape = getShape(zoomLevel, effectsOn);

	addFill(shape, infraredOn, alpha);
	addStroke(shape, infraredOn, alpha, zoomLevel);
	addMotionBlurEffect(shape, zoomLevel, effectsOn);

	previousOrganPosition = organ.toSegment();

	return shape;
}
 
Example #3
Source File: ShapeDetailPaneInfo.java    From scenic-view with GNU General Public License v3.0 6 votes vote down vote up
@Override protected void updateDetail(final String propertyName) {
    final boolean all = propertyName.equals("*") ? true : false;

    final Shape shapeNode = (Shape) getTarget();
    if (all || propertyName.equals("fill")) {
        if (shapeNode != null && shapeNode.getFill() == null) {
            Logger.print("Error: null shape fill for property " + propertyName);
        }
        fillDetail.setValue(shapeNode != null && shapeNode.getFill() != null ? shapeNode.getFill().toString() : "-");
        fillDetail.setIsDefault(shapeNode == null || shapeNode.getFill() == null);
        fillDetail.setSimpleProperty((shapeNode != null) ? shapeNode.fillProperty() : null);
        if (!all)
            fillDetail.updated();
        if (!all)
            return;
    }
    if (all)
        sendAllDetails();
}
 
Example #4
Source File: XMLTargetReader.java    From ShootOFF with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
	switch (qName) {
	case "polygon":
		final double[] points = new double[polygonPoints.size()];

		for (int i = 0; i < polygonPoints.size(); i++)
			points[i] = polygonPoints.get(i);

		currentRegion = new PolygonRegion(points);
		((Shape) currentRegion).setFill(polygonFill);
	case "image":
	case "rectangle":
	case "ellipse":
		currentRegion.setTags(currentTags);
		regions.add((Node) currentRegion);
		break;
	}
}
 
Example #5
Source File: AbstractInterpolator.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Adjusts the curveClip so that the curve node does not paint through the
 * given decoration.
 *
 * @param curveShape
 *            A shape describing the {@link ICurve} geometry, which is used
 *            for clipping.
 *
 * @param curveClip
 *            A shape that represents the clip of the curve node,
 *            interpreted in scene coordinates.
 * @param decoration
 *            The decoration to clip the curve node from.
 * @return A shape representing the resulting clip, interpreted in scene
 *         coordinates.
 */
protected Shape clipAtDecoration(Shape curveShape, Shape curveClip,
		Shape decoration) {
	// first intersect curve shape with decoration layout bounds,
	// then subtract the curve shape from the result, and the decoration
	// from that
	Path decorationShapeBounds = new Path(
			Geometry2Shape.toPathElements(NodeUtils
					.localToScene(decoration,
							NodeUtils.getShapeBounds(decoration))
					.toPath()));
	decorationShapeBounds.setFill(Color.RED);
	Shape clip = Shape.intersect(decorationShapeBounds, curveShape);
	clip = Shape.subtract(clip, decoration);
	clip = Shape.subtract(curveClip, clip);
	return clip;
}
 
Example #6
Source File: NodePart.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
private void refreshShape() {
	Node shape = ZestProperties.getShape(getContent());
	if (this.shape != shape && shape != null) {
		getVisual().getChildren().remove(this.shape);
		this.shape = shape;
		if (shape instanceof GeometryNode) {
			((GeometryNode<?>) shape).setStrokeType(StrokeType.INSIDE);
		} else if (shape instanceof Shape) {
			((Shape) shape).setStrokeType(StrokeType.INSIDE);
		}
		if (!shape.getStyleClass().contains(CSS_CLASS_SHAPE)) {
			shape.getStyleClass().add(CSS_CLASS_SHAPE);
		}
		getVisual().getChildren().add(0, shape);
	}
}
 
Example #7
Source File: FarCry4Loading.java    From FXTutorials with MIT License 6 votes vote down vote up
public LoadingCircle() {
    Circle circle = new Circle(20);
    circle.setFill(null);
    circle.setStroke(Color.WHITE);
    circle.setStrokeWidth(2);

    Rectangle rect = new Rectangle(20, 20);

    Shape shape = Shape.subtract(circle, rect);
    shape.setFill(Color.WHITE);

    getChildren().add(shape);

    animation = new RotateTransition(Duration.seconds(2.5), this);
    animation.setByAngle(-360);
    animation.setInterpolator(Interpolator.LINEAR);
    animation.setCycleCount(Animation.INDEFINITE);
    animation.play();
}
 
Example #8
Source File: Cross.java    From jsilhouette with Apache License 2.0 6 votes vote down vote up
@Override
protected void calculateShape() {
    double cx = getCenterX();
    double cy = getCenterY();
    double r = getRadius();
    double n = validateRoundness(getRoundness());
    double w = validateWidth(getWidth(), r);

    double arcWH = w * n;
    Rectangle beam1 = new Rectangle(cx - r, cy - (w / 2), r * 2, w);
    Rectangle beam2 = new Rectangle(cx - (w / 2), cy - r, w, r * 2);
    beam1.setArcWidth(arcWH);
    beam1.setArcHeight(arcWH);
    beam2.setArcWidth(arcWH);
    beam2.setArcHeight(arcWH);
    Shape shape = Shape.union(beam1, beam2);

    shape.getStyleClass().addAll("silhouette", "silhoutte-cross");

    setShape(shape);
}
 
Example #9
Source File: World.java    From worldfx with Apache License 2.0 6 votes vote down vote up
private void registerListeners() {
    widthProperty().addListener(o -> resize());
    heightProperty().addListener(o -> resize());
    sceneProperty().addListener(o -> {
        if (!locations.isEmpty()) { addShapesToScene(locations.values()); }
        if (isZoomEnabled()) { getScene().addEventFilter( ScrollEvent.ANY, new WeakEventHandler<>(_scrollEventHandler)); }

        locations.addListener((MapChangeListener<Location, Shape>) CHANGE -> {
            if (CHANGE.wasAdded()) {
                addShapesToScene(CHANGE.getValueAdded());
            } else if(CHANGE.wasRemoved()) {
                Platform.runLater(() -> pane.getChildren().remove(CHANGE.getValueRemoved()));
            }
        });
    });
}
 
Example #10
Source File: OrganView.java    From narjillos with MIT License 6 votes vote down vote up
private void addMotionBlurEffect(Shape organShape, double zoomLevel, boolean effectsOn) {
	organShape.setEffect(null);

	if (!effectsOn)
		return;

	if (zoomLevel < MOTION_BLUR_DISTANCE)
		return;

	Vector movement = calculateMovement();

	if (movement.equals(Vector.ZERO))
		return;

	double velocity = movement.getLength();

	if (velocity < MOTION_BLUR_THRESHOLD)
		return;

	try {
		organShape.setEffect(new MotionBlur(movement.getAngle(), velocity / MOTION_BLUR_THRESHOLD * MOTION_BLUR_INTENSITY));
	} catch (ZeroVectorAngleException e) {
	}
}
 
Example #11
Source File: TargetEditorController.java    From ShootOFF with GNU General Public License v3.0 6 votes vote down vote up
@FXML
public void startPolygon(ActionEvent event) {
	if (cursorRegion.isPresent() && targetRegions.contains(cursorRegion.get())) {
		final TargetRegion selected = (TargetRegion) cursorRegion.get();

		if (selected.getType() != RegionType.IMAGE)
			((Shape) selected).setStroke(TargetRegion.UNSELECTED_STROKE_COLOR);

		if (tagsButton.isSelected()) {
			tagsButton.setSelected(false);
			toggleTagEditor();
		}
		toggleShapeControls(false);
	}

	clearFreeformState(false);
}
 
Example #12
Source File: NodeUtils.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Returns an {@link IGeometry} that corresponds whose outline represents
 * the geometric outline of the given {@link Node}, excluding its stroke.
 * <p>
 * The {@link IGeometry} is specified within the local coordinate system of
 * the given {@link Node}.
 * <p>
 * The following {@link Node}s are supported:
 * <ul>
 * <li>{@link Connection}
 * <li>{@link GeometryNode}
 * <li>{@link Arc}
 * <li>{@link Circle}
 * <li>{@link CubicCurve}
 * <li>{@link Ellipse}
 * <li>{@link Line}
 * <li>{@link Path}
 * <li>{@link Polygon}
 * <li>{@link Polyline}
 * <li>{@link QuadCurve}
 * <li>{@link Rectangle}
 * </ul>
 *
 * @param visual
 *            The {@link Node} of which the geometric outline is returned.
 * @return An {@link IGeometry} that corresponds to the geometric outline of
 *         the given {@link Node}.
 * @throws IllegalArgumentException
 *             if the given {@link Node} is not supported.
 */
public static IGeometry getGeometricOutline(Node visual) {
	if (visual instanceof Connection) {
		Node curveNode = ((Connection) visual).getCurve();
		return localToParent(curveNode, getGeometricOutline(curveNode));
	} else if (visual instanceof GeometryNode) {
		// XXX: The geometry's position is specified relative to the
		// GeometryNode's layout bounds (which are fixed as (0, 0, width,
		// height) and includes the layoutX, layoutY (which we have to
		// compensate here)
		GeometryNode<?> geometryNode = (GeometryNode<?>) visual;
		IGeometry geometry = geometryNode.getGeometry();
		if (geometry != null) {
			if (geometry instanceof ITranslatable) {
				return ((ITranslatable<?>) geometry).getTranslated(
						-geometryNode.getLayoutX(),
						-geometryNode.getLayoutY());
			} else {
				return geometry.getTransformed(new AffineTransform()
						.translate(-geometryNode.getLayoutX(),
								-geometryNode.getLayoutY()));
			}
		} else {
			// if the geometry node has no geometry (yet), return an empty
			// geometry
			return new Rectangle();
		}
	} else if (visual instanceof Shape && !(visual instanceof Text)
			&& !(visual instanceof SVGPath)) {
		return Shape2Geometry.toGeometry((Shape) visual);
	} else {
		throw new IllegalArgumentException(
				"Cannot determine geometric outline for the given visual <"
						+ visual + ">.");
	}
}
 
Example #13
Source File: DotArrowShapeDecorations.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
private static void setSide(Shape shape, String side) {
	if (shape instanceof Polygon) {
		setSide((Polygon) shape, side);
	} else if (shape instanceof Arc) {
		setSide((Arc) shape, side);
	}
}
 
Example #14
Source File: ConicalGradient.java    From regulators with Apache License 2.0 5 votes vote down vote up
public ImagePattern apply(final Shape SHAPE) {
    double x      = SHAPE.getLayoutBounds().getMinX();
    double y      = SHAPE.getLayoutBounds().getMinY();
    double width  = SHAPE.getLayoutBounds().getWidth();
    double height = SHAPE.getLayoutBounds().getHeight();
    centerX       = width * 0.5;
    centerY       = height * 0.5;
    return new ImagePattern(getImage(width, height), x, y, width, height, false);
}
 
Example #15
Source File: DotArrowShapeDecorations.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
private static Shape getPrimitiveShape(
		org.eclipse.gef.dot.internal.language.arrowtype.PrimitiveShape primitiveShape,
		double arrowSize) {
	switch (primitiveShape) {
	case BOX:
		return new Box(arrowSize);
	case CROW:
		return new Crow(arrowSize);
	case CURVE:
		return new Curve(arrowSize);
	case ICURVE:
		return new ICurve(arrowSize);
	case DIAMOND:
		return new Diamond(arrowSize);
	case DOT:
		return new Dot(arrowSize);
	case INV:
		return new Inv(arrowSize);
	case NONE:
		return null;
	case NORMAL:
		return new Normal(arrowSize);
	case TEE:
		return new Tee(arrowSize);
	case VEE:
		return new Vee(arrowSize);
	default:
		return null;
	}
}
 
Example #16
Source File: Shape2Geometry.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Returns an {@link IGeometry} that describes the geometric outline of the
 * given {@link Shape}, i.e. excluding the stroke.
 * <p>
 * The conversion is supported for the following {@link Shape}s:
 * <ul>
 * <li>{@link Arc}
 * <li>{@link Circle}
 * <li>{@link CubicCurve}
 * <li>{@link Ellipse}
 * <li>{@link Line}
 * <li>{@link Path}
 * <li>{@link Polygon}
 * <li>{@link Polyline}
 * <li>{@link QuadCurve}
 * <li>{@link Rectangle}
 * </ul>
 * The following {@link Shape}s cannot be converted, yet:
 * <ul>
 * <li>{@link Text}
 * <li>{@link SVGPath}
 * </ul>
 *
 * @param visual
 *            The {@link Shape} for which an {@link IGeometry} is
 *            determined.
 * @return The newly created {@link IGeometry} that best describes the
 *         geometric outline of the given {@link Shape}.
 * @throws IllegalStateException
 *             if the given {@link Shape} is not supported.
 */
public static IGeometry toGeometry(Shape visual) {
	if (visual instanceof Arc) {
		return toArc((Arc) visual);
	} else if (visual instanceof Circle) {
		return toEllipse((Circle) visual);
	} else if (visual instanceof CubicCurve) {
		return toCubicCurve((CubicCurve) visual);
	} else if (visual instanceof Ellipse) {
		return toEllipse((Ellipse) visual);
	} else if (visual instanceof Line) {
		return toLine((Line) visual);
	} else if (visual instanceof Path) {
		return toPath((Path) visual);
	} else if (visual instanceof Polygon) {
		return toPolygon((Polygon) visual);
	} else if (visual instanceof Polyline) {
		return toPolyline((Polyline) visual);
	} else if (visual instanceof QuadCurve) {
		QuadCurve quad = (QuadCurve) visual;
		return toQuadraticCurve(quad);
	} else if (visual instanceof Rectangle) {
		Rectangle rect = (Rectangle) visual;
		if (rect.getArcWidth() == 0 && rect.getArcHeight() == 0) {
			// corners are not rounded => normal rectangle is sufficient
			return toRectangle(rect);
		}
		return toRoundedRectangle((Rectangle) visual);
	} else {
		// Text and SVGPath shapes are currently not supported
		throw new IllegalStateException(
				"Cannot compute geometric outline for Shape of type <"
						+ visual.getClass() + ">.");
	}
}
 
Example #17
Source File: StateTransitionEdgeViewer.java    From JetUML with GNU General Public License v3.0 5 votes vote down vote up
private Shape getNormalEdgeShape(Edge pEdge)
{
	Line line = getConnectionPoints(pEdge);
	Path path = new Path();
	MoveTo moveTo = new MoveTo(line.getPoint1().getX(), line.getPoint1().getY());
	QuadCurveTo curveTo = new QuadCurveTo(getControlPoint(pEdge).getX(), getControlPoint(pEdge).getY(), 
			line.getPoint2().getX(), line.getPoint2().getY());
	path.getElements().addAll(moveTo, curveTo);
	return path;
}
 
Example #18
Source File: StateTransitionEdgeViewer.java    From JetUML with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected Shape getShape(Edge pEdge)
{
	if( isSelfEdge(pEdge) )
	{
		return getSelfEdgeShape(pEdge);
	}
	else
	{
		return getNormalEdgeShape(pEdge);
	}
}
 
Example #19
Source File: TestViewGrid.java    From latexdraw with GNU General Public License v3.0 5 votes vote down vote up
@Test
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());
}
 
Example #20
Source File: OrganView.java    From narjillos with MIT License 5 votes vote down vote up
private void addStroke(Shape organShape, boolean infraredOn, double alpha, double zoomLevel) {
	if (infraredOn && zoomLevel > HIGH_MAGNIFICATION) {
		organShape.setStroke(new Color(1, 1, 1, alpha));
		organShape.setStrokeWidth(3);
	} else {
		organShape.setStrokeWidth(0);
	}
}
 
Example #21
Source File: FxSchema.java    From FxDock with Apache License 2.0 5 votes vote down vote up
private static String getName(Node n)
{
	Object x = n.getProperties().get(PROP_NAME);
	if(x instanceof String)
	{
		return (String)x;
	}
	
	if(n instanceof MenuBar)
	{
		return null;
	}
	else if(n instanceof Shape)
	{
		return null;
	}
	else if(n instanceof ImageView)
	{
		return null;
	}
	
	String id = n.getId();
	if(id != null)
	{
		return id;
	}
			
	return n.getClass().getSimpleName();
}
 
Example #22
Source File: Lauburu.java    From jsilhouette with Apache License 2.0 5 votes vote down vote up
@Override
protected void calculateShape() {
    double cx = getCenterX();
    double cy = getCenterY();
    double r = getRadius();
    Direction d = getDirection();

    Shape shape = new PathBuilder().moveTo(cx, cy)
        .arcTo(cx + r, cy, r / 2, r / 2, d == Direction.CLOCKWISE)
        .arcTo(cx + (r / 2), cy, r / 4, r / 4, d == Direction.CLOCKWISE)
        .arcTo(cx, cy, r / 4, r / 4, d != Direction.CLOCKWISE)
        .close()
        .arcTo(cx - r, cy, r / 2, r / 2, d == Direction.CLOCKWISE)
        .arcTo(cx - (r / 2), cy, r / 4, r / 4, d == Direction.CLOCKWISE)
        .arcTo(cx, cy, r / 4, r / 4, d != Direction.CLOCKWISE)
        .close()
        .arcTo(cx, cy + r, r / 2, r / 2, d == Direction.CLOCKWISE)
        .arcTo(cx, cy + (r / 2), r / 4, r / 4, d == Direction.CLOCKWISE)
        .arcTo(cx, cy, r / 4, r / 4, d != Direction.CLOCKWISE)
        .close()
        .arcTo(cx, cy - r, r / 2, r / 2, d == Direction.CLOCKWISE)
        .arcTo(cx, cy - (r / 2), r / 4, r / 4, d == Direction.CLOCKWISE)
        .arcTo(cx, cy, r / 4, r / 4, d != Direction.CLOCKWISE)
        .close()
        .build();

    shape.getStyleClass().addAll("silhouette", "silhoutte-lauburu");

    setShape(shape);
}
 
Example #23
Source File: DotArrowShapeDecorations.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Returns the dot arrow shape decoration corresponding to the
 * <i>arrowType</i> parameter.
 *
 * @param arrowType
 *            The arrow type for which the dot edge decoration should be
 *            determined.
 *
 * @param arrowSize
 *            The size of the arrow shape decoration.
 *
 * @param penwidth
 *            The (pen)width of the shape's drawn lines.
 *
 * @param color
 *            The color to use for the arrow shape decoration outline.
 *
 * @param fillColor
 *            The color to use for the arrow shape decoration background.
 *
 * @return The dot arrow shape decoration.
 */
static Node get(ArrowType arrowType, double arrowSize, Double penwidth,
		String color, String fillColor) {
	// The first arrow shape specified should occur closest to the node.
	double offset = 0.0;
	Group group = new Group();
	for (AbstractArrowShape arrowShape : arrowType.getArrowShapes()) {
		Shape currentShape = get(arrowShape, arrowSize, penwidth, color,
				fillColor);
		if (currentShape == null) {
			// represent the "none" arrow shape with a transparent box with
			// the corresponding size
			currentShape = new Box(arrowSize);
			currentShape.setFill(Color.TRANSPARENT);
			currentShape.setTranslateX(offset);
		} else {
			if (currentShape instanceof Circle) {
				// translate a circle-based shape specially because of its
				// middle-point-based translation
				currentShape.setTranslateX(offset
						+ currentShape.getLayoutBounds().getWidth() / 2);
			} else {
				currentShape.setTranslateX(offset);
			}
		}
		offset += NodeUtils.getShapeBounds(currentShape).getWidth()
				- currentShape.getStrokeWidth();
		group.getChildren().add(currentShape);
	}

	return group;
}
 
Example #24
Source File: Dialogs.java    From helloiot with GNU General Public License v3.0 5 votes vote down vote up
private static void setRotate(Shape s, boolean reverse, double angle, int duration) {
    RotateTransition r = new RotateTransition(Duration.seconds(duration), s);
    r.setAutoReverse(reverse);
    r.setDelay(Duration.ZERO);
    r.setRate(3.0);
    r.setCycleCount(RotateTransition.INDEFINITE);
    r.setByAngle(angle);
    r.play();
}
 
Example #25
Source File: ConicalGradient.java    From Medusa with Apache License 2.0 5 votes vote down vote up
public ImagePattern apply(final Shape SHAPE) {
    double x      = SHAPE.getLayoutBounds().getMinX();
    double y      = SHAPE.getLayoutBounds().getMinY();
    double width  = SHAPE.getLayoutBounds().getWidth();
    double height = SHAPE.getLayoutBounds().getHeight();
    centerX       = width * 0.5;
    centerY       = height * 0.5;
    return new ImagePattern(getImage(width, height), x, y, width, height, false);
}
 
Example #26
Source File: TestViewBezierCurve.java    From latexdraw with GNU General Public License v3.0 5 votes vote down vote up
@Test
void testShowPtsCtrlLineSizeDbleLine() {
	model.setShowPts(true);
	model.setHasDbleBord(true);
	model.setDbleBordSep(12d);
	model.setThickness(5d);
	WaitForAsyncUtils.waitForFxEvents();
	assertThat(view.showPoint.getChildren())
		.filteredOn(n -> n instanceof Line)
		.allMatch(elt -> MathUtils.INST.equalsDouble(((Shape) elt).getStrokeWidth(), 11d));
}
 
Example #27
Source File: Level4.java    From FXGLGames with MIT License 5 votes vote down vote up
@Override
public void init() {
    double t = 0;

    for (int y = 0; y < ENEMY_ROWS; y++) {
        for (int x = 0; x < ENEMIES_PER_ROW; x++) {
            Entity enemy = spawnEnemy(50, 50);

            var path = new Rectangle(Config.WIDTH - 100, Config.HEIGHT / 2.0);
            path.setX(50);
            path.setY(50);

            var inter = new Rectangle(Config.WIDTH - 100, Config.HEIGHT);
            inter.setX(50);
            inter.setY(50);

            var a = animationBuilder()
                    .repeatInfinitely()
                    .delay(Duration.seconds(t))
                    .duration(Duration.seconds(2.5))
                    .translate(enemy)
                    // TODO: remove intersection
                    .alongPath(Shape.intersect(inter, path))
                    .build();

            animations.add(a);
            a.start();

            t += 0.3;
        }
    }
}
 
Example #28
Source File: ClockSkin.java    From Medusa with Apache License 2.0 5 votes vote down vote up
@Override protected void handleEvents(final String EVENT_TYPE) {
    super.handleEvents(EVENT_TYPE);
    if ("VISIBILITY".equals(EVENT_TYPE)) {
        title.setVisible(getSkinnable().isTitleVisible());
        title.setManaged(getSkinnable().isTitleVisible());
        text.setVisible(getSkinnable().isTextVisible());
        text.setManaged(getSkinnable().isTextVisible());
        dateText.setVisible(getSkinnable().isDateVisible());
        dateText.setManaged(getSkinnable().isDateVisible());
        second.setVisible(getSkinnable().isSecondsVisible());
        second.setManaged(getSkinnable().isSecondsVisible());
        boolean alarmsVisible = getSkinnable().isAlarmsVisible();
        for (Shape shape : alarmMap.values()) {
            shape.setManaged(alarmsVisible);
            shape.setVisible(alarmsVisible);
        }
    } else if ("SECTION".equals(EVENT_TYPE)) {
        sections          = getSkinnable().getSections();
        highlightSections = getSkinnable().isHighlightSections();
        sectionsVisible   = getSkinnable().getSectionsVisible();
        areas             = getSkinnable().getAreas();
        highlightAreas    = getSkinnable().isHighlightAreas();
        areasVisible      = getSkinnable().getAreasVisible();
        redraw();
    } else if ("FINISHED".equals(EVENT_TYPE)) {

    }
}
 
Example #29
Source File: Level4.java    From FXGLGames with MIT License 5 votes vote down vote up
@Override
public void init() {
    double t = 0;

    for (int y = 0; y < ENEMY_ROWS; y++) {
        for (int x = 0; x < ENEMIES_PER_ROW; x++) {
            Entity enemy = spawnEnemy(50, 50);

            var path = new Rectangle(Config.WIDTH - 100, Config.HEIGHT / 2.0);
            path.setX(50);
            path.setY(50);

            var inter = new Rectangle(Config.WIDTH - 100, Config.HEIGHT);
            inter.setX(50);
            inter.setY(50);

            var a = animationBuilder()
                    .repeatInfinitely()
                    .delay(Duration.seconds(t))
                    .duration(Duration.seconds(2.5))
                    .translate(enemy)
                    // TODO: remove intersection
                    .alongPath(Shape.intersect(inter, path))
                    .build();

            animations.add(a);
            a.start();

            t += 0.3;
        }
    }
}
 
Example #30
Source File: BasicView.java    From gluon-samples with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static void updateShapeAppearance( Shape shape, boolean selected ) {
    if ( shape == null ) return;

    shape.setFill(selected ? Color.LIGHTGREEN : Color.LIGHTBLUE);
    shape.setStroke(Color.DARKGRAY);
    shape.setStrokeWidth(2.5);

    DropShadow shadow = new DropShadow();
    shadow.setOffsetY(3.0);
    shadow.setOffsetX(3.0);
    shadow.setColor(Color.GRAY);
    shape.setEffect(shadow);
}