001 /* 002 * This file is part of the Jikes RVM project (http://jikesrvm.org). 003 * 004 * This file is licensed to You under the Eclipse Public License (EPL); 005 * You may not use this file except in compliance with the License. You 006 * may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/eclipse-1.0.php 009 * 010 * See the COPYRIGHT.txt file distributed with this work for information 011 * regarding copyright ownership. 012 */ 013 package org.mmtk.utility.gcspy; 014 015 import org.mmtk.vm.VM; 016 017 import org.vmmagic.pragma.*; 018 019 /** 020 * Cut-down implementation of java.awt.Color sufficient to provide 021 * the server side (Stream) with colours 022 */ 023 @Uninterruptible public class Color { 024 025 /*Some gcspy standard colours (taken from gcspy_color_db.c). */ 026 public static final Color Black = new Color(0, 0, 0); 027 public static final Color Blue = new Color(0, 0, 255); 028 public static final Color Cyan = new Color(0, 255, 255); 029 public static final Color DarkGray = new Color(64, 64, 64); 030 public static final Color Gray = new Color(128, 128, 128); 031 public static final Color Green = new Color(0, 255, 0); 032 public static final Color LightGray = new Color(192, 192, 192); 033 public static final Color Magenta = new Color(255, 0, 255); 034 public static final Color MidGray = new Color(160, 160, 160); 035 public static final Color NavyBlue = new Color(0, 0, 150); 036 public static final Color OffWhite = new Color(230, 230, 230); 037 public static final Color Orange = new Color(255, 200, 0); 038 public static final Color Pink = new Color(255, 175, 175); 039 public static final Color Red = new Color(255, 0, 0); 040 public static final Color White = new Color(255, 255, 255); 041 public static final Color Yellow = new Color(255, 255, 0); 042 043 private short r; // red component 044 private short g; // green component 045 private short b; // blue component 046 047 /** 048 * Constructor for a simple RGB colour model. 049 * 050 * @param r red component 051 * @param g green component 052 * @param b blue component 053 */ 054 public Color(short r, short g, short b) { 055 if (VM.VERIFY_ASSERTIONS) 056 VM.assertions._assert((0 <= r) && (r <= 255) && 057 (0 <= g) && (g <= 255) && 058 (0 <= b) && (b <= 255)); 059 this.r = r; 060 this.g = g; 061 this.b = b; 062 } 063 064 /** 065 * Constructor for a simple RGB colour model. 066 * 067 * @param r red component 068 * @param g green component 069 * @param b blue component 070 */ 071 private Color(int r, int g, int b) { 072 this((short) r, (short) g, (short) b); 073 } 074 075 076 /** 077 * Red component 078 * 079 * @return the red component 080 */ 081 public short getRed() { return r; } 082 083 /** 084 * Green component 085 * 086 * @return the green component 087 */ 088 public short getGreen() { return g; } 089 090 /** 091 * Blue component 092 * 093 * @return the blue component 094 */ 095 public short getBlue() { return b; } 096 }