From: git Date: Thu, 29 Jun 2017 11:30:20 +0000 (+0200) Subject: Updated Final X-Git-Url: http://git.risc.jku.at/gitweb/?a=commitdiff_plain;h=1a9882187fd37ba15de26fbc24dd4c107364b8b8;p=ipau%2FColorBlackWhiteConversion.git Updated Final --- diff --git a/Final/BlackandWhite.java b/Final/BlackandWhite.java new file mode 100644 index 0000000..1a046c7 --- /dev/null +++ b/Final/BlackandWhite.java @@ -0,0 +1,49 @@ +import java.awt.*; +import java.awt.image.BufferedImage; + +public class BlackandWhite { + + BufferedImage image; + int width; + int height; + + public BlackandWhite() + { + image = null; + width = 0; + height = 0; + } + + public BufferedImage Black_and_White(BufferedImage input_image) { + + try { + this.image = input_image; + width = image.getWidth(); + height = image.getHeight(); + + for(int i=0; i GUIComponent; + private String userinput = ""; + + boolean occupied = false; + boolean saved = false; + + ColorBlackWhiteConversionGUI() + { + int fill[] = { GridBagConstraints.BOTH, + GridBagConstraints.VERTICAL, + GridBagConstraints.HORIZONTAL, + GridBagConstraints.NONE}; + + int anchor[] = {GridBagConstraints.CENTER, + GridBagConstraints.EAST, + GridBagConstraints.SOUTHEAST, + GridBagConstraints.SOUTH, + GridBagConstraints.SOUTHWEST, + GridBagConstraints.WEST, + GridBagConstraints.NORTHWEST, + GridBagConstraints.NORTH, + GridBagConstraints.NORTHEAST}; + + String n[] = { "Input:", + "Output:", + "hint...", + "Load", + "BW", + "Gray", + "Save", + "Quit"}; + + name = n; + + //x, y, width, height, weight-x, weight-y, GridBagConstraints.fill, GridBagConstraints.anchor + int a[][] = {{0, 0, 1, 1, 0, 0, fill[3], anchor[5]}, //input (word) + {9, 0, 1, 1, 0, 0, fill[3], anchor[5]}, //output (word) + {0, 11, 7, 1, 0, 0, fill[3], anchor[5]}, //hint... (word) + + //Image field + {0, 1, 4, 8, 0, 0, fill[3], anchor[5]}, //input image + {9, 1, 4, 8, 0, 0, fill[3], anchor[1]}, //output image + + //Buttons + {0, 10, 1, 1, 0, 0, fill[3], anchor[0]}, //Load file button + {6, 6, 1, 1, 0, 0, fill[3], anchor[0]}, //Black and White button + {6, 7, 1, 1, 0, 0, fill[3], anchor[0]}, //Gray Scale button + {9, 10, 1, 1, 0, 0, fill[3], anchor[0]}, //Save file button + {9, 11, 1, 1, 0, 0, fill[2], anchor[0]}, //Quit button + + //Text field + {1, 10, 3, 1, 0, 0, fill[2], anchor[0]}, //Load file text + {10, 10, 3, 1, 0, 0, fill[2], anchor[0]} //Save file text + }; + + att = a; + + frame = new JFrame(); + frame.setTitle("Color Black White Conversion"); + frame.setSize(1200, 500); + frame.setLayout(new GridBagLayout()); + frame.setLocationRelativeTo(null); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + Output = new JPanel(); + Input = new JPanel(); + Input.setBackground(Color.RED); + Output.setBackground(Color.WHITE); + + GUIComponent = new ArrayList(15); + } + + public void run() + { + for (int i=0; i<3; i++) + { + JLabel nLabel = new JLabel(name[i]); + GUIComponent.add(nLabel); + } + + JScrollPane scrollPane = new JScrollPane(new JLabel(new ImageIcon(input_image))); // put input_Image into label + Input.add(scrollPane); + GUIComponent.add(Input); + + JScrollPane scrollPane2 = new JScrollPane(new JLabel(new ImageIcon(output_image))); //put output_Image into label + Output.add(scrollPane2); + GUIComponent.add(Output); + + //add Buttons + for (int k=3; k