KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > java > swing > plaf > nimbus > ViewportPainter


1 /*
2  * ViewportPainter.java %E%
3  *
4  * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7 package com.sun.java.swing.plaf.nimbus;
8
9 import java.awt.*;
10 import java.awt.geom.*;
11 import java.awt.image.*;
12 import javax.swing.*;
13 import com.sun.java.swing.Painter;
14
15 /**
16  */

17 public final class ViewportPainter extends AbstractRegionPainter {
18     //package private integers representing the available states that
19
//this painter will paint. These are used when creating a new instance
20
//of ViewportPainter to determine which region/state is being painted
21
//by that instance.
22

23
24     private int state; //refers to one of the static final ints above
25
private PaintContext ctx;
26
27     //the following 4 variables are reused during the painting code of the layers
28
private Path2D path = new Path2D.Float();
29     private Rectangle2D rect = new Rectangle2D.Float(0, 0, 0, 0);
30     private RoundRectangle2D roundRect = new RoundRectangle2D.Float(0, 0, 0, 0, 0, 0);
31     private Ellipse2D ellipse = new Ellipse2D.Float(0, 0, 0, 0);
32
33     //All Colors used for painting are stored here. Ideally, only those colors being used
34
//by a particular instance of ViewportPainter would be created. For the moment at least,
35
//however, all are created for each instance.
36

37
38     //Array of current component colors, updated in each paint call
39
private Object JavaDoc[] componentColors;
40
41     public ViewportPainter(PaintContext ctx, int state) {
42         super();
43         this.state = state;
44         this.ctx = ctx;
45     }
46
47     @Override JavaDoc
48     protected void doPaint(Graphics2D g, JComponent c, int width, int height, Object JavaDoc[] extendedCacheKeys) {
49         //populate componentColors array with colors calculated in getExtendedCacheKeys call
50
componentColors = extendedCacheKeys;
51         //generate this entire method. Each state/bg/fg/border combo that has
52
//been painted gets its own KEY and paint method.
53
switch(state) {
54
55         }
56     }
57         
58
59
60     @Override JavaDoc
61     protected final PaintContext getPaintContext() {
62         return ctx;
63     }
64
65
66
67
68
69
70 }
71
Popular Tags