enum Color { BLACK, WHITE }; Color nothing = null; if (nothing == Color.BLACK); // runs fine if (nothing.equals(Color.BLACK)); // throws NullPointerException
@Override public boolean equals(Object other) { if (other instanceof HtmlColorSimple == false) { return false; } return this.color.equals(((HtmlColorSimple) other).color); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; HSSFColor hssfColor = (HSSFColor) o; if (index != hssfColor.index) return false; if (index2 != hssfColor.index2) return false; return color != null ? color.equals(hssfColor.color) : hssfColor.color == null; }
@SuppressWarnings("SimplifiableIfStatement") @Override public boolean equals(Object obj) { if(obj == null) { return false; } if(getClass() != obj.getClass()) { return false; } final RGB other = (RGB) obj; return color.equals(other.color); } }
if(this.defaultColor != other.defaultColor && (this.defaultColor == null || !this.defaultColor.equals(other.defaultColor))) { return false; if(this.defaultBrightColor != other.defaultBrightColor && (this.defaultBrightColor == null || !this.defaultBrightColor.equals(other.defaultBrightColor))) { return false; if(this.defaultBackgroundColor != other.defaultBackgroundColor && (this.defaultBackgroundColor == null || !this.defaultBackgroundColor.equals(other.defaultBackgroundColor))) { return false; if(this.normalBlack != other.normalBlack && (this.normalBlack == null || !this.normalBlack.equals(other.normalBlack))) { return false; if(this.brightBlack != other.brightBlack && (this.brightBlack == null || !this.brightBlack.equals(other.brightBlack))) { return false; if(this.normalRed != other.normalRed && (this.normalRed == null || !this.normalRed.equals(other.normalRed))) { return false; if(this.brightRed != other.brightRed && (this.brightRed == null || !this.brightRed.equals(other.brightRed))) { return false; if(this.normalGreen != other.normalGreen && (this.normalGreen == null || !this.normalGreen.equals(other.normalGreen))) { return false; if(this.brightGreen != other.brightGreen && (this.brightGreen == null || !this.brightGreen.equals(other.brightGreen))) { return false; if(this.normalYellow != other.normalYellow && (this.normalYellow == null || !this.normalYellow.equals(other.normalYellow))) { return false;
if (direction == 0 && !COLOR_BG_ERROR.equals(searchField.getBackground())) { try { int caretPos = rTextArea.getCaretPosition();
private UGraphic2 createUGraphicSVG(ColorMapper colorMapper, double scale, Dimension2D dim, HtmlColor mybackcolor, String svgLinkTarget, String hover, long seed) { Color backColor = Color.WHITE; if (mybackcolor instanceof HtmlColorSimple) { backColor = colorMapper.getMappedColor(mybackcolor); } final UGraphicSvg ug; if (mybackcolor instanceof HtmlColorGradient) { ug = new UGraphicSvg(svgDimensionStyle, dim, colorMapper, (HtmlColorGradient) mybackcolor, false, scale, svgLinkTarget, hover, seed); } else if (backColor == null || backColor.equals(Color.WHITE)) { ug = new UGraphicSvg(svgDimensionStyle, dim, colorMapper, false, scale, svgLinkTarget, hover, seed); } else { ug = new UGraphicSvg(svgDimensionStyle, dim, colorMapper, StringUtils.getAsHtml(backColor), false, scale, svgLinkTarget, hover, seed); } return ug; }
public int findTabLocation(int offset) { // find first { boolean cont = true; while (offset > -1 && cont) { Element el = doc.getCharacterElement(offset); Object color = el.getAttributes().getAttribute(StyleConstants.Foreground); if (!COMMENT_COLOR.equals(color)) { cont = segment.array[offset] != '{' && segment.array[offset] != '}'; } offset -= cont ? 1 : 0; } if (offset > -1 && segment.array[offset] == '{') { while (offset > -1 && !Character.isWhitespace(segment.array[offset--])) { } } int index = offset < 0 || segment.array[offset] == '}' ? -4 : 0; if (offset > -1) { Element top = doc.getDefaultRootElement(); offset = top.getElement(top.getElementIndex(offset)).getStartOffset(); while (Character.isWhitespace(segment.array[offset++])) { index++; } } return index; } }
@Test public void testAsJavaColor() { final int color = 0xFF00FF; final Color apiColor = Color.ofRgb(color); final java.awt.Color javaColor = apiColor.asJavaColor(); final java.awt.Color testColor = new java.awt.Color(color); assertTrue(javaColor.equals(testColor)); }
private void lootReceived(Collection<ItemStack> items) { for (ItemStack itemStack : items) { WorldPoint location = WorldPoint.fromLocal(client, itemStack.getLocation()); GroundItem.GroundItemKey groundItemKey = new GroundItem.GroundItemKey(itemStack.getId(), location); GroundItem groundItem = collectedGroundItems.get(groundItemKey); if (groundItem != null) { groundItem.setMine(true); boolean shouldNotify = config.onlyShowLoot() && config.highlightedColor().equals(getHighlighted( groundItem.getName(), groundItem.getGePrice(), groundItem.getHaPrice())); if (config.notifyHighlightedDrops() && shouldNotify) { notifyHighlightedItem(groundItem); } } } }
@Subscribe public void onItemSpawned(ItemSpawned itemSpawned) { Item item = itemSpawned.getItem(); Tile tile = itemSpawned.getTile(); GroundItem groundItem = buildGroundItem(tile, item); GroundItem.GroundItemKey groundItemKey = new GroundItem.GroundItemKey(item.getId(), tile.getWorldLocation()); GroundItem existing = collectedGroundItems.putIfAbsent(groundItemKey, groundItem); if (existing != null) { existing.setQuantity(existing.getQuantity() + groundItem.getQuantity()); } boolean shouldNotify = !config.onlyShowLoot() && config.highlightedColor().equals(getHighlighted( groundItem.getName(), groundItem.getGePrice(), groundItem.getHaPrice())); if (config.notifyHighlightedDrops() && shouldNotify) { notifyHighlightedItem(groundItem); } }
/** * Sets the color to use to paint line numbers. * * @param color The color to use when painting line numbers. * @see #getLineNumberColor() */ public void setLineNumberColor(Color color) { if (color!=null && !color.equals(lineNumberColor)) { lineNumberColor = color; if (lineNumberList!=null) { lineNumberList.setForeground(color); } } }
/** * Returns whether or not the specified object is equivalent to * this one. * * @param o2 The object to which to compare. * @return Whether <code>o2</code> is another * <code>ColorBackgroundPainterStrategy</code> representing * the same color as this one. */ @Override public boolean equals(Object o2) { return o2!=null && (o2 instanceof ColorBackgroundPainterStrategy) && this.color.equals( ((ColorBackgroundPainterStrategy)o2).getColor()); }
/** * Sets the color to use to render active line ranges. * * @param color The color to use. If this is null, then the default * color is used. * @see #getActiveLineRangeColor() * @see Gutter#DEFAULT_ACTIVE_LINE_RANGE_COLOR */ public void setActiveLineRangeColor(Color color) { if (color==null) { color = Gutter.DEFAULT_ACTIVE_LINE_RANGE_COLOR; } if (!color.equals(activeLineRangeColor)) { activeLineRangeColor = color; repaint(); } }
final boolean canBeRecolored = highlighted != null || (hidden != null && config.recolorMenuHiddenItems()); if (color != null && canBeRecolored && !color.equals(config.defaultColor()))
public void setColor(Color color) { if (color.equals(this.color)) return; this.color = color; fireStateChanged(); repaint(); }
@Override public boolean equals(Object other) { if (other instanceof LineHighlightInfo) { LineHighlightInfo lhi2 = (LineHighlightInfo)other; return this.getOffset() == lhi2.getOffset() && this.getColor() == null ? lhi2.getColor() == null : this.getColor().equals(lhi2.getColor()); } return false; }
/** * Sets the color used for "mark all." This fires a property change of * type {@link #MARK_ALL_COLOR_PROPERTY}. * * @param color The color to use for "mark all." * @see #getMarkAllHighlightColor() */ public void setMarkAllHighlightColor(Color color) { Color old = (Color)markAllHighlightPainter.getPaint(); if (old!=null && !old.equals(color)) { markAllHighlightPainter.setPaint(color); RTextAreaHighlighter h = (RTextAreaHighlighter)getHighlighter(); if (h.getMarkAllHighlightCount()>0) { repaint(); // Repaint if words are highlighted. } firePropertyChange(MARK_ALL_COLOR_PROPERTY, old, color); } }