Exemplo n.º 1
0
    public void paintIcon(Component c, Graphics g, int x, int y) {
      Color color = c == null ? Color.GRAY : c.getBackground();
      // In a compound sort, make each succesive triangle 20%
      // smaller than the previous one.
      int dx = (int) (size / 2 * Math.pow(0.8, priority));
      int dy = descending ? dx : -dx;
      // Align icon (roughly) with font baseline.
      y = y + 5 * size / 6 + (descending ? -dy : 0);
      int shift = descending ? 1 : -1;
      g.translate(x, y);

      // Right diagonal.
      g.setColor(color.darker());
      g.drawLine(dx / 2, dy, 0, 0);
      g.drawLine(dx / 2, dy + shift, 0, shift);

      // Left diagonal.
      g.setColor(color.brighter());
      g.drawLine(dx / 2, dy, dx, 0);
      g.drawLine(dx / 2, dy + shift, dx, shift);

      // Horizontal line.
      if (descending) {
        g.setColor(color.darker().darker());
      } else {
        g.setColor(color.brighter().brighter());
      }
      g.drawLine(dx, 0, 0, 0);

      g.setColor(color);
      g.translate(-x, -y);
    }
Exemplo n.º 2
0
  /**
   * Function: getJavaColor Pre: Takes an ANIMAL color string 'c' Post: Returns the java color for
   * this node (Note: returns "white" as a default)
   */
  private Color getJavaColor(String c) {
    if (!isValidNodeColor(c)) return Color.white;

    // Temporary color to use with numbered colors
    Color temp = Color.white;

    if (c.compareTo("black") == 0) return Color.black;
    if (c.compareTo("white") == 0) return Color.white;
    if (c.compareTo("gray") == 0) return Color.gray;
    if (c.compareTo("yellow") == 0) return Color.yellow;
    if (c.startsWith("blue")) temp = Color.blue;
    if (c.startsWith("cyan")) temp = Color.cyan;
    if (c.startsWith("pink")) temp = Color.pink;
    if (c.startsWith("red")) temp = Color.red;
    if (c.startsWith("magenta")) temp = Color.magenta;
    if (c.startsWith("green")) temp = Color.green;

    // Finally, do some final handling for
    temp = temp.darker().darker();
    if (c.endsWith("2")) return temp.brighter();
    if (c.endsWith("3")) return temp.brighter().brighter();
    if (c.endsWith("4")) return temp.brighter().brighter().brighter();

    return temp;
  }
 protected void installDefaults() {
   String string = UIManager.getLookAndFeel().getName();
   Color defaultGridColor = UIManager.getColor("Table.gridColor");
   Color defaultForegroundColor = UIManager.getColor("TableHeader.foreground");
   Color defaultBackgroundColor = UIManager.getColor("TableHeader.background");
   Font defaultGridFont = UIManager.getFont("Table.font");
   Border defaultGridBorder = UIManager.getBorder("TableHeader.border");
   Color defaultSelectionForegroundColor = defaultForegroundColor.brighter();
   Color defaultSelectionBackgroundColor = defaultBackgroundColor;
   Color defaultFocusForegroundColor = defaultForegroundColor.brighter();
   Color defaultFocusBackgroundColor = defaultBackgroundColor.brighter();
   if (!installedHeader) {
     UIManager.getDefaults().put("GridHeader.gridColor", defaultGridColor);
     UIManager.getDefaults().put("GridHeader.foreground", defaultForegroundColor);
     UIManager.getDefaults().put("GridHeader.background", defaultBackgroundColor);
     UIManager.getDefaults()
         .put("GridHeader.selectionForegroundColor", defaultSelectionForegroundColor);
     UIManager.getDefaults()
         .put("GridHeader.selectionBackgroundColor", defaultSelectionBackgroundColor);
     UIManager.getDefaults().put("GridHeader.focusForegroundColor", defaultFocusForegroundColor);
     UIManager.getDefaults().put("GridHeader.focusBackgroundColor", defaultFocusBackgroundColor);
     UIManager.getDefaults().put("GridHeader.border", defaultGridBorder);
     UIManager.getDefaults().put("GridHeader.font", defaultGridFont);
   }
   Color foregroundColor = gridHeader.getForeground();
   Color backgroundColor = gridHeader.getBackground();
   Font gridFont = gridHeader.getFont();
   Border gridBorder = gridHeader.getBorder();
   Color gridColor = gridHeader.getGridColor();
   Color selectionForegroundColor = gridHeader.getSelectionForegroundColor();
   Color selectionBackgroundColor = gridHeader.getSelectionBackgroundColor();
   Color focusForegroundColor = gridHeader.getFocusForegroundColor();
   Color focusBackgroundColor = gridHeader.getFocusBackgroundColor();
   if (foregroundColor == null || foregroundColor instanceof UIResource)
     gridHeader.setForeground(defaultForegroundColor);
   if (backgroundColor == null || backgroundColor instanceof UIResource)
     gridHeader.setBackground(defaultBackgroundColor);
   if (gridColor == null || gridColor instanceof UIResource)
     gridHeader.setGridColor(defaultGridColor);
   if (gridFont == null || gridFont instanceof UIResource) gridHeader.setFont(defaultGridFont);
   if (gridBorder == null || gridBorder instanceof UIResource)
     gridHeader.setBorder(defaultGridBorder);
   if (selectionForegroundColor == null || selectionForegroundColor instanceof UIResource)
     gridHeader.setSelectionForegroundColor(defaultSelectionForegroundColor);
   if (selectionBackgroundColor == null || selectionBackgroundColor instanceof UIResource)
     gridHeader.setSelectionBackgroundColor(defaultSelectionBackgroundColor);
   if (focusForegroundColor == null || focusForegroundColor instanceof UIResource)
     gridHeader.setFocusForegroundColor(defaultFocusForegroundColor);
   if (focusBackgroundColor == null || focusBackgroundColor instanceof UIResource)
     gridHeader.setFocusBackgroundColor(defaultFocusBackgroundColor);
 }
