

-s2b2 .. only glider in hexLife ??

Ok, folks! .. here's the long promised 'Game Of Life - enhancement' for You ! I am pretty happy and proud to offer You a hexagonal implementation of the famous 'time-killer' - let's call it a 'beta-version' (cos' it's the first upload and still has minor imponderabilities and defectives) - ''HexLife, 1st upload''. ..
|
It's highly self-explaining and comes with .. o an algo handling ''on''-cells only, for faster performance, scanning ''on''-cell's neighbour's neighbours for births (instead of all cells). o It is as is best viewn with screen-resolution 1024x768, for it does'nt have any resizable Layout yet. o a bunch of 'ad hoc' collected patterns o its src-code, commented in 'pidgin germlish or engman' It was developed on piii, win'98, java j2sdk1.4.0_03-b04. |
|
some important hints for use: o tooltip tf1: plz untoggle tf1 (i-count and messages) for fast loading from file ! o plz do'nt click too fast ! (prog sometimes ca'nt handle yet) o major bug discovered! .. alas! .. .. sometimes prog 'vanishes' after many clicks or long time use .. ?! .. looks like whole prog is being auto-Garbage-collected .. ;o|:)) .. queer .. :o| (plz, do'nt blame! .. :o| .. ) o do single cell or two cells or triangle in center .. and then do 20 to 50 steps wit *b1* or *b2* , then ''pause'', then do s1345b3456 ! will it die or stay forever doing all possible ornaments? |
..
| Here's some few links to what I last found on this topic: another hexlife applet www.well.com/~dgb/hexlife.html hexatron, applet with Golay, Preston, Callahan and other distinct rules www.hexatron.com/hexca/ hexagonal applet www.cse.sc.edu/~bays/h6h6h6/ HexCells 1.0.1, nice little proggie with small zoom, but great patterns members.optusnet.com.au/thekingdoms/hexlife/ collidoscope, applet and screensaver, thirty days, then small limitations (even these may be gotten around) www.collidoscope.com/ca/hcat.html www.collidoscope.com/ .. applet www.antimodal.com/flash/hexlife/ .. [article:] www.complex-systems.com/pdf/15-3-4.pdf |
| a) send feedback b) send me gorgeous patterns or systematic pattern-element-collections c) alert me and the world, that you're still alive by mailing 'hullo?'' or alike .. ;o)) .. or even .. d) feel like participating in the next ''HexLife, 2nd upload'' to by doing so even come sooner and .. ''Please, send me one pound!'' by PayPal to christof.held@t-online.de. Any symbolic amount is welcome as palpable feedback to motivate me! .. :o) |
/* @(#) aus HexLife08Upload (aus HexLife07aRuleEdit) 1.4.0_03-b04 07/01/06 */
package myprojects.hexlife;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.imageio.ImageIO;
import java.io.File;
import java.io.IOException;
import java.io.*;
//import java.lang.Math;
//import java.lang.String;
public class HexLife1stUpload extends Frame
implements Runnable, MouseListener, MouseMotionListener, ActionListener, AdjustmentListener/*, ImageObserver */ {
// public Label alabel;
int i=0;
int x; int y;
Rectangle screenRect= new Rectangle(0,0,800,740); /* Carré ca. hoch 40 - 644, breit 20 - 623 (bei zoom 2x2pix) */
// File f=new File("c:/progeigene/JCreator/MyProjects/owndata/scrshot"/*+Integer.toString(i)*/+".jpg"); //toString(i) hier eh' immer ''0''
File f;
BufferedImage bi;
boolean relaxed=false; boolean onlyjuststarted=true;
Button pauserunbutton; String cmd=">"; boolean pausebool=false; boolean runbool=true;
Button gridbutton; boolean gridnew=true;
Button screenshotbutton; boolean shot=false;
Button clearbutton; Button pattbutton; boolean patt=false;
Button nillbutt; Button onebutt; Button fiftybutt; Button hundredbutt; Button thsdbutt; int stim=100;
Button toggibutt; boolean toggibool=true; Button togtipbutt; boolean togtipbool=true;/* false */
Button savpatbutt; Button loadpatsbutt; Button loadpatcbutt;
Button zoom2butt; Button zoom4butt; Button zoom6butt; Button zoom8butt; int zoom=4;
/* 2x2pix zoom=1 4x4pix zoom=2 6x6pix zoom=3 8x8pix zoom=4 */
Graphics mg; Graphics eg; Graphics sg;
Robot robo;
TextField tf1;
Component ec;
Color bgcol;
Checkbox cbs0; Checkbox cbs1; Checkbox cbs2; Checkbox cbs3; Checkbox cbs4; Checkbox cbs5; Checkbox cbs6; /* CheckBoxes survive */
Checkbox cbb0; Checkbox cbb1; Checkbox cbb2; Checkbox cbb3; Checkbox cbb4; Checkbox cbb5; Checkbox cbb6; /* CheckBoxes birth */
int ct=1; /* counter für Nachbarscan */
int[][] hexGrid=new int[620][620]; /* Werte: 1 - blacke AN-Zelle
2 - grüne Mauer-Zelle
10 - (bereits) auf (no)survive geprüfte AN-Zelle
11 - (bereits) auf (does)survive geprüfte AN-ZElle
30 - (bereits) auf (no)birth kontrollierte AUS-Zelle
31 - (bereits) auf (new)birth kontrollierte AUS-Zelle */
public File PattFile/*= new File("c:/progeigene/JCreator/MyProjects/stories/hexLife/SavedPattern"+i+".txt")*/; // +i.toString() .. ?
public RandomAccessFile randaff;
Button PattSaveMem1; Button PattLoadMem1; Button PattSaveMem2; Button PattLoadMem2;
int hexMem1[][]=new int[620][620]; int hexMem2[][]=new int[620][620];
boolean refreshGraphics=true;
Button rndPatt10; Button rndPatt20; Button rndPattL; /*Button rndPatt_O;*/ Button rndPatt_o; boolean rnd10bool; boolean rnd20bool; boolean rndLbool; /*boolean rnd_Obool;*/ boolean rnd_obool;
TextField tf2; Double tf2StringToDouble=new Double(0.0); Integer tf2StringToInteger=new Integer(0);
Color mygreen=new Color(0,120,0);
boolean dragbool;
TextField tf3; Integer tf3StringToInt=new Integer(0);
Image moos; Image xantho; Image flechte1; Image flechte13; Image flechte12; Image flechte_schuessel_fl; Image datronia_mollis; Image antarktisflechte; Image vomKirschbaum; Image daheim_Schneekristalle; Image naturSchneekristall; Image eiskristalle_Makro_41_HP;
MediaTracker mediatracker=new MediaTracker(this);
Scrollbar rndPixAmount; Scrollbar rndRadius;
TextField tf4; Integer tf4StringToInteger=new Integer(0);
Button pres1; Button pres2; Button pres3; Button pres4; Button pres5; Button pres6; Button pres7; Button pres8; Button pres9; Button pres10;
Button pcfro;/*paste then clear from center*/ boolean pcfro_bool=true; Button cfroul;/*copy from center to up left*/ Button cfrou; Button cfrour; Button cfrol; Button cfror; Button cfrodl; Button cfrod; Button cfrodr;
Button pcto;/*paste then clear to center*/ boolean pcto_bool=true; Button ctoul;/*copy to center from up left*/ Button ctou; Button ctour; Button ctol; Button ctor; Button ctodl; Button ctod; Button ctodr;
int hexCopy[][]=new int[610][610];
Button clearcenteronly;
/* schomma die rules definieren .. */
public boolean birthrule(int ct) {
if ( (ct==0 && cbb0.getState()==true) || (ct==1 && cbb1.getState()==true) || (ct==2 && cbb2.getState()==true) || (ct==3 && cbb3.getState()==true) || (ct==4 && cbb4.getState()==true) || (ct==5 && cbb5.getState()==true) || (ct==6 && cbb6.getState()==true) ) { return true; } else { return false; }
}
public boolean surviverule(int ct) {
if ( (ct==0 && cbs0.getState()==true) || (ct==1 && cbs1.getState()==true) || (ct==2 && cbs2.getState()==true) || (ct==3 && cbs3.getState()==true) || (ct==4 && cbs4.getState()==true) || (ct==5 && cbs5.getState()==true) || (ct==6 && cbs6.getState()==true) ) { return true; } else { return false; }
}
/*public void clearcells() { }*/
/* - - - STEP - - - */
public void step(Graphics sg) throws AWTException { if(toggibool==true){this.setTitle("HexLife1stUpload "+i);}
/* div. Kram für start oder debug */
/*if (cmd.equals("#")==false) { }*/ /*sg.translate(20,40); */
if(i==0) { for (int breit=1;breit<800;breit++) {
if (breit%10==0) { sg.drawLine(breit,25,breit,27); }
if (breit%50==0) { sg.drawLine(breit,25,breit,29); }
if (breit%100==0) { sg.setColor(Color.red); sg.drawLine(breit,25,breit,31); sg.setColor(Color.black); }}
for (int hoch=1;hoch<740;hoch++) {
if (hoch%10==0) { sg.drawLine(5,hoch,7,hoch); }
if (hoch%50==0) { sg.drawLine(5,hoch,9,hoch); }
if (hoch%100==0) { sg.setColor(Color.red); sg.drawLine(5,hoch,11,hoch); sg.setColor(Color.black); }}
}
sg.setColor(Color.black);
if(i==0||i==1||cmd=="c"||refreshGraphics==true|| cmd=="2p"||cmd=="4p"||cmd=="6p"||cmd=="8p"||cmd==">"/*or.. or WindowFocusGained==true or nosebud==false, but not every step or i-count. yeah! */) {
sg.drawString("survive",625,475); sg.drawString("rule",630,490); sg.drawString(" birth",675,475); sg.drawString("rule",680,490);
sg.drawString("%",767,325); sg.drawString("pix",748,205); sg.drawString("presets",740,475);
sg.drawString("copy",700,340); sg.drawString("fro",660,355); sg.drawString("or",705,355); sg.drawString("to",745,355); sg.drawString("center",695,450);
}
robo=new Robot();
i++;
/* routine für clearbutton */
if (cmd=="c") { /*getGraphics()*/sg.setColor(Color.lightGray); /* malen bzw darstellen nur den zoom-Bereich: */
if(zoom!=1){ for (int p=300-300/zoom/*1*/;p<300+300/zoom/*300*/;++p) { for (int q=300-300/zoom/*2*/;q<300+300/zoom/*300*//* && q%2==0*/;++q/*+=2*/) { /* geht vlt nur p,q = 0 und clearRect ganzes Carré ? */
/**/if (hexGrid[p][q]!=0) { /*getGraphics()*/sg./*fillRect*/fillOval(zoom/*2*/*(p-(300-300/zoom))+20-zoom,zoom/*2*/*(q-(300-300/zoom))+40-zoom,2*zoom,2*zoom); }
}}}else{for (int p=0;p<=600;++p) { for (int q=0;q<=600;q+=2/*++*/) { /* geht vlt nur p,q = 0 und clearRect ganzes Carré ? */
/**/if (hexGrid[p][q]!=0) { sg.fillRect(p+19,q+39/* ?! */,2,2); }
}}} /* ausradieren auch gesamten, auch nicht sichtbaren hexGrid[][] außerhalb zoom: */
for (int p=0;p<=600;++p) { for (int q=0;q<=600/* && q%2==0*/;q+=2/*++*/) {
/**/if (hexGrid[p][q]!=0) { hexGrid[p][q]=0; }
}} }
/* .. die eigentliche run() STEP Routine */
if (runbool==true || refreshGraphics==true) { if(toggibool==true) { tf1.setText("running .. i="+i); }
/* grid neu malen, wenn start oder gridbutton geklickt */
if (gridnew==/*i==1||cmd=="#"*/true || refreshGraphics==true) { int zc=300-300/zoom; int wh=2*zoom;
for (x=300-300/zoom/*0*/;x<=300+300/zoom/*300*/;++x) { for (y=300-300/zoom/*0*/;y<=300+300/zoom/*300*/; ++y) { /* ein Schachspringer-Gitter wird mit Kreisen bemalt */
if ( (y%4==0 && x%2==0) || (y%2==0 && y%4!=0 && x%2!=0) ) { if(zoom!=1){ sg.setColor(Color.lightGray);/*}*/ sg./*drawRect*/drawOval(zoom/*2*/*(x-zc)+20-zoom,zoom/*2*/*(y-zc)+40-zoom,wh,wh); } }
if (hexGrid[x][y]==1) { sg.setColor(Color.black); sg./*fillRect*/fillOval(zoom/*2*/*(x-zc)+20-zoom,zoom/*2*/*(y-zc)+40-zoom,wh,wh); }
/*if (hexGrid[x][y]==2) { sg.setColor(Color.green); sg.fillRect(2*x+20,2*y+40,4,4); }*/
}} if (i==1) { if(toggibool==true) { tf1.setText("draw, then press ''>'' to iterate .. i="+i); } } if (i==1 /*|| cmd=="#"*/) { pausebool=true; runbool=false; return; } gridnew=false;
}
/* screenshot machen, wenn "S"-Button geklickt */
if (shot==true) {
try { bi=robo.createScreenCapture(screenRect); }catch(SecurityException sex) {}
// try { ImageIO.write(bi,"jpg",f); }catch(IOException ioex) {}
/* .. ! Achtung ! .. screenshots akkumulieren (nach i benannt) unbemerkt und nehmen Festplattenplatz auf C: .. ! .. wenn: */
// try { ImageIO.write(bi,"jpg",new File("c:/progeigene/JCreator/MyProjects/owndata/scrshot"+Integer.toString(i)+".jpg")); }catch(IOException ioex) {}
try { ImageIO.write(bi,"jpg",new File("scrshot"+Integer.toString(i)+".jpg")); }catch(IOException ioex) {}
// try { ImageIO.write(bi,"jpg",new File(/**/"../screenshotSe/scrshot"+Integer.toString(i)+".jpg")); }catch(IOException ioex) {}
/* .. letzteres = error FileNotFoundException .. */
shot=false;
}
/* random pattern in center */
/* nur dem hexGrid Zufallswerte zuweisen, die dann automatisch gezoomt, iteriert und dargestellt werden müßten ..
* .. aber hexGrid[][] muß richtig 'getroffen werden (nur jedes zweite Pixel x,y im Fenster ist Element von hexGrid)
* zwar mit Versatz je nach x od y .. ?? */
if (rnd10bool==true) { for (x=295;x<=305;++x/*+=2*/) { for (y=294;y<=304;y+=2/*++*/) {
if(( y %4==0 && x %2==0) || ( y %2==0 && y %4!=0 && x %2!=0) ) { hexGrid[x][y]=(int)(Math.random()+0.3); }
/* Math.random() liefert double 0,00-1,00 .. und ''(int)'' rundet ab: ''+n''
* zB 0.3 bewirkt, daß (int)(0.69+0.3)=0 (int)(0,70+0.3)=1 */
} } rnd10bool=false; }
if (rnd20bool==true) { for (x=291;x<=311;++x/*+=2*/) { for (y=290;y<=310;y+=2/*++*/) {
if(( y %4==0 && x %2==0) || ( y %2==0 && y %4!=0 && x %2!=0) ) { hexGrid[x][y]=(int)(Math.random()+0.3); }
} } rnd20bool=false; }
/* random horizontal bars resp. rectangles */
if (rndLbool==true) { if(toggibool==true){ tf1.setText("loading .. PLZ WAIT ! ");} int rad=rndRadius.getValue();
for (x=51;x<=551;++x/*+=2*/) { for (y=300-rad;y<=300+rad;++y/*+=2*/) {
if(( y %4==0 && x %2==0) || ( y %2==0 && y %4!=0 && x %2!=0) ) {
hexGrid[x][y]=(int)(Math.random()+(double)(rndPixAmount.getValue())/150 ); } /* '' /150 '', da getValue() = 0 - 150 */
} } tf1.setText("ok"); rndLbool=false; } /* .. aber gewollt in Prozent */
/* draw random ring, custom thick */
if (rnd_obool==true) { if(toggibool==true){tf1.setText("loading .. PLZ WAIT ! ");} int rad=rndRadius.getValue();/*(int)(tf4StringToInteger.valueOf(tf4.getText()).intValue()*//*);*/
for(int x=1; x<600; ++x) { for(int y=2; y<600; y+=2) { /* rad = custom radius-'spread' from tf3 user-input .. not */
if( ( y %4==0 && x %2==0) || ( y %2==0 && y %4!=0 && x %2!=0) ) { /* ..inner-outer Radius which is 150+-rad */
if ( x < 300+(int)(Math.sqrt(Math.pow(150+rad,2)-Math.pow(y-300,2))) && /* ''300+-'' ab Kreis um Nullpunkt */
x > 300-(int)(Math.sqrt(Math.pow(150+rad,2)-Math.pow(y-300,2))) && /* ''x,y -300'' für Werte ab Zentrum 300,300 */
(y > 300+(int)(Math.sqrt(Math.pow(150-rad,2)-Math.pow(x-300,2))) || /* ''150+-rad'' Radius1=150+rad .. */
y < 300-(int)(Math.sqrt(Math.pow(150-rad,2)-Math.pow(x-300,2))) ) ) { /* Radius2=150-rad .. rad=Spanne, spread */
//// hexGrid [ x ] [ y ] = (int)(Math.random()+(double)(tf2StringToDouble.valueOf(tf2.getText()).doubleValue())); /* ?! */
//// hexGrid [ x ] [ y ] = (int)(Math.random()+(double)(tf2StringToDouble.valueOf(tf2.getText()).doubleValue())); /* no 'NumberField' in java .. ;o] */
hexGrid [ x ] [ y ] = (int)( Math.random()+(double)(rndPixAmount.getValue())/150 );
/* f(x) = Wurzel( radius^2 - x^2 ) .. Halbkreis um Nullpunkt
* entspricht: y = Math.sqrt( .. ) - '' -
* also .. hexGrid [ x ] [ Math.sqrt(..) ] = Math.rnd( 1 oder 0 ) - '' - als rnd
* .. not all random, 'cos Sqrt(x^2) and y+=2 involved */
} } } } if(toggibool==true){tf1.setText("ok");} rnd_obool=false; } /* if(toggibool==true) { tf1.setText("loading .. hexGrid [ "+x+" ][ "+y+" ] = "+hexGrid[x][y]);}*/
/* Der sb-algo: */
/* ersma' die Nachbarn zählen ..
* erst die der an eine lebende Zelle angrenzenden Leerstellen für births */
/* (es müssen schon sehr viele Zellen an sein, um ein scan aller leeren Zellen auf birth hin lohnend zu machen) */
if(refreshGraphics==false) {
for (int j=5; j<600; ++j) { for (int k=6; k<600; k+=2) {
if (birthrule(0)) {
if (hexGrid[j][k]==0) { /* außschließlich für b0 */
if ( (hexGrid[j-1][k-2]==0 || hexGrid[j-1][k-2]==30 || hexGrid[j-1][k-2]==31) &&
(hexGrid[j-2][k] ==0 || hexGrid[j-2][k] ==30 || hexGrid[j-2][k] ==31) &&
(hexGrid[j-1][k+2]==0 || hexGrid[j-1][k+2]==30 || hexGrid[j-1][k+2]==31) &&
(hexGrid[j+1][k+2]==0 || hexGrid[j+1][k+2]==30 || hexGrid[j+1][k+2]==31) &&
(hexGrid[j+2][k] ==0 || hexGrid[j+2][k] ==30 || hexGrid[j+2][k] ==31) &&
(hexGrid[j+1][k-2]==0 || hexGrid[j+1][k-2]==30 || hexGrid[j+1][k-2]==31) ) { ct=0; }
if (birthrule(ct)) { hexGrid[j][k]=31; ct=1; } else { ct=1; }
} }
if (hexGrid[j][k]==1 || hexGrid[j][k]==10 || hexGrid[j][k]==11) { /* die 'Ausgangszelle' */
if (hexGrid[j-1][k-2]==0) { /* erste angrenzende (obli) aus-Zelle, die jetzt auf birth geprüft wird */
if (hexGrid[j-2][k-4]==1 || hexGrid[j-2][k-4]==10 || hexGrid[j-2][k-4]==11) { ct+=1; }
/* 2, weil Ausgangszelle is' ja für ihren leeren Nachbar schon ein Nachbar */
if (hexGrid[j-3][k-2]==1 || hexGrid[j-3][k-2]==10 || hexGrid[j-3][k-2]==11) { ct+=1; }
if (hexGrid[j-2][k] ==1 || hexGrid[j-2][k] ==10 || hexGrid[j-2][k] ==11) { ct+=1; }
if (hexGrid[j+1][k-2]==1 || hexGrid[j+1][k-2]==10 || hexGrid[j+1][k-2]==11) { ct+=1; }
if (hexGrid[j] [k-4]==1 || hexGrid[j] [k-4]==10 || hexGrid[j] [k-4]==11) { ct+=1; }
/* jetzt schon - bei jeder geprüften Zelle - entscheidet birthrule, ob die Nachbaranzahl sich auswirkt */
if (birthrule(ct)) { hexGrid[j-1][k-2]=31; ct=1; } else { hexGrid[j-1][k-2]=30; ct=1; } }
if (hexGrid[j-2][k]==0) { /* li */
if (hexGrid[j-3][k-2]==1 || hexGrid[j-3][k-2]==10 || hexGrid[j-3][k-2]==11) { ct+=1; }
if (hexGrid[j-4][k] ==1 || hexGrid[j-4][k] ==10 || hexGrid[j-4][k] ==11) { ct+=1; }
if (hexGrid[j-3][k+2]==1 || hexGrid[j-3][k+2]==10 || hexGrid[j-3][k+2]==11) { ct+=1; }
if (hexGrid[j-1][k+2]==1 || hexGrid[j-1][k+2]==10 || hexGrid[j-1][k+2]==11) { ct+=1; }
if (hexGrid[j-1][k-2]==1 || hexGrid[j-1][k-2]==10 || hexGrid[j-1][k-2]==11) { ct+=1; }
if (birthrule(ct)) { hexGrid[j-2][k]=31; ct=1; } else { hexGrid[j-2][k]=30; ct=1; } }
if (hexGrid[j-1][k+2]==0) { /* liun */
if (hexGrid[j-2][k] ==1 || hexGrid[j-2][k] ==10 || hexGrid[j-2][k] ==11) { ct+=1; }
if (hexGrid[j-3][k+2]==1 || hexGrid[j-3][k+2]==10 || hexGrid[j-3][k+2]==11) { ct+=1; }
if (hexGrid[j-2][k+4]==1 || hexGrid[j-2][k+4]==10 || hexGrid[j-2][k+4]==11) { ct+=1; }
if (hexGrid[j] [k+4]==1 || hexGrid[j] [k+4]==10 || hexGrid[j] [k+4]==11) { ct+=1; }
if (hexGrid[j+1][k+2]==1 || hexGrid[j+1][k+2]==10 || hexGrid[j+1][k+2]==11) { ct+=1; }
if (birthrule(ct)) { hexGrid[j-1][k+2]=31; ct=1; } else { hexGrid[j-1][k+2]=30; ct=1; } }
if (hexGrid[j+1][k+2]==0) { /* reun */
if (hexGrid[j-1][k+2]==1 || hexGrid[j-1][k+2]==10 || hexGrid[j-1][k+2]==11) { ct+=1; }
if (hexGrid[j] [k+4]==1 || hexGrid[j] [k+4]==10 || hexGrid[j] [k+4]==11) { ct+=1; }
if (hexGrid[j+2][k+4]==1 || hexGrid[j+2][k+4]==10 || hexGrid[j+2][k+4]==11) { ct+=1; }
if (hexGrid[j+3][k+2]==1 || hexGrid[j+3][k+2]==10 || hexGrid[j+3][k+2]==11) { ct+=1; }
if (hexGrid[j+2][k] ==1 || hexGrid[j+2][k] ==10 || hexGrid[j+2][k] ==11) { ct+=1; }
if (birthrule(ct)) { hexGrid[j+1][k+2]=31; ct=1; } else { hexGrid[j+1][k+2]=30; ct=1; } }
if (hexGrid[j+2][k]==0) { /* re */
if (hexGrid[j+1][k-2]==1 || hexGrid[j+1][k-2]==10 || hexGrid[j+1][k-2]==11) { ct+=1; }
if (hexGrid[j+1][k+2]==1 || hexGrid[j+1][k+2]==10 || hexGrid[j+1][k+2]==11) { ct+=1; }
if (hexGrid[j+3][k+2]==1 || hexGrid[j+3][k+2]==10 || hexGrid[j+3][k+2]==11) { ct+=1; }
if (hexGrid[j+4][k] ==1 || hexGrid[j+4][k] ==10 || hexGrid[j+4][k] ==11) { ct+=1; }
if (hexGrid[j+3][k-2]==1 || hexGrid[j+3][k-2]==10 || hexGrid[j+3][k-2]==11) { ct+=1; }
if (birthrule(ct)) { hexGrid[j+2][k]=31; ct=1; } else { hexGrid[j+2][k]=30; ct=1; } }
if (hexGrid[j+1][k-2]==0) { /* reob */
if (hexGrid[j] [k-4]==1 || hexGrid[j] [k-4]==10 || hexGrid[j] [k-4]==11) { ct+=1; }
if (hexGrid[j-1][k-2]==1 || hexGrid[j-1][k-2]==10 || hexGrid[j-1][k-2]==11) { ct+=1; }
if (hexGrid[j+2][k] ==1 || hexGrid[j+2][k] ==10 || hexGrid[j+2][k] ==11) { ct+=1; }
if (hexGrid[j+3][k-2]==1 || hexGrid[j+3][k-2]==10 || hexGrid[j+3][k-2]==11) { ct+=1; }
if (hexGrid[j+2][k-4]==1 || hexGrid[j+2][k-4]==10 || hexGrid[j+2][k-4]==11) { ct+=1; }
if (birthrule(ct)) { hexGrid[j+1][k-2]=31; } else { hexGrid[j+1][k-2]=30; } }
/* jetzt die der lebenden Zelle selbst für survive */
ct=0; /* ! */
if (hexGrid[j-1][k-2]==1 || hexGrid[j-1][k-2]==10 || hexGrid[j-1][k-2]==11) { ct+=1; }
if (hexGrid[j-2][k] ==1 || hexGrid[j-2][k] ==10 || hexGrid[j-2][k] ==11) { ct+=1; }
if (hexGrid[j-1][k+2]==1 || hexGrid[j-1][k+2]==10 || hexGrid[j-1][k+2]==11) { ct+=1; }
if (hexGrid[j+1][k+2]==1 || hexGrid[j+1][k+2]==10 || hexGrid[j+1][k+2]==11) { ct+=1; }
if (hexGrid[j+2][k] ==1 || hexGrid[j+2][k] ==10 || hexGrid[j+2][k] ==11) { ct+=1; }
if (hexGrid[j+1][k-2]==1 || hexGrid[j+1][k-2]==10 || hexGrid[j+1][k-2]==11) { ct+=1; }
if (surviverule(ct)) { hexGrid[j][k]=11; ct=1; } else { hexGrid[j][k]=10; ct=1; }
} }} } /* End ..if hexGrid[Ausgangszelle] ..forfor j,k .. if-refreshGraphics */
/* Ende sb-algo */
/* noch alle Teile malen je nach Wert und Zwischenwerte zurückübersetzen */
for (int n=1/*1*/;n<=600/*300*/;++n) { for (int m=2/*2*/;m<=600/*300*//* && m%2==0*/;m+=2) {
/* all cells 1 to 600 value hexGrid [x][y]= 10, 30, 11, 31 must be reset to 1 or 0 (on / off) .. */
if (hexGrid[n][m]==11 || hexGrid[n][m]==31) {
if (n>=300-300/zoom && n<=300+300/zoom && m>=300-300/zoom && m<=300+300/zoom) {
/* .. but draw and erase only zoom-area. */
sg.setColor(/*Color.*/mygreen); if(zoom!=1) { sg./*fillRect*/fillOval(zoom/*2*/*(n-(300-300/zoom))+20-zoom,zoom/*2*/*(m-(300-300/zoom))+40-zoom,2*zoom,2*zoom); }
else { sg./*fillOval*/fillRect(zoom/*2*/*(n-(300-300/zoom))+20-zoom,zoom/*2*/*(m-(300-300/zoom))+40-zoom,2*zoom,2*zoom); }
} hexGrid[n][m]=1; }
if (hexGrid[n][m]==10||hexGrid[n][m]==77) {
if (n>=300-300/zoom && n<=300+300/zoom && m>=300-300/zoom && m<=300+300/zoom) {
sg.setColor(Color.lightGray/*gray*/); if(zoom!=1) { sg./*fillRect*/fillOval(zoom/*2*/*(n-(300-300/zoom))+20-zoom,zoom/*2*/*(m-(300-300/zoom))+40-zoom,2*zoom,2*zoom);}
else { sg./*fillOval*/fillRect(zoom/*2*/*(n-(300-300/zoom))+20-zoom,zoom/*2*/*(m-(300-300/zoom))+40-zoom,2*zoom,2*zoom); }
} hexGrid[n][m]=0; }
if (hexGrid[n][m]==30) { hexGrid[n][m]=0; } /* (off-cells, scanned 'not newborn' -> nothing to draw or erase here) */
}}
/*if(refreshGraphics==true) { i-=1; }*/ refreshGraphics=false;
try { Thread.sleep(steptakt(stim)); } catch(InterruptedException e) { }
} } /* End ..if-runbool==true .. step() */
/* ENDE STEP */
public void run() { while(true) { if (i==0 || runbool==true) { /*try {*/try { step(getGraphics()); }catch(AWTException awex){ tf1.setText("awex caught from run()-step()"+i); try{Thread.sleep(500);}catch(InterruptedException ie){} }/*}*/catch(ArrayIndexOutOfBoundsException aioobe){ tf1.setText("aioobe caught"+i); try{Thread.sleep(500);}catch(InterruptedException ie){} } } } }
/* draw with clicks */
public void mousePressed(MouseEvent e) {
x=((e.getX())-20+zoom)/zoom+(300-300/zoom)/* /2 2 */; y=((e.getY())-40+zoom)/zoom+(300-300/zoom)/* /2 2 */;
if (x>300-300/zoom/*0*/ && x<300+300/zoom/*300*/ && y>300-300/zoom/*0*/ && y<300+300/zoom/*300*/) {
mg=getGraphics(); /*mg.translate(20,40);*/
if(( y %4==0 && x %2==0) || ( y %2==0 && y %4!=0 && x %2!=0) ) { if (hexGrid[x] [y] ==0) { hexGrid[x] [y] =1; dragbool=true; mg.setColor(Color.black/*green*/); mg./*fillRect*/fillOval(zoom/*2*/* (x-(300-300/zoom)) +20-zoom,zoom/*2*/* (y-(300-300/zoom)) +40-zoom,2*zoom,2*zoom); }else{ hexGrid[x] [y] =0; dragbool=false; mg.setColor(Color.lightGray); mg./*fillRect*/fillOval(zoom/*2*/* (x-(300-300/zoom)) +20-zoom,zoom/*2*/* (y-(300-300/zoom)) +40-zoom,2*zoom,2*zoom); } }
if(( y %4==0 && (x-1)%2==0) || ( y %2==0 && y %4!=0 && (x-1)%2!=0) ) { if (hexGrid[x-1][y] ==0) { hexGrid[x-1][y] =1; dragbool=true; mg.setColor(Color.black/*green*/); mg./*fillRect*/fillOval(zoom/*2*/*(x-1-(300-300/zoom))+20-zoom,zoom/*2*/* (y-(300-300/zoom)) +40-zoom,2*zoom,2*zoom); }else{ hexGrid[x-1][y] =0; dragbool=false; mg.setColor(Color.lightGray); mg./*fillRect*/fillOval(zoom/*2*/*(x-1-(300-300/zoom))+20-zoom,zoom/*2*/* (y-(300-300/zoom)) +40-zoom,2*zoom,2*zoom); } }
if(((y-1)%4==0 && x %2==0) || ((y-1)%2==0 && (y-1)%4!=0 && x %2!=0) ) { if (hexGrid[x] [y-1]==0) { hexGrid[x] [y-1]=1; dragbool=true; mg.setColor(Color.black/*green*/); mg./*fillRect*/fillOval(zoom/*2*/* (x-(300-300/zoom)) +20-zoom,zoom/*2*/*(y-1-(300-300/zoom))+40-zoom,2*zoom,2*zoom); }else{ hexGrid[x] [y-1]=0; dragbool=false; mg.setColor(Color.lightGray); mg./*fillRect*/fillOval(zoom/*2*/* (x-(300-300/zoom)) +20-zoom,zoom/*2*/*(y-1-(300-300/zoom))+40-zoom,2*zoom,2*zoom); } }
if(((y-1)%4==0 && (x-1)%2==0) || ((y-1)%2==0 && (y-1)%4!=0 && (x-1)%2!=0) ) { if (hexGrid[x-1][y-1]==0) { hexGrid[x-1][y-1]=1; dragbool=true; mg.setColor(Color.black/*green*/); mg./*fillRect*/fillOval(zoom/*2*/*(x-1-(300-300/zoom))+20-zoom,zoom/*2*/*(y-1-(300-300/zoom))+40-zoom,2*zoom,2*zoom); }else{ hexGrid[x-1][y-1]=0; dragbool=false; mg.setColor(Color.lightGray); mg./*fillRect*/fillOval(zoom/*2*/*(x-1-(300-300/zoom))+20-zoom,zoom/*2*/*(y-1-(300-300/zoom))+40-zoom,2*zoom,2*zoom); } }
// repaint();
} }
public void mouseClicked(MouseEvent e) {}
public void mouseReleased(MouseEvent e) { relaxed=true; }
/* Tooltips */
public void mouseEntered(MouseEvent e) {
if(togtipbool==true) {
mg=getGraphics(); ec=e.getComponent();
if (ec==screenshotbutton) { mg.setColor(new Color(255,255,255,110)); mg.fillRect(400,655,380,70); mg.setColor(Color.black); mg.drawString("makes a screenshot.jpg saved to program's directory",410,670); }
if (ec==gridbutton) { mg.setColor(new Color(255,255,255,110)); mg.fillRect(400,655,380,70); mg.setColor(Color.black); mg.drawString("gridbutton repaints grid if necessary",410,670); mg.drawString("(re-zooming does similar)",430,690); }
if (ec==clearbutton) { mg.setColor(new Color(255,255,255,110)); mg.fillRect(400,655,380,70); mg.setColor(Color.black); mg.drawString("clear whole Pattern",410,670); }
if (ec==nillbutt||ec==onebutt||ec==fiftybutt||ec==hundredbutt) { mg.setColor(new Color(255,255,255,110)); mg.fillRect(400,655,380,70); mg.setColor(Color.black); mg.drawString("speedbuttons",410,670); }
if (ec==thsdbutt) { mg.setColor(new Color(255,255,255,110)); mg.fillRect(400,655,380,70); mg.setColor(Color.black); mg.drawString("speedbuttons",410,670); mg.drawString("use this one + run-pause-run-pause.. ",410,690); mg.drawString("to run single steps",420,710); }
if (ec==toggibutt) { mg.setColor(new Color(255,255,255,110)); mg.fillRect(400,655,380,70); mg.setColor(Color.black); mg.drawString("toggle i-count and messages on / off",410,670); mg.drawString("untoggling will load from file much faster!",410,670); }
if (ec==togtipbutt) { mg.setColor(new Color(255,255,255,110)); mg.fillRect(400,655,380,70); mg.setColor(Color.black); mg.drawString("toggle tooltips on / off",410,670); }
if (ec==savpatbutt) { mg.setColor(new Color(255,255,255,110)); mg.fillRect(400,655,380,70); mg.setColor(Color.black); mg.drawString("save actual pattern together with current sb-rule (to ''classes''-folder)",410,670); mg.drawString("see cyan tf3 on how to type desired filename",410,690); }
if (ec==loadpatsbutt) { mg.setColor(new Color(255,255,255,110)); mg.fillRect(400,655,380,70); mg.setColor(Color.black); mg.drawString("load pattern with its saved sb-rule",410,670); mg.drawString("( that's why you saved it for with its rule )",420,690); mg.drawString("see cyan tf3 on how to choose filename to load",420,710); }
if (ec==loadpatcbutt) { mg.setColor(new Color(255,255,255,110)); mg.fillRect(400,655,380,70); mg.setColor(Color.black); mg.drawString("load pattern with current sb-rule",410,670); mg.drawString("( that's why you chose a rule below )",420,690); mg.drawString("see cyan tf3 on how to choose filename to load",420,710); }
if (ec==zoom2butt) { mg.setColor(new Color(255,255,255,110)); mg.fillRect(400,655,380,70); mg.setColor(Color.black); mg.drawString("zoom to 2x2 pixels per cell",410,670); }
if (ec==zoom4butt) { mg.setColor(new Color(255,255,255,110)); mg.fillRect(400,655,380,70); mg.setColor(Color.black); mg.drawString("unzoom back to 4x4 pixels per cell",410,670); }
if (ec==zoom6butt) { mg.setColor(new Color(255,255,255,110)); mg.fillRect(400,655,380,70); mg.setColor(Color.black); mg.drawString("zoom to 6x6 pixels per cell",410,670); }
if (ec==zoom8butt) { mg.setColor(new Color(255,255,255,110)); mg.fillRect(400,655,380,70); mg.setColor(Color.black); mg.drawString("zoom to 8x8 pixels per cell",410,670); }
if (ec==PattSaveMem1||ec==PattLoadMem1||ec==PattSaveMem2||ec==PattLoadMem2) { mg.setColor(new Color(255,255,255,110)); mg.fillRect(400,655,380,70); mg.setColor(Color.black); mg.drawString("fast save to and load from memory",410,670); mg.drawString("( not to file .. discarded after Window close )",420,700); }
if (ec==rndPatt10||ec==rndPatt20) { mg.setColor(new Color(255,255,255,110)); mg.fillRect(400,655,380,70); mg.setColor(Color.black); mg.drawString("generate random pattern n*n in the center",410,670); }
if (ec==rndPattL) { mg.setColor(new Color(255,255,255,110)); mg.fillRect(400,655,380,70); mg.setColor(Color.black); mg.drawString("generate random bar resp. rectangle (adds it)",410,670); mg.drawString("use scrollbars or textfields to adjust",420,690); mg.drawString("its size and amount of pixels",420,710); }
if (ec==rndPatt_o) { mg.setColor(new Color(255,255,255,110)); mg.fillRect(400,655,380,70); mg.setColor(Color.black); mg.drawString("generate big random ring (adds it)",410,670); mg.drawString("type thickness of ring between",420,685); mg.drawString(" 1 and 150 to tf4 or use scrollbar",420,700); mg.drawString("use 1 for 1pix-circle",420,715); }
if (ec==rndPixAmount) { mg.setColor(new Color(255,255,255,110)); mg.fillRect(400,655,380,70); mg.setColor(Color.black); mg.drawString("%-amount of random ''on'' cells",410,670); }
if (ec==rndRadius) { mg.setColor(new Color(255,255,255,110)); mg.fillRect(400,655,380,70); mg.setColor(Color.black); mg.drawString("thickness of random pattern in pixels",410,670); }
if (ec==tf2) { mg.setColor(new Color(255,255,255,110)); mg.fillRect(400,655,380,70); mg.setColor(Color.black); mg.drawString("tf2 for %-amount of random ''on'' cells",410,670); mg.drawString("( hit ''Enter'' to validate )",430,690); }
if (ec==tf4) { mg.setColor(new Color(255,255,255,110)); mg.fillRect(400,655,380,70); mg.setColor(Color.black); mg.drawString("tf4 for thickness of random pattern in pixels",410,670); mg.drawString("( hit ''Enter'' to validate )",430,690); }
if (ec==tf3) { mg.setColor(new Color(255,255,255,110)); mg.fillRect(400,655,380,70); mg.setColor(Color.black); mg.drawString("TextField 'tf3' for entering filename before saving or loading",410,670); mg.drawString("will save as / load from ''SavedPattern'' + [..] + ''.txt''",420,685); mg.drawString("eg. input ''-s2b23'' will save as / load from ''SavedPattern-s2b23.txt''",420,700); mg.drawString("! Attention ! .. saving will overwrite!",420,715); }
if (ec==cbs0||ec==cbb0||ec==cbs6||ec==cbb6) { mg.setColor(new Color(255,255,255,110)); mg.fillRect(400,655,380,70); mg.setColor(Color.black); mg.drawString("choose any, some or no rule(s) for survival of 'on' cells",410,670); mg.drawString("and/or birth of 'off' cells, depending on",420,690); mg.drawString("the number of their 'on' neighbours",420,710); }
if (ec==pcfro||ec==cfroul||ec==cfrou||ec==cfrour||ec==cfrol||ec==cfror||ec==cfrodl||ec==cfrod||ec==cfrodr) { mg.setColor(new Color(255,255,255,110)); mg.fillRect(400,655,380,70); mg.setColor(Color.black); mg.drawString("copy center area ( 200x200 like zoom 6p )",410,670); mg.drawString("to upleft, right, downleft or downuprightleftnose",420,690); mg.drawString("use center button to toggle 'clear or not' center after copying",410,710); }
if (ec==pcto||ec==ctoul||ec==ctou||ec==ctour||ec==ctol||ec==ctor||ec==ctodl||ec==ctod||ec==ctodr) { mg.setColor(new Color(255,255,255,110)); mg.fillRect(400,655,380,70); mg.setColor(Color.black); mg.drawString("copy outer area upleftdownright ( 200x200 like center-zoom 6p )",410,670); mg.drawString("to center .. use center button to toggle 'clear or not'",420,690); mg.drawString("outer area after toggling .. errhh! .. copying! *gosh* ¦o))",420,710); }
if (ec==pres1||ec==pres2||ec==pres3||ec==pres4||ec==pres5||ec==pres6||ec==pres7||ec==pres8||ec==pres9||ec==pres10) { mg.setColor(new Color(255,255,255,110)); mg.fillRect(400,655,380,70); mg.setColor(Color.black); mg.drawString("changing presets or rules while running may",410,670); mg.drawString("disturb iteration algorithm .. especially at high speed.",410,690); mg.drawString("better use pause when running big symmetric structures",410,710); }
if (ec==clearcenteronly) { mg.setColor(new Color(255,255,255,110)); mg.fillRect(400,655,380,70); mg.setColor(Color.black); mg.drawString("clear center only (for pasting from outer areas)",410,670); }
// if (ec==) { mg.setColor(new Color(255,255,255,110)); mg.fillRect(400,655,380,70); mg.setColor(Color.black); mg.drawString(" .. ",410,670); }
// if (ec==) { mg.setColor(new Color(255,255,255,110)); mg.fillRect(400,655,380,70); mg.setColor(Color.black); mg.drawString(" .. ",410,670); }
// if (ec==) { mg.setColor(new Color(255,255,255,110)); mg.fillRect(400,655,380,70); mg.setColor(Color.black); mg.drawString(" .. ",410,670); }
// if (ec==) { mg.setColor(new Color(255,255,255,110)); mg.fillRect(400,655,380,70); mg.setColor(Color.black); mg.drawString(" .. ",410,670); }
// if (ec==) { mg.setColor(new Color(255,255,255,110)); mg.fillRect(400,655,380,70); mg.setColor(Color.black); mg.drawString(" .. ",410,670); }
// else { /*mg.drawString(ec.toString(),410,670);*/ }mit gewünschtem Dateinamen
} }
public void mouseExited(MouseEvent e) { if(togtipbool!=false||/**/i==1) { mg=getGraphics(); mg.clearRect(400,655,380,70); } }
/* draw by dragging */
public void mouseDragged(MouseEvent e) {
x=((e.getX())-20+zoom)/zoom+(300-300/zoom); y=((e.getY())-40+zoom)/zoom+(300-300/zoom);
/* x' = zoom * (x-(300-300/zoom)) +21 -zoom becomes x = (x'-21+zoom)/zoom) +(300-300/zoom) */
if (x>300-300/zoom && x<300+300/zoom && y>300-300/zoom && y<300+300/zoom) {
mg=getGraphics();
if(( y %4==0 && x %2==0) || ( y %2==0 && y %4!=0 && x %2!=0) ) {
if (dragbool==true) { hexGrid[x] [y] =1; mg.setColor(Color.black/*green*/); mg./*fillRect*/fillOval(zoom* (x-(300-300/zoom)) +20-zoom,zoom* (y-(300-300/zoom)) +40-zoom,2*zoom,2*zoom); }
if (dragbool==false) { hexGrid[x] [y] =0; mg.setColor(Color.lightGray); mg./*fillRect*/fillOval(zoom* (x-(300-300/zoom)) +20-zoom,zoom* (y-(300-300/zoom)) +40-zoom,2*zoom,2*zoom); } }
else if(( y %4==0 && (x-1)%2==0) || ( y %2==0 && y %4!=0 && (x-1)%2!=0) ) {
if (dragbool==true) { hexGrid[x-1][y] =1; mg.setColor(Color.black/*green*/); mg./*fillRect*/fillOval(zoom*(x-1-(300-300/zoom)) +20-zoom,zoom* (y-(300-300/zoom)) +40-zoom,2*zoom,2*zoom); }
if (dragbool==false) { hexGrid[x-1][y] =0; mg.setColor(Color.lightGray); mg./*fillRect*/fillOval(zoom*(x-1-(300-300/zoom)) +20-zoom,zoom* (y-(300-300/zoom)) +40-zoom,2*zoom,2*zoom); } }
else if(((y-1)%4==0 && x %2==0) || ((y-1)%2==0 && (y-1)%4!=0 && x %2!=0) ) {
if (dragbool==true) { hexGrid[x] [y-1]=1; mg.setColor(Color.black/*green*/); mg./*fillRect*/fillOval(zoom* (x-(300-300/zoom)) +20-zoom,zoom*(y-1-(300-300/zoom)) +40-zoom,2*zoom,2*zoom); }
if (dragbool==false) { hexGrid[x] [y-1]=0; mg.setColor(Color.lightGray); mg./*fillRect*/fillOval(zoom* (x-(300-300/zoom)) +20-zoom,zoom*(y-1-(300-300/zoom)) +40-zoom,2*zoom,2*zoom); } }
else if(((y-1)%4==0 && (x-1)%2==0) || ((y-1)%2==0 && (y-1)%4!=0 && (x-1)%2!=0) ) {
if (dragbool==true) { hexGrid[x-1][y-1]=1; mg.setColor(Color.black/*green*/); mg./*fillRect*/fillOval(zoom*(x-1-(300-300/zoom)) +20-zoom,zoom*(y-1-(300-300/zoom)) +40-zoom,2*zoom,2*zoom); }
if (dragbool==false) { hexGrid[x-1][y-1]=0; mg.setColor(Color.lightGray); mg./*fillRect*/fillOval(zoom*(x-1-(300-300/zoom)) +20-zoom,zoom*(y-1-(300-300/zoom)) +40-zoom,2*zoom,2*zoom); } }
} }
/**/ /**/ /**/ /**/ /**/ /**/ /**/ /**/
/* show start-Tooltip */
public void mouseMoved(MouseEvent e) {
if ( onlyjuststarted==true && 20" ); pausebool=true; runbool=false; if(toggibool==true) { tf1.setText("paused .. i="+i); } }
if (cmd==">" ) { pauserunbutton.setLabel("||"); runbool=true; pausebool=false; }
if (cmd=="#" ) { gridnew=true; refreshGraphics=true; try { /*pauserunbutton.setLabel(">" ); pausebool=true; runbool=false;*/ if(toggibool==true) { tf1.setText("paused .. i="+i); }
step(getGraphics()); } catch(AWTException awex) {} } // nur einmal step(), falls pausebool==true
if (cmd=="scr" ) { shot=true; }
if (cmd=="c" ) { try { pauserunbutton.setLabel(">" ); pausebool=true; runbool=false; i=0; if(toggibool==true) { tf1.setText("reset .. i="+i); }
step(getGraphics()); } catch(AWTException awex) {} } /*clearcells(); } catch(Exception e) {} }*/
if (cmd=="0" ) { stim=0; nillbutt.setForeground(Color.white); onebutt.setForeground(Color.black); fiftybutt.setForeground(Color.black); hundredbutt.setForeground(Color.black); thsdbutt.setForeground(Color.black); nillbutt.setBackground(Color.gray); onebutt.setBackground(Color.lightGray); fiftybutt.setBackground(Color.lightGray); hundredbutt.setBackground(Color.lightGray); thsdbutt.setBackground(Color.lightGray); steptakt(stim); }
if (cmd=="10" ) { stim=10; onebutt.setForeground(Color.white); fiftybutt.setForeground(Color.black); nillbutt.setForeground(Color.black); hundredbutt.setForeground(Color.black); thsdbutt.setForeground(Color.black); onebutt.setBackground(Color.gray); fiftybutt.setBackground(Color.lightGray); nillbutt.setBackground(Color.lightGray); hundredbutt.setBackground(Color.lightGray); thsdbutt.setBackground(Color.lightGray); steptakt(stim); }
if (cmd=="50" ) { stim=50; fiftybutt.setForeground(Color.white); onebutt.setForeground(Color.black); nillbutt.setForeground(Color.black);hundredbutt.setForeground(Color.black); thsdbutt.setForeground(Color.black); fiftybutt.setBackground(Color.gray); onebutt.setBackground(Color.lightGray); nillbutt.setBackground(Color.lightGray);hundredbutt.setBackground(Color.lightGray); thsdbutt.setBackground(Color.lightGray); steptakt(stim); }
if (cmd=="100" ) { stim=100; hundredbutt.setForeground(Color.white); onebutt.setForeground(Color.black); fiftybutt.setForeground(Color.black); nillbutt.setForeground(Color.black);thsdbutt.setForeground(Color.black); hundredbutt.setBackground(Color.gray); onebutt.setBackground(Color.lightGray); fiftybutt.setBackground(Color.lightGray); nillbutt.setBackground(Color.lightGray);thsdbutt.setBackground(Color.lightGray); steptakt(stim); }
if (cmd=="500" ) { stim=500; thsdbutt.setForeground(Color.white); onebutt.setForeground(Color.black); fiftybutt.setForeground(Color.black); nillbutt.setForeground(Color.black); hundredbutt.setForeground(Color.black); thsdbutt.setBackground(Color.gray); onebutt.setBackground(Color.lightGray); fiftybutt.setBackground(Color.lightGray); nillbutt.setBackground(Color.lightGray); hundredbutt.setBackground(Color.lightGray); steptakt(stim); }
if (cmd==" " ) { f=new File(tf3.getText()+".jpg"); }
if (cmd=="2p" ) { zoom=1; zoom2butt.setForeground(Color.white); zoom4butt.setForeground(Color.black); zoom6butt.setForeground(Color.black); zoom8butt.setForeground(Color.black); zoom2butt.setBackground(Color.gray); zoom4butt.setBackground(Color.lightGray); zoom6butt.setBackground(Color.lightGray); zoom8butt.setBackground(Color.lightGray); mg.clearRect(20,40,610,610);
gridnew=true; refreshGraphics=true; try { step(getGraphics()); } catch(AWTException awex) {} }
if (cmd=="4p" ) { zoom=2; zoom2butt.setForeground(Color.black); zoom4butt.setForeground(Color.white); zoom6butt.setForeground(Color.black); zoom8butt.setForeground(Color.black); zoom2butt.setBackground(Color.lightGray); zoom4butt.setBackground(Color.gray); zoom6butt.setBackground(Color.lightGray); zoom8butt.setBackground(Color.lightGray); mg.clearRect(20,40,610,610);
gridnew=true; refreshGraphics=true; try { step(getGraphics()); } catch(AWTException awex) {} }
if (cmd=="6p" ) { zoom=3; zoom2butt.setForeground(Color.black); zoom4butt.setForeground(Color.black); zoom6butt.setForeground(Color.white); zoom8butt.setForeground(Color.black); zoom2butt.setBackground(Color.lightGray); zoom4butt.setBackground(Color.lightGray); zoom6butt.setBackground(Color.gray); zoom8butt.setBackground(Color.lightGray); mg.clearRect(20,40,610,610);
gridnew=true; refreshGraphics=true; try { step(getGraphics()); } catch(AWTException awex) {} }
if (cmd=="8p" ) { zoom=4; zoom2butt.setForeground(Color.black); zoom4butt.setForeground(Color.black); zoom6butt.setForeground(Color.black); zoom8butt.setForeground(Color.white); zoom2butt.setBackground(Color.lightGray); zoom4butt.setBackground(Color.lightGray); zoom6butt.setBackground(Color.lightGray); zoom8butt.setBackground(Color.gray); mg.clearRect(20,40,610,610);
gridnew=true; refreshGraphics=true; try { step(getGraphics()); } catch(AWTException awex) {} }
if (ae.getSource()==toggibutt ) { if(toggibool==true) { toggibool=false; } else if(toggibool==false) { toggibool=true; } }
if (ae.getSource()==togtipbutt) { if(togtipbool==true) { togtipbool=false; mg.clearRect(400,640,390,100);
// eiskristalle_Makro_41_HP=getToolkit().getImage("Eiskristalle_Makro_41_HP.jpg"); moos=getToolkit().getImage("Moos.jpg"/*bmp*//*gif*/); xantho=getToolkit().getImage("Xanthoriaparietina.jpg"); flechte1=getToolkit().getImage("Flechte1.jpg"); flechte13=getToolkit().getImage("Flechte13.jpg"); flechte12=getToolkit().getImage("Flechte12.jpg"); flechte_schuessel_fl=getToolkit().getImage("Flechte_schuessel_fl.jpg"); datronia_mollis=getToolkit().getImage("Datronia_mollis.jpg"); antarktisflechte=getToolkit().getImage("Antarktisflechte.jpg"); vomKirschbaum=getToolkit().getImage("VomKirschbaum.jpg"); daheim_Schneekristalle=getToolkit().getImage("Daheim_Schneekristalle.jpg"); naturSchneekristall=getToolkit().getImage("NaturSchneekristall.jpg");
eiskristalle_Makro_41_HP=Toolkit.getDefaultToolkit().getImage("Eiskristalle_Makro_41_HP.jpg"); moos=Toolkit.getDefaultToolkit().getImage("Moos.jpg"/*bmp*//*gif*/); xantho=Toolkit.getDefaultToolkit().getImage("Xanthoriaparietina.jpg"); flechte1=Toolkit.getDefaultToolkit().getImage("Flechte1.jpg"); flechte13=Toolkit.getDefaultToolkit().getImage("Flechte13.jpg"); flechte12=Toolkit.getDefaultToolkit().getImage("Flechte12.jpg"); flechte_schuessel_fl=Toolkit.getDefaultToolkit().getImage("Flechte_schuessel_fl.jpg"); datronia_mollis=Toolkit.getDefaultToolkit().getImage("Datronia_mollis.jpg"); antarktisflechte=Toolkit.getDefaultToolkit().getImage("Antarktisflechte.jpg"); vomKirschbaum=Toolkit.getDefaultToolkit().getImage("VomKirschbaum.jpg"); daheim_Schneekristalle=Toolkit.getDefaultToolkit().getImage("Daheim_Schneekristalle.jpg"); naturSchneekristall=Toolkit.getDefaultToolkit().getImage("NaturSchneekristall.jpg");
/*mediatracker=new MediaTracker(this);*/ mediatracker.addImage(eiskristalle_Makro_41_HP,0); mediatracker.addImage(moos,0); mediatracker.addImage(xantho,0); mediatracker.addImage(flechte1,0); mediatracker.addImage(flechte13,0); mediatracker.addImage(flechte12,0); mediatracker.addImage(flechte_schuessel_fl,0); mediatracker.addImage(datronia_mollis,0); mediatracker.addImage(antarktisflechte,0); mediatracker.addImage(vomKirschbaum,0); mediatracker.addImage(daheim_Schneekristalle,0); mediatracker.addImage(naturSchneekristall,0);
try{ mediatracker.waitForAll(); }catch(InterruptedException iex) {}
switch ( (int)(Math.random()*12) ) {
case 0: mg.drawImage(eiskristalle_Makro_41_HP,500,640,this); break; case 1: mg.drawImage(moos,500,640,this); break; case 2: mg.drawImage(xantho,490,640,this); break; case 3: mg.drawImage(flechte1,490,640,this); break; case 4: mg.drawImage(flechte13,490,640,this); break; case 5: mg.drawImage(flechte12,490,640,this); break; case 6: mg.drawImage(flechte_schuessel_fl,510,640,this); break; case 7: mg.drawImage(datronia_mollis,480,640,this); break; case 8: mg.drawImage(antarktisflechte,490,640,this); break; case 9: mg.drawImage(vomKirschbaum,490,640,this); break; case 10: mg.drawImage(daheim_Schneekristalle,460,640,this); break; case 11: mg.drawImage(naturSchneekristall,450,640,this); break;
} /*refreshGraphics=true; try{step(getGraphics());}catch(AWTException awex){} refreshGraphics=true; try { step(getGraphics()); } catch(AWTException awex) {} i-=2;*/ } else if(togtipbool==false) { togtipbool=true; } }
/* save pattern to file with its rule */
if (cmd=="s") { /* */
// try { /*File */PattFile= new File("c:/progeigene/JCreator/MyProjects/stories/hexLife/loadable patterns/SavedPattern"+tf3.getText()/*i*/+".txt"); PattFile.createNewFile(); }catch(FileNotFoundException fnofex) {}catch(IOException joex) {}
try { /*File */PattFile= new File("SavedPattern"+tf3.getText()/*i*/+".txt"); PattFile.createNewFile(); }catch(FileNotFoundException fnofex) {}catch(IOException joex) {}
/* .. ( landet ohne Pfadangabe im classes-Ordner ) ..
* .. Nur existierende Pfade werden angenommen, also keine neuen Ordner angelegt.
* .. auch relative Pfade, wie in DOS liefern Exceptions. */
try { randaff=new RandomAccessFile(PattFile,"rw"); }catch(FileNotFoundException fnofex) {}/*catch(IOException joex) {}*/
try { randaff.writeInt(-80); if (cbs0.getState()==true) { randaff.writeInt(-11); } else { randaff.writeInt(-10); }
randaff.writeInt(-81); if (cbs1.getState()==true) { randaff.writeInt(-11); } else { randaff.writeInt(-10); }
randaff.writeInt(-82); if (cbs2.getState()==true) { randaff.writeInt(-11); } else { randaff.writeInt(-10); }
randaff.writeInt(-83); if (cbs3.getState()==true) { randaff.writeInt(-11); } else { randaff.writeInt(-10); }
randaff.writeInt(-84); if (cbs4.getState()==true) { randaff.writeInt(-11); } else { randaff.writeInt(-10); }
randaff.writeInt(-85); if (cbs5.getState()==true) { randaff.writeInt(-11); } else { randaff.writeInt(-10); }
randaff.writeInt(-86); if (cbs6.getState()==true) { randaff.writeInt(-11); } else { randaff.writeInt(-10); }
randaff.writeInt(-90); if (cbb0.getState()==true) { randaff.writeInt(-11); } else { randaff.writeInt(-10); }
randaff.writeInt(-91); if (cbb1.getState()==true) { randaff.writeInt(-11); } else { randaff.writeInt(-10); }
randaff.writeInt(-92); if (cbb2.getState()==true) { randaff.writeInt(-11); } else { randaff.writeInt(-10); }
randaff.writeInt(-93); if (cbb3.getState()==true) { randaff.writeInt(-11); } else { randaff.writeInt(-10); }
randaff.writeInt(-94); if (cbb4.getState()==true) { randaff.writeInt(-11); } else { randaff.writeInt(-10); }
randaff.writeInt(-95); if (cbb5.getState()==true) { randaff.writeInt(-11); } else { randaff.writeInt(-10); }
randaff.writeInt(-96); if (cbb6.getState()==true) { randaff.writeInt(-11); } else { randaff.writeInt(-10); }
}catch(IOException joex) { tf1.setText("joex caught from s"+i); try{Thread.sleep(500);}catch(InterruptedException ie){} }
for(int x=0;x<=600;++x/*+=2*/) { for (int y=0;y<=600;++y/*+=2*/) {
try { if (hexGrid[x/*+200*/][y]==1)/**/ { randaff.writeInt(x); randaff.writeInt(y);/**/ }
}catch(IOException joex) { tf1.setText("joex caught from s"+i); try{Thread.sleep(500);}catch(InterruptedException ie){} }
/* if you're curious to see how bytes are written as ASCII chars to ''SavedPattern*.txt'' use: */
// for(int x=0;x<=600;++x) { try { randaff.write(x);
// }catch(IOException joex) { eg=getGraphics(); eg.drawString("joex caught from s"+i,50,720); } }
/* .. open file like usual. To see the unprintable characters too choose font ''Terminal'' in WordPad or Word */
} } try { randaff.close(); }catch(IOException ioex){} }
/**/ /**/
/* load pattern from file with or without its rule */
if (cmd=="ls"||cmd=="lc") {
// /*try {*/ PattFile= new File("c:/progeigene/JCreator/MyProjects/stories/hexLife/loadable patterns/SavedPattern"+tf3.getText()+".txt"); /*PattFile.createNewFile(); hier auch? }catch(FileNotFoundException fnofex) {}catch(IOException joex) {}*/
/*try {*/ PattFile= new File("SavedPattern"+tf3.getText()+".txt"); /*PattFile.createNewFile(); hier auch? }catch(FileNotFoundException fnofex) {}catch(IOException joex) {}*/
try { randaff=new RandomAccessFile(PattFile,"r"); }catch(FileNotFoundException fnofex) {}
// /*cmd="c"; */ try { step(getGraphics()); }catch(AWTException awex) { eg=getGraphics(); eg.drawString("awex caught from ls"+i,50,720); }
if(cmd=="ls") { /* sicherer wär' erst checken, ob readInt()==-80 usw .. */
try { randaff.readInt(); if (randaff.readInt()==-11) { cbs0.setState(true); } else { cbs0.setState(false); }
randaff.readInt(); if (randaff.readInt()==-11) { cbs1.setState(true); } else { cbs1.setState(false); }
randaff.readInt(); if (randaff.readInt()==-11) { cbs2.setState(true); } else { cbs2.setState(false); }
randaff.readInt(); if (randaff.readInt()==-11) { cbs3.setState(true); } else { cbs3.setState(false); }
randaff.readInt(); if (randaff.readInt()==-11) { cbs4.setState(true); } else { cbs4.setState(false); }
randaff.readInt(); if (randaff.readInt()==-11) { cbs5.setState(true); } else { cbs5.setState(false); }
randaff.readInt(); if (randaff.readInt()==-11) { cbs6.setState(true); } else { cbs6.setState(false); }
randaff.readInt(); if (randaff.readInt()==-11) { cbb0.setState(true); } else { cbb0.setState(false); }
randaff.readInt(); if (randaff.readInt()==-11) { cbb1.setState(true); } else { cbb1.setState(false); }
randaff.readInt(); if (randaff.readInt()==-11) { cbb2.setState(true); } else { cbb2.setState(false); }
randaff.readInt(); if (randaff.readInt()==-11) { cbb3.setState(true); } else { cbb3.setState(false); }
randaff.readInt(); if (randaff.readInt()==-11) { cbb4.setState(true); } else { cbb4.setState(false); }
randaff.readInt(); if (randaff.readInt()==-11) { cbb5.setState(true); } else { cbb5.setState(false); }
randaff.readInt(); if (randaff.readInt()==-11) { cbb6.setState(true); } else { cbb6.setState(false); }
}catch(IOException joex) { tf1.setText("joex caught from ls"+i); try{Thread.sleep(500);}catch(InterruptedException ie){} }
} else { try { for(int n=1;n<=28;++n) { randaff.readInt(); } }catch(IOException joex) { tf1.setText("joex caught from lc"+i); try{Thread.sleep(500);}catch(InterruptedException ie){} } }
int x; int y; try {
while( (x=randaff.readInt()) != -1 /* ''-1'' here: 'eof' */) { while( (y=randaff.readInt()) != -1 ) {
hexGrid[x][y]=1; if(toggibool==true){tf1.setText("loading cells from file .. x = "+x+", y = "+y);} /* debug eg=getGraphics(); eg.drawString(" "+i+" "+hexGrid[x][y],50+i,720);*/ break;
}
/*try{Thread.sleep(1);}catch(InterruptedException ie){}*/ } randaff.close();
}
catch(EOFException eofex) { tf1.setText("eofex caught from ls"+i); try{Thread.sleep(500);}catch(InterruptedException ie){} }catch(IOException jojex) { tf1.setText("jojex caught from ls"+i); try{Thread.sleep(500);}catch(InterruptedException ie){} }
// try { randaff.close(); }catch(IOException ioex){ eg=getGraphics(); eg.drawString("ioex caught from ls"+i,50,720); }
gridnew=true; refreshGraphics=true; try { step(getGraphics()); }catch(AWTException awex) { tf1.setText("awex caught from ls"+i); try{Thread.sleep(500);}catch(InterruptedException ie){} }
}
if (cmd=="SM1") { for(int x=0;x<=600;++x) { for(int y=0;y<=600;++y) { hexMem1[x][y]=hexGrid[x][y]; } } PattSaveMem1.setBackground(Color.gray); PattSaveMem1.setForeground(Color.white); }
if (cmd=="SM2") { for(int x=0;x<=600;++x) { for(int y=0;y<=600;++y) { hexMem2[x][y]=hexGrid[x][y]; } } PattSaveMem2.setBackground(Color.gray); PattSaveMem2.setForeground(Color.white); }
if (cmd=="LM1") { cmd="c"; for(int x=0;x<=600;++x) { for(int y=0;y<=600;++y) { hexGrid[x][y]=hexMem1[x][y]; } } cmd=null; /* queer, but works .. looks like cmd=''c''; is evaluated even though step() is only required later .. ?! (however .. it works!) */
/*gridnew=true;*/ refreshGraphics=true; try { step(getGraphics()); } catch(AWTException awex) {} refreshGraphics=true; try { step(getGraphics()); } catch(AWTException awex) {} i=1; } /* (without cmd=''0''; pattern will be cleared in second step() ?! ) */
if (cmd=="LM2") { cmd="c"; for(int x=0;x<=600;++x) { for(int y=0;y<=600;++y) { hexGrid[x][y]=hexMem2[x][y]; } } cmd=null;
/*gridnew=true;*/ refreshGraphics=true; try { step(getGraphics()); } catch(AWTException awex) {} refreshGraphics=true; try { step(getGraphics()); } catch(AWTException awex) {} i=1; }
if (cmd=="rnd 10") { rnd10bool=true; /*cmd="c"; gridnew=true;*/ refreshGraphics=true; try{step(getGraphics());}catch(AWTException awex){} refreshGraphics=true; try { step(getGraphics()); } catch(AWTException awex) {} i=1; } /* bad, queer code, but works ?! .. does one step with refresh and rnd_bool true .. */
if (cmd=="rnd 20") { rnd20bool=true; /*cmd="c"; gridnew=true;*/ refreshGraphics=true; try{step(getGraphics());}catch(AWTException awex){} refreshGraphics=true; try { step(getGraphics()); } catch(AWTException awex) {} i=1; } /* .. (with both rnd_bool and refresh reset back to false),.. */
if (cmd=="rnd |") { rndLbool=true; if(toggibool==true){tf1.setText(".. loading .. PLZ WAIT !");} /*cmd="c"; gridnew=true;*/ refreshGraphics=true; try{step(getGraphics());}catch(AWTException awex){} refreshGraphics=true; try{step(getGraphics());}catch(AWTException awex){} i=1; } /* .. then does another step with refresh and puts i back */
if (cmd=="rnd O") { rnd_obool=true; if(toggibool==true){tf1.setText(".. loading .. PLZ WAIT !");} /*cmd="c"; gridnew=true;*/ refreshGraphics=true; try{step(getGraphics());}catch(AWTException awex){} refreshGraphics=true; try{step(getGraphics());}catch(AWTException awex){} i=1; }
if(ae.getSource()==tf2) { rndPixAmount.setValue((int)(tf2StringToInteger.valueOf(tf2.getText()).intValue()*1.5)); }
if(ae.getSource()==tf4) { rndRadius.setValue((int)(tf4StringToInteger.valueOf(tf4.getText()).intValue())); }
if(ae.getSource()==pres1) { cbs0.setState(false); cbs1.setState(false); cbs2.setState(true); cbs3.setState(false); cbs4.setState(false); cbs5.setState(false); cbs6.setState(false); cbb0.setState(false); cbb1.setState(false); cbb2.setState(true); cbb3.setState(true); cbb4.setState(false); cbb5.setState(false); cbb6.setState(false); }
if(ae.getSource()==pres2) { cbs0.setState(false); cbs1.setState(false); cbs2.setState(true); cbs3.setState(true); cbs4.setState(false); cbs5.setState(true); cbs6.setState(false); cbb0.setState(false); cbb1.setState(false); cbb2.setState(false); cbb3.setState(true); cbb4.setState(true); cbb5.setState(false); cbb6.setState(false); }
if(ae.getSource()==pres3) { cbs0.setState(false); cbs1.setState(false); cbs2.setState(false); cbs3.setState(true); cbs4.setState(false); cbs5.setState(false); cbs6.setState(false); cbb0.setState(false); cbb1.setState(false); cbb2.setState(true); cbb3.setState(false); cbb4.setState(true); cbb5.setState(true); cbb6.setState(false); }
if(ae.getSource()==pres4) { cbs0.setState(true); cbs1.setState(true); cbs2.setState(true); cbs3.setState(true); cbs4.setState(false); cbs5.setState(false); cbs6.setState(false); cbb0.setState(false); cbb1.setState(false); cbb2.setState(false); cbb3.setState(true); cbb4.setState(false); cbb5.setState(false); cbb6.setState(false); }
if(ae.getSource()==pres5) { cbs0.setState(false); cbs1.setState(false); cbs2.setState(false); cbs3.setState(true); cbs4.setState(true); cbs5.setState(true); cbs6.setState(false); cbb0.setState(false); cbb1.setState(false); cbb2.setState(true); cbb3.setState(false); cbb4.setState(false); cbb5.setState(false); cbb6.setState(false); }
if(ae.getSource()==pres6) { cbs0.setState(true); cbs1.setState(false); cbs2.setState(true); cbs3.setState(false); cbs4.setState(true); cbs5.setState(true); cbs6.setState(false); cbb0.setState(false); cbb1.setState(false); cbb2.setState(false); cbb3.setState(true); cbb4.setState(true); cbb5.setState(true); cbb6.setState(false); }
if(ae.getSource()==pres7) { cbs0.setState(false); cbs1.setState(true); cbs2.setState(true); cbs3.setState(false); cbs4.setState(true); cbs5.setState(true); cbs6.setState(false); cbb0.setState(false); cbb1.setState(false); cbb2.setState(false); cbb3.setState(true); cbb4.setState(true); cbb5.setState(true); cbb6.setState(true); }
if(ae.getSource()==pres8) { cbs0.setState(false); cbs1.setState(false); cbs2.setState(false); cbs3.setState(false); cbs4.setState(false); cbs5.setState(false); cbs6.setState(false); cbb0.setState(false); cbb1.setState(true); cbb2.setState(true); cbb3.setState(false); cbb4.setState(false); cbb5.setState(false); cbb6.setState(false); }
if(ae.getSource()==pres9) { cbs0.setState(false); cbs1.setState(false); cbs2.setState(false); cbs3.setState(true); cbs4.setState(true); cbs5.setState(true); cbs6.setState(false); cbb0.setState(false); cbb1.setState(false); cbb2.setState(false); cbb3.setState(true); cbb4.setState(true); cbb5.setState(true); cbb6.setState(false); }
if(ae.getSource()==pres10) { cbs0.setState(false); cbs1.setState(false); cbs2.setState(true); cbs3.setState(true); cbs4.setState(true); cbs5.setState(true); cbs6.setState(false); cbb0.setState(false); cbb1.setState(false); cbb2.setState(false); cbb3.setState(true); cbb4.setState(true); cbb5.setState(true); cbb6.setState(true); }
// if(ae.getSource()==pres) { cbs0.setState(false); cbs1.setState(false); cbs2.setState(false); cbs3.setState(false); cbs4.setState(false); cbs5.setState(false); cbs6.setState(false); cbb0.setState(false); cbb1.setState(false); cbb2.setState(false); cbb3.setState(false); cbb4.setState(false); cbb5.setState(false); cbb6.setState(false); }
// if(ae.getSource()==pres) { cbs0.setState(false); cbs1.setState(false); cbs2.setState(false); cbs3.setState(false); cbs4.setState(false); cbs5.setState(false); cbb.setState(false); cbb0.setState(false); cbb1.setState(false); cbb2.setState(false); cbb3.setState(false); cbb4.setState(false); cbb5.setState(false); cbb6.setState(false); }
if(ae.getSource()==cfroul||ae.getSource()==cfrou||ae.getSource()==cfrour||ae.getSource()==cfrol||ae.getSource()==cfror||ae.getSource()==cfrodl||ae.getSource()==cfrod||ae.getSource()==cfrodr) {
for(x=201;x<=400;++x) { for(y=202;y<=400;/*++*/y+=2) { hexCopy[x][y]=hexGrid[x][y];
} } /* center von hexGrid[][] wurde ausgelesen und kopiert nach hexCopy[][] */
if(ae.getSource()==cfroul) { for(x=201;x<=400;++x) { for(y=202;y<=400;/*++*/y+=2) { hexGrid[x-200][y-200]=hexCopy[x][y]; hexCopy[x][y]=0; } } }
if(ae.getSource()==cfrou) { for(x=201;x<=400;++x) { for(y=202;y<=400;/*++*/y+=2) { hexGrid[x][y-200]=hexCopy[x][y]; hexCopy[x][y]=0; } } }
if(ae.getSource()==cfrour) { for(x=201;x<=400;++x) { for(y=202;y<=400;/*++*/y+=2) { hexGrid[x+200][y-200]=hexCopy[x][y]; hexCopy[x][y]=0; } } }
if(ae.getSource()==cfrol) { for(x=201;x<=400;++x) { for(y=202;y<=400;/*++*/y+=2) { hexGrid[x-200][y]=hexCopy[x][y]; hexCopy[x][y]=0; } } }
if(ae.getSource()==cfror) { for(x=201;x<=400;++x) { for(y=202;y<=400;/*++*/y+=2) { hexGrid[x+200][y]=hexCopy[x][y]; hexCopy[x][y]=0; } } }
if(ae.getSource()==cfrodl) { for(x=201;x<=400;++x) { for(y=202;y<=400;/*++*/y+=2) { hexGrid[x-200][y+200]=hexCopy[x][y]; hexCopy[x][y]=0; } } }
if(ae.getSource()==cfrod) { for(x=201;x<=400;++x) { for(y=202;y<=400;/*++*/y+=2) { hexGrid[x][y+200]=hexCopy[x][y]; hexCopy[x][y]=0; } } }
if(ae.getSource()==cfrodr) { for(x=201;x<=400;++x) { for(y=202;y<=400;/*++*/y+=2) { hexGrid[x+200][y+200]=hexCopy[x][y]; hexCopy[x][y]=0; } } }
if(pcfro_bool==false){ for(x=201;x<=400;++x) { for(y=202;y<=400;/*++*/y+=2) { if(hexGrid[x][y]==1){ hexGrid[x][y]=77/*10*//*0*/; } } } }
} /* abhängig von wohin wurde hexCopy[][] ins hexGrid[][] zurückkopiert (und selbst wieder gelöscht), dann das hexGrid[][]-center gelöscht oder nicht */
if(ae.getSource()==pcfro) { if(pcfro_bool==false){ pcfro_bool=true; pcfro.setLabel("+"); } else /* ! not only ''if'' ;o)) ! */ if(pcfro_bool==true){ pcfro_bool=false; pcfro.setLabel("-"); } }
/* jetzt umgekehrt .. */
if(ae.getSource()==ctoul||ae.getSource()==ctou||ae.getSource()==ctour||ae.getSource()==ctol||ae.getSource()==ctor||ae.getSource()==ctodl||ae.getSource()==ctod||ae.getSource()==ctodr) {
/* erst werden die Randbereiche abhängig 'von woher' ausgelesen, ins center von hexCopy[][] kopiert, und am Rand (hexGrid[][]) schon gelöscht oder nicht */
if(ae.getSource()==ctoul) { for(x=0;x<=200;++x) { for(y=0;y<=200;/*++*/y+=2) { hexCopy[x+200][y+200]=hexGrid[x][y]; if(pcto_bool==false){ if(hexGrid[x][y]==1){ hexGrid[x][y]=77; } } } } }
if(ae.getSource()==ctou) { for(x=200;x<=400;++x) { for(y=0;y<=200;/*++*/y+=2) { hexCopy[x][y+200]=hexGrid[x][y]; if(pcto_bool==false){ if(hexGrid[x][y]==1){ hexGrid[x][y]=77; } } } } }
if(ae.getSource()==ctour) { for(x=400;x<=600;++x) { for(y=0;y<=200;/*++*/y+=2) { hexCopy[x-200][y+200]=hexGrid[x][y]; if(pcto_bool==false){ if(hexGrid[x][y]==1){ hexGrid[x][y]=77; } } } } }
if(ae.getSource()==ctol) { for(x=0;x<=200;++x) { for(y=200;y<=400;/*++*/y+=2) { hexCopy[x+200][y]=hexGrid[x][y]; if(pcto_bool==false){ if(hexGrid[x][y]==1){ hexGrid[x][y]=77; } } } } }
if(ae.getSource()==ctor) { for(x=400;x<=600;++x) { for(y=200;y<=400;/*++*/y+=2) { hexCopy[x-200][y]=hexGrid[x][y]; if(pcto_bool==false){ if(hexGrid[x][y]==1){ hexGrid[x][y]=77; } } } } }
if(ae.getSource()==ctodl) { for(x=0;x<=200;++x) { for(y=400;y<=600;/*++*/y+=2) { hexCopy[x+200][y-200]=hexGrid[x][y]; if(pcto_bool==false){ if(hexGrid[x][y]==1){ hexGrid[x][y]=77; } } } } }
if(ae.getSource()==ctod) { for(x=200;x<=400;++x) { for(y=400;y<=600;/*++*/y+=2) { hexCopy[x][y-200]=hexGrid[x][y]; if(pcto_bool==false){ if(hexGrid[x][y]==1){ hexGrid[x][y]=77; } } } } }
if(ae.getSource()==ctodr) { for(x=400;x<=600;++x) { for(y=400;y<=600;/*++*/y+=2) { hexCopy[x-200][y-200]=hexGrid[x][y]; if(pcto_bool==false){ if(hexGrid[x][y]==1){ hexGrid[x][y]=77; } } } } }
for(x=200;x<=400;++x) { for(y=200;y<=400;/*++*/y+=2) { hexGrid[x][y]=hexCopy[x][y]; hexCopy[x][y]=0;
} } /* .. und (Zeile drüber) von hexCopy[][]-center für hexGrid einfach übernommen! ( und hexCopy[][] gelöscht ) */
}
if(ae.getSource()==pcto) { if(pcto_bool==false){ pcto_bool=true; pcto.setLabel("+"); } else if(pcto_bool==true){ pcto_bool=false; pcto.setLabel("-"); } }
if(ae.getSource()==clearcenteronly) { for(x=200;x<=400;++x) { for(y=200;y<=400;/*++*/y+=2) { hexGrid[x][y]=0; } } refreshGraphics=true; try{step(getGraphics());}catch(AWTException awex){} }
} /* end..actionperformed() */ /* */
public int steptakt(int stim) { return stim; }
/**/ /**/ /* if(toggibool==true){} */ /**/ /**/ /**/ /**/ /**/ /**/ /**/
public void itemStateChanged(ItemEvent ie) {}
public void adjustmentValueChanged(AdjustmentEvent adje) { /* hier drunter ''/1.5'', da Wert in Prozent von 150 gewollt */
if(adje.getSource()==rndPixAmount) { tf2.setText( ""+String.valueOf( (int)((double)(adje.getValue()/1.5)) )/* or: +" "+Integer.toString( (int)((double)(adje.getValue()/1.5)) )*/ ); }
if(adje.getSource()==rndRadius) { tf4.setText( ""+String.valueOf( (int)(adje.getValue()) ) ); } /* hier Radius in Pixeln */
}
public HexLife1stUpload() /*throws FileNotFoundException, IOException*/ {
// try { PattFile.createNewFile(); }catch(IOException joex) {}
addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { dispose(); System.exit(0); } } );
addMouseListener(this);
addMouseMotionListener(this);
setLayout(null);
pauserunbutton=new Button(">"); pauserunbutton.setBounds(650,50,30,20); pauserunbutton.setBackground(Color.white); pauserunbutton.addActionListener(this); add(pauserunbutton);
gridbutton=new Button("#"); gridbutton.setBounds(700,50,30,20); gridbutton.setBackground(Color.lightGray); gridbutton.addActionListener(this); gridbutton.addMouseListener(this); add(gridbutton);
tf1=new TextField(); tf1.setBounds(40,645,300,20); tf1.setBackground(Color.white); tf1.addActionListener(this); add(tf1);
screenshotbutton=new Button("scr"); screenshotbutton.setBounds(700,70,30,20); screenshotbutton.setBackground(Color.lightGray); screenshotbutton.addActionListener(this); screenshotbutton.addMouseListener(this); add(screenshotbutton);
clearbutton=new Button("c"); clearbutton.setBounds(700,90,30,20); clearbutton.setBackground(Color.orange); clearbutton.addActionListener(this); clearbutton.addMouseListener(this); add(clearbutton);
nillbutt =new Button("0"); nillbutt.setBounds(650,70,30,20); nillbutt.setBackground(Color.lightGray); nillbutt.addActionListener(this); nillbutt.addMouseListener(this); add(nillbutt);
onebutt =new Button("10"); onebutt.setBounds(650,90,30,20); onebutt.setBackground(Color.lightGray); onebutt.addActionListener(this); onebutt.addMouseListener(this); add(onebutt);
fiftybutt =new Button("50"); fiftybutt.setBounds(650,110,30,20); fiftybutt.setBackground(Color.gray); fiftybutt.setForeground(Color.white); fiftybutt.addMouseListener(this); fiftybutt.addActionListener(this); add(fiftybutt);
hundredbutt =new Button("100"); hundredbutt.setBounds(650,130,30,20); hundredbutt.setBackground(Color.lightGray); hundredbutt.addActionListener(this); hundredbutt.addMouseListener(this); add(hundredbutt);
thsdbutt =new Button("500"); thsdbutt.setBounds(650,150,30,20); thsdbutt.setBackground(Color.lightGray); thsdbutt.addActionListener(this); thsdbutt.addMouseListener(this); add(thsdbutt);
toggibutt =new Button("±"); toggibutt.setBounds(25,647,15,15); toggibutt.setForeground(Color.white); toggibutt.addActionListener(this); toggibutt.addMouseListener(this); add(toggibutt);
togtipbutt =new Button("±"); togtipbutt.setBounds(780,720,15,15); togtipbutt.setForeground(Color.white); togtipbutt.addActionListener(this); togtipbutt.addMouseListener(this); add(togtipbutt);
savpatbutt =new Button("s"); savpatbutt.setBounds(650,180,30,20); savpatbutt.setBackground(Color.cyan); savpatbutt.addActionListener(this); savpatbutt.addMouseListener(this); add(savpatbutt);
loadpatsbutt =new Button("ls"); loadpatsbutt.setBounds(635,200,30,20); loadpatsbutt.setBackground(Color.cyan); loadpatsbutt.addActionListener(this); loadpatsbutt.addMouseListener(this); add(loadpatsbutt);
loadpatcbutt =new Button("lc"); loadpatcbutt.setBounds(665,200,30,20); loadpatcbutt.setBackground(Color.cyan); loadpatcbutt.addActionListener(this); loadpatcbutt.addMouseListener(this); add(loadpatcbutt);
zoom2butt =new Button("2p"); zoom2butt.setBounds(700,120,30,20); zoom2butt.setBackground(Color.lightGray); zoom2butt.addActionListener(this); zoom2butt.addMouseListener(this); add(zoom2butt);
zoom4butt =new Button("4p"); zoom4butt.setBounds(700,140,30,20); zoom4butt.setBackground(Color.gray); zoom4butt.setForeground(Color.white); zoom4butt.addActionListener(this); zoom4butt.addMouseListener(this); add(zoom4butt);
zoom6butt =new Button("6p"); zoom6butt.setBounds(700,160,30,20); zoom6butt.setBackground(Color.lightGray); zoom6butt.addActionListener(this); zoom6butt.addMouseListener(this); add(zoom6butt);
zoom8butt =new Button("8p"); zoom8butt.setBounds(700,180,30,20); zoom8butt.setBackground(Color.lightGray); zoom8butt.addActionListener(this); zoom8butt.addMouseListener(this); add(zoom8butt);
// try { s0=new CheckboxGroup(); cbs0=new Checkbox("0",s0,false); cbs0.setBounds(650,500,30,10);/*cbs0.setLocation(700,300);*/ add(cbs0); }catch(HeadlessException he){}
// try { s1=new CheckboxGroup(); cbs1=new Checkbox("1",s1,true); cbs1.setBounds(650,520,30,10); add(cbs1); }catch(HeadlessException he){}
// try { cbs2=new Checkbox("2",s0,false); cbs2.setBounds(650,540,30,10/*650,380,30,15*/); add(cbs2); }catch(HeadlessException he) {}
cbs0=new Checkbox("0",false); cbs0.setBounds(630,500,30,15); cbs0.setBackground(Color.white); add(cbs0); cbb0=new Checkbox("0",false); cbb0.setBounds(680,500,30,15); cbb0.setBackground(Color.white); add(cbb0);
cbs1=new Checkbox("1",true); cbs1.setBounds(630,520,30,15); cbs1.setBackground(Color.white); add(cbs1); cbb1=new Checkbox("1",false); cbb1.setBounds(680,520,30,15); cbb1.setBackground(Color.white); add(cbb1);
cbs2=new Checkbox("2",false); cbs2.setBounds(630,540,30,15); cbs2.setBackground(Color.white); add(cbs2); cbb2=new Checkbox("2",true); cbb2.setBounds(680,540,30,15); cbb2.setBackground(Color.white); add(cbb2);
cbs3=new Checkbox("3",false); cbs3.setBounds(630,560,30,15); cbs3.setBackground(Color.white); add(cbs3); cbb3=new Checkbox("3",false); cbb3.setBounds(680,560,30,15); cbb3.setBackground(Color.white); add(cbb3);
cbs4=new Checkbox("4",false); cbs4.setBounds(630,580,30,15); cbs4.setBackground(Color.white); add(cbs4); cbb4=new Checkbox("4",false); cbb4.setBounds(680,580,30,15); cbb4.setBackground(Color.white); add(cbb4);
cbs5=new Checkbox("5",false); cbs5.setBounds(630,600,30,15); cbs5.setBackground(Color.white); add(cbs5); cbb5=new Checkbox("5",false); cbb5.setBounds(680,600,30,15); cbb5.setBackground(Color.white); add(cbb5);
cbs6=new Checkbox("6",false); cbs6.setBounds(630,620,30,15); cbs6.setBackground(Color.white); add(cbs6); cbb6=new Checkbox("6",false); cbb6.setBounds(680,620,30,15); cbb6.setBackground(Color.white); add(cbb6);
cbs0.addMouseListener(this); cbb0.addMouseListener(this); cbs6.addMouseListener(this); cbb6.addMouseListener(this);
// try { File PattFile= new File("c:/progeigene/JCreator/MyProjects/stories/hexLife/SavedPattern"+i+".txt"); PattFile.createNewFile(); }catch(FileNotFoundException fnofex) {}catch(IOException joex) {} // +i.toString() .. ?
// try { PattFile.createNewFile(); }catch(FileNotFoundException fnofex) {}catch(IOException joex) {}
rndPatt10=new Button("rnd 10"); rndPatt10.setBounds(700,210,50,20); rndPatt10.setBackground(Color.lightGray); rndPatt10.addActionListener(this); rndPatt10.addMouseListener(this); add(rndPatt10);
rndPatt20=new Button("rnd 20"); rndPatt20.setBounds(700,230,50,20); rndPatt20.setBackground(Color.lightGray); rndPatt20.addActionListener(this); rndPatt20.addMouseListener(this); add(rndPatt20);
rndPattL=new Button("rnd |"); rndPattL.setBounds(700,250,50,20); rndPattL.setBackground(Color.lightGray); rndPattL.addActionListener(this); rndPattL.addMouseListener(this); add(rndPattL);
// alabel= new Label("rnd O");
rndPatt_o=new Button("rnd O"); rndPatt_o.setBounds(700,290,50,20); rndPatt_o.setBackground(Color.lightGray); rndPatt_o.addActionListener(this); rndPatt_o.addMouseListener(this); add(rndPatt_o);
tf2=new TextField(); tf2.setBounds(735,310,30,20); tf2.setBackground(new Color(238,220,166)); tf2.addActionListener(this); tf2.addMouseListener(this); add(tf2); tf2.setText("25");
tf3=new TextField(); tf3.setBounds(40,670,300,20); tf3.setBackground(Color.cyan); tf3.addActionListener(this); tf3.addMouseListener(this); add(tf3); tf3.setText("[user input]"/*"enter filename here before saving or loading patterns"*/);
PattSaveMem1=new Button("SM1"); PattSaveMem1.setBounds(635,230,30,20); PattSaveMem1.setBackground(Color.lightGray); PattSaveMem1.addActionListener(this); PattSaveMem1.addMouseListener(this); add(PattSaveMem1);
PattLoadMem1=new Button("LM1"); PattLoadMem1.setBounds(635,250,30,20); PattLoadMem1.setBackground(Color.lightGray); PattLoadMem1.addActionListener(this); PattLoadMem1.addMouseListener(this); add(PattLoadMem1);
PattSaveMem2=new Button("SM2"); PattSaveMem2.setBounds(665,230,30,20); PattSaveMem2.setBackground(Color.lightGray); PattSaveMem2.addActionListener(this); PattSaveMem2.addMouseListener(this); add(PattSaveMem2);
PattLoadMem2=new Button("LM2"); PattLoadMem2.setBounds(665,250,30,20); PattLoadMem2.setBackground(Color.lightGray); PattLoadMem2.addActionListener(this); PattLoadMem2.addMouseListener(this); add(PattLoadMem2);
rndPixAmount= new Scrollbar(Scrollbar.VERTICAL,5,40,0,190); rndPixAmount.setBounds(750,210,15,100); rndPixAmount.setValue(10); rndPixAmount.setBackground(new Color(238,220,166)); rndPixAmount.setForeground(Color.lightGray); rndPixAmount.addAdjustmentListener(this);/**/ rndPixAmount.addMouseListener(this); add(rndPixAmount);
rndRadius= new Scrollbar(Scrollbar.VERTICAL,5,40,0,190); rndRadius.setBounds(765,210,15,100); rndRadius.setValue(10); rndRadius.setBackground(new Color(176,247,172)); rndRadius.setForeground(Color.lightGray); rndRadius.addAdjustmentListener(this);/**/ rndRadius.addMouseListener(this); add(rndRadius);
tf4=new TextField(); tf4.setBounds(765,190,30,20); tf4.setBackground(new Color(176,247,172)); tf4.addActionListener(this); tf4.addMouseListener(this); add(tf4); tf4.setText("10");
pres1=new Button("s2b23"); pres1.setBounds(725,485,65,15); pres1.setBackground(Color.lightGray); pres1.addActionListener(this); pres1.addMouseListener(this); add(pres1); pres2=new Button("s235b34"); pres2.setBounds(725,500,65,15); pres2.setBackground(Color.lightGray); pres2.addActionListener(this); pres2.addMouseListener(this); add(pres2); pres3=new Button("s3b245"); pres3.setBounds(725,515,65,15); pres3.setBackground(Color.lightGray); pres3.addActionListener(this); pres3.addMouseListener(this); add(pres3); pres4=new Button("s0123b3"); pres4.setBounds(725,530,65,15); pres4.setBackground(Color.lightGray); pres4.addActionListener(this); pres4.addMouseListener(this); add(pres4); pres5=new Button("s345b2"); pres5.setBounds(725,545,65,15); pres5.setBackground(Color.lightGray); pres5.addActionListener(this); pres5.addMouseListener(this); add(pres5); pres6=new Button("s0245b345"); pres6.setBounds(725,560,65,15); pres6.setBackground(Color.lightGray); pres6.addActionListener(this); pres6.addMouseListener(this); add(pres6); pres7=new Button("s1245b3456"); pres7.setBounds(718,575,75,15); pres7.setBackground(Color.lightGray); pres7.addActionListener(this); pres7.addMouseListener(this); add(pres7); pres8=new Button("s-b12"); pres8.setBounds(725,590,65,15); pres8.setBackground(Color.lightGray); pres8.addActionListener(this); pres8.addMouseListener(this); add(pres8); pres9=new Button("s345b345"); pres9.setBounds(725,605,65,15); pres9.setBackground(Color.lightGray); pres9.addActionListener(this); pres9.addMouseListener(this); add(pres9); pres10=new Button("s2345b3456"); pres10.setBounds(718,620,76,15); pres10.setBackground(Color.lightGray); pres10.addActionListener(this); pres10.addMouseListener(this); add(pres10);
// addAdjustmentListener(this); 238,220,166 176,247,172
pcfro=new Button("±"); pcfro.setBounds(660,390,15,15); pcfro.addActionListener(this); pcfro.addMouseListener(this); pcfro.setForeground(Color.white); add(pcfro); cfroul=new Button(""); cfroul.setBounds(630,360,25,25); cfroul.addActionListener(this); cfroul.addMouseListener(this); cfroul.setBackground(Color.lightGray); cfroul.setForeground(Color.lightGray); add(cfroul); cfrou=new Button(""); cfrou.setBounds(655,360,25,25); cfrou.addActionListener(this); cfrou.addMouseListener(this); cfrou.setBackground(Color.lightGray); cfrou.setForeground(Color.lightGray); add(cfrou); cfrour=new Button(""); cfrour.setBounds(680,360,25,25); cfrour.addActionListener(this); cfrour.addMouseListener(this); cfrour.setBackground(Color.lightGray); cfrour.setForeground(Color.lightGray); add(cfrour); cfrol=new Button(""); cfrol.setBounds(630,385,25,25); cfrol.addActionListener(this); cfrol.addMouseListener(this); cfrol.setBackground(Color.lightGray); cfrol.setForeground(Color.lightGray); add(cfrol); cfror=new Button(""); cfror.setBounds(680,385,25,25); cfror.addActionListener(this); cfror.addMouseListener(this); cfror.setBackground(Color.lightGray); cfror.setForeground(Color.lightGray); add(cfror); cfrodl=new Button(""); cfrodl.setBounds(630,410,25,25); cfrodl.addActionListener(this); cfrodl.addMouseListener(this); cfrodl.setBackground(Color.lightGray); cfrodl.setForeground(Color.lightGray); add(cfrodl); cfrod=new Button(""); cfrod.setBounds(655,410,25,25); cfrod.addActionListener(this); cfrod.addMouseListener(this); cfrod.setBackground(Color.lightGray); cfrod.setForeground(Color.lightGray); add(cfrod); cfrodr=new Button(""); cfrodr.setBounds(680,410,25,25); cfrodr.addActionListener(this); cfrodr.addMouseListener(this); cfrodr.setBackground(Color.lightGray); cfrodr.setForeground(Color.lightGray); add(cfrodr);
pcto=new Button("±"); pcto.setBounds(747,391,11,13); pcto.addActionListener(this); pcto.addMouseListener(this); pcto.setForeground(Color.white); add(pcto); ctoul=new Button(""); ctoul.setBounds(715,360,25,25); ctoul.addActionListener(this); ctoul.addMouseListener(this); ctoul.setBackground(Color.lightGray); ctoul.setForeground(Color.lightGray); add(ctoul); ctou=new Button(""); ctou.setBounds(740,360,25,25); ctou.addActionListener(this); ctou.addMouseListener(this); ctou.setBackground(Color.lightGray); ctou.setForeground(Color.lightGray); add(ctou); ctour=new Button(""); ctour.setBounds(765,360,25,25); ctour.addActionListener(this); ctour.addMouseListener(this); ctour.setBackground(Color.lightGray); ctour.setForeground(Color.lightGray); add(ctour); ctol=new Button(""); ctol.setBounds(715,385,25,25); ctol.addActionListener(this); ctol.addMouseListener(this); ctol.setBackground(Color.lightGray); ctol.setForeground(Color.lightGray); add(ctol); ctor=new Button(""); ctor.setBounds(765,385,25,25); ctor.addActionListener(this); ctor.addMouseListener(this); ctor.setBackground(Color.lightGray); ctor.setForeground(Color.lightGray); add(ctor); ctodl=new Button(""); ctodl.setBounds(715,410,25,25); ctodl.addActionListener(this); ctodl.addMouseListener(this); ctodl.setBackground(Color.lightGray); ctodl.setForeground(Color.lightGray); add(ctodl); ctod=new Button(""); ctod.setBounds(740,410,25,25); ctod.addActionListener(this); ctod.addMouseListener(this); ctod.setBackground(Color.lightGray); ctod.setForeground(Color.lightGray); add(ctod); ctodr=new Button(""); ctodr.setBounds(765,410,25,25); ctodr.addActionListener(this); ctodr.addMouseListener(this); ctodr.setBackground(Color.lightGray); ctodr.setForeground(Color.lightGray); add(ctodr);
clearcenteronly=new Button(""); clearcenteronly.setBounds(740,385,25,25); clearcenteronly.addActionListener(this); clearcenteronly.addMouseListener(this); clearcenteronly.setBackground(Color.orange); add(clearcenteronly);
} /* END .. HexLife1stUpload */ /**/ /* */ /**/ /**/ /**/ /**/ /**/ /**/
public static void main(String args[]) throws FileNotFoundException, IOException, EOFException /**/ {
System.out.println("Starting HexLife1stUpload...");
HexLife1stUpload mainFrame = new HexLife1stUpload();
mainFrame.setSize(800, 740);
mainFrame.setTitle("HexLife1stUpload");
mainFrame.setVisible(true);
new Thread(mainFrame).start();
}
}
/* *** *** *** Versions-übergreifend ..
*
* (o Problem x zu y+1 (-1) .. Versatz .. taucht immer wieder auf, um unter zoom oder random jedes zweite Pixel richtig zu treffen .. !?
* Es muß eine *.bmp her mit exakter liob Ecke des hexGrid[][] bei x= und y=,
* wo erstmals beim malen mit Maus dem hexGrid[][] Werte An/Aus, =1, =0 zugewiesen werden, dann jeweils x2 für 6-Eck-Gitter ..
* Problem tauchte unüberwindlich auf bei randomPattern (und bei load?) )
* .. soweit entschärft: Es durfte nicht mit zoom*(n-(301-300/zoom)) zoom*(m-(302-300/zoom)) gemalt werden ! (nach algo-Block)
* o
* o ..
*
* ******************* HexLife07 * RuleEdit [alles aufsteigend, nur ohne Leerzeile oder mit '' | '' absteigend]
*
* *** 07aRuleEdit ff
* .. NACH Zwischenversionen 07a1Zoom und 07a2PattSav
* // gridnew könnte dringend optimiert werden -> nicht komplett gridnew,
* sondern, wo nötig nach zB clear
* // save-load-path ggf mit neuem button
* // mehrmaliges save-load-Problem debuggen lösen
* oder clear Rect und drawString MiTTig ''plz wait!''
*
* o mediatracker hinzugefügt. (sonst löscht togtipbool off neuerdings ganzes Carré Oo.-_o ?!)
* o clearcenteronly orange hinzugefügt (um paterns bei zoom 2p zur Mitte zu 'fischen' zum 'ranzoomen)
//
// ???: refreshGraphics funktioniert bei rndL und rnd_o weder mit refresh + try step in actionperformed, noch in if rndbool==true,
// mit oder ohne gridnew, egal welcher zoom
// obwohl i+=1 gezählt wird ..
// mit zweimal refresh + try step geht's !?
// .. aber bei Lm1+2 wird alles gelöscht ?! .. wg cmd=''c''. Mit zusätzlich cmd=null; funktioniert's aber !? *gruselig*
*
* o sinnloses zoom1 2p ganz 'rausgeschmissen .. lädt alles (rndSe, zoom2p, clearbutt, refresh) viel schneller
* o catch->drawString(..) .. jetzt catch->tf1.setText(..) + sleep(500);
* o 'save/load with rule' erledigt! .. einfach komplett für alle 14 Checkboxen Schreiben und Lesen ''An/Aus'' erzwungen
* und per setState() verarbeitet.
* o pa' rule-presets gemacht. .. 'custom' noch zurückgestellt, da auslesen wieder nicht trivial
* o getToolkit() für jpgSe jetzt im jew case .. ( hat irgendswie Ladehemmung .. ohne avast geht's manchmal besser ?! )
* o rndL3 und 7 sind jetzt rndL mit 'Radius' 1 bis 150.
* o scrollbar RndRadius und tf4 hinzugefügt und synchronisiert.
* o rndPixAmount-scrollbar und tf2 jetzt für user in Prozent (nicht mehr double)
* .. sowie miteinander synchronisiert per actionPerformed() -> rndPixAmount.setValue(..) für tf2 -> rndPixAmount
* bzw per adjustmentValueChanged() -> tf2.setText(..) für <-
* o rnd-Ring hinzugefügt rndPatt_o
*
* o .. jetzt die Checkboxen abfragen und richtig in den sb-rules(ct) unterbringen ..
* -> trivial erledigt per if ( .. && CheckBox.getState() ) !
*
* o mit neuem dragbool aus mousePressed() ( wird dort nur einmal evaluiert .. ) malt und löscht mouseDragged() jetzt vernünftig
* zusammenhängend. ( hier würde bzw wird pausenlos evaluiert)
* o debug1 für mouseMoved() getX,Y() und zugewiesene hexGrid[][]-Werte anzeigen wieder 'rausgeschmissen (noch drin in 07a2PattSav)
* bissel Kleinkram zuerst ..
*
* *** 07a2PattSav
* |
* Um an elementaren Beispielen schrittweise zu prüfen und nachzuvollziehen, ob der algo richtig funktioniert (zB wegen
* des +/-1-Versatzes der Zeilen), ist nun Speichern und Laden der patterns (Zellebene), jetzt schon höchst brauchbar,
* BEVOR die checkboxen aktiviert werden.
* Es sollen patterns mit ihrer aktuellen sb-rule dauerhaft als Datei gespeichert werden können.
* Sie sollen wahlweise mit ihrer rule ODER mit aktueller sb-rule geladen werden können.
* Es sollen einige patterns per schnell-speicher und -lade ( memory ) zB ~Buttons in einige default-memory-Dateien ge-
* -speichert und geladen werden können, um nicht immer den Pfad suchen zu müssen bzw auf windows-dialog zu verzichten.
* .. also ähnlich, wie 'presets' .. (kann ja erstma' auch ohne sb-rule sein), dann ..
* dürfte es mit einem (oder mehreren) zusätzlichen hexMem[a][b] dann forfor a,b hexGrid[a][b]=hexMem[x][y] die
* erst bei Bedarf ins Spiel kommen, kein Problem sein .. ( aber nur zur Laufzeit, sonst doch Dateien und io nötig )
* .. also erstmal in IO einsteigen ..
* (übrigens .. Life2.32 kann sogar Bitmaps lesen und laden .. !? - vllt wird das nochmal 'ne brauchbare Behelfslösung? )
* |
* - import java.io.*;
* - File PattFile= new File("SavedPattern"+i+".txt"); // +i.toString() .. ?
* - FileInputstream streamFromFileIn = new FileInputStream(PattFile);
* FileOutputStream streamToFileOut = new FileOutputStream(PattFile); .. für bytes(-arrays).
* ( In-, OutputStream() liest / schreibt in einen array, nicht Datei .. FileReader()~Writer() für 'characters', chars )
* Auch RandomAccessFile; ist möglich und schreibt UND liest und hat 'file pointer'. ( geht über DataIn-OutputStream )
* dazu : ..
* - read(byte[] b, int off, int len); write(byte[] b, int off, int len); close(); unod sicherheitshalber auch finalize()
* sowie : ..
* - mark(); oder einfach if(in.read()==511) { } um rule von x,y-Pärchen zu unterscheiden
* |
* ?? - compiler meldet: ''FileNotFoundException must be caught or declared to be thrown'' für FileIn-OutputStream ..
* jew. throws deklarieren in main und HexLife07a2PattSav() compiliert dann ohne error, startet aber das Programm nicht wg
* ''Exception in thread main'' im Output
* Wenn SavedPattern"+i+".txt unter Windows erstellt wird, startet es doch.
* Aber das soll das Programm machen! .. aber bis PattFile.createNewFile(); kommt es eben gar nicht erst .. ?????
* (immerhin wurde beim 'rumprobieren SavedPattern.txt angelegt, wenn auch leer.)
* |
* -> jetzt klappt's immerhin soweit: SavedPattern.txt wird be-schrieben, .. wieder laden klappt noch nicht:
* - File, FileIn-OutputStreams, jetzt wie Buttons, Textfield und die Listener behandelt:
* -> im Klassenblock {} angelegt, in Klassenmethode() initialisiert und ''(PattFile)'' zugewiesen ....
* -> .. und zwar dort im try{..}catch{}catch{} - Block (der unter Klassenblock {} oder in main nicht ging ..
* ''public'' für File und FileIn-OutputStreams wiederum wollte HexLife07a2PattSav() nicht annehmmen .. )
* .. sicherheitshalber mit FileNotFoundException UND IOException
* .. und beide von main string[] args() ge-throwed
* .. unter actionPerformed() wird jetzt alles erkannt.
* also:
* -> public class __Zwischenspeicherkladde extends [usw] { ..
* besser: SIEHE ''learn_FileIOStream.java''
* |
* .. load funkst noch nicht .. es wird alles gelesen .. zu sehen mit Thread.sleep() und tf1.setText: streamFromFileIn.read()
* tf1 zeigt bis zu dreistellige Zahlen an.
* (- fehlende close() unod finalize() haben die zum Schreiben geöffnete SavedPattern.txt nicht wieder geschlossen?
* nach Thread.sleep() und tf1 - check nicht möglich)
* - irgendwas am Lese-code ..
* offenbar wird alles gelesen, aber nicht richtig ausgewertet .. ?
* (- der frisch und richtig gelesene hexGrid[][] wird wegen cmd=''c'' ( für clearbutton ) erstmal wieder gelöscht bei step() !?
* ausgeschlossen <- auch ohne clearbutton geht's nicht.)
* - vielleicht hält pausebutt oder ''s''-Button mitten im algo an, wo hexGrid[][] nicht nur =1 oder =0, sondern auch 10,11,30,31
* load malt nur die =1 ~er
* - wenn load funktioniert, dann immer obenlinks .. vielleicht doch Zifferweise, statt Zahlweise gelesen ?!
* |
* load per ''ls'' reagiert nur einmal. Woran liegt's ?
* Wie vorauszusehen, wird wohl nicht bis 600 gelesen und geschrieben. ( sondern jew. bis ca. 256 = ±128 = ±2^7 )
* |
* Lösungen müssen her für:
* 1) Name (anders als lfd i) für ''SavedPattern'' + ? +''.txt'' um Speicher- und Lade-Datei richtig auszusuchen
* zB behelfsweise per try { .. tf1.getText() .. } UND sonst default="", wenn beliebig ?
* // 2) anders als byte (zu klein für 600x600)
* DataIn-OutputStream ? oder doch chars per FileReader-Writer und byte (int?) to char und zurück ?
* Es sollte auch gelingen, nur die wirklich für hexGrid benutztn Pixel zu speichern .. und nur jedes 2-te x,y=1<600 umzurech-
* -nen. Nachteil hier ist der Versatz bei y .. und 256 sind immer noch zuwenig für 600/2=300 benötigte.
* // 3) richtig laden ( nicht alles oben links .. Warum? )
* erledigt sich vllt von alleine mit anders als byte per FileIn-OutputStream
* // .. 2) und 3) erledigt .. s. unten *** 07a3PattSavRandomAccessFile
* 4) laden UND darstellen ohne 1x step()
* vllt ganz einfach per neues bool für step() ohne algo-Block ?
* 5) richtig speichern ohne Pause .. ist dann hexGrid[][]=10,11,30,31 auch ?
* -> PRÜFEN ! .. per *.write(hexGrid[][]) oder besser drawString(..,50,720)
* .. oder von vornherein ausschließen per pausebool=true; runbool=false; -> speichern, dann direkt wieder zurück true<->false ?
* .. ferner: Wie und Wann funktioniert nochmal ''return; '' .. zum hin- und herspringen zw step() und actionPerformed()
* 6) geeignet ?
*
* *** 07a3PattSavRandomAccessFile
* ( .. wie der Name schon sagt .. writeInt() und readInt() klang doch zu verführerisch )
* .. Zwischenversion in 07a2PattSav übernommen
*
* o einwandfrei!! .. lädt jetzt richtig mit writeInt() und readInt() ( schreibt und liest immer vier bytes )
* YIPPIE !
* .. damit haben sich obige 2) und 3) erledigt.
*
* o tf2 und rnd-malen hinzugefügt. .. (funktioniert zoom 6 nicht richtig wg mod-gerade-ungerade Zeilen per %4, %2 usw.)
*
* *** .. wieder *** 07a2PattSav
*
* .. weiter mit 07aRuleEdit ..
*
/ / / / / / / / ES DARF NICHT MIT zoom*(n-(301-300/zoom)) zoom*(m-(302-300/zoom)) GEMALT WERDEN !! (nach algo-Block)
* ( .. urspr. wg ArrIndexOutBound ? oder um nicht in den Rand 'reinzumalen ? .. )
*
* o noch SavedPattern+tf3.getText()+.txt hinzugefügt ( in actionPerf(), cmd=''s'' )
* o .. ganzen FileIn-OutputStream-Kram 'rausgeschmissen (in learn_FileIOStreams.java festgehalten .. gut für bis zu 256 bytes)
*
* - noch die Schönheitsfehler hinkriegen:
* - notdürftiger programflow (noch ohne Auslagern in methoden) run-pause bei scr unod rnd unod gridnew unod zoombuttSe..
* je nach Click-Reihenfolge reagiert '' > '' nicht mehr )
* .. dazu die ganzen boolSe nachverfolgen, nachvollziehen, durchdenken .. :o(
* - Lösung für ''SavedPattern*.* '' zB per tf2.getText() sonst default ''i'' .. ?
* [erl.] - ungewollter Versatz bei mousePressed(), mouseDragged() -> '' hexGrid[][]= '' .. malt richtig, iteriert aber versetzt ?!
*
* *** 07a1Zoom - eigene Zwischenversion, da viele Änderungen in __Zwischenspeicherkladde ..
*
* - rb und pb heißen jetzt runbool und pausebool
* - grid neu malen pausiert nicht mehr i
* - e.getX() in mouseDragged() und ~Pressed() war doch noch umständlicher (als einfach ''/zoom'')
* x'= muss äquivalent umgeformt werden zu x= .. also erstmals Gemaltes zurückgelesen werden zur algo-Rechenebene.
* dabei sowohl richtig gemalt, als auch hexGrid[][]= -Werte exakt vergeben werden (s. Bem. dort)
*
* .. auf Rechenebene, wo hexGrid[][] gescannt und iteriert wird, .. HAT zoom NIX ZU SUCHEN !!
* also im survive/birth-algo-Block schonmal gar nicht ..
* .. aber das genügt nicht, denn beim malen mit Maus sind beide beteiligt zoom UND hexGrid[][] wird editiert .. !??
* alle Zellen auch außerhalb zoom-area müssen 1,0 richtig zugewiesen bekommen
* Zellen dargestellt werden hingegen nur im Zoombereich.
* -> forfor und if dementsprechend geschachtelt in ''alle Teile malen'', ''mouseDragged()'' und ''mousePressed()''
* .. zoom , statt "2" bei mouseDragged(), Zeile getX(), getY() hat auch gefehlt ..
*
* - sinngem.: draw und fill 2*x,2*y jetzt zoom*x,zoom*y
* - 0 noch API, javabuch, konsultieren
*
* - zwischendurch kleinere version mit fillRect(x,y,2,2) *********** HexLife06bSmall4x4
* noch ohne initialPattern() und Pattern-IO to File
* /3 = /2 .. 3* = 2* .. fillOval = fillRect .. drawOval = drawRect (lightGray) .. 6,6 = 4,4 ..
* .. array größer [310][310] .. <200 = <300 bzw <=200 = <=300 ..
*
* - nun arrayoutbound-problem notdürftig gelöst mit j=5; k=6;
*
* - if(rb==true) {} !! .. nicht rb=true ??! (Und Button Label muß ">" sein, wenn prog jetzt mit paused startet)
* mit if rb==true wird aber nun if cmd=="#" nicht mehr erreicht .. ?! --> irgendwie umstellen!
* default jetzt rb=true, erst nach Grid Malen false (+ setText + return).
* - copypaste-Funktionalität (um Patterns nicht immer neu malen zu müssen) läßt sich auch verwirklichen, indem
* vor dem Startbutton-Klick (nach dem Mausmalen) alle An-Zellen (also hexGrid[][] ) in einem zB
* initialPattern[][] gespeichert werden, der dann mit einem neuen zB Button initialPattbutt ('skip back'
* also) das Iterieren pausiert, alles cleart,dann initialPattern[][] malt. Optimalerweise noch loadsave to
* file. (dann erübrigt sich kompliziertes copypasten vorerst .. zum Editieren später doch)
*
* - ersma' um den translate-kram kümmern - genauer:
* maus klickt und malt richtig, algo malt richtig, aber ..
* wenn #-gridbutton-Klick, malt prog die An-Zellen +20, +40 (21,42?) versetzt ..
* .. und prog malt zum Grid versetzt (wohl ab (0,0) liob Fenster) - also mausmalen und algomalen sind zum
* (erst~) Grid versetzt, .. und dann noch das gridbutton-Grid (zusätzlich?).
* Wie funktioniert dieser Fehler?
* -->
* !! Ohne translate und überall malen mit +20, +40 klappt's jetzt !! .. (s.a. debug-translate.java).
* Per gridbutton Grid neu malen überlagert jetzt richtig. Aber per clearbutton noch 1 Pixel Versatz.
*
*
* ******************* HexL05AlgoSteht .. Yippie ! :o)
*
* - ersma' als HexLife05AlgoSteht speichern weiter HexLife06
* - ärgerlich immer noch:
* o translate-kram
* bzw pause-run-Koordination bei "s, #, c", dann ">, ||"-Klick? liegt's daran?
* unod #-Grid malt ein (oder 21,42?) Pixel versetzt
* (ein Problem oder drei Probleme?)
* o arrayindexoutbound (=Rand vom hexGrid handeln)
* - dringend benötigte features:
* o edit, insbes. c&p-funktionen;
* o randomfill;
* o checkbuttons für rules;
* o save-load from file, für Testpattern;
* o zoom .. (=größeres Universum, leichteres Editieren in groß)
* - steptakt "0-500" Buttons und Methode - für Thread.sleep(steptakt(stim)) - hinzugefügt.
* - ?! ct=0 ! (nicht=1), wenn survive geprüft wird! .. (alle survive-in hexrules'08.ewr falsch gewesen!)
* - feature: grid 60° rotieren wär' gut.
* - merkenswert: ganze code-Stücke wie in Variable verpacken, wie in birthrule(int ct).
*
* *** Nachbarn scannen ***
* der Reihe nach von ab liob (zeilenweise im Springersprung) werden AN-Zellen 'behandelt':
* o erst werden alle angrenzenden AUS-Zellen auf ihre Nachbarn und birth geprüft.
* Dabei erhalten sie einen zwischenzeitlichen Wert für ''birth oder nicht'', der
* nach dem Malen und vor Stepende wieder 'Übersetzt werden muß, um am Ende wieder
* nur an- und aus-Zellen zu haben.
* o erst jetzt wird die an-Zelle auf ihre Nachbarn und survive geprüft (und erhält entspr.
* einen Zwischenwert).
* o? .. möglicherweise ist es optimaler, einen extra Prüf-array einzurichten, in den das
* Prüfergebnis birth death survive aufgenommen wird, der dann nur noch gemalt wer-
* -den muß, statt mit Zwischenwerten, was eine Umbenennungs-Schleife erfordert ?
* [ Reichlich Optimierung ist möglich, da eine Leerzelle oft an mehrere An-Zellen grenzt
* und schon fertig gescannt ist, bevor sie 'drankommt' und gar nicht mehr gescannt werden muß.
* Auch ist eine An-Zelle, die ihre Nachbarn findet, für letztere selbst Nachbar. (Es ist
* aber wohl aufwendiger, diese Ersparnis aus dem systematischen scan (zB im Uhrzeigersinn)
* auszunehmen, damit sie sich auch auswirkt (Zeilen einer switch-Schleife überspringen
* oder einen extra Nachbar-array für jede An-Zelle (??) einrichten zu müssen?)
* Programm läuft aber eh' so schnell, daß sogar Thread.sleep(#) nötig is'.]
*
*
[j-2][k-4] [j][k-4] [j+2][k-4]
[j-3][k-2] [j-1][k-2] [j+1][k-2] [j+3][k-2]
[j-4][k] [j-2][k] [j][k] [j+2][k] [j+4][k]
[j-3][k+2] [j-1][k+2] [j+1][k+2] [j+3][k+2]
[j-2][k+4] [j][k+4] [j+2][k+4]
* - ..
* -
* - translate:
* funkst nur scheinbar .. programm malt über das grid hinaus bis in liob Ecke und unten zu 'kurz'.
* korrigier' ich's, kann die maus nich' mehr stimmen .. ?!
* Aber den Nachbaralgo kann ich ja schomma machen ..
* - in den schnell-langsam-Wechsel sind alle Buttons involviert:
* zunächst läuft es schnell, gridbuttonmacht's langsam, dann play oder snapshot-Buttons wieder schnell o.s.ä.
*
* Bestandsaufnahme ..
* [HexL04BereitFuerRulesAlgo; HexL04Diffus; HexLife (im eigenen projekt neben bzw drüber)]
* - HexLife.java, ein projekt drüber war wohl der accu?
* aber es verhält sich anders als HexL04BereitFuerRulesAlgo und auch HexL04Diffus, ..
* zu letzterer unterscheidet sich HexLife nur ca. Zeile 46 (forfor n,m-Schleife; -21, -42, statt -1,-2).
* Is'vielleicht neu gespeichert, aber noch nich' compiliert?
* - das translate-chaos muß weg! .. ggf ganz verzichten? _[ gemalt)
* (oder: in ''bereitfürrules'' wird wohl nochmal transliert, wenn gridbutton geklickt wird, dadurch doppelt
* - immer noch arrayindexoutbound exceptions.
* - eine version läuft langsam, andere schnell; 'mal ändert gridbutton das tempo hin zu 'höllisch'; auch
* snapshot; .. ?
* - HexL04BereitFuerRulesAlgo und HexL04Diffus unterscheiden sich nur durch screenshot und algo in forfor-
* n,m-Schleife (''BereitFuerusw'' hat nur eine rudimentäre probierzeile drin).
* HexL04Diffus scheint demnach die jüngste und beste version zu sein (nicht eine Abwandlung).
* .. und HexLife demnach der Ober-speicher-accu.
* - HexL04Diffus war offenbar noch nich' compiliert .. läuft jetzt auch zT. (s.o.) schnell bzw so, wie auch HexLife.
*
* [drüber: 23,01,08]
*
* [älterer, vorgefundener Kommentar]
* jetzt alle freien nachbarn scannen (nachbarsnachbarn zählen für birth); alle Nachbarn zählen für survive ..
*
* ******************** HexLife04Diffus
*
* - .. was kann alles 'draus werden ?
* - Zufallsweg-algo, 'Schmetterlingsweg'
*
* ******************** HexL04BereitFuerRulesAlgo
*
* - pauserunbutton hinzugefügt
* - if (robo.getPixelColor(42+3*x ,52+3*y)==Color.black) {} um pixelfarbe vom screen zu lesen verworfen, dafür wieder ..
* - mit array alle pixel im hexGrid erfaßbar, scanbar, prüfbar und malbar gemacht. pixel löschen is' dann trivial
* .. sg.translate(..) wird später anscheinend von mg bzw getGraphics miterfaßt
* .. ohne rb und pb wirkt "#", gridbutton, wie ein pausebutton, weil cmd!=">" ..
* ! Achtung ! .. in zB forfor-n,m-Schleife ist translate(20,40) nicht berücksichtigt -> beim malen wieder abziehen (-21,-42).
* auf e.getX() bzw Y wirkt's offenbar mit.
* - einfacher algo (testweise) verwirklicht.
*
* .. alles bißken zusammengeschustert und 'rumprobiert .. warum funktioniert m%2 nicht? ..
* .. Lösung mit pb und rb noch nich' optimal: während run gridbutton klicken, läßt cmd="#" nicht nur für einen step() das Grid auffrischen
* .. translate, e.getX/3, .. (was noch?) verlangt alles in allem malen x: -1, y: -2 .. warum genau bleibt schleierhaft ..
* .. die unterschiedliche Behandlung der Exceptions is' noch unklar (warum awex, und nich' sex schon bei step() .. warum sex, und nich'
* awex erst bei robo.createScreenCapture() ? ) .. aber es funktioniert ja und die HexLife-Routine kann beginnen!
*
* - screenshotbutton + boolean shot hinzugefügt .. sonst "relaxed" immer true (nach einmal released) und programm viel langsamer! (speichert ständig screenCaptures)
* .. translate stimmt immer noch nich' ganz .. pixel malebene ist um translate verschoben und liefert ArrayIndexOutOfBounds, wenn pixel über'n Rand weglaufen ..
* wenn statt - in der forfor-n,m-routine - bei -21,-42, bei -1, -2 gemalt werden lasse, bleiben die (zufallswege der) pixel richtig am rand des Grid stehen,
* aber bei den mausgesetzten pixeln wird translate(20,40) durchgeführt .. ?! .. vielleicht wirkt translate auf e.getX() bzw Y doch nicht .. ? .. würde
* heißen: mausgesetzte pixel sind (beim malen doch) nicht transliert ..
* .. möglicher Fehler: translate() wirkt - natürlich - in step(), aber nicht in mousePressed() oder mouseDragged .. -> dort auch mg.translate machen? oder
* entsprechend draw-coords korrigieren (mit -21, -42) .. ?
* .. dort auch translate(20,40) führt dazu, daß mouse-eingegebene pixel +20,+40 von der maus weg gemalt werden .. ?! .. ??
* also mousePressed() und mouseDragged() malt an der richtigen Stelle (translate(+20,+40) ..
* forfor-n,m rechnet und malt ebenfalls vom mausgesetzten pixel aus richtig weiter, .. nur ist dabei der 'gültigkeitsbereich' (?) der malebene um (-20,-40)
* verschoben ?! .. wie kann das sein? ..
*
*
* ******************** HexL03WoW .. RoboKram & ImageIO.write(..)
*
* .. ein screenshot vom Fenster soll gemacht werden, dann als Bild zB *.jpg oder *.bmp auf Festplatte abgespeichert werden
*
* der Robot macht einen screenshot als BufferedImage, das für javax.imageio.ImageIO.write(RenderedImage,string Bildformat,File)
* als RenderedImage gilt!
//? * der Robot macht einen screenshot als BufferedImage, das wiederum ein WritableRaster kopieren kann, ..
//? * von javax.imageio.ImageIO.write(RenderedImage,string Bildformat,File) wird RenderedImage gebraucht ..?
//? * außerdem gibt's noch WritableRaster, WritableRenderedImage möglicherweise werden noch ImageReader und ImageWriter für ImageIO benötigt
*
* - der Robot muß richtig .. äh .. 'eingerichtet' werden: (im class-Kopf als variable einrichtet klappt nich' .. )
* java.awt.Robot.createScreenCapture(Rectangle) wirft IllegalArgumentException (aber nur, wenn Rect.width() oder Rect.height()==0 )
* .. wirft SecurityException, wenn Konflikt mit Windows, .. errormeldung beim kompilieren verlangt aber nach catch or throw
* AWTException!?
* .. also irgendwie, bevor er überhaupt eingerichtet ist, muß AWTException schon zum Abgefangen werden bereit sein .. ?1
* Robot robo=new Robot(); also erst in Methode instanzieren & initialisieren, die AWTException catcht oder throwt
* aktuell: step() throws und run() while[..] { mit try { step(getGraphics()); }catch[..usw]
* - man hat damit schonmal ein BufferedImage .. und das ist ein RenderedImage! .. jedenfalls funktioniert
* ImageIO.write(BufferedImage,string [Bildformat], File);
* .. wohl, weil BufferedImage interface RenderedImage implementiert
*
* ******************* HexL02MausMalen
*
* - ClickMe Applet (allJava CD) link: e'exShred'Javatool' code zBs [usw]. html
* bißchen umständlich mit "Spot"-kram .. MouseListener-Sachen dafür übersichtl.
*
* ******************* WSP - candy / HexL01SpringerGitterBunt
*
* - siehe ../stories/hexneighbours.bmp & hexneighbour's neighbours.bmp
* wg Springer-Gitter per Modulo-Bedingungen
*/