1173N/A/*
2362N/A * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
1173N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1173N/A *
1173N/A * This code is free software; you can redistribute it and/or modify it
1173N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
1173N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
1173N/A *
1173N/A * This code is distributed in the hope that it will be useful, but WITHOUT
1173N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1173N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1173N/A * version 2 for more details (a copy is included in the LICENSE file that
1173N/A * accompanied this code).
1173N/A *
1173N/A * You should have received a copy of the GNU General Public License version
1173N/A * 2 along with this work; if not, write to the Free Software Foundation,
1173N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1173N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
1173N/A */
1173N/Apackage ${PACKAGE};
1173N/A
1173N/Aimport java.awt.*;
1173N/Aimport java.awt.geom.*;
1173N/Aimport java.awt.image.*;
1173N/Aimport javax.swing.*;
1173N/Aimport javax.swing.Painter;
1173N/A
1173N/A
1347N/Afinal class ${PAINTER_NAME} extends AbstractRegionPainter {
1173N/A //package private integers representing the available states that
1173N/A //this painter will paint. These are used when creating a new instance
1173N/A //of ${PAINTER_NAME} to determine which region/state is being painted
1173N/A //by that instance.
1173N/A${STATIC_DECL}
1173N/A
1173N/A private int state; //refers to one of the static final ints above
1173N/A private PaintContext ctx;
1173N/A
1173N/A //the following 4 variables are reused during the painting code of the layers
1173N/A private Path2D path = new Path2D.Float();
1173N/A private Rectangle2D rect = new Rectangle2D.Float(0, 0, 0, 0);
1173N/A private RoundRectangle2D roundRect = new RoundRectangle2D.Float(0, 0, 0, 0, 0, 0);
1173N/A private Ellipse2D ellipse = new Ellipse2D.Float(0, 0, 0, 0);
1173N/A
1173N/A //All Colors used for painting are stored here. Ideally, only those colors being used
1173N/A //by a particular instance of ${PAINTER_NAME} would be created. For the moment at least,
1173N/A //however, all are created for each instance.
1173N/A${COLORS_DECL}
1173N/A
1173N/A //Array of current component colors, updated in each paint call
1173N/A private Object[] componentColors;
1173N/A
1173N/A public ${PAINTER_NAME}(PaintContext ctx, int state) {
1173N/A super();
1173N/A this.state = state;
1173N/A this.ctx = ctx;
1173N/A }
1173N/A
1173N/A @Override
1173N/A protected void doPaint(Graphics2D g, JComponent c, int width, int height, Object[] extendedCacheKeys) {
1173N/A //populate componentColors array with colors calculated in getExtendedCacheKeys call
1173N/A componentColors = extendedCacheKeys;
1173N/A //generate this entire method. Each state/bg/fg/border combo that has
1173N/A //been painted gets its own KEY and paint method.
1173N/A switch(state) {
1173N/A${DO_PAINT_SWITCH_BODY}
1173N/A }
1173N/A }
1173N/A
1173N/A${GET_EXTENDED_CACHE_KEYS}
1173N/A
1173N/A @Override
1173N/A protected final PaintContext getPaintContext() {
1173N/A return ctx;
1173N/A }
1173N/A
1173N/A${PAINTING_DECL}
1173N/A
1173N/A${SHAPES_DECL}
1173N/A
1173N/A${GRADIENTS_DECL}
1173N/A}