From 2ef8b0fca1590fa0722b453a5af3408c353137fd Mon Sep 17 00:00:00 2001 From: Francois Fleuret Date: Sat, 24 Aug 2013 11:16:15 +0200 Subject: [PATCH] Initial commit --- Grid.class | Bin 0 -> 8775 bytes Square.class | Bin 0 -> 805 bytes Words.class | Bin 0 -> 3884 bytes Words.java | 611 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 611 insertions(+) create mode 100644 Grid.class create mode 100644 Square.class create mode 100644 Words.class create mode 100644 Words.java diff --git a/Grid.class b/Grid.class new file mode 100644 index 0000000000000000000000000000000000000000..d902c49b875ce289cbc63fe967fc7e0ccba3973f GIT binary patch literal 8775 zcmb7Kd3@AGvakC6esg3pfe`osfdm0j!bA=Oj886!k!t}#K@h`{Au~w^CNps|0fMNj zMqMww4+J3r))DbQB!jDXtc&RCdMzHPd*Ss~eb4uH_pNW;b)EOE{>_yT*XJKo-Cb2( zRb5?Ozv}+X%iliv4CyqQCpu}jlYZ)?*PZltCw=4Ou?~8{L9aRJ4F?@{&|41r)`u*iFBoy>9xQ41X^yf1p>~be!ID(}(n&n?9obZu*!Gy6F>o)=i(%AvgUy{oGA| z6vAipOE-N^FT3dr`h}bRgW_)bPXS*F_%FKOP5&*uKMVMafWL~OuLS%r9d*;+=!l!X z7Vr;I{!e<;&3(YfMfA9v`vS+spzhfbLLq1T=TM=ivt^CmC=ANH940_tm~g+$gHTZsX_DzVPH=L zYn>%Iq`MvqCEf=4PfD82fH4OI4k zEdjVI1n&I0U?{XO5^AlFgfUk})?A|ws)ddwwL`G5F47_^%c~E>Dw}KJUnoKUoIq+I zgxP^$eM5=>pNUx(mkd-06@qJFG=N}@2KDBK2(FO8y&&0Kd@mz9UPhoN)@L_X*r0-rbt+= zEsM+~WkoYg0TPA8$AVcVyj+h3WNXZ6a zaW`T%2{D!QM9WU?tH@oC8G=z^b529r<{Xrjc)IeoA~!a|{c8iQ*y`ry0Cp`OgYyHS zfKQE_7%gsX5`sMx2-nMTFhY@9oEW<_LU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001 diff --git a/Words.class b/Words.class new file mode 100644 index 0000000000000000000000000000000000000000..2f6ab99a5468417a13d706a08f5f6d3e773949ed GIT binary patch literal 3884 zcmaJ^TX+-K5&qAyq+P97wpk;LA;toNEz81!q&TVVIDmtR8XE{E7y)Tm%WHW--ZiTg zCTUBOHciteZPQztUIJ}tp|>6~3%Y%qP9 zIp?3tnKNf*w0ir$SKdG!Hsfs>hK!HOI3wc;8Bfaigp8+Td{V~KGCn2a(=t9I<8v}T zFXM|cz9!?FGG3B#PR6%nd|SqMWc*0R%QAi<<24z-mhqO11sT_6{7%BhC451`mn3{e z!cQgqOu{7zmnD=W%u9G(!p|jKk#JSQFC<)(@P>q6D!3gZ3c3a9z^H;4_9)ndy$ZUp zPeBq7Du`phAY(#sAdC%oNa!6Dt8oPh98%DUjBs^W!B!j*f}=v^VX^wKf-QJNkYfr` z(1r4ZLixxFY*NL?a9ohQAdVn&f}9rQQ59dstRRo6coD9Ouj4rt-w+mO@mUq$#Yq+4 zLr%p7oKo?9Osn{TQ2C)y`7xeR@d{>C{0dVleuJWl-@;b$CO)F#_plhiP#5n?GeqNE zBggeqdP<*jQ@b5~cG}Dq`WaSM@Vsv2QhO(k8(H@zc+7Q7D@QQ-I>@jp-gV@N@6EHS ziUaYqkO$-Gv^aB>;LGVX$7`_+*?HUP7iNhi=*+Bb8J63>DC{A-0y1WTfR zK{0zbeELSs+S#7r(rv|Vc{H8&@x|A!X&x|6yE`01@4s0|+^>C6AjT=WTWUwvHEnB` zSbG`Ra0`tQv)~$*;ioBDR$3f`$acqa_|1`sQn(ov@wF_2(*u%Z^|BIAG_Z`QmXX?v z-QpPo@x$T(*254QFfG#^WLUdX&z{IRcF~%QdDRh%+p{83dcKPxFl0{}4APKYbWFpc zD!b2^5|*S;SgN_(F((-|3Kq*w>yDmv4JS55)e*Dw8Doj^vRVc6v87t7?~6RplQGnL z+iAnhP18>Cc5~*WJ59G45j$#`2&g`_2JrSF;oypGFMA3C^Ye^j4 zH>l^#Q^u{e8%Ipb*i)RDFq{MWM4s}pqL%!fo_7kNxrS9sl%Z?CJr~m{$5}gHoUvl2 zHEEo_MRxv=?oByT#^`0T#;_^E35}gB>JBX)AEz6~^x4_G;l@sF?b)V`JElu%^g@Vd zyJEwRZe?w=5F5@LMaOWHu^HXW$6Px$FjW@yO!=birsbG=&y+K$40-9CcHP;&RBCQ+ zZnI-&Pxe&gsWW8@g{G2-pg_;$@g6Y@DK*Q^u|}#CDyMyhL(ev2P!ZMXlSEe#^?SC` zkyMBiIZB{Sg;?)Bt)F#t+U=t@m@%ji7@8JueFtHJ{O6-Q ziPEdwMiv|YG7+&{beBNRYcoZ#N-KoLrrZgVS6F+e=rW>B>GCGEPfkRj`M*fs4O0F^ z7#gcTQDew2d|0Sjd${SWr43wZ{JA%uz zx>GR76d6;F#?Zib4bz0-A#QX>pIt_djoR1K45hsXJ6s!PANbr7B{WWaN)P=5LOQue1 z8p{N>6Juz)K*Gy%7ZC}aUwoHSSApn$_=-z%zcy?~W6+){2s{iRrE9y=q-=B-wO28YyA8w;>sg zL>o$YKm=SLZ3r9_!qhTCwJeNAk|pdWi#^f$v)B+-&!Ua8lgwx=sz&QW^SJvm2B}2` z>q_`gLet7og)}}&da+Dvur<^wwaU?OR1qCDxOpDiE@M|hTkAJg-*`e>Q4YCd0TK^TBKi|r%QE625)XM|QlqC3+XbYrqB}E>JNrZ*4=fMct6;JB~g14CtC zZ~+YoZ5@dQOAvvqYo$E(jn{g8f&OiQ{R0yFC+gY1u!j8y>)CsVv-gprzTM6_MtJ~- zc!(-e!W0iqv~wO-+7EN zzMeJkjjWw-VqLt0_47_P#JkypJjpD+nLWx=>@WOY_AaOB_zqsr-ld9vo`wv^m;VPaVE91* literal 0 HcmV?d00001 diff --git a/Words.java b/Words.java new file mode 100644 index 0000000..8b3c0ef --- /dev/null +++ b/Words.java @@ -0,0 +1,611 @@ +/****************************************************************************** + + Cross-Words applet v1.5 (c) Francois FLEURET + + This small applet is an interactive crosswords grid for web + pages. Mail for bug reports and + questions. + + In the past, I put his applet under a pure GPL licence. So, what was + expected to happen happened : commercial sites used it and I saw + people earning money with my work without giving me a single + buck. This is bad. So, now this software is distributed under the FFL + (Francois Fleuret Licence) which is the same as GPL version 2, plus + the following paragraph: + + * + * RESTRICTION OF USE FOR APPLET SOFTWARES + * + * 13 The site the applet is used on must be a NON-PROFIT site, which + * implies it does not contain banners or any other mean to make money + * (including indirectly, for example as an ISP portal). The name of + * all the authors of the software and a link to the URL they provide + * in the source code must appear on any web page that uses the + * applet. If the source code was modified, the modified source must + * be downloadable from the site the applet is used on. + * + + So, if you use this applet on a non-profit site, please add a link to + http://www-rocq.inria.fr/~fleuret and a short note indicating my name + as the author of the applet. For any other usage, please contact + me. Be sure we can make a deal for a reasonnable price. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + Sept 11th 2000, François Fleuret + +******************************************************************************/ + +import java.applet.Applet; +import java.awt.*; +import java.awt.event.*; +import java.lang.Object; + +class Square { + char solution; + char found; + boolean ajour; + boolean holdCursor; + boolean locked; + Color color; + + Square(char c) { + solution = c; + found = ' '; + ajour = false; + locked = false; + color = Color.black; + } + + void setFound(char c) { if(c != found) { found = c; ajour = false; } } + + void putCursor() { if(!holdCursor) ajour = false; holdCursor = true; } + + void remCursor() { if(holdCursor) ajour = false; holdCursor = false; } + + void lock(Color c) { + if(!locked) { + ajour = false; + locked = true; + color = c; + } + } +} + +class Grid extends Panel implements KeyListener, MouseListener { + int gridWidth, gridHeight; + int xCursor, yCursor; + int nbLetters, nbFound; + boolean cursorHorizontal; + + int xMargin, yMargin; + Square grid[][]; + Font font, smallFont; + FontMetrics fontMetrics, smallFontMetrics; + int squareSize; + + TextArea definitionArea; + String[][][] definitions; + + Grid(Font f, Font sf, + FontMetrics fm, FontMetrics sfm, + int w, int h, + String content, + TextArea ta, String def) { + + int x, y, xx, yy, k; + + font = f; fontMetrics = fm; + smallFont = sf; smallFontMetrics = sfm; + squareSize = fontMetrics.getHeight(); + + gridWidth = w; + gridHeight = h; + grid = new Square[gridWidth][gridHeight]; + + yMargin = smallFontMetrics.getHeight(); + xMargin = yMargin; + + nbLetters = 0; nbFound = 0; + k = 0; + for(y = 0; y 0) && ((def.indexOf(':', i) > j) || (def.indexOf(':', i) < 0))) { + direction = def.substring(i, j).toLowerCase(); + j++; + } else j = i; + + + i = j; + y = 0; + while((def.charAt(i) >= 'a') && (def.charAt(i) <= 'z')) + y = y*26 + ((int) def.charAt(i++)) - 'a'; + + x = 0; + while((def.charAt(i) >= '0') && (def.charAt(i) <= '9')) + x = x*10 + ((int) def.charAt(i++)) - '0'; + x--; + i++; + + j = def.indexOf('/', i); + if(j < 0) j = def.length(); + sd = def.substring(i, j); + j++; + + if(direction.equals("horizontal")) { + for(xx = x; (xx>=0) && (grid[xx][y].solution != '.'); xx--) + definitions[xx][y][0] = sd; + for(xx = x; (xx=0) && (grid[x][yy].solution != '.'); yy--) + definitions[x][yy][1] = sd; + for(yy = y; (yy=0) && (grid[xx][y].solution != '.'); xx--) { + grid[xx][y].setFound(grid[xx][y].solution); + grid[xx][y].lock(Color.red); + } + + for(xx = x; (xx=0) && (grid[x][yy].solution != '.'); yy--) { + grid[x][yy].setFound(grid[x][yy].solution); + grid[x][yy].lock(Color.red); + } + + for(yy = y; (yy=0) && (grid[xmin][y].solution != '.'); xmin--) + ok &= (grid[xmin][y].solution == grid[xmin][y].found); + + for(xmax = x; ok && (xmax=0) && (grid[x][ymin].solution != '.'); ymin--) + ok &= (grid[x][ymin].solution == grid[x][ymin].found); + + for(ymax = y; ok && (ymax 0) && (grid[xCursor][y].solution == '.')) y--; + if((y >= 0) && (grid[xCursor][y].solution != '.')) { + grid[xCursor][yCursor].remCursor(); + yCursor = y; + grid[xCursor][yCursor].putCursor(); + } + } + else if(code == KeyEvent.VK_DOWN) { + y = yCursor+1; + while((y < gridHeight-1) && (grid[xCursor][y].solution == '.')) y++; + if((y < gridHeight) && (grid[xCursor][y].solution != '.')) { + grid[xCursor][yCursor].remCursor(); + yCursor = y; + grid[xCursor][yCursor].putCursor(); + } + } + else if(code == KeyEvent.VK_LEFT) { + x = xCursor-1; + while((x > 0) && (grid[x][yCursor].solution == '.')) x--; + if((x >= 0) && (grid[x][yCursor].solution != '.')) { + grid[xCursor][yCursor].remCursor(); + xCursor = x; + grid[xCursor][yCursor].putCursor(); + } + } + else if(code == KeyEvent.VK_RIGHT) { + x = xCursor+1; + while((x < gridWidth-1) && (grid[x][yCursor].solution == '.')) x++; + if((x < gridWidth) && (grid[x][yCursor].solution != '.')) { + grid[xCursor][yCursor].remCursor(); + xCursor = x; + grid[xCursor][yCursor].putCursor(); + } + } + else if(code == Event.ENTER) { + cursorHorizontal = !cursorHorizontal; + grid[xCursor][yCursor].ajour = false; + } + else if(code == Event.BACK_SPACE) { + if((grid[xCursor][yCursor].found == ' ') || grid[xCursor][yCursor].locked) { + if(cursorHorizontal) { + if(xCursor > 0) + if(grid[xCursor - 1][yCursor].solution != '.') { + grid[xCursor][yCursor].remCursor(); + xCursor--; + grid[xCursor][yCursor].putCursor(); + } + } else { + if(yCursor > 0) + if(grid[xCursor][yCursor - 1].solution != '.') { + grid[xCursor][yCursor].remCursor(); + yCursor--; + grid[xCursor][yCursor].putCursor(); + } + } + } + + if(!grid[xCursor][yCursor].locked) { + if(grid[xCursor][yCursor].found == grid[xCursor][yCursor].solution) + nbFound--; + grid[xCursor][yCursor].setFound(' '); + } + } else if(key == ' ') { + if(definitionArea != null) { + if(cursorHorizontal) definitionArea.setText(definitions[xCursor][yCursor][0]); + else definitionArea.setText(definitions[xCursor][yCursor][1]); + } + } else if((key >= 'a') && (key <= 'z')) { + if(!grid[xCursor][yCursor].locked) { + if(grid[xCursor][yCursor].found == grid[xCursor][yCursor].solution) + nbFound--; + grid[xCursor][yCursor].setFound((char) key); + if(grid[xCursor][yCursor].found == grid[xCursor][yCursor].solution) + nbFound++; + } + + if(cursorHorizontal) { + if(xCursor < gridWidth-1) + if(grid[xCursor + 1][yCursor].solution != '.') { + grid[xCursor][yCursor].remCursor(); + xCursor++; + grid[xCursor][yCursor].putCursor(); + } + } else { + if(yCursor < gridHeight-1) + if(grid[xCursor][yCursor + 1].solution != '.') { + grid[xCursor][yCursor].remCursor(); + yCursor++; + grid[xCursor][yCursor].putCursor(); + } + } + + if(nbFound == nbLetters) { + for(y = 0; y= gridWidth) xc = gridWidth-1; + yc = (mouseEvent.getY()-yMargin)/squareSize; + if(yc < 0) yc = 0; + if(yc >= gridHeight) yc = gridHeight-1; + + if(grid[xc][yc].solution != '.') { + grid[xCursor][yCursor].remCursor(); + xCursor = xc; yCursor = yc; + grid[xCursor][yCursor].putCursor(); + } + + repaint(); + } + + public void mouseClicked(MouseEvent mouseEvent) {} + public void mouseReleased(MouseEvent e) {} + public void mouseEntered(MouseEvent e) {} + public void mouseExited(MouseEvent e) {} + + public Dimension getPreferredSize() { + return new Dimension(xMargin + gridWidth*squareSize + 1, + yMargin + gridHeight*squareSize + 1); + } + +} + +public class Words extends Applet implements ActionListener { + Grid grid; + Button checkButton, giveButton; + TextArea definitionArea; + + public void init() { + String fontName, s, definitionString; + int fontSize; + + Font f, sf; + FontMetrics fm, sfm; + int w, h, wd, hd; + + s = getParameter("bgcolor"); + if(s != null) + setBackground(new Color(Integer.parseInt(s))); + + fontName = getParameter("font"); + if(fontName == null) fontName = "Courier"; + + s = getParameter("fontsize"); + if(s == null) fontSize = 48; else fontSize = Integer.parseInt(s); + + f = new Font(fontName, Font.PLAIN, fontSize); + + fm = getGraphics().getFontMetrics(f); + + fontName = getParameter("smallfont"); + if(fontName == null) fontName = "Courier"; + + s = getParameter("smallfontsize"); + if(s == null) fontSize = 20; else fontSize = Integer.parseInt(s); + + sf = new Font(fontName, Font.ITALIC, fontSize); + sfm = getGraphics().getFontMetrics(sf); + + s = getParameter("gridwidth"); + if(s == null) w = 1; else w = Integer.parseInt(s); + + s = getParameter("gridheight"); + if(s == null) h = 1; else h = Integer.parseInt(s); + + definitionString = null; + + s = getParameter("definitions"); + + if(s != null) { + int i, j; + wd = -1; hd = -1; + + // Find the width and the height + i = 0; j = s.indexOf('x', i); + wd = Integer.parseInt(s.substring(i, j)); + i = j+1; j = s.indexOf('/', i); + hd = Integer.parseInt(s.substring(i, j)); + + i = j+1; definitionString = s.substring(i, s.length()); + + if((wd > 0) && (hd > 0)) { + definitionArea = new TextArea("", hd, wd, TextArea.SCROLLBARS_NONE); + definitionArea.setEditable(false); + } + } + + s = getParameter("content"); if(s == null) s = "."; + grid = new Grid(f, sf, fm, sfm, w, h, s, definitionArea, definitionString); + add("north", grid); + + s = getParameter("checkwordlabel"); + if(s != null) { + checkButton = new Button(s); + checkButton.addActionListener(this); + } + + s = getParameter("givewordlabel"); + if(s != null) { + giveButton = new Button(s); + giveButton.addActionListener(this); + } + + if((checkButton != null) || (giveButton != null)) { + Panel buttonPanel; + buttonPanel = new Panel(); + if(checkButton != null) buttonPanel.add(checkButton); + if(giveButton != null) buttonPanel.add(giveButton); + if(definitionArea != null) add("south", definitionArea); + add("south", buttonPanel); + } + } + + public void actionPerformed(ActionEvent event) { + Object source = event.getSource(); + if(source == checkButton) grid.checkWord(); + else if(source == giveButton) grid.giveWord(); + } + + public String getAppletInfo() { + return "Word applet v1.5\n" + + "Written and (c) Francois Fleuret, mail to \n" + + "Check http://www-rocq.inria.fr/~fleuret\n"; + } + + public String[][] getParameterInfo() { + String chose[][] = { + { "bgcolor", "integer", "Background Color (optional)" }, + { "font", "font name", "Grid character font name (optional)" }, + { "fontsize", "integer", "Grid character font size (optional)" }, + { "smallfont", "font name", "Row and column index font name (optional)" }, + { "smallfontsize", "integer", "Row and column index font size (optional)" }, + { "gridwidth", "integer", "Grid width" }, + { "gridheight", "integer", "Grid height" }, + { "content", "string", "Grid content" }, + { "definitions", "string", "Definitions (optional)" }, + { "checkwordlabel", "string", "Label for the 'check word' button (optional)" }, + { "givewordlabel", "string", "Label for the 'give word' button (optional)" } + }; + + return chose; + } +} + -- 2.39.5