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


Java TextLayout.getLineBounds方法代码示例

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


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

示例1: getPreferredHeight

import org.eclipse.swt.graphics.TextLayout; //导入方法依赖的package包/类
public int getPreferredHeight(LayerCell cell, GC gc, IConfigRegistry configRegistry) {
	if (innerTagFactory == null) {
		innerTagFactory = new XliffInnerTagFactory(placeHolderBuilder);
	}
	innerTagFactory.reset();
	TextLayout layout = getCellTextLayout(cell);

	int counts = layout.getLineCount();
	int contentHeight = 0;
	for (int i = 0; i < counts; i++) {
		contentHeight += layout.getLineBounds(i).height;
	}
	layout.dispose();
	contentHeight += Math.max(counts - 1, 0) * SEGMENT_LINE_SPACING;
	contentHeight += 4;// 加上编辑模式下,StyledTextCellEditor的边框
	contentHeight += topPadding;
	contentHeight += bottomPadding;
	return contentHeight;
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:20,代码来源:TextPainterWithPadding.java

示例2: drawInnerTag

import org.eclipse.swt.graphics.TextLayout; //导入方法依赖的package包/类
protected void drawInnerTag(GC gc, TextLayout layout) {
	String displayStr = layout.getText();
	List<InnerTagBean> innerTagBeans = innerTagFactory.getInnerTagBeans();
	Rectangle bounds = getBounds();
	for (InnerTagBean innerTagBean : innerTagBeans) {
		String placeHolder = placeHolderBuilder.getPlaceHolder(innerTagBeans, innerTagBeans.indexOf(innerTagBean));
		int start = displayStr.indexOf(placeHolder);
		if (start == -1) {
			continue;
		}			
		if (gc != null) {
			Point p = layout.getLocation(start, false);
			int x = bounds.x + p.x + leftMargin;
			x += SEGMENT_LINE_SPACING;

			Point tagSize = tagRender.calculateTagSize(innerTagBean);
			int lineIdx = layout.getLineIndex(start);
			Rectangle r = layout.getLineBounds(lineIdx);
			int y = bounds.y + p.y + topMargin + r.height / 2 - tagSize.y /2;				
			tagRender.draw(gc, innerTagBean, x, y - layout.getAscent());
		}
	}
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:24,代码来源:XGridCellRenderer.java

示例3: createMessageArea

import org.eclipse.swt.graphics.TextLayout; //导入方法依赖的package包/类
@Override
protected Control createMessageArea(Composite parent) {
	initializeDialogUnits(parent);

	Composite messageComposite= new Composite(parent, SWT.NONE);
	messageComposite.setFont(parent.getFont());
	GridLayout layout= new GridLayout();
	layout.numColumns= 1;
	layout.marginHeight= 0;
	layout.marginWidth= 0;
	layout.verticalSpacing= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
	layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
	messageComposite.setLayout(layout);
	messageComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

	Label explain= new Label(messageComposite, SWT.WRAP);
	explain.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
	explain.setText(FixMessages.CleanUpPostSaveListener_SlowCleanUpWarningDialog_explain);

	final BulletListBlock cleanUpListBlock= new BulletListBlock(messageComposite, SWT.NONE);
	GridData gridData= new GridData(SWT.FILL, SWT.FILL, true, true);
	cleanUpListBlock.setLayoutData(gridData);
	cleanUpListBlock.setText(fCleanUpNames);

	TextLayout textLayout= new TextLayout(messageComposite.getDisplay());
	textLayout.setText(fCleanUpNames);
	int lineCount= textLayout.getLineCount();
	if (lineCount < 5)
		gridData.heightHint= textLayout.getLineBounds(0).height * 6;
	textLayout.dispose();

	Link link= new Link(messageComposite, SWT.NONE);
	link.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
	link.setText(FixMessages.CleanUpPostSaveListener_SlowCleanUpDialog_link);

	link.addSelectionListener(new SelectionAdapter() {
		/*
		 * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
		 */
		@Override
		public void widgetSelected(SelectionEvent e) {
			PreferencesUtil.createPreferenceDialogOn(getShell(), SaveParticipantPreferencePage.PREFERENCE_PAGE_ID, null, null).open();
		}
	});

	return messageComposite;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:48,代码来源:CleanUpPostSaveListener.java

示例4: computeSize

import org.eclipse.swt.graphics.TextLayout; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public Point computeSize(GC gc, int wHint, int hHint, Object value) {
	GridItem item = (GridItem) value;

	gc.setFont(item.getFont(getColumn()));

	int x = 0;

	x += leftMargin;

	if (isTree()) {
		x += getToggleIndent(item);

		x += toggleRenderer.getBounds().width + insideMargin;

	}

	if (isCheck()) {
		x += checkRenderer.getBounds().width + insideMargin;
	}

	int y = 0;

	Image image = item.getImage(getColumn());
	if (image != null) {
		y = topMargin + image.getBounds().height + bottomMargin;

		x += image.getBounds().width + insideMargin;
	}

	// MOPR-DND
	// MOPR: replaced this code (to get correct preferred height for cells
	// in word-wrap columns)
	//
	// x += gc.stringExtent(item.getText(column)).x + rightMargin;
	//
	// y = Math.max(y,topMargin + gc.getFontMetrics().getHeight() +
	// bottomMargin);
	//
	// with this code:

	int textHeight = 0;
	if (!isWordWrap()) {
		x += gc.textExtent(item.getText(getColumn())).x + rightMargin;

		textHeight = topMargin + textTopMargin + gc.getFontMetrics().getHeight() + textBottomMargin + bottomMargin;
	} else {
		int plainTextWidth;
		if (wHint == SWT.DEFAULT)
			plainTextWidth = getBounds().width - x - rightMargin;
		else
			plainTextWidth = wHint - x - rightMargin;

		TextLayout currTextLayout = new TextLayout(gc.getDevice());
		currTextLayout.setFont(gc.getFont());
		currTextLayout.setText(item.getText(getColumn()));
		currTextLayout.setAlignment(getAlignment());
		currTextLayout.setWidth(plainTextWidth < 1 ? 1 : plainTextWidth);

		x += plainTextWidth + rightMargin;

		textHeight += topMargin + textTopMargin;
		for (int cnt = 0; cnt < currTextLayout.getLineCount(); cnt++)
			textHeight += currTextLayout.getLineBounds(cnt).height;
		textHeight += textBottomMargin + bottomMargin;

		currTextLayout.dispose();
	}

	y = Math.max(y, textHeight);

	return new Point(x, y);
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:76,代码来源:CellRenderer.java

示例5: computeSize

import org.eclipse.swt.graphics.TextLayout; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public Point computeSize(GC gc, int wHint, int hHint, Object value) {
	GridItem item = (GridItem) value;

	gc.setFont(item.getFont(getColumn()));

	int x = 0;

	x += leftMargin;

	int y = 0;

	Image image = item.getImage(getColumn());
	if (image != null) {
		y = topMargin + image.getBounds().height + bottomMargin;

		x += image.getBounds().width + 3;
	}

	// MOPR-DND
	// MOPR: replaced this code (to get correct preferred height for cells in word-wrap columns)
	//
	// x += gc.stringExtent(item.getText(column)).x + rightMargin;
	//
	// y = Math.max(y,topMargin + gc.getFontMetrics().getHeight() + bottomMargin);
	//
	// with this code:

	int textHeight = 0;
	if (!isWordWrap()) {
		x += gc.textExtent(item.getText(getColumn())).x + rightMargin;

		textHeight = topMargin + textTopMargin + gc.getFontMetrics().getHeight() + textBottomMargin + bottomMargin;
	} else {
		int plainTextWidth;
		if (wHint == SWT.DEFAULT)
			plainTextWidth = getBounds().width - x - rightMargin;
		else
			plainTextWidth = wHint - x - rightMargin;

		TextLayout currTextLayout = new TextLayout(gc.getDevice());
		currTextLayout.setFont(gc.getFont());
		currTextLayout.setText(item.getText(getColumn()));
		currTextLayout.setAlignment(getAlignment());
		currTextLayout.setWidth(plainTextWidth < 1 ? 1 : plainTextWidth);

		x += plainTextWidth + rightMargin;

		textHeight += topMargin + textTopMargin;
		for (int cnt = 0; cnt < currTextLayout.getLineCount(); cnt++)
			textHeight += currTextLayout.getLineBounds(cnt).height;
		textHeight += textBottomMargin + bottomMargin;

		currTextLayout.dispose();
	}

	y = Math.max(y, textHeight);

	return new Point(x, y);
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:63,代码来源:TargetColunmCellRenderer.java

示例6: computeSize

import org.eclipse.swt.graphics.TextLayout; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public Point computeSize(GC gc, int wHint, int hHint, Object value) {
	GridItem item = (GridItem) value;

	gc.setFont(item.getFont(getColumn()));

	int x = 0;

	x += leftMargin;

	int y = 0;

	Image image = item.getImage(getColumn());
	if (image != null) {
		y = topMargin + image.getBounds().height + bottomMargin;
	}

	// MOPR-DND
	// MOPR: replaced this code (to get correct preferred height for cells in word-wrap columns)
	//
	// x += gc.stringExtent(item.getText(column)).x + rightMargin;
	//
	// y = Math.max(y,topMargin + gc.getFontMetrics().getHeight() + bottomMargin);
	//
	// with this code:

	int textHeight = 0;
	if (!isWordWrap()) {
		x += gc.textExtent(item.getText(getColumn())).x + rightMargin;

		textHeight = topMargin + textTopMargin + gc.getFontMetrics().getHeight() + textBottomMargin + bottomMargin;
	} else {
		int plainTextWidth;
		if (wHint == SWT.DEFAULT)
			plainTextWidth = getBounds().width - x - rightMargin;
		else
			plainTextWidth = wHint - x - rightMargin;

		TextLayout currTextLayout = new TextLayout(gc.getDevice());
		currTextLayout.setFont(gc.getFont());
		currTextLayout.setText(item.getText(getColumn()));
		currTextLayout.setAlignment(getAlignment());
		currTextLayout.setWidth(plainTextWidth < 1 ? 1 : plainTextWidth);

		x += plainTextWidth + rightMargin;

		textHeight += topMargin + textTopMargin;
		for (int cnt = 0; cnt < currTextLayout.getLineCount(); cnt++)
			textHeight += currTextLayout.getLineBounds(cnt).height;
		textHeight += textBottomMargin + bottomMargin;

		currTextLayout.dispose();
	}

	y = Math.max(y, textHeight);

	return new Point(x, y);
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:61,代码来源:SourceColunmCellRenderer.java

示例7: computeSize

import org.eclipse.swt.graphics.TextLayout; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public Point computeSize(GC gc, int wHint, int hHint, Object value) {
	GridItem item = (GridItem) value;

	gc.setFont(item.getFont(getColumn()));

	int x = 0;

	x += leftMargin;

	if (isTree()) {
		x += getToggleIndent(item);

		x += toggleRenderer.getBounds().width + insideMargin;

	}

	if (isCheck()) {
		x += checkRenderer.getBounds().width + insideMargin;
	}

	int y = 0;

	Image image = item.getImage(getColumn());
	if (image != null) {
		y = topMargin + image.getBounds().height + bottomMargin;

		x += image.getBounds().width + insideMargin;
	}

	// MOPR-DND
	// MOPR: replaced this code (to get correct preferred height for cells in word-wrap columns)
	//
	// x += gc.stringExtent(item.getText(column)).x + rightMargin;
	//
	// y = Math.max(y,topMargin + gc.getFontMetrics().getHeight() + bottomMargin);
	//
	// with this code:

	int textHeight = 0;
	if (!isWordWrap()) {
		x += gc.textExtent(item.getText(getColumn())).x + rightMargin;

		textHeight = topMargin + textTopMargin + gc.getFontMetrics().getHeight() + textBottomMargin + bottomMargin;
	} else {
		int plainTextWidth;
		if (wHint == SWT.DEFAULT)
			plainTextWidth = getBounds().width - x - rightMargin;
		else
			plainTextWidth = wHint - x - rightMargin;

		TextLayout currTextLayout = new TextLayout(gc.getDevice());
		currTextLayout.setFont(gc.getFont());
		currTextLayout.setText(item.getText(getColumn()));
		currTextLayout.setAlignment(getAlignment());
		currTextLayout.setWidth(plainTextWidth < 1 ? 1 : plainTextWidth);

		x += plainTextWidth + rightMargin;

		textHeight += topMargin + textTopMargin;
		for (int cnt = 0; cnt < currTextLayout.getLineCount(); cnt++)
			textHeight += currTextLayout.getLineBounds(cnt).height;
		textHeight += textBottomMargin + bottomMargin;

		currTextLayout.dispose();
	}

	y = Math.max(y, textHeight);

	return new Point(x, y);
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:74,代码来源:TBSearchCellRenderer.java

示例8: computeSize

import org.eclipse.swt.graphics.TextLayout; //导入方法依赖的package包/类
/**
     * {@inheritDoc}
     */
    public Point computeSize(GC gc, int wHint, int hHint, Object value)
    {
        GridItem item = (GridItem)value;

        gc.setFont(item.getFont(getColumn()));

        int x = 0;

        x += leftMargin;

        if (isTree())
        {
            x += getToggleIndent(item);

            x += toggleRenderer.getBounds().width + insideMargin;

        }

        if (isCheck())
        {
            x += checkRenderer.getBounds().width + insideMargin;
        }

        int y = 0;

        Image image = item.getImage(getColumn());
        if (image != null)
        {
            y = topMargin + image.getBounds().height + bottomMargin;

            x += image.getBounds().width + insideMargin;
        }

// MOPR-DND
// MOPR: replaced this code (to get correct preferred height for cells in word-wrap columns)
//
//       x += gc.stringExtent(item.getText(column)).x + rightMargin;
//
//        y = Math.max(y,topMargin + gc.getFontMetrics().getHeight() + bottomMargin);
//
// with this code:

        int textHeight = 0;
        if(!isWordWrap())
        {
            x += gc.textExtent(item.getText(getColumn())).x + rightMargin;

            textHeight = topMargin + textTopMargin + gc.getFontMetrics().getHeight() + textBottomMargin + bottomMargin;
        }
        else
        {
        	int plainTextWidth;
        	if (wHint == SWT.DEFAULT)
        	  plainTextWidth = getBounds().width - x - rightMargin;
        	else
        		plainTextWidth = wHint - x - rightMargin;

            TextLayout currTextLayout = new TextLayout(gc.getDevice());
            currTextLayout.setFont(gc.getFont());
            currTextLayout.setText(item.getText(getColumn()));
            currTextLayout.setAlignment(getAlignment());
            currTextLayout.setWidth(plainTextWidth < 1 ? 1 : plainTextWidth);

            x += plainTextWidth + rightMargin;

            textHeight += topMargin + textTopMargin;
            for(int cnt=0;cnt<currTextLayout.getLineCount();cnt++)
                textHeight += currTextLayout.getLineBounds(cnt).height;
            textHeight += textBottomMargin + bottomMargin;

            currTextLayout.dispose();
        }

        y = Math.max(y, textHeight);

        return new Point(x, y);
    }
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:81,代码来源:DefaultCellRenderer.java


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