示例#1
0
  /**
   * Initializes colors.
   *
   * @param prop gui properties
   */
  public static void init(final GUIProp prop) {
    final int r = prop.num(GUIProp.COLORRED);
    final int g = prop.num(GUIProp.COLORGREEN);
    final int b = prop.num(GUIProp.COLORBLUE);

    // calculate color c:
    // c = (255 - expectedColor) * 10 / factor (= GUIRED/BLUE/GREEN)
    color1 = new Color(col(r, 24), col(g, 25), col(b, 40));
    color2 = new Color(col(r, 32), col(g, 32), col(b, 44));
    color3 = new Color(col(r, 48), col(g, 50), col(b, 40));
    color4 = new Color(col(r, 140), col(g, 100), col(b, 70));
    color1A = new Color(col(r, 110), col(g, 150), col(b, 160), 100);

    colormark1A = new Color(col(r, 32), col(g, 160), col(b, 320), 100);
    colormark2A = new Color(col(r, 16), col(g, 80), col(b, 160), 100);
    colormark1 = new Color(col(r, 16), col(g, 120), col(b, 240));
    colormark2 = new Color(col(r, 16), col(g, 80), col(b, 160));
    colormark3 = new Color(col(r, 32), col(g, 160), col(b, 320));
    colormark4 = new Color(col(r, 1), col(g, 40), col(b, 80));

    // create color array
    for (int l = 1; l < COLORS.length + 1; ++l) {
      COLORS[l - 1] =
          new Color(Math.max(255 - l * r, 0), Math.max(255 - l * g, 0), Math.max(255 - l * b, 0));
    }
    final Color c = COLORS[16];
    color2A = new Color(c.getRed(), c.getGreen(), c.getBlue(), 40);
    color3A = new Color(c.getRed(), c.getGreen(), c.getBlue(), 100);

    final String f = prop.get(GUIProp.FONT);
    final int type = prop.num(GUIProp.FONTTYPE);
    fontSize = prop.num(GUIProp.FONTSIZE);
    font = new Font(f, type, fontSize);
    mfont = new Font(prop.get(GUIProp.MONOFONT), type, fontSize);
    bfont = new Font(f, Font.BOLD, fontSize);
    lfont = new Font(f, type, 18 + (fontSize >> 1));
    dmfont = new Font(prop.get(GUIProp.MONOFONT), 0, TFONT.getSize() - 1);

    final Container comp = new Container();
    dwidth = comp.getFontMetrics(dmfont).getWidths();
    fwidth = comp.getFontMetrics(font).getWidths();
    lwidth = comp.getFontMetrics(lfont).getWidths();
    mfwidth = comp.getFontMetrics(mfont).getWidths();
    bwidth = comp.getFontMetrics(bfont).getWidths();
  }
示例#2
0
 /**
  * Converts color value with specified factor.
  *
  * @param c color
  * @param f factor
  * @return converted color value
  */
 private static int col(final int c, final int f) {
   return Math.max(0, 255 - c * f / 10);
 }