<commit_before>package edu.mit.csail.uid;

import java.io.*;
import java.awt.*;
import java.awt.image.*;
import java.awt.event.*;
import javax.swing.*;
import javax.imageio.*;

class CapturePrompt extends JWindow implements Subject{
   static Color _overlayColor = new Color(0F,0F,0F,0.6F);
   static GraphicsDevice _gdev = null;

   Observer _obs;

   Screen _scr;
   BufferedImage _scr_img = null;
   BufferedImage _darker_screen = null;
   Rectangle rectSelection;
   BasicStroke bs;
   int srcx, srcy, destx, desty;

   BasicStroke _StrokeCross = new BasicStroke (1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1, new float [] { 2f }, 0);

   public void addObserver(Observer o){
      _obs = o;
   }
   public void notifyObserver(){
      _obs.update(this);
   }

   private void captureScreen(Screen scr) {
      ScreenImage simg = scr.capture();
      /*
      try{
         System.out.println( "screen file: " + simg.getFilename() );
      }
      catch(IOException e){}
      */

      _scr_img = simg.getImage();
      float scaleFactor = .6f;
      RescaleOp op = new RescaleOp(scaleFactor, 0, null);
      _darker_screen = op.filter(_scr_img, null);
   }

   private void drawSelection(Graphics2D g2d){
      if (srcx != destx || srcy != desty)
      {
         int x1 = (srcx < destx) ? srcx : destx;
         int y1 = (srcy < desty) ? srcy : desty;
         int x2 = (srcx > destx) ? srcx : destx;
         int y2 = (srcy > desty) ? srcy : desty;

         rectSelection.x = x1;
         rectSelection.y = y1;
         rectSelection.width = (x2-x1)+1;
         rectSelection.height = (y2-y1)+1;

         g2d.setColor(Color.white);
         g2d.setStroke(bs);
         g2d.draw(rectSelection);

         int cx = (x1+x2)/2;
         int cy = (y1+y2)/2;
         g2d.setStroke(_StrokeCross);
         g2d.drawLine(cx, y1, cx, y2);
         g2d.drawLine(x1, cy, x2, cy);
      }
   }

   public void paint(Graphics g)
   {
      if( _scr_img != null ){
         Graphics2D g2d = (Graphics2D)g;

         g2d.drawImage(_darker_screen,0,0,this);
         drawSelection(g2d);
         setVisible(true);
      }
      else
         setVisible(false);
   }

   void init(){
      rectSelection = new Rectangle ();
      bs = new BasicStroke (3, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
            0, new float [] { 12, 12 }, 0);
      addMouseListener(new MouseAdapter(){<commit_msg>change the style of CapturePrompt<commit_after>package edu.mit.csail.uid;

import java.io.*;
import java.awt.*;
import java.awt.image.*;
import java.awt.event.*;
import javax.swing.*;
import javax.imageio.*;

class CapturePrompt extends JWindow implements Subject{
   static Color _overlayColor = new Color(0F,0F,0F,0.6F);
   static GraphicsDevice _gdev = null;

   Observer _obs;

   Screen _scr;
   BufferedImage _scr_img = null;
   BufferedImage _darker_screen = null;
   Rectangle rectSelection;
   BasicStroke bs;
   int srcx, srcy, destx, desty;

   BasicStroke _StrokeCross = new BasicStroke (1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1, new float [] { 2f }, 0);

   public void addObserver(Observer o){
      _obs = o;
   }
   public void notifyObserver(){
      _obs.update(this);
   }

   private void captureScreen(Screen scr) {
      ScreenImage simg = scr.capture();
      /*
      try{
         System.out.println( "screen file: " + simg.getFilename() );
      }
      catch(IOException e){}
      */

      _scr_img = simg.getImage();
      float scaleFactor = .6f;
      RescaleOp op = new RescaleOp(scaleFactor, 0, null);
      _darker_screen = op.filter(_scr_img, null);
   }

   private void drawSelection(Graphics2D g2d){
      if (srcx != destx || srcy != desty)
      {
         int x1 = (srcx < destx) ? srcx : destx;
         int y1 = (srcy < desty) ? srcy : desty;
         int x2 = (srcx > destx) ? srcx : destx;
         int y2 = (srcy > desty) ? srcy : desty;

         rectSelection.x = x1;
         rectSelection.y = y1;
         rectSelection.width = (x2-x1)+1;
         rectSelection.height = (y2-y1)+1;

         if(rectSelection.width>0 && rectSelection.height>0)
            g2d.drawImage(_scr_img.getSubimage(x1, y1,x2-x1+1, y2-y1+1),
                          null, x1, y1);

         g2d.setColor(Color.white);
         g2d.setStroke(bs);
         g2d.draw(rectSelection);

         int cx = (x1+x2)/2;
         int cy = (y1+y2)/2;
         g2d.setColor(Color.red);
         g2d.setStroke(_StrokeCross);
         g2d.drawLine(cx, y1, cx, y2);
         g2d.drawLine(x1, cy, x2, cy);
      }
   }

   public void paint(Graphics g)
   {
      if( _scr_img != null ){
         Graphics2D g2d = (Graphics2D)g;

         g2d.drawImage(_darker_screen,0,0,this);
         drawSelection(g2d);
         setVisible(true);
      }
      else
         setVisible(false);
   }

   void init(){
      getContentPane().setCursor(
            Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
      rectSelection = new Rectangle ();
      bs = new BasicStroke(1);
      addMouseListener(new MouseAdapter(){
{'fraction_non_alphanumeric': 0.123834094066283, 'fraction_numerical': 0.023417344711252234, 'mean_word_length': 2.3267326732673266, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '3871846', 'n_tokens_mistral': 1811, 'n_tokens_neox': 1754, 'n_words': 387}