<commit_before>package com.mytestproject.drawing.client;

import java.util.ArrayList;
import java.util.Collection;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.widgetideas.graphics.client.Color;
import com.google.gwt.widgetideas.graphics.client.GWTCanvas;


public class Drawing implements EntryPoint {

  public void onModuleLoad() {

    GWTCanvas canvas = new GWTCanvas(400,400);
    Collection<VertexDrawable> collection1 = new ArrayList<VertexDrawable>();
    Collection<EdgeDrawable> collection2 = new ArrayList<EdgeDrawable>();
    VertexDrawable v1 = new VertexDrawable(10,10,10,10,"v1");
    VertexDrawable v2 = new VertexDrawable(20,20,10,10,"v2");
    VertexDrawable v3 = new VertexDrawable(70,70,10,10,"v3");
    VertexDrawable v4 = new VertexDrawable(100,100,10,10,"v4");
    collection1.add(v1);
    collection1.add(v2);
    collection1.add(v3);
    collection1.add(v4);
    EdgeDrawable e1 = new EdgeDrawable(10, 10, 50, 50);
    EdgeDrawable e2 = new EdgeDrawable(100, 100, 150, 250);
    collection2.add(e1);
    collection2.add(e2);
    canvas.setLineWidth(1);
    canvas.setStrokeStyle(Color.BLACK);
    canvas.setFillStyle(Color.BLACK);
    canvas.setBackgroundColor(Color.WHITE);
    drawGraph(collection2, collection1, canvas);
    RootPanel.get("graph_panel").add(canvas);
    
  }
  
  private void drawVertex(VertexDrawable vertex, GWTCanvas canvas) {
	  double centreX = vertex.getLeft() + 0.5*vertex.getWidth();
	  double centreY = vertex.getTop() + 0.5*vertex.getHeight();
	  double radius = 0.5*vertex.getWidth();
	  
	  canvas.moveTo(centreX, centreY);
      canvas.beginPath();
      canvas.arc(centreX,centreY,radius,0,360,false);
      canvas.closePath();
      canvas.stroke();
      canvas.fill();
  }
  
 private void drawEdge(EdgeDrawable edge, GWTCanvas canvas) { 
	double startX = edge.getStartX();
	double startY = edge.getStartY();
	double endX = edge.getEndX();
	double endY = edge.getEndY();
	
    canvas.beginPath();
    canvas.moveTo(startX,startY);
    canvas.lineTo(endX,endY);
    canvas.closePath();
    canvas.stroke();
 }
 
 private void drawGraph(Collection<EdgeDrawable> edges, Collection<VertexDrawable> vertices, GWTCanvas canvas) {
	 for (EdgeDrawable thisEdge : edges) {
		drawEdge(thisEdge, canvas);
	}
	 for (VertexDrawable thisVertex : vertices) {
		 drawVertex(thisVertex, canvas);
	 }
 }
}<commit_msg>Added a few comments<commit_after>package me.teaisaweso.client;

import java.util.ArrayList;
import java.util.Collection;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.widgetideas.graphics.client.Color;
import com.google.gwt.widgetideas.graphics.client.GWTCanvas;


public class Drawing implements EntryPoint {

  public void onModuleLoad() {

    GWTCanvas canvas = new GWTCanvas(400,400);
    Collection<VertexDrawable> collection1 = new ArrayList<VertexDrawable>();
    Collection<EdgeDrawable> collection2 = new ArrayList<EdgeDrawable>();
    VertexDrawable v1 = new VertexDrawable(10,10,10,10,"v1");
    VertexDrawable v2 = new VertexDrawable(20,20,10,10,"v2");
    VertexDrawable v3 = new VertexDrawable(70,70,10,10,"v3");
    VertexDrawable v4 = new VertexDrawable(100,100,10,10,"v4");
    collection1.add(v1);
    collection1.add(v2);
    collection1.add(v3);
    collection1.add(v4);
    EdgeDrawable e1 = new EdgeDrawable(10, 10, 50, 50);
    EdgeDrawable e2 = new EdgeDrawable(100, 100, 150, 250);
    collection2.add(e1);
    collection2.add(e2);
    canvas.setLineWidth(1);
    canvas.setStrokeStyle(Color.BLACK);
    canvas.setFillStyle(Color.BLACK);
    canvas.setBackgroundColor(Color.WHITE);
    drawGraph(collection2, collection1, canvas);
    RootPanel.get("graph_panel").add(canvas);
    
  }
  // Draws a single vertex, currently only draws circular nodes
  
  private void drawVertex(VertexDrawable vertex, GWTCanvas canvas) {
	  double centreX = vertex.getLeft() + 0.5*vertex.getWidth();
	  double centreY = vertex.getTop() + 0.5*vertex.getHeight();
	  double radius = 0.5*vertex.getWidth();
	  
	  canvas.moveTo(centreX, centreY);
      canvas.beginPath();
      canvas.arc(centreX,centreY,radius,0,360,false);
      canvas.closePath();
      canvas.stroke();
      canvas.fill();
  }
  
 // Draws a line from coordinates to other coordinates
 private void drawEdge(EdgeDrawable edge, GWTCanvas canvas) { 
	double startX = edge.getStartX();
	double startY = edge.getStartY();
	double endX = edge.getEndX();
	double endY = edge.getEndY();
	
    canvas.beginPath();
    canvas.moveTo(startX,startY);
    canvas.lineTo(endX,endY);
    canvas.closePath();
    canvas.stroke();
 }
 
 // Takes collections of edges and vertices and draws a graph on a specified canvas.
 private void drawGraph(Collection<EdgeDrawable> edges, Collection<VertexDrawable> vertices, GWTCanvas canvas) {
	 for (EdgeDrawable thisEdge : edges) {
		drawEdge(thisEdge, canvas);
	}
	 for (VertexDrawable thisVertex : vertices) {
		 drawVertex(thisVertex, canvas);
	 }
 }
}
{'fraction_non_alphanumeric': 0.12645492207536002, 'fraction_numerical': 0.03827184849082659, 'mean_word_length': 4.3936170212765955, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '4610509', 'n_tokens_mistral': 1749, 'n_tokens_neox': 1657, 'n_words': 324}