<commit_before>package hu.kazocsaba.imageviewer;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.Rectangle;
import javax.swing.JComponent;
import javax.swing.JLayeredPane;
import javax.swing.JViewport;
import javax.swing.OverlayLayout;
import javax.swing.Scrollable;

/**
 * A component showing an image as well as an arbitrary number of overlays.
 * @author <NAME>
 */
class LayeredImageView  {
	private final ImageComponent theImage;
	private final JLayeredPane layeredPane;
	
	public LayeredImageView(ImageComponent theImage) {
		this.theImage = theImage;
		layeredPane=new ScrollableLayeredPane();
		layeredPane.setLayout(new OverlayLayout(layeredPane));
		layeredPane.add(theImage, Integer.valueOf(0));
	}
	/**
	 * Returns the component for this layered view.
	 * @return the Swing component for this view
	 */
	public JComponent getComponent() {return layeredPane;}
	
	/**
	 * Adds an overlay as the specified layer.
	 * @param overlay the overlay to add
	 * @param layer the layer to add the overlay to; higher layers are on top of lower layers;
	 * the image resides in layer 0
	 */
	public void addOverlay(Overlay overlay, int layer) {
		if (overlay==null) throw new NullPointerException();
		OverlayComponent c=new OverlayComponent(overlay, theImage);
		overlay.addOverlayComponent(c);
		layeredPane.add(c, Integer.valueOf(layer));
		layeredPane.revalidate();
		layeredPane.repaint();
	}<commit_msg>Enable scrolling to be optimized by setting the component to opaque.<commit_after>package hu.kazocsaba.imageviewer;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.Rectangle;
import javax.swing.JComponent;
import javax.swing.JLayeredPane;
import javax.swing.JViewport;
import javax.swing.OverlayLayout;
import javax.swing.Scrollable;

/**
 * A component showing an image as well as an arbitrary number of overlays.
 * @author <NAME>
 */
class LayeredImageView  {
	private final ImageComponent theImage;
	private final JLayeredPane layeredPane;
	
	public LayeredImageView(ImageComponent theImage) {
		this.theImage = theImage;
		layeredPane=new ScrollableLayeredPane();
		layeredPane.setLayout(new OverlayLayout(layeredPane));
		layeredPane.add(theImage, Integer.valueOf(0));
		layeredPane.setOpaque(true);
	}
	/**
	 * Returns the component for this layered view.
	 * @return the Swing component for this view
	 */
	public JComponent getComponent() {return layeredPane;}
	
	/**
	 * Adds an overlay as the specified layer.
	 * @param overlay the overlay to add
	 * @param layer the layer to add the overlay to; higher layers are on top of lower layers;
	 * the image resides in layer 0
	 */
	public void addOverlay(Overlay overlay, int layer) {
		if (overlay==null) throw new NullPointerException();
		OverlayComponent c=new OverlayComponent(overlay, theImage);
		overlay.addOverlayComponent(c);
		layeredPane.add(c, Integer.valueOf(layer));
		layeredPane.revalidate();
		layeredPane.repaint();
	}
{'fraction_non_alphanumeric': 0.09254237288135593, 'fraction_numerical': 0.0013559322033898306, 'mean_word_length': 4.973684210526316, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4228532', 'n_tokens_mistral': 926, 'n_tokens_neox': 858, 'n_words': 269}