<commit_before>//
// $Id: SpriteIcon.java,v 1.4 2002/11/05 03:40:06 mdb Exp $

package com.threerings.media.sprite;

import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;

import javax.swing.Icon;

/**
 * Implements the icon interface, using a {@link Sprite} to render the
 * icon image.
 */
public class SpriteIcon implements Icon
{
    /**
     * Creates a sprite icon that will use the supplied sprite to render
     * itself. This sprite should not be used for anything else while
     * being used in this icon because it will be "moved" when the icon is
     * rendered. The sprite's origin will be set to the bottom center of
     * the label. If this is undesirable, the origin can be offset via
     * {@link #setOriginOffset}.
     */
    public SpriteIcon (Sprite sprite)
    {
        this(sprite, 0);
    }

    /**
     * Creates a sprite icon that will use the supplied sprite to render
     * itself. This sprite should not be used for anything else while
     * being used in this icon because it will be "moved" when the icon is
     * rendered. The sprite's origin will be set to the bottom center of
     * the label. If this is undesirable, the origin can be offset via
     * {@link #setOriginOffset}.
     *
     * @param sprite the sprite to render in this label.
     * @param padding the number of pixels of blank space to put on all
     * four sides of the sprite.
     */
    public SpriteIcon (Sprite sprite, int padding)
    {
        _sprite = sprite;
        _padding = padding;
    }

    // documentation inherited from interface
    public void paintIcon (Component c, Graphics g, int x, int y)
    {
        // move the sprite to a "location" that results in its image being
        // in the upper left of the rectangle we desire
        _sprite.setLocation(x + _sprite.getXOffset() + _padding,
                            y + _sprite.getYOffset() + _padding);
        _sprite.paint((Graphics2D)g);
    }
    
    // documentation inherited from interface
    public int getIconWidth ()
    {
        return _sprite.getWidth() + 2*_padding;
    }

    // documentation inherited from interface
    public int getIconHeight ()
    {
        return _sprite.getHeight() + 2*_padding;
    }
<commit_msg>Have to tick() a sprite before painting it since we're using it outside its normal media panel happy place.<commit_after>//
// $Id: SpriteIcon.java,v 1.5 2003/01/18 03:13:32 mdb Exp $

package com.threerings.media.sprite;

import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;

import javax.swing.Icon;

/**
 * Implements the icon interface, using a {@link Sprite} to render the
 * icon image.
 */
public class SpriteIcon implements Icon
{
    /**
     * Creates a sprite icon that will use the supplied sprite to render
     * itself. This sprite should not be used for anything else while
     * being used in this icon because it will be "moved" when the icon is
     * rendered. The sprite's origin will be set to the bottom center of
     * the label. If this is undesirable, the origin can be offset via
     * {@link #setOriginOffset}.
     */
    public SpriteIcon (Sprite sprite)
    {
        this(sprite, 0);
    }

    /**
     * Creates a sprite icon that will use the supplied sprite to render
     * itself. This sprite should not be used for anything else while
     * being used in this icon because it will be "moved" when the icon is
     * rendered. The sprite's origin will be set to the bottom center of
     * the label. If this is undesirable, the origin can be offset via
     * {@link #setOriginOffset}.
     *
     * @param sprite the sprite to render in this label.
     * @param padding the number of pixels of blank space to put on all
     * four sides of the sprite.
     */
    public SpriteIcon (Sprite sprite, int padding)
    {
        _sprite = sprite;
        // the sprite should be ticked once so that we can safely paint it
        _sprite.tick(System.currentTimeMillis());
        _padding = padding;
    }

    // documentation inherited from interface
    public void paintIcon (Component c, Graphics g, int x, int y)
    {
        // move the sprite to a "location" that results in its image being
        // in the upper left of the rectangle we desire
        _sprite.setLocation(x + _sprite.getXOffset() + _padding,
                            y + _sprite.getYOffset() + _padding);
        _sprite.paint((Graphics2D)g);
    }
    
    // documentation inherited from interface
    public int getIconWidth ()
    {
        return _sprite.getWidth() + 2*_padding;
    }

    // documentation inherited from interface
    public int getIconHeight ()
    {
        return _sprite.getHeight() + 2*_padding;
    }

{'fraction_non_alphanumeric': 0.07731198651780072, 'fraction_numerical': 0.008847693279966295, 'mean_word_length': 2.468224981738495, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6715243', 'n_tokens_mistral': 1377, 'n_tokens_neox': 1300, 'n_words': 568}