public void lineGetStyle(LineStyleEvent e) { StyleRange style = new StyleRange(); style.metrics = new GlyphMetrics(0, 0, Integer.toString(100000).length()*5); e.bullet = new Bullet(ST.BULLET_DOT, style); } });
/** * Returns an integer hash code for the receiver. Any two * objects that return <code>true</code> when passed to * <code>equals</code> must return the same value for this * method. * * @return the receiver's hash * * @see #equals(Object) */ public int hashCode() { int hash = 0; if (foreground != null) hash ^= foreground.hashCode(); if (background != null) hash ^= background.hashCode(); if (font != null) hash ^= font.hashCode(); if (metrics != null) hash ^= metrics.hashCode(); if (underline) hash ^= (hash << 1); if (strikeout) hash ^= (hash << 2); hash ^= rise; if (underlineColor != null) hash ^= underlineColor.hashCode(); if (strikeoutColor != null) hash ^= strikeoutColor.hashCode(); if (borderColor != null) hash ^= borderColor.hashCode(); hash ^= underlineStyle; return hash; }
if (run.style != null && run.style.metrics != null) { GlyphMetrics metrics = run.style.metrics; cx = metrics.getWidthInPixels() * (start - run.start); } else if (!run.tab) { int[] piX = new int[1]; if (run.style != null && run.style.metrics != null) { GlyphMetrics metrics = run.style.metrics; cx = metrics.getWidthInPixels() * (end - run.start + 1); } else if (!run.tab) { int[] piX = new int[1];
/** * Returns an integer hash code for the receiver. Any two * objects that return <code>true</code> when passed to * <code>equals</code> must return the same value for this * method. * * @return the receiver's hash * * @see #equals(Object) */ @Override public int hashCode() { int hash = 0; if (foreground != null) hash ^= foreground.hashCode(); if (background != null) hash ^= background.hashCode(); if (font != null) hash ^= font.hashCode(); if (metrics != null) hash ^= metrics.hashCode(); if (underline) hash ^= (hash << 1); if (strikeout) hash ^= (hash << 2); hash ^= rise; if (underlineColor != null) hash ^= underlineColor.hashCode(); if (strikeoutColor != null) hash ^= strikeoutColor.hashCode(); if (borderColor != null) hash ^= borderColor.hashCode(); hash ^= underlineStyle; return hash; }
if (run.style != null && run.style.metrics != null) { GlyphMetrics metrics = run.style.metrics; width = metrics.getWidthInPixels() * (offset - run.start + (trailing ? 1 : 0)); } else if (run.tab) { width = (trailing || (offset == length)) ? run.width : 0;
@Override public void lineGetStyle(LineStyleEvent event) { StyleRange range = new StyleRange(); range.foreground = Display.getCurrent().getSystemColor(SWT.COLOR_GRAY); int maxNumLine = styledText.getLineCount(); int bulletLength = Integer.toString(maxNumLine).length(); // right padding int widthBullet = ((bulletLength + 1) * styledText.getLineHeight()) / 2; range.metrics = new GlyphMetrics(0, 0, widthBullet); event.bullet = new Bullet(ST.BULLET_TEXT, range); event.bullet.text = String.format("%" + bulletLength + "s", styledText.getLineAtOffset(event.lineOffset) + 1); }
/** * Returns an integer hash code for the receiver. Any two * objects that return <code>true</code> when passed to * <code>equals</code> must return the same value for this * method. * * @return the receiver's hash * * @see #equals(Object) */ @Override public int hashCode() { int hash = 0; if (foreground != null) hash ^= foreground.hashCode(); if (background != null) hash ^= background.hashCode(); if (font != null) hash ^= font.hashCode(); if (metrics != null) hash ^= metrics.hashCode(); if (underline) hash ^= (hash << 1); if (strikeout) hash ^= (hash << 2); hash ^= rise; if (underlineColor != null) hash ^= underlineColor.hashCode(); if (strikeoutColor != null) hash ^= strikeoutColor.hashCode(); if (borderColor != null) hash ^= borderColor.hashCode(); hash ^= underlineStyle; return hash; }
if (run.style != null && run.style.metrics != null) { GlyphMetrics metrics = run.style.metrics; if (metrics.getWidthInPixels() > 0) { if (trailing != null) { trailing[0] = (xRun % metrics.getWidthInPixels() < metrics.getWidthInPixels() / 2) ? 0 : 1; return untranslateOffset(run.start + xRun / metrics.getWidthInPixels());
private Bullet createBullet(Composite main) { StyleRange style = new StyleRange(); style.metrics = new GlyphMetrics(0, 0, 40); style.foreground = main.getDisplay().getSystemColor(SWT.COLOR_BLACK); Bullet bullet = new Bullet(style); return bullet; }
/** * Returns an integer hash code for the receiver. Any two * objects that return <code>true</code> when passed to * <code>equals</code> must return the same value for this * method. * * @return the receiver's hash * * @see #equals(Object) */ @Override public int hashCode() { int hash = 0; if (foreground != null) hash ^= foreground.hashCode(); if (background != null) hash ^= background.hashCode(); if (font != null) hash ^= font.hashCode(); if (metrics != null) hash ^= metrics.hashCode(); if (underline) hash ^= (hash << 1); if (strikeout) hash ^= (hash << 2); hash ^= rise; if (underlineColor != null) hash ^= underlineColor.hashCode(); if (strikeoutColor != null) hash ^= strikeoutColor.hashCode(); if (borderColor != null) hash ^= borderColor.hashCode(); hash ^= underlineStyle; return hash; }
run.width = metrics.getWidthInPixels() * Math.max (1, run.glyphCount); run.ascentInPoints = metrics.ascent; run.descentInPoints = metrics.descent;
@Override public void lineGetStyle(LineStyleEvent event) { StyledText styledText = (StyledText) event.widget; // Using ST.BULLET_NUMBER sometimes results in weird alignment. // event.bulletIndex = styledText.getLineAtOffset(event.lineOffset); StyleRange styleRange = new StyleRange(); styleRange.foreground = Display.getCurrent().getSystemColor( SWT.COLOR_GRAY); 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); }
/** * Returns an integer hash code for the receiver. Any two * objects that return <code>true</code> when passed to * <code>equals</code> must return the same value for this * method. * * @return the receiver's hash * * @see #equals(Object) */ @Override public int hashCode() { int hash = 0; if (foreground != null) hash ^= foreground.hashCode(); if (background != null) hash ^= background.hashCode(); if (font != null) hash ^= font.hashCode(); if (metrics != null) hash ^= metrics.hashCode(); if (underline) hash ^= (hash << 1); if (strikeout) hash ^= (hash << 2); hash ^= rise; if (underlineColor != null) hash ^= underlineColor.hashCode(); if (strikeoutColor != null) hash ^= strikeoutColor.hashCode(); if (borderColor != null) hash ^= borderColor.hashCode(); hash ^= underlineStyle; return hash; }
void addImage(Image image) { int offset = styledText.getCaretOffset(); styledText.replaceTextRange(offset, 0, "\uFFFC"); //$NON-NLS-1$ StyleRange style = new StyleRange(); Rectangle rect = image.getBounds(); style.metrics = new GlyphMetrics(rect.height, 0, rect.width); style.data = image; int[] ranges = {offset, 1}; StyleRange[] styles = {style}; styledText.setStyleRanges(0,0, ranges, styles); }
if (!annotation.isMarkedDeleted()) { if (metrics == null) { metrics= new GlyphMetrics(0, 0, fullWidth); } else { if (metrics.width == fullWidth) { metrics= new GlyphMetrics(0, 0, fullWidth);
void addControl(Control control) { int offset = styledText.getCaretOffset(); styledText.replaceTextRange(offset, 0, "\uFFFC"); //$NON-NLS-1$ StyleRange style = new StyleRange(); Point size = control.computeSize(SWT.DEFAULT, SWT.DEFAULT); int ascent = 2 * size.y / 3; int descent = size.y - ascent; style.metrics = new GlyphMetrics(ascent + MARGIN, descent + MARGIN, size.x + 2 * MARGIN); style.data = control; int[] ranges = {offset, 1}; StyleRange[] styles = {style}; styledText.setStyleRanges(0,0, ranges, styles); control.setSize(size); }
style.metrics = new GlyphMetrics(0, 0, 30); Bullet bullet0 = new Bullet (style); problemsText.setLineBullet(0, problems.length, bullet0);
style.metrics = new GlyphMetrics(0, 0, 30); Bullet bullet0 = new Bullet (style); problemsText.setLineBullet(0, problems.length, bullet0);
style.metrics = new GlyphMetrics(0, 0, 30); Bullet bullet0 = new Bullet (style); problemsText.setLineBullet(0, problems.length, bullet0);
style.metrics = new GlyphMetrics(0, 0, 30); Bullet bullet0 = new Bullet (style); problemsText.setLineBullet(0, problems.length, bullet0);