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);
    }
 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);
 }
Esempio n. 3
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);
    }
Esempio n. 5
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*/);
    }
Esempio n. 7
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!");

  }
    @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;
    }