<commit_before>//
// $Id: IsoSceneView.java,v 1.91 2002/02/06 23:14:56 mdb Exp $

package com.threerings.miso.scene;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Polygon;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.Stroke;
import java.awt.event.MouseEvent;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import com.samskivert.util.HashIntMap;
import com.samskivert.util.StringUtil;

import com.threerings.media.animation.AnimationManager;
import com.threerings.media.sprite.Path;
import com.threerings.media.sprite.SpriteManager;

import com.threerings.media.tile.ObjectTile;
import com.threerings.media.tile.ObjectTileLayer;
import com.threerings.media.tile.Tile;
import com.threerings.media.tile.TileLayer;

import com.threerings.miso.Log;
import com.threerings.miso.scene.DirtyItemList.DirtyItem;
import com.threerings.miso.scene.util.AStarPathUtil;
import com.threerings.miso.scene.util.IsoUtil;
import com.threerings.miso.tile.BaseTileLayer;

/**
 * The iso scene view provides an isometric view of a particular
 * scene.
 */
public class IsoSceneView implements SceneView
{
    /** Instructs the scene view never to draw highlights around object
     * tiles. */
    public static final int HIGHLIGHT_NEVER = 0;

    /** Instructs the scene view to highlight only object tiles that have
     * a non-empty action string. */
    public static final int HIGHLIGHT_WITH_ACTION = 1;

    /** Instructs the scene view to highlight every object tile,
     * regardless of whether it has a valid action string. */
    public static final int HIGHLIGHT_ALWAYS = 2;

    /** Instructs the scene view to highlight whatever tile the mouse is
     * over, regardless of whether or not it is an object tile. This is
     * generally only useful in an editor rather than a game. */
    public static final int HIGHLIGHT_ALL = 3;

    /**
     * Constructs an iso scene view.
     *
     * @param animmgr the animation manager.
     * @param spritemgr the sprite manager.
     * @param model the data model.
     */
    public IsoSceneView (AnimationManager animmgr, SpriteManager spritemgr,
                         IsoSceneViewModel model)
    {
        // save off references
        _animmgr = animmgr;
        _spritemgr = spritemgr;
        _model = model;

        // give the model a chance to pre-calculate various things
        _model.precalculate();

        // create our polygon arrays and create polygons for each of the
        // tiles. we use these repeatedly, so we go ahead and make 'em all
        // up front
        _polys = new Polygon[model.scenewid][model.scenehei];
	for (int xx = 0; xx < model.scenewid; xx++) {
	    for (int yy = 0; yy < model.scenehei; yy++) {
		_polys[xx][yy] = IsoUtil.getTilePolygon(_model, xx, yy);
	    }
	}

        // create the array used to mark dirty tiles
        _dirty = new boolean[model.scenewid][model.tilehei];
    }

    /**
     * Configures the scene view to highlight object tiles either never
     * ({@link #HIGHLIGHT_NEVER}), only when an object tile has an
     * associated action string ({@link #HIGHLIGHT_WITH_ACTION}), or
     * always ({@link #HIGHLIGHT_ALWAYS}). It is also possible to
     * configure the view to highlight whatever tile is under the cursor,
     * even if it's not an object tile which is done in the {@link
     * #HIGHLIGHT_ALL} mode.
     */
    public void setHighlightMode (int hmode)
    {
        _hmode = hmode;
    }

    /**
     * Returns a reference to the scene being displayed by this view.
     */
    public DisplayMisoScene getScene ()
    {
        return _scene;
    }

    // documentation inherited
    public void setScene (DisplayMisoScene scene)
    {
        _scene = scene;

        // clear all dirty lists and tile array
	clearDirtyRegions();

        // generate all object tile polygons
        initAllObjectBounds();

        // invalidate the entire screen as there's a new scene in town
        invalidate();
    }

    // documentation inherited
    public void paint (Graphics g)
    {
	if (_scene == null) {
            Log.warning("Scene view painted with null scene.");
            return;
        }

	Graphics2D gfx = (Graphics2D)g;

	// clip everything to the overall scene view bounds
    	Shape oldclip = gfx.getClip();
    	gfx.setClip(_model.bounds);

	if (_numDirty == 0) {
            // invalidate the entire screen
            invalidate();
	}

        // render the scene to the graphics context
        renderScene(gfx);

        // render any animations
        _animmgr.renderAnimations(gfx);

        // draw frames of dirty tiles and rectangles
        // drawDirtyRegions(gfx);

        // draw tile coordinates
        if (_model.showCoords) {
            paintCoordinates(gfx);
        }

        // clear out the dirty tiles and rectangles
        clearDirtyRegions();

	// draw sprite paths
	if (_model.showPaths) {
	    _spritemgr.renderSpritePaths(gfx);
	}

        // paint our highlighted tile (if any)
        paintHighlights(gfx);

        // paint any extra goodies
	paintExtras(gfx);

	// restore the original clipping region
	gfx.setClip(oldclip);
    }
<commit_msg>Removed the code that was setting the clip as it wasn't actually doing anything. The clip is already properly set before render() is called.<commit_after>//
// $Id: IsoSceneView.java,v 1.92 2002/02/12 08:54:49 mdb Exp $

package com.threerings.miso.scene;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Polygon;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.Stroke;
import java.awt.event.MouseEvent;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import com.samskivert.util.HashIntMap;
import com.samskivert.util.StringUtil;

import com.threerings.media.animation.AnimationManager;
import com.threerings.media.sprite.Path;
import com.threerings.media.sprite.SpriteManager;

import com.threerings.media.tile.ObjectTile;
import com.threerings.media.tile.ObjectTileLayer;
import com.threerings.media.tile.Tile;
import com.threerings.media.tile.TileLayer;

import com.threerings.miso.Log;
import com.threerings.miso.scene.DirtyItemList.DirtyItem;
import com.threerings.miso.scene.util.AStarPathUtil;
import com.threerings.miso.scene.util.IsoUtil;
import com.threerings.miso.tile.BaseTileLayer;

/**
 * The iso scene view provides an isometric view of a particular
 * scene.
 */
public class IsoSceneView implements SceneView
{
    /** Instructs the scene view never to draw highlights around object
     * tiles. */
    public static final int HIGHLIGHT_NEVER = 0;

    /** Instructs the scene view to highlight only object tiles that have
     * a non-empty action string. */
    public static final int HIGHLIGHT_WITH_ACTION = 1;

    /** Instructs the scene view to highlight every object tile,
     * regardless of whether it has a valid action string. */
    public static final int HIGHLIGHT_ALWAYS = 2;

    /** Instructs the scene view to highlight whatever tile the mouse is
     * over, regardless of whether or not it is an object tile. This is
     * generally only useful in an editor rather than a game. */
    public static final int HIGHLIGHT_ALL = 3;

    /**
     * Constructs an iso scene view.
     *
     * @param animmgr the animation manager.
     * @param spritemgr the sprite manager.
     * @param model the data model.
     */
    public IsoSceneView (AnimationManager animmgr, SpriteManager spritemgr,
                         IsoSceneViewModel model)
    {
        // save off references
        _animmgr = animmgr;
        _spritemgr = spritemgr;
        _model = model;

        // give the model a chance to pre-calculate various things
        _model.precalculate();

        // create our polygon arrays and create polygons for each of the
        // tiles. we use these repeatedly, so we go ahead and make 'em all
        // up front
        _polys = new Polygon[model.scenewid][model.scenehei];
	for (int xx = 0; xx < model.scenewid; xx++) {
	    for (int yy = 0; yy < model.scenehei; yy++) {
		_polys[xx][yy] = IsoUtil.getTilePolygon(_model, xx, yy);
	    }
	}

        // create the array used to mark dirty tiles
        _dirty = new boolean[model.scenewid][model.tilehei];
    }

    /**
     * Configures the scene view to highlight object tiles either never
     * ({@link #HIGHLIGHT_NEVER}), only when an object tile has an
     * associated action string ({@link #HIGHLIGHT_WITH_ACTION}), or
     * always ({@link #HIGHLIGHT_ALWAYS}). It is also possible to
     * configure the view to highlight whatever tile is under the cursor,
     * even if it's not an object tile which is done in the {@link
     * #HIGHLIGHT_ALL} mode.
     */
    public void setHighlightMode (int hmode)
    {
        _hmode = hmode;
    }

    /**
     * Returns a reference to the scene being displayed by this view.
     */
    public DisplayMisoScene getScene ()
    {
        return _scene;
    }

    // documentation inherited
    public void setScene (DisplayMisoScene scene)
    {
        _scene = scene;

        // clear all dirty lists and tile array
	clearDirtyRegions();

        // generate all object tile polygons
        initAllObjectBounds();

        // invalidate the entire screen as there's a new scene in town
        invalidate();
    }

    // documentation inherited
    public void paint (Graphics g)
    {
	if (_scene == null) {
            Log.warning("Scene view painted with null scene.");
            return;
        }

	Graphics2D gfx = (Graphics2D)g;

	if (_numDirty == 0) {
            // invalidate the entire screen
            invalidate();
	}

        // render the scene to the graphics context
        renderScene(gfx);

        // render any animations
        _animmgr.renderAnimations(gfx);

        // draw frames of dirty tiles and rectangles
        // drawDirtyRegions(gfx);

        // draw tile coordinates
        if (_model.showCoords) {
            paintCoordinates(gfx);
        }

        // clear out the dirty tiles and rectangles
        clearDirtyRegions();

	// draw sprite paths
	if (_model.showPaths) {
	    _spritemgr.renderSpritePaths(gfx);
	}

        // paint our highlighted tile (if any)
        paintHighlights(gfx);

        // paint any extra goodies
	paintExtras(gfx);
    }

{'fraction_non_alphanumeric': 0.08860998395772389, 'fraction_numerical': 0.005095781825044824, 'mean_word_length': 2.6369251887439944, 'pattern_counts': {'":': 0, '<': 7, '<?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': '9273', 'n_tokens_mistral': 3256, 'n_tokens_neox': 3154, 'n_words': 1019}