IppMat3x2.java 6.62 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.awt.geom.AffineTransform;
import java.io.IOException;
import java.io.Writer;

public class IppMat3x2 {
    private double a_;
    private double b_;
    private double c_;
    private double d_;
    private double tx_;
    private double ty_;

    public IppMat3x2(double a, double b, double c, double d, double tx, double ty) {
        this.a_ = a;
        this.b_ = b;
        this.c_ = c;
        this.d_ = d;
        this.tx_ = tx;
        this.ty_ = ty;
    }

    public String toString() {
        StringBuffer buffer = new StringBuffer();
        buffer.append("[");
        buffer.append("a: ").append(String.valueOf(this.a_)).append(" ");
        buffer.append("b: ").append(String.valueOf(this.b_)).append(" ");
        buffer.append("c: ").append(String.valueOf(this.c_)).append(" ");
        buffer.append("d: ").append(String.valueOf(this.d_)).append(" ");
        buffer.append("tx: ").append(String.valueOf(this.tx_)).append(" ");
        buffer.append("ty: ").append(String.valueOf(this.ty_)).append(" ");
        buffer.append("]");
        return buffer.toString();
    }

    public boolean equals(Object o) {
        if (!(o instanceof IppMat3x2)) {
            return false;
        }
        IppMat3x2 e = (IppMat3x2)o;
        if (this.a_ != e.a_) {
            return false;
        }
        if (this.b_ != e.b_) {
            return false;
        }
        if (this.c_ != e.c_) {
            return false;
        }
        if (this.d_ != e.d_) {
            return false;
        }
        if (this.tx_ != e.tx_) {
            return false;
        }
        if (this.ty_ != e.ty_) {
            return false;
        }
        return true;
    }

    public static IppMat3x2 Unstuff(byte[] arr, Offset arrayPos) {
        Ipp.Assert((arrayPos.val & 7) == 0, "IppMat3x2 align");
        double a = IppDouble.Unstuff(arr, arrayPos);
        double b = IppDouble.Unstuff(arr, arrayPos);
        double c = IppDouble.Unstuff(arr, arrayPos);
        double d = IppDouble.Unstuff(arr, arrayPos);
        double tx = IppDouble.Unstuff(arr, arrayPos);
        double ty = IppDouble.Unstuff(arr, arrayPos);
        return new IppMat3x2(a, b, c, d, tx, ty);
    }

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

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

    public static void Stuff(byte[] arr, Offset arrayPos, Offset varPos, IppMat3x2 val) {
        Ipp.Assert((arrayPos.val & 7) == 0, "IppMat3x2 align");
        if (val != null) {
            IppDouble.Stuff(arr, arrayPos, varPos, val.a());
            IppDouble.Stuff(arr, arrayPos, varPos, val.b());
            IppDouble.Stuff(arr, arrayPos, varPos, val.c());
            IppDouble.Stuff(arr, arrayPos, varPos, val.d());
            IppDouble.Stuff(arr, arrayPos, varPos, val.tx());
            IppDouble.Stuff(arr, arrayPos, varPos, val.ty());
        } else {
            Ipp.StuffNullBytes(arr, arrayPos, 48);
        }
    }

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

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

    public static void Print(Writer tf, String label, IppMat3x2 it) throws IOException {
        String ll = label + "IppMat3x2: ";
        if (it == null) {
            tf.write(ll + "NULL!!\n");
            return;
        }
        tf.write(ll + "\n");
        IppDouble.Print(tf, ll + "a: ", it.a());
        IppDouble.Print(tf, ll + "b: ", it.b());
        IppDouble.Print(tf, ll + "c: ", it.c());
        IppDouble.Print(tf, ll + "d: ", it.d());
        IppDouble.Print(tf, ll + "tx: ", it.tx());
        IppDouble.Print(tf, ll + "ty: ", it.ty());
    }

    public static void PrintArray(Writer tf, String label, IppMat3x2[] it) throws IOException {
        String ll = label + "IppMat3x2 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 + "IppMat3x2[" + String.valueOf(i) + "]: ";
            IppMat3x2.Print(tf, ll, it[i]);
        }
    }

    public double a() {
        return this.a_;
    }

    public double b() {
        return this.b_;
    }

    public double c() {
        return this.c_;
    }

    public double d() {
        return this.d_;
    }

    public double tx() {
        return this.tx_;
    }

    public double ty() {
        return this.ty_;
    }

    public IppMat3x2(AffineTransform x) {
        double[] flat = new double[6];
        x.getMatrix(flat);
        this.a_ = flat[0];
        this.b_ = flat[1];
        this.c_ = flat[2];
        this.d_ = flat[3];
        this.tx_ = flat[4];
        this.ty_ = flat[5];
    }

    public AffineTransform xform() {
        double[] flat = new double[]{this.a_, this.b_, this.c_, this.d_, this.tx_, this.ty_};
        AffineTransform x = new AffineTransform(flat);
        return x;
    }
}