当前位置: 首页>>代码示例>>Java>>正文


Java FigureUtilities.getStringExtents方法代码示例

本文整理汇总了Java中org.eclipse.draw2d.FigureUtilities.getStringExtents方法的典型用法代码示例。如果您正苦于以下问题:Java FigureUtilities.getStringExtents方法的具体用法?Java FigureUtilities.getStringExtents怎么用?Java FigureUtilities.getStringExtents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.draw2d.FigureUtilities的用法示例。


在下文中一共展示了FigureUtilities.getStringExtents方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: relocate

import org.eclipse.draw2d.FigureUtilities; //导入方法依赖的package包/类
public void relocate(CellEditor celleditor) {
	Text text = (Text) celleditor.getControl();
	Rectangle rect = null;
	if(bounds == null) { 
		rect = figure.getBounds().getCopy();
	} else { 
		rect = bounds.getCopy();
	}
	figure.translateToAbsolute(rect);
	org.eclipse.swt.graphics.Rectangle trim = text.computeTrim(0, 0, 0, 0);
	rect.translate(trim.x, trim.y);
	rect.width += trim.width;
	rect.height = HEIGHT;
	if (text.getFont() != null){
		rect.height = FigureUtilities.getStringExtents("T", text.getFont()).height + 4;
	}
	text.setBounds(rect.x, rect.y - rect.height, rect.width, rect.height);
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:19,代码来源:ElementCellEditorLocator.java

示例2: paintMessage

import org.eclipse.draw2d.FigureUtilities; //导入方法依赖的package包/类
protected void paintMessage(Graphics graphics, Rectangle parentRect) {
	String message = Utils.getString(this.message, "");
	List<String> text = SWTWordWrap.wrap(message, resolution.width - 24, graphics.getFont());
	if (text != null && text.size() > 0){
		int oneLineHeight = getMargin()
			+ FigureUtilities.getStringExtents("X", graphics.getFont()).height;
		graphics.pushState();
		graphics.clipRect(parentRect);

		int y = parentRect.y;
		for (int i = 0; y < parentRect.bottom() && i < text.size(); i++) {
			Rectangle lineRect = new Rectangle(parentRect.x, y, parentRect.width,
					oneLineHeight + getMargin());
			Drawer.drawString(graphics, text.get(i), lineRect, Alignments.left, Alignments.top, getMargin());
			y += oneLineHeight;
		}
		graphics.popState();
	}
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:20,代码来源:EmailDialogFigure.java

示例3: canDrawNumber

import org.eclipse.draw2d.FigureUtilities; //导入方法依赖的package包/类
private boolean canDrawNumber(String num, Point startPoint ,Graphics g)
{
	Transposer transposer = new Transposer();
	transposer.setEnabled( !isHorizontal() );
	Rectangle rect =  transposer.t( g.getClip( Rectangle.SINGLETON ));
	Dimension strSize = FigureUtilities.getStringExtents(num, getFont());
	startPoint = transposer.t(startPoint);
	
	if (strSize.width + startPoint.x > rect.x  +  rect.width)
	{
		return false;
	}
	rect = transposer.t( getEndRect( g
			.getClip( Rectangle.SINGLETON ) ));
	
	if (rect.width == 0)
	{
		return true;
	}
	if (strSize.width + startPoint.x > rect.x)
	{
		return false;
	}
	return true;
}
 
开发者ID:eclipse,项目名称:birt,代码行数:26,代码来源:EditorRulerFigure.java

示例4: paintTitle

import org.eclipse.draw2d.FigureUtilities; //导入方法依赖的package包/类
@Override
public void paintTitle(Graphics graphics) {
	if (Utils.isNotEmpty(getText())){
		graphics.pushState();
		Color bgColor = graphics.getBackgroundColor(); 
		graphics.setBackgroundColor(ColorConstants.white);
		int titleHeight = FigureUtilities.getStringExtents(getText(), titleFont).height;
		Rectangle titleRect = getTextHolderRectangle();
		Rectangle imRect = new Rectangle(titleRect.x + getMargin(),
				titleRect.y + getMargin(), titleHeight,	titleHeight);
		graphics.fillArc(imRect, 0, 360);
		
		graphics.setBackgroundColor(bgColor);
		imRect.shrink(4, 4);
		graphics.fillArc(imRect, 0, 360);
		
		graphics.setBackgroundColor(ColorConstants.white);
		graphics.fillPolygon(new int[]{imRect.x + imRect.width / 6,
				imRect.y + imRect.width / 3,
				imRect.x + imRect.width - imRect.width/ 6,
				imRect.y + imRect.width / 3,
				imRect.x + imRect.width/ 2,
				imRect.y + imRect.width});
		
		graphics.setBackgroundColor(ColorConstants.gray);
		graphics.drawLine(titleRect.x + 50, titleRect.y + titleHeight + getMargin() + 1,
				titleRect.right() - 50, titleRect.y + titleHeight + getMargin() + 1);
		graphics.popState();
		titleRect.x += titleHeight + getMargin()*2;
		titleRect.width -= titleHeight + getMargin()*3;
		paintString(graphics, getText(), titleRect);
		
	}
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:35,代码来源:AndroidAlertDialogFigure.java

示例5: paintTitaniumFigure

import org.eclipse.draw2d.FigureUtilities; //导入方法依赖的package包/类
@Override
protected void paintTitaniumFigure(Graphics graphics) {
	String time = getTime();
	time_width = FigureUtilities
		.getStringExtents(time, graphics.getFont()).width;
	graphics.setForegroundColor(ColorConstants.white);
	this.paintString(graphics, time, getBounds());
	this.paintRightImage(graphics);
	this.paintSignalImage(graphics);
	this.paintSignal3GImage(graphics);
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:12,代码来源:AndroidCarrierFigure.java

示例6: paintTitaniumFigure

import org.eclipse.draw2d.FigureUtilities; //导入方法依赖的package包/类
@Override
protected void paintTitaniumFigure(Graphics graphics) {
	titleFont = createTitleFont();
	graphics.pushState();
	graphics.setFont(titleFont);
	paintTitle(graphics);
	graphics.popState();
	paintLines(graphics, getLines(), getLinesHolderRectangle());
	Rectangle expRect = getTextHolderRectangle();
	if (explanation != null && explanation.length() > 0){
		int titleHeight = getMargin()*2;
		if (getText() != null && getText().length() > 0){
			titleHeight += FigureUtilities.getStringExtents(getText(), titleFont).height;
		}
		expRect.height -= titleHeight;
		expRect.y += titleHeight;
		paintString(graphics, explanation, expRect);
	}
	if (okButton.getText() != null){
		graphics.setFont(okButton.getFont_());
		Dimension p = FigureUtilities.getStringExtents(okButton.getText(), okButton.getFont_());
		p.expand(20, 4);
		p.width = Math.min(p.width, expRect.width);
		p.height = 40;
		okButton.setBounds(new Rectangle(expRect.getBottomLeft().getTranslated(
				(expRect.width - p.width) / 2, -2 - p.height), p));
		okButton.paint(graphics);
	}
	titleFont.dispose();
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:31,代码来源:AlertDialogFigure.java

示例7: getLinesHolderRectangle

import org.eclipse.draw2d.FigureUtilities; //导入方法依赖的package包/类
protected Rectangle getLinesHolderRectangle(){
	Rectangle r = getClientArea();
	if (useLocalCoordinates()){
		r.setLocation(getBounds().getLocation());
	}
	if (getText() != null && getText().length() > 0){
		Dimension textSize = FigureUtilities.getStringExtents(getText(), titleFont);
		r.y += textSize.height + getMargin();
		r.height -= textSize.height + getMargin();
	}
	return r;
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:13,代码来源:AlertDialogFigure.java

示例8: drawBadge

import org.eclipse.draw2d.FigureUtilities; //导入方法依赖的package包/类
public static void drawBadge(Graphics graphics, Rectangle r, String text){
	if (Utils.isNotEmpty(text)){
		graphics.setBackgroundColor(ColorConstants.white);
		Dimension textSize = FigureUtilities.getStringExtents(text, graphics.getFont());
		int h = textSize.height;
		int w = Math.max(h, textSize.width + 8);
		int radius = Math.min(w, h);
		graphics.fillRoundRectangle(new Rectangle(r.right()-w-2, r.y+2, w, h), radius, radius);
		graphics.setBackgroundColor(ColorConstants.red);
		Rectangle textRect = new Rectangle(r.right()-w-1, r.y + 3,w-2, h-2);
		radius = Math.min(textRect.width, textRect.height);
		graphics.fillRoundRectangle(textRect, radius, radius);
		drawString(graphics, text, textRect);
	}
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:16,代码来源:Drawer.java

示例9: drawString

import org.eclipse.draw2d.FigureUtilities; //导入方法依赖的package包/类
public static void drawString(Graphics graphics, String text, Rectangle parentRect,
		Alignments hAlign, Alignments vAlign, int textMargin) {
	if (text != null && text.length() > 0){
		graphics.pushState();
		Dimension textSize = FigureUtilities.getStringExtents(text, graphics.getFont());
		Point textLocation = getTextLocation(parentRect,
				textSize, hAlign, vAlign, textMargin);
		graphics.clipRect(parentRect);
		graphics.drawString(text, textLocation);
		graphics.popState();
	}
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:13,代码来源:Drawer.java

示例10: paintLeftImage

import org.eclipse.draw2d.FigureUtilities; //导入方法依赖的package包/类
protected void paintLeftImage(Graphics graphics) {
	if (signalImage != null){
		Rectangle dest = super.getTextHolderRectangle();
		Dimension textSize = FigureUtilities.getStringExtents(CARRIER, graphics.getFont());
		dest.translate(textSize.width + getMargin()*2,
				(dest.height - IMAGE_SIZE) / 2);
		dest.setSize(new Dimension(IMAGE_SIZE, IMAGE_SIZE));
		graphics.drawImage(signalImage, new Rectangle(0, 0, signalImage.getImageData().width,
				signalImage.getImageData().height), dest);
	}
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:12,代码来源:IPhoneCarrierFigure.java

示例11: getTitleHeight

import org.eclipse.draw2d.FigureUtilities; //导入方法依赖的package包/类
public int getTitleHeight(){
	if (getFont_() != null){
		return FigureUtilities.getStringExtents("Some Text", getFont_()).height;
	} else {
		return FigureUtilities.getStringExtents("Some Text", Display.getCurrent().getSystemFont()).height;
	}
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:8,代码来源:TableViewFigure.java

示例12: wrap

import org.eclipse.draw2d.FigureUtilities; //导入方法依赖的package包/类
public static List<String> wrap(String text, int width, Font font){
	if (text == null) return Collections.emptyList();
	text = text.trim();
	List<String> lines = new ArrayList<String>();
	if (text.length() != 0){
		if (FigureUtilities.getStringExtents(text, font).width > width){
			int i = text.length() - 2;
			//find the maximum string length
			for (;FigureUtilities.getStringExtents(text.substring(0, i), font).width > width
				&& i > 0;i--){
				i--;
			}
			int j = i + 1;//include previous char to delimiter test
			while (delimiters.indexOf(text.charAt(j)) < 0 && j > 0){j--;}
			if (j == 0){//no delimiters are found
				lines.add(text.substring(0, i));
				lines.addAll(wrap(text.substring(i), width, font));
			} else {//delimiter at position j
				//include delimiter as it can be not a whitespace
				lines.add(text.substring(0, j + 1).trim());
				lines.addAll(wrap(text.substring(j + 1), width, font));
			}
		} else {
			lines.add(text);
		}
	}
	return lines;
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:29,代码来源:SWTWordWrap.java

示例13: getFontAverageCharWidth

import org.eclipse.draw2d.FigureUtilities; //导入方法依赖的package包/类
private static int getFontAverageCharWidth(Font f)
{
    StringBuffer buf = new StringBuffer(""); //$NON-NLS-1$
    for(int i= 'A'; i<='Z'; i++) {
        buf.append((char)i);
    }
    for(int i= 'a'; i<='z'; i++) {
        buf.append((char)i);
    }
    Dimension dim = FigureUtilities.getStringExtents(buf.toString(),f);
    return (int)div(dim.width,52);
}
 
开发者ID:henrikor2,项目名称:eclipsensis,代码行数:13,代码来源:FigureUtility.java

示例14: getRowHeight

import org.eclipse.draw2d.FigureUtilities; //导入方法依赖的package包/类
private int getRowHeight(){
	return  FigureUtilities.getStringExtents("T", getFigure().getFont_()).height;
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:4,代码来源:AlertDialogEditPart.java

示例15: refreshVisuals

import org.eclipse.draw2d.FigureUtilities; //导入方法依赖的package包/类
@Override
protected void refreshVisuals() {
	LabelFigure figure = (LabelFigure)getFigure();
	Label model = getModel();
	
	figure.setFontData(Converter.getFontDataFromFont(model.getFont()));
	String modelText = getText();
	int width = modelText == null ? 0 : FigureUtilities.getStringExtents(modelText, figure.getFont_()).width;
	
	int elementWidth = getBounds().width;
	elementWidth -= (int)(Utils.getFloat(model.getBorderWidth(), 0)*2);//0 is default for label
	
	if (Utils.getBoolean(model.getWordWrap(), false)){
		figure.setLines(SWTWordWrap.wrap(modelText, elementWidth, figure.getFont_())
				.toArray(new String[0]));
		figure.setText(null);
	} else {
		boolean defaultEllipsize = getModel().getPlatform().isIPhone();
		if (Utils.getBoolean(model.getEllipsize(), defaultEllipsize) && Utils.isNotEmpty(modelText)) {
			if (elementWidth > 0 && elementWidth < width) { 
				StringBuffer textString = new StringBuffer(modelText + "...");
				while (elementWidth < width && textString.length() > 3) {
					textString = textString.delete(textString.length() - 4, textString.length() - 3);
					width = FigureUtilities.getStringExtents(textString.toString(), figure.getFont_()).width;
				}
				figure.setText(textString.toString());
			}
		} else {
			figure.setText(modelText);
		}
		figure.setLines(null);
	}
	
	// For the text align
	figure.setTextAlign(model.getTextAlign());
	figure.setFontColor(model.getColor());
	
	figure.getBorder().setOpaque(getBackgroundColor() == null && getBackgroundImage() == null);
	
	super.refreshVisuals();
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:42,代码来源:LabelEditPart.java


注:本文中的org.eclipse.draw2d.FigureUtilities.getStringExtents方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。