/**
 * 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.StructureFragment;

/**
 * @author Dmitry Repchevsky
 */

public class StructureFragmentComponent extends AnnotationComponent<StructureFragment>
{
    public StructureFragmentComponent(StructureFragment annotation)
    {
        super(annotation);
    }

    @Override
    protected String getHtml(StructureFragment 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 chainMobyString = annotation.getChain();
        if (chainMobyString != null)
        {
            sb.append("chain: ").append(chainMobyString.getString());
        }

        MobyInteger numResiduesMobyInteger = annotation.getEnd();
        if (numResiduesMobyInteger != null)
        {
            sb.append("<br/>residues: ").append(numResiduesMobyInteger.getInteger());
        }

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

        return sb.toString();
    }
}