KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SOFA > SOFAnode > Made > CDL > ConsoleLogger


1 /* $Id: ConsoleLogger.java,v 1.1.1.1 2003/02/11 16:19:40 bures Exp $ */
2 package SOFA.SOFAnode.Made.CDL;
3
4 /** Logger class for console.
5   *
6   * @author Petr Hnetynka
7   */

8 public class ConsoleLogger implements ILogger {
9   protected int color; // current color
10
private boolean useColor; // if setColor was used
11

12   public ConsoleLogger() {
13     color = 1;
14     useColor = false;
15   }
16
17   private void printColor(int c) {
18     switch (color) {
19       case Black: System.out.println("\033[30m"); break;
20       case White: System.out.println("\033[37m"); break;
21       case Yellow: System.out.println("\033[33m"); break;
22       case Green: System.out.println("\033[32m"); break;
23       case Red: System.out.println("\033[31m"); break;
24       case Blue: System.out.println("\033[34m"); break;
25       case Magenta: System.out.println("\033[35m"); break;
26       case Cyan: System.out.println("\033[36m"); break;
27     }
28   }
29
30   public void print(String JavaDoc s) {
31     System.out.print(s);
32   }
33   public void print(Object JavaDoc o) {
34     System.out.print(o);
35   }
36   public void println(String JavaDoc s) {
37     System.out.println(s);
38   }
39   public void println(Object JavaDoc o) {
40     System.out.println(o);
41   }
42   public void flush() {
43     System.out.flush();
44   }
45
46   public void setColor(int color) {
47     this.color = color;
48     useColor = true;
49     printColor(color);
50   }
51
52   public int getColor() {
53     return color;
54   }
55   
56   public boolean supportColors() {
57     return true;
58   }
59
60   public void reset() {}
61   public boolean supportReset() {
62     return false;
63   }
64 }
65
Popular Tags