Exemplo n.º 4
0
    private void drawSquare(Graphics g, int x, int y, Tetrominoes shape) {

      int squareWidth = (int) getSize().getWidth() / model.getWidth();
      int squareHeight = (int) getSize().getHeight() / model.getHeight();

      Color colors[] = {
        new Color(0, 0, 0),
        new Color(204, 102, 102),
        new Color(102, 204, 102),
        new Color(102, 102, 204),
        new Color(204, 204, 102),
        new Color(204, 102, 204),
        new Color(102, 204, 204),
        new Color(218, 170, 0)
      };

      Color color = colors[shape.ordinal()];
      g.setColor(color);
      g.fillRect(x + 1, y + 1, squareWidth - 2, squareHeight - 2);
      g.setColor(color.brighter());
      g.drawLine(x, y + squareHeight - 1, x, y);
      g.drawLine(x, y, x + squareWidth - 1, y);

      g.setColor(color.darker());
      g.drawLine(x + 1, y + squareHeight - 1, x + squareWidth - 1, y + squareHeight - 1);
      g.drawLine(x + squareWidth - 1, y + squareHeight - 1, x + squareWidth - 1, y + 1);
    }
    public SearchPopup(String initialString) {
      final Color foregroundColor = UIUtil.getToolTipForeground();
      Color color1 = UIUtil.getToolTipBackground();
      mySearchField = new SearchField();
      final JLabel searchLabel =
          new JLabel(" " + UIBundle.message("search.popup.search.for.label") + " ");
      searchLabel.setFont(searchLabel.getFont().deriveFont(Font.BOLD));
      searchLabel.setForeground(foregroundColor);
      mySearchField.setBorder(null);
      mySearchField.setBackground(color1.brighter());
      mySearchField.setForeground(foregroundColor);

      mySearchField.setDocument(
          new PlainDocument() {
            public void insertString(int offs, String str, AttributeSet a)
                throws BadLocationException {
              String oldText;
              try {
                oldText = getText(0, getLength());
              } catch (BadLocationException e1) {
                oldText = "";
              }

              String newText = oldText.substring(0, offs) + str + oldText.substring(offs);
              super.insertString(offs, str, a);
              if (findElement(newText) == null) {
                mySearchField.setForeground(Color.RED);
              } else {
                mySearchField.setForeground(foregroundColor);
              }
            }
          });
      mySearchField.setText(initialString);

      setBorder(BorderFactory.createLineBorder(Color.gray, 1));
      setBackground(color1.brighter());
      setLayout(new BorderLayout());
      add(searchLabel, BorderLayout.WEST);
      add(mySearchField, BorderLayout.EAST);
      Object element = findElement(mySearchField.getText());
      updateSelection(element);
    }
