2417 lines · 97.2 KB · Java
RawDownload
/* * Copyright (c) 2002, 2005, 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. */package javax.swing.plaf.synth; import java.awt.*; /** * <code>SynthPainter</code> is used for painting portions of * <code>JComponent</code>s. At a minimum each <code>JComponent</code> * has two paint methods: one for the border and one for the background. Some * <code>JComponent</code>s have more than one <code>Region</code>, and as * a consequence more paint methods. * <p> * Instances of <code>SynthPainter</code> are obtained from the * {@link javax.swing.plaf.synth.SynthStyle#getPainter} method. * <p> * You typically supply a <code>SynthPainter</code> by way of Synth's * <a href="doc-files/synthFileFormat.html">file</a> format. The following * example registers a painter for all <code>JButton</code>s that will * render the image <code>myImage.png</code>: * <pre> *  &lt;style id="buttonStyle"> *    &lt;imagePainter path="myImage.png" sourceInsets="2 2 2 2" *                  paintCenter="true" stretch="true"/> *    &lt;insets top="2" bottom="2" left="2" right="2"/> *  &lt;/style> *  &lt;bind style="buttonStyle" type="REGION" key="button"/> *</pre> * <p> * <code>SynthPainter</code> is abstract in so far as it does no painting, * all the methods * are empty. While none of these methods are typed to throw an exception, * subclasses can assume that valid arguments are passed in, and if not * they can throw a <code>NullPointerException</code> or * <code>IllegalArgumentException</code> in response to invalid arguments. * * @since 1.5 * @author Scott Violet */public abstract class SynthPainter {    /**     * Used to avoid null painter checks everywhere.     */    static SynthPainter NULL_PAINTER = new SynthPainter() {};      /**     * Paints the background of an arrow button. Arrow buttons are created by     * some components, such as <code>JScrollBar</code>.     *     * @param context SynthContext identifying the <code>JComponent</code> and     *        <code>Region</code> to paint to     * @param g <code>Graphics</code> to paint to     * @param x X coordinate of the area to paint to     * @param y Y coordinate of the area to paint to     * @param w Width of the area to paint to     * @param h Height of the area to paint to     */    public void paintArrowButtonBackground(SynthContext context,                                           Graphics g, int x, int y,                                           int w, int h) {    }     /**     * Paints the border of an arrow button. Arrow buttons are created by     * some components, such as <code>JScrollBar</code>.     *     * @param context SynthContext identifying the <code>JComponent</code> and     *        <code>Region</code> to paint to     * @param g <code>Graphics</code> to paint to     * @param x X coordinate of the area to paint to     * @param y Y coordinate of the area to paint to     * @param w Width of the area to paint to     * @param h Height of the area to paint to     */    public void paintArrowButtonBorder(SynthContext context,                                       Graphics g, int x, int y,                                       int w, int h) {    }     /**     * Paints the foreground of an arrow button. This method is responsible     * for drawing a graphical representation of a direction, typically     * an arrow. Arrow buttons are created by     * some components, such as <code>JScrollBar</code>     *     * @param context SynthContext identifying the <code>JComponent</code> and     *        <code>Region</code> to paint to     * @param g <code>Graphics</code> to paint to     * @param x X coordinate of the area to paint to     * @param y Y coordinate of the area to paint to     * @param w Width of the area to paint to     * @param h Height of the area to paint to     * @param direction One of SwingConstants.NORTH, SwingConstants.SOUTH     *                  SwingConstants.EAST or SwingConstants.WEST     */    public void paintArrowButtonForeground(SynthContext context,                                           Graphics g, int x, int y,                                           int w, int h,                                           int direction) {    }     /**     * Paints the background of a button.     *     * @param context SynthContext identifying the <code>JComponent</code> and     *        <code>Region</code> to paint to     * @param g <code>Graphics</code> to paint to     * @param x X coordinate of the area to paint to     * @param y Y coordinate of the area to paint to     * @param w Width of the area to paint to     * @param h Height of the area to paint to     */    public void paintButtonBackground(SynthContext context,                                      Graphics g, int x, int y,                                      int w, int h) {    }     /**     * Paints the border of a button.     *     * @param context SynthContext identifying the <code>JComponent</code> and     *        <code>Region</code> to paint to     * @param g <code>Graphics</code> to paint to     * @param x X coordinate of the area to paint to     * @param y Y coordinate of the area to paint to     * @param w Width of the area to paint to     * @param h Height of the area to paint to     */    public void paintButtonBorder(SynthContext context,                                  Graphics g, int x, int y,                                  int w, int h) {    }     /**     * Paints the background of a check box menu item.     *     * @param context SynthContext identifying the <code>JComponent</code> and     *        <code>Region</code> to paint to     * @param g <code>Graphics</code> to paint to     * @param x X coordinate of the area to paint to     * @param y Y coordinate of the area to paint to     * @param w Width of the area to paint to     * @param h Height of the area to paint to     */    public void paintCheckBoxMenuItemBackground(SynthContext context,                                                Graphics g, int x, int y,                                                int w, int h) {    }     /**     * Paints the border of a check box menu item.     *     * @param context SynthContext identifying the <code>JComponent</code> and     *        <code>Region</code> to paint to     * @param g <code>Graphics</code> to paint to     * @param x X coordinate of the area to paint to     * @param y Y coordinate of the area to paint to     * @param w Width of the area to paint to     * @param h Height of the area to paint to     */    public void paintCheckBoxMenuItemBorder(SynthContext context,                                            Graphics g, int x, int y,                                            int w, int h) {    }     /**     * Paints the background of a check box.     *     * @param context SynthContext identifying the <code>JComponent</code> and     *        <code>Region</code> to paint to     * @param g <code>Graphics</code> to paint to     * @param x X coordinate of the area to paint to     * @param y Y coordinate of the area to paint to     * @param w Width of the area to paint to     * @param h Height of the area to paint to     */    public void paintCheckBoxBackground(SynthContext context,                                        Graphics g, int x, int y,                                        int w, int h) {    }     /**     * Paints the border of a check box.     *     * @param context SynthContext identifying the <code>JComponent</code> and     *        <code>Region</code> to paint to     * @param g <code>Graphics</code> to paint to     * @param x X coordinate of the area to paint to     * @param y Y coordinate of the area to paint to     * @param w Width of the area to paint to     * @param h Height of the area to paint to     */    public void paintCheckBoxBorder(SynthContext context,                                    Graphics g, int x, int y,                                    int w, int h) {    }     /**     * Paints the background of a color chooser.     *     * @param context SynthContext identifying the <code>JComponent</code> and     *        <code>Region</code> to paint to     * @param g <code>Graphics</code> to paint to     * @param x X coordinate of the area to paint to     * @param y Y coordinate of the area to paint to     * @param w Width of the area to paint to     * @param h Height of the area to paint to     */    public void paintColorChooserBackground(SynthContext context,                                            Graphics g, int x, int y,                                            int w, int h) {    }     /**     * Paints the border of a color chooser.     *     * @param context SynthContext identifying the <code>JComponent</code> and     *        <code>Region</code> to paint to     * @param g <code>Graphics</code> to paint to     * @param x X coordinate of the area to paint to     * @param y Y coordinate of the area to paint to     * @param w Width of the area to paint to     * @param h Height of the area to paint to     */    public void paintColorChooserBorder(SynthContext context,                                        Graphics g, int x, int y,                                        int w, int h) {    }     /**     * Paints the background of a combo box.     *     * @param context SynthContext identifying the <code>JComponent</code> and     *        <code>Region</code> to paint to     * @param g <code>Graphics</code> to paint to     * @param x X coordinate of the area to paint to     * @param y Y coordinate of the area to paint to     * @param w Width of the area to paint to     * @param h Height of the area to paint to     */    public void paintComboBoxBackground(SynthContext context,                                        Graphics g, int x, int y,                                        int w, int h) {    }     /**     * Paints the border of a combo box.     *     * @param context SynthContext identifying the <code>JComponent</code> and     *        <code>Region</code> to paint to     * @param g <code>Graphics</code> to paint to     * @param x X coordinate of the area to paint to     * @param y Y coordinate of the area to paint to     * @param w Width of the area to paint to     * @param h Height of the area to paint to     */    public void paintComboBoxBorder(SynthContext context,                                        Graphics g, int x, int y,                                        int w, int h) {    }     /**     * Paints the background of a desktop icon.     *     * @param context SynthContext identifying the <code>JComponent</code> and     *        <code>Region</code> to paint to     * @param g <code>Graphics</code> to paint to     * @param x X coordinate of the area to paint to     * @param y Y coordinate of the area to paint to     * @param w Width of the area to paint to     * @param h Height of the area to paint to     */    public void paintDesktopIconBackground(SynthContext context,                                        Graphics g, int x, int y,                                        int w, int h) {    }     /**     * Paints the border of a desktop icon.     *     * @param context SynthContext identifying the <code>JComponent</code> and     *        <code>Region</code> to paint to     * @param g <code>Graphics</code> to paint to     * @param x X coordinate of the area to paint to     * @param y Y coordinate of the area to paint to     * @param w Width of the area to paint to     * @param h Height of the area to paint to     */    public void paintDesktopIconBorder(SynthContext context,                                           Graphics g, int x, int y,                                           int w, int h) {    }     /**     * Paints the background of a desktop pane.     *     * @param context SynthContext identifying the <code>JComponent</code> and     *        <code>Region</code> to paint to     * @param g <code>Graphics</code> to paint to     * @param x X coordinate of the area to paint to     * @param y Y coordinate of the area to paint to     * @param w Width of the area to paint to     * @param h Height of the area to paint to     */    public void paintDesktopPaneBackground(SynthContext context,                                           Graphics g, int x, int y,                                           int w, int h) {    }     /**     * Paints the background of a desktop pane.     *     * @param context SynthContext identifying the <code>JComponent</code> and     *        <code>Region</code> to paint to     * @param g <code>Graphics</code> to paint to     * @param x X coordinate of the area to paint to     * @param y Y coordinate of the area to paint to     * @param w Width of the area to paint to     * @param h Height of the area to paint to     */    public void paintDesktopPaneBorder(SynthContext context,                                       Graphics g, int x, int y,                                       int w, int h) {    }     /**     * Paints the background of an editor pane.     *     * @param context SynthContext identifying the <code>JComponent</code> and     *        <code>Region</code> to paint to     * @param g <code>Graphics</code> to paint to     * @param x X coordinate of the area to paint to     * @param y Y coordinate of the area to paint to     * @param w Width of the area to paint to     * @param h Height of the area to paint to     */    public void paintEditorPaneBackground(SynthContext context,                                          Graphics g, int x, int y,                                          int w, int h) {    }     /**     * Paints the border of an editor pane.     *     * @param context SynthContext identifying the <code>JComponent</code> and     *        <code>Region</code> to paint to     * @param g <code>Graphics</code> to paint to     * @param x X coordinate of the area to paint to     * @param y Y coordinate of the area to paint to     * @param w Width of the area to paint to     * @param h Height of the area to paint to     */    public void paintEditorPaneBorder(SynthContext context,                                      Graphics g, int x, int y,                                      int w, int h) {    }     /**     * Paints the background of a file chooser.     *     * @param context SynthContext identifying the <code>JComponent</code> and     *        <code>Region</code> to paint to     * @param g <code>Graphics</code> to paint to     * @param x X coordinate of the area to paint to     * @param y Y coordinate of the area to paint to     * @param w Width of the area to paint to     * @param h Height of the area to paint to     */    public void paintFileChooserBackground(SynthContext context,                                          Graphics g, int x, int y,                                          int w, int h) {    }     /**     * Paints the border of a file chooser.     *     * @param context SynthContext identifying the <code>JComponent</code> and     *        <code>Region</code> to paint to     * @param g <code>Graphics</code> to paint to     * @param x X coordinate of the area to paint to     * @param y Y coordinate of the area to paint to     * @param w Width of the area to paint to     * @param h Height of the area to paint to     */    public void paintFileChooserBorder(SynthContext context,                                      Graphics g, int x, int y,                                      int w, int h) {    }     /**     * Paints the background of a formatted text field.     *     * @param context SynthContext identifying the <code>JComponent</code> and     *        <code>Region</code> to paint to     * @param g <code>Graphics</code> to paint to     * @param x X coordinate of the area to paint to     * @param y Y coordinate of the area to paint to     * @param w Width of the area to paint to     * @param h Height of the area to paint to     */    public void paintFormattedTextFieldBackground(SynthContext context,                                          Graphics g, int x, int y,                                          int w, int h) {    }     /**     * Paints the border of a formatted text field.     *     * @param context SynthContext identifying the <code>JComponent</code> and     *        <code>Region</code> to paint to     * @param g <code>Graphics</code> to paint to     * @param x X coordinate of the area to paint to     * @param y Y coordinate of the area to paint to     * @param w Width of the area to paint to     * @param h Height of the area to paint to     */    public void paintFormattedTextFieldBorder(SynthContext context,                                      Graphics g, int x, int y,                                      int w, int h) {    }     /**     * Paints the background of an internal frame title pane.     *     * @param context SynthContext identifying the <code>JComponent</code> and     *        <code>Region</code> to paint to     * @param g <code>Graphics</code> to paint to     * @param x X coordinate of the area to paint to     * @param y Y coordinate of the area to paint to     * @param w Width of the area to paint to     * @param h Height of the area to paint to     */    public void paintInternalFrameTitlePaneBackground(SynthContext context,                                          Graphics g, int x, int y,                                          int w, int h) {    }     /**     * Paints the border of an internal frame title pane.     *     * @param context SynthContext identifying the <code>JComponent</code> and     *        <code>Region</code> to paint to     * @param g <code>Graphics</code> to paint to     * @param x X coordinate of the area to paint to     * @param y Y coordinate of the area to paint to     * @param w Width of the area to paint to     * @param h Height of the area to paint to     */    public void paintInternalFrameTitlePaneBorder(SynthContext context,                                      Graphics g, int x, int y,                                      int w, int h) {    }     /**     * Paints the background of an internal frame.     *     * @param context SynthContext identifying the <code>JComponent</code> and     *        <code>Region</code> to paint to     * @param g <code>Graphics</code> to paint to     * @param x X coordinate of the area to paint to     * @param y Y coordinate of the area to paint to     * @param w Width of the area to paint to     * @param h Height of the area to paint to     */    public void paintInternalFrameBackground(SynthContext context,                                          Graphics g, int x, int y,                                          int w, int h) {    }     /**     * Paints the border of an internal frame.     *     * @param context SynthContext identifying the <code>JComponent</code> and     *        <code>Region</code> to paint to     * @param g <code>Graphics</code> to paint to     * @param x X coordinate of the area to paint to     * @param y Y coordinate of the area to paint to

Lines 1–500 of 2417.