KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > gvt > text > TextPaintInfo


1 /*
2
3    Copyright 2003 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18 package org.apache.batik.gvt.text;
19
20 import java.awt.Composite JavaDoc;
21 import java.awt.Paint JavaDoc;
22 import java.awt.Shape JavaDoc;
23 import java.awt.Stroke JavaDoc;
24
25 /**
26  * One line Class Desc
27  *
28  * Complete Class Desc
29  *
30  * @author <a HREF="mailto:deweese@apache.org">deweese</a>
31  * @version $Id: TextPaintInfo.java,v 1.4 2005/03/27 08:58:35 cam Exp $
32  */

33 public class TextPaintInfo {
34     public boolean visible;
35     public Paint JavaDoc fillPaint;
36     public Paint JavaDoc strokePaint;
37     public Stroke JavaDoc strokeStroke;
38     public Composite JavaDoc composite;
39     
40     public Paint JavaDoc underlinePaint;
41     public Paint JavaDoc underlineStrokePaint;
42     public Stroke JavaDoc underlineStroke;
43     
44     public Paint JavaDoc overlinePaint;
45     public Paint JavaDoc overlineStrokePaint;
46     public Stroke JavaDoc overlineStroke;
47     
48     public Paint JavaDoc strikethroughPaint;
49     public Paint JavaDoc strikethroughStrokePaint;
50     public Stroke JavaDoc strikethroughStroke;
51
52     public TextPaintInfo() { }
53     
54     public TextPaintInfo(TextPaintInfo pi) {
55         set(pi);
56     }
57
58     public void set(TextPaintInfo pi) {
59         if (pi == null) {
60             this.fillPaint = null;
61             this.strokePaint = null;
62             this.strokeStroke = null;
63             this.composite = null;
64         
65             this.underlinePaint = null;
66             this.underlineStrokePaint = null;
67             this.underlineStroke = null;
68         
69             this.overlinePaint = null;
70             this.overlineStrokePaint = null;
71             this.overlineStroke = null;
72         
73             this.strikethroughPaint = null;
74             this.strikethroughStrokePaint = null;
75             this.strikethroughStroke = null;
76
77             this.visible = false;
78         } else {
79             this.fillPaint = pi.fillPaint;
80             this.strokePaint = pi.strokePaint;
81             this.strokeStroke = pi.strokeStroke;
82             this.composite = pi.composite;
83             
84             this.underlinePaint = pi.underlinePaint;
85             this.underlineStrokePaint = pi.underlineStrokePaint;
86             this.underlineStroke = pi.underlineStroke;
87             
88             this.overlinePaint = pi.overlinePaint;
89             this.overlineStrokePaint = pi.overlineStrokePaint;
90             this.overlineStroke = pi.overlineStroke;
91
92             this.strikethroughPaint = pi.strikethroughPaint;
93             this.strikethroughStrokePaint = pi.strikethroughStrokePaint;
94             this.strikethroughStroke = pi.strikethroughStroke;
95
96             this.visible = pi.visible;
97         }
98     }
99
100     public static boolean equivilent(TextPaintInfo tpi1, TextPaintInfo tpi2) {
101         if (tpi1 == null) {
102             if (tpi2 == null) return true;
103             return false;
104         } else if (tpi2 == null) return false;
105
106         if ((tpi1.fillPaint == null) != (tpi2.fillPaint == null))
107             return false;
108
109         if (tpi1.visible != tpi2.visible) return false;
110         
111         boolean tpi1Stroke = ((tpi1.strokePaint != null) &&
112                               (tpi1.strokeStroke != null));
113
114         boolean tpi2Stroke = ((tpi2.strokePaint != null) &&
115                               (tpi2.strokeStroke != null));
116
117         return (tpi1Stroke == tpi2Stroke);
118
119     }
120 }
121
Popular Tags