Added support for off-axis justification.

git-svn-id: https://samskivert.googlecode.com/svn/trunk@151 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
mdb
2001-06-07 08:39:10 +00:00
parent 4cd0102c69
commit d1dee28125
3 changed files with 52 additions and 9 deletions
@@ -1,5 +1,5 @@
//
// $Id: GroupLayout.java,v 1.1 2000/12/07 05:41:07 mdb Exp $
// $Id: GroupLayout.java,v 1.2 2001/06/07 08:39:10 mdb Exp $
package com.samskivert.swing;
@@ -118,6 +118,16 @@ public abstract class GroupLayout
return _justification;
}
public void setOffAxisJustification (int justification)
{
_offjust = justification;
}
public int getOffAxisJustification ()
{
return _offjust;
}
public void addLayoutComponent (String name, Component comp)
{
// nothing to do here
@@ -272,6 +282,7 @@ public abstract class GroupLayout
protected int _offpolicy = NONE;
protected int _gap = 5;
protected int _justification = CENTER;
protected int _offjust = CENTER;
protected HashMap _constraints;
@@ -1,5 +1,5 @@
//
// $Id: HGroupLayout.java,v 1.4 2001/05/28 18:26:27 mdb Exp $
// $Id: HGroupLayout.java,v 1.5 2001/06/07 08:39:10 mdb Exp $
package com.samskivert.swing;
@@ -113,7 +113,6 @@ public class HGroupLayout extends GroupLayout
break;
case EQUALIZE:
sy = insets.top + (b.height - info.maxhei)/2;
defhei = info.maxhei;
break;
@@ -129,7 +128,7 @@ public class HGroupLayout extends GroupLayout
break;
case RIGHT:
case BOTTOM:
sx += b.width - totwid;
sx += b.width - totwid - insets.right;
break;
}
@@ -150,7 +149,24 @@ public class HGroupLayout extends GroupLayout
if (_offpolicy == NONE) {
newhei = info.dimens[i].height;
}
// determine our off-axis position
switch (_offjust) {
case LEFT:
case TOP:
sy = insets.top;
break;
case RIGHT:
case BOTTOM:
sy = b.height - newhei - insets.bottom;
break;
default:
case CENTER:
sy = insets.top + (b.height - newhei)/2;
break;
}
child.setBounds(sx, sy, newwid, newhei);
@@ -1,5 +1,5 @@
//
// $Id: VGroupLayout.java,v 1.4 2001/05/28 18:26:27 mdb Exp $
// $Id: VGroupLayout.java,v 1.5 2001/06/07 08:39:10 mdb Exp $
package com.samskivert.swing;
@@ -113,7 +113,6 @@ public class VGroupLayout extends GroupLayout
break;
case EQUALIZE:
sx = insets.left + (b.width - info.maxwid)/2;
defwid = info.maxwid;
break;
@@ -129,7 +128,7 @@ public class VGroupLayout extends GroupLayout
break;
case RIGHT:
case BOTTOM:
sy += b.height - tothei;
sy += b.height - tothei - insets.bottom;
break;
}
@@ -150,7 +149,24 @@ public class VGroupLayout extends GroupLayout
if (_offpolicy == NONE) {
newwid = info.dimens[i].width;
}
// determine our off-axis position
switch (_offjust) {
case LEFT:
case TOP:
sx = insets.left;
break;
case RIGHT:
case BOTTOM:
sx = b.width - newwid - insets.right;
break;
default:
case CENTER:
sx = insets.left + (b.width - newwid)/2;
break;
}
child.setBounds(sx, sy, newwid, newhei);