<commit_before>package antipasto.GUI.GadgetListView;

import javax.imageio.ImageIO;
import javax.swing.event.EventListenerList;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.*;

import antipasto.CoreFactory;
import antipasto.GadgetFactory;
import antipasto.ModuleFactory;
import antipasto.GUI.GadgetListView.AddGadgetMenu;
import antipasto.GUI.GadgetListView.GadgetPanelEvents.ActiveGadgetObject;
import antipasto.GUI.GadgetListView.GadgetPanelEvents.IActiveGadgetChangedEventListener;
import antipasto.GUI.GadgetListView.GadgetPanelEvents.IActiveSketchChangingListener;
import antipasto.GUI.GadgetListView.GadgetPanelEvents.SketchChangingObject;
import antipasto.Interfaces.IGadget;
import antipasto.Interfaces.IModule;
import antipasto.Interfaces.IPackedFile;
import antipasto.Interfaces.ITemporary;

import processing.app.Base;
import processing.app.Editor;
import processing.app.Serial;

import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URL;
import java.awt.*;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.ArrayList;

public class GadgetPanel extends JDialog implements ListSelectionListener, IActiveSketchChangingListener, ComponentListener,
													MouseListener, WindowListener
													{

 
    //JList list;
    private EventListenerList activeGadgetChangedEventList = new EventListenerList();
    private EventListenerList sketchBookChangedEventList = new EventListenerList();

    private GadgetFactory skbFact = new GadgetFactory();
    private CoreFactory coreFact= new CoreFactory();
    private ModuleFactory modFact = new ModuleFactory();
    private GadgetList list;
    private Serial serial;

    private File _sketchBookDirectory;

    private IModule activeModule;

    private GadgetListHorizontal libPanel;

    private String libraryDirectory;
    private IGadget _gadget;
    private JScrollPane scrollPanel;

    private JPanel messagePanel;
    private JLabel messageLabel;
    
    private JPanel gadgetDescPanel;
    private JLabel gadgetDescLabel;

    private Box box;
    
    private int cachedHeight = 415;
    private int cachedWidth = 300;

    public GadgetPanel(String sketchBookDirectory, JFrame frame, String libraryDirectory) {
    	super(frame, false);
        this.addMouseListener(new ModuleMouseAdapter());
        this.setUndecorated(true);
        frame.addWindowListener(this);
        this.libraryDirectory = libraryDirectory;
        this.init();
    }
    
    public void loadGadget(String gadget){
    	this.loadGadget(new File(gadget));
    }
    
    private void init(){
    	this.getContentPane().setLayout(new BorderLayout());
    	//JPanel top = new JPanel();
        //top.setBackground(new Color(0x04, 0x4F, 0x6F));
    	//this.getContentPane().add(top, BorderLayout.NORTH);
    	//top.setSize(new Dimension(this.getWidth(), 15));
        //top.setLayout(new FlowLayout());
    	//messagePanel.setLayout(new FlowLayout());
        
        /*
        try {
        	ImageIcon upperLeft = new ImageIcon("..\\lib\\upperleftgadget.png");
    		upperLeft.setImage(Base.getImage("..\\lib\\upperleftgadget.png", this));
    		JLabel upperImageLabel = new JLabel(upperLeft);
			top.add(upperImageLabel);
			upperImageLabel.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}*/

        /*
    	JPanel bottom = new JPanel();
    	bottom.setBackground(new Color(0x04, 0x4F, 0x6F));
    	this.getContentPane().add(bottom, BorderLayout.SOUTH);
    	bottom.setSize(new Dimension(this.getWidth(), 15));
    	bottom.setLayout(new FlowLayout());
        */ 

        /*
    	ImageIcon lowerRight = new ImageIcon();
    	try {
    		ImageIcon lowerLeftImage = new ImageIcon("\\lib\\lowerleftgadget.png");
			lowerLeftImage.setImage(Base.getImage("..\\lib\\lowerleftgadget.png", this));
    		JLabel lowerImageLabel = new JLabel(lowerLeftImage);
			top.add(lowerImageLabel);
			lowerImageLabel.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
        */
        
    	/* The library description */
    	JPanel libDescPanel = new JPanel();
        JLabel libDescLabel = new JLabel(" Library: OpenHardware");
        libDescLabel.setForeground(Color.white);
        
        libDescPanel.setBackground(new Color(0x04, 0x4F, 0x6F));
        libDescPanel.setSize(new Dimension(300, 15));
    	libDescPanel.setLayout(new BorderLayout());
    	libDescPanel.add(libDescLabel, BorderLayout.WEST);  	

    	/* The gadget file description */
    	gadgetDescPanel = new JPanel();
        gadgetDescLabel = new JLabel(" Gadget: ");
        gadgetDescLabel.setForeground(Color.white);
        
        gadgetDescPanel.setBackground(new Color(0x04, 0x4F, 0x6F));
        gadgetDescPanel.setSize(new Dimension(300, 15));
        gadgetDescPanel.setLayout(new BorderLayout());
        gadgetDescPanel.add(gadgetDescLabel, BorderLayout.WEST);  
        
        /* The message panel */
    	messagePanel = new JPanel();
        messageLabel = new JLabel(" No messages.");<commit_msg>Update GadgetPanel background for Mac Display.<commit_after>package antipasto.GUI.GadgetListView;

import javax.imageio.ImageIO;
import javax.swing.event.EventListenerList;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.*;

import antipasto.CoreFactory;
import antipasto.GadgetFactory;
import antipasto.ModuleFactory;
import antipasto.GUI.GadgetListView.AddGadgetMenu;
import antipasto.GUI.GadgetListView.GadgetPanelEvents.ActiveGadgetObject;
import antipasto.GUI.GadgetListView.GadgetPanelEvents.IActiveGadgetChangedEventListener;
import antipasto.GUI.GadgetListView.GadgetPanelEvents.IActiveSketchChangingListener;
import antipasto.GUI.GadgetListView.GadgetPanelEvents.SketchChangingObject;
import antipasto.Interfaces.IGadget;
import antipasto.Interfaces.IModule;
import antipasto.Interfaces.IPackedFile;
import antipasto.Interfaces.ITemporary;

import processing.app.Base;
import processing.app.Editor;
import processing.app.Serial;

import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URL;
import java.awt.*;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.ArrayList;

public class GadgetPanel extends JDialog implements ListSelectionListener, IActiveSketchChangingListener, ComponentListener,
													MouseListener, WindowListener
													{

 
    //JList list;
    private EventListenerList activeGadgetChangedEventList = new EventListenerList();
    private EventListenerList sketchBookChangedEventList = new EventListenerList();

    private GadgetFactory skbFact = new GadgetFactory();
    private CoreFactory coreFact= new CoreFactory();
    private ModuleFactory modFact = new ModuleFactory();
    private GadgetList list;
    private Serial serial;

    private File _sketchBookDirectory;

    private IModule activeModule;

    private GadgetListHorizontal libPanel;

    private String libraryDirectory;
    private IGadget _gadget;
    private JScrollPane scrollPanel;

    private JPanel messagePanel;
    private JLabel messageLabel;
    
    private JPanel gadgetDescPanel;
    private JLabel gadgetDescLabel;

    private Box box;
    
    private int cachedHeight = 425;
    private int cachedWidth = 300;

    public GadgetPanel(String sketchBookDirectory, JFrame frame, String libraryDirectory) {
    	super(frame, false);
        this.addMouseListener(new ModuleMouseAdapter());
        this.setUndecorated(true);
        frame.addWindowListener(this);
        this.libraryDirectory = libraryDirectory;
        this.init();
    }
    
    public void loadGadget(String gadget){
    	this.loadGadget(new File(gadget));
    }
    
    private void init(){
    	this.getContentPane().setLayout(new BorderLayout());
    	//JPanel top = new JPanel();
        //top.setBackground(new Color(0x04, 0x4F, 0x6F));
    	//this.getContentPane().add(top, BorderLayout.NORTH);
    	//top.setSize(new Dimension(this.getWidth(), 15));
        //top.setLayout(new FlowLayout());
    	//messagePanel.setLayout(new FlowLayout());
        
        /*
        try {
        	ImageIcon upperLeft = new ImageIcon("..\\lib\\upperleftgadget.png");
    		upperLeft.setImage(Base.getImage("..\\lib\\upperleftgadget.png", this));
    		JLabel upperImageLabel = new JLabel(upperLeft);
			top.add(upperImageLabel);
			upperImageLabel.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}*/

        /*
    	JPanel bottom = new JPanel();
    	bottom.setBackground(new Color(0x04, 0x4F, 0x6F));
    	this.getContentPane().add(bottom, BorderLayout.SOUTH);
    	bottom.setSize(new Dimension(this.getWidth(), 15));
    	bottom.setLayout(new FlowLayout());
        */ 

        /*
    	ImageIcon lowerRight = new ImageIcon();
    	try {
    		ImageIcon lowerLeftImage = new ImageIcon("\\lib\\lowerleftgadget.png");
			lowerLeftImage.setImage(Base.getImage("..\\lib\\lowerleftgadget.png", this));
    		JLabel lowerImageLabel = new JLabel(lowerLeftImage);
			top.add(lowerImageLabel);
			lowerImageLabel.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
        */
        
		this.setBackground(new Color(0x04, 0x4F, 0x6F));
		
    	/* The library description */
    	JPanel libDescPanel = new JPanel();
        JLabel libDescLabel = new JLabel(" Library: OpenHardware");
        libDescLabel.setForeground(Color.white);
        
        libDescPanel.setBackground(new Color(0x04, 0x4F, 0x6F));
        libDescPanel.setSize(new Dimension(300, 15));
    	libDescPanel.setLayout(new BorderLayout());
    	libDescPanel.add(libDescLabel, BorderLayout.WEST);  	

    	/* The gadget file description */
    	gadgetDescPanel = new JPanel();
        gadgetDescLabel = new JLabel(" Gadget: ");
        gadgetDescLabel.setForeground(Color.white);
        
        gadgetDescPanel.setBackground(Color.black);
		gadgetDescPanel.setSize(new Dimension(300, 15));
        gadgetDescPanel.setLayout(new BorderLayout());
        gadgetDescPanel.add(gadgetDescLabel, BorderLayout.WEST);  
        
        /* The message panel */
    	messagePanel = new JPanel();
        messageLabel = new JLabel(" No messages.");
{'fraction_non_alphanumeric': 0.10184222957014644, 'fraction_numerical': 0.009069437883797828, 'mean_word_length': 3.715367483296214, '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': '665428', 'n_tokens_mistral': 3286, 'n_tokens_neox': 3149, 'n_words': 619}