Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class Main {
    public static Element toXML(Point p, Document document) {
        Element result = document.createElement("center");
        result.setAttribute("x", Integer.toString(p.x));
        result.setAttribute("y", Integer.toString(p.y));
        return result;
    }

    public static Element toXML(Color c, Document document) {
        Element result = document.createElement("color");

        String name;
        if (c.equals(Color.WHITE)) {
            name = "white";
        } else if (c.equals(Color.CYAN)) {
            name = "cyan";
        } else if (c.equals(Color.YELLOW)) {
            name = "yellow";
        } else if (c.equals(Color.PINK)) {
            name = "pink";
        } else if (c.equals(Color.GREEN)) {
            name = "green";
        } else {
            name = "white";
        }

        result.setAttribute("name", name);

        return result;
    }
}