Exemplo n.º 6
0
 private void draw3DCircle(Graphics g, int x, int y, int radius, boolean raised) {
   Color foreground = getForeground();
   Color light = foreground.brighter();
   Color dark = foreground.darker();
   g.setColor(foreground);
   g.fillOval(x, y, radius * 2, radius * 2);
   g.setColor(raised ? light : dark);
   g.drawArc(x, y, radius * 2, radius * 2, 45, 180);
   g.setColor(raised ? dark : light);
   g.drawArc(x, y, radius * 2, radius * 2, 225, 180);
 }
Exemplo n.º 7
0
 /**
  * Performs disabled text painting.
  *
  * @param label label to process
  * @param g2d graphics context
  * @param text label text
  * @param textX text X coordinate
  * @param textY text Y coordinate
  */
 protected void paintDisabledText(
     final E label, final Graphics2D g2d, final String text, final int textX, final int textY) {
   if (label.isEnabled() && drawShade) {
     g2d.setColor(label.getBackground().darker());
     paintShadowText(g2d, text, textX, textY);
   } else {
     final int accChar = label.getDisplayedMnemonicIndex();
     final Color background = label.getBackground();
     g2d.setColor(background.brighter());
     SwingUtils.drawStringUnderlineCharAt(g2d, text, accChar, textX + 1, textY + 1);
     g2d.setColor(background.darker());
     SwingUtils.drawStringUnderlineCharAt(g2d, text, accChar, textX, textY);
   }
 }
    private void drawSpot(
        Graphics g,
        int width,
        boolean thinErrorStripeMark,
        int yStart,
        int yEnd,
        Color color,
        boolean drawTopDecoration,
        boolean drawBottomDecoration) {
      int x = isMirrored() ? 3 : 5;
      int paintWidth = width;
      if (thinErrorStripeMark) {
        paintWidth /= 2;
        paintWidth += 1;
        x = isMirrored() ? width + 2 : 0;
      }
      if (color == null) return;
      g.setColor(color);
      g.fillRect(x + 1, yStart, paintWidth - 2, yEnd - yStart + 1);

      Color brighter = color.brighter();
      g.setColor(brighter);
      // left decoration
      UIUtil.drawLine(g, x, yStart, x, yEnd /* - 1*/);
      if (drawTopDecoration) {
        // top decoration
        UIUtil.drawLine(g, x + 1, yStart, x + paintWidth - 2, yStart);
      }
      Color darker = ColorUtil.shift(color, 0.75);

      g.setColor(darker);
      if (drawBottomDecoration) {
        // bottom decoration
        UIUtil.drawLine(
            g,
            x + 1,
            yEnd /* - 1*/,
            x + paintWidth - 2,
            yEnd /* - 1*/); // large bottom to let overwrite by hl below
      }
      // right decoration
      UIUtil.drawLine(g, x + paintWidth - 2, yStart, x + paintWidth - 2, yEnd /* - 1*/);
    }
Exemplo n.º 9
0
  private static void configure() {

    // overwrite banner
    Color color = new Color(0, 102, 153);
    UIManager.put("JXLoginPane.bannerDarkBackground", color);
    UIManager.put("JXLoginPane.bannerLightBackground", color.brighter());
    UIManager.put("JXLoginPane.bannerFont", new Font("Arial", Font.ITALIC, 25));
    UIManager.put("JXLoginPane.bannerForeground", Color.WHITE);

    // overwrite login & cancel strings from buttons
    UIManager.put("JXLoginPane.loginString", "Ok");
    UIManager.put("JXLoginPane.cancelString", "Exit");

    // overwrite please wait at login
    UIManager.put("JXLoginPane.pleaseWaitFont", new Font("Arial", Font.ITALIC, 20));
    UIManager.put("JXLoginPane.pleaseWait", "Loging ...");
    UIManager.put("JXLoginPane.cancelLogin", "Cancel");

    // overwrite error icon , message, background & border
    // UIManager.put("JXLoginPane.errorIcon", ImageUtil.getImageIcon("img.png"));
    // UIManager.put("JXLoginPane.errorMessage", "Failed"); // if error message must be inserted see
    // login listener
    //            Color errorColor = new Color(252, 236, 236);
    //            UIManager.put("JXLoginPane.errorBackground", errorColor);
    //            UIManager.put("JXLoginPane.errorBorder", new
    // BorderUIResource(BorderFactory.createCompoundBorder(
    //                    BorderFactory.createEmptyBorder(0, 36, 0, 11),
    //                    BorderFactory.createCompoundBorder(
    //                            BorderFactory.createLineBorder(Color.GRAY.darker()),
    //                            BorderFactory.createMatteBorder(5, 7, 5, 5, errorColor)))));

    // overwrite name , password & server labels
    UIManager.put("JXLoginPane.nameString", "User");
    UIManager.put("JXLoginPane.passwordString", "Credentials");
    UIManager.put("JXLoginPane.serverString", "Server");

    // UIManager.put("JXLoginPane.capsOnWarning", "Caps Lock pressed!");

  }
