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.scene.control;
27
28
29 import com.sun.javafx.beans.IDProperty;
30 import com.sun.javafx.css.StyleManager;
31 import com.sun.javafx.stage.PopupWindowHelper;
32
33 import javafx.css.SimpleStyleableBooleanProperty;
34 import javafx.css.SimpleStyleableDoubleProperty;
35 import javafx.css.SimpleStyleableObjectProperty;
36 import javafx.css.StyleOrigin;
37 import javafx.css.StyleableObjectProperty;
38 import javafx.css.StyleableStringProperty;
39
40 import javafx.css.converter.BooleanConverter;
41 import javafx.css.converter.EnumConverter;
42 import javafx.css.converter.SizeConverter;
43 import javafx.css.converter.StringConverter;
44 import javafx.css.converter.DurationConverter;
45 import javafx.scene.control.skin.TooltipSkin;
46
47 import java.util.ArrayList;
48 import java.util.Collections;
49 import java.util.List;
50
251
252 /**
253 * The default font to use for text in the Tooltip. If the Tooltip's text is
254 * rich text then this font may or may not be used depending on the font
255 * information embedded in the rich text, but in any case where a default
256 * font is required, this font will be used.
257 */
258 public final ObjectProperty<Font> fontProperty() {
259 return font;
260 }
261 public final void setFont(Font value) {
262 fontProperty().setValue(value);
263 }
264 public final Font getFont() {
265 return fontProperty().getValue();
266 }
267 private final ObjectProperty<Font> font = new StyleableObjectProperty<Font>(Font.getDefault()) {
268 private boolean fontSetByCss = false;
269
270 @Override public void applyStyle(StyleOrigin newOrigin, Font value) {
271 // RT-20727 - if CSS is setting the font, then make sure invalidate doesn't call impl_reapplyCSS
272 try {
273 // super.applyStyle calls set which might throw if value is bound.
274 // Have to make sure fontSetByCss is reset.
275 fontSetByCss = true;
276 super.applyStyle(newOrigin, value);
277 } catch(Exception e) {
278 throw e;
279 } finally {
280 fontSetByCss = false;
281 }
282 }
283
284 @Override public void set(Font value) {
285 final Font oldValue = get();
286 StyleOrigin origin = ((StyleableObjectProperty<Font>)font).getStyleOrigin();
287 if (origin == null || (value != null ? !value.equals(oldValue) : oldValue != null)) {
288 super.set(value);
289 }
290 }
291
292 @Override protected void invalidated() {
293 // RT-20727 - if font is changed by calling setFont, then
294 // css might need to be reapplied since font size affects
295 // calculated values for styles with relative values
296 if(fontSetByCss == false) {
297 Tooltip.this.bridge.impl_reapplyCSS();
298 }
299 }
300
301 @Override public CssMetaData<Tooltip.CSSBridge,Font> getCssMetaData() {
302 return FONT;
303 }
304
305 @Override public Object getBean() {
306 return Tooltip.this;
307 }
308
309 @Override public String getName() {
310 return "font";
311 }
312 };
313
314
315 /**
316 * The delay between the mouse entering the hovered node and when the associated tooltip will be shown to the user.
317 * The default delay is 1000ms.
|
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.scene.control;
27
28
29 import com.sun.javafx.beans.IDProperty;
30 import com.sun.javafx.css.StyleManager;
31 import com.sun.javafx.scene.NodeHelper;
32 import com.sun.javafx.stage.PopupWindowHelper;
33
34 import javafx.css.SimpleStyleableBooleanProperty;
35 import javafx.css.SimpleStyleableDoubleProperty;
36 import javafx.css.SimpleStyleableObjectProperty;
37 import javafx.css.StyleOrigin;
38 import javafx.css.StyleableObjectProperty;
39 import javafx.css.StyleableStringProperty;
40
41 import javafx.css.converter.BooleanConverter;
42 import javafx.css.converter.EnumConverter;
43 import javafx.css.converter.SizeConverter;
44 import javafx.css.converter.StringConverter;
45 import javafx.css.converter.DurationConverter;
46 import javafx.scene.control.skin.TooltipSkin;
47
48 import java.util.ArrayList;
49 import java.util.Collections;
50 import java.util.List;
51
252
253 /**
254 * The default font to use for text in the Tooltip. If the Tooltip's text is
255 * rich text then this font may or may not be used depending on the font
256 * information embedded in the rich text, but in any case where a default
257 * font is required, this font will be used.
258 */
259 public final ObjectProperty<Font> fontProperty() {
260 return font;
261 }
262 public final void setFont(Font value) {
263 fontProperty().setValue(value);
264 }
265 public final Font getFont() {
266 return fontProperty().getValue();
267 }
268 private final ObjectProperty<Font> font = new StyleableObjectProperty<Font>(Font.getDefault()) {
269 private boolean fontSetByCss = false;
270
271 @Override public void applyStyle(StyleOrigin newOrigin, Font value) {
272 // RT-20727 - if CSS is setting the font, then make sure invalidate doesn't call NodeHelper.reapplyCSS
273 try {
274 // super.applyStyle calls set which might throw if value is bound.
275 // Have to make sure fontSetByCss is reset.
276 fontSetByCss = true;
277 super.applyStyle(newOrigin, value);
278 } catch(Exception e) {
279 throw e;
280 } finally {
281 fontSetByCss = false;
282 }
283 }
284
285 @Override public void set(Font value) {
286 final Font oldValue = get();
287 StyleOrigin origin = ((StyleableObjectProperty<Font>)font).getStyleOrigin();
288 if (origin == null || (value != null ? !value.equals(oldValue) : oldValue != null)) {
289 super.set(value);
290 }
291 }
292
293 @Override protected void invalidated() {
294 // RT-20727 - if font is changed by calling setFont, then
295 // css might need to be reapplied since font size affects
296 // calculated values for styles with relative values
297 if(fontSetByCss == false) {
298 NodeHelper.reapplyCSS(Tooltip.this.bridge);
299 }
300 }
301
302 @Override public CssMetaData<Tooltip.CSSBridge,Font> getCssMetaData() {
303 return FONT;
304 }
305
306 @Override public Object getBean() {
307 return Tooltip.this;
308 }
309
310 @Override public String getName() {
311 return "font";
312 }
313 };
314
315
316 /**
317 * The delay between the mouse entering the hovered node and when the associated tooltip will be shown to the user.
318 * The default delay is 1000ms.
|