<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java_by_API%2Fjava.awt%2FLayoutManager2</id>
		<title>Java by API/java.awt/LayoutManager2 - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java_by_API%2Fjava.awt%2FLayoutManager2"/>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java_by_API/java.awt/LayoutManager2&amp;action=history"/>
		<updated>2026-04-26T14:23:04Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java_by_API/java.awt/LayoutManager2&amp;diff=1130&amp;oldid=prev</id>
		<title> в 17:43, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java_by_API/java.awt/LayoutManager2&amp;diff=1130&amp;oldid=prev"/>
				<updated>2010-05-31T17:43:48Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 17:43, 31 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java_by_API/java.awt/LayoutManager2&amp;diff=1131&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java_by_API/java.awt/LayoutManager2&amp;diff=1131&amp;oldid=prev"/>
				<updated>2010-05-31T14:24:10Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== implements LayoutManager2 ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
/*&lt;br /&gt;
 *&lt;br /&gt;
 * Copyright (c) 1998 Sun Microsystems, Inc. All Rights Reserved.&lt;br /&gt;
 *&lt;br /&gt;
 * Sun grants you (&amp;quot;Licensee&amp;quot;) a non-exclusive, royalty free, license to use,&lt;br /&gt;
 * modify and redistribute this software in source and binary code form,&lt;br /&gt;
 * provided that i) this copyright notice and license appear on all copies of&lt;br /&gt;
 * the software; and ii) Licensee does not utilize the software in a manner&lt;br /&gt;
 * which is disparaging to Sun.&lt;br /&gt;
 *&lt;br /&gt;
 * This software is provided &amp;quot;AS IS,&amp;quot; without a warranty of any kind. ALL&lt;br /&gt;
 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY&lt;br /&gt;
 * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR&lt;br /&gt;
 * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE&lt;br /&gt;
 * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING&lt;br /&gt;
 * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS&lt;br /&gt;
 * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,&lt;br /&gt;
 * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER&lt;br /&gt;
 * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF&lt;br /&gt;
 * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE&lt;br /&gt;
 * POSSIBILITY OF SUCH DAMAGES.&lt;br /&gt;
 *&lt;br /&gt;
 * This software is not designed or intended for use in on-line control of&lt;br /&gt;
 * aircraft, air traffic, aircraft navigation or aircraft communications; or in&lt;br /&gt;
 * the design, construction, operation or maintenance of any nuclear&lt;br /&gt;
 * facility. Licensee represents and warrants that it will not use or&lt;br /&gt;
 * redistribute the Software for such purposes.&lt;br /&gt;
 */&lt;br /&gt;
import java.awt.Button;&lt;br /&gt;
import java.awt.ruponent;&lt;br /&gt;
import java.awt.Container;&lt;br /&gt;
import java.awt.Dimension;&lt;br /&gt;
import java.awt.Insets;&lt;br /&gt;
import java.awt.LayoutManager;&lt;br /&gt;
import java.awt.LayoutManager2;&lt;br /&gt;
import java.awt.Rectangle;&lt;br /&gt;
import java.util.Hashtable;&lt;br /&gt;
import javax.swing.JFrame;&lt;br /&gt;
/**&lt;br /&gt;
 * The &amp;lt;code&amp;gt;GraphPaperLayout&amp;lt;/code&amp;gt; class is a layout manager that lays out a&lt;br /&gt;
 * container&amp;quot;s components in a rectangular grid, similar to GridLayout. Unlike&lt;br /&gt;
 * GridLayout, however, components can take up multiple rows and/or columns. The&lt;br /&gt;
 * layout manager acts as a sheet of graph paper. When a component is added to&lt;br /&gt;
 * the layout manager, the location and relative size of the component are&lt;br /&gt;
 * simply supplied by the constraints as a Rectangle.&lt;br /&gt;
 * &amp;lt;P&amp;gt;&lt;br /&gt;
 * &amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
 * import java.awt.*;&lt;br /&gt;
 * import java.applet.Applet;&lt;br /&gt;
 * &lt;br /&gt;
 * public class ButtonGrid extends Applet {&lt;br /&gt;
 *   public void init() {&lt;br /&gt;
 *     setLayout(new GraphPaperLayout(new Dimension(5, 5)));&lt;br /&gt;
 *     // Add a 1x1 Rect at (0,0)&lt;br /&gt;
 *     add(new Button(&amp;amp;quot;1&amp;amp;quot;), new Rectangle(0, 0, 1, 1));&lt;br /&gt;
 *     // Add a 2x1 Rect at (2,0)&lt;br /&gt;
 *     add(new Button(&amp;amp;quot;2&amp;amp;quot;), new Rectangle(2, 0, 2, 1));&lt;br /&gt;
 *     // Add a 1x2 Rect at (1,1)&lt;br /&gt;
 *     add(new Button(&amp;amp;quot;3&amp;amp;quot;), new Rectangle(1, 1, 1, 2));&lt;br /&gt;
 *     // Add a 2x2 Rect at (3,2)&lt;br /&gt;
 *     add(new Button(&amp;amp;quot;4&amp;amp;quot;), new Rectangle(3, 2, 2, 2));&lt;br /&gt;
 *     // Add a 1x1 Rect at (0,4)&lt;br /&gt;
 *     add(new Button(&amp;amp;quot;5&amp;amp;quot;), new Rectangle(0, 4, 1, 1));&lt;br /&gt;
 *     // Add a 1x2 Rect at (2,3)&lt;br /&gt;
 *     add(new Button(&amp;amp;quot;6&amp;amp;quot;), new Rectangle(2, 3, 1, 2));&lt;br /&gt;
 *   }&lt;br /&gt;
 * }&lt;br /&gt;
 * &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
 * &lt;br /&gt;
 * @author Michael Martak&lt;br /&gt;
 */&lt;br /&gt;
class GraphPaperLayout implements LayoutManager2 {&lt;br /&gt;
  int hgap; // horizontal gap&lt;br /&gt;
  int vgap; // vertical gap&lt;br /&gt;
  Dimension gridSize; // grid size in logical units (n x m)&lt;br /&gt;
  Hashtable&amp;lt;Component, Rectangle&amp;gt; compTable; // constraints (Rectangles)&lt;br /&gt;
  /**&lt;br /&gt;
   * Creates a graph paper layout with a default of a 1 x 1 graph, with no&lt;br /&gt;
   * vertical or horizontal padding.&lt;br /&gt;
   */&lt;br /&gt;
  public GraphPaperLayout() {&lt;br /&gt;
    this(new Dimension(1, 1));&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Creates a graph paper layout with the given grid size, with no vertical or&lt;br /&gt;
   * horizontal padding.&lt;br /&gt;
   */&lt;br /&gt;
  public GraphPaperLayout(Dimension gridSize) {&lt;br /&gt;
    this(gridSize, 0, 0);&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Creates a graph paper layout with the given grid size and padding.&lt;br /&gt;
   * &lt;br /&gt;
   * @param gridSize&lt;br /&gt;
   *          size of the graph paper in logical units (n x m)&lt;br /&gt;
   * @param hgap&lt;br /&gt;
   *          horizontal padding&lt;br /&gt;
   * @param vgap&lt;br /&gt;
   *          vertical padding&lt;br /&gt;
   */&lt;br /&gt;
  public GraphPaperLayout(Dimension gridSize, int hgap, int vgap) {&lt;br /&gt;
    if ((gridSize.width &amp;lt;= 0) || (gridSize.height &amp;lt;= 0)) {&lt;br /&gt;
      throw new IllegalArgumentException(&amp;quot;dimensions must be greater than zero&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    this.gridSize = new Dimension(gridSize);&lt;br /&gt;
    this.hgap = hgap;&lt;br /&gt;
    this.vgap = vgap;&lt;br /&gt;
    compTable = new Hashtable&amp;lt;Component, Rectangle&amp;gt;();&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * @return the size of the graph paper in logical units (n x m)&lt;br /&gt;
   */&lt;br /&gt;
  public Dimension getGridSize() {&lt;br /&gt;
    return new Dimension(gridSize);&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Set the size of the graph paper in logical units (n x m)&lt;br /&gt;
   */&lt;br /&gt;
  public void setGridSize(Dimension d) {&lt;br /&gt;
    setGridSize(d.width, d.height);&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Set the size of the graph paper in logical units (n x m)&lt;br /&gt;
   */&lt;br /&gt;
  public void setGridSize(int width, int height) {&lt;br /&gt;
    gridSize = new Dimension(width, height);&lt;br /&gt;
  }&lt;br /&gt;
  public void setConstraints(Component comp, Rectangle constraints) {&lt;br /&gt;
    compTable.put(comp, new Rectangle(constraints));&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Adds the specified component with the specified name to the layout. This&lt;br /&gt;
   * does nothing in GraphPaperLayout, since constraints are required.&lt;br /&gt;
   */&lt;br /&gt;
  public void addLayoutComponent(String name, Component comp) {&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Removes the specified component from the layout.&lt;br /&gt;
   * &lt;br /&gt;
   * @param comp&lt;br /&gt;
   *          the component to be removed&lt;br /&gt;
   */&lt;br /&gt;
  public void removeLayoutComponent(Component comp) {&lt;br /&gt;
    compTable.remove(comp);&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Calculates the preferred size dimensions for the specified panel given the&lt;br /&gt;
   * components in the specified parent container.&lt;br /&gt;
   * &lt;br /&gt;
   * @param parent&lt;br /&gt;
   *          the component to be laid out&lt;br /&gt;
   * &lt;br /&gt;
   * @see #minimumLayoutSize&lt;br /&gt;
   */&lt;br /&gt;
  public Dimension preferredLayoutSize(Container parent) {&lt;br /&gt;
    return getLayoutSize(parent, true);&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Calculates the minimum size dimensions for the specified panel given the&lt;br /&gt;
   * components in the specified parent container.&lt;br /&gt;
   * &lt;br /&gt;
   * @param parent&lt;br /&gt;
   *          the component to be laid out&lt;br /&gt;
   * @see #preferredLayoutSize&lt;br /&gt;
   */&lt;br /&gt;
  public Dimension minimumLayoutSize(Container parent) {&lt;br /&gt;
    return getLayoutSize(parent, false);&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Algorithm for calculating layout size (minimum or preferred).&lt;br /&gt;
   * &amp;lt;P&amp;gt;&lt;br /&gt;
   * The width of a graph paper layout is the largest cell width (calculated in&lt;br /&gt;
   * &amp;lt;code&amp;gt;getLargestCellSize()&amp;lt;/code&amp;gt; times the number of columns, plus the&lt;br /&gt;
   * horizontal padding times the number of columns plus one, plus the left and&lt;br /&gt;
   * right insets of the target container.&lt;br /&gt;
   * &amp;lt;P&amp;gt;&lt;br /&gt;
   * The height of a graph paper layout is the largest cell height (calculated&lt;br /&gt;
   * in &amp;lt;code&amp;gt;getLargestCellSize()&amp;lt;/code&amp;gt; times the number of rows, plus the&lt;br /&gt;
   * vertical padding times the number of rows plus one, plus the top and bottom&lt;br /&gt;
   * insets of the target container.&lt;br /&gt;
   * &lt;br /&gt;
   * @param parent&lt;br /&gt;
   *          the container in which to do the layout.&lt;br /&gt;
   * @param isPreferred&lt;br /&gt;
   *          true for calculating preferred size, false for calculating minimum&lt;br /&gt;
   *          size.&lt;br /&gt;
   * @return the dimensions to lay out the subcomponents of the specified&lt;br /&gt;
   *         container.&lt;br /&gt;
   * @see java.awt.GraphPaperLayout#getLargestCellSize&lt;br /&gt;
   */&lt;br /&gt;
  protected Dimension getLayoutSize(Container parent, boolean isPreferred) {&lt;br /&gt;
    Dimension largestSize = getLargestCellSize(parent, isPreferred);&lt;br /&gt;
    Insets insets = parent.getInsets();&lt;br /&gt;
    largestSize.width = (largestSize.width * gridSize.width) + (hgap * (gridSize.width + 1))&lt;br /&gt;
        + insets.left + insets.right;&lt;br /&gt;
    largestSize.height = (largestSize.height * gridSize.height) + (vgap * (gridSize.height + 1))&lt;br /&gt;
        + insets.top + insets.bottom;&lt;br /&gt;
    return largestSize;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Algorithm for calculating the largest minimum or preferred cell size.&lt;br /&gt;
   * &amp;lt;P&amp;gt;&lt;br /&gt;
   * Largest cell size is calculated by getting the applicable size of each&lt;br /&gt;
   * component and keeping the maximum value, dividing the component&amp;quot;s width by&lt;br /&gt;
   * the number of columns it is specified to occupy and dividing the&lt;br /&gt;
   * component&amp;quot;s height by the number of rows it is specified to occupy.&lt;br /&gt;
   * &lt;br /&gt;
   * @param parent&lt;br /&gt;
   *          the container in which to do the layout.&lt;br /&gt;
   * @param isPreferred&lt;br /&gt;
   *          true for calculating preferred size, false for calculating minimum&lt;br /&gt;
   *          size.&lt;br /&gt;
   * @return the largest cell size required.&lt;br /&gt;
   */&lt;br /&gt;
  protected Dimension getLargestCellSize(Container parent, boolean isPreferred) {&lt;br /&gt;
    int ncomponents = parent.getComponentCount();&lt;br /&gt;
    Dimension maxCellSize = new Dimension(0, 0);&lt;br /&gt;
    for (int i = 0; i &amp;lt; ncomponents; i++) {&lt;br /&gt;
      Component c = parent.getComponent(i);&lt;br /&gt;
      Rectangle rect = compTable.get(c);&lt;br /&gt;
      if (c != null &amp;amp;&amp;amp; rect != null) {&lt;br /&gt;
        Dimension componentSize;&lt;br /&gt;
        if (isPreferred) {&lt;br /&gt;
          componentSize = c.getPreferredSize();&lt;br /&gt;
        } else {&lt;br /&gt;
          componentSize = c.getMinimumSize();&lt;br /&gt;
        }&lt;br /&gt;
        // Note: rect dimensions are already asserted to be &amp;gt; 0 when the&lt;br /&gt;
        // component is added with constraints&lt;br /&gt;
        maxCellSize.width = Math.max(maxCellSize.width, componentSize.width / rect.width);&lt;br /&gt;
        maxCellSize.height = Math.max(maxCellSize.height, componentSize.height / rect.height);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    return maxCellSize;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Lays out the container in the specified container.&lt;br /&gt;
   * &lt;br /&gt;
   * @param parent&lt;br /&gt;
   *          the component which needs to be laid out&lt;br /&gt;
   */&lt;br /&gt;
  public void layoutContainer(Container parent) {&lt;br /&gt;
    synchronized (parent.getTreeLock()) {&lt;br /&gt;
      Insets insets = parent.getInsets();&lt;br /&gt;
      int ncomponents = parent.getComponentCount();&lt;br /&gt;
      if (ncomponents == 0) {&lt;br /&gt;
        return;&lt;br /&gt;
      }&lt;br /&gt;
      // Total parent dimensions&lt;br /&gt;
      Dimension size = parent.getSize();&lt;br /&gt;
      int totalW = size.width - (insets.left + insets.right);&lt;br /&gt;
      int totalH = size.height - (insets.top + insets.bottom);&lt;br /&gt;
      // Cell dimensions, including padding&lt;br /&gt;
      int totalCellW = totalW / gridSize.width;&lt;br /&gt;
      int totalCellH = totalH / gridSize.height;&lt;br /&gt;
      // Cell dimensions, without padding&lt;br /&gt;
      int cellW = (totalW - ((gridSize.width + 1) * hgap)) / gridSize.width;&lt;br /&gt;
      int cellH = (totalH - ((gridSize.height + 1) * vgap)) / gridSize.height;&lt;br /&gt;
      for (int i = 0; i &amp;lt; ncomponents; i++) {&lt;br /&gt;
        Component c = parent.getComponent(i);&lt;br /&gt;
        Rectangle rect = compTable.get(c);&lt;br /&gt;
        if (rect != null) {&lt;br /&gt;
          int x = insets.left + (totalCellW * rect.x) + hgap;&lt;br /&gt;
          int y = insets.top + (totalCellH * rect.y) + vgap;&lt;br /&gt;
          int w = (cellW * rect.width) - hgap;&lt;br /&gt;
          int h = (cellH * rect.height) - vgap;&lt;br /&gt;
          c.setBounds(x, y, w, h);&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  // LayoutManager2 /////////////////////////////////////////////////////////&lt;br /&gt;
  /**&lt;br /&gt;
   * Adds the specified component to the layout, using the specified constraint&lt;br /&gt;
   * object.&lt;br /&gt;
   * &lt;br /&gt;
   * @param comp&lt;br /&gt;
   *          the component to be added&lt;br /&gt;
   * @param constraints&lt;br /&gt;
   *          where/how the component is added to the layout.&lt;br /&gt;
   */&lt;br /&gt;
  public void addLayoutComponent(Component comp, Object constraints) {&lt;br /&gt;
    if (constraints instanceof Rectangle) {&lt;br /&gt;
      Rectangle rect = (Rectangle) constraints;&lt;br /&gt;
      if (rect.width &amp;lt;= 0 || rect.height &amp;lt;= 0) {&lt;br /&gt;
        throw new IllegalArgumentException(&lt;br /&gt;
            &amp;quot;cannot add to layout: rectangle must have positive width and height&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
      if (rect.x &amp;lt; 0 || rect.y &amp;lt; 0) {&lt;br /&gt;
        throw new IllegalArgumentException(&amp;quot;cannot add to layout: rectangle x and y must be &amp;gt;= 0&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
      setConstraints(comp, rect);&lt;br /&gt;
    } else if (constraints != null) {&lt;br /&gt;
      throw new IllegalArgumentException(&amp;quot;cannot add to layout: constraint must be a Rectangle&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Returns the maximum size of this component.&lt;br /&gt;
   * &lt;br /&gt;
   * @see java.awt.ruponent#getMinimumSize()&lt;br /&gt;
   * @see java.awt.ruponent#getPreferredSize()&lt;br /&gt;
   * @see LayoutManager&lt;br /&gt;
   */&lt;br /&gt;
  public Dimension maximumLayoutSize(Container target) {&lt;br /&gt;
    return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Returns the alignment along the x axis. This specifies how the component&lt;br /&gt;
   * would like to be aligned relative to other components. The value should be&lt;br /&gt;
   * a number between 0 and 1 where 0 represents alignment along the origin, 1&lt;br /&gt;
   * is aligned the furthest away from the origin, 0.5 is centered, etc.&lt;br /&gt;
   */&lt;br /&gt;
  public float getLayoutAlignmentX(Container target) {&lt;br /&gt;
    return 0.5f;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Returns the alignment along the y axis. This specifies how the component&lt;br /&gt;
   * would like to be aligned relative to other components. The value should be&lt;br /&gt;
   * a number between 0 and 1 where 0 represents alignment along the origin, 1&lt;br /&gt;
   * is aligned the furthest away from the origin, 0.5 is centered, etc.&lt;br /&gt;
   */&lt;br /&gt;
  public float getLayoutAlignmentY(Container target) {&lt;br /&gt;
    return 0.5f;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Invalidates the layout, indicating that if the layout manager has cached&lt;br /&gt;
   * information it should be discarded.&lt;br /&gt;
   */&lt;br /&gt;
  public void invalidateLayout(Container target) {&lt;br /&gt;
    // Do nothing&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
public class DemoGraphPaperLayout {&lt;br /&gt;
  public static void main(String[] a) {&lt;br /&gt;
    JFrame frame = new JFrame();&lt;br /&gt;
    frame.setLayout(new GraphPaperLayout(new Dimension(5, 5)));&lt;br /&gt;
    // Add a 1x1 Rect at (0,0)&lt;br /&gt;
    frame.add(new Button(&amp;quot;1&amp;quot;), new Rectangle(0, 0, 1, 1));&lt;br /&gt;
    // Add a 2x1 Rect at (2,0)&lt;br /&gt;
    frame.add(new Button(&amp;quot;2&amp;quot;), new Rectangle(2, 0, 2, 1));&lt;br /&gt;
    // Add a 1x2 Rect at (1,1)&lt;br /&gt;
    frame.add(new Button(&amp;quot;3&amp;quot;), new Rectangle(1, 1, 1, 2));&lt;br /&gt;
    // Add a 2x2 Rect at (3,2)&lt;br /&gt;
    frame.add(new Button(&amp;quot;4&amp;quot;), new Rectangle(3, 2, 2, 2));&lt;br /&gt;
    // Add a 1x1 Rect at (0,4)&lt;br /&gt;
    frame.add(new Button(&amp;quot;5&amp;quot;), new Rectangle(0, 4, 1, 1));&lt;br /&gt;
    // Add a 1x2 Rect at (2,3)&lt;br /&gt;
    frame.add(new Button(&amp;quot;6&amp;quot;), new Rectangle(2, 3, 1, 2));&lt;br /&gt;
    frame.pack();&lt;br /&gt;
    frame.setVisible(true);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>