亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? styledtextrenderer.java

?? 源碼為Eclipse開源開發平臺桌面開發工具SWT的源代碼,
?? JAVA
字號:
/******************************************************************************* * Copyright (c) 2000, 2004 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html *  * Contributors: *     IBM Corporation - initial API and implementation *******************************************************************************/package org.eclipse.swt.custom;import org.eclipse.swt.SWT;import org.eclipse.swt.graphics.*;/** * A StyledTextRenderer renders the content of a StyledText widget. * Subclasses can provide a different device (e.g., Display, Printer)  * to render on and implement abstract methods to return resources  * created on that device. */abstract class StyledTextRenderer {	private Device device;					// device to render on	protected Font regularFont, boldFont, italicFont, boldItalicFont;	private int tabWidth;					// width in pixels of a tab character	private int ascent, descent;	private int lineEndSpaceWidth;			// width in pixels of the space used to represent line delimiters	/** * Creates an instance of <class>StyledTextRenderer</class>. * </p> * @param device Device to render on * @param regularFont Font to use for regular (non-bold) text * @param leftMargin margin to the left of the text */StyledTextRenderer(Device device, Font regularFont) {	this.device = device;	this.regularFont = regularFont;}/** * Calculates the line height and space width. */void calculateLineHeight() {	GC gc = getGC();	lineEndSpaceWidth = gc.stringExtent(" ").x;			// don't assume that bold and normal fonts have the same height	// fixes bug 41773	Font originalFont = gc.getFont();	FontMetrics metrics = gc.getFontMetrics();	ascent = Math.max(ascent, metrics.getAscent() + metrics.getLeading());	descent = Math.max(descent, metrics.getDescent());	gc.setFont(getFont(SWT.BOLD));	metrics = gc.getFontMetrics();	ascent = Math.max(ascent, metrics.getAscent() + metrics.getLeading());	descent = Math.max(descent, metrics.getDescent());	gc.setFont(getFont(SWT.ITALIC));	metrics = gc.getFontMetrics();	ascent = Math.max(ascent, metrics.getAscent() + metrics.getLeading());	descent = Math.max(descent, metrics.getDescent());	gc.setFont(getFont(SWT.BOLD | SWT.ITALIC));	metrics = gc.getFontMetrics();	ascent = Math.max(ascent, metrics.getAscent() + metrics.getLeading());	descent = Math.max(descent, metrics.getDescent());	gc.setFont(originalFont);	disposeGC(gc);		// clear the font cache	if (boldFont != null) boldFont.dispose();	if (italicFont != null) italicFont.dispose();	if (boldItalicFont != null) boldItalicFont.dispose();	boldFont = italicFont = boldItalicFont = null;}/** * Disposes the resource created by the receiver. */void dispose() {	if (boldFont != null) boldFont.dispose();	if (italicFont != null) italicFont.dispose();	if (boldItalicFont != null) boldItalicFont.dispose();	boldFont = italicFont = boldItalicFont = null;}/** * Dispose the specified GC. * Allows subclasses to reuse GCs. * </p> * @param gc GC to dispose. */protected abstract void disposeGC(GC gc);/**  * Draws a line of text at the specified location. * </p> * * @param line the line to draw * @param lineIndex	index of the line to draw * @param paintY y location to draw at * @param gc GC to draw on * @param widgetBackground the widget background color.  * 	Used as the default rendering color. * @param widgetForeground the widget foreground color.  * 	Used as the default rendering color.  * @param clearBackground true if the line background should be drawn * explicitly. */void drawLine(String line, int lineIndex, int paintY, GC gc, Color widgetBackground, Color widgetForeground, boolean clearBackground) {	int lineOffset = getContent().getOffsetAtLine(lineIndex);	int lineLength = line.length();	Point selection = getSelection();	int selectionStart = selection.x;	int selectionEnd = selection.y;	int leftMargin = getLeftMargin();	Color lineBackground = null;	TextLayout layout = getTextLayout(line, lineOffset);	Rectangle client = getClientArea();	StyledTextEvent event = getLineBackgroundData(lineOffset, line);	if (event != null) {		lineBackground = event.lineBackground;	}	if (lineBackground == null) {		lineBackground = widgetBackground;	}		if (clearBackground &&		(isFullLineSelection() == false || 		 selectionStart > lineOffset || 		 selectionEnd <= lineOffset + lineLength)) {		// draw background if full selection is off or if line is not 		// completely selected		gc.setBackground(lineBackground);		gc.setForeground(lineBackground);		gc.fillRectangle(client.x + leftMargin, paintY, client.width, ascent + descent);	}	int paintX = client.x + leftMargin - getHorizontalPixel();	if (selectionStart != selectionEnd) {		Rectangle rect = layout.getLineBounds(0);		drawLineBreakSelection(line, lineOffset, paintX + rect.x + rect.width, paintY, gc);	}	gc.setForeground(widgetForeground);	gc.setBackground(lineBackground);		if (selectionStart == selectionEnd || (selectionEnd <= lineOffset && selectionStart > lineOffset + lineLength - 1)) {		layout.draw(gc, paintX, paintY);	} else {		int start = Math.max(0, selectionStart - lineOffset);		int end = Math.min(lineLength, selectionEnd - lineOffset);		layout.draw(gc, paintX, paintY, start, end - 1, getSelectionForeground(), getSelectionBackground());	}	disposeTextLayout(layout);}/**  * Draws the background of the line selection. * Implemented by subclasses for optional selection rendering. * </p> * * @param line the line to draw * @param lineOffset offset of the first character in the line. * 	Relative to the start of the document. * @param styles line styles * @param paintY y location to draw at * @param gc GC to draw on * @param bidi the bidi object to use for measuring and rendering 	text in bidi * locales. null when not in bidi mode. */protected abstract void drawLineBreakSelection(String line, int lineOffset, int paintX, int paintY, GC gc);/** * Returns the visible client area that can be used for rendering. * </p> * @return the visible client area that can be used for rendering. */protected abstract Rectangle getClientArea();/** * Returns the <class>StyledTextContent</class> to use for line offset * calculations. * </p> * @return the <class>StyledTextContent</class> to use for line offset * calculations. */protected abstract StyledTextContent getContent();/** * Returns the Device that is being rendered on. * </p> * @return the Device that is being rendered on. */Device getDevice() {	return device;}int getBaseline() {	return ascent;}/** * Returns the text segments that should be treated as if they  * had a different direction than the surrounding text. * </p> * * @param lineOffset offset of the first character in the line.  * 	0 based from the beginning of the document. * @param line text of the line to specify bidi segments for * @return text segments that should be treated as if they had a * 	different direction than the surrounding text. Only the start  * 	index of a segment is specified, relative to the start of the  * 	line. Always starts with 0 and ends with the line length.  * @exception IllegalArgumentException <ul> *    <li>ERROR_INVALID_ARGUMENT - if the segment indices returned  * 		by the listener do not start with 0, are not in ascending order, * 		exceed the line length or have duplicates</li> * </ul> */protected abstract int[] getBidiSegments(int lineOffset, String lineText);/** *  Returns the Font according with the given style */Font getFont(int style) {	switch (style) {		case SWT.BOLD:			if (boldFont != null) return boldFont;			return boldFont = new Font(device, getFontData(style));		case SWT.ITALIC:			if (italicFont != null) return italicFont;			return italicFont = new Font(device, getFontData(style));		case SWT.BOLD | SWT.ITALIC:			if (boldItalicFont != null) return boldItalicFont;			return boldItalicFont = new Font(device, getFontData(style));		default:			return regularFont;	}}FontData[] getFontData(int style) {	FontData[] fontDatas = regularFont.getFontData();	for (int i = 0; i < fontDatas.length; i++) {		fontDatas[i].setStyle(style);	}	return fontDatas;}/** * Returns the GC to use for rendering and measuring. * Allows subclasses to reuse GCs. * </p> * @return the GC to use for rendering and measuring. */protected abstract GC getGC();/** * Returns the horizontal scroll position. * </p> * @return the horizontal scroll position. */protected abstract int getHorizontalPixel();protected int getLeftMargin() {	return 0;}/** * Returns the width in pixels of the space used to represent line delimiters. * @return the width in pixels of the space used to represent line delimiters. */int getLineEndSpaceWidth() {	return lineEndSpaceWidth;}/** * Returns the line background data for the given line or null if  * there is none.  * </p> * @param lineOffset offset of the line start relative to the start * 	of the content. * @param line line to get line background data for * @return line background data for the given line. may return null */protected abstract StyledTextEvent getLineBackgroundData(int lineOffset, String line);/** * Returns the height in pixels of a line. * </p> * @return the height in pixels of a line. */int getLineHeight() {	return ascent + descent;}/** * Returns the line style data for the specified line. * The lineOffset and line may specify a segment of a logical line stored * in the <class>StyledTextContent</class> of the widget. * The returned styles are guaranteed to be at least partially on the * segment. * </p> * @param event the styles for the logical line * @param lineOffset offset of the line start relative to the start of  * 	the content. * @param line line to get line styles for * @return line style data for the given line segment. Styles may start  * 	before line start and end after line end but are guaranteed to be at  * 	least partially on the line. */StyledTextEvent getLineStyleData(StyledTextEvent event, int lineOffset, String line) {	int lineLength = line.length();		if (event.styles != null && getWordWrap()) {		event.styles = getVisualLineStyleData(event.styles, lineOffset, lineLength);	}	if (event.styles == null) {		event.styles = new StyleRange[0];	}	return event;}/** * Returns the line style data for the given line or null if there is  * none. If there is a LineStyleListener but it does not set any styles,  * the StyledTextEvent.styles field will be initialized to an empty  * array. * </p> *  * @param lineOffset offset of the line start relative to the start of  * 	the content. * @param line line to get line styles for * @return line style data for the given line. Styles may start before  * 	line start and end after line end */protected abstract StyledTextEvent getLineStyleData(int lineOffset, String line);/** * */protected abstract int getOrientation ();/****/protected int getRightMargin() {	return 0;}/** * */protected abstract Color getSelectionForeground();/** * */protected abstract Color getSelectionBackground();/** * Returns the widget selection. * Implemented by subclasses for optional selection rendering. * </p> * @return the widget selection. */protected abstract Point getSelection();/** * Returns styles for the specified visual (wrapped) line. * </p> *  * @param logicalStyles the styles for a logical (unwrapped) line * @param lineOffset offset of the visual line * @param lineLength length of the visual line * @return styles in the logicalStyles array that are at least  * 	partially on the specified visual line. */StyleRange[] getVisualLineStyleData(StyleRange[] logicalStyles, int lineOffset, int lineLength) {	int lineEnd = lineOffset + lineLength;	int oldStyleCount = logicalStyles.length;	int newStyleCount = 0;		for (int i = 0; i < oldStyleCount; i++) {		StyleRange style = logicalStyles[i];		if (style.start < lineEnd && style.start + style.length > lineOffset) {			newStyleCount++;		}	}	if (newStyleCount != oldStyleCount) {		StyleRange[] newStyles = new StyleRange[newStyleCount];		for (int i = 0, j = 0; i < oldStyleCount; i++) {			StyleRange style = logicalStyles[i];			if (style.start < lineEnd && style.start + style.length > lineOffset) {				newStyles[j++] = logicalStyles[i];									}		}		logicalStyles = newStyles;	}	return logicalStyles;}/** * Returns the word wrap state. * </p> * @return true=word wrap is on. false=no word wrap, lines may extend  * 	beyond the right side of the client area. */protected abstract boolean getWordWrap();/** * Returns whether the widget was created with the SWT.FULL_SELECTION style. * Implemented by subclasses for optional selection rendering. * </p> * @return true=the widget is running in full line selection mode,  * 	false=otherwise */protected abstract boolean isFullLineSelection();/** * Calculates the width in pixel of a tab character * </p> * @param tabLength number of space characters represented by a tab character. */void setTabLength(int tabLength) {	GC gc = getGC();	StringBuffer tabBuffer = new StringBuffer(tabLength);		for (int i = 0; i < tabLength; i++) {		tabBuffer.append(' ');	}	tabWidth = gc.stringExtent(tabBuffer.toString()).x;	disposeGC(gc);}/** *  Returns TextLayout given a line index and an array of styles  */TextLayout getTextLayout(String line, int lineOffset) {	TextLayout layout = createTextLayout(lineOffset);	layout.setFont(regularFont);	layout.setAscent(ascent);	layout.setDescent(descent);	layout.setText(line);	layout.setOrientation(getOrientation());	layout.setSegments(getBidiSegments(lineOffset, line));	layout.setTabs(new int[]{tabWidth});	int length = line.length();	StyledTextEvent event = getLineStyleData(lineOffset, line);	StyleRange[] styles = event != null ? event.styles : null;	int lastOffset = 0;	if (styles != null) {		for (int styleIndex = 0; styleIndex < styles.length; styleIndex++) {			StyleRange style = styles[styleIndex];			if (style.isUnstyled()) continue;			int start, end;			if (lineOffset > style.start) {				start = 0;				end = Math.min (length, style.length - lineOffset + style.start);			} else {				start = style.start - lineOffset;				end = Math.min(length, start + style.length);			}			if (start >= length) break;			if (lastOffset != start) {				layout.setStyle(null, lastOffset, start - 1);				}			TextStyle textStyle = new TextStyle(getFont(style.fontStyle), style.foreground, style.background);			layout.setStyle(textStyle, start, end - 1);			lastOffset = end;		}	}	if (lastOffset != length) layout.setStyle(null, lastOffset, length);	return layout;}TextLayout createTextLayout(int lineOffset) {	return new TextLayout(device);}void disposeTextLayout (TextLayout layout) {	layout.dispose();}}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产在线乱码一区二区三区| 色综合天天综合给合国产| 精品一区二区免费看| 东方欧美亚洲色图在线| 欧美精品乱码久久久久久按摩| 国产三级精品三级| 国产成人精品aa毛片| 欧美日韩国产电影| 亚洲精品国产精品乱码不99| 黑人巨大精品欧美一区| 欧美久久久久免费| 亚洲精品国产品国语在线app| 风流少妇一区二区| 日韩一级二级三级| 午夜精品福利一区二区蜜股av| 9久草视频在线视频精品| 26uuu成人网一区二区三区| 亚洲第一电影网| 在线亚洲一区二区| 亚洲色图视频网| 国产不卡免费视频| 久久人人爽爽爽人久久久| 蜜臀av一区二区三区| 在线观看91av| 日本欧洲一区二区| 欧美一区在线视频| 午夜精品久久久久久久| 欧美日韩在线综合| 亚洲一二三四在线| 欧美亚洲一区三区| 亚洲大片一区二区三区| 欧美在线观看一区| 亚洲午夜三级在线| 欧美亚洲国产一区二区三区| 亚洲免费大片在线观看| 91福利精品第一导航| 亚洲蜜桃精久久久久久久| 97aⅴ精品视频一二三区| 亚洲品质自拍视频| 91黄视频在线| 亚洲第一狼人社区| 欧美一区二区性放荡片| 久久国产精品第一页| 国产亚洲精品aa午夜观看| 国产精品小仙女| 国产精品久久久久久久久免费丝袜 | 国产色婷婷亚洲99精品小说| 粉嫩绯色av一区二区在线观看| 久久蜜臀中文字幕| 99视频精品全部免费在线| 亚洲精品中文在线| 91麻豆精品国产无毒不卡在线观看| 欧美aaaaaa午夜精品| 2020国产精品| 不卡一区在线观看| 天堂久久一区二区三区| 精品国产乱码久久久久久久| 成人污污视频在线观看| 亚洲综合区在线| 日韩欧美第一区| gogo大胆日本视频一区| 亚洲成av人片一区二区三区| 久久综合视频网| 色综合一区二区| 麻豆传媒一区二区三区| 亚洲国产精品成人久久综合一区| 色妞www精品视频| 激情综合色综合久久| 最新热久久免费视频| 91精品麻豆日日躁夜夜躁| 成人永久看片免费视频天堂| 亚洲第一会所有码转帖| 国产农村妇女精品| 7777精品伊人久久久大香线蕉的| 国产成人综合视频| 日韩成人一区二区三区在线观看| 国产欧美日韩综合| 欧美久久久久免费| 91免费观看视频| 韩国av一区二区三区四区| 亚洲一二三级电影| 国产精品色在线观看| 欧美一区二区三区在线观看视频| 99久久精品费精品国产一区二区| 久久精品国产精品亚洲红杏| 亚洲一区二区三区四区在线| 久久婷婷综合激情| 91精品国产综合久久久久| 99热99精品| 国产成人精品亚洲午夜麻豆| 美国毛片一区二区三区| 午夜欧美在线一二页| 日韩毛片精品高清免费| 欧美国产综合色视频| 日韩精品影音先锋| 欧美精品久久一区| 91久久国产综合久久| 99re热视频精品| 成人av在线一区二区| 国产老肥熟一区二区三区| 麻豆一区二区三| 日本特黄久久久高潮| 亚洲综合久久久久| 18欧美乱大交hd1984| 国产精品久久久一本精品| 久久婷婷国产综合精品青草| 日韩欧美的一区二区| 欧美一区二区日韩| 欧美一区二区视频在线观看 | 一区二区三区精品| 亚洲日穴在线视频| 亚洲美女视频在线观看| 综合色天天鬼久久鬼色| √…a在线天堂一区| 国产精品嫩草99a| 国产精品美女久久久久久久网站| 国产日韩精品一区| 国产精品欧美一区喷水| 国产精品不卡一区二区三区| 中文字幕在线播放不卡一区| 亚洲同性同志一二三专区| 亚洲精品第一国产综合野| 伊人开心综合网| 亚洲第一二三四区| 日本午夜一本久久久综合| 麻豆成人免费电影| 国产成人综合视频| 97久久超碰国产精品| 在线观看免费亚洲| 欧美日本免费一区二区三区| 3d成人动漫网站| 久久亚洲欧美国产精品乐播 | 欧美精品一区二区三区高清aⅴ | 久久国产精品99久久久久久老狼| 久久国产三级精品| 国产很黄免费观看久久| 99国产精品久久久| 欧美写真视频网站| 欧美大胆人体bbbb| 国产欧美一区二区在线观看| 亚洲欧美日韩国产另类专区 | 成人的网站免费观看| 欧美丝袜丝nylons| 日韩欧美的一区| 亚洲欧美在线观看| 日本成人在线视频网站| 国产一区二区日韩精品| 91网站最新地址| 欧美一级理论性理论a| 日本一区二区三区电影| 亚洲丰满少妇videoshd| 国产精品69毛片高清亚洲| 色94色欧美sute亚洲线路一ni | 美女在线观看视频一区二区| 成人激情动漫在线观看| 69堂国产成人免费视频| 中文字幕av资源一区| 同产精品九九九| 99久久精品国产毛片| 欧美一区二区三区男人的天堂| 国产精品嫩草久久久久| 蜜桃一区二区三区四区| 日本伦理一区二区| 久久精品亚洲一区二区三区浴池| 一二三四社区欧美黄| 国产成人精品www牛牛影视| 欧美日韩国产高清一区二区三区| 中文字幕精品—区二区四季| 日韩二区三区四区| 色悠久久久久综合欧美99| xfplay精品久久| 午夜精品在线看| av成人免费在线| 久久你懂得1024| 喷水一区二区三区| 欧美性大战久久久久久久| 国产精品色婷婷久久58| 青青青爽久久午夜综合久久午夜| 97se亚洲国产综合在线| 国产亚洲欧美激情| 美国毛片一区二区三区| 91麻豆精品国产自产在线| 一区二区日韩电影| 91免费观看在线| 中文字幕在线一区| 国产成人av一区二区三区在线| 日韩欧美综合在线| 日韩电影在线免费观看| 欧美色网站导航| 亚洲图片有声小说| 欧美综合在线视频| 亚洲一区二区三区四区在线观看| 99久免费精品视频在线观看| 国产精品美日韩| 成人av在线一区二区三区| 国产精品久久久久桃色tv| 成人精品一区二区三区四区 | 日本亚洲视频在线| 91精品久久久久久久91蜜桃| 亚洲图片欧美色图|