001package conexp.fx.gui.util; 002 003/* 004 * #%L 005 * Concept Explorer FX 006 * %% 007 * Copyright (C) 2010 - 2023 Francesco Kriegel 008 * %% 009 * This program is free software: you can redistribute it and/or modify 010 * it under the terms of the GNU General Public License as 011 * published by the Free Software Foundation, either version 3 of the 012 * License, or (at your option) any later version. 013 * 014 * This program is distributed in the hope that it will be useful, 015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 017 * GNU General Public License for more details. 018 * 019 * You should have received a copy of the GNU General Public 020 * License along with this program. If not, see 021 * <http://www.gnu.org/licenses/gpl-3.0.html>. 022 * #L% 023 */ 024 025import java.util.Collection; 026 027import com.sun.javafx.geom.BaseBounds; 028import com.sun.javafx.geom.transform.BaseTransform; 029 030import javafx.scene.Node; 031import javafx.scene.layout.Pane; 032 033public final class SynchronizedPane extends Pane { 034 035 public SynchronizedPane() { 036 super(); 037 } 038 039 public final void add(final Node... c) { 040 synchronized (this) { 041 for (Node n : c) 042// try { 043 getChildren().add(n); 044// } catch (IllegalArgumentException e) { 045//// System.err.println("ignore " + e.toString() + " in <SynchronizedPane>.add(...)"); 046// } 047 } 048 } 049 050 public final void add(final Collection<? extends Node> c) { 051 synchronized (this) { 052 for (Node n : c) 053// try { 054 getChildren().add(n); 055// } catch (IllegalArgumentException e) { 056//// System.err.println("ignore " + e.toString() + " in <SynchronizedPane>.add(...)"); 057// } 058 } 059 } 060 061 public final void remove(final Node... c) { 062 synchronized (this) { 063 getChildren().removeAll(c); 064 } 065 } 066 067 public final void remove(final Collection<? extends Node> c) { 068 synchronized (this) { 069 getChildren().removeAll(c); 070 } 071 } 072 073 public final void clear() { 074 synchronized (this) { 075 getChildren().clear(); 076 } 077 } 078 079 @Deprecated 080 public final BaseBounds impl_computeGeomBounds(final BaseBounds baseBounds, final BaseTransform baseTransform) { 081 synchronized (this) { 082// while (true) 083 try { 084 return super.impl_computeGeomBounds(baseBounds, baseTransform); 085 } catch (Exception e) { 086 return null; 087//// System.err.println("ignore " + e.toString() + " in <SynchronizedPane>.impl_computeGeomBounds(...)"); 088 } 089 } 090 } 091}