IppPointDouble.java 4.61 KB
/*
 * Decompiled with CFR 0_118.
 */
package com.scene7.is.ipp.messages;

import com.scene7.is.ipp.messages.Ipp;
import com.scene7.is.ipp.messages.IppDouble;
import com.scene7.is.ipp.messages.IppInt;
import com.scene7.is.ipp.messages.Offset;
import java.io.IOException;
import java.io.Writer;

public class IppPointDouble {
    private double x_;
    private double y_;

    public IppPointDouble(double x, double y) {
        this.x_ = x;
        this.y_ = y;
    }

    public String toString() {
        StringBuffer buffer = new StringBuffer();
        buffer.append("[");
        buffer.append("x: ").append(String.valueOf(this.x_)).append(" ");
        buffer.append("y: ").append(String.valueOf(this.y_)).append(" ");
        buffer.append("]");
        return buffer.toString();
    }

    public boolean equals(Object o) {
        if (!(o instanceof IppPointDouble)) {
            return false;
        }
        IppPointDouble e = (IppPointDouble)o;
        if (this.x_ != e.x_) {
            return false;
        }
        if (this.y_ != e.y_) {
            return false;
        }
        return true;
    }

    public static IppPointDouble Unstuff(byte[] arr, Offset arrayPos) {
        Ipp.Assert((arrayPos.val & 7) == 0, "IppPointDouble align");
        double x = IppDouble.Unstuff(arr, arrayPos);
        double y = IppDouble.Unstuff(arr, arrayPos);
        return new IppPointDouble(x, y);
    }

    public static IppPointDouble[] UnstuffArray(byte[] arr, Offset arrayPos) {
        Ipp.Assert((arrayPos.val & 3) == 0, "IppPointDouble alignemt");
        int count = IppInt.Unstuff(arr, arrayPos);
        int size = IppInt.Unstuff(arr, arrayPos);
        Ipp.Assert(count == 0 || size >= 16, "IppPointDouble count");
        Offset roff = new Offset(IppInt.Unstuff(arr, arrayPos));
        Offset loff = new Offset(roff.val);
        IppPointDouble[] result = new IppPointDouble[count];
        for (int i = 0; i < count; ++i) {
            loff.val = roff.val;
            result[i] = IppPointDouble.Unstuff(arr, loff);
            roff.val += size;
        }
        return result;
    }

    public static IppPointDouble[] UnstuffFixedArray(byte[] arr, Offset arrayPos, int count) {
        IppPointDouble[] result = new IppPointDouble[count];
        for (int i = 0; i < count; ++i) {
            result[i] = IppPointDouble.Unstuff(arr, arrayPos);
        }
        return result;
    }

    public static void Stuff(byte[] arr, Offset arrayPos, Offset varPos, IppPointDouble val) {
        Ipp.Assert((arrayPos.val & 7) == 0, "IppPointDouble align");
        if (val != null) {
            IppDouble.Stuff(arr, arrayPos, varPos, val.x());
            IppDouble.Stuff(arr, arrayPos, varPos, val.y());
        } else {
            Ipp.StuffNullBytes(arr, arrayPos, 16);
        }
    }

    public static void StuffArray(byte[] arr, Offset arrayPos, Offset varPos, IppPointDouble[] val) {
        Ipp.Assert((arrayPos.val & 3) == 0, "IppPointDouble stuffarray align");
        int len = val != null ? val.length : 0;
        IppInt.Stuff(arr, arrayPos, varPos, len);
        IppInt.Stuff(arr, arrayPos, varPos, 16);
        Ipp.StuffOffset(arr, arrayPos, varPos, len > 0 ? 8 : 1);
        Offset varvarPos = new Offset(varPos.val + 16 * len);
        for (int i = 0; i < len; ++i) {
            IppPointDouble.Stuff(arr, varPos, varvarPos, val[i]);
        }
        varPos.val = varvarPos.val;
    }

    public static void StuffFixedArray(byte[] arr, Offset arrayPos, Offset varPos, int count, IppPointDouble[] val) {
        Ipp.Assert(val.length == count, "IppPointDouble count");
        for (int i = 0; i < count; ++i) {
            IppPointDouble.Stuff(arr, arrayPos, varPos, val[i]);
        }
    }

    public static void Print(Writer tf, String label, IppPointDouble it) throws IOException {
        String ll = label + "IppPointDouble: ";
        if (it == null) {
            tf.write(ll + "NULL!!\n");
            return;
        }
        tf.write(ll + "\n");
        IppDouble.Print(tf, ll + "x: ", it.x());
        IppDouble.Print(tf, ll + "y: ", it.y());
    }

    public static void PrintArray(Writer tf, String label, IppPointDouble[] it) throws IOException {
        String ll = label + "IppPointDouble Array, length: ";
        tf.write(ll);
        if (it == null) {
            tf.write("NULL!!!\n");
            return;
        }
        tf.write("" + it.length + "\n");
        for (int i = 0; i < it.length; ++i) {
            ll = label + "IppPointDouble[" + String.valueOf(i) + "]: ";
            IppPointDouble.Print(tf, ll, it[i]);
        }
    }

    public double x() {
        return this.x_;
    }

    public double y() {
        return this.y_;
    }
}