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


Java GlyphMetrics类代码示例

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


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

示例1: Note

import org.eclipse.swt.graphics.GlyphMetrics; //导入依赖的package包/类
/**
 * Constructor. Sets properties of the editor window.
 * 
 * @param parent
 * @param text
 * @param editable
 * @param shortcutHandler
 */
public Note(Composite parent, String text, boolean editable) {
	// Enable multiple lines and scroll bars.
	super(parent, SWT.V_SCROLL | SWT.H_SCROLL);

	preferences = InstanceScope.INSTANCE.getNode(Notepad4e.PLUGIN_ID);

	undoRedoManager = new UndoRedoManager(this);
	bulletStyle = new StyleRange();
	bulletStyle.metrics = new GlyphMetrics(0, 0, 0);

	// Scroll bars only appear when the text extends beyond the note window.
	setAlwaysShowScrollBars(false);
	setParametersFromPreferences();
	setText(text);
	initialiseMenu();

	if (!editable) {
		toggleEditable();
	}
}
 
开发者ID:PyvesB,项目名称:Notepad4e,代码行数:29,代码来源:Note.java

示例2: createUI30Hints

import org.eclipse.swt.graphics.GlyphMetrics; //导入依赖的package包/类
private void createUI30Hints(final Composite parent) {

		final Composite container = new Composite(parent, SWT.NONE);
		GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(container);
		GridLayoutFactory.fillDefaults().numColumns(1).applyTo(container);
		{
			// use a bulleted list to display this info
			final StyleRange style = new StyleRange();
			style.metrics = new GlyphMetrics(0, 0, 10);
			final Bullet bullet = new Bullet(style);

			final String infoText = Messages.Modify_MapProvider_Label_Hints;
			final int lineCount = Util.countCharacter(infoText, '\n');

			final StyledText styledText = new StyledText(container, SWT.READ_ONLY | SWT.WRAP | SWT.MULTI);
			GridDataFactory.fillDefaults().grab(true, false).applyTo(styledText);
			styledText.setText(infoText);
			styledText.setBackground(container.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
			styledText.setLineBullet(1, lineCount, bullet);
			styledText.setLineWrapIndent(1, lineCount, 10);
		}
	}
 
开发者ID:wolfgang-ch,项目名称:mytourbook,代码行数:23,代码来源:DialogModifyMapProvider.java

示例3: createUI_76_Hints

import org.eclipse.swt.graphics.GlyphMetrics; //导入依赖的package包/类
private void createUI_76_Hints(final Composite parent) {

		// use a bulleted list to display this info
		final StyleRange style = new StyleRange();
		style.metrics = new GlyphMetrics(0, 0, 10);
		final Bullet bullet = new Bullet(style);

		final String infoText = Messages.ColumnModifyDialog_Label_Hints;
		final int lineCount = Util.countCharacter(infoText, '\n');

		final StyledText styledText = new StyledText(parent, SWT.READ_ONLY | SWT.WRAP | SWT.MULTI);
		styledText.setText(infoText);
		styledText.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
		styledText.setLineBullet(1, lineCount, bullet);
		styledText.setLineWrapIndent(1, lineCount, 10);
		GridDataFactory.fillDefaults()//
				.grab(true, false)
				.span(2, 1)
				.applyTo(styledText);
	}
 
开发者ID:wolfgang-ch,项目名称:mytourbook,代码行数:21,代码来源:DialogModifyColumns.java

示例4: configureStyledText

import org.eclipse.swt.graphics.GlyphMetrics; //导入依赖的package包/类
private void configureStyledText(String text, boolean enabled) {
	if (fStyledText == null)
		return;

	fStyledText.setText(text);
	int count= fStyledText.getCharCount();
	if (count == 0)
		return;

	Color foreground= enabled ? null : Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY);

	fStyledText.setStyleRange(new StyleRange(0, count, foreground, null));

	StyleRange styleRange= new StyleRange(0, count, foreground, null);
	styleRange.metrics= new GlyphMetrics(0, 0, 20);
	fStyledText.setLineBullet(0, fStyledText.getLineCount(), new Bullet(styleRange));

	fStyledText.setEnabled(enabled);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:BulletListBlock.java

示例5: lineGetStyle

import org.eclipse.swt.graphics.GlyphMetrics; //导入依赖的package包/类
@Override
public void lineGetStyle(LineStyleEvent e) {
	// Set the line number
	int line = tc.getLineAtOffset(e.lineOffset);
	int lastLine = tc.getLineCount() - 1;

	e.bulletIndex = line;

	String prompt = "gdb>";

	// Set the style, 12 pixles wide for each digit
	StyleRange style = new StyleRange();
	style.metrics = new GlyphMetrics(0, 0, prompt.length() * 12);

	// Create and set the bullet
	e.bullet = new Bullet(ST.BULLET_TEXT, style);
	if (line == lastLine) {
		e.bullet.text = prompt;
	} else {
		e.bullet.text = "";
	}
}
 
开发者ID:AndersDala,项目名称:eclipse-debug-console-history,代码行数:23,代码来源:StyledTextConsolePage.java

示例6: buildMainModelStyle

import org.eclipse.swt.graphics.GlyphMetrics; //导入依赖的package包/类
private Bullet buildMainModelStyle() {
	StyleRange style = new StyleRange();
	style.metrics = new GlyphMetrics(0, 0, 40);
	style.foreground = Display.getDefault().getSystemColor(SWT.COLOR_BLACK);
	Bullet bullet = new Bullet(style);
	return bullet;
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:8,代码来源:TestPresentationPage.java

示例7: buildAdditionalTitleModelStyle

import org.eclipse.swt.graphics.GlyphMetrics; //导入依赖的package包/类
private Bullet buildAdditionalTitleModelStyle() {
	StyleRange style = new StyleRange();
	style.metrics = new GlyphMetrics(0, 0, 40);
	style.foreground = Display.getDefault().getSystemColor(SWT.COLOR_BLACK);
	Bullet bullet = new Bullet(style);
	return bullet;
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:8,代码来源:TestPresentationPage.java

示例8: buildCheckedlStyle

import org.eclipse.swt.graphics.GlyphMetrics; //导入依赖的package包/类
private Bullet buildCheckedlStyle() {
	StyleRange style2 = new StyleRange();
	style2.metrics = new GlyphMetrics(0, 0, 80);
	style2.foreground = Display.getDefault().getSystemColor(SWT.COLOR_BLACK);
	Bullet bullet = new Bullet(ST.BULLET_TEXT, style2);
	bullet.text = "\u2713";
	return bullet;
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:9,代码来源:TestPresentationPage.java

示例9: lineGetStyle

import org.eclipse.swt.graphics.GlyphMetrics; //导入依赖的package包/类
public void lineGetStyle(LineStyleEvent e) {
	int lineStart = e.lineOffset;
	int lineEnd = lineStart + e.lineText.length();
	// Set the line number
	e.bulletIndex = text.getLineAtOffset(lineStart);
	
	// Set the style, 12 pixels wide for each digit
	StyleRange style = new StyleRange();
	style.foreground = new Color(text.getDisplay(), 120, 120, 120);
	style.fontStyle = SWT.ITALIC;
	style.metrics = new GlyphMetrics(0, 0, Integer.toString(text.getLineCount() + 1).length() * 12);
	// Create and set the bullet
	e.bullet = new Bullet(ST.BULLET_NUMBER, style);
	
	List<StyleRange> ranges = Lists.newArrayList();
	for(TermOccurrence occ:FileEditorPart.this.occurrences) {
		if((occ.getBegin() < lineEnd && occ.getEnd() > lineStart)) {
			int styleStart = Ints.max(occ.getBegin(), lineStart);
			int styleEnd = Ints.min(occ.getEnd(), lineEnd);
			int overlap = styleEnd - styleStart;
			StyleRange styleRange = new StyleRange();
			styleRange.start = styleStart;
			styleRange.length =  overlap;
			if(occ.equals(activeOccurrence)) {
				styleRange.fontStyle = SWT.BOLD | SWT.ITALIC;
				styleRange.background = COLOR_CYAN;
			} else {
				styleRange.background = COLOR_GRAY;						
			}
				
			ranges.add(styleRange);
		}
	}
	e.styles = ranges.toArray(new StyleRange[ranges.size()]);
}
 
开发者ID:termsuite,项目名称:termsuite-ui,代码行数:36,代码来源:FileEditorPart.java

示例10: setLineBulletAndStuff

import org.eclipse.swt.graphics.GlyphMetrics; //导入依赖的package包/类
protected void setLineBulletAndStuff() {
		text.setLineBullet(0, text.getLineCount(), null); // delete line bullet first to guarantee update! (bug in SWT?)
		if (settings.isShowLineBullets() && currentRegionObject!=null && getNTextLines()>0) {
			Storage store = Storage.getInstance();
			for (int i=0; i<text.getLineCount(); ++i) {				
				final int docId = store.getDoc().getId();
				final int pNr = store.getPage().getPageNr();
				
				int bulletFgColor = SWT.COLOR_BLACK;
				
				int fontStyle = SWT.NORMAL;
				if (i>= 0 && i <currentRegionObject.getTextLine().size()) {
					final String lineId = currentRegionObject.getTextLine().get(i).getId();
					boolean hasWg = store.hasWordGraph(docId, pNr, lineId);
					
					fontStyle = (i == getCurrentLineIndex()) ? SWT.BOLD : SWT.NORMAL;	
					bulletFgColor = hasWg ? SWT.COLOR_DARK_GREEN : SWT.COLOR_BLACK;
				}

				StyleRange style = new StyleRange(0, text.getCharCount(), Colors.getSystemColor(bulletFgColor), Colors.getSystemColor(SWT.COLOR_GRAY), fontStyle);
				style.metrics = new GlyphMetrics(0, 0, Integer.toString(text.getLineCount() + 1).length() * 12);
//				style.background = Colors.getSystemColor(SWT.COLOR_GRAY);
				Bullet bullet = new Bullet(/*ST.BULLET_NUMBER |*/ ST.BULLET_TEXT, style);
				bullet.text = ""+(i+1);
				
				text.setLineBullet(i, 1, bullet);
				text.setLineIndent(i, 1, 25);
				text.setLineAlignment(i, 1, settings.getTextAlignment());
				text.setLineWrapIndent(i, 1, 25+style.metrics.width);
			}
			
//			text.setLineBullet(0, text.getLineCount(), bullet);
//			text.setLineIndent(0, text.getLineCount(), 25);
//			text.setLineAlignment(0, text.getLineCount(), textAlignment);
//			text.setLineWrapIndent(0, text.getLineCount(), 25+style.metrics.width);			
			

		}
	}
 
开发者ID:Transkribus,项目名称:TranskribusSwtGui,代码行数:40,代码来源:ATranscriptionWidget.java

示例11: setLineBullet

import org.eclipse.swt.graphics.GlyphMetrics; //导入依赖的package包/类
private void setLineBullet() {
		StyleRange style = new StyleRange();
		style.metrics = new GlyphMetrics(0, 0, Integer.toString(text.getLineCount() + 1).length() * 12);
		style.background = Colors.getSystemColor(SWT.COLOR_GRAY);
		Bullet bullet = new Bullet(ST.BULLET_NUMBER, style);
		text.setLineBullet(0, text.getLineCount(), bullet);
//		text.setLineIndent(0, text.getLineCount(), 25);
//		text.setLineAlignment(0, text.getLineCount(), textAlignment);
//		text.setLineWrapIndent(0, text.getLineCount(), 25+style.metrics.width);		
	}
 
开发者ID:Transkribus,项目名称:TranskribusSwtGui,代码行数:11,代码来源:XmlViewer.java

示例12: addBulletForLine

import org.eclipse.swt.graphics.GlyphMetrics; //导入依赖的package包/类
private static void addBulletForLine(StyledText styledText, LineStyleEvent event,
                                     Map<StyleType, StyleRangeTemplate> theme) {
    // Using ST.BULLET_NUMBER sometimes results in weird alignment.
    //event.bulletIndex = styledText.getLineAtOffset(event.lineOffset);
    StyleRange styleRange = theme.get(StyleType.LINE_NUMBER).create();
    int maxLine = styledText.getLineCount();
    int bulletLength = Integer.toString(maxLine).length();
    // Width of number character is half the height in monospaced font, add 1 character width for right padding.
    int bulletWidth = (bulletLength + 1) * styledText.getLineHeight() / 2;
    styleRange.metrics = new GlyphMetrics(0, 0, bulletWidth);
    event.bullet = new Bullet(ST.BULLET_TEXT, styleRange);
    // getLineAtOffset() returns a zero-based line index.
    int bulletLine = styledText.getLineAtOffset(event.lineOffset) + 1;
    event.bullet.text = String.format("%" + bulletLength + "s", bulletLine);
}
 
开发者ID:DreaminginCodeZH,项目名称:mipsasm,代码行数:16,代码来源:StyledTextStyleHelper.java

示例13: getCellTextLayout

import org.eclipse.swt.graphics.GlyphMetrics; //导入依赖的package包/类
private TextLayout getCellTextLayout(LayerCell cell) {
	int orientation = editor.getTable().getStyle() & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT);
	TextLayout layout = new TextLayout(editor.getTable().getDisplay());
	layout.setOrientation(orientation);
	layout.setSpacing(Constants.SEGMENT_LINE_SPACING);
	layout.setFont(font);
	layout.setAscent(ascent);
	layout.setDescent(descent); // 和 StyledTextEditor 同步
	layout.setTabs(new int[] { tabWidth });

	Rectangle rectangle = cell.getBounds();
	int width = rectangle.width - leftPadding - rightPadding;
	width -= 1;
	if (wrapText && width > 0) {
		layout.setWidth(width);
	}

	String displayText = InnerTagUtil.resolveTag(innerTagFactory.parseInnerTag((String) cell.getDataValue()));
	if (XliffEditorParameter.getInstance().isShowNonpirnttingCharacter()) {
		displayText = displayText.replaceAll("\\n", Constants.LINE_SEPARATOR_CHARACTER + "\n");
		displayText = displayText.replaceAll("\\t", Constants.TAB_CHARACTER + "\u200B");
		displayText = displayText.replaceAll(" ", Constants.SPACE_CHARACTER + "\u200B");
	}
	layout.setText(displayText);
	List<InnerTagBean> innerTagBeans = innerTagFactory.getInnerTagBeans();
	for (InnerTagBean innerTagBean : innerTagBeans) {
		String placeHolder = placeHolderBuilder.getPlaceHolder(innerTagBeans, innerTagBeans.indexOf(innerTagBean));
		int start = displayText.indexOf(placeHolder);
		if (start == -1) {
			continue;
		}
		TextStyle style = new TextStyle();
		Point rect = tagRender.calculateTagSize(innerTagBean);
		style.metrics = new GlyphMetrics(rect.y, 0, rect.x + SEGMENT_LINE_SPACING * 2);
		layout.setStyle(style, start, start + placeHolder.length() - 1);
	}

	return layout;
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:40,代码来源:TextPainterWithPadding.java

示例14: addRange

import org.eclipse.swt.graphics.GlyphMetrics; //导入依赖的package包/类
/**
 * Adds style information to the given text presentation.
 * @param presentation
 *            the text presentation to be extended
 * @param offset
 *            the offset of the range to be styled
 * @param length
 *            the length of the range to be styled
 * @param textStyle
 *            the style of the range to be styled
 */
protected void addRange(TextPresentation presentation, int offset, int length, TextStyle textStyle) {
	if (textStyle != null) {

		if (textStyle.metrics != null && length >= 1) {
			for (int i = offset; i < offset + length; i++) {
				try {
					StyleRange styleRange = new StyleRange(textStyle);
					String placeHolder = fDocument.get(i, 1);
					InnerTag innerTag = InnerTagUtil.getInnerTag(fViewer.getInnerTagCacheList(), placeHolder);
					if (innerTag != null) {
						Point rect = innerTag.computeSize(SWT.DEFAULT, SWT.DEFAULT);
						// int ascent = 4 * rect.height / 5 + SEGMENT_LINE_SPACING / 2;
						// int descent = rect.height - ascent + SEGMENT_LINE_SPACING;
						styleRange.metrics = new GlyphMetrics(rect.y, 0, rect.x + SEGMENT_LINE_SPACING * 2);
					}
					styleRange.start = i;
					styleRange.length = 1;
					presentation.addStyleRange(styleRange);
				} catch (BadLocationException e) {
					e.printStackTrace();
				}
			}
		} /*
		 * else { StyleRange styleRange = new StyleRange(textStyle); styleRange.start = offset; styleRange.length =
		 * length; presentation.addStyleRange(styleRange); }
		 */
	}
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:40,代码来源:PresentationRepairer.java

示例15: addRange

import org.eclipse.swt.graphics.GlyphMetrics; //导入依赖的package包/类
private void addRange(List<StyleRange> ranges, int start, int length, Color foreground, boolean isCode) {
    StyleRange range = new StyleRange(start, length, foreground, null);
    AnsiConsoleAttributes.updateRangeStyle(range, lastAttributes);
    if (isCode) {
        range.metrics = new GlyphMetrics(0, 0, 0);
    }
    ranges.add(range);
    lastRangeEnd = lastRangeEnd + range.length;
}
 
开发者ID:Talend,项目名称:tesb-studio-se,代码行数:10,代码来源:AnsiConsoleStyleListener.java


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