Package java.awt

Examples of java.awt.Color


      } else if (a < 15) {
        paint = paintSteady;
      } else {
        paint = new Paint[colorBase.length];
        for (int i = 0; i < paint.length; i++) {
          Color hue = colorBase[i];
          paint[i] = new GradientPaint(0.0f, 0.0f, derive(hue, a),
            0.0f, fadeStop, hue);
        }
      }
      yPos = initY;
View Full Code Here


    if (opacity == null || opacity.equals("")) {
      a = 255;
    } else {
      a = (int) Math.round(Double.parseDouble(opacity) * 255);
    }
    return new Color(r, g, b, a);
  }
View Full Code Here

      val = data == null ? Value.FALSE : (Value) data.getValue();
    } else {
      val = Value.FALSE;
    }
   
    Color color = painter.getAttributeValue(Io.ATTR_COLOR);
    if (!painter.shouldDrawColor()) {
      int hue = (color.getRed() + color.getGreen() + color.getBlue()) / 3;
      color = new Color(hue, hue, hue);
    }
   
    Graphics g = painter.getGraphics();
    int depress;
    if (val == Value.TRUE) {
      x += DEPTH;
      y += DEPTH;
      Object labelLoc = painter.getAttributeValue(Io.ATTR_LABEL_LOC);
      if (labelLoc == Io.LABEL_CENTER || labelLoc == Direction.NORTH
          || labelLoc == Direction.WEST) {
        depress = DEPTH;
      } else {
        depress = 0;
      }
     
      Object facing = painter.getAttributeValue(StdAttr.FACING);
      if (facing == Direction.NORTH || facing == Direction.WEST) {
        Location p = painter.getLocation();
        int px = p.getX();
        int py = p.getY();
        GraphicsUtil.switchToWidth(g, Wire.WIDTH);
        g.setColor(Value.TRUE_COLOR);
        if (facing == Direction.NORTH) g.drawLine(px, py, px, py + 10);
        else                          g.drawLine(px, py, px + 10, py);
        GraphicsUtil.switchToWidth(g, 1);
      }
     
      g.setColor(color);
      g.fillRect(x, y, w - DEPTH, h - DEPTH);
      g.setColor(Color.BLACK);
      g.drawRect(x, y, w - DEPTH, h - DEPTH);
    } else {
      depress = 0;
      int[] xp = new int[] { x, x + w - DEPTH, x + w, x + w, x + DEPTH, x };
      int[] yp = new int[] { y, y, y + DEPTH, y + h, y + h, y + h - DEPTH };
      g.setColor(color.darker());
      g.fillPolygon(xp, yp, xp.length);
      g.setColor(color);
      g.fillRect(x, y, w - DEPTH, h - DEPTH);
      g.setColor(Color.BLACK);
      g.drawRect(x, y, w - DEPTH, h - DEPTH);
View Full Code Here

    if (negated != 0) {
      width -= 10;
    }

    Graphics g = painter.getGraphics();
    Color baseColor = g.getColor();
    if (shape == AppPreferences.SHAPE_SHAPED && paintInputLines) {
      PainterShaped.paintInputLines(painter, this);
    } else if (negated != 0) {
      for (int i = 0; i < inputs; i++) {
        int negatedBit = (negated >> i) & 1;
View Full Code Here

public class EditableLabelField extends JTextField {
  static final int FIELD_BORDER = 2;

  public EditableLabelField() {
    super(10);
    setBackground(new Color(255, 255, 255, 128));
    setOpaque(false);
    setBorder(BorderFactory.createCompoundBorder(
        BorderFactory.createLineBorder(Color.BLACK),
        BorderFactory.createEmptyBorder(1, 1, 1, 1)));
  }
View Full Code Here

    {
       MessageComponent comp = (MessageComponent) e.nextElement();
       if(comp instanceof TextComponent)
       {
         TextComponent txt = (TextComponent) comp;
        Color color = txt.getColor();
        if(color != null)
        {
          ret.append("\033[#");
          ret.append(Integer.toHexString(color.getRed()));
          ret.append(Integer.toHexString(color.getGreen()));
          ret.append(Integer.toHexString(color.getBlue()));
          ret.append('m');
        }
        Font font = txt.getFont();
        if(font != null)
        {
View Full Code Here

  private static MessageComponent[] splitFontAndColor(TextComponent comp)
  {
    int currentFontStyle = Font.PLAIN;
    int currentFontSize = 10;
    Font currentFont = new Font(null, currentFontStyle, currentFontSize);
    Color currentColor = Color.black;

    List ret = new ArrayList();
    StringBuffer sb = new StringBuffer();
    sb.append(comp.getSequence());

    Matcher m = fontColorPattern.matcher(sb);
    int txtStart = 0;
    while(m.find())
    {
      int txtEnd = m.end();
      if(txtStart < txtEnd)
      {
        String text = sb.substring(txtStart, txtEnd);
        ret.add(new TextComponent(text, currentFont, currentColor));
      }
      txtStart = txtEnd;

      String fontFace = m.group(3);
      String fontSize = m.group(4);
      String colorCodeStr = m.group(7);
      String colorStr = m.group(9);

      if(fontFace != null)
        currentFont = new Font(fontFace, currentFontStyle, currentFontSize);
      if(fontSize != null)
      {
        currentFontSize = Integer.parseInt(fontSize);
        currentFont = currentFont.deriveFont((float)currentFontSize);
      }
      if(colorCodeStr != null)
      {
        switch(Integer.parseInt(colorCodeStr))
        {
          case 38:
            currentColor = new Color(0xff0000);
            break;
          case 34:
            currentColor = new Color(0x00ff00);
            break;
          case 39:
            currentColor = new Color(0xffff00);
            break;
          case 31:
            currentColor = new Color(0x0000ff);
            break;
          case 36:
            currentColor = new Color(0xff00ff);
            break;
          case 32:
            currentColor = new Color(0x00ffff);
            break;
          case 37:
            currentColor = new Color(0xff8000);
            break;
          case 35:
            currentColor = new Color(0xff0080);
            break;
          case 33:
            currentColor = new Color(0x808080);
            break;
        }
      }
      if(colorStr != null)
      {
        currentColor = new Color(Integer.parseInt(colorStr, 16));
      }
    }
    if(txtStart < sb.length())
    {
      String text = sb.substring(txtStart);
View Full Code Here

 
  @Override
  public void paintComponent(Graphics g) {
    if (toolbar.getPressed() == this) {
      Dimension dim = item.getDimension(toolbar.getOrientation());
      Color defaultColor = g.getColor();
      GraphicsUtil.switchToWidth(g, 2);
      g.setColor(Color.GRAY);
      g.fillRect(BORDER, BORDER, dim.width, dim.height);
      GraphicsUtil.switchToWidth(g, 1);
      g.setColor(defaultColor);
View Full Code Here

      Composite c = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f);
      ((Graphics2D) g).setComposite(c);
    }

    if (icon == null) {
      g.setColor(new Color(255, 128, 128));
      g.fillRect(4, 4, 8, 8);
      g.setColor(Color.BLACK);
      g.drawLine(4, 4, 12, 12);
      g.drawLine(4, 12, 12, 4);
      g.drawRect(4, 4, 8, 8);
View Full Code Here

  // user interface features
  // 
  @Override
  public void paintGhost(InstancePainter painter) {
    Graphics g = painter.getGraphics();
    Color fg = g.getColor();
    int v = fg.getRed() + fg.getGreen() + fg.getBlue();
    Composite oldComposite = null;
    if (g instanceof Graphics2D && v > 50) {
      oldComposite = ((Graphics2D) g).getComposite();
      Composite c = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f);
      ((Graphics2D) g).setComposite(c);
View Full Code Here

TOP

Related Classes of java.awt.Color

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.