该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
public class TextAglinManage{
//other aglinment defination.
//..
public static final int AGLIN_HORIZONAL_LEFT=3;
public static final int AGLIN_HORIZONAL_RIGHT=4;
public static final int AGLIN_HORIZONAL_CENTER=5;
//..other defination
}
import TextAglinManage;
public class MyTextLayout
{
/**
*@bounds the range to draw text
*@dim the text dimention width from java.awt.FontMetrics method
*stringWidth(String str),height from getHeight()
*@aglinment the aglinment int para
*@return : return the x-axis of the text paint,it's axis should
* relative to @bounds .
*/
public static int getHorzizonalPos(Rectangle bounds,Dimention dim,int
aglinment)
{
switch(aglinment)
{
case TextAglinManage.AGLIN_HORIZONAL_LEFT:
return bounds.x;
case TextAglinManage.AGLIN_HORIZONAL_RIGHT:
return bounds.x+bounds.getWidth()-dim.getWidth();
case TextAglinManage.AGLIN_HORIZONAL_CENTER:
bounds.x+bounds.getWidth()/2-dim.getWidth()/2;
default :
return bounds.x;
}
}
}