private static void formatStyle(
      final StringBuilder builder, final SimpleTextAttributes attributes) {
    final Color fgColor = attributes.getFgColor();
    final Color bgColor = attributes.getBgColor();
    final int style = attributes.getStyle();

    final int pos = builder.length();
    if (fgColor != null) {
      builder
          .append("color:#")
          .append(Integer.toString(fgColor.getRGB() & 0xFFFFFF, 16))
          .append(';');
    }
    if (bgColor != null) {
      builder
          .append("background-color:#")
          .append(Integer.toString(bgColor.getRGB() & 0xFFFFFF, 16))
          .append(';');
    }
    if ((style & SimpleTextAttributes.STYLE_BOLD) != 0) {
      builder.append("font-weight:bold;");
    }
    if ((style & SimpleTextAttributes.STYLE_ITALIC) != 0) {
      builder.append("font-style:italic;");
    }
    if ((style & SimpleTextAttributes.STYLE_UNDERLINE) != 0) {
      builder.append("text-decoration:underline;");
    } else if ((style & SimpleTextAttributes.STYLE_STRIKEOUT) != 0) {
      builder.append("text-decoration:line-through;");
    }
    if (builder.length() > pos) {
      builder.insert(pos, " style=\"");
      builder.append('"');
    }
  }
 /** Patches attributes to be visible under debugger active line */
 @SuppressWarnings("UseJBColor")
 public static TextAttributes patchAttributesColor(
     TextAttributes attributes, @NotNull TextRange range, @NotNull Editor editor) {
   if (attributes.getForegroundColor() == null && attributes.getEffectColor() == null)
     return attributes;
   MarkupModel model =
       DocumentMarkupModel.forDocument(editor.getDocument(), editor.getProject(), false);
   if (model != null) {
     if (!((MarkupModelEx) model)
         .processRangeHighlightersOverlappingWith(
             range.getStartOffset(),
             range.getEndOffset(),
             highlighter -> {
               if (highlighter.isValid()
                   && highlighter.getTargetArea() == HighlighterTargetArea.LINES_IN_RANGE) {
                 TextAttributes textAttributes = highlighter.getTextAttributes();
                 if (textAttributes != null) {
                   Color color = textAttributes.getBackgroundColor();
                   return !(color != null
                       && color.getBlue() > 128
                       && color.getRed() < 128
                       && color.getGreen() < 128);
                 }
               }
               return true;
             })) {
       TextAttributes clone = attributes.clone();
       clone.setForegroundColor(Color.orange);
       clone.setEffectColor(Color.orange);
       return clone;
     }
   }
   return attributes;
 }
 protected String paramString() {
   String str;
   if (linkBehavior == ALWAYS_UNDERLINE) str = "ALWAYS_UNDERLINE";
   else if (linkBehavior == HOVER_UNDERLINE) str = "HOVER_UNDERLINE";
   else if (linkBehavior == NEVER_UNDERLINE) str = "NEVER_UNDERLINE";
   else str = "SYSTEM_DEFAULT";
   String colorStr = linkColor == null ? "" : linkColor.toString();
   String colorPressStr = colorPressed == null ? "" : colorPressed.toString();
   String disabledLinkColorStr = disabledLinkColor == null ? "" : disabledLinkColor.toString();
   String visitedLinkColorStr = visitedLinkColor == null ? "" : visitedLinkColor.toString();
   String buttonURLStr = buttonURL == null ? "" : buttonURL.toString();
   String isLinkVisitedStr = isLinkVisited ? "true" : "false";
   return super.paramString()
       + ",linkBehavior="
       + str
       + ",linkURL="
       + buttonURLStr
       + ",linkColor="
       + colorStr
       + ",activeLinkColor="
       + colorPressStr
       + ",disabledLinkColor="
       + disabledLinkColorStr
       + ",visitedLinkColor="
       + visitedLinkColorStr
       + ",linkvisitedString="
       + isLinkVisitedStr;
 }
Exemple #4
0
 public void addPlot(String name, int[] data) {
   plot_names.add(name);
   plot_data.add(data);
   int new_max = getMax(plot_data.size() - 1);
   if (new_max > MAX_Y) {
     MAX_Y = new_max;
   }
   if (data.length > MAX_X) {
     MAX_X = data.length;
   }
   int i = plot_data.size();
   Color c =
       new Color(
           (i * COLOR_RATIO) % 255,
           ((i + 2) * COLOR_RATIO) % 255,
           ((i + 3) * COLOR_RATIO) % 255,
           255);
   plot_colors.add(c);
   for (int j = 0; j < plot_colors.size(); j++) {
     Color color = plot_colors.get(j);
     Color new_color =
         new Color(
             color.getRed(), color.getBlue(), color.getGreen(), 127 / plot_colors.size() + 128);
     plot_colors.set(j, new_color);
   }
 }
  private static Component createDescription(Example example, ExampleGroup group) {
    Color foreground = group.getPreferredForeground();

    WebLabel titleLabel = new WebLabel(example.getTitle(), JLabel.TRAILING);
    titleLabel.setDrawShade(true);
    titleLabel.setForeground(foreground);
    if (foreground.equals(Color.WHITE)) {
      titleLabel.setShadeColor(Color.BLACK);
    }

    if (example.getDescription() == null) {
      return titleLabel;
    } else {
      WebLabel descriptionLabel = new WebLabel(example.getDescription(), WebLabel.TRAILING);
      descriptionLabel.setForeground(Color.GRAY);
      SwingUtils.changeFontSize(descriptionLabel, -1);

      WebPanel vertical =
          new WebPanel(new VerticalFlowLayout(VerticalFlowLayout.MIDDLE, 0, 0, true, false));
      vertical.setOpaque(false);
      vertical.add(titleLabel);
      vertical.add(descriptionLabel);

      return vertical;
    }
  }
  @Override
  public void writeExternal(Element element) throws WriteExternalException {
    List<HighlightSeverity> list = getOrderAsList(getOrderMap());
    for (HighlightSeverity severity : list) {
      Element info = new Element(INFO_TAG);
      String severityName = severity.getName();
      final SeverityBasedTextAttributes infoType = getAttributesBySeverity(severity);
      if (infoType != null) {
        infoType.writeExternal(info);
        final Color color = myRendererColors.get(severityName);
        if (color != null) {
          info.setAttribute(COLOR_ATTRIBUTE, Integer.toString(color.getRGB() & 0xFFFFFF, 16));
        }
        element.addContent(info);
      }
    }

    if (myReadOrder != null && !myReadOrder.isEmpty()) {
      myReadOrder.writeExternal(element);
    } else if (!getDefaultOrder().equals(list)) {
      final JDOMExternalizableStringList ext =
          new JDOMExternalizableStringList(Collections.nCopies(getOrderMap().size(), ""));
      getOrderMap()
          .forEachEntry(
              new TObjectIntProcedure<HighlightSeverity>() {
                @Override
                public boolean execute(HighlightSeverity orderSeverity, int oIdx) {
                  ext.set(oIdx, orderSeverity.getName());
                  return true;
                }
              });
      ext.writeExternal(element);
    }
  }
Exemple #7
0
 /** Patches attributes to be visible under debugger active line */
 @SuppressWarnings("UseJBColor")
 private static TextAttributes patchAttributesColor(
     TextAttributes attributes, TextRange range, Editor editor) {
   int line = editor.offsetToLogicalPosition(range.getStartOffset()).line;
   for (RangeHighlighter highlighter : editor.getMarkupModel().getAllHighlighters()) {
     if (!highlighter.isValid()) continue;
     if (highlighter.getTargetArea() == HighlighterTargetArea.LINES_IN_RANGE
         && editor.offsetToLogicalPosition(highlighter.getStartOffset()).line == line) {
       TextAttributes textAttributes = highlighter.getTextAttributes();
       if (textAttributes != null) {
         Color color = textAttributes.getBackgroundColor();
         if (color != null
             && color.getBlue() > 128
             && color.getRed() < 128
             && color.getGreen() < 128) {
           TextAttributes clone = attributes.clone();
           clone.setForegroundColor(Color.orange);
           clone.setEffectColor(Color.orange);
           return clone;
         }
       }
     }
   }
   return attributes;
 }
Exemple #8
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 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);
    }
  private void setSubscriberDetails(
      String subscriberName, String subscriberAddress, String message) {
    this.name = subscriberName;
    this.address = subscriberAddress;

    Color color = messagePane.getForeground();

    messagePane.setText(
        "<FONT COLOR=\"#"
            + Integer.toHexString(color.getRGB()).substring(2)
            + "\">"
            + messageString1
            + "<p>"
            + namePrefix
            + name
            + nameSuffix
            + "<br>"
            + addressPrefix
            + address
            + addressSuffix
            + "<p>"
            + ((message != null && message.trim().length() > 0)
                ? messagePrefix + message + messageSuffix + "<p>"
                : "")
            + messageString2
            + "</FONT>");
  }
  private void drawColorButton(Graphics g, int no) {
    g.setColor(cDarkShadowColor);
    g.drawLine(mRect[no].x, mRect[no].y, mRect[no].x + mRect[no].width - 2, mRect[no].y);
    g.drawLine(mRect[no].x, mRect[no].y, mRect[no].x, mRect[no].y + mRect[no].height - 2);
    g.drawLine(
        mRect[no].x + mRect[no].width - 2,
        mRect[no].y + 2,
        mRect[no].x + mRect[no].width - 2,
        mRect[no].y + mRect[no].height - 2);
    g.drawLine(
        mRect[no].x + 2,
        mRect[no].y + mRect[no].height - 2,
        mRect[no].x + mRect[no].width - 2,
        mRect[no].y + mRect[no].height - 2);

    if (mPressedButton != no || !mMouseOverButton) g.setColor(Color.white);

    g.drawLine(
        mRect[no].x + 1, mRect[no].y + 1, mRect[no].x + mRect[no].width - 3, mRect[no].y + 1);
    g.drawLine(
        mRect[no].x + 1, mRect[no].y + 1, mRect[no].x + 1, mRect[no].y + mRect[no].height - 3);

    if (mPressedButton == no && mMouseOverButton) g.setColor(Color.white);

    g.drawLine(
        mRect[no].x + mRect[no].width - 1,
        mRect[no].y + 1,
        mRect[no].x + mRect[no].width - 1,
        mRect[no].y + mRect[no].height - 1);
    g.drawLine(
        mRect[no].x + 1,
        mRect[no].y + mRect[no].height - 1,
        mRect[no].x + mRect[no].width - 1,
        mRect[no].y + mRect[no].height - 1);

    if (mColorListMode != VisualizationColor.cColorListModeCategories && no == cColorWedgeButton) {
      int x1 = mRect[no].x + 2;
      int x2 = x1 + mRect[no].width - 4;
      if (x1 < x2) {
        for (int x = x1; x < x2; x++) {
          int c = mWedgeColorList.length * (x - x1) / (x2 - x1);
          g.setColor(
              (mPressedButton == no && mMouseOverButton)
                  ? mWedgeColorList[c].darker()
                  : mWedgeColorList[c]);
          g.drawLine(x, mRect[no].y + 2, x, mRect[no].y + mRect[no].height - 3);
        }
      }
    } else {
      Color color =
          (mColorListMode == VisualizationColor.cColorListModeCategories)
              ? mCategoryColorList[no]
              : mWedgeColorList[no * (mWedgeColorList.length - 1)];
      if (mPressedButton == no && mMouseOverButton) color = color.darker();

      g.setColor(color);
      g.fillRect(mRect[no].x + 2, mRect[no].y + 2, mRect[no].width - 4, mRect[no].height - 4);
    }
  }
 private void paintBackground(Graphics2D g, Color color, float x, int y, float width) {
   if (width <= 0
       || color == null
       || color.equals(myEditor.getColorsScheme().getDefaultBackground())
       || color.equals(myEditor.getBackgroundColor())) return;
   g.setColor(color);
   g.fillRect((int) x, y, (int) width, myView.getLineHeight());
 }
Exemple #13
0
 public ColorPane(Color c) {
   col = c;
   setBackground(c);
   setBorder(unselectedBorder);
   String msg = "R " + c.getRed() + ", G " + c.getGreen() + ", B " + c.getBlue();
   setToolTipText(msg);
   addMouseListener(this);
 }
Exemple #14
0
  /**
   * Esta funcion se usa para inicializar los colores del tema segun los argumentos que se le pasen.
   */
  static NimRODTheme iniCustomColors(
      NimRODTheme nt,
      String selection,
      String background,
      String p1,
      String p2,
      String p3,
      String s1,
      String s2,
      String s3,
      String w,
      String b,
      String opMenu,
      String opFrame) {
    if (selection != null) {
      nt.setPrimary(Color.decode(selection));
    }
    if (background != null) {
      nt.setSecondary(Color.decode(background));
    }

    if (p1 != null) {
      nt.setPrimary1(Color.decode(p1));
    }
    if (p2 != null) {
      nt.setPrimary2(Color.decode(p2));
    }
    if (p3 != null) {
      nt.setPrimary3(Color.decode(p3));
    }

    if (s1 != null) {
      nt.setSecondary1(Color.decode(s1));
    }
    if (s2 != null) {
      nt.setSecondary2(Color.decode(s2));
    }
    if (s3 != null) {
      nt.setSecondary3(Color.decode(s3));
    }

    if (w != null) {
      nt.setWhite(Color.decode(w));
    }
    if (b != null) {
      nt.setBlack(Color.decode(b));
    }

    if (opMenu != null) {
      nt.setMenuOpacity(Integer.parseInt(opMenu));
    }
    if (opFrame != null) {
      nt.setFrameOpacity(Integer.parseInt(opFrame));
    }

    return nt;
  }
 /**
  * Determine the color used for blurring. If the no blurColor is set (see {@link
  * JModalConfiguration#setBlurColor(Color) setBlurColor}) then the {@link
  * JBusyPanel#DEFAULT_ALPHA_TRANSPARENCY_FACTOR DEFAULT_ALPHA_TRANSPARENCY_FACTOR} is applied to
  * the supplied backgroundColor.
  *
  * @param backgroundColor Color Optional base color for blurring.
  * @return int Current blurring color.
  */
 public static Color getBlurColor(Color backgroundColor) {
   if (getBlurColor() == null) {
     return new Color(
         backgroundColor.getRed(),
         backgroundColor.getGreen(),
         backgroundColor.getBlue(),
         JBusyPanel.DEFAULT_ALPHA_TRANSPARENCY_FACTOR);
   } else {
     return getBlurColor();
   }
 }
 public Color getColor() {
   if (myColorWheelPanel.myColorWheel.myOpacity == 255) {
     return myColor;
   } else {
     //noinspection UseJBColor
     return new Color(
         myColor.getRed(),
         myColor.getGreen(),
         myColor.getBlue(),
         myColorWheelPanel.myColorWheel.myOpacity);
   }
 }
    /**
     * @param points
     * @param color
     * @param g
     */
    private void paintSequence(
        Slot type, List<List<ValuePointColored>> points, Color color, Graphics2D g) {
      int i = 0;
      int size = points.size();

      if (size > 0) {
        double increment = 200 / size;

        for (List<ValuePointColored> valuePoints : points) {
          int alpha = (int) (i * increment) + 55;
          Color c = new Color(color.getRed(), color.getGreen(), color.getBlue(), alpha);
          for (ValuePointColored valuePoint : valuePoints) {
            double[] coordinates = valuePoint.getPoint().toArray();
            int x = xToPix(coordinates[0]);
            int y = yToPix(coordinates[1]);
            // if minimum then red, else black
            if (valuePoint.getBest() == true) {
              g.setColor(Color.red);
            } else {
              g.setColor(c);
            }
            g.setStroke(LINE);

            switch (type) {
              case CIRCLE:
                g.drawOval(x - RADIUS / 2 - 3, y - RADIUS / 2 - 3, RADIUS * 2, RADIUS * 2);
                break;
              case SQUARE:
                g.drawRect(x - RADIUS / 2 - 2, y - RADIUS / 2 - 2, RADIUS * 2 - 2, RADIUS * 2 - 2);
                break;
              case TRIANGLE:
                GeneralPath polyline = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 3);
                polyline.moveTo(x, y - RADIUS / 2 - 4);
                polyline.lineTo(x + RADIUS / 2 + 3, y + RADIUS / 2 + 1);
                polyline.lineTo(x - RADIUS / 2 - 3, y + RADIUS / 2 + 1);
                polyline.closePath();
                g.draw(polyline);
                break;
              case CROSS:
                int xLow = x - RADIUS / 2 - 1;
                int xHigh = x + RADIUS / 2 + 1;
                int yLow = y - RADIUS / 2 - 1;
                int yHigh = y + RADIUS / 2 + 1;
                g.drawLine(xLow, yLow, xHigh, yHigh);
                g.drawLine(xHigh, yLow, xLow, yHigh);
                break;
            }
          }
          i++;
        }
      }
    }
    private void setColor(Color color, Object source) {
      float[] hsb = new float[3];
      Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), hsb);
      myColor = color;
      myHue = hsb[0];
      mySaturation = hsb[1];
      myBrightness = hsb[2];
      myOpacity = color.getAlpha();

      fireColorChanged(source);

      repaint();
    }
 /**
  * Set a fixed blurring color. If the blurColor has no alpha transparency factor (see {@link
  * JBusyPanel#DEFAULT_ALPHA_NO_TRANSPARENCY_FACTOR DEFAULT_ALPHA_NO_TRANSPARENCY_FACTOR} ) the
  * {@link JBusyPanel#DEFAULT_ALPHA_TRANSPARENCY_FACTOR DEFAULT_ALPHA_TRANSPARENCY_FACTOR} is
  * applied.
  *
  * <p>If the blurColor is NULL the {@link JBusyPanel#DEFAULT_ALPHA_TRANSPARENCY_FACTOR
  * DEFAULT_ALPHA_TRANSPARENCY_FACTOR} is applied to the window's background color in {@link
  * JBusyPanel#BLUR_STYLE_ALPHA_CHANNEL BLUR_STYLE_ALPHA_CHANNEL} mode.
  *
  * @param blurColor Color New blurring color.
  */
 public static synchronized void setBlurColor(Color blurColor) {
   if ((blurColor == null)
       || (blurColor.getAlpha() != JBusyPanel.DEFAULT_ALPHA_NO_TRANSPARENCY_FACTOR)) {
     getInstance().blurColor = blurColor;
   } else {
     getInstance().blurColor =
         new Color(
             blurColor.getRed(),
             blurColor.getGreen(),
             blurColor.getBlue(),
             JBusyPanel.DEFAULT_ALPHA_TRANSPARENCY_FACTOR);
   }
 }
 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);
 }
 // Overridden for performance reasons. ---->
 @Override
 public boolean isOpaque() {
   Color back = getBackground();
   Component p = getParent();
   if (Objects.nonNull(p)) {
     p = p.getParent();
   } // p should now be the JTable.
   boolean colorMatch =
       Objects.nonNull(back)
           && Objects.nonNull(p)
           && back.equals(p.getBackground())
           && p.isOpaque();
   return !colorMatch && super.isOpaque();
 }
    @Override
    public String getToolTipText(MouseEvent event) {
      Color color = getColor(event);
      if (color != null) {
        return String.format(
            "R: %d G: %d B: %d A: %s",
            color.getRed(),
            color.getGreen(),
            color.getBlue(),
            String.format("%.2f", (float) (color.getAlpha() / 255.0)));
      }

      return super.getToolTipText(event);
    }
Exemple #23
0
 public void paintText(Graphics g, int x, int y, String title) {
   x += paintIcon(g, x, y);
   Graphics2D g2D = (Graphics2D) g;
   Color fc = AbstractLookAndFeel.getWindowTitleForegroundColor();
   if (fc.equals(Color.white)) {
     Color bc = AbstractLookAndFeel.getWindowTitleColorDark();
     g2D.setColor(bc);
     JTattooUtilities.drawString(rootPane, g, title, x - 1, y - 1);
     g2D.setColor(ColorHelper.darker(bc, 30));
     JTattooUtilities.drawString(rootPane, g, title, x + 1, y + 1);
   }
   g.setColor(fc);
   JTattooUtilities.drawString(rootPane, g, title, x, y);
 }
Exemple #24
0
  /**
   * Sets the selected color of this panel.
   *
   * <p>If this panel is in RED, GREEN, or BLUE mode, then this method converts these values to RGB
   * coordinates and calls <code>setRGB</code>.
   *
   * <p>This method may regenerate the graphic if necessary.
   *
   * @param h the hue value of the selected color.
   * @param s the saturation value of the selected color.
   * @param b the brightness value of the selected color.
   */
  public void setHSB(float h, float s, float b) {
    if (Float.isInfinite(h) || Float.isNaN(h))
      throw new IllegalArgumentException("The hue value (" + h + ") is not a valid number.");
    // hue is cyclic, so it can be any value:
    while (h < 0) h++;
    while (h > 1) h--;

    if (s < 0 || s > 1)
      throw new IllegalArgumentException("The saturation value (" + s + ") must be between [0,1]");
    if (b < 0 || b > 1)
      throw new IllegalArgumentException("The brightness value (" + b + ") must be between [0,1]");

    if (hue != h || sat != s || bri != b) {
      if (mode == ColorPicker.HUE || mode == ColorPicker.BRI || mode == ColorPicker.SAT) {
        float lastHue = hue;
        float lastBri = bri;
        float lastSat = sat;
        hue = h;
        sat = s;
        bri = b;
        if (mode == ColorPicker.HUE) {
          if (lastHue != hue) {
            regenerateImage();
          }
        } else if (mode == ColorPicker.SAT) {
          if (lastSat != sat) {
            regenerateImage();
          }
        } else if (mode == ColorPicker.BRI) {
          if (lastBri != bri) {
            regenerateImage();
          }
        }
      } else {

        Color c = new Color(Color.HSBtoRGB(h, s, b));
        setRGB(c.getRed(), c.getGreen(), c.getBlue());
        return;
      }

      Color c = new Color(Color.HSBtoRGB(hue, sat, bri));
      red = c.getRed();
      green = c.getGreen();
      blue = c.getBlue();

      regeneratePoint();
      repaint();
      fireChangeListeners();
    }
  }
Exemple #25
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);
   }
 }
    public void setColor(Color color, Object source) {
      float[] hsb = new float[3];
      Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), hsb);

      myBrightnessComponent.setValue(255 - (int) (hsb[2] * 255));
      myBrightnessComponent.repaint();

      myColorWheel.dropImage();
      if (myOpacityComponent != null && source instanceof ColorPicker) {
        myOpacityComponent.setValue(color.getAlpha());
        myOpacityComponent.repaint();
      }

      myColorWheel.setColor(color, source);
    }
  private static String toHex(@NotNull final Color color) {
    final StringBuilder sb = new StringBuilder();
    for (int i = 0; i < 3; i++) {
      String s =
          Integer.toHexString(
              i == 0 ? color.getRed() : i == 1 ? color.getGreen() : color.getBlue());
      if (s.length() < 2) {
        sb.append('0');
      }

      sb.append(s);
    }

    return sb.toString();
  }
 public void overlay() {
   for (int y = 0; y < height; ++y) {
     for (int x = 0; x < width; ++x) {
       // System.out.println(nonMax.getRGB(x,y));
       if (nonMax.getRGB(x, y) != -1) {
         int rgb = img.getRGB(x, y);
         Color color = new Color(rgb);
         Color res = new Color(255, color.getGreen(), color.getBlue());
         img.setRGB(x, y, res.getRGB());
       }
     }
   }
   ImageIcon icon1 = new ImageIcon(img);
   lbl1.setIcon(icon1);
 }
  private void drawColorBar(Graphics g) {
    int minimum, maximum, height;

    minimum = 100;
    maximum = 500;
    height = 1;
    int finalI = 0;

    for (int i = 0; i < (maximum - minimum); i++) {
      float f = 0.75f * i / (float) (maximum - minimum);
      g.setColor(Color.getHSBColor(0.75f - f, 1.0f, 1.0f));
      g.fillRect(getWidth() - 40, height * i + 50, 20, height);
      finalI = i;
    }

    g.setColor(Color.BLACK);
    g.drawString(
        String.valueOf(this.opticalReturnPowerController.getMaxValue()),
        getWidth() - 60,
        48); // Max Value
    g.drawString(
        String.valueOf(this.opticalReturnPowerController.getMinValue()),
        getWidth() - 60,
        finalI + 63); // Min Value
  }
  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (!(o instanceof ColorSampleLookupValue)) {
      return false;
    }

    ColorSampleLookupValue value = (ColorSampleLookupValue) o;

    if (myIsStandard != value.myIsStandard) {
      return false;
    }
    if (myColor != null ? !myColor.equals(value.myColor) : value.myColor != null) {
      return false;
    }
    if (myName != null ? !myName.equals(value.myName) : value.myName != null) {
      return false;
    }
    if (myValue != null ? !myValue.equals(value.myValue) : value.myValue != null) {
      return false;
    }

    return true;
  }