/**
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 *
 * Copyright (C)
 * <a href="http://www.inab.org">Spanish National Institute of Bioinformatics (INB)</a>
 * <a href="http://www.bsc.es">Barcelona Supercomputing Center (BSC)</a>
 * <a href="http://inb.bsc.es">Computational Node 6</a>
 */

package org.inb.biomoby.client.gui.ontology;

import org.inb.biomoby.shared.datatypes.MobyInteger;
import org.inb.biomoby.shared.datatypes.MobyString;
import org.inb.biomoby.shared.ontology.FeatureAnnotation;

/**
 * @author Dmitry Repchevsky
 */

public class FeatureAnnotationComponent extends AnnotationComponent<FeatureAnnotation>
{
    public FeatureAnnotationComponent(FeatureAnnotation annotation)
    {
        super(annotation);
    }

    @Override
    protected String getHtml(FeatureAnnotation annotation)
    {
        StringBuilder sb = new StringBuilder();

        sb.append("<html>");
        sb.append("<font style='color: blue'>");

        MobyInteger startMobyInteger = annotation.getStart();
        sb.append("from ").append(startMobyInteger != null ? startMobyInteger.getInteger() : "?");

        MobyInteger endMobyInteger = annotation.getEnd();
        sb.append(" to ").append(endMobyInteger != null ? endMobyInteger.getInteger() : "?").append("<br/>");

        MobyString idMobyString = annotation.getId();
        if (idMobyString != null)
        {
            sb.append("<br/>id: ").append(idMobyString.getString());
        }

        MobyString refMobyString = annotation.getRef();
        if (refMobyString != null)
        {
            sb.append("<br/>ref: ").append(refMobyString.getString());
        }

        MobyString statusMobyString = annotation.getStatus();
        if (statusMobyString != null)
        {
            sb.append("<br/>status: ").append(statusMobyString.getString());
        }

        MobyString typeMobyString = annotation.getType();
        if (typeMobyString != null)
        {
            sb.append("<br/>type: ").append(typeMobyString.getString());
        }

        MobyString descriptionMobyString = annotation.getDescription();
        if (descriptionMobyString != null)
        {
            sb.append("<br/>description: ").append(descriptionMobyString.getString());
        }

        sb.append("</font>");
        sb.append("</html>");

        return sb.toString();
    }

}