Exemplo n.º 10
0
  private void render() {
    ArrayList<NetworkMessage> messages = networkController.getMessages();

    for (NetworkMessage message : messages) {
      String messageType =
          message.getClass().getName().replace("NetworkMessages.", "").replace("Messages.", "");
      switch (messageType) {
        case "PelletPositionMessage":
          {
            PelletPositionMessage m = (PelletPositionMessage) message;
            Drawable drawable = getCachedDrawable(m.id);
            if (drawable != null) {
              drawable.node.relocate(m.x, m.y);
              drawable.cacheMisses = 0;
            } else {
              Random r = new Random();
              Node node =
                  drawCircle(
                      m.x, m.y, 5, new Color(r.nextFloat(), r.nextFloat(), r.nextFloat(), 1));
              drawableCache.add(new Drawable(m.id, node));
            }
          }
          break;
        case "BlobStateMessage":
          {
            BlobStateMessage m = (BlobStateMessage) message;
            Color color = Color.web(m.color);
            Node node;
            if (color.getBrightness() != 0) {
              node = drawCircle(m.x, m.y, m.size / 2, color);
            } else {
              node = drawCircle(m.x, m.y, m.size / 2, color.brighter().brighter());
            }
            Node nameText =
                drawText((m.x - m.username.length() * 5), (m.y - m.size / 2), m.username, color);
            Drawable drawable = getCachedDrawable(m.id);
            if (drawable != null) {
              node.setLayoutX((drawable.node.getTranslateX() - m.x) / 10000);
              node.setLayoutY((drawable.node.getTranslateY() - m.y) / 10000);
              drawable.node = node;
              drawable.cacheMisses = 0;
              Drawable nameTag = getCachedDrawable(m.id + 9000);
              nameTag.node = nameText;
              nameTag.cacheMisses = 0;
            } else {
              drawableCache.add(new Drawable(m.id, node));
              drawableCache.add(new Drawable(m.id + 9000, nameText));
            }
          }
          break;
        case "PingMessage":
          {
            renderPane.getChildren().clear();
            ArrayList<Drawable> drawables = new ArrayList<>(drawableCache);
            for (Drawable drawable : drawables) {
              if (drawable.cacheMisses > 1) {
                drawableCache.remove(drawable);
              }
              drawable.cacheMisses++;
              renderPane.getChildren().add(drawable.node);
            }
            renderPane.getChildren().addAll(chatBox, chatInput, lagLabel, scores);

            lag = System.currentTimeMillis() - lastReceivedTime;
            lastReceivedTime = System.currentTimeMillis();
            lagLabel.setText("Net Lag: " + Long.toString(lag));
          }
          break;
        case "HighScoreMessage":
          {
            HighScoreMessage m = (HighScoreMessage) message;
            highScores.setText("HIGH SCORES:" + m.text);
          }
          break;
        case "CurrentScoreMessage":
          {
            CurrentScoreMessage m = (CurrentScoreMessage) message;
            currentScores.setText("Current Scores:" + m.text);
          }
          break;
        case "ChatMessage":
          {
            ChatMessage m = (ChatMessage) message;
            chatBox.appendText(m.username + "> " + m.text + "\n");
          }
          break;
      }
    }
  }
