1 /*
   2  * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   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.scene.control;
  27 
  28 import javafx.beans.property.BooleanProperty;
  29 import javafx.beans.property.ObjectProperty;
  30 import javafx.collections.ObservableMap;
  31 
  32 /**
  33  * Represents a control that can be toggled between selected and non-selected
  34  * states. In addition, a Toggle can be assigned a
  35  * <code>{@link ToggleGroup}</code>, which manages all assigned Toggles such
  36  * that only a single Toggle within the <code>{@link ToggleGroup}</code> may be
  37  * selected at any one time.
  38  * @since JavaFX 2.0
  39  */
  40 public interface Toggle {
  41 
  42     /**
  43      * Returns The {@link ToggleGroup} to which this {@code Toggle} belongs.
  44      * @return The {@link ToggleGroup} to which this {@code Toggle} belongs.
  45      */
  46     ToggleGroup getToggleGroup();
  47 
  48     /**
  49      * Sets the {@link ToggleGroup} to which this {@code Toggle} belongs.
  50      * @param toggleGroup The new {@link ToggleGroup}.
  51      */
  52     void setToggleGroup(ToggleGroup toggleGroup);
  53 
  54     /**
  55      * The {@link ToggleGroup} to which this {@code Toggle} belongs.
  56      * @return the toggle group property
  57      */
  58     ObjectProperty<ToggleGroup> toggleGroupProperty();
  59 
  60     /**
  61      * Indicates whether this {@code Toggle} is selected.
  62      * @return {@code true} if this {@code Toggle} is selected.
  63      */
  64     boolean isSelected();
  65 
  66     /**
  67      * Sets this {@code Toggle} as selected or unselected.
  68      *
  69      * @param selected {@code true} to make this {@code Toggle} selected.
  70      */
  71     void setSelected(boolean selected);
  72 
  73     /**
  74      * The selected state for this {@code Toggle}.
  75      * @return the selected property
  76      */
  77     BooleanProperty selectedProperty();
  78 
  79     /**
  80      * Returns a previously set Object property, or null if no such property
  81      * has been set using the {@code Node.setUserData(java.lang.Object)} method.
  82      *
  83      * @return The Object that was previously set, or null if no property
  84      *          has been set or if null was set.
  85      */
  86     Object getUserData();
  87 
  88     /**
  89      * Convenience method for setting a single Object property that can be
  90      * retrieved at a later date. This is functionally equivalent to calling
  91      * the getProperties().put(Object key, Object value) method. This can later
  92      * be retrieved by calling {@code Node.getUserData()}.
  93      *
  94      * @param value The value to be stored - this can later be retrieved by calling
  95      *          {@code Node.getUserData()}.
  96      */
  97     void setUserData(Object value);
  98 
  99     /**
 100      * Returns an observable map of properties on this toggle for use primarily
 101      * by application developers.
 102      *
 103      * @return An observable map of properties on this toggle for use primarily
 104      * by application developers
 105      */
 106     ObservableMap<Object, Object> getProperties();
 107 }