// // // Author: B.Borchert, programmed Dec 30-31. 2006 import java.io.*; import java.net.*; import java.awt.*; import java.applet.*; import java.awt.event.*; import java.awt.image.*; public class vc extends Applet implements MouseListener, MouseMotionListener{ int pixelSize = 1; int ueberstand = 0; int offsetRand = 20; Label xpmLabel = new Label("Wg. Schreib-Restriktionen fuer applets: Die Bilder im .xpm-Format (mit cut+paste in eine Datei schreiben): Original Bild (links) und die verschluesselten Bilder 1 und 2"); int zweiteLinie = 200; String dummy[]; int xSize; int ySize; boolean original[][]; boolean randomFolie[][]; boolean zweiteFolie[][]; boolean normalPattern[][][] = {{{false,false}, {false,false}}, {{true ,true}, {true ,true}}}; boolean codePattern[][][] = {{{true, false}, {false,true}}, {{false,true}, {true, false}}}; // double-buffering trick, part 1 of 5, copied from http://www.realapplets.com/tutorial/DoubleBuffering.html Graphics bufferGraphics; Image offscreen; Dimension dim; int curX, curY; // ---- fuer die Maus: -------------------------------------- int lastX = 600; int lastY = 200; int xStretch = 0; int yStretch = 0; int downX = 0; int downY = 0; int beforeX = 0; int beforeY = 0; boolean hitArea = false; boolean hitCorner = false; // ---------------------------------------------------------------------------------------- public void init() { addMouseListener(this); addMouseMotionListener(this); setBackground(Color.white); // double-buffering trick, part 2 of 5, copied from http://www.realapplets.com/tutorial/DoubleBuffering.html dim = getSize(); offscreen = createImage(dim.width,dim.height); bufferGraphics = offscreen.getGraphics(); // default Bild einlesen: Bilder/dummy.xpm String dummy2 = ""; try { String anItem = ""; URL source = null; try{source = new URL(getCodeBase(), "Originalbild.xpm");} catch (MalformedURLException e) {}; BufferedReader in = new BufferedReader(new InputStreamReader(source.openStream())); do { anItem = in.readLine(); } while (anItem.charAt(0) != '"'); String header = anItem.substring(1,anItem.indexOf("\"",1)); xSize = Integer.parseInt(header.substring(0,header.indexOf(' '))); ySize = Integer.parseInt(header.substring(header.indexOf(' ')+1,header.indexOf(' ',header.indexOf(' ')+1))); original = new boolean[ySize][xSize]; in.readLine(); in.readLine(); int y = 0; while(null != (anItem = in.readLine())) { String neuItem = anItem.substring(1,anItem.indexOf("\"",1)); dummy2 += neuItem + "\n"; for (int x=0;x= 0 - xSize ) xStretch=newX; if (newY <= ySize && newY >= 0 - ySize ) yStretch=newY; repaint(); } } } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public void mouseClicked(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } public void mouseMoved(MouseEvent e) { } // --------------------------------------------------------------------------------------------------------------- // double-buffering trick, part 5 of 5, copied from http://www.realapplets.com/tutorial/DoubleBuffering.html public void update(Graphics g) { paint(g); } }