<commit_before>package org.test.ui;


import com.vaadin.annotations.Push;
import com.vaadin.server.ThemeResource;
import com.vaadin.shared.MouseEventDetails;
import com.vaadin.ui.*;
import com.vaadin.*;
import com.vaadin.ui.Button;
import com.vaadin.ui.themes.ValoTheme;
import org.test.Canvas;

import javax.servlet.annotation.WebServlet;

import com.vaadin.annotations.Theme;
import com.vaadin.annotations.Title;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;

import java.awt.*;

@Theme("demo")
@SuppressWarnings("serial")
@Push
public class UI extends com.vaadin.ui.UI
{
    private static Rooms rooms = Rooms.getInstance();

    @WebServlet(value = "/*", asyncSupported = true)
    @VaadinServletConfiguration(productionMode = false, ui = UI.class)
    public static class Servlet extends VaadinServlet {
    }

    @Override
    protected void init(VaadinRequest request) {
        Key<String> name = new Key<String>("MyRoom_v0.01");
        Room room;
        try {
            room = rooms.createRoom(name, 0, getUI());
        } catch(NonUniqName e) {
            //some handling
            return;
        }

        Canvas canvas = room.getCanvas(this);

        final VerticalLayout layout = new VerticalLayout();
        final HorizontalLayout layout1 = new HorizontalLayout();
        final Button rectangle = new Button("Rectangle", new ThemeResource("icons/png/thin-square.png"));
        rectangle.addStyleName("mystyle");
        //rectangle.addClickListener(clickEvent -> Notification.show ("Norm"));
        final Button line = new Button("Linear", new ThemeResource("icons/1.png"));
        line.addStyleName("mystyle");
        line.addClickListener(clickEvent -> {canvas.startDrawLines("", 2);});
        layout1.addComponents(rectangle, line);
        layout1.setSpacing(true);
        layout.addComponents(layout1, canvas);
        layout.setSpacing(true);
        setContent(layout);

        canvas.addMouseMoveListener((MouseEventDetails mouseDetails) -> {
            System.out.println("Mouse moved at "
                    + mouseDetails.getClientX() + ","
                    + mouseDetails.getClientY());
        });

        canvas.addMouseDownListener((MouseEventDetails mouseDetails) -> {
            System.out.println("Mouse down at "
                    + mouseDetails.getClientX() + ","
                    + mouseDetails.getClientY());
        });

        canvas.addMouseUpListener((MouseEventDetails mouseDetails) -> {
            System.out.println("Mouse up at "
                    + mouseDetails.getClientX() + ","
                    + mouseDetails.getClientY());
        });
    }
}<commit_msg>Working buttons<commit_after>package org.test.ui;


import com.vaadin.annotations.Push;
import com.vaadin.annotations.Theme;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.server.Page;
import com.vaadin.server.ThemeResource;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.shared.MouseEventDetails;
import com.vaadin.ui.*;
import com.vaadin.ui.components.colorpicker.ColorChangeEvent;
import com.vaadin.ui.components.colorpicker.ColorChangeListener;
import org.test.Canvas;

import javax.servlet.annotation.WebServlet;


@Theme("demo")
@SuppressWarnings("serial")
@Push
public class UI extends com.vaadin.ui.UI
{
    private static Rooms rooms = Rooms.getInstance();

    @WebServlet(value = "/*", asyncSupported = true)
    @VaadinServletConfiguration(productionMode = false, ui = UI.class)
    public static class Servlet extends VaadinServlet {
    }

    @Override
    protected void init(VaadinRequest request) {
        Key<String> name = new Key<String>("MyRoom_v0.01");
        Room room;
        try {
            room = rooms.createRoom(name, 0, getUI());
        } catch(NonUniqName e) {
            //some handling
            return;
        }
        class Info1 {
           private int thickness1;
           private String color;
        }
        Canvas canvas = room.getCanvas(this);
        Info1 info = new Info1();
        info.color = "#000000";
        info.thickness1 = 1;
        final VerticalLayout layout = new VerticalLayout();
        final HorizontalLayout layout1 = new HorizontalLayout();
        final HorizontalLayout layout2 = new HorizontalLayout();
        final VerticalLayout layout3 = new VerticalLayout();
        final Button rectangle = new Button("Rectangle", new ThemeResource("icons/png/thin-square.png"));
        rectangle.addStyleName("mystyle");
        rectangle.addClickListener(clickEvent -> {
            canvas.endDraw();
            canvas.startDrawRectangles(info.color,info.thickness1);
        });
        final Button line = new Button("Linear", new ThemeResource("icons/1.png"));
        line.addStyleName("mystyle");
        line.addClickListener(clickEvent -> {
            canvas.endDraw();
            canvas.startDrawLines(info.color,info.thickness1);
        });
        final MenuBar menu = new MenuBar();
        final Label selection = new Label("The thickness is 1 px");
        final Label color = new Label("The color is #ffffff");
        layout1.addComponent(selection);
        selection.addStyleName("labelstyle");
        final MenuBar.Command chooseThickness = new MenuBar.Command() {
            MenuBar.MenuItem previous = null;
            public void menuSelected(MenuBar.MenuItem selectedItem) {
                if (selectedItem.getText().equalsIgnoreCase("1 px")) {
                    info.thickness1 = 1;
                }
                if (selectedItem.getText().equalsIgnoreCase("2 px"))  {
                    info.thickness1 = 2;
                }
                if (selectedItem.getText().equalsIgnoreCase("3 px"))  {
                    info.thickness1 = 3;
                }
                if (selectedItem.getText().equalsIgnoreCase("4 px"))  {
                    info.thickness1 = 4;
                }
                selection.setValue("   The thickness is " + selectedItem.getText());
                if (previous != null)
                    previous.setStyleName(null);
                selectedItem.setStyleName("highlight");
                previous = selectedItem;
            }
        };
        final MenuBar.MenuItem thickness = menu.addItem("Thickness", new ThemeResource( "icons/png/pencil.png") , null);
        final MenuBar.MenuItem size = thickness.addItem("Size",null,null);
        size.addItem("1px",new ThemeResource("icons/1.png"), chooseThickness );
        size.addItem("2px",new ThemeResource("icons/2.png"), chooseThickness);
        size.addItem("3px",new ThemeResource("icons/3.png"), chooseThickness);
        size.addItem("4px",new ThemeResource("icons/4.png"), chooseThickness);
        menu.addStyleName("mystyle");
        ColorPicker picker = new ColorPicker("Pick the color");
        picker.addColorChangeListener(new ColorChangeListener() {
            @Override
            public void colorChanged(ColorChangeEvent event) {
                // Do something with the color
                color.setValue(
                        "Color is " + event.getColor().getCSS());
                info.color = event.getColor().getCSS();
            }
        });

        picker.setPosition(
                Page.getCurrent().getBrowserWindowWidth() / 2 - 246/2,
                Page.getCurrent().getBrowserWindowHeight() / 2 - 507/2);
        color.addStyleName("labelstyle");

        picker.addStyleName("mystyle");
        layout3.addComponents(selection, color);
        layout1.addComponents(rectangle, line, menu, picker);
        layout1.setSpacing(true);
        layout2.addComponents(canvas, layout3);
        layout.addComponents(layout1, layout2);
        layout.setSpacing(true);
        setContent(layout);
    }
}
{'fraction_non_alphanumeric': 0.11599542624825308, 'fraction_numerical': 0.009020454834201498, 'mean_word_length': 2.5111507582515613, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 14, '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': '5002697', 'n_tokens_mistral': 2204, 'n_tokens_neox': 2062, 'n_words': 418}