net.mariottini.layout
Class PileLayout

java.lang.Object
  extended by net.mariottini.layout.PileLayout
All Implemented Interfaces:
LayoutManager, LayoutManager2

public final class PileLayout
extends Object
implements LayoutManager2

A layout manager that piles components either vertically or horizontally. Components are layed out with their preferred with and height, aligned or resized according to the constraints used. See the document "How to use PileLayout" for more information.

License:
  Copyright © 2006, 2007 Roberto Mariottini. All rights reserved.

  Permission is granted to anyone to use this software in source and binary forms
  for any purpose, with or without modification, including commercial applications,
  and to alter it and redistribute it freely, provided that the following conditions
  are met:

  o  Redistributions of source code must retain the above copyright notice,
     this list of conditions and the following disclaimer.
  o  The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  o  Altered source versions must be plainly marked as such, and must not
     be misrepresented as being the original software.
 
  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.
 


Field Summary
static Integer ALIGN_BOTTOM
          the component is vertically aligned to the bottom (valid ony for horizontal placement)
static Integer ALIGN_CENTER
          the component is horizontally center aligned (valid ony for vertical placement)
static Integer ALIGN_EXPAND
          like ALIGN_FIT but expands in both dimensions
static Integer ALIGN_FIT
          the component is not aligned, but fitted in size (adjusting its height for horizontal placement or its width for vertical placement)
static Integer ALIGN_LEFT
          the component is horizontally aligned to the left (valid ony for vertical placement)
static Integer ALIGN_MIDDLE
          the component is vertically aligned to the middle (valid ony for horizontal placement)
static Integer ALIGN_RIGHT
          the component is horizontally aligned to the right (valid ony for vertical placement)
static Integer ALIGN_TOP
          the component is vertically aligned to the top (valid ony for horizontal placement)
static int DIRECTION_HORIZONTAL
          the placement direction is horizontal
static int DIRECTION_VERTICAL
          the placement direction is vertical
 
Constructor Summary
PileLayout(int direction)
          Builds a PileLayout with the specified placement direction, with the default gap and with the default margins.
PileLayout(int direction, Insets margins)
          Builds a PileLayout with the specified placement direction, with the default gap and with the specified margins.
PileLayout(int direction, int gap)
          Builds a PileLayout with the specified placement direction and with the specified gap, used also for the margins.
PileLayout(int direction, int gap, Insets margins)
          Builds a PileLayout with the specified placement direction, with the specified gap and with the specified margins.
 
Method Summary
 void addLayoutComponent(Component comp, Object constr)
           
 void addLayoutComponent(String x, Component comp)
           
 float getLayoutAlignmentX(Container target)
           
 float getLayoutAlignmentY(Container target)
           
 void invalidateLayout(Container target)
           
 void layoutContainer(Container cont)
           
 Dimension maximumLayoutSize(Container target)
           
 Dimension minimumLayoutSize(Container cont)
           
 Dimension preferredLayoutSize(Container cont)
           
 void removeLayoutComponent(Component comp)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALIGN_LEFT

public static final Integer ALIGN_LEFT
the component is horizontally aligned to the left (valid ony for vertical placement)


ALIGN_CENTER

public static final Integer ALIGN_CENTER
the component is horizontally center aligned (valid ony for vertical placement)


ALIGN_RIGHT

public static final Integer ALIGN_RIGHT
the component is horizontally aligned to the right (valid ony for vertical placement)


ALIGN_TOP

public static final Integer ALIGN_TOP
the component is vertically aligned to the top (valid ony for horizontal placement)


ALIGN_MIDDLE

public static final Integer ALIGN_MIDDLE
the component is vertically aligned to the middle (valid ony for horizontal placement)


ALIGN_BOTTOM

public static final Integer ALIGN_BOTTOM
the component is vertically aligned to the bottom (valid ony for horizontal placement)


ALIGN_FIT

public static final Integer ALIGN_FIT
the component is not aligned, but fitted in size (adjusting its height for horizontal placement or its width for vertical placement)


ALIGN_EXPAND

public static final Integer ALIGN_EXPAND
like ALIGN_FIT but expands in both dimensions


DIRECTION_HORIZONTAL

public static final int DIRECTION_HORIZONTAL
the placement direction is horizontal

See Also:
Constant Field Values

DIRECTION_VERTICAL

public static final int DIRECTION_VERTICAL
the placement direction is vertical

See Also:
Constant Field Values
Constructor Detail

PileLayout

public PileLayout(int direction)
Builds a PileLayout with the specified placement direction, with the default gap and with the default margins.

Parameters:
direction - one of DIRECTION_HORIZONTAL or DIRECTION_VERTICAL

PileLayout

public PileLayout(int direction,
                  int gap)
Builds a PileLayout with the specified placement direction and with the specified gap, used also for the margins.

Parameters:
direction - one of DIRECTION_HORIZONTAL or DIRECTION_VERTICAL
gap - the gap used for component spacing and also for margins

PileLayout

public PileLayout(int direction,
                  Insets margins)
Builds a PileLayout with the specified placement direction, with the default gap and with the specified margins.

Parameters:
direction - one of DIRECTION_HORIZONTAL or DIRECTION_VERTICAL
margins - the margins to use

PileLayout

public PileLayout(int direction,
                  int gap,
                  Insets margins)
Builds a PileLayout with the specified placement direction, with the specified gap and with the specified margins.

Parameters:
direction - one of DIRECTION_HORIZONTAL or DIRECTION_VERTICAL
gap - the gap used for component spacing
margins - the margins to use
Method Detail

addLayoutComponent

public void addLayoutComponent(String x,
                               Component comp)
Specified by:
addLayoutComponent in interface LayoutManager

removeLayoutComponent

public void removeLayoutComponent(Component comp)
Specified by:
removeLayoutComponent in interface LayoutManager

preferredLayoutSize

public Dimension preferredLayoutSize(Container cont)
Specified by:
preferredLayoutSize in interface LayoutManager

minimumLayoutSize

public Dimension minimumLayoutSize(Container cont)
Specified by:
minimumLayoutSize in interface LayoutManager

layoutContainer

public void layoutContainer(Container cont)
Specified by:
layoutContainer in interface LayoutManager

addLayoutComponent

public void addLayoutComponent(Component comp,
                               Object constr)
Specified by:
addLayoutComponent in interface LayoutManager2

getLayoutAlignmentX

public float getLayoutAlignmentX(Container target)
Specified by:
getLayoutAlignmentX in interface LayoutManager2

getLayoutAlignmentY

public float getLayoutAlignmentY(Container target)
Specified by:
getLayoutAlignmentY in interface LayoutManager2

invalidateLayout

public void invalidateLayout(Container target)
Specified by:
invalidateLayout in interface LayoutManager2

maximumLayoutSize

public Dimension maximumLayoutSize(Container target)
Specified by:
maximumLayoutSize in interface LayoutManager2


Copyright © 2006,2007 Roberto Mariottini. All Rights Reserved.