This map is used for calculating the colors of a matching node.

All Nodes, which are not included, should not be colorized. For getting
HEX-values according to html or css standards, it is possible to use
{@link MatchedNodeColors}.

@return
484774
public Map<SNode, Long> getMarkedAndCovered()
  {
    if(cachedMarkedAndCoveredNodes == null)
    {      
      if (document != null)
      {
        cachedMarkedAndCoveredNodes = CommonHelper.createSNodeMapFromIDs(
          markedAndCovered, document.getDocumentGraph());
      }
    }
    
    return cachedMarkedAndCoveredNodes;
  }
424830
public boolean matches(final Node node) throws IllegalArgumentException {
        // Precondition checks
        if (node == null) {
            throw new IllegalArgumentException("node must be specified");
        }

        if (!name.equals(node.getName())) {
            return false;
        }

        if ((text != null && node.getText() == null) || (text != null && !text.trim().equals(node.getText().trim()))) {
            return false;
        }

        if (attributes != null) {
            for (final Map.Entry<String, String> attribute : attributes.entrySet()) {
                final String attrValue = attribute.getValue();
                final String attrName = attribute.getKey();

                if (!attrValue.equals(node.getAttribute(attrName))) {
                    return false;
                }
            }
        }

        return true;
    }
368474
public static boolean isHexColorValue (@Nullable final String sValue)
  {
    final String sRealValue = StringHelper.trim (sValue);
    return StringHelper.hasText (sRealValue) &&
           sRealValue.charAt (0) == CCSSValue.PREFIX_HEX &&
           RegExHelper.stringMatchesPattern (PATTERN_HEX, sRealValue);
  }
1191020
@Override
    protected IIOMetadataNode getStandardChromaNode() {
        IIOMetadataNode chroma = new IIOMetadataNode("Chroma");

        IIOMetadataNode colorSpaceType = new IIOMetadataNode("ColorSpaceType");
        String cs;
        switch (header.mode) {
            case PSD.COLOR_MODE_BITMAP:
            case PSD.COLOR_MODE_GRAYSCALE:
            case PSD.COLOR_MODE_DUOTONE: // Rationale: Spec says treat as gray...
                cs = "GRAY";
                break;
            case PSD.COLOR_MODE_RGB:
            case PSD.COLOR_MODE_INDEXED:
                cs = "RGB";
                break;
            case PSD.COLOR_MODE_CMYK:
                cs = "CMYK";
                break;
            case PSD.COLOR_MODE_MULTICHANNEL:
                cs = getMultiChannelCS(header.channels);
                break;
            case PSD.COLOR_MODE_LAB:
                cs = "Lab";
                break;
            default:
                throw new AssertionError("Unreachable");
        }
        colorSpaceType.setAttribute("name", cs);
        chroma.appendChild(colorSpaceType);

        // TODO: Channels might be 5 for RGB + A + Mask... Probably not correct
        IIOMetadataNode numChannels = new IIOMetadataNode("NumChannels");
        numChannels.setAttribute("value", Integer.toString(header.channels));
        chroma.appendChild(numChannels);

        IIOMetadataNode blackIsZero = new IIOMetadataNode("BlackIsZero");
        blackIsZero.setAttribute("value", "true");
        chroma.appendChild(blackIsZero);

        if (header.mode == PSD.COLOR_MODE_INDEXED) {
            IIOMetadataNode paletteNode = createPaletteNode();
            chroma.appendChild(paletteNode);
        }

        // TODO: Use
//        if (bKGD_present) {
//            if (bKGD_colorType == PNGImageReader.PNG_COLOR_PALETTE) {
//                node = new IIOMetadataNode("BackgroundIndex");
//                node.setAttribute("value", Integer.toString(bKGD_index));
//            } else {
//                node = new IIOMetadataNode("BackgroundColor");
//                int r, g, b;
//
//                if (bKGD_colorType == PNGImageReader.PNG_COLOR_GRAY) {
//                    r = g = b = bKGD_gray;
//                } else {
//                    r = bKGD_red;
//                    g = bKGD_green;
//                    b = bKGD_blue;
//                }
//                node.setAttribute("red", Integer.toString(r));
//                node.setAttribute("green", Integer.toString(g));
//                node.setAttribute("blue", Integer.toString(b));
//            }
//            chroma_node.appendChild(node);
//        }

        return chroma;
    }
815200
public static String toHex(int color) {
		validateRGB(color);
		String hex = Integer.toHexString(color).toUpperCase();
		if (hex.length() == 1) {
			hex = "0" + hex;
		}
		return hex;
	}
1093886
public R getMatch() {
    for (Pattern<T, R> pattern : patterns) {
      if (pattern.matches(value)) {
        return pattern.apply(value);
      }
    }

    throw new MatchException("No match found for " + value);
  }
617772
def color=(hex)
      valid_colors = Type::Color.constants.map { |c| Type::Color.const_get(c) }
      unless hex.nil? || valid_colors.include?(hex.to_s.downcase)
        raise ArgumentError, "Unable to set color to an invalid color.\nUse one of #{valid_colors}"
      end

      @color = hex
    end
1225778
@Override
	public String colorBySequenceCluster() {
		QuatSymmetrySubunits subunits = rotationAxisAligner.getSubunits();
		int n = subunits.getSubunitCount();
		List<Integer> modelNumbers = subunits.getModelNumbers();
		List<String> chainIds = subunits.getChainIds();
		List<Integer> seqClusterIds = subunits.getClusterIds();
		int clusters = Collections.max(seqClusterIds) + 1;
		Color[] col = ColorBrewer.BrBG.getColorPalette(clusters);
		Color4f[] colors = ColorConverter.convertColor4f(col);
		Map<Color4f, List<String>> colorMap = new HashMap<Color4f, List<String>>();

		for (int i = 0; i < n; i++) {
			Color4f c = colors[seqClusterIds.get(i)];
			List<String> ids = colorMap.get(c);
			if (ids == null) {
				ids = new ArrayList<String>();
				colorMap.put(c,  ids);
			}
			String id = getChainSpecification(modelNumbers, chainIds, i);
			ids.add(id);

		}

		return defaultColoring + getJmolColorScript(colorMap) + getJmolLigandScript();
	}
351835
public HSBColor getComplementaryColor() {
        double[] rgb = HSBColor.getRGB(hue, saturation, brightness);
        double[] hsb = HSBColor.getHSB(1.0 - rgb[0], 1.0 - rgb[1], 1.0 - rgb[2]);
        return new HSBColor(hsb[0], hsb[1], hsb[2]);
    }
1355907
public static Style pink() {
        final Style style = new Style();
        style.color = PaletteUtils.getSolidColor(PaletteUtils.MATERIAL_PINK);
        return style;
    }
1240913
protected int getColor(Node node)
	{
		if (!colors.containsKey(node))
		{
			// Absence of color is interpreted as white
			return WHITE;
		}
		else
		{
			return colors.get(node);
		}
	}
94913
public Color parse(String value)
    {
        if (value.length() <= 1) {
            throw new ConversionException(USAGE);
        }

        if (value.charAt(0) == '#') {
            return parseHtml(value);
        } else if (value.indexOf(',') != -1) {
            return parseRGB(value);
        } else {
            throw new ConversionException(USAGE);
        }
    }
653586
public static GenericColor valueOf(String color) {

    Objects.requireNonNull(color, "color");
    Color namedColor = Color.fromName(color);
    if (namedColor != null) {
      return valueOf(namedColor);
    }
    int length = color.length();
    Throwable cause = null;
    try {
      // "#RRGGBB" / #AARRGGBB
      Color hexColor = Color.parseHexString(color);
      if (hexColor != null) {
        return valueOf(hexColor);
      }
      // "rgb(1,1,1)" = 10
      if (length >= 7) {
        String model = BasicHelper.toUpperCase(color.substring(0, 3));
        ColorModel colorModel = ColorModel.valueOf(model);
        int index = 3;
        boolean hasAlpha = false;
        char c = Character.toLowerCase(color.charAt(index));
        if (c == 'a') {
          hasAlpha = true;
          index++;
          c = color.charAt(index);
        }
        if (c == '(') {
          index++;
          int endIndex = color.indexOf(',', index);
          if (endIndex > 0) {
            String firstSegment = color.substring(index, endIndex).trim();
            index = endIndex + 1;
            endIndex = color.indexOf(',', index);
            if (endIndex > 0) {
              String secondSegment = color.substring(index, endIndex).trim();
              index = endIndex + 1;
              if (hasAlpha) {
                endIndex = color.indexOf(',', index);
              } else {
                endIndex = length - 1;
              }
              if (endIndex > 0) {
                String thirdSegment = color.substring(index, endIndex).trim();
                Alpha alpha;
                if (hasAlpha) {
                  alpha = new Alpha(color.substring(endIndex + 1, length - 1));
                } else {
                  alpha = Alpha.OPAQUE;
                }
                switch (colorModel) {
                  case RGB:
                    return valueOf(new Red(firstSegment), new Green(secondSegment), new Blue(thirdSegment), alpha);
                  case HSL:
                    return valueOf(new Hue(firstSegment), new Saturation(secondSegment), new Lightness(thirdSegment), alpha);
                  case HSV:
                  case HSB:
                    return valueOf(new Hue(firstSegment), new Saturation(secondSegment), new Brightness(thirdSegment), alpha);
                  default :
                    throw new IllegalStateException("" + colorModel);
                }
              }
            }
          }
        }
      }
    } catch (RuntimeException e) {
      cause = e;
    }
    throw new IllegalArgumentException(color, cause);
  }
1022312
public int getColor(float v) {
/*
		v *= 255;
		int n = (int)v;
		float f = v-n;
		if (n < 0)
			return map[0];
		else if (n >= 255)
			return map[255];
		return ImageMath.mixColors(f, map[n], map[n+1]);
*/
		int n = (int)(v*255);
		if (n < 0)
			n = 0;
		else if (n > 255)
			n = 255;
		return map[n];
	}
440555
protected Map<String, List<Element>> elementsIndexByName() {
        HashMap<String, List<Element>> index = new HashMap<>();
        for (Object part : renderingParts) {//We have to use the rendering order of elements for multiple elements with same name
            if (part instanceof Element) {
                Element element = (Element) part;
                String name = element.getProperty("name");
                if (name != null && !name.trim().isEmpty()) {
                    boolean multiValued = element.isMultiValue();
                    if (multiValued && index.containsKey(name)) {
                        throw new IllegalStateException("Name '" + name + "' cannot be repeated in the form if any of the elements is multi-valued");
                    }

                    if (name.contains("[") && name.contains("]")) {
                        throw new IllegalStateException("Name '" + name + "' cannot be in array form");
                    }

                    if (!index.containsKey(name)) {
                        index.put(name, new ArrayList<Element>());
                    } else {
                        Class<?> expectedType = index.get(name).get(0).getValueType();
                        if (!element.getValueType().equals(expectedType)) {
                            //This is necessary for calling fillBeanProperties
                            throw new IllegalStateException("Multiple elements with same name '" + name + "' should all have the same value type");
                        }
                    }

                    index.get(name).add(element);
                }
            }

        }

        return index;
    }
48916
public Map<T, Integer> getAllSorted()
    {
        Map<T, Integer> map = styles;
        TreeMap<T, Integer> smap = new TreeMap<T, Integer>(new StyleCountComparator(map));
        smap.putAll(map);
        return smap;
    }
312958
public Color getFromString(final String hexValue) {
        final String hv = hexValue.toLowerCase(Locale.US);
        Color color = this.colorByHexValue.get(hv);
        if (color == null) {
            color = new Color() {
                @Override
                public String hexValue() {
                    return hv;
                }
            };
            this.colorByHexValue.put(hv, color);
        }
        return color;
    }