package net.miginfocom.layout;

import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.ObjectStreamException;
import java.util.ArrayList;

public final class AC implements Externalizable {
   private final ArrayList<DimConstraint> cList = new ArrayList(8);
   private transient int curIx = 0;

   public AC() {
      this.cList.add(new DimConstraint());
   }

   public final DimConstraint[] getConstaints() {
      return (DimConstraint[])this.cList.toArray(new DimConstraint[this.cList.size()]);
   }

   public final void setConstaints(DimConstraint[] var1) {
      if (var1 == null || var1.length < 1) {
         var1 = new DimConstraint[]{new DimConstraint()};
      }

      this.cList.clear();
      this.cList.ensureCapacity(var1.length);
      DimConstraint[] var2 = var1;
      int var3 = var1.length;

      for(int var4 = 0; var4 < var3; ++var4) {
         DimConstraint var5 = var2[var4];
         this.cList.add(var5);
      }

   }

   public int getCount() {
      return this.cList.size();
   }

   public final AC count(int var1) {
      this.makeSize(var1);
      return this;
   }

   public final AC noGrid() {
      return this.noGrid(this.curIx);
   }

   public final AC noGrid(int... var1) {
      for(int var2 = var1.length - 1; var2 >= 0; --var2) {
         int var3 = var1[var2];
         this.makeSize(var3);
         ((DimConstraint)this.cList.get(var3)).setNoGrid(true);
      }

      return this;
   }

   public final AC index(int var1) {
      this.makeSize(var1);
      this.curIx = var1;
      return this;
   }

   public final AC fill() {
      return this.fill(this.curIx);
   }

   public final AC fill(int... var1) {
      for(int var2 = var1.length - 1; var2 >= 0; --var2) {
         int var3 = var1[var2];
         this.makeSize(var3);
         ((DimConstraint)this.cList.get(var3)).setFill(true);
      }

      return this;
   }

   public final AC sizeGroup() {
      return this.sizeGroup("", this.curIx);
   }

   public final AC sizeGroup(String var1) {
      return this.sizeGroup(var1, this.curIx);
   }

   public final AC sizeGroup(String var1, int... var2) {
      for(int var3 = var2.length - 1; var3 >= 0; --var3) {
         int var4 = var2[var3];
         this.makeSize(var4);
         ((DimConstraint)this.cList.get(var4)).setSizeGroup(var1);
      }

      return this;
   }

   public final AC size(String var1) {
      return this.size(var1, this.curIx);
   }

   public final AC size(String var1, int... var2) {
      BoundSize var3 = ConstraintParser.parseBoundSize(var1, false, true);

      for(int var4 = var2.length - 1; var4 >= 0; --var4) {
         int var5 = var2[var4];
         this.makeSize(var5);
         ((DimConstraint)this.cList.get(var5)).setSize(var3);
      }

      return this;
   }

   public final AC gap() {
      ++this.curIx;
      return this;
   }

   public final AC gap(String var1) {
      return this.gap(var1, this.curIx++);
   }

   public final AC gap(String var1, int... var2) {
      BoundSize var3 = var1 != null ? ConstraintParser.parseBoundSize(var1, true, true) : null;

      for(int var4 = var2.length - 1; var4 >= 0; --var4) {
         int var5 = var2[var4];
         this.makeSize(var5);
         if (var3 != null) {
            ((DimConstraint)this.cList.get(var5)).setGapAfter(var3);
         }
      }

      return this;
   }

   public final AC align(String var1) {
      return this.align(var1, this.curIx);
   }

   public final AC align(String var1, int... var2) {
      UnitValue var3 = ConstraintParser.parseAlignKeywords(var1, true);
      if (var3 == null) {
         var3 = ConstraintParser.parseAlignKeywords(var1, false);
      }

      for(int var4 = var2.length - 1; var4 >= 0; --var4) {
         int var5 = var2[var4];
         this.makeSize(var5);
         ((DimConstraint)this.cList.get(var5)).setAlign(var3);
      }

      return this;
   }

   public final AC growPrio(int var1) {
      return this.growPrio(var1, this.curIx);
   }

   public final AC growPrio(int var1, int... var2) {
      for(int var3 = var2.length - 1; var3 >= 0; --var3) {
         int var4 = var2[var3];
         this.makeSize(var4);
         ((DimConstraint)this.cList.get(var4)).setGrowPriority(var1);
      }

      return this;
   }

   public final AC grow() {
      return this.grow(1.0F, this.curIx);
   }

   public final AC grow(float var1) {
      return this.grow(var1, this.curIx);
   }

   public final AC grow(float var1, int... var2) {
      Float var3 = new Float(var1);

      for(int var4 = var2.length - 1; var4 >= 0; --var4) {
         int var5 = var2[var4];
         this.makeSize(var5);
         ((DimConstraint)this.cList.get(var5)).setGrow(var3);
      }

      return this;
   }

   public final AC shrinkPrio(int var1) {
      return this.shrinkPrio(var1, this.curIx);
   }

   public final AC shrinkPrio(int var1, int... var2) {
      for(int var3 = var2.length - 1; var3 >= 0; --var3) {
         int var4 = var2[var3];
         this.makeSize(var4);
         ((DimConstraint)this.cList.get(var4)).setShrinkPriority(var1);
      }

      return this;
   }

   public final AC shrink() {
      return this.shrink(100.0F, this.curIx);
   }

   public final AC shrink(float var1) {
      return this.shrink(var1, this.curIx);
   }

   public final AC shrink(float var1, int... var2) {
      Float var3 = new Float(var1);

      for(int var4 = var2.length - 1; var4 >= 0; --var4) {
         int var5 = var2[var4];
         this.makeSize(var5);
         ((DimConstraint)this.cList.get(var5)).setShrink(var3);
      }

      return this;
   }

   /** @deprecated */
   public final AC shrinkWeight(float var1) {
      return this.shrink(var1);
   }

   /** @deprecated */
   public final AC shrinkWeight(float var1, int... var2) {
      return this.shrink(var1, var2);
   }

   private void makeSize(int var1) {
      if (this.cList.size() <= var1) {
         this.cList.ensureCapacity(var1);

         for(int var2 = this.cList.size(); var2 <= var1; ++var2) {
            this.cList.add(new DimConstraint());
         }
      }

   }

   private Object readResolve() throws ObjectStreamException {
      return LayoutUtil.getSerializedObject(this);
   }

   public void readExternal(ObjectInput var1) throws IOException, ClassNotFoundException {
      LayoutUtil.setSerializedObject(this, LayoutUtil.readAsXML(var1));
   }

   public void writeExternal(ObjectOutput var1) throws IOException {
      if (this.getClass() == AC.class) {
         LayoutUtil.writeAsXML(var1, this);
      }

   }
}
