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


Java Utilities.drawTabbedText方法代码示例

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


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

示例1: testNPE

import javax.swing.text.Utilities; //导入方法依赖的package包/类
private static void testNPE() {

        Graphics g = null;
        try {
            String test = "\ttest\ttest2";
            BufferedImage buffImage = new BufferedImage(
                    100, 100, BufferedImage.TYPE_INT_RGB);
            g = buffImage.createGraphics();
            Segment segment = new Segment(test.toCharArray(), 0, test.length());
            Utilities.drawTabbedText(segment, 0, 0, g, null, 0);
        } finally {
            if (g != null) {
                g.dispose();
            }
        }
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:bug8134721.java

示例2: paintPlainLine

import javax.swing.text.Utilities; //导入方法依赖的package包/类
protected void paintPlainLine(Graphics gfx, int line, Font defaultFont,
	Color defaultColor, int x, int y)
{
	paintHighlight(gfx,line,y);
	textArea.getLineText(line,currentLine);

	gfx.setFont(defaultFont);
	gfx.setColor(defaultColor);

	y += fm.getHeight();
	x = Utilities.drawTabbedText(currentLine,x,y,gfx,this,0);

	if(eolMarkers)
	{
		gfx.setColor(eolMarkerColor);
		gfx.drawString(".",x,y);
	}
}
 
开发者ID:nativelibs4java,项目名称:JNAerator,代码行数:19,代码来源:TextAreaPainter.java

示例3: drawTabbedText

import javax.swing.text.Utilities; //导入方法依赖的package包/类
public static int drawTabbedText(Segment segment, int x, int y, Graphics g, TabExpander e, int startOffset){
    
    List<Segment> segments=new ArrayList<Segment>();
    List<Boolean> unis=new ArrayList<Boolean>();
    getSegments(g.getFont(), segment, segments, unis);
    Font origFont=g.getFont();
    Font uniFont = defaultUniFont.deriveFont(origFont.getStyle(),origFont.getSize2D());
    int ret=x;
    int pos=0;
    for(int i=0;i<segments.size();i++){
        Segment seg=segments.get(i);
        if(unis.get(i)){
            g.setFont(uniFont);
        }else{
            g.setFont(origFont);
        }
        ret = Utilities.drawTabbedText(seg, ret, y, g, e, startOffset+pos);   
        pos += seg.length();
    }
    g.setFont(origFont);
    return ret;         
}
 
开发者ID:jindrapetrik,项目名称:jpexs-decompiler,代码行数:23,代码来源:UniTools.java

示例4: drawText

import javax.swing.text.Utilities; //导入方法依赖的package包/类
/**
 * Draw text. This can directly call the Utilities.drawTabbedText.
 * Sub-classes can override this method to provide any other decorations.
 * 
 * @param  segment - the source of the text
 * @param  x - the X origin >= 0
 * @param  y - the Y origin >= 0
 * @param  graphics - the graphics context
 * @param e - how to expand the tabs. If this value is null, tabs will be 
 * expanded as a space character.
 * @param startOffset - starting offset of the text in the document >= 0 
 * @return
 */
public int drawText(Segment segment, int x, int y,
        Graphics graphics, TabExpander e, int startOffset) {
    graphics.setFont(graphics.getFont().deriveFont(getFontStyle()));
    FontMetrics fontMetrics = graphics.getFontMetrics();
    int a = fontMetrics.getAscent();
    int h = a + fontMetrics.getDescent();
    int w = Utilities.getTabbedTextWidth(segment, fontMetrics, 0, e, startOffset);
    int rX = x - 1;
    int rY = y - a;
    int rW = w + 2;
    int rH = h;
    if ((getFontStyle() & 0x10) != 0) {
        graphics.setColor(Color.decode("#EEEEEE"));
        graphics.fillRect(rX, rY, rW, rH);
    }
    graphics.setColor(getColor());
    x = Utilities.drawTabbedText(segment, x, y, graphics, e, startOffset);
    if ((getFontStyle() & 0x8) != 0) {
        graphics.setColor(Color.RED);
        graphics.drawRect(rX, rY, rW, rH);
    }
    
    return x;
}
 
开发者ID:nextreports,项目名称:nextreports-designer,代码行数:38,代码来源:SyntaxStyle.java

示例5: drawText

import javax.swing.text.Utilities; //导入方法依赖的package包/类
private int drawText(Graphics g,
                     int x, int y,
                     int startOffset, int endOffset,
                     boolean error,
                     boolean selected,
                     DocElement docElem) throws BadLocationException {
    Segment s = EventQueue.isDispatchThread() ? SEGMENT : new Segment(); 
    s.array = docElem.getChars();
    s.offset = startOffset - docElem.offset;
    s.count = endOffset - startOffset;

    g.setColor(getColor(error, selected));

    return Utilities.drawTabbedText(s, x, y, g, this, startOffset);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:OutputView.java

示例6: paintSyntaxLine

import javax.swing.text.Utilities; //导入方法依赖的package包/类
/**
 * Paints the specified line onto the graphics context. Note that this method munges the offset
 * and count values of the segment.
 * 
 * @param line
 *            The line segment
 * @param tokens
 *            The token list for the line
 * @param styles
 *            The syntax style list
 * @param expander
 *            The tab expander used to determine tab stops. May be null
 * @param gfx
 *            The graphics context
 * @param x
 *            The x co-ordinate
 * @param y
 *            The y co-ordinate
 * @return The x co-ordinate, plus the width of the painted string
 */
public static int paintSyntaxLine(Segment line, Token tokens, SyntaxStyle[] styles, TabExpander expander, Graphics gfx,
		int x, int y) {
	Font defaultFont = gfx.getFont();
	Color defaultColor = gfx.getColor();

	int offset = 0;
	for (;;) {
		byte id = tokens.id;
		if (id == Token.END) {
			break;
		}

		int length = tokens.length;
		if (id == Token.NULL) {
			if (!defaultColor.equals(gfx.getColor())) {
				gfx.setColor(defaultColor);
			}
			if (!defaultFont.equals(gfx.getFont())) {
				gfx.setFont(defaultFont);
			}
		} else {
			styles[id].setGraphicsFlags(gfx, defaultFont);
		}

		line.count = length;
		x = Utilities.drawTabbedText(line, x, y, gfx, expander, 0);
		line.offset += length;
		offset += length;

		tokens = tokens.next;
	}

	return x;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:55,代码来源:SyntaxUtilities.java

示例7: paintPlainLine

import javax.swing.text.Utilities; //导入方法依赖的package包/类
protected void paintPlainLine(Graphics gfx, int line, Font defaultFont, Color defaultColor, int x, int y) {
	paintHighlight(gfx, line, y);
	textArea.getLineText(line, currentLine);

	gfx.setFont(defaultFont);
	gfx.setColor(defaultColor);

	y += fm.getHeight();
	x = Utilities.drawTabbedText(currentLine, x, y, gfx, this, 0);

	if (eolMarkers) {
		gfx.setColor(eolMarkerColor);
		gfx.drawString(".", x, y);
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:16,代码来源:TextAreaPainter.java

示例8: drawColoredText

import javax.swing.text.Utilities; //导入方法依赖的package包/类
private int drawColoredText(Graphics g, int x, int y, TabExpander ex, Document doc,
                            int p0, int p1, Element elem) throws BadLocationException {
  final Segment s = new Segment();
  doc.getText(p0, p1 - p0, s);
  g.setColor(getColor(elem));

  final Graphics2D g2d = (Graphics2D) g;
  g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                       RenderingHints.VALUE_ANTIALIAS_ON);
  return Utilities.drawTabbedText(s, x, y, g, ex, p0);
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:12,代码来源:Chatter.java

示例9: paintSyntaxLine

import javax.swing.text.Utilities; //导入方法依赖的package包/类
/**
 * Paints the specified line onto the graphics context. Note that this method munges the offset
 * and count values of the segment.
 * 
 * @param line
 *            The line segment
 * @param tokens
 *            The token list for the line
 * @param styles
 *            The syntax style list
 * @param expander
 *            The tab expander used to determine tab stops. May be null
 * @param gfx
 *            The graphics context
 * @param x
 *            The x co-ordinate
 * @param y
 *            The y co-ordinate
 * @return The x co-ordinate, plus the width of the painted string
 */
public static int paintSyntaxLine(Segment line, Token tokens, SyntaxStyle[] styles, TabExpander expander, Graphics gfx,
		int x, int y) {
	Font defaultFont = gfx.getFont();
	Color defaultColor = gfx.getColor();

	for (;;) {
		byte id = tokens.id;
		if (id == Token.END) {
			break;
		}

		int length = tokens.length;
		if (id == Token.NULL) {
			if (!defaultColor.equals(gfx.getColor())) {
				gfx.setColor(defaultColor);
			}
			if (!defaultFont.equals(gfx.getFont())) {
				gfx.setFont(defaultFont);
			}
		} else {
			styles[id].setGraphicsFlags(gfx, defaultFont);
		}

		line.count = length;
		x = Utilities.drawTabbedText(line, x, y, gfx, expander, 0);
		line.offset += length;

		tokens = tokens.next;
	}

	return x;
}
 
开发者ID:rapidminer,项目名称:rapidminer-studio,代码行数:53,代码来源:SyntaxUtilities.java

示例10: paintSyntaxLine

import javax.swing.text.Utilities; //导入方法依赖的package包/类
/**
 * Paints the specified line onto the graphics context. Note that this
 * method munges the offset and count values of the segment.
 * @param line The line segment
 * @param tokens The token list for the line
 * @param styles The syntax style list
 * @param expander The tab expander used to determine tab stops. May
 * be null
 * @param gfx The graphics context
 * @param x The x co-ordinate
 * @param y The y co-ordinate
 * @return The x co-ordinate, plus the width of the painted string
 */
public static int paintSyntaxLine(Segment line, Token tokens,
	SyntaxStyle[] styles, TabExpander expander, Graphics gfx,
	int x, int y)
{
	Font defaultFont = gfx.getFont();
	Color defaultColor = gfx.getColor();

	int offset = 0;
	for(;;)
	{
		byte id = tokens.id;
		if(id == Token.END)
			break;

		int length = tokens.length;
		if(id == Token.NULL)
		{
			if(!defaultColor.equals(gfx.getColor()))
				gfx.setColor(defaultColor);
			if(!defaultFont.equals(gfx.getFont()))
				gfx.setFont(defaultFont);
		}
		else
			styles[id].setGraphicsFlags(gfx,defaultFont);

		line.count = length;
		x = Utilities.drawTabbedText(line,x,y,gfx,expander,0);
		line.offset += length;
		offset += length;

		tokens = tokens.next;
	}

	return x;
}
 
开发者ID:nativelibs4java,项目名称:JNAerator,代码行数:49,代码来源:SyntaxUtilities.java

示例11: drawUnselectedText

import javax.swing.text.Utilities; //导入方法依赖的package包/类
protected int drawUnselectedText(Graphics g, int x, int y,int p0, int p1) throws BadLocationException
{
	int stLine = p0;// findStartOfLine(p0, getDocument());
	int enLine = p1;// findEndOfLine(p1-1, getDocument());

	if (g instanceof Graphics2D) {
		Graphics2D g2d = (Graphics2D)g;
		g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
	}
       
	// x+= getLeftInset();
	// System.out.println("p0 = "+p0+", p1 = "+p1+", st = "+stLine+",
	// enLine = "+enLine+".");
	try
	{
		g.setColor(Color.green);
		Document doc = getDocument();
		// Segment segment = getLineBuffer();

		// System.out.println(doc.getText(p0, p1-p0));
		// String s = doc.getText(p0, p1-p0);
		String s = doc.getText(stLine, enLine-stLine);
		// System.out.println("------");
		// System.out.println("highlighting unselected string = \n"+s);
		// System.out.println("------");

		Style[] styles = highlight(s, (p0-stLine), (p1-p0));
		int currStart = 0;
		int currEnd = 0;
		Color last = null;
		String fname = handler.getPrismEditorFontFast().getName();
		int fsize = handler.getPrismEditorFontFast().getSize();

		for(int curr = 0; curr < styles.length; curr++)
		{

			Style c = styles[curr];

			g.setColor(c.c);
			g.setFont(new Font(fname, c.style, fsize));
			Segment segm = new Segment();// getLineBuffer();
			doc.getText(p0+curr, 1, segm);
			x = Utilities.drawTabbedText(segm, x, y, g, this, p0+curr);

		}
		g.setColor(Color.black);
		g.setFont(new Font(fname, Font.PLAIN, fsize));
	}
	catch(BadLocationException ex)
	{
		ex.printStackTrace();
	}
	return x;
}
 
开发者ID:musaeed,项目名称:Prism-gsoc16,代码行数:55,代码来源:PrismEditorKit.java

示例12: drawSelectedText

import javax.swing.text.Utilities; //导入方法依赖的package包/类
protected int drawSelectedText(Graphics g, int x, int y,int p0, int p1) throws BadLocationException
{
	int stLine = p0;// findStartOfLine(p0, getDocument());
	int enLine = p1;// findEndOfLine(p1-1, getDocument());

	if (g instanceof Graphics2D) {
		Graphics2D g2d = (Graphics2D)g;
		g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
	}
       
	// x+= getLeftInset();
	// System.out.println("p0 = "+p0+", p1 = "+p1+", st = "+stLine+",
	// enLine = "+enLine+".");
	try
	{
		g.setColor(Color.green);
		Document doc = getDocument();
		// Segment segment = getLineBuffer();


		// String s = doc.getText(p0, p1-p0);
		// System.out.println(doc.getText(p0, p1-p0));


		String s = doc.getText(stLine, enLine-stLine);
		// System.out.println("------");
		// System.out.println("highlighting selected string = \n"+s);
		// System.out.println("------");
		Style[] styles = highlight(s, (p0-stLine), (p1-p0));
		int currStart = 0;
		int currEnd = 0;
		Color last = null;
		String fname = handler.getPrismEditorFontFast().getName();
		int fsize = handler.getPrismEditorFontFast().getSize();

		for(int curr = 0; curr < styles.length; curr++)
		{

			Style c = styles[curr];

			g.setColor(c.c);
			g.setFont(new Font(fname, c.style, fsize));
			Segment segm = new Segment();// getLineBuffer();
			doc.getText(p0+curr, 1, segm);
			x = Utilities.drawTabbedText(segm, x, y, g, this, p0+curr);

		}
		g.setColor(Color.black);
		g.setFont(new Font(fname, Font.PLAIN, fsize));
	}
	catch(BadLocationException ex)
	{
		ex.printStackTrace();
	}
	return x;
}
 
开发者ID:musaeed,项目名称:Prism-gsoc16,代码行数:57,代码来源:PrismEditorKit.java

示例13: drawUnselectedText

import javax.swing.text.Utilities; //导入方法依赖的package包/类
protected int drawUnselectedText(Graphics g, int x, int y, int p0, int p1) throws BadLocationException
{
	int stLine = findStartOfLine(p0, getDocument());
	int enLine = findEndOfLine(p1, getDocument());

	if (g instanceof Graphics2D) {
		Graphics2D g2d = (Graphics2D)g;
		g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
	}
       
	try
	{
		g.setColor(Color.green);
		Document doc = getDocument();
		Segment segment = getLineBuffer();
		
		
		//String s = doc.getText(p0, p1-p0);
		String s = doc.getText(stLine, enLine-stLine);
		userinterface.model.Style[] styles = highlight(s, (p0-stLine), (p1-p0));
		int currStart = 0;
		int currEnd = 0;
		Color last = null;
		String fname = handler.getPepaEditorFontFast().getName();
		int fsize = handler.getPepaEditorFontFast().getSize();
		
		for(int curr = 0; curr < styles.length; curr++)
		{
			
			userinterface.model.Style c = styles[curr];
			
			g.setColor(c.c);
			g.setFont(new Font(fname, c.style, fsize));
			Segment segm = getLineBuffer();
			doc.getText(p0+curr, 1, segm);
			x = Utilities.drawTabbedText(segm, x, y, g, this, p0+curr);
			
		}
		g.setColor(Color.black);
		g.setFont(new Font(fname, Font.PLAIN, fsize));
	}
	catch(BadLocationException ex)
	{
		//System.out.println("ex = "+ex);
		//ex.printStackTrace();
	}
	return x;
}
 
开发者ID:musaeed,项目名称:Prism-gsoc16,代码行数:49,代码来源:PepaEditorKit.java

示例14: drawSelectedText

import javax.swing.text.Utilities; //导入方法依赖的package包/类
protected int drawSelectedText(Graphics g, int x, int y, int p0, int p1) throws BadLocationException
{
	int stLine = findStartOfLine(p0, getDocument());
	int enLine = findEndOfLine(p1, getDocument());

	if (g instanceof Graphics2D) {
		Graphics2D g2d = (Graphics2D)g;
		g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
	}
       
	try
	{
		g.setColor(Color.green);
		Document doc = getDocument();
		Segment segment = getLineBuffer();
		
		
		//String s = doc.getText(p0, p1-p0);
		String s = doc.getText(stLine, enLine-stLine);
		userinterface.model.Style[] styles = highlight(s, (p0-stLine), (p1-p0));
		int currStart = 0;
		int currEnd = 0;
		Color last = null;
		String fname = handler.getPepaEditorFontFast().getName();
		int fsize = handler.getPepaEditorFontFast().getSize();
		
		for(int curr = 0; curr < styles.length; curr++)
		{
			
			userinterface.model.Style c = styles[curr];
			
			g.setColor(c.c);
			g.setFont(new Font(fname, c.style, fsize));
			Segment segm = getLineBuffer();
			doc.getText(p0+curr, 1, segm);
			x = Utilities.drawTabbedText(segm, x, y, g, this, p0+curr);
			
		}
		g.setColor(Color.black);
		g.setFont(new Font(fname, Font.PLAIN, fsize));
	}
	catch(BadLocationException ex)
	{
		//System.out.println("ex = "+ex);
		//ex.printStackTrace();
	}
	return x;
}
 
开发者ID:musaeed,项目名称:Prism-gsoc16,代码行数:49,代码来源:PepaEditorKit.java

示例15: drawUnselectedText

import javax.swing.text.Utilities; //导入方法依赖的package包/类
@Override
protected int drawUnselectedText(Graphics graphics, int x, int y, int p0, int p1) throws BadLocationException {
	addRenderingHints(graphics);
	
	Document doc = getDocument();
	String text = doc.getText(p0, p1 - p0);
	
	
	Segment segment = getLineBuffer();
	
	SortedMap<Integer, Integer> searchStartMap = new TreeMap<Integer, Integer>();
	SortedMap<Integer, Integer> startMap = new TreeMap<Integer, Integer>();
	SortedMap<Integer, Color> colorMap = new TreeMap<Integer, Color>();
	
	
	processText(text, patternColors, searchStartMap, startMap, colorMap);
	
	int i = 0;
	// Colour the parts
	for (Map.Entry<Integer, Integer> entry : startMap.entrySet()) {
		
		int start = entry.getKey();
		int end = entry.getValue();
		
		if (i < start) {
			graphics.setColor(Color.black);
			doc.getText(p0 + i, start - i, segment);
			x = Utilities.drawTabbedText(segment, x, y, graphics, this, i);
		}
		
		graphics.setColor(colorMap.get(start));
		i = end;
		doc.getText(p0 + start, i - start, segment);
		drawHighlightedWord(searchStartMap, segment, start, x, y, graphics);
		x = Utilities.drawTabbedText(segment, x, y, graphics, this, start);
	}
	
	// Paint possible remaining text black
	if (i < text.length()) {
		graphics.setColor(Color.black);
		doc.getText(p0 + i, text.length() - i, segment);
		x = Utilities.drawTabbedText(segment, x, y, graphics, this, i);
	}
	
	return x;
}
 
开发者ID:Emd4600,项目名称:SporeModder,代码行数:47,代码来源:XmlView.java


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