Widening.

git-svn-id: https://samskivert.googlecode.com/svn/trunk@2509 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
samskivert
2008-12-18 01:34:19 +00:00
parent c5504d6857
commit e6740260c9
+17 -23
View File
@@ -29,8 +29,8 @@ import javax.swing.Icon;
import com.samskivert.swing.util.SwingUtil; import com.samskivert.swing.util.SwingUtil;
/** /**
* An abstract lightweight renderer that sizes and renders a label (with * An abstract lightweight renderer that sizes and renders a label (with optional icon) in a
* optional icon) in a roundy-ended sausage. * roundy-ended sausage.
*/ */
public abstract class LabelSausage public abstract class LabelSausage
{ {
@@ -44,8 +44,8 @@ public abstract class LabelSausage
} }
/** /**
* Lays out the label sausage. It is assumed that the desired label * Lays out the label sausage. It is assumed that the desired label font is already set in the
* font is already set in the label. * label.
*/ */
protected void layout (Graphics2D gfx, int extraPadding) protected void layout (Graphics2D gfx, int extraPadding)
{ {
@@ -53,20 +53,18 @@ public abstract class LabelSausage
} }
/** /**
* Lays out the label sausage. It is assumed that the desired label * Lays out the label sausage. It is assumed that the desired label font is already set in the
* font is already set in the label. * label.
* *
* @param iconPadding the number of pixels in the x direction to pad * @param iconPadding the number of pixels in the x direction to pad around the icon.
* around the icon.
*/ */
protected void layout (Graphics2D gfx, int iconPadding, int extraPadding) protected void layout (Graphics2D gfx, int iconPadding, int extraPadding)
{ {
// if we have an icon, let that dictate our size; otherwise just // if we have an icon, let that dictate our size; otherwise just lay out our label all on
// lay out our label all on one line // one line
int sqwid, sqhei; int sqwid, sqhei;
if (_icon == null) { if (_icon == null) {
sqwid = sqhei = 0; sqwid = sqhei = 0;
} else { } else {
sqwid = _icon.getIconWidth(); sqwid = _icon.getIconWidth();
sqhei = _icon.getIconHeight(); sqhei = _icon.getIconHeight();
@@ -83,8 +81,7 @@ public abstract class LabelSausage
sqwid = extraPadding * 2; sqwid = extraPadding * 2;
} }
// compute the diameter of the circle that perfectly encompasses our // compute the diameter of the circle that perfectly encompasses our icon
// icon
int hhei = sqhei / 2; int hhei = sqhei / 2;
int hwid = sqwid / 2; int hwid = sqwid / 2;
_dia = (int) (Math.sqrt(hwid * hwid + hhei * hhei) * 2); _dia = (int) (Math.sqrt(hwid * hwid + hhei * hhei) * 2);
@@ -100,12 +97,12 @@ public abstract class LabelSausage
// now compute our closed and open sizes // now compute our closed and open sizes
_size.height = _dia; _size.height = _dia;
// width is the diameter of the circle that contains // width is the diameter of the circle that contains the icon plus space for the label when
// the icon plus space for the label when we're open // we're open
_size.width = _dia + lsize.width + _xoff; _size.width = _dia + lsize.width + _xoff;
// and if we are actually rendering the icon, we need to // and if we are actually rendering the icon, we need to account for the space between it
// account for the space between it and the label. // and the label.
if (_icon != null) { if (_icon != null) {
// and add the padding needed for the icon // and add the padding needed for the icon
_size.width += _xoff + (iconPadding * 2); _size.width += _xoff + (iconPadding * 2);
@@ -117,8 +114,7 @@ public abstract class LabelSausage
/** /**
* Paints the label sausage. * Paints the label sausage.
*/ */
protected void paint ( protected void paint (Graphics2D gfx, int x, int y, Color background, Object cliData)
Graphics2D gfx, int x, int y, Color background, Object cliData)
{ {
// turn on anti-aliasing // turn on anti-aliasing
Object oalias = SwingUtil.activateAntiAliasing(gfx); Object oalias = SwingUtil.activateAntiAliasing(gfx);
@@ -140,8 +136,7 @@ public abstract class LabelSausage
} }
/** /**
* Draws the base sausage within which all the other decorations are * Draws the base sausage within which all the other decorations are added.
* added.
*/ */
protected void drawBase (Graphics2D gfx, int x, int y) protected void drawBase (Graphics2D gfx, int x, int y)
{ {
@@ -174,8 +169,7 @@ public abstract class LabelSausage
{ {
// draw the black outer border // draw the black outer border
gfx.setColor(Color.black); gfx.setColor(Color.black);
gfx.drawRoundRect(x, y, _size.width - 1, _size.height - 1, gfx.drawRoundRect(x, y, _size.width - 1, _size.height - 1, _dia, _dia);
_dia, _dia);
} }
/** /**