Exemplo n.º 11
0
 public d(
     e e1, int i1, boolean flag, boolean flag1, Color acolor[], String s, Component acomponent[]) {
   p = e1;
   e1 = i1 != 2 || !flag1 ? 0 : 1;
   a = i1 + i1 % 2;
   c = 0;
   d = new m[a];
   h = new Button[a];
   i = new Button[a];
   l = new Panel[a];
   k = new Panel[a];
   n = new CardLayout[a];
   m = new CardLayout[a];
   if (flag) e = new Label[a];
   if (flag1) f = new Label[a];
   if (s != null) g = new Label[a];
   if (acolor != null) j = new x[a];
   if (e1 != 0) o = new x[a];
   setLayout(new GridLayout(a / 2, 2, 4, 6));
   for (acomponent = 0; acomponent < a; acomponent++) {
     Panel panel;
     (panel = new Panel()).setLayout(new BorderLayout(0, a > 1 ? 4 : 1));
     if (e1 != 0) panel.add("North", o[acomponent] = new x(new Dimension(25, 17), 2));
     Panel panel1;
     (panel1 = new Panel()).setBackground(a.a);
     panel1.setLayout(new BorderLayout(0, 1));
     Panel panel3;
     Panel panel4;
     (panel4 = c.n.a(panel3 = new Panel(), 1, new String[] {"East", "West", "North"}))
         .setFont(c.n.a(0));
     panel4.setForeground(Color.lightGray);
     Object obj;
     ((Container) (obj = new Panel())).setLayout(new GridLayout(1, 2, 0, 0));
     ((Container) (obj)).setLayout(new BorderLayout(0, 0));
     if (acolor != null)
       ((Container) (obj)).add("West", j[acomponent] = new x(acolor[acomponent]));
     Object obj1;
     ((Component) (obj1 = c.n.b(p.c(acomponent), 0, 2, 9))).setBackground(a.a);
     ((Component) (obj1)).setFont(c.n.a(0));
     ((Container) (obj)).add(acolor == null ? "West" : "Center", ((Component) (obj1)));
     if (s != null) {
       ((Component) (obj1 = c.n.b(s + "     ", acolor == null ? 0 : 2, 2, 8))).setFont(c.n.a(0));
       ((Container) (obj))
           .add(acolor == null ? "Center" : "East", g[acomponent] = ((Label) (obj1)));
     }
     panel4.add("Center", ((Component) (obj)));
     panel1.add("North", panel3);
     ((Container) (obj1 = new Panel())).setLayout(new BorderLayout(0, 0));
     l[acomponent] = new Panel();
     l[acomponent].setLayout(n[acomponent] = new CardLayout());
     panel4 = c.n.a(panel3 = new Panel(), 1, new String[] {"East", "West", "South"}, 0);
     d[acomponent] = new m("", 0, 0, -4);
     d[acomponent].setFont(c.n.a(5));
     d[acomponent].setBackground(Color.white);
     d[acomponent].setForeground(Color.black);
     panel4.add("Center", d[acomponent]);
     k[acomponent] = new Panel();
     k[acomponent].setLayout(m[acomponent] = new CardLayout());
     ((Component) (obj = c.n.g(""))).setBackground(Color.white);
     k[acomponent].add("0", ((Component) (obj)));
     k[acomponent].add("x", i[acomponent] = c.n.a("x", 3));
     panel4.add("East", k[acomponent]);
     l[acomponent].add("name", panel3);
     h[acomponent] = c.n.c(p.c("bl_sit"));
     l[acomponent].add("but", h[acomponent]);
     ((Container) (obj1)).add("Center", l[acomponent]);
     panel1.add("Center", ((Component) (obj1)));
     panel.add("Center", panel1);
     if (flag || flag1) {
       Panel panel2;
       (panel2 = new Panel()).setLayout(new GridLayout(1, 2, 3, 0));
       if (flag) {
         e[acomponent] = p.a(g.m.e.b(0), 1, 0, 4);
         Color color;
         if ((color = p.getBackground()) != null) e[acomponent].setBackground(color.brighter());
         panel2.add(e[acomponent]);
       }
       if (flag1) {
         f[acomponent] = c.n.b("00:00", flag ? 1 : 0, 0, 4);
         if (!flag && a <= 2) f[acomponent].setFont(c.n.a(6));
         panel2.add(f[acomponent]);
       } else {
         panel2.add(new Canvas());
       }
       if (!flag) panel2.add(new Canvas());
       panel.add("South", panel2);
     }
     if (acomponent < i1) add(panel);
     else add(new Panel());
   }
 }
