Java Color Create toColor(Node n)

Here you can find the source of toColor(Node n)

Description

to Color

License

Open Source License

Declaration

public static Color toColor(Node n) 

Method Source Code


//package com.java2s;
import java.awt.Color;

import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;

public class Main {
    public static Color toColor(Node n) {
        if (!n.getNodeName().equals("color")) {
            throw new IllegalArgumentException(n.getNodeName());
        }//from  w  ww  . ja  v  a 2 s. c o  m
        NamedNodeMap map = n.getAttributes();
        String s = map.getNamedItem("name").getNodeValue();
        if (s.equals("white")) {
            return Color.WHITE;
        } else if (s.equals("green")) {
            return Color.GREEN;
        } else if (s.equals("pink")) {
            return Color.PINK;
        } else if (s.equals("cyan")) {
            return Color.CYAN;
        } else if (s.equals("yellow")) {
            return Color.YELLOW;
        } else {
            return Color.WHITE;
        }
    }
}

Related

  1. toColor(final String hexString)
  2. toColor(final String text, final Color defaultValue)
  3. toColor(float[] color)
  4. toColor(int rgba)
  5. toColor(int x)
  6. toColor(short rgb565)
  7. toColor(String background)
  8. toColor(String hexString)
  9. toColor(String pString)