// Copyright (c) Lawrence Livermore National Security, LLC and other VisIt
// Project developers.  See the top-level LICENSE file for dates and other
// details.  No copyright assignment is required to contribute to VisIt.

package llnl.visit;

import java.lang.Double;
import java.util.Vector;

// ****************************************************************************
// Class: VisualCueInfo
//
// Purpose:
//    attributes necessary to describe a visual cue in a VisWindow (e.g. pick point or refline)
//
// Notes:      Autogenerated by xml2java.
//
// Programmer: xml2java
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

public class VisualCueInfo extends AttributeSubject
{
    private static int VisualCueInfo_numAdditionalAtts = 10;

    // Enum values
    public final static int CUETYPE_PICKPOINT = 0;
    public final static int CUETYPE_REFLINE = 1;
    public final static int CUETYPE_UNKNOWN = 2;


    public VisualCueInfo()
    {
        super(VisualCueInfo_numAdditionalAtts);

        points = new Vector();
        cueType = CUETYPE_UNKNOWN;
        color = new ColorAttribute(0, 0, 0);
        glyphType = new String("");
        label = new String("");
        showLabel = false;
        lineWidth = 0;
        opacity = 1;
        highlightColor = new float[3];
        highlightColor[0] = 0f;
        highlightColor[1] = 1f;
        highlightColor[2] = 0f;
        showHighlight = false;
    }

    public VisualCueInfo(int nMoreFields)
    {
        super(VisualCueInfo_numAdditionalAtts + nMoreFields);

        points = new Vector();
        cueType = CUETYPE_UNKNOWN;
        color = new ColorAttribute(0, 0, 0);
        glyphType = new String("");
        label = new String("");
        showLabel = false;
        lineWidth = 0;
        opacity = 1;
        highlightColor = new float[3];
        highlightColor[0] = 0f;
        highlightColor[1] = 1f;
        highlightColor[2] = 0f;
        showHighlight = false;
    }

    public VisualCueInfo(VisualCueInfo obj)
    {
        super(obj);

        int i;

        points = new Vector(obj.points.size());
        for(i = 0; i < obj.points.size(); ++i)
        {
            Double dv = (Double)obj.points.elementAt(i);
            points.addElement(new Double(dv.doubleValue()));
        }

        cueType = obj.cueType;
        color = new ColorAttribute(obj.color);
        glyphType = new String(obj.glyphType);
        label = new String(obj.label);
        showLabel = obj.showLabel;
        lineWidth = obj.lineWidth;
        opacity = obj.opacity;
        highlightColor = new float[3];
        highlightColor[0] = obj.highlightColor[0];
        highlightColor[1] = obj.highlightColor[1];
        highlightColor[2] = obj.highlightColor[2];

        showHighlight = obj.showHighlight;

        SelectAll();
    }

    public int Offset()
    {
        return super.Offset() + super.GetNumAdditionalAttributes();
    }

    public int GetNumAdditionalAttributes()
    {
        return VisualCueInfo_numAdditionalAtts;
    }

    public boolean equals(VisualCueInfo obj)
    {
        int i;

        // Compare the elements in the points vector.
        boolean points_equal = (obj.points.size() == points.size());
        for(i = 0; (i < points.size()) && points_equal; ++i)
        {
            // Make references to Double from Object.
            Double points1 = (Double)points.elementAt(i);
            Double points2 = (Double)obj.points.elementAt(i);
            points_equal = points1.equals(points2);
        }
        // Compare the highlightColor arrays.
        boolean highlightColor_equal = true;
        for(i = 0; i < 3 && highlightColor_equal; ++i)
            highlightColor_equal = (highlightColor[i] == obj.highlightColor[i]);

        // Create the return value
        return (points_equal &&
                (cueType == obj.cueType) &&
                (color == obj.color) &&
                (glyphType.equals(obj.glyphType)) &&
                (label.equals(obj.label)) &&
                (showLabel == obj.showLabel) &&
                (lineWidth == obj.lineWidth) &&
                (opacity == obj.opacity) &&
                highlightColor_equal &&
                (showHighlight == obj.showHighlight));
    }

    // Property setting methods
    public void SetPoints(Vector points_)
    {
        points = points_;
        Select(0);
    }

    public void SetCueType(int cueType_)
    {
        cueType = cueType_;
        Select(1);
    }

    public void SetColor(ColorAttribute color_)
    {
        color = color_;
        Select(2);
    }

    public void SetGlyphType(String glyphType_)
    {
        glyphType = glyphType_;
        Select(3);
    }

    public void SetLabel(String label_)
    {
        label = label_;
        Select(4);
    }

    public void SetShowLabel(boolean showLabel_)
    {
        showLabel = showLabel_;
        Select(5);
    }

    public void SetLineWidth(int lineWidth_)
    {
        lineWidth = lineWidth_;
        Select(6);
    }

    public void SetOpacity(double opacity_)
    {
        opacity = opacity_;
        Select(7);
    }

    public void SetHighlightColor(float[] highlightColor_)
    {
        highlightColor[0] = highlightColor_[0];
        highlightColor[1] = highlightColor_[1];
        highlightColor[2] = highlightColor_[2];
        Select(8);
    }

    public void SetHighlightColor(float e0, float e1, float e2)
    {
        highlightColor[0] = e0;
        highlightColor[1] = e1;
        highlightColor[2] = e2;
        Select(8);
    }

    public void SetShowHighlight(boolean showHighlight_)
    {
        showHighlight = showHighlight_;
        Select(9);
    }

    // Property getting methods
    public Vector         GetPoints() { return points; }
    public int            GetCueType() { return cueType; }
    public ColorAttribute GetColor() { return color; }
    public String         GetGlyphType() { return glyphType; }
    public String         GetLabel() { return label; }
    public boolean        GetShowLabel() { return showLabel; }
    public int            GetLineWidth() { return lineWidth; }
    public double         GetOpacity() { return opacity; }
    public float[]        GetHighlightColor() { return highlightColor; }
    public boolean        GetShowHighlight() { return showHighlight; }

    // Write and read methods.
    public void WriteAtts(CommunicationBuffer buf)
    {
        if(WriteSelect(0, buf))
            buf.WriteDoubleVector(points);
        if(WriteSelect(1, buf))
            buf.WriteInt(cueType);
        if(WriteSelect(2, buf))
            color.Write(buf);
        if(WriteSelect(3, buf))
            buf.WriteString(glyphType);
        if(WriteSelect(4, buf))
            buf.WriteString(label);
        if(WriteSelect(5, buf))
            buf.WriteBool(showLabel);
        if(WriteSelect(6, buf))
            buf.WriteInt(lineWidth);
        if(WriteSelect(7, buf))
            buf.WriteDouble(opacity);
        if(WriteSelect(8, buf))
            buf.WriteFloatArray(highlightColor);
        if(WriteSelect(9, buf))
            buf.WriteBool(showHighlight);
    }

    public void ReadAtts(int index, CommunicationBuffer buf)
    {
        switch(index)
        {
        case 0:
            SetPoints(buf.ReadDoubleVector());
            break;
        case 1:
            SetCueType(buf.ReadInt());
            break;
        case 2:
            color.Read(buf);
            Select(2);
            break;
        case 3:
            SetGlyphType(buf.ReadString());
            break;
        case 4:
            SetLabel(buf.ReadString());
            break;
        case 5:
            SetShowLabel(buf.ReadBool());
            break;
        case 6:
            SetLineWidth(buf.ReadInt());
            break;
        case 7:
            SetOpacity(buf.ReadDouble());
            break;
        case 8:
            SetHighlightColor(buf.ReadFloatArray());
            break;
        case 9:
            SetShowHighlight(buf.ReadBool());
            break;
        }
    }

    public String toString(String indent)
    {
        String str = new String();
        str = str + doubleVectorToString("points", points, indent) + "\n";
        str = str + indent + "cueType = ";
        if(cueType == CUETYPE_PICKPOINT)
            str = str + "CUETYPE_PICKPOINT";
        if(cueType == CUETYPE_REFLINE)
            str = str + "CUETYPE_REFLINE";
        if(cueType == CUETYPE_UNKNOWN)
            str = str + "CUETYPE_UNKNOWN";
        str = str + "\n";
        str = str + indent + "color = {" + color.Red() + ", " + color.Green() + ", " + color.Blue() + ", " + color.Alpha() + "}\n";
        str = str + stringToString("glyphType", glyphType, indent) + "\n";
        str = str + stringToString("label", label, indent) + "\n";
        str = str + boolToString("showLabel", showLabel, indent) + "\n";
        str = str + intToString("lineWidth", lineWidth, indent) + "\n";
        str = str + doubleToString("opacity", opacity, indent) + "\n";
        str = str + floatArrayToString("highlightColor", highlightColor, indent) + "\n";
        str = str + boolToString("showHighlight", showHighlight, indent) + "\n";
        return str;
    }


    // Attributes
    private Vector         points; // vector of Double objects
    private int            cueType;
    private ColorAttribute color;
    private String         glyphType;
    private String         label;
    private boolean        showLabel;
    private int            lineWidth;
    private double         opacity;
    private float[]        highlightColor;
    private boolean        showHighlight;
}