Exemplo n.º 12
0
    @Override
    public boolean _setProgress(
        IdeFrame frame,
        Object processId,
        AppIconScheme.Progress scheme,
        double value,
        boolean isOk) {
      assertIsDispatchThread();

      if (getAppImage() == null) return false;

      myCurrentProcessId = processId;

      if (Math.abs(myLastValue - value) < 0.02d) return true;

      try {
        int progressHeight = (int) (myAppImage.getHeight() * 0.13);
        int xInset = (int) (myAppImage.getWidth() * 0.05);
        int yInset = (int) (myAppImage.getHeight() * 0.15);

        final int width = myAppImage.getWidth() - xInset * 2;
        final int y = myAppImage.getHeight() - progressHeight - yInset;
        Shape rect =
            new RoundRectangle2D.Double(
                xInset, y, width, progressHeight, progressHeight, progressHeight);
        Shape border =
            new RoundRectangle2D.Double(
                xInset - 1,
                y - 1,
                width + 2,
                progressHeight + 2,
                (progressHeight + 2),
                (progressHeight + 2));
        Shape progress =
            new RoundRectangle2D.Double(
                xInset + 1,
                y + 1,
                (width - 2) * value,
                progressHeight - 1,
                (progressHeight - 2),
                (progressHeight - 1));
        AppImage appImg = createAppImage();

        final Color brighter = Color.GRAY.brighter().brighter();
        final Color backGround =
            new Color(brighter.getRed(), brighter.getGreen(), brighter.getBlue(), 85);
        appImg.myG2d.setColor(backGround);
        appImg.myG2d.fill(rect);
        final Color color = isOk ? scheme.getOkColor() : scheme.getErrorColor();
        final Paint paint =
            UIUtil.getGradientPaint(
                xInset + 1,
                y + 1,
                color.brighter(),
                xInset + 1,
                y + progressHeight - 1,
                color.darker().darker());
        appImg.myG2d.setPaint(paint);
        appImg.myG2d.fill(progress);
        appImg.myG2d.setColor(Color.GRAY.darker().darker());
        appImg.myG2d.draw(rect);
        appImg.myG2d.draw(border);

        setDockIcon(appImg.myImg);

        myLastValue = value;
      } catch (Exception e) {
        LOG.error(e);
      } finally {
        myCurrentProcessId = null;
      }

      return true;
    }
Exemplo n.º 13
0
  public void print(Graphics g) {
    TextField txt = (TextField) target;
    Dimension d = txt.size();
    int w = d.width - (2 * BORDER);
    int h = d.height - (2 * BORDER);
    Color bg = txt.getBackground();
    Color fg = txt.getForeground();
    Color highlight = bg.brighter();
    String text = txt.getText();
    int moved = 0;
    int selStart = 0;
    int selEnd = 0;

    g.setFont(txt.getFont());
    g.setColor(txt.isEditable() ? highlight : bg);
    g.fillRect(BORDER, BORDER, w, h);

    g.setColor(bg);
    // g.drawRect(0, 0, d.width-1, d.height-1);
    draw3DRect(g, bg, 1, 1, d.width - 3, d.height - 3, false);

    if (text != null) {
      g.clipRect(BORDER, MARGIN, w, d.height - (2 * MARGIN));
      FontMetrics fm = g.getFontMetrics();

      w = d.width - BORDER;
      h = d.height - (2 * MARGIN);
      int xs = pos2x(selStart) - moved;
      int xe = pos2x(selEnd) - moved;

      if ((xs < MARGIN) && (xe > w)) {
        g.setColor(highlight);
        g.fillRect(BORDER, MARGIN, w - BORDER, h);
      } else {
        g.setColor(bg);
        // g.fillRect(BORDER, MARGIN, w - BORDER, h);

        if ((xs >= MARGIN) && (xs <= w)) {
          g.setColor(highlight); // selected text

          if (xe > w) {
            g.fillRect(xs, MARGIN, w - xs, h);
          } else if (xs == xe) {
            // g.fillRect(xs, MARGIN, 1, h);
          } else {
            g.fillRect(xs, MARGIN, xe - xs, h);
          }
        } else if ((xe >= MARGIN) && (xe <= w)) {
          g.setColor(highlight);
          g.fillRect(BORDER, MARGIN, xe - BORDER, h);
        }
      }
      g.setColor(fg);
      int x = MARGIN - moved;
      char echoChar = txt.getEchoChar();
      if (echoChar == 0) {
        g.drawString(text, x, BORDER + MARGIN + fm.getMaxAscent());
      } else {
        char data[] = new char[text.length()];
        for (int i = 0; i < data.length; i++) {
          data[i] = echoChar;
        }
        g.drawChars(data, 0, data.length, x, BORDER + MARGIN + fm.getMaxAscent());
      }
    }

    target.print(g);
  }
Exemplo n.º 14
0
  /** Updates the FancyShape. */
  void update() { // don't update warning regions here, do it in GraphArea...

    if (getNeedsUpdate()) {

      if (lightSource == TOP) {
        paint =
            new GradientPaint(
                lightBounds.x,
                lightBounds.y,
                color.brighter(),
                lightBounds.x,
                lightBounds.y + lightBounds.height,
                color);
        if (outlineExistence) {
          outlinePaint =
              new GradientPaint(
                  lightBounds.x,
                  lightBounds.y,
                  outlineColor.brighter(),
                  lightBounds.x,
                  lightBounds.y + lightBounds.height,
                  outlineColor);
        }
        warningPaints.removeAllElements();
        if (warningRegions != null) {
          for (int i = 0; i < warningRegions.size(); ++i) {
            Color warningColor = ((WarningRegion) warningRegions.get(i)).getComponentColor();
            warningPaints.add(
                new GradientPaint(
                    lightBounds.x,
                    lightBounds.y,
                    warningColor.brighter(),
                    lightBounds.x,
                    lightBounds.y + lightBounds.height,
                    warningColor));
          }
        }
      } else if (lightSource == BOTTOM) {
        paint =
            new GradientPaint(
                lightBounds.x,
                lightBounds.y,
                color,
                lightBounds.x,
                lightBounds.y + lightBounds.height,
                color.brighter());
        if (outlineExistence) {
          outlinePaint =
              new GradientPaint(
                  lightBounds.x,
                  lightBounds.y,
                  outlineColor,
                  lightBounds.x,
                  lightBounds.y + lightBounds.height,
                  outlineColor.brighter());
        }
        warningPaints.removeAllElements();
        for (int i = 0; i < warningRegions.size(); ++i) {
          Color warningColor = ((WarningRegion) warningRegions.get(i)).getComponentColor();
          warningPaints.add(
              new GradientPaint(
                  lightBounds.x,
                  lightBounds.y,
                  warningColor,
                  lightBounds.x,
                  lightBounds.y + lightBounds.height,
                  warningColor.brighter()));
        }
      } else if (lightSource == LEFT) {

        paint =
            new GradientPaint(
                lightBounds.x,
                lightBounds.y,
                color.brighter(),
                lightBounds.x + lightBounds.width,
                lightBounds.y,
                color);
        if (outlineExistence) {
          outlinePaint =
              new GradientPaint(
                  lightBounds.x,
                  lightBounds.y,
                  outlineColor.brighter(),
                  lightBounds.x + lightBounds.width,
                  lightBounds.y,
                  outlineColor);
        }
        warningPaints.removeAllElements();
        if (warningRegions != null) {
          for (int i = 0; i < warningRegions.size(); ++i) {
            Color warningColor = ((WarningRegion) warningRegions.get(i)).getComponentColor();
            warningPaints.add(
                new GradientPaint(
                    lightBounds.x,
                    lightBounds.y,
                    warningColor.brighter(),
                    lightBounds.x + lightBounds.width,
                    lightBounds.y,
                    warningColor));
          }
        }
      } else if (lightSource == RIGHT) {
        paint =
            new GradientPaint(
                lightBounds.x,
                lightBounds.y,
                color,
                lightBounds.x + lightBounds.width,
                lightBounds.y,
                color.brighter());
        if (outlineExistence) {
          outlinePaint =
              new GradientPaint(
                  lightBounds.x,
                  lightBounds.y,
                  outlineColor,
                  lightBounds.x + lightBounds.width,
                  lightBounds.y,
                  outlineColor.brighter());
        }
        warningPaints.removeAllElements();
        if (warningRegions != null) {
          for (int i = 0; i < warningRegions.size(); ++i) {
            Color warningColor = ((WarningRegion) warningRegions.get(i)).getComponentColor();
            warningPaints.add(
                new GradientPaint(
                    lightBounds.x,
                    lightBounds.y,
                    warningColor,
                    lightBounds.x + lightBounds.width,
                    lightBounds.y,
                    warningColor.brighter()));
          }
        }
      } else {
        paint = color;
        outlinePaint = outlineColor;
        warningPaints.removeAllElements();
        if (warningRegions != null) {
          for (int i = 0; i < warningRegions.size(); ++i) {
            Color warningColor = ((WarningRegion) warningRegions.get(i)).getComponentColor();
            warningPaints.add(warningColor);
          }
        }
      }
      needsUpdate = false;
    }
  }