{"action":"created","comment":{"url":"https://api.github.com/repos/kerimdragolj/homeworks/pulls/comments/36619023","id":36619023,"diff_hunk":"@@ -0,0 +1,148 @@\n+package homework27.task02;\n+\n+import java.awt.Color;\n+import java.awt.Component;\n+import java.awt.Graphics;\n+import java.awt.Image;\n+import java.awt.image.BufferedImage;\n+import java.io.File;\n+import java.io.IOException;\n+import java.util.concurrent.LinkedBlockingQueue;\n+\n+import javax.imageio.ImageIO;\n+import javax.swing.Icon;\n+import javax.swing.ImageIcon;\n+import javax.swing.JFileChooser;\n+import javax.swing.JFrame;\n+import javax.swing.JLabel;\n+import javax.swing.JPanel;\n+\n+/**\n+ * This class represents frame that will open picture that we choose in its own\n+ * colors, then it will change color of every pixel into its negative color\n+ * \n+ * @author Kerim\n+ *\n+ */\n+public class ImageRecoloring extends JFrame {\n+\n+\t// initializing variables\n+\tprivate static JPanel panel = new JPanel();\n+\tprivate static BufferedImage image;\n+\tprivate static LinkedBlockingQueue<Task> tasks;\n+\tprivate static LinkedBlockingQueue<Worker> workers;\n+\tprivate static JLabel imgLabel;\n+\n+\t// creating constructor of frame\n+\tpublic ImageRecoloring() {\n+\n+\t\t// adding image to label, and adding label on panel\n+\t\timgLabel = new JLabel(new ImageIcon(image));\n+\t\tpanel.add(imgLabel);\n+\n+\t\t// adding panel on frame and setting it characteristics\n+\t\tadd(panel);\n+\t\tsetSize(800, 500);\n+\t\tsetDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\n+\t\tsetLocationRelativeTo(null);\n+\t\tsetTitle(\"Task02\");\n+\t\tsetVisible(true);\n+\t}\n+\n+\tpublic static void main(String[] args) {\n+\n+\t\ttry {\n+\n+\t\t\t// opening image, creating tasks and workers queue\n+\t\t\timage = ImageIO.read(new File(\"src/ac.jpg\"));\n+\t\t\ttasks = new LinkedBlockingQueue<>();\n+\t\t\tworkers = new LinkedBlockingQueue<>();\n+\t\t\tImageRecoloring frame = new ImageRecoloring();\n+\n+\t\t\t// creating new task for every pixel of pictures height and adding\n+\t\t\t// it into queue\n+\t\t\tfor (int x = 0; x < image.getHeight(); x++) {\n+\t\t\t\ttasks.add(new Task(x, image));\n+\t\t\t}\n+\n+\t\t\t// creating 4 workers, adding them into queue\n+\t\t\tfor (int i = 0; i < 4; i++) {\n+\t\t\t\tWorker w = new Worker();\n+\t\t\t\tworkers.add(w);\n+\t\t\t\tw.run();\n+\t\t\t\ttry {\n+\t\t\t\t\tw.join();\n+\t\t\t\t} catch (InterruptedException e) {\n+\t\t\t\t\te.printStackTrace();\n+\t\t\t\t}\n+\t\t\t\tframe.repaint();\n+\t\t\t}\n+\n+\t\t} catch (IOException e) {\n+\t\t\te.printStackTrace();\n+\t\t}\n+\t}\n+\n+\t/**\n+\t * This class represents task that workers will do, each row of pixels is\n+\t * one task, \"i\" represents row that will be done in that task, and \"img\" is\n+\t * picture that will be painted\n+\t * \n+\t * @author Kerim\n+\t *\n+\t */\n+\tpublic static class Task implements Runnable {\n+\n+\t\tint i;\n+\t\tBufferedImage img;\n+\n+\t\tpublic Task(int i, BufferedImage img) {\n+\n+\t\t\tthis.i = i;\n+\t\t\tthis.img = img;\n+\n+\t\t}\n+\n+\t\t@Override\n+\t\tpublic void run() {\n+\n+\t\t\t// going trough whole width of picture, and change color of each\n+\t\t\t// pixel into its negative color\n+\t\t\tfor (int y = 0; y < img.getWidth(); y++) {\n+\t\t\t\tint rgba = img.getRGB(y, i);\n+\t\t\t\tColor col = new Color(rgba, true);\n+\t\t\t\tcol = new Color(255 - col.getRed(), 255 - col.getGreen(), 255 - col.getBlue());\n+\t\t\t\timage.setRGB(y, i, col.getRGB());\n+\n+\t\t\t\tpanel.repaint();\n+\n+\t\t\t}\n+\t\t}\n+\n+\t}\n+\n+\t/**\n+\t * This class extends thread and represents workers(threads) who will do tasks we made above\n+\t * @author Kerim\n+\t *\n+\t */\n+\tpublic static class Worker extends Thread {\n+\n+\t\tpublic void run() {\n+\t\t\t//Worker is going to work while queue of tasks isn't empty\n+\t\t\twhile (!tasks.isEmpty()) {\n+\t\t\t\tRunnable job;\n+\t\t\t\ttry {\n+\t\t\t\t\t//it will take task by task from queue\n+\t\t\t\t\tjob = tasks.take();\n+\t\t\t\t\tjob.run();\n+\t\t\t\t} catch (InterruptedException e) {\n+\t\t\t\t\tbreak;\n+\t\t\t\t}\n+\n+\t\t\t}\n+\n+\t\t}\n+\t}\n+","path":"Homework#27/src/homework27/task02/ImageRecoloring.java","position":147,"original_position":147,"commit_id":"489ce89f4b36e7fcac7e8752c4ee7f7f0e01abdb","original_commit_id":"489ce89f4b36e7fcac7e8752c4ee7f7f0e01abdb","user":{"login":"hkraji","id":1286134,"avatar_url":"https://avatars.githubusercontent.com/u/1286134?v=3","gravatar_id":"","url":"https://api.github.com/users/hkraji","html_url":"https://github.com/hkraji","followers_url":"https://api.github.com/users/hkraji/followers","following_url":"https://api.github.com/users/hkraji/following{/other_user}","gists_url":"https://api.github.com/users/hkraji/gists{/gist_id}","starred_url":"https://api.github.com/users/hkraji/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hkraji/subscriptions","organizations_url":"https://api.github.com/users/hkraji/orgs","repos_url":"https://api.github.com/users/hkraji/repos","events_url":"https://api.github.com/users/hkraji/events{/privacy}","received_events_url":"https://api.github.com/users/hkraji/received_events","type":"User","site_admin":false},"body":"Sve radi moze odmah mege :checkered_flag: ","created_at":"2015-08-10T10:39:26Z","updated_at":"2015-08-10T10:39:26Z","html_url":"https://github.com/kerimdragolj/homeworks/pull/5#discussion_r36619023","pull_request_url":"https://api.github.com/repos/kerimdragolj/homeworks/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/kerimdragolj/homeworks/pulls/comments/36619023"},"html":{"href":"https://github.com/kerimdragolj/homeworks/pull/5#discussion_r36619023"},"pull_request":{"href":"https://api.github.com/repos/kerimdragolj/homeworks/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/kerimdragolj/homeworks/pulls/5","id":41963219,"html_url":"https://github.com/kerimdragolj/homeworks/pull/5","diff_url":"https://github.com/kerimdragolj/homeworks/pull/5.diff","patch_url":"https://github.com/kerimdragolj/homeworks/pull/5.patch","issue_url":"https://api.github.com/repos/kerimdragolj/homeworks/issues/5","number":5,"state":"open","locked":false,"title":"homework27","user":{"login":"kerimdragolj","id":12545884,"avatar_url":"https://avatars.githubusercontent.com/u/12545884?v=3","gravatar_id":"","url":"https://api.github.com/users/kerimdragolj","html_url":"https://github.com/kerimdragolj","followers_url":"https://api.github.com/users/kerimdragolj/followers","following_url":"https://api.github.com/users/kerimdragolj/following{/other_user}","gists_url":"https://api.github.com/users/kerimdragolj/gists{/gist_id}","starred_url":"https://api.github.com/users/kerimdragolj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kerimdragolj/subscriptions","organizations_url":"https://api.github.com/users/kerimdragolj/orgs","repos_url":"https://api.github.com/users/kerimdragolj/repos","events_url":"https://api.github.com/users/kerimdragolj/events{/privacy}","received_events_url":"https://api.github.com/users/kerimdragolj/received_events","type":"User","site_admin":false},"body":"@hkraji","created_at":"2015-08-09T00:39:40Z","updated_at":"2015-08-10T10:39:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"91c39dee574d50302fdb01ec978796bba12d25ae","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/kerimdragolj/homeworks/pulls/5/commits","review_comments_url":"https://api.github.com/repos/kerimdragolj/homeworks/pulls/5/comments","review_comment_url":"https://api.github.com/repos/kerimdragolj/homeworks/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kerimdragolj/homeworks/issues/5/comments","statuses_url":"https://api.github.com/repos/kerimdragolj/homeworks/statuses/489ce89f4b36e7fcac7e8752c4ee7f7f0e01abdb","head":{"label":"kerimdragolj:homework27","ref":"homework27","sha":"489ce89f4b36e7fcac7e8752c4ee7f7f0e01abdb","user":{"login":"kerimdragolj","id":12545884,"avatar_url":"https://avatars.githubusercontent.com/u/12545884?v=3","gravatar_id":"","url":"https://api.github.com/users/kerimdragolj","html_url":"https://github.com/kerimdragolj","followers_url":"https://api.github.com/users/kerimdragolj/followers","following_url":"https://api.github.com/users/kerimdragolj/following{/other_user}","gists_url":"https://api.github.com/users/kerimdragolj/gists{/gist_id}","starred_url":"https://api.github.com/users/kerimdragolj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kerimdragolj/subscriptions","organizations_url":"https://api.github.com/users/kerimdragolj/orgs","repos_url":"https://api.github.com/users/kerimdragolj/repos","events_url":"https://api.github.com/users/kerimdragolj/events{/privacy}","received_events_url":"https://api.github.com/users/kerimdragolj/received_events","type":"User","site_admin":false},"repo":{"id":38105040,"name":"homeworks","full_name":"kerimdragolj/homeworks","owner":{"login":"kerimdragolj","id":12545884,"avatar_url":"https://avatars.githubusercontent.com/u/12545884?v=3","gravatar_id":"","url":"https://api.github.com/users/kerimdragolj","html_url":"https://github.com/kerimdragolj","followers_url":"https://api.github.com/users/kerimdragolj/followers","following_url":"https://api.github.com/users/kerimdragolj/following{/other_user}","gists_url":"https://api.github.com/users/kerimdragolj/gists{/gist_id}","starred_url":"https://api.github.com/users/kerimdragolj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kerimdragolj/subscriptions","organizations_url":"https://api.github.com/users/kerimdragolj/orgs","repos_url":"https://api.github.com/users/kerimdragolj/repos","events_url":"https://api.github.com/users/kerimdragolj/events{/privacy}","received_events_url":"https://api.github.com/users/kerimdragolj/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kerimdragolj/homeworks","description":"","fork":false,"url":"https://api.github.com/repos/kerimdragolj/homeworks","forks_url":"https://api.github.com/repos/kerimdragolj/homeworks/forks","keys_url":"https://api.github.com/repos/kerimdragolj/homeworks/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kerimdragolj/homeworks/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kerimdragolj/homeworks/teams","hooks_url":"https://api.github.com/repos/kerimdragolj/homeworks/hooks","issue_events_url":"https://api.github.com/repos/kerimdragolj/homeworks/issues/events{/number}","events_url":"https://api.github.com/repos/kerimdragolj/homeworks/events","assignees_url":"https://api.github.com/repos/kerimdragolj/homeworks/assignees{/user}","branches_url":"https://api.github.com/repos/kerimdragolj/homeworks/branches{/branch}","tags_url":"https://api.github.com/repos/kerimdragolj/homeworks/tags","blobs_url":"https://api.github.com/repos/kerimdragolj/homeworks/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kerimdragolj/homeworks/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kerimdragolj/homeworks/git/refs{/sha}","trees_url":"https://api.github.com/repos/kerimdragolj/homeworks/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kerimdragolj/homeworks/statuses/{sha}","languages_url":"https://api.github.com/repos/kerimdragolj/homeworks/languages","stargazers_url":"https://api.github.com/repos/kerimdragolj/homeworks/stargazers","contributors_url":"https://api.github.com/repos/kerimdragolj/homeworks/contributors","subscribers_url":"https://api.github.com/repos/kerimdragolj/homeworks/subscribers","subscription_url":"https://api.github.com/repos/kerimdragolj/homeworks/subscription","commits_url":"https://api.github.com/repos/kerimdragolj/homeworks/commits{/sha}","git_commits_url":"https://api.github.com/repos/kerimdragolj/homeworks/git/commits{/sha}","comments_url":"https://api.github.com/repos/kerimdragolj/homeworks/comments{/number}","issue_comment_url":"https://api.github.com/repos/kerimdragolj/homeworks/issues/comments{/number}","contents_url":"https://api.github.com/repos/kerimdragolj/homeworks/contents/{+path}","compare_url":"https://api.github.com/repos/kerimdragolj/homeworks/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kerimdragolj/homeworks/merges","archive_url":"https://api.github.com/repos/kerimdragolj/homeworks/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kerimdragolj/homeworks/downloads","issues_url":"https://api.github.com/repos/kerimdragolj/homeworks/issues{/number}","pulls_url":"https://api.github.com/repos/kerimdragolj/homeworks/pulls{/number}","milestones_url":"https://api.github.com/repos/kerimdragolj/homeworks/milestones{/number}","notifications_url":"https://api.github.com/repos/kerimdragolj/homeworks/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kerimdragolj/homeworks/labels{/name}","releases_url":"https://api.github.com/repos/kerimdragolj/homeworks/releases{/id}","created_at":"2015-06-26T10:21:13Z","updated_at":"2015-08-06T21:28:14Z","pushed_at":"2015-08-09T00:39:41Z","git_url":"git://github.com/kerimdragolj/homeworks.git","ssh_url":"git@github.com:kerimdragolj/homeworks.git","clone_url":"https://github.com/kerimdragolj/homeworks.git","svn_url":"https://github.com/kerimdragolj/homeworks","homepage":null,"size":8264,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":0,"default_branch":"master"}},"base":{"label":"kerimdragolj:master","ref":"master","sha":"0c4977cc606ddc31695e8d22beb048a95c058bab","user":{"login":"kerimdragolj","id":12545884,"avatar_url":"https://avatars.githubusercontent.com/u/12545884?v=3","gravatar_id":"","url":"https://api.github.com/users/kerimdragolj","html_url":"https://github.com/kerimdragolj","followers_url":"https://api.github.com/users/kerimdragolj/followers","following_url":"https://api.github.com/users/kerimdragolj/following{/other_user}","gists_url":"https://api.github.com/users/kerimdragolj/gists{/gist_id}","starred_url":"https://api.github.com/users/kerimdragolj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kerimdragolj/subscriptions","organizations_url":"https://api.github.com/users/kerimdragolj/orgs","repos_url":"https://api.github.com/users/kerimdragolj/repos","events_url":"https://api.github.com/users/kerimdragolj/events{/privacy}","received_events_url":"https://api.github.com/users/kerimdragolj/received_events","type":"User","site_admin":false},"repo":{"id":38105040,"name":"homeworks","full_name":"kerimdragolj/homeworks","owner":{"login":"kerimdragolj","id":12545884,"avatar_url":"https://avatars.githubusercontent.com/u/12545884?v=3","gravatar_id":"","url":"https://api.github.com/users/kerimdragolj","html_url":"https://github.com/kerimdragolj","followers_url":"https://api.github.com/users/kerimdragolj/followers","following_url":"https://api.github.com/users/kerimdragolj/following{/other_user}","gists_url":"https://api.github.com/users/kerimdragolj/gists{/gist_id}","starred_url":"https://api.github.com/users/kerimdragolj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kerimdragolj/subscriptions","organizations_url":"https://api.github.com/users/kerimdragolj/orgs","repos_url":"https://api.github.com/users/kerimdragolj/repos","events_url":"https://api.github.com/users/kerimdragolj/events{/privacy}","received_events_url":"https://api.github.com/users/kerimdragolj/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kerimdragolj/homeworks","description":"","fork":false,"url":"https://api.github.com/repos/kerimdragolj/homeworks","forks_url":"https://api.github.com/repos/kerimdragolj/homeworks/forks","keys_url":"https://api.github.com/repos/kerimdragolj/homeworks/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kerimdragolj/homeworks/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kerimdragolj/homeworks/teams","hooks_url":"https://api.github.com/repos/kerimdragolj/homeworks/hooks","issue_events_url":"https://api.github.com/repos/kerimdragolj/homeworks/issues/events{/number}","events_url":"https://api.github.com/repos/kerimdragolj/homeworks/events","assignees_url":"https://api.github.com/repos/kerimdragolj/homeworks/assignees{/user}","branches_url":"https://api.github.com/repos/kerimdragolj/homeworks/branches{/branch}","tags_url":"https://api.github.com/repos/kerimdragolj/homeworks/tags","blobs_url":"https://api.github.com/repos/kerimdragolj/homeworks/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kerimdragolj/homeworks/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kerimdragolj/homeworks/git/refs{/sha}","trees_url":"https://api.github.com/repos/kerimdragolj/homeworks/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kerimdragolj/homeworks/statuses/{sha}","languages_url":"https://api.github.com/repos/kerimdragolj/homeworks/languages","stargazers_url":"https://api.github.com/repos/kerimdragolj/homeworks/stargazers","contributors_url":"https://api.github.com/repos/kerimdragolj/homeworks/contributors","subscribers_url":"https://api.github.com/repos/kerimdragolj/homeworks/subscribers","subscription_url":"https://api.github.com/repos/kerimdragolj/homeworks/subscription","commits_url":"https://api.github.com/repos/kerimdragolj/homeworks/commits{/sha}","git_commits_url":"https://api.github.com/repos/kerimdragolj/homeworks/git/commits{/sha}","comments_url":"https://api.github.com/repos/kerimdragolj/homeworks/comments{/number}","issue_comment_url":"https://api.github.com/repos/kerimdragolj/homeworks/issues/comments{/number}","contents_url":"https://api.github.com/repos/kerimdragolj/homeworks/contents/{+path}","compare_url":"https://api.github.com/repos/kerimdragolj/homeworks/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kerimdragolj/homeworks/merges","archive_url":"https://api.github.com/repos/kerimdragolj/homeworks/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kerimdragolj/homeworks/downloads","issues_url":"https://api.github.com/repos/kerimdragolj/homeworks/issues{/number}","pulls_url":"https://api.github.com/repos/kerimdragolj/homeworks/pulls{/number}","milestones_url":"https://api.github.com/repos/kerimdragolj/homeworks/milestones{/number}","notifications_url":"https://api.github.com/repos/kerimdragolj/homeworks/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kerimdragolj/homeworks/labels{/name}","releases_url":"https://api.github.com/repos/kerimdragolj/homeworks/releases{/id}","created_at":"2015-06-26T10:21:13Z","updated_at":"2015-08-06T21:28:14Z","pushed_at":"2015-08-09T00:39:41Z","git_url":"git://github.com/kerimdragolj/homeworks.git","ssh_url":"git@github.com:kerimdragolj/homeworks.git","clone_url":"https://github.com/kerimdragolj/homeworks.git","svn_url":"https://github.com/kerimdragolj/homeworks","homepage":null,"size":8264,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kerimdragolj/homeworks/pulls/5"},"html":{"href":"https://github.com/kerimdragolj/homeworks/pull/5"},"issue":{"href":"https://api.github.com/repos/kerimdragolj/homeworks/issues/5"},"comments":{"href":"https://api.github.com/repos/kerimdragolj/homeworks/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/kerimdragolj/homeworks/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/kerimdragolj/homeworks/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kerimdragolj/homeworks/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/kerimdragolj/homeworks/statuses/489ce89f4b36e7fcac7e8752c4ee7f7f0e01abdb"}}}}