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('"');
    }
  }
Example #2
0
  public void paintText(Graphics g, int x, int y, String title) {
    x += paintIcon(g, x, y);
    Graphics2D g2D = (Graphics2D) g;
    Shape savedClip = g2D.getClip();
    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);

    Area clipArea = new Area(new Rectangle2D.Double(x, 0, getWidth(), getHeight() / 2));
    clipArea.intersect(new Area(savedClip));
    g2D.setClip(clipArea);
    JTattooUtilities.drawString(rootPane, g, title, x, y);

    clipArea = new Area(new Rectangle2D.Double(x, (getHeight() / 2), getWidth(), getHeight()));
    clipArea.intersect(new Area(savedClip));
    g2D.setClip(clipArea);
    g.setColor(ColorHelper.darker(fc, 20));
    JTattooUtilities.drawString(rootPane, g, title, x, y);

    g2D.setClip(savedClip);
  }
Example #3
0
  public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
    // choose which colors we want to use
    Color bg = c.getBackground();

    if (c.getParent() != null) {
      bg = c.getParent().getBackground();
    }

    if (bg != null) {
      Color mid = bg.darker();
      Color edge = average(mid, bg);

      g.setColor(bg);
      g.drawLine(0, h - 2, w, h - 2);
      g.drawLine(0, h - 1, w, h - 1);
      g.drawLine(w - 2, 0, w - 2, h);
      g.drawLine(w - 1, 0, w - 1, h);

      // draw the drop-shadow
      g.setColor(mid);
      g.drawLine(1, h - 2, w - 2, h - 2);
      g.drawLine(w - 2, 1, w - 2, h - 2);

      g.setColor(edge);
      g.drawLine(2, h - 1, w - 2, h - 1);
      g.drawLine(w - 1, 2, w - 1, h - 2);
    }
  }
 public static final Color contrastBW(Color c) {
   if ((c.getRed() + c.getGreen() + c.getBlue()) > 200.0) {
     return (Color.black);
   } else {
     return (Color.white);
   }
 }
Example #5
0
  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;
    }
  }
Example #6
0
  @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);
    }
  }
  @Override
  protected void onDraw(Canvas canvas) {
    // draw the background and color wheel
    canvas.drawBitmap(mBackground, mBackgroundPosition.x, mBackgroundPosition.y, null);
    canvas.drawBitmap(mWheel, mWheelPosition.x, mWheelPosition.y, null);

    // setup paint for the gradient filling
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setStyle(Paint.Style.FILL);
    paint.setStrokeWidth(2.0f);
    // create a shader that will show the range of brightness settings
    float[] gradientStartColor = new float[3];
    float[] gradientEndColor = new float[3];
    System.arraycopy(mNewColor, 0, gradientStartColor, 0, mNewColor.length);
    System.arraycopy(mNewColor, 0, gradientEndColor, 0, mNewColor.length);
    gradientStartColor[2] = 1.0f;
    gradientEndColor[2] = 0.0f;
    Shader gradientShader =
        new LinearGradient(
            (float) (mWheelPosition.x + mRadius),
            mWheelPosition.y,
            mOuterArcRect.right,
            mWheelPosition.y + mWheel.getHeight(),
            Color.HSVToColor(gradientStartColor),
            Color.HSVToColor(gradientEndColor),
            Shader.TileMode.MIRROR);
    paint.setShader(gradientShader);
    canvas.drawPath(mArcPath, paint);

    drawHSCrosshairs(canvas);
    drawBrightnessIndicator(canvas);
  }
  /**
   * Draw labels for picking.
   *
   * @param dc Current draw context.
   * @param pickSupport the PickSupport instance to be used.
   */
  protected void doPick(DrawContext dc, PickSupport pickSupport) {
    GL gl = dc.getGL();

    Angle heading = this.rotation;

    double headingDegrees;
    if (heading != null) headingDegrees = heading.degrees;
    else headingDegrees = 0;

    int x = this.screenPoint.x;
    int y = this.screenPoint.y;

    boolean matrixPushed = false;
    try {
      if (headingDegrees != 0) {
        gl.glPushMatrix();
        matrixPushed = true;

        gl.glTranslated(x, y, 0);
        gl.glRotated(headingDegrees, 0, 0, 1);
        gl.glTranslated(-x, -y, 0);
      }

      for (int i = 0; i < this.lines.length; i++) {
        Rectangle2D bounds = this.lineBounds[i];
        double width = bounds.getWidth();
        double height = bounds.getHeight();

        x = this.screenPoint.x;
        if (this.textAlign.equals(AVKey.CENTER)) x = x - (int) (width / 2.0);
        else if (this.textAlign.equals(AVKey.RIGHT)) x = x - (int) width;
        y -= this.lineHeight;

        Color color = dc.getUniquePickColor();
        int colorCode = color.getRGB();
        PickedObject po = new PickedObject(colorCode, this.getPickedObject(), this.position, false);
        pickSupport.addPickableObject(po);

        // Draw line rectangle
        gl.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());

        try {
          gl.glBegin(GL.GL_POLYGON);
          gl.glVertex3d(x, y, 0);
          gl.glVertex3d(x + width - 1, y, 0);
          gl.glVertex3d(x + width - 1, y + height - 1, 0);
          gl.glVertex3d(x, y + height - 1, 0);
          gl.glVertex3d(x, y, 0);
        } finally {
          gl.glEnd();
        }

        y -= this.lineSpacing;
      }
    } finally {
      if (matrixPushed) {
        gl.glPopMatrix();
      }
    }
  }
 /** 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;
 }
Example #10
0
  /*
   * Draws this place.
   */
  void paint(Graphics g) {
    super.paint(g); // very important, do not forget

    Graphics2D g2 = (Graphics2D) g;
    int w = this.getSize().width;
    int h = this.getSize().height;
    int x = this.getPosition().x - (w >> 1);
    int y = this.getPosition().y - (h >> 1);

    // draw forground
    if (this.getAction()) g2.setPaint(this.actionColor);
    else if (this.getSelected()) g2.setPaint(this.selectColor);
    else if (this.getEmphasized()) g2.setPaint(emphasize_color);
    // else g2.setPaint(new GradientPaint(x,y,this.foreground_color,x+w,y+h,Color.white));
    else g2.setPaint(Props.PLACE_FILL_COLOR);

    if (isMouseOver()) {
      Color c = (Color) g2.getPaint();
      g2.setPaint(new Color(c.getRed() ^ 0x66, c.getGreen() ^ 0x00, c.getBlue() ^ 0x00));
    }

    g2.fillOval(x, y, w, h);

    // draw background

    g2.setPaint(Props.PLACE_BORDER_COLOR);
    if (this.getJoined()) {
      Stroke oldStroke = g2.getStroke();
      g2.setStroke(new BasicStroke(2.5f));
      g2.drawOval(x, y, w, h);
      g2.setStroke(oldStroke);
    } else g2.drawOval(x, y, w, h);
  }
Example #11
0
  public void write(OutStream out, boolean hasAlpha) throws IOException {
    out.writeUI8(fillType);

    if (fillType == SWFConstants.FILL_SOLID) {
      if (hasAlpha) color.writeWithAlpha(out);
      else color.writeRGB(out);
    } else if (fillType == SWFConstants.FILL_LINEAR_GRADIENT
        || fillType == SWFConstants.FILL_RADIAL_GRADIENT) {
      matrix.write(out);

      int numRatios = ratios.length;

      out.writeUI8(numRatios);

      for (int i = 0; i < numRatios; i++) {
        if (colors[i] == null) continue;

        out.writeUI8(ratios[i]);

        if (hasAlpha) colors[i].writeWithAlpha(out);
        else colors[i].writeRGB(out);
      }
    } else if (fillType == SWFConstants.FILL_TILED_BITMAP
        || fillType == SWFConstants.FILL_CLIPPED_BITMAP) {
      out.writeUI16(bitmapId);
      matrix.write(out);
    }
  }
Example #12
0
 /**
  * Compares the argument to the receiver, and returns true if they represent the <em>same</em>
  * object using a class specific comparison.
  *
  * @param object the object to compare with this object
  * @return <code>true</code> if the object is the same as this object and <code>false</code>
  *     otherwise
  * @see #hashCode()
  */
 public boolean equals(Object object) {
   if (object == this) return true;
   if (object == null) return false;
   if (!(object instanceof TextStyle)) return false;
   TextStyle style = (TextStyle) object;
   if (foreground != null) {
     if (!foreground.equals(style.foreground)) return false;
   } else if (style.foreground != null) return false;
   if (background != null) {
     if (!background.equals(style.background)) return false;
   } else if (style.background != null) return false;
   if (font != null) {
     if (!font.equals(style.font)) return false;
   } else if (style.font != null) return false;
   if (metrics != null || style.metrics != null) return false;
   if (underline != style.underline) return false;
   if (underlineStyle != style.underlineStyle) return false;
   if (borderStyle != style.borderStyle) return false;
   if (strikeout != style.strikeout) return false;
   if (rise != style.rise) return false;
   if (underlineColor != null) {
     if (!underlineColor.equals(style.underlineColor)) return false;
   } else if (style.underlineColor != null) return false;
   if (strikeoutColor != null) {
     if (!strikeoutColor.equals(style.strikeoutColor)) return false;
   } else if (style.strikeoutColor != null) return false;
   if (underlineStyle != style.underlineStyle) return false;
   if (borderColor != null) {
     if (!borderColor.equals(style.borderColor)) return false;
   } else if (style.borderColor != null) return false;
   if (data != null) {
     if (!data.equals(style.data)) return false;
   } else if (style.data != null) return false;
   return true;
 }
Example #13
0
  // construct the linear gradient from XML
  public RadialGradient(XMLUtility XMLUtility, Node root) throws ParseException {

    // get the transformation matrix
    Node matrixNode = XMLUtility.findNode(root, "Matrix");
    TransformationMatrix m = new TransformationMatrix(XMLUtility, matrixNode);

    fCenterX = m.getTranslateX();
    fCenterY = m.getTranslateY();

    double radius1 = 819.2 * m.getMatrix()[0][0]; // a
    double radius2 = 819.2 * m.getMatrix()[1][1]; // d

    if (radius1 == radius2) // circle
    {
      fRadius = radius1;
    } else // oval
    {
      // this is a stab in the dark at a filthy hack
      // I think 'a' and 'c' in the transform are modifiers for the radius of the ellipse
      // can't find any documentation on this, and for the flas I'm working with this
      // looks acceptable
      fRadius = 819.2 * m.getMatrix()[1][0]; // c
    }

    // get the gradient entries
    Vector<Node> nodes = XMLUtility.findNodes(root, "GradientEntry");
    for (Node node : nodes) {
      double ratio = XMLUtility.getDoubleAttribute(node, "ratio", 0.0);
      String colorCode = XMLUtility.getAttribute(node, "color", "#000000");
      Color color = Color.parseColor(colorCode);
      color.setAlpha(XMLUtility.getDoubleAttribute(node, "alpha", 1.0));
      fColorStops.add(new ColorStop(ratio, color));
    }
  }
 private int changeColorAlpha(int color, float value) {
   int alpha = Math.round(Color.alpha(color) * value);
   int red = Color.red(color);
   int green = Color.green(color);
   int blue = Color.blue(color);
   return Color.argb(alpha, red, green, blue);
 }
Example #15
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);
   }
 }
Example #16
0
  /**
   * Find the color band that this value falls in and assign that color.
   *
   * @param v
   * @param color
   */
  private final void absoluteValue(final double v, final int[] color) {
    final double search;
    switch (scaling) {
      case Absolute:
        search = v;
        break;
      case MinMax:
        search = (v - min) / (max - min);
        break;
      case Modulo:
        search = v % (max - min);
        break;
      default:
        search = 0;
        break;
    }

    final Map.Entry<Double, Color> lower = floorEntry(search);

    Color c;
    if (lower == null) {
      c = entrySet().iterator().next().getValue();
    } else {
      c = lower.getValue();
    }

    color[R] = c.getRed();
    color[G] = c.getGreen();
    color[B] = c.getBlue();
    color[A] = c.getAlpha();
  }
  /**
   * Compute a contrasting background color to draw the label's outline.
   *
   * @param color Label color.
   * @return A color that contrasts with {@code color}.
   */
  protected Color computeBackgroundColor(Color color) {
    float[] colorArray = new float[4];
    Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), colorArray);

    if (colorArray[2] > 0.5) return new Color(0, 0, 0, 0.7f);
    else return new Color(1, 1, 1, 0.7f);
  }
Example #18
0
 /**
  * Computes the combined histogram for a color pixel based on the following formula: RGB_Combined
  * = R*0.2126 + G*0.7152 + B*0.0722
  *
  * @param c the color of a pixel.
  * @return the combined value which is computed from R, G and B colors.
  */
 private static int computeGrayColor1(Color c) {
   int r = c.getRed();
   int g = c.getGreen();
   int b = c.getBlue();
   int gray = (int) ((double) (r * 0.2126) + (double) (g * 0.7152) + (double) (b * 0.0722));
   return gray;
 }
  @Override
  public TextStyle convert(String s) {
    if (StringUtils.isBlank(s)) {
      return TextStyle.DEFAULT;
    }

    Font f = null;
    Color fg = null;
    Color bg = null;

    String[] parts = s.split(";");
    if (parts.length > 0) {
      // Have font property
      f = Font.decode(parts[0]);

      if (parts.length > 1) {
        // Have foreground
        fg = Color.decode(parts[1]);

        if (parts.length > 2) {
          bg = Color.decode(parts[2]);
        }
      }
    }

    return new TextStyle(f, fg, bg);
  }
Example #20
0
 /**
  * Computes the combined histogram for a color pixel based on the following formula: RGB_Combined
  * = R*0.299 + G*0.587 + B*0.114
  *
  * @param c the color of a pixel.
  * @return the combined value which is computed from R, G and B colors.
  */
 private static int computeGrayColor2(Color c) {
   int r = c.getRed();
   int g = c.getGreen();
   int b = c.getBlue();
   int gray = (int) ((double) (r * 0.299) + (double) (g * 0.587) + (double) (b * 0.114));
   return gray;
 }
  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>");
  }
Example #22
0
 public void run(ImageProcessor ip) {
   if (enlarge && gd.wasOKed())
     synchronized (this) {
       if (!isEnlarged) {
         enlargeCanvas();
         isEnlarged = true;
       }
     }
   if (isEnlarged) { // enlarging may have made the ImageProcessor invalid, also for the parallel
                     // threads
     int slice = pfr.getSliceNumber();
     if (imp.getStackSize() == 1) ip = imp.getProcessor();
     else ip = imp.getStack().getProcessor(slice);
   }
   ip.setInterpolationMethod(interpolationMethod);
   if (fillWithBackground) {
     Color bgc = Toolbar.getBackgroundColor();
     if (bitDepth == 8) ip.setBackgroundValue(ip.getBestIndex(bgc));
     else if (bitDepth == 24) ip.setBackgroundValue(bgc.getRGB());
   } else ip.setBackgroundValue(0);
   ip.rotate(angle);
   if (!gd.wasOKed()) drawGridLines(gridLines);
   if (isEnlarged && imp.getStackSize() == 1) {
     imp.changes = true;
     imp.updateAndDraw();
     Undo.setup(Undo.COMPOUND_FILTER_DONE, imp);
   }
 }
    private int rotateColor(int color, float rad) {
      float deg = rad * 180 / 3.1415927f;
      int r = Color.red(color);
      int g = Color.green(color);
      int b = Color.blue(color);

      ColorMatrix cm = new ColorMatrix();
      ColorMatrix tmp = new ColorMatrix();

      cm.setRGB2YUV();
      tmp.setRotate(0, deg);
      cm.postConcat(tmp);
      tmp.setYUV2RGB();
      cm.postConcat(tmp);

      final float[] a = cm.getArray();

      int ir = floatToByte(a[0] * r + a[1] * g + a[2] * b);
      int ig = floatToByte(a[5] * r + a[6] * g + a[7] * b);
      int ib = floatToByte(a[10] * r + a[11] * g + a[12] * b);

      return Color.argb(
          Color.alpha(color), pinToByte(ir),
          pinToByte(ig), pinToByte(ib));
    }
    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);
    }
Example #25
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;
 }
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    KeyPromoterSettings that = (KeyPromoterSettings) o;

    if (allButtonsEnabled != that.allButtonsEnabled) return false;
    if (displayTime != that.displayTime) return false;
    if (fixedTipPosistion != that.fixedTipPosistion) return false;
    if (flashAnimationDelay != that.flashAnimationDelay) return false;
    if (menusEnabled != that.menusEnabled) return false;
    if (proposeToCreateShortcutCount != that.proposeToCreateShortcutCount) return false;
    if (toolWindowButtonsEnabled != that.toolWindowButtonsEnabled) return false;
    if (toolbarButtonsEnabled != that.toolbarButtonsEnabled) return false;
    if (backgroundColor != null
        ? !backgroundColor.equals(that.backgroundColor)
        : that.backgroundColor != null) return false;
    if (borderColor != null ? !borderColor.equals(that.borderColor) : that.borderColor != null)
      return false;
    if (popupTemplate != null
        ? !popupTemplate.equals(that.popupTemplate)
        : that.popupTemplate != null) return false;
    if (textColor != null ? !textColor.equals(that.textColor) : that.textColor != null)
      return false;

    return true;
  }
Example #27
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);
    }
Example #28
0
 void lineToArea(ImagePlus imp) {
   Roi roi = imp.getRoi();
   if (roi == null || !roi.isLine()) {
     IJ.error("Line to Area", "Line selection required");
     return;
   }
   Undo.setup(Undo.ROI, imp);
   Roi roi2 = null;
   if (roi.getType() == Roi.LINE) {
     double width = roi.getStrokeWidth();
     if (width <= 1.0) roi.setStrokeWidth(1.0000001);
     FloatPolygon p = roi.getFloatPolygon();
     roi.setStrokeWidth(width);
     roi2 = new PolygonRoi(p, Roi.POLYGON);
     roi2.setDrawOffset(roi.getDrawOffset());
   } else {
     ImageProcessor ip2 = new ByteProcessor(imp.getWidth(), imp.getHeight());
     ip2.setColor(255);
     roi.drawPixels(ip2);
     // new ImagePlus("ip2", ip2.duplicate()).show();
     ip2.setThreshold(255, 255, ImageProcessor.NO_LUT_UPDATE);
     ThresholdToSelection tts = new ThresholdToSelection();
     roi2 = tts.convert(ip2);
   }
   transferProperties(roi, roi2);
   roi2.setStrokeWidth(0);
   Color c = roi2.getStrokeColor();
   if (c != null) // remove any transparency
   roi2.setStrokeColor(new Color(c.getRed(), c.getGreen(), c.getBlue()));
   imp.setRoi(roi2);
   Roi.previousRoi = (Roi) roi.clone();
 }
 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;
 }
Example #30
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;
  }