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      */
  57     ObjectProperty<ToggleGroup> toggleGroupProperty();
  58 
  59     /**
  60      * Indicates whether this {@code Toggle} is selected.
  61      * @return {@code true} if this {@code Toggle} is selected.
  62      */
  63     boolean isSelected();
  64 
  65     /**
  66      * Sets this {@code Toggle} as selected or unselected.
  67      *
  68      * @param selected {@code true} to make this {@code Toggle} selected.
  69      */
  70     void setSelected(boolean selected);
  71 
  72     /**
  73      * The selected state for this {@code Toggle}.
  74      */
  75     BooleanProperty selectedProperty();
  76 
  77     /**
  78      * Returns a previously set Object property, or null if no such property
  79      * has been set using the {@code Node.setUserData(java.lang.Object)} method.
  80      *
  81      * @return The Object that was previously set, or null if no property
  82      *          has been set or if null was set.
  83      */
  84     Object getUserData();
  85 
  86     /**
  87      * Convenience method for setting a single Object property that can be
  88      * retrieved at a later date. This is functionally equivalent to calling
  89      * the getProperties().put(Object key, Object value) method. This can later
  90      * be retrieved by calling {@code Node.getUserData()}.
  91      *
  92      * @param value The value to be stored - this can later be retrieved by calling
  93      *          {@code Node.getUserData()}.
  94      */
  95     void setUserData(Object value);
  96 
  97     /**
  98      * Returns an observable map of properties on this toggle for use primarily
  99      * by application developers.
 100      *
 101      * @return An observable map of properties on this toggle for use primarily
 102      * by application developers
 103      */
 104     ObservableMap<Object, Object> getProperties();
 105 }