यह ऑपरेशन दो या अधिक आकृतियों को इनपुट के रूप में लेता है और उनके द्वारा घिरे संयुक्त क्षेत्र को वापस करता है जैसा कि नीचे दिखाया गया है।

javafx.scene.shape.Shape क्लास का union() (स्टैटिक) मेथड दो Shape ऑब्जेक्ट्स को स्वीकार करता है और दिए गए ऑब्जेक्ट्स के यूनियन ऑपरेशन का परिणाम वापस करता है।
उदाहरण
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Shape;
public class JavaFXUnionExample extends Application {
public void start(Stage stage) {
// सर्कल 1 बनाना
Circle circle1 = new Circle();
circle1.setCenterX(230.0f);
circle1.setCenterY(100.0f);
circle1.setRadius(75.0f);
circle1.setFill(Color.DARKRED);
// सर्कल 2 बनाना
Circle circle2 = new Circle();
circle2.setCenterX(280.0f);
circle2.setCenterY(170.0f);
circle2.setRadius(75.0f);
circle2.setFill(Color.DARKRED);
// सर्कल 3 बनाना
Circle circle3 = new Circle();
circle3.setCenterX(330.0f);
circle3.setCenterY(100.0f);
circle3.setRadius(75.0f);
circle3.setFill(Color.DARKRED);
// यूनियन ऑपरेशन
Shape union = Shape.union(circle1, circle2);
union = Shape.union(union, circle3);
union.setFill(Color.RED);
// स्टेज सेट करना
Group root = new Group(circle1, circle2, circle3, union);
Scene scene = new Scene(root, 595, 300);
stage.setTitle("Union Operation");
stage.setScene(scene);
stage.show();
}
public static void main(String args[]){
launch(args);
}
}
आउटपुट
