com.sun.javafx.scene.control.LabeledImpl Maven / Gradle / Ivy
/*
* Copyright (c) 2011, 2016, 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.
*/
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.sun.javafx.scene.control;
import javafx.beans.InvalidationListener;
import javafx.beans.Observable;
import javafx.scene.control.Label;
import javafx.scene.control.Labeled;
import javafx.css.CssMetaData;
import javafx.css.StyleOrigin;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javafx.css.Styleable;
import javafx.css.StyleableProperty;
import javafx.scene.layout.Region;
public class LabeledImpl extends Label {
public LabeledImpl(final Labeled labeled) {
shuttler = new Shuttler(this, labeled);
}
private final Shuttler shuttler;
private static void initialize(Shuttler shuttler, LabeledImpl labeledImpl, Labeled labeled) {
labeledImpl.setText(labeled.getText());
labeled.textProperty().addListener(shuttler);
labeledImpl.setGraphic(labeled.getGraphic());
labeled.graphicProperty().addListener(shuttler);
final List> styleables = StyleableProperties.STYLEABLES_TO_MIRROR;
for(int n=0, nMax=styleables.size(); n styleable = (CssMetaData)styleables.get(n);
// the Labeled isn't necessarily a Label, so skip the skin or
// we'll get an argument type mismatch on the invocation of the
// skin constructor.
if ("-fx-skin".equals(styleable.getProperty())) continue;
final StyleableProperty> fromVal = styleable.getStyleableProperty(labeled);
if (fromVal instanceof Observable) {
// listen for changes to this property
((Observable)fromVal).addListener(shuttler);
// set this LabeledImpl's property to the same value as the Labeled.
final StyleOrigin origin = fromVal.getStyleOrigin();
if (origin == null) continue;
final StyleableProperty
© 2015 - 2024 Weber Informatics LLC | Privacy Policy