Spec-Zone .ru
спецификации, руководства, описания, API
001/*
002 * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation.  Oracle designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Oracle in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
022 * or visit www.oracle.com if you need additional information or have any
023 * questions.
024 */
025
026package javafx.css;
027
028import javafx.beans.property.SimpleDoubleProperty;
029
030/**
031 * This class extends {@code SimpleDoubleProperty} and provides a full
032 * implementation of a {@code StyleableProperty}.  
033 *
034 * This class is used to make a {@link javafx.beans.property.DoubleProperty},
035 * that would otherwise be implemented as a {@link SimpleDoubleProperty},
036 * style‑able by CSS.
037 *
038 * @see javafx.beans.property.SimpleDoubleProperty
039 * @see CssMetaData
040 * @see StyleableProperty
041 * @see StyleableDoubleProperty
042 */
043public class SimpleStyleableDoubleProperty extends StyleableDoubleProperty {
044
045    private static final Object DEFAULT_BEAN = null;
046    private static final String DEFAULT_NAME = "";
047
048    private final Object bean;
049    private final String name;
050    private final CssMetaData<? extends Styleable, Number> cssMetaData;
051
052    /**
053     * The constructor of the {@code SimpleStyleableDoubleProperty}.
054     * @param cssMetaData
055     *            the CssMetaData associated with this {@code StyleableProperty}
056     */
057    public SimpleStyleableDoubleProperty(CssMetaData<? extends Styleable, Number> cssMetaData) {
058        this(cssMetaData, DEFAULT_BEAN, DEFAULT_NAME);
059    }
060
061    /**
062     * The constructor of the {@code SimpleStyleableDoubleProperty}.
063     *
064     * @param cssMetaData
065     *            the CssMetaData associated with this {@code StyleableProperty}
066     * @param initialValue
067     *            the initial value of the wrapped {@code Object}
068     */
069    public SimpleStyleableDoubleProperty(CssMetaData<? extends Styleable, Number> cssMetaData, Double initialValue) {
070        this(cssMetaData, DEFAULT_BEAN, DEFAULT_NAME, initialValue);
071    }
072
073    /**
074     * The constructor of the {@code SimpleStyleableDoubleProperty}.
075     *
076     * @param cssMetaData
077     *            the CssMetaData associated with this {@code StyleableProperty}
078     * @param bean
079     *            the bean of this {@code DoubleProperty}
080     * @param name
081     *            the name of this {@code DoubleProperty}
082     */
083    public SimpleStyleableDoubleProperty(CssMetaData<? extends Styleable, Number> cssMetaData, Object bean, String name) {
084        this.bean = bean;
085        this.name = (name == null) ? DEFAULT_NAME : name;
086        this.cssMetaData = cssMetaData;
087    }
088
089    /**
090     * The constructor of the {@code SimpleStyleableDoubleProperty}.
091     *
092     * @param cssMetaData
093     *            the CssMetaData associated with this {@code StyleableProperty}
094     * @param bean
095     *            the bean of this {@code DoubleProperty}
096     * @param name
097     *            the name of this {@code DoubleProperty}
098     * @param initialValue
099     *            the initial value of the wrapped {@code Object}
100     */
101    public SimpleStyleableDoubleProperty(CssMetaData<? extends Styleable, Number> cssMetaData, Object bean, String name, Double initialValue) {
102        super(initialValue);
103        this.bean = bean;
104        this.name = (name == null) ? DEFAULT_NAME : name;
105        this.cssMetaData = cssMetaData;
106    }
107
108    /**
109     * {@inheritDoc}
110     */
111    @Override
112    public Object getBean() {
113        return bean;
114    }
115
116    /**
117     * {@inheritDoc}
118     */
119    @Override
120    public String getName() {
121        return name;
122    }
123
124    /** {@inheritDoc} */
125    @Override
126    public final CssMetaData<? extends Styleable, Number> getCssMetaData() {
127        return cssMetaData;
128    }
129
130}