/* * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ //package bugs; import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.paint.Color; import javafx.scene.shape.Circle; import javafx.scene.shape.Rectangle; import javafx.stage.Stage; public class AntiAliasedShapeBug extends Application { Rectangle rect1 = new Rectangle(); boolean rect1AAFlag = true; Rectangle rect2 = new Rectangle(); boolean rect2AAFlag = true; Circle circle1 = new Circle(250, 75, 70, Color.RED); boolean circle1AAFlag = true; Circle circle2 = new Circle(250, 75, 50, Color.BLUE); boolean circle2AAFlag = true; @Override public void start(Stage stage) { stage.setTitle("Hello Antialiased Shape Bug"); System.err.println("Click on shape to toggle its smooth property"); Group root = new Group(); Scene scene = new Scene(root, 600, 450, true); scene.setFill(Color.WHITE); rect1.setX(25); rect1.setY(40); rect1.setWidth(400); rect1.setHeight(400); rect1.setFill(Color.GREEN); rect1.setOnMousePressed(e -> { rect1AAFlag = !rect1AAFlag; System.out.println("Mouse Pressed: rect1's smooth = " + rect1AAFlag); rect1.setSmooth(rect1AAFlag); }); rect2.setTranslateZ(-0.2); rect2.setX(225); rect2.setY(150); rect2.setRotate(10); rect2.setWidth(300); rect2.setHeight(150); rect2.setArcHeight(50); rect2.setArcWidth(50); rect2.setFill(Color.color(0.5, 0.5, 0.5)); rect2.setStroke(Color.DARKCYAN); rect2.setStrokeWidth(5); rect2.setOnMousePressed(e -> { rect2AAFlag = !rect2AAFlag; System.out.println("Mouse Pressed: rect2's smooth = " + rect2AAFlag); rect2.setSmooth(rect2AAFlag); }); circle1.setTranslateZ(-0.1); circle1.setOnMousePressed(e -> { circle1AAFlag = !circle1AAFlag; System.out.println("Mouse Pressed: circle1's smooth = " + circle1AAFlag); circle1.setSmooth(circle1AAFlag); }); circle2.setTranslateZ(-0.2); circle2.setOnMousePressed(e -> { circle2AAFlag = !circle2AAFlag; System.out.println("Mouse Pressed: circle2's smooth = " + circle2AAFlag); circle2.setSmooth(circle2AAFlag); }); root.getChildren().addAll(rect2, rect1, circle2, circle1); stage.setScene(scene); stage.show(); } /** * @param args the command line arguments */ public static void main(String[] args) { Application.launch(args); } }