<commit_before>package edu.berkeley.guir.prefuse.render;

import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.awt.Shape;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.geom.RectangularShape;
import java.awt.geom.RoundRectangle2D;

import edu.berkeley.guir.prefuse.VisualItem;
import edu.berkeley.guir.prefuse.util.FontLib;
import edu.berkeley.guir.prefuse.util.StringAbbreviator;

/**
 * Renders an item as a text string. The text string used by default is the
 * value of the "label" attribute. To use a different attribute, use the
 * <code>setTextAttributeName</code> method. To perform custom String
 * selection, simply subclass this Renderer and override the 
 * <code>getText</code> method.
 * 
 * @version 1.0
 * @author <a href="http://jheer.org"><NAME></a> prefuse(AT)jheer.org
 */
public class TextItemRenderer extends ShapeRenderer {

	public static final int ALIGNMENT_LEFT   = 0;
	public static final int ALIGNMENT_RIGHT  = 1;
	public static final int ALIGNMENT_CENTER = 2;
	public static final int ALIGNMENT_BOTTOM = 1;
	public static final int ALIGNMENT_TOP    = 0;

	protected String m_labelName = "label";
	protected int m_xAlign = ALIGNMENT_CENTER;
	protected int m_yAlign = ALIGNMENT_CENTER;
	protected int m_horizBorder = 3;
	protected int m_vertBorder = 0;

	protected int m_maxTextWidth = -1;
	protected int m_abbrevType = StringAbbreviator.TRUNCATE;
	protected StringAbbreviator m_abbrev = StringAbbreviator.getInstance();
	
	protected RectangularShape m_textBox  = new Rectangle2D.Float();
	protected Font m_font = new Font("SansSerif", Font.PLAIN, 10);
    
	protected Point2D     m_tmpPoint = new Point2D.Float();

	public TextItemRenderer() {
	} //

    /**
     * Sets the default font used by this Renderer. If calling getFont() on
     * a VisualItem returns a non-null value, the returned Font will be used
     * instead of this default one.
     * @param f the default font to use.
     */
	public void setFont(Font f) {
		m_font = f;
	} //
    
    /**
     * Rounds the corners of the bounding rectangle in which the text
     * string is rendered.
     * @param arcWidth the width of the curved corner
     * @param arcHeight the height of the curved corner
     */<commit_msg>Expanded javadoc comment<commit_after>package edu.berkeley.guir.prefuse.render;

import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.awt.Shape;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.geom.RectangularShape;
import java.awt.geom.RoundRectangle2D;

import edu.berkeley.guir.prefuse.VisualItem;
import edu.berkeley.guir.prefuse.util.FontLib;
import edu.berkeley.guir.prefuse.util.StringAbbreviator;

/**
 * Renders an item as a text string. The text string used by default is the
 * value of the "label" attribute. To use a different attribute, use the
 * <code>setTextAttributeName</code> method. To perform custom String
 * selection, simply subclass this Renderer and override the 
 * <code>getText</code> method.
 * 
 * @version 1.0
 * @author <a href="http://jheer.org"><NAME></a> prefuse(AT)jheer.org
 */
public class TextItemRenderer extends ShapeRenderer {

	public static final int ALIGNMENT_LEFT   = 0;
	public static final int ALIGNMENT_RIGHT  = 1;
	public static final int ALIGNMENT_CENTER = 2;
	public static final int ALIGNMENT_BOTTOM = 1;
	public static final int ALIGNMENT_TOP    = 0;

	protected String m_labelName = "label";
	protected int m_xAlign = ALIGNMENT_CENTER;
	protected int m_yAlign = ALIGNMENT_CENTER;
	protected int m_horizBorder = 3;
	protected int m_vertBorder = 0;

	protected int m_maxTextWidth = -1;
	protected int m_abbrevType = StringAbbreviator.TRUNCATE;
	protected StringAbbreviator m_abbrev = StringAbbreviator.getInstance();
	
	protected RectangularShape m_textBox  = new Rectangle2D.Float();
	protected Font m_font = FontLib.getFont("SansSerif", Font.PLAIN, 10);
    
	protected Point2D     m_tmpPoint = new Point2D.Float();

	public TextItemRenderer() {
	} //

    /**
     * Sets the default font used by this Renderer. If calling getFont() on
     * a VisualItem returns a non-null value, the returned Font will be used
     * instead of this default one.
     * @param f the default font to use. Note that this will ONLY be used when
     * if a VisualItem's getFont() method returns null.
     */
	public void setFont(Font f) {
		m_font = f;
	} //
    
    /**
     * Rounds the corners of the bounding rectangle in which the text
     * string is rendered.
     * @param arcWidth the width of the curved corner
     * @param arcHeight the height of the curved corner
     */
{'fraction_non_alphanumeric': 0.08667805294619983, 'fraction_numerical': 0.008112724167378309, 'mean_word_length': 3.8650051921079958, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5626461', 'n_tokens_mistral': 1541, 'n_tokens_neox': 1462, 'n_words': 478}