KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > soot > tagkit > ColorTag


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2003 Jennifer Lhotak
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */

19
20 /*
21  * Modified by the Sable Research Group and others 1997-1999.
22  * See the 'credits' file distributed with Soot for the complete list of
23  * contributors. (Soot is distributed at http://www.sable.mcgill.ca/soot)
24  */

25
26
27 package soot.tagkit;
28
29 import soot.*;
30
31 public class ColorTag implements Tag
32 {
33     /* it is a value representing red. */
34     private int red;
35     /* it is a value representing green. */
36     private int green;
37     /* it is a value representing blue. */
38     private int blue;
39     /* for highlighting foreground of text default is to
40      * higlight background */

41     private boolean foreground = false;
42     private String JavaDoc analysisType = "Unknown";
43     
44     public static final int RED = 0;
45     public static final int GREEN = 1;
46     public static final int YELLOW = 2;
47     public static final int BLUE = 3;
48     public static final int ORANGE = 4;
49     public static final int PURPLE = 5;
50     
51     public ColorTag(int r, int g, int b, boolean fg)
52     {
53         red = r;
54         green = g;
55         blue = b;
56         foreground = fg;
57     }
58     
59     public ColorTag(int r, int g, int b)
60     {
61         this(r, g, b, false);
62     }
63
64     public ColorTag(int r, int g, int b, String JavaDoc type){
65         this(r, g, b, false, type);
66     }
67     
68     public ColorTag(int r, int g, int b, boolean fg, String JavaDoc type){
69         this(r, g, b, false);
70         analysisType = type;
71     }
72
73     public ColorTag(int color, String JavaDoc type){
74         this(color, false, type);
75     }
76     
77     public ColorTag(int color, boolean fg, String JavaDoc type){
78         this(color, fg);
79         analysisType = type;
80     }
81     
82     public ColorTag(int color){
83         this(color, false);
84     }
85     
86     public ColorTag(int color, boolean fg){
87         //G.v().out.println("color: "+color);
88
switch (color) {
89             case RED: {
90                 red = 255;
91                 green = 0;
92                 blue = 0;
93                 break;
94             }
95             case GREEN: {
96                 red = 45;
97                 green = 255;
98                 blue = 84;
99                 break;
100             }
101             case YELLOW: {
102                 red = 255;
103                 green = 248;
104                 blue = 35;
105                 break;
106             }
107             case BLUE: {
108                 red = 174;
109                 green = 210;
110                 blue = 255;
111                 break;
112             }
113             case ORANGE: {
114                 red = 255;
115                 green = 163;
116                 blue = 0;
117                 break;
118             }
119             case PURPLE: {
120                 red = 159;
121                 green = 34;
122                 blue = 193;
123                 break;
124             }
125             default: {
126                 red = 220;
127                 green = 220;
128                 blue = 220;
129                 break;
130             }
131         }
132         foreground = fg;
133     }
134
135     public String JavaDoc getAnalysisType(){
136         return analysisType;
137     }
138     
139     public int getRed(){
140         return red;
141     }
142
143     public int getGreen(){
144         return green;
145     }
146
147     public int getBlue(){
148         return blue;
149     }
150    
151     public boolean isForeground(){
152         return foreground;
153     }
154     
155     public String JavaDoc getName()
156     {
157         return "ColorTag";
158     }
159
160     public byte[] getValue()
161     {
162     byte[] v = new byte[2];
163     return v;
164     }
165
166     public String JavaDoc toString()
167     {
168     return ""+red+" "+green+" "+blue;
169     }
170
171 }
172
Popular Tags