001    /*
002     * $Id: DatePickerUI.java 3100 2008-10-14 22:33:10Z rah003 $
003     *
004     * Copyright 2005 Sun Microsystems, Inc., 4150 Network Circle,
005     * Santa Clara, California 95054, U.S.A. All rights reserved.
006     *
007     * This library is free software; you can redistribute it and/or
008     * modify it under the terms of the GNU Lesser General Public
009     * License as published by the Free Software Foundation; either
010     * version 2.1 of the License, or (at your option) any later version.
011     *
012     * This library is distributed in the hope that it will be useful,
013     * but WITHOUT ANY WARRANTY; without even the implied warranty of
014     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015     * Lesser General Public License for more details.
016     *
017     * You should have received a copy of the GNU Lesser General Public
018     * License along with this library; if not, write to the Free Software
019     * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
020     */
021    package org.jdesktop.swingx.plaf;
022    
023    import java.beans.PropertyVetoException;
024    import java.util.Date;
025    
026    import javax.swing.plaf.ComponentUI;
027    
028    /**
029     * The ComponentUI for a JXDatePicker.
030     * <p>
031     * 
032     * Responsible for keeping the date property of all participants synchronized at
033     * all "stable" points in their life-cycle. That is the following invariant is
034     * guaranteed:
035     * 
036     * <pre><code>
037     * Date selected = datePicker.getMonthView().getSelectedDate();
038     * assertEquals(selected, datePicker.getDate());
039     * assertEquals(selected, datePicker.getEditor().getValue());
040     * </code></pre>
041     * 
042     * @author Joshua Outwater
043     * @author Jeanette Winzenburg
044     */
045    public abstract class DatePickerUI extends ComponentUI {
046        /**
047         * Get the baseline for the specified component, or a value less
048         * than 0 if the baseline can not be determined.  The baseline is measured
049         * from the top of the component.
050         *
051         * @param width  Width of the component to determine baseline for.
052         * @param height Height of the component to determine baseline for.
053         * @return baseline for the specified component
054         */
055        public int getBaseline(int width, int height) {
056            return -1;
057        }
058    
059        /**
060         * Checks the given date for validity for selection. If valid, 
061         * returns the date as appropriate in the picker's context, otherwise
062         * throws a propertyVetoException. Note that the returned date might
063         * be different from the input date, f.i. the time fields might be
064         * cleared. The input date is guaranteed to be unchanged.
065         * 
066         * @param date date to check
067         * @return the date as allowed in the context of the picker.
068         * 
069         * @throws PropertyVetoException if the given date is not valid for 
070         *    selection
071         */
072        public abstract Date getSelectableDate(Date date) throws PropertyVetoException;
073    
074    }