package aufgaben.b20160425; import java.awt.Color; import java.awt.Graphics; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; import javax.swing.JPanel; import javax.swing.JSpinner; import javax.swing.SpinnerNumberModel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import aufgaben.Aufgabe; import misc.Utils; public class Aufgabe3 extends Aufgabe { private final int width = 500, height = 500; private boolean done = false; private String name; private BufferedImage image, todraw; private JPanel panel; private JSpinner spinner; public Aufgabe3() { name = "Interpolation"; this.setSize(width, height); this.setTitle(name); this.addWindowListener( new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { System.out.println("close"); done = true; } } ); this.setLayout(null); } @Override public boolean done() { return done; } @Override public String getName() { return name; } @Override public void init() { panel = new JPanel(){ public void paint(Graphics g) { if(todraw != null) g.drawImage(todraw, 0, 0, this.getWidth(), this.getHeight(), this); } }; panel.setBounds(0, 100, width, height-100); spinner = new JSpinner(new SpinnerNumberModel(0, 0, 100, 1)); spinner.setBounds(100, 50, 100, 20); spinner.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { for(int x = 0; x= 0 && absoluteX < image.getWidth() && absoluteY >= 0 && absoluteY < image.getHeight()) { color = new Color(image.getRGB(absoluteX, absoluteY)); colori[0] += color.getRed(); colori[1] += color.getGreen(); colori[2] += color.getBlue(); c++; } } } return new Color(colori[0]/c, colori[1]/c, colori[2]/c); } }