本文整理汇总了Java中org.eclipse.draw2d.FigureUtilities.getTextWidth方法的典型用法代码示例。如果您正苦于以下问题:Java FigureUtilities.getTextWidth方法的具体用法?Java FigureUtilities.getTextWidth怎么用?Java FigureUtilities.getTextWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.draw2d.FigureUtilities
的用法示例。
在下文中一共展示了FigureUtilities.getTextWidth方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paintFigure
import org.eclipse.draw2d.FigureUtilities; //导入方法依赖的package包/类
@Override
protected void paintFigure(Graphics g) {
super.paintFigure(g);
final int LEG = 5;
Rectangle r = getBounds();
g.setLineWidth(1);
g.setForegroundColor(valid ? ColorConstants.black : PandionJConstants.Colors.ERROR);
g.drawLine(r.x, r.y, r.x, r.y+r.height-1);
g.drawLine(r.x, r.y, r.x+LEG, r.y);
g.drawLine(r.x, r.y+r.height-1, r.x+LEG, r.y+r.height-1);
g.drawLine(r.x+r.width-1, r.y, r.x+r.width-1, r.y+r.height);
g.drawLine(r.x+r.width-1, r.y, r.x+r.width-1-LEG, r.y);
g.drawLine(r.x+r.width-1, r.y+r.height-1, r.x+r.width-1-LEG, r.y+r.height-1);
if(!valid) {
g.setForegroundColor(PandionJConstants.Colors.ERROR);
String text = "Invalid matrix";
int textWidth = FigureUtilities.getTextWidth(text, g.getFont());
Point p = r.getLocation().translate(r.width/2 - textWidth/2, 5);
g.drawText(text, p);
}
}
示例2: paintSpecial_old
import org.eclipse.draw2d.FigureUtilities; //导入方法依赖的package包/类
private void paintSpecial_old( Graphics g, String text, int x, int y,
boolean firstBox )
{
if ( firstBox
&& specialPREFIX.length( ) != 0
&& text.indexOf( specialPREFIX ) == 0 )
{
int with = FigureUtilities.getTextWidth( specialPREFIX, g.getFont( ) );
Color c = g.getForegroundColor( );
g.setForegroundColor( ReportColorConstants.textFillColor );
g.drawString( specialPREFIX, x, y );
g.setForegroundColor( c );
g.drawString( text.substring( specialPREFIX.length( ) ),
x + with,
y );
}
else
{
g.drawString( text, x, y );
}
}
示例3: setAutoFont
import org.eclipse.draw2d.FigureUtilities; //导入方法依赖的package包/类
private void setAutoFont(int size, String text, FontStyle ... styles) {
Font f = FontManager.getFont(size, styles);
while(FigureUtilities.getTextWidth(text, f) > PandionJConstants.POSITION_WIDTH-4 && size > 8) {
size--;
f = FontManager.getFont(size, styles);
}
setFont(f);
}
示例4: paintFigure
import org.eclipse.draw2d.FigureUtilities; //导入方法依赖的package包/类
@Override
protected void paintFigure(Graphics g) {
super.paintFigure(g);
FontMetrics fm = FigureUtilities.getFontMetrics(getFont());
int h = fm.getHeight();
int y = h;
boolean first = true;
String symbolicFontName = getFont().toString();
Font boldFont = FontUtils.FONT_REGISTRY_INSTANCE.getBold(symbolicFontName);
for (DateFormat format : dateFormats) {
try {
g.pushState();
if (first) {
g.setFont(boldFont);
first = false;
}
String id = DateFormatRegistry.INSTANCE.getDateFormatID(format);
if (id==null) id = "";
g.drawText(id, 5, y);
if (cursorTime != null) {
String date = format.format(cursorTime);
int width = FigureUtilities.getTextWidth(date, getFont()) + 5;
g.drawText(date, bounds.width - width, y);
}
y += h;
} finally {
g.popState();
}
}
//boldFont.dispose();
}
示例5: ListControlDisplayNameFigure
import org.eclipse.draw2d.FigureUtilities; //导入方法依赖的package包/类
/**
* @param owner
*/
public ListControlDisplayNameFigure( ListBandEditPart owner )
{
super( );
this.owner = owner;
text = ( ( (ListBandProxy) owner.getModel( ) ).getDisplayName( ) );
Font font = getFont( );
Shell sl = null;
GC gc = null;
if ( font == null )
{
sl = new Shell( );
gc = new GC( sl );
font = gc.getFont( );
}
int width = FigureUtilities.getTextWidth( text, font );
if ( gc != null )
{
gc.dispose( );
}
if ( sl != null )
{
sl.dispose( );
}
setBounds( new Rectangle( 35, 0, width + DISPLAY_MARGIN.right, 19 ) );
setBorder( new MarginBorder( 8, 0, 0, 0 ) );
}
示例6: computeWidth
import org.eclipse.draw2d.FigureUtilities; //导入方法依赖的package包/类
/**
* Computes the width required by control
*
* @param control
* The control to compute width
* @return int The width required
*/
protected int computeWidth(Control control) {
int width = control.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x;
// $TODO: Windows workaround - Fixed in Eclipse 3.0
// Combo is not wide enough to show all text - add enough space for
// another character
if (SWT.getPlatform().equals("win32")) //$NON-NLS-1$
width += FigureUtilities.getTextWidth("8", control.getFont()); //$NON-NLS-1$
return width;
}
示例7: paint
import org.eclipse.draw2d.FigureUtilities; //导入方法依赖的package包/类
@Override
public void paint(Graphics g)
{
g.pushState();
try {
g.setForegroundColor(ColorConstants.black);
g.setBackgroundColor(ColorConstants.white);
// draw lines
double tLineX = getBounds().x;
int lineTop, lineBottom, numLabelWidth;
String numLabel;
for (int x = 0; x <= totalTime; x += dispTimeInterval) {
if (x % (10 * dispTimeInterval) == 0) {
lineTop = 10;
lineBottom = 30;
numLabel = Double.toString(x / 1000.0);
numLabelWidth = FigureUtilities.getTextWidth(numLabel, g.getFont());
g.drawText(numLabel,
(int) (tLineX - ((x == 0.0)
? 0
: (numLabelWidth * .5))),
32);
}
else {
lineTop = 15;
lineBottom = 25;
}
g.drawLine((int)tLineX, lineTop, (int)tLineX, lineBottom);
tLineX += dispTimeIntervalWidth;
}
}
finally {
g.popState();
}
}