All Downloads are FREE. Search and download functionalities are using the official Maven repository.

soot.tagkit.ColorTag Maven / Gradle / Ivy

package soot.tagkit;

/*-
 * #%L
 * Soot - a J*va Optimization Framework
 * %%
 * Copyright (C) 2003 Jennifer Lhotak
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, either version 2.1 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Lesser Public License for more details.
 * 
 * You should have received a copy of the GNU General Lesser Public
 * License along with this program.  If not, see
 * .
 * #L%
 */

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ColorTag implements Tag {
  private static final Logger logger = LoggerFactory.getLogger(ColorTag.class);
  /* it is a value representing red. */
  private int red;
  /* it is a value representing green. */
  private int green;
  /* it is a value representing blue. */
  private int blue;
  /*
   * for highlighting foreground of text default is to higlight background
   */
  private boolean foreground = false;
  private String analysisType = "Unknown";

  public static final int RED = 0;
  public static final int GREEN = 1;
  public static final int YELLOW = 2;
  public static final int BLUE = 3;
  public static final int ORANGE = 4;
  public static final int PURPLE = 5;

  public ColorTag(int r, int g, int b, boolean fg) {
    red = r;
    green = g;
    blue = b;
    foreground = fg;
  }

  public ColorTag(int r, int g, int b) {
    this(r, g, b, false);
  }

  public ColorTag(int r, int g, int b, String type) {
    this(r, g, b, false, type);
  }

  public ColorTag(int r, int g, int b, boolean fg, String type) {
    this(r, g, b, false);
    analysisType = type;
  }

  public ColorTag(int color, String type) {
    this(color, false, type);
  }

  public ColorTag(int color, boolean fg, String type) {
    this(color, fg);
    analysisType = type;
  }

  public ColorTag(int color) {
    this(color, false);
  }

  public ColorTag(int color, boolean fg) {
    // logger.debug("color: "+color);
    switch (color) {
      case RED: {
        red = 255;
        green = 0;
        blue = 0;
        break;
      }
      case GREEN: {
        red = 45;
        green = 255;
        blue = 84;
        break;
      }
      case YELLOW: {
        red = 255;
        green = 248;
        blue = 35;
        break;
      }
      case BLUE: {
        red = 174;
        green = 210;
        blue = 255;
        break;
      }
      case ORANGE: {
        red = 255;
        green = 163;
        blue = 0;
        break;
      }
      case PURPLE: {
        red = 159;
        green = 34;
        blue = 193;
        break;
      }
      default: {
        red = 220;
        green = 220;
        blue = 220;
        break;
      }
    }
    foreground = fg;
  }

  public String getAnalysisType() {
    return analysisType;
  }

  public int getRed() {
    return red;
  }

  public int getGreen() {
    return green;
  }

  public int getBlue() {
    return blue;
  }

  public boolean isForeground() {
    return foreground;
  }

  public String getName() {
    return "ColorTag";
  }

  public byte[] getValue() {
    byte[] v = new byte[2];
    return v;
  }

  public String toString() {
    return "" + red + " " + green + " " + blue;
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy