本文整理汇总了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();
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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 = "";
}
}
示例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;
}
示例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;
}
示例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;
}
示例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()]);
}
示例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);
}
}
示例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);
}
示例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);
}
示例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;
}
示例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); }
*/
}
}
示例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;
}