Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package net.miginfocom.layout;
  
  import java.io.*;
  
  /*
   * License (BSD):
   * ==============
   *
  * Copyright (c) 2004, Mikael Grev, MiG InfoCom AB. (miglayout (at) miginfocom (dot) com)
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without modification,
  * are permitted provided that the following conditions are met:
  * Redistributions of source code must retain the above copyright notice, this list
  * of conditions and the following disclaimer.
  * Redistributions in binary form must reproduce the above copyright notice, this
  * list of conditions and the following disclaimer in the documentation and/or other
  * materials provided with the distribution.
  * Neither the name of the MiG InfoCom AB nor the names of its contributors may be
  * used to endorse or promote products derived from this software without specific
  * prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
  * OF SUCH DAMAGE.
  *
  * @version 1.0
  * @author Mikael Grev, MiG InfoCom AB
  *         Date: 2006-sep-08
  */

A constraint that holds the column or row constraints for the grid. It also holds the gaps between the rows and columns.

This class is a holder and builder for a number of DimConstraints.

For a more thorough explanation of what these constraints do, and how to build the constraints, see the White Paper or Cheat Sheet at www.migcomponents.com.

Note that there are two way to build this constraint. Through String (e.g. "[100]3[200,fill]" or through API (E.g. new AxisConstraint().size("100").gap("3").size("200").fill().

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

Constructor. Creates an instance that can be configured manually. Will be initialized with a default DimConstraint.
 
 	public AC()
 	{
 	}

Property. The different DimConstraints that this object consists of. These <DimConstraints/code> contains all information in this class.

Yes, we are embarrassingly aware that the method is misspelled.

Returns:
The different DimConstraints that this object consists of. A new list and never null.
 
 	public final DimConstraint[] getConstaints()
 	{
 		return .toArray(new DimConstraint[.size()]);
 	}

Sets the different DimConstraints that this object should consists of.

Yes, we are embarrassingly aware that the method is misspelled.

Parameters:
constr The different DimConstraints that this object consists of. The list will be copied for storage. null or and emty array will reset the constraints to one DimConstraint with default values.
 
 	public final void setConstaints(DimConstraint[] constr)
 	{
 		if (constr == null || constr.length < 1 )
 			constr = new DimConstraint[] {new DimConstraint()};
 
 		.ensureCapacity(constr.length);
 		for (DimConstraint c : constr)
 			.add(c);
 	}

Returns the number of rows/columns that this constraints currently have.

Returns:
The number of rows/columns that this constraints currently have. At least 1.
 
 	public int getCount()
 	{
 		return .size();
 	}

Sets the total number of rows/columns to size. If the number of rows/columns is already more than size nothing will happen.

Parameters:
size The total number of rows/columns
Returns:
this so it is possible to chain calls. E.g. new AxisConstraint().noGrid().gap().fill().
	public final AC count(int size)
	{
		makeSize(size);
		return this;
	}

Specifies that the current row/column should not be grid-like. The while row/colum will have its components layed out in one single cell. It is the same as to say that the cells in this column/row will all be merged (a.k.a spanned).

For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

Returns:
this so it is possible to chain calls. E.g. new AxisConstraint().noGrid().gap().fill().
	public final AC noGrid()
	{
		return noGrid();
	}

Specifies that the indicated rows/columns should not be grid-like. The while row/colum will have its components layed out in one single cell. It is the same as to say that the cells in this column/row will all be merged (a.k.a spanned).

For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

Parameters:
indexes The index(es) (0-based) of the columns/rows that should be affected by this constraint.
Returns:
this so it is possible to chain calls. E.g. new AxisConstraint().noGrid().gap().fill().
	public final AC noGrid(int... indexes)
	{
		for (int i = indexes.length - 1; i >= 0; i--) {
			int ix = indexes[i];
			.get(ix).setNoGrid(true);
		}
		return this;
	}

Sets the current row/column to i. If the current number of rows/columns is less than i a call to count(int) will set the size accordingly.

The next call to any of the constraint methods (e.g. noGrid()) will be carried out on this new row/column.

For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

Parameters:
i The new current row/column.
Returns:
this so it is possible to chain calls. E.g. new AxisConstraint().noGrid().gap().fill().
	public final AC index(int i)
	{
		 = i;
		return this;
	}

Specifies that the current row/column's component should grow by default. It does not affect the size of the row/column.

For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

Returns:
this so it is possible to chain calls. E.g. new AxisConstraint().noGrid().gap().fill().
	public final AC fill()
	{
		return fill();
	}

Specifies that the indicated rows'/columns' component should grow by default. It does not affect the size of the row/column.

For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

Parameters:
indexes The index(es) (0-based) of the columns/rows that should be affected by this constraint.
Returns:
this so it is possible to chain calls. E.g. new AxisConstraint().noGrid().gap().fill().
	public final AC fill(int... indexes)
	{
		for (int i = indexes.length - 1; i >= 0; i--) {
			int ix = indexes[i];
			.get(ix).setFill(true);
		}
		return this;
	}
//	/** Specifies that the current row/column should be put in the end group <code>s</code> and will thus share the same ending
//	 * coordinate within the group.
//	 * <p>
//	 * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
//	 * @param s A name to associate on the group that should be the same for other rows/columns in the same group.
//	 * @return <code>this</code> so it is possible to chain calls. E.g. <code>new AxisConstraint().noGrid().gap().fill()</code>.
//	 */
//	public final AxisConstraint endGroup(String s)
//	{
//		return endGroup(s, curIx);
//	}
//
//	/** Specifies that the indicated rows/columns should be put in the end group <code>s</code> and will thus share the same ending
//	 * coordinate within the group.
//	 * <p>
//	 * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
//	 * @param s A name to associate on the group that should be the same for other rows/columns in the same group.
//	 * @param indexes The index(es) (0-based) of the columns/rows that should be affected by this constraint.
//	 * @return <code>this</code> so it is possible to chain calls. E.g. <code>new AxisConstraint().noGrid().gap().fill()</code>.
//	 */
//	public final AxisConstraint endGroup(String s, int... indexes)
//	{
//		for (int i = indexes.length - 1; i >= 0; i--) {
//			int ix = indexes[i];
//			makeSize(ix);
//			cList.get(ix).setEndGroup(s);
//		}
//		return this;
//	}
Specifies that the current row/column should be put in the size group s and will thus share the same size constraints as the other components in the group.

Same as sizeGroup("")

For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

Returns:
this so it is possible to chain calls. E.g. new AxisConstraint().noGrid().gap().fill().
Since:
3.7.2
	public final AC sizeGroup()
	{
		return sizeGroup("");
	}

Specifies that the current row/column should be put in the size group s and will thus share the same size constraints as the other components in the group.

For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

Parameters:
s A name to associate on the group that should be the same for other rows/columns in the same group.
Returns:
this so it is possible to chain calls. E.g. new AxisConstraint().noGrid().gap().fill().
	public final AC sizeGroup(String s)
	{
		return sizeGroup(s);
	}

Specifies that the indicated rows/columns should be put in the size group s and will thus share the same size constraints as the other components in the group.

For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

Parameters:
s A name to associate on the group that should be the same for other rows/columns in the same group.
indexes The index(es) (0-based) of the columns/rows that should be affected by this constraint.
Returns:
this so it is possible to chain calls. E.g. new AxisConstraint().noGrid().gap().fill().
	public final AC sizeGroup(String sint... indexes)
	{
		for (int i = indexes.length - 1; i >= 0; i--) {
			int ix = indexes[i];
		}
		return this;
	}

Specifies the current row/column's min and/or preferred and/or max size. E.g. "10px" or "50:100:200".

For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

Parameters:
s The minimum and/or preferred and/or maximum size of this row. The string will be interpreted as a BoundSize. For more info on how BoundSize is formatted see the documentation.
Returns:
this so it is possible to chain calls. E.g. new AxisConstraint().noGrid().gap().fill().
	public final AC size(String s)
	{
		return size(s);
	}

Specifies the indicated rows'/columns' min and/or preferred and/or max size. E.g. "10px" or "50:100:200".

For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

Parameters:
size The minimum and/or preferred and/or maximum size of this row. The string will be interpreted as a BoundSize. For more info on how BoundSize is formatted see the documentation.
indexes The index(es) (0-based) of the columns/rows that should be affected by this constraint.
Returns:
this so it is possible to chain calls. E.g. new AxisConstraint().noGrid().gap().fill().
	public final AC size(String sizeint... indexes)
	{
		BoundSize bs = ConstraintParser.parseBoundSize(sizefalsetrue);
		for (int i = indexes.length - 1; i >= 0; i--) {
			int ix = indexes[i];
			.get(ix).setSize(bs);
		}
		return this;
	}

Specifies the gap size to be the default one AND moves to the next column/row. The method is called .gap() rather the more natural .next() to indicate that it is very much related to the other .gap(..) methods.

For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

Returns:
this so it is possible to chain calls. E.g. new AxisConstraint().noGrid().gap().fill().
	public final AC gap()
	{
		return this;
	}

Specifies the gap size to size AND moves to the next column/row.

For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

Parameters:
size minimum and/or preferred and/or maximum size of the gap between this and the next row/column. The string will be interpreted as a BoundSize. For more info on how BoundSize is formatted see the documentation.
Returns:
this so it is possible to chain calls. E.g. new AxisConstraint().noGrid().gap().fill().
	public final AC gap(String size)
	{
		return gap(size++);
	}

Specifies the indicated rows'/columns' gap size to size.

For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

Parameters:
size minimum and/or preferred and/or maximum size of the gap between this and the next row/column. The string will be interpreted as a BoundSize. For more info on how BoundSize is formatted see the documentation.
indexes The index(es) (0-based) of the columns/rows that should be affected by this constraint.
Returns:
this so it is possible to chain calls. E.g. new AxisConstraint().noGrid().gap().fill().
	public final AC gap(String sizeint... indexes)
	{
		BoundSize bsa = size != null ? ConstraintParser.parseBoundSize(sizetruetrue) : null;
		for (int i = indexes.length - 1; i >= 0; i--) {
			int ix = indexes[i];
			if (bsa != null)
		}
		return this;
	}

Specifies the current row/column's columns default alignment for its components. It does not affect the positioning or size of the columns/row itself. For columns it is the horizonal alignment (e.g. "left") and for rows it is the vertical alignment (e.g. "top").

For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

Parameters:
side The default side to align the components. E.g. "top" or "left", or "leading" or "trailing" or "bottom" or "right".
Returns:
this so it is possible to chain calls. E.g. new AxisConstraint().noGrid().gap().fill().
	public final AC align(String side)
	{
		return align(side);
	}

Specifies the indicated rows'/columns' columns default alignment for its components. It does not affect the positioning or size of the columns/row itself. For columns it is the horizonal alignment (e.g. "left") and for rows it is the vertical alignment (e.g. "top").

For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

Parameters:
side The default side to align the components. E.g. "top" or "left", or "before" or "after" or "bottom" or "right".
indexes The index(es) (0-based) of the columns/rows that should be affected by this constraint.
Returns:
this so it is possible to chain calls. E.g. new AxisConstraint().noGrid().gap().fill().
	public final AC align(String sideint... indexes)
	{
		UnitValue al = ConstraintParser.parseAlignKeywords(sidetrue);
		if (al == null)
			al = ConstraintParser.parseAlignKeywords(sidefalse);
		for (int i = indexes.length - 1; i >= 0; i--) {
			int ix = indexes[i];
		}
		return this;
	}

Specifies the current row/column's grow priority.

For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

Parameters:
p The new grow priority.
Returns:
this so it is possible to chain calls. E.g. new AxisConstraint().noGrid().gap().fill().
	public final AC growPrio(int p)
	{
		return growPrio(p);
	}

Specifies the indicated rows'/columns' grow priority.

For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

Parameters:
p The new grow priority.
indexes The index(es) (0-based) of the columns/rows that should be affected by this constraint.
Returns:
this so it is possible to chain calls. E.g. new AxisConstraint().noGrid().gap().fill().
	public final AC growPrio(int pint... indexes)
	{
		for (int i = indexes.length - 1; i >= 0; i--) {
			int ix = indexes[i];
		}
		return this;
	}

Specifies the current row/column's grow weight within columns/rows with the grow priority 100f.

Same as grow(100f)

For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

Returns:
this so it is possible to chain calls. E.g. new AxisConstraint().noGrid().gap().fill().
Since:
3.7.2
	public final AC grow()
	{
		return grow(1f, );
	}

Specifies the current row/column's grow weight within columns/rows with the same grow priority.

For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

Parameters:
w The new grow weight.
Returns:
this so it is possible to chain calls. E.g. new AxisConstraint().noGrid().gap().fill().
	public final AC grow(float w)
	{
		return grow(w);
	}

Specifies the indicated rows'/columns' grow weight within columns/rows with the same grow priority.

For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

Parameters:
w The new grow weight.
indexes The index(es) (0-based) of the columns/rows that should be affected by this constraint.
Returns:
this so it is possible to chain calls. E.g. new AxisConstraint().noGrid().gap().fill().
	public final AC grow(float wint... indexes)
	{
		Float gw = new Float(w);
		for (int i = indexes.length - 1; i >= 0; i--) {
			int ix = indexes[i];
			.get(ix).setGrow(gw);
		}
		return this;
	}

Specifies the current row/column's shrink priority.

For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

Parameters:
p The new shrink priority.
Returns:
this so it is possible to chain calls. E.g. new AxisConstraint().noGrid().gap().fill().
	public final AC shrinkPrio(int p)
	{
		return shrinkPrio(p);
	}

Specifies the indicated rows'/columns' shrink priority.

For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

Parameters:
p The new shrink priority.
indexes The index(es) (0-based) of the columns/rows that should be affected by this constraint.
Returns:
this so it is possible to chain calls. E.g. new AxisConstraint().noGrid().gap().fill().
	public final AC shrinkPrio(int pint... indexes)
	{
		for (int i = indexes.length - 1; i >= 0; i--) {
			int ix = indexes[i];
		}
		return this;
	}

Specifies that the current row/column's shrink weight withing the columns/rows with the shrink priority 100f.

Same as shrink(100f).

For a more thorough explanation of what this constraint does see the White Paper or Cheat Sheet at www.migcomponents.com.

Returns:
this so it is possible to chain calls. E.g. new AxisConstraint().noGrid().gap().fill().
Since:
3.7.2
	public final AC shrink()
	{
		return shrink(100f, );
	}

Specifies that the current row/column's shrink weight withing the columns/rows with the same shrink priority.

For a more thorough explanation of what this constraint does see the White Paper or Cheat Sheet at www.migcomponents.com.

Parameters:
w The shrink weight.
Returns:
this so it is possible to chain calls. E.g. new AxisConstraint().noGrid().gap().fill().
Since:
3.7.2
	public final AC shrink(float w)
	{
		return shrink(w);
	}

Specifies the indicated rows'/columns' shrink weight withing the columns/rows with the same shrink priority.

For a more thorough explanation of what this constraint does see the White Paper or Cheat Sheet at www.migcomponents.com.

Parameters:
w The shrink weight.
indexes The index(es) (0-based) of the columns/rows that should be affected by this constraint.
Returns:
this so it is possible to chain calls. E.g. new AxisConstraint().noGrid().gap().fill().
Since:
3.7.2
	public final AC shrink(float wint... indexes)
	{
		Float sw = new Float(w);
		for (int i = indexes.length - 1; i >= 0; i--) {
			int ix = indexes[i];
		}
		return this;
	}

Specifies that the current row/column's shrink weight withing the columns/rows with the same shrink priority.

For a more thorough explanation of what this constraint does see the White Paper or Cheat Sheet at www.migcomponents.com.

Deprecated:
in 3.7.2. Use shrink(float) instead.
Parameters:
w The shrink weight.
Returns:
this so it is possible to chain calls. E.g. new AxisConstraint().noGrid().gap().fill().
	public final AC shrinkWeight(float w)
	{
		return shrink(w);
	}

Specifies the indicated rows'/columns' shrink weight withing the columns/rows with the same shrink priority.

For a more thorough explanation of what this constraint does see the White Paper or Cheat Sheet at www.migcomponents.com.

Deprecated:
in 3.7.2. Use shrink(float,int[]) instead.
Parameters:
w The shrink weight.
indexes The index(es) (0-based) of the columns/rows that should be affected by this constraint.
Returns:
this so it is possible to chain calls. E.g. new AxisConstraint().noGrid().gap().fill().
	public final AC shrinkWeight(float wint... indexes)
	{
		return shrink(windexes);
	}
	private void makeSize(int sz)
	{
		if (.size() <= sz) {
			for (int i = .size(); i <= szi++)
		}
	}
	// ************************************************
	// Persistence Delegate and Serializable combined.
	// ************************************************
	{
		return LayoutUtil.getSerializedObject(this);
	}
	{
		LayoutUtil.setSerializedObject(this, LayoutUtil.readAsXML(in));
	}
	public void writeExternal(ObjectOutput outthrows IOException
	{
		if (getClass() == AC.class)
			LayoutUtil.writeAsXML(outthis);
	}
New to GrepCode? Check out our FAQ X