8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package javafx.beans.property;
27
28 import javafx.beans.InvalidationListener;
29 import javafx.beans.value.ChangeListener;
30
31 /**
32 * This class provides a convenient class to define read-only properties. It
33 * creates two properties that are synchronized. One property is read-only
34 * and can be passed to external users. The other property is read- and
35 * writable and should be used internally only.
36 *
37 * @since JavaFX 2.0
38 */
39 public class ReadOnlyFloatWrapper extends SimpleFloatProperty {
40
41 private ReadOnlyPropertyImpl readOnlyProperty;
42
43 /**
44 * The constructor of {@code ReadOnlyFloatWrapper}
45 */
46 public ReadOnlyFloatWrapper() {
47 }
48
49 /**
50 * The constructor of {@code ReadOnlyFloatWrapper}
82 super(bean, name, initialValue);
83 }
84
85 /**
86 * Returns the readonly property, that is synchronized with this
87 * {@code ReadOnlyFloatWrapper}.
88 *
89 * @return the readonly property
90 */
91 public ReadOnlyFloatProperty getReadOnlyProperty() {
92 if (readOnlyProperty == null) {
93 readOnlyProperty = new ReadOnlyPropertyImpl();
94 }
95 return readOnlyProperty;
96 }
97
98 /**
99 * {@inheritDoc}
100 */
101 @Override
102 public void addListener(InvalidationListener listener) {
103 getReadOnlyProperty().addListener(listener);
104 }
105
106 /**
107 * {@inheritDoc}
108 */
109 @Override
110 public void removeListener(InvalidationListener listener) {
111 if (readOnlyProperty != null) {
112 readOnlyProperty.removeListener(listener);
113 }
114 }
115
116 /**
117 * {@inheritDoc}
118 */
119 @Override
120 public void addListener(ChangeListener<? super Number> listener) {
121 getReadOnlyProperty().addListener(listener);
122 }
123
124 /**
125 * {@inheritDoc}
126 */
127 @Override
128 public void removeListener(ChangeListener<? super Number> listener) {
129 if (readOnlyProperty != null) {
130 readOnlyProperty.removeListener(listener);
131 }
132 }
133
134 /**
135 * {@inheritDoc}
136 */
137 @Override
138 protected void fireValueChangedEvent() {
139 if (readOnlyProperty != null) {
140 readOnlyProperty.fireValueChangedEvent();
141 }
142 }
143
144 private class ReadOnlyPropertyImpl extends ReadOnlyFloatPropertyBase {
145
146 @Override
147 public float get() {
148 return ReadOnlyFloatWrapper.this.get();
149 }
150
151 @Override
152 public Object getBean() {
153 return ReadOnlyFloatWrapper.this.getBean();
154 }
155
156 @Override
157 public String getName() {
158 return ReadOnlyFloatWrapper.this.getName();
|
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package javafx.beans.property;
27
28 /**
29 * This class provides a convenient class to define read-only properties. It
30 * creates two properties that are synchronized. One property is read-only
31 * and can be passed to external users. The other property is read- and
32 * writable and should be used internally only.
33 *
34 * @since JavaFX 2.0
35 */
36 public class ReadOnlyFloatWrapper extends SimpleFloatProperty {
37
38 private ReadOnlyPropertyImpl readOnlyProperty;
39
40 /**
41 * The constructor of {@code ReadOnlyFloatWrapper}
42 */
43 public ReadOnlyFloatWrapper() {
44 }
45
46 /**
47 * The constructor of {@code ReadOnlyFloatWrapper}
79 super(bean, name, initialValue);
80 }
81
82 /**
83 * Returns the readonly property, that is synchronized with this
84 * {@code ReadOnlyFloatWrapper}.
85 *
86 * @return the readonly property
87 */
88 public ReadOnlyFloatProperty getReadOnlyProperty() {
89 if (readOnlyProperty == null) {
90 readOnlyProperty = new ReadOnlyPropertyImpl();
91 }
92 return readOnlyProperty;
93 }
94
95 /**
96 * {@inheritDoc}
97 */
98 @Override
99 protected void fireValueChangedEvent() {
100 super.fireValueChangedEvent();
101 if (readOnlyProperty != null) {
102 readOnlyProperty.fireValueChangedEvent();
103 }
104 }
105
106 private class ReadOnlyPropertyImpl extends ReadOnlyFloatPropertyBase {
107
108 @Override
109 public float get() {
110 return ReadOnlyFloatWrapper.this.get();
111 }
112
113 @Override
114 public Object getBean() {
115 return ReadOnlyFloatWrapper.this.getBean();
116 }
117
118 @Override
119 public String getName() {
120 return ReadOnlyFloatWrapper.this.getName();
|