BlinkenSimJava v.0.2 (2006-07-28)
Christian Heimke

Christian Heimke commited on 2011-07-15 09:13:27
Showing 45 changed files, with 846 additions and 24 deletions.

... ...
@@ -0,0 +1,47 @@
1
+# BlinkenSim
2
+# version 0.1 date 2006-07-28
3
+# Copyright (C) 2004-2006: Stefan Schuermans <1stein@schuermans.info>
4
+# Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html
5
+# a blinkenarea.org project
6
+
7
+BLINKEN_LIB=../BlinkenLibJava/BlinkenLib.jar
8
+
9
+JAVAC=javac
10
+JAR=jar
11
+KEYTOOL=keytool
12
+JARSIGNER=jarsigner
13
+KEYPASS=BlinkenLib
14
+JAVA=java
15
+P=org/blinkenarea/BlinkenSim
16
+
17
+CLASSPATH=.:$(BLINKEN_LIB)
18
+CLASS_FILES=$(P)/FrameReceiver.class $(P)/DataSource.class \
19
+            $(P)/DynMcufClientRecv.class $(P)/DynMcufClientSend.class $(P)/DynMcufClient.class \
20
+            $(P)/MoviePlayerTimerTask.class $(P)/MoviePlayer.class $(P)/PlaylistPlayer.class \
21
+            $(P)/BlinkenSim.class
22
+
23
+.phony: all clean jar
24
+
25
+all: jar
26
+
27
+clean:
28
+	rm -f $(CLASS_FILES) BlinkenSim.jar
29
+
30
+jar: BlinkenSim.jar
31
+
32
+%.class: %.java
33
+	$(JAVAC) -classpath $(CLASSPATH) $<
34
+
35
+BlinkenSim.keystore:
36
+	$(KEYTOOL) -genkey -alias BlinkenSim -keystore BlinkenSim.keystore -keypass $(KEYPASS) -storepass $(KEYPASS)
37
+
38
+BlinkenSim.jar: BlinkenSim.keystore $(CLASS_FILES)
39
+	$(JAR) cf BlinkenSim.jar $(CLASS_FILES)
40
+	rm -rf jar.tmp
41
+	mkdir jar.tmp
42
+	cat $(BLINKEN_LIB) | ( cd jar.tmp ; $(JAR) x )
43
+	rm -rf jar.tmp/META-INF
44
+	$(JAR) uf BlinkenSim.jar -C jar.tmp .
45
+	rm -rf jar.tmp
46
+	$(JARSIGNER) -keystore BlinkenSim.keystore -storepass $(KEYPASS) BlinkenSim.jar BlinkenSim
47
+
... ...
@@ -0,0 +1,25 @@
1
+<html>
2
+  <head>
3
+    <title>BlinkenSimJava - bluebox - 1024x420</title>
4
+  </head>
5
+  <body>
6
+    <applet archive="BlinkenSim.jar" code="org.blinkenarea.BlinkenSim.BlinkenSim" width="1024" height="420">
7
+      <param name="pixelX" value="98">
8
+      <param name="pixelY" value="7">
9
+      <param name="colors" value="16">
10
+      <param name="background" value="bluebox-1024x420-bg.png">
11
+      <param name="backgroundX" value="1024">
12
+      <param name="backgroundY" value="420">
13
+      <param name="overlay" value="bluebox-1024x420-ov.png">
14
+      <param name="windowX" value="8">
15
+      <param name="windowY" value="14">
16
+      <param name="startX" value="24">
17
+      <param name="startY" value="65">
18
+      <param name="distanceX" value="10">
19
+      <param name="distanceY" value="28">
20
+      <param name="mode" value="stream">
21
+      <param name="host" value="127.0.0.1">
22
+      <param name="port" value="6861">
23
+    </applet>
24
+  </body>
25
+</html>
... ...
@@ -0,0 +1,25 @@
1
+<html>
2
+  <head>
3
+    <title>BlinkenSimJava - bluebox - 1139x413</title>
4
+  </head>
5
+  <body>
6
+    <applet archive="BlinkenSim.jar" code="org.blinkenarea.BlinkenSim.BlinkenSim" width="1139" height="413">
7
+      <param name="pixelX" value="98">
8
+      <param name="pixelY" value="7">
9
+      <param name="colors" value="16">
10
+      <param name="background" value="bluebox-1139x413-bg.png">
11
+      <param name="backgroundX" value="1139">
12
+      <param name="backgroundY" value="413">
13
+      <param name="overlay" value="bluebox-1139x413-ov.png">
14
+      <param name="windowX" value="8">
15
+      <param name="windowY" value="15">
16
+      <param name="startX" value="101">
17
+      <param name="startY" value="112">
18
+      <param name="distanceX" value="10">
19
+      <param name="distanceY" value="34">
20
+      <param name="mode" value="stream">
21
+      <param name="host" value="127.0.0.1">
22
+      <param name="port" value="6861">
23
+    </applet>
24
+  </body>
25
+</html>
... ...
@@ -0,0 +1,25 @@
1
+<html>
2
+  <head>
3
+    <title>BlinkenSimJava - bluebox - 512x210</title>
4
+  </head>
5
+  <body>
6
+    <applet archive="BlinkenSim.jar" code="org.blinkenarea.BlinkenSim.BlinkenSim" width="512" height="210">
7
+      <param name="pixelX" value="98">
8
+      <param name="pixelY" value="7">
9
+      <param name="colors" value="16">
10
+      <param name="background" value="bluebox-512x210-bg.png">
11
+      <param name="backgroundX" value="512">
12
+      <param name="backgroundY" value="210">
13
+      <param name="overlay" value="bluebox-512x210-ov.png">
14
+      <param name="windowX" value="4">
15
+      <param name="windowY" value="7">
16
+      <param name="startX" value="12">
17
+      <param name="startY" value="33">
18
+      <param name="distanceX" value="5">
19
+      <param name="distanceY" value="14">
20
+      <param name="mode" value="stream">
21
+      <param name="host" value="127.0.0.1">
22
+      <param name="port" value="6861">
23
+    </applet>
24
+  </body>
25
+</html>
... ...
@@ -0,0 +1,25 @@
1
+<html>
2
+  <head>
3
+    <title>BlinkenSimJava - bluebox - 569x206</title>
4
+  </head>
5
+  <body>
6
+    <applet archive="BlinkenSim.jar" code="org.blinkenarea.BlinkenSim.BlinkenSim" width="569" height="206">
7
+      <param name="pixelX" value="98">
8
+      <param name="pixelY" value="7">
9
+      <param name="colors" value="16">
10
+      <param name="background" value="bluebox-569x206-bg.png">
11
+      <param name="backgroundX" value="569">
12
+      <param name="backgroundY" value="206">
13
+      <param name="overlay" value="bluebox-569x206-ov.png">
14
+      <param name="windowX" value="4">
15
+      <param name="windowY" value="8">
16
+      <param name="startX" value="50">
17
+      <param name="startY" value="56">
18
+      <param name="distanceX" value="5">
19
+      <param name="distanceY" value="17">
20
+      <param name="mode" value="stream">
21
+      <param name="host" value="127.0.0.1">
22
+      <param name="port" value="6861">
23
+    </applet>
24
+  </body>
25
+</html>
... ...
@@ -3,7 +3,7 @@
3 3
     <title>BlinkenSimJava - BNF - 144x108</title>
4 4
   </head>
5 5
   <body>
6
-    <applet archive="BlinkenSim.jar" code="BlinkenSim.class" width="144" height="108">
6
+    <applet archive="BlinkenSim.jar" code="org.blinkenarea.BlinkenSim.BlinkenSim" width="144" height="108">
7 7
       <param name="pixelX" value="26">
8 8
       <param name="pixelY" value="20">
9 9
       <param name="colors" value="8">
... ...
@@ -17,8 +17,9 @@
17 17
       <param name="startY" value="5">
18 18
       <param name="distanceX" value="2">
19 19
       <param name="distanceY" value="4">
20
+      <param name="mode" value="stream">
20 21
       <param name="host" value="www.1stein.no-ip.com">
21 22
       <param name="port" value="23231">
22
-    </applet archive="BlinkenSim.jar">
23
+    </applet>
23 24
   </body>
24 25
 </html>
... ...
@@ -3,7 +3,7 @@
3 3
     <title>BlinkenSimJava - BNF - 144x108</title>
4 4
   </head>
5 5
   <body>
6
-    <applet archive="BlinkenSim.jar" code="BlinkenSim.class" width="144" height="108">
6
+    <applet archive="BlinkenSim.jar" code="org.blinkenarea.BlinkenSim.BlinkenSim" width="144" height="108">
7 7
       <param name="pixelX" value="26">
8 8
       <param name="pixelY" value="20">
9 9
       <param name="colors" value="8">
... ...
@@ -17,8 +17,9 @@
17 17
       <param name="startY" value="5">
18 18
       <param name="distanceX" value="2">
19 19
       <param name="distanceY" value="4">
20
+      <param name="mode" value="stream">
20 21
       <param name="host" value="192.168.0.33">
21 22
       <param name="port" value="23231">
22
-    </applet archive="BlinkenSim.jar">
23
+    </applet>
23 24
   </body>
24 25
 </html>
... ...
@@ -3,7 +3,7 @@
3 3
     <title>BlinkenSimJava - BNF - 640x480</title>
4 4
   </head>
5 5
   <body>
6
-    <applet archive="BlinkenSim.jar" code="BlinkenSim.class" width="640" height="480">
6
+    <applet archive="BlinkenSim.jar" code="org.blinkenarea.BlinkenSim.BlinkenSim" width="640" height="480">
7 7
       <param name="pixelX" value="26">
8 8
       <param name="pixelY" value="20">
9 9
       <param name="colors" value="8">
... ...
@@ -17,8 +17,9 @@
17 17
       <param name="startY" value="31">
18 18
       <param name="distanceX" value="7">
19 19
       <param name="distanceY" value="14">
20
+      <param name="mode" value="stream">
20 21
       <param name="host" value="www.1stein.no-ip.com">
21 22
       <param name="port" value="23231">
22
-    </applet archive="BlinkenSim.jar">
23
+    </applet>
23 24
   </body>
24 25
 </html>
... ...
@@ -3,7 +3,7 @@
3 3
     <title>BlinkenSimJava - BNF - 640x480</title>
4 4
   </head>
5 5
   <body>
6
-    <applet archive="BlinkenSim.jar" code="BlinkenSim.class" width="640" height="480">
6
+    <applet archive="BlinkenSim.jar" code="org.blinkenarea.BlinkenSim.BlinkenSim" width="640" height="480">
7 7
       <param name="pixelX" value="26">
8 8
       <param name="pixelY" value="20">
9 9
       <param name="colors" value="8">
... ...
@@ -17,8 +17,9 @@
17 17
       <param name="startY" value="31">
18 18
       <param name="distanceX" value="7">
19 19
       <param name="distanceY" value="14">
20
+      <param name="mode" value="stream">
20 21
       <param name="host" value="192.168.0.33">
21 22
       <param name="port" value="23231">
22
-    </applet archive="BlinkenSim.jar">
23
+    </applet>
23 24
   </body>
24 25
 </html>
... ...
@@ -3,7 +3,7 @@
3 3
     <title>BlinkenSimJava - HDL - 1024x768</title>
4 4
   </head>
5 5
   <body>
6
-    <applet archive="BlinkenSim.jar" code="BlinkenSim.class" width="1024" height="768">
6
+    <applet archive="BlinkenSim.jar" code="org.blinkenarea.BlinkenSim.BlinkenSim" width="1024" height="768">
7 7
       <param name="pixelX" value="18">
8 8
       <param name="pixelY" value="8">
9 9
       <param name="colors" value="8">
... ...
@@ -17,8 +17,9 @@
17 17
       <param name="startY" value="74">
18 18
       <param name="distanceX" value="30">
19 19
       <param name="distanceY" value="55">
20
+      <param name="mode" value="stream">
20 21
       <param name="host" value="www.1stein.no-ip.com">
21 22
       <param name="port" value="23230">
22
-    </applet archive="BlinkenSim.jar">
23
+    </applet>
23 24
   </body>
24 25
 </html>
... ...
@@ -3,7 +3,7 @@
3 3
     <title>BlinkenSimJava - HDL - 1024x768</title>
4 4
   </head>
5 5
   <body>
6
-    <applet archive="BlinkenSim.jar" code="BlinkenSim.class" width="1024" height="768">
6
+    <applet archive="BlinkenSim.jar" code="org.blinkenarea.BlinkenSim.BlinkenSim" width="1024" height="768">
7 7
       <param name="pixelX" value="18">
8 8
       <param name="pixelY" value="8">
9 9
       <param name="colors" value="8">
... ...
@@ -17,8 +17,9 @@
17 17
       <param name="startY" value="74">
18 18
       <param name="distanceX" value="30">
19 19
       <param name="distanceY" value="55">
20
+      <param name="mode" value="stream">
20 21
       <param name="host" value="192.168.0.33">
21 22
       <param name="port" value="23230">
22
-    </applet archive="BlinkenSim.jar">
23
+    </applet>
23 24
   </body>
24 25
 </html>
... ...
@@ -3,7 +3,7 @@
3 3
     <title>BlinkenSimJava - HDL - 144x108</title>
4 4
   </head>
5 5
   <body>
6
-    <applet archive="BlinkenSim.jar" code="BlinkenSim.class" width="144" height="108">
6
+    <applet archive="BlinkenSim.jar" code="org.blinkenarea.BlinkenSim.BlinkenSim" width="144" height="108">
7 7
       <param name="pixelX" value="18">
8 8
       <param name="pixelY" value="8">
9 9
       <param name="colors" value="8">
... ...
@@ -17,8 +17,9 @@
17 17
       <param name="startY" value="14">
18 18
       <param name="distanceX" value="4">
19 19
       <param name="distanceY" value="7">
20
+      <param name="mode" value="stream">
20 21
       <param name="host" value="www.1stein.no-ip.com">
21 22
       <param name="port" value="23230">
22
-    </applet archive="BlinkenSim.jar">
23
+    </applet>
23 24
   </body>
24 25
 </html>
... ...
@@ -3,7 +3,7 @@
3 3
     <title>BlinkenSimJava - HDL - 144x108</title>
4 4
   </head>
5 5
   <body>
6
-    <applet archive="BlinkenSim.jar" code="BlinkenSim.class" width="144" height="108">
6
+    <applet archive="BlinkenSim.jar" code="org.blinkenarea.BlinkenSim.BlinkenSim" width="144" height="108">
7 7
       <param name="pixelX" value="18">
8 8
       <param name="pixelY" value="8">
9 9
       <param name="colors" value="8">
... ...
@@ -17,8 +17,9 @@
17 17
       <param name="startY" value="14">
18 18
       <param name="distanceX" value="4">
19 19
       <param name="distanceY" value="7">
20
+      <param name="mode" value="stream">
20 21
       <param name="host" value="192.168.0.33">
21 22
       <param name="port" value="23230">
22
-    </applet archive="BlinkenSim.jar">
23
+    </applet>
23 24
   </body>
24 25
 </html>
... ...
@@ -3,7 +3,7 @@
3 3
     <title>BlinkenSimJava - HDL - 640x480</title>
4 4
   </head>
5 5
   <body>
6
-    <applet archive="BlinkenSim.jar" code="BlinkenSim.class" width="640" height="480">
6
+    <applet archive="BlinkenSim.jar" code="org.blinkenarea.BlinkenSim.BlinkenSim" width="640" height="480">
7 7
       <param name="pixelX" value="18">
8 8
       <param name="pixelY" value="8">
9 9
       <param name="colors" value="8">
... ...
@@ -17,8 +17,9 @@
17 17
       <param name="startY" value="52">
18 18
       <param name="distanceX" value="19">
19 19
       <param name="distanceY" value="34">
20
+      <param name="mode" value="stream">
20 21
       <param name="host" value="www.1stein.no-ip.com">
21 22
       <param name="port" value="23230">
22
-    </applet archive="BlinkenSim.jar">
23
+    </applet>
23 24
   </body>
24 25
 </html>
... ...
@@ -3,7 +3,7 @@
3 3
     <title>BlinkenSimJava - HDL - 640x480</title>
4 4
   </head>
5 5
   <body>
6
-    <applet archive="BlinkenSim.jar" code="BlinkenSim.class" width="640" height="480">
6
+    <applet archive="BlinkenSim.jar" code="org.blinkenarea.BlinkenSim.BlinkenSim" width="640" height="480">
7 7
       <param name="pixelX" value="18">
8 8
       <param name="pixelY" value="8">
9 9
       <param name="colors" value="8">
... ...
@@ -17,8 +17,9 @@
17 17
       <param name="startY" value="52">
18 18
       <param name="distanceX" value="19">
19 19
       <param name="distanceY" value="34">
20
+      <param name="mode" value="stream">
20 21
       <param name="host" value="192.168.0.33">
21 22
       <param name="port" value="23230">
22
-    </applet archive="BlinkenSim.jar">
23
+    </applet>
23 24
   </body>
24 25
 </html>
... ...
@@ -3,7 +3,7 @@
3 3
     <title>BlinkenSimJava - HDL - 800x600</title>
4 4
   </head>
5 5
   <body>
6
-    <applet archive="BlinkenSim.jar" code="BlinkenSim.class" width="800" height="600">
6
+    <applet archive="BlinkenSim.jar" code="org.blinkenarea.BlinkenSim.BlinkenSim" width="800" height="600">
7 7
       <param name="pixelX" value="18">
8 8
       <param name="pixelY" value="8">
9 9
       <param name="colors" value="8">
... ...
@@ -17,8 +17,9 @@
17 17
       <param name="startY" value="60">
18 18
       <param name="distanceX" value="24">
19 19
       <param name="distanceY" value="43">
20
+      <param name="mode" value="stream">
20 21
       <param name="host" value="www.1stein.no-ip.com">
21 22
       <param name="port" value="23230">
22
-    </applet archive="BlinkenSim.jar">
23
+    </applet>
23 24
   </body>
24 25
 </html>
... ...
@@ -3,7 +3,7 @@
3 3
     <title>BlinkenSimJava - HDL - 800x600</title>
4 4
   </head>
5 5
   <body>
6
-    <applet archive="BlinkenSim.jar" code="BlinkenSim.class" width="800" height="600">
6
+    <applet archive="BlinkenSim.jar" code="org.blinkenarea.BlinkenSim.BlinkenSim" width="800" height="600">
7 7
       <param name="pixelX" value="18">
8 8
       <param name="pixelY" value="8">
9 9
       <param name="colors" value="8">
... ...
@@ -17,8 +17,9 @@
17 17
       <param name="startY" value="60">
18 18
       <param name="distanceX" value="24">
19 19
       <param name="distanceY" value="43">
20
+      <param name="mode" value="stream">
20 21
       <param name="host" value="192.168.0.33">
21 22
       <param name="port" value="23230">
22
-    </applet archive="BlinkenSim.jar">
23
+    </applet>
23 24
   </body>
24 25
 </html>
... ...
@@ -0,0 +1,24 @@
1
+<html>
2
+  <head>
3
+    <title>BlinkenSimJava - bluebox - 512x210</title>
4
+  </head>
5
+  <body>
6
+    <applet archive="BlinkenSim.jar" code="org.blinkenarea.BlinkenSim.BlinkenSim" width="512" height="210">
7
+      <param name="pixelX" value="98">
8
+      <param name="pixelY" value="7">
9
+      <param name="colors" value="16">
10
+      <param name="background" value="bluebox-512x210-bg.png">
11
+      <param name="backgroundX" value="512">
12
+      <param name="backgroundY" value="210">
13
+      <param name="overlay" value="bluebox-512x210-ov.png">
14
+      <param name="windowX" value="4">
15
+      <param name="windowY" value="7">
16
+      <param name="startX" value="12">
17
+      <param name="startY" value="33">
18
+      <param name="distanceX" value="5">
19
+      <param name="distanceY" value="14">
20
+      <param name="mode" value="movie">
21
+      <param name="movie" value="mymovie.bml">
22
+    </applet>
23
+  </body>
24
+</html>
... ...
@@ -0,0 +1,177 @@
1
+/* BlinkenSim
2
+ * version 0.1 date 2006-07-28
3
+ * Copyright (C) 2004-2006: Stefan Schuermans <1stein@schuermans.info>
4
+ * Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html
5
+ * a blinkenarea.org project
6
+ */
7
+
8
+package org.blinkenarea.BlinkenSim;
9
+
10
+import java.lang.*;
11
+import java.applet.*;
12
+import java.awt.*;
13
+import java.net.*;
14
+import org.blinkenarea.BlinkenLib.*;
15
+import org.blinkenarea.BlinkenSim.*;
16
+
17
+public class BlinkenSim extends Applet implements FrameReceiver
18
+{ 
19
+  private int pixelX = 0;
20
+  private int pixelY = 0;
21
+  private int colors = 0;
22
+  private int backgroundX = 0;
23
+  private int backgroundY = 0;
24
+  private int windowX = 0;
25
+  private int windowY = 0;
26
+  private int startX = 0;
27
+  private int startY = 0;
28
+  private int distanceX = 0;
29
+  private int distanceY = 0;
30
+  private Image backgroundImg;
31
+  private Image overlayImg;
32
+  private BlinkenFrame frame;
33
+  private DataSource dataSrc;
34
+
35
+  public void init( )
36
+  {
37
+    String param;
38
+    URL url;
39
+    String host;
40
+    int port = 0;
41
+	int movieCnt = 0;
42
+	String [] movies;
43
+
44
+    param = getParameter( "pixelX" );
45
+    if( param != null )
46
+      pixelX = Integer.parseInt( param );
47
+    if( pixelX < 1 || pixelX > 100 )
48
+      pixelX = 26;
49
+    param = getParameter( "pixelY" );
50
+    if( param != null )
51
+      pixelY = Integer.parseInt( param );
52
+    if( pixelY < 1 || pixelY > 100 )
53
+      pixelY = 20;
54
+    param = getParameter( "colors" );
55
+    if( param != null )
56
+      colors = Integer.parseInt( param );
57
+    if( colors < 1 || colors > 256 )
58
+      colors = 8;
59
+    param = getParameter( "backgroundX" );
60
+    if( param != null )
61
+      backgroundX = Integer.parseInt( param );
62
+    if( backgroundX < 1 || backgroundX > 2048 )
63
+      backgroundX = 144;
64
+    param = getParameter( "backgroundY" );
65
+    if( param != null )
66
+      backgroundY = Integer.parseInt( param );
67
+    if( backgroundY < 1 || backgroundY > 2048 )
68
+      backgroundY = 108;
69
+    param = getParameter( "windowX" );
70
+    if( param != null )
71
+      windowX = Integer.parseInt( param );
72
+    if( windowX < 1 || windowX > 256 )
73
+      windowX = 2;
74
+    param = getParameter( "windowY" );
75
+    if( param != null )
76
+      windowY = Integer.parseInt( param );
77
+    if( windowY < 1 || windowY > 256 )
78
+      windowY = 4;
79
+    param = getParameter( "startX" );
80
+    if( param != null )
81
+      startX = Integer.parseInt( param );
82
+    if( startX < 1 || startX > 2048 )
83
+      startX = 21;
84
+    param = getParameter( "startY" );
85
+    if( param != null )
86
+      startY = Integer.parseInt( param );
87
+    if( startY < 1 || startY > 2048 )
88
+      startY = 5;
89
+    param = getParameter( "distanceX" );
90
+    if( param != null )
91
+      distanceX = Integer.parseInt( param );
92
+    if( distanceX < 1 || distanceX > 512 )
93
+      distanceX = 2;
94
+    param = getParameter( "distanceY" );
95
+    if( param != null )
96
+      distanceY = Integer.parseInt( param );
97
+    if( distanceY < 1 || distanceY > 512 )
98
+      distanceY = 24;
99
+
100
+    url = getDocumentBase( );
101
+    if( url != null )
102
+    {
103
+      backgroundImg = getImage( url, getParameter( "background" ) );
104
+      overlayImg = getImage( url, getParameter( "overlay" ) );
105
+    }
106
+    else
107
+    {
108
+      try
109
+      {
110
+        url = new URL( "file:" + getParameter( "background" ) );
111
+        backgroundImg = getImage( url );
112
+      }
113
+      catch( MalformedURLException e )
114
+      {
115
+        backgroundImg = createImage( -1, -1 );
116
+      }
117
+      try
118
+      {
119
+        url = new URL( "file:" + getParameter( "overlay" ) );
120
+        overlayImg = getImage( url );
121
+      }
122
+      catch( MalformedURLException e )
123
+      {
124
+        overlayImg = createImage( -1, -1 );
125
+      }
126
+    }
127
+
128
+	String mode = getParameter( "mode" );
129
+
130
+	if( mode.equals( "stream" ) )
131
+		dataSrc = new DynMcufClient( this );
132
+	else if( mode.equals( "movie" ) )
133
+		dataSrc = new MoviePlayer( this );
134
+	else if( mode.equals( "playlist" ) )
135
+		dataSrc = new PlaylistPlayer( this );
136
+	else
137
+	    dataSrc = null;
138
+
139
+    frame = new BlinkenFrame( pixelY, pixelX, 1, 1, 1 );
140
+
141
+    if( dataSrc != null )
142
+      dataSrc.start( this );
143
+  }
144
+
145
+  public void newFrame( BlinkenFrame frame )
146
+  {
147
+    this.frame = frame;
148
+    repaint( );
149
+  }
150
+
151
+  public void paint( Graphics g )
152
+  {
153
+    frame.resize( pixelY, pixelX, 1, colors - 1 );
154
+    
155
+    Image img = createImage( backgroundX, backgroundY );
156
+    Graphics gBuf = img.getGraphics( );
157
+
158
+    gBuf.drawImage( backgroundImg, 0, 0, this );
159
+
160
+    for( int y = 0, yy = startY; y < pixelY; y++, yy += distanceY )
161
+    {
162
+      for( int x = 0, xx = startX; x < pixelX; x++, xx += distanceX )
163
+      {
164
+        int value = frame.getPixel( y, x, 0 );
165
+        gBuf.drawImage( overlayImg, xx, yy, xx + windowX, yy + windowY,
166
+                        value * windowX, 0, value * windowX + windowX, windowY, this );
167
+      }
168
+    }
169
+
170
+    g.drawImage( img, 0, 0, this );
171
+  }
172
+
173
+  public void update( Graphics g )
174
+  {
175
+    paint( g );
176
+  }
177
+}
... ...
@@ -0,0 +1,19 @@
1
+/* BlinkenSim
2
+ * version 0.1 date 2006-07-28
3
+ * Copyright (C) 2004-2006: Stefan Schuermans <1stein@schuermans.info>
4
+ * Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html
5
+ * a blinkenarea.org project
6
+ */
7
+
8
+package org.blinkenarea.BlinkenSim;
9
+
10
+public class DataSource
11
+{
12
+  public void start( FrameReceiver receiver )
13
+  {
14
+  }
15
+
16
+  public void stop( )
17
+  {
18
+  }
19
+}
... ...
@@ -0,0 +1,81 @@
1
+/* BlinkenSim
2
+ * version 0.1 date 2006-07-28
3
+ * Copyright (C) 2004-2006: Stefan Schuermans <1stein@schuermans.info>
4
+ * Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html
5
+ * a blinkenarea.org project
6
+ */
7
+
8
+package org.blinkenarea.BlinkenSim;
9
+
10
+import java.lang.*;
11
+import java.applet.*;
12
+import java.awt.*;
13
+import java.io.*;
14
+import java.net.*;
15
+import org.blinkenarea.BlinkenSim.*;
16
+
17
+public class DynMcufClient extends DataSource
18
+{
19
+  private InetAddress host;
20
+  private int port;
21
+  private DatagramSocket sock = null;
22
+  private DynMcufClientSend send = null;
23
+  private DynMcufClientRecv recv = null;
24
+
25
+  public DynMcufClient( Applet applet )
26
+  {
27
+    String hostname = applet.getParameter( "host" );
28
+    if( hostname == null || hostname.length( ) <= 0 )
29
+      hostname = "proxy.blinkenlights.de";
30
+    try
31
+    {
32
+      host = InetAddress.getByName( hostname );
33
+    }
34
+    catch( UnknownHostException e )
35
+    {
36
+      host = null;
37
+    }
38
+
39
+    String portStr = applet.getParameter( "port" );
40
+    if( portStr != null )
41
+      port = Integer.parseInt( portStr );
42
+    if( port <= 0 || port > 65535 )
43
+      port = 4242;
44
+  }
45
+
46
+  public void start( FrameReceiver receiver )
47
+  {
48
+    stop( );
49
+    if( host == null || port == 0 )
50
+      return;
51
+    try
52
+    {
53
+      sock = new DatagramSocket( );
54
+      send = new DynMcufClientSend( sock, host, port );
55
+      recv = new DynMcufClientRecv( sock, host, port, receiver );
56
+      recv.start( );
57
+      send.start( );
58
+    }
59
+    catch( SocketException e )
60
+    {
61
+      sock = null;
62
+      host = null;
63
+      port = 0;
64
+    }
65
+  }
66
+
67
+  public void stop( )
68
+  {
69
+    sock = null;
70
+    if( send != null )
71
+    {
72
+      send.terminate( );
73
+      send = null;
74
+    }
75
+    if( recv != null )
76
+    {
77
+      recv.terminate( );
78
+      recv = null;
79
+    }
80
+  }
81
+}
... ...
@@ -0,0 +1,60 @@
1
+/* BlinkenSim
2
+ * version 0.1 date 2006-07-28
3
+ * Copyright (C) 2004-2006: Stefan Schuermans <1stein@schuermans.info>
4
+ * Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html
5
+ * a blinkenarea.org project
6
+ */
7
+
8
+package org.blinkenarea.BlinkenSim;
9
+
10
+import java.lang.*;
11
+import java.applet.*;
12
+import java.awt.*;
13
+import java.io.*;
14
+import java.net.*;
15
+import org.blinkenarea.BlinkenLib.*;
16
+import org.blinkenarea.BlinkenSim.*;
17
+
18
+public class DynMcufClientRecv extends Thread
19
+{
20
+  private DatagramSocket sock;
21
+  private InetAddress host;
22
+  private int port;
23
+  private FrameReceiver receiver;
24
+  private boolean termReq = false;
25
+
26
+  DynMcufClientRecv( DatagramSocket sock, InetAddress host, int port, FrameReceiver receiver )
27
+  {
28
+    this.sock = sock;
29
+    this.host = host;
30
+    this.port = port;
31
+    this.receiver = receiver;
32
+  }
33
+
34
+  public void run( )
35
+  {
36
+    while( ! termReq )
37
+    {
38
+      try
39
+      {
40
+        byte[] data = new byte[8192];
41
+        DatagramPacket framePacket = new DatagramPacket( data, 8192 );
42
+        sock.receive( framePacket );
43
+        if( framePacket.getAddress( ).equals( host ) && framePacket.getPort( ) == port )
44
+        {
45
+          data = framePacket.getData( );
46
+          BlinkenFrame frame = new BlinkenFrame( 1, 1, 1, 1, 1 );
47
+          if( data != null && frame.fromNetwork( data ) == BlinkenConstants.BlinkenProtoMcuf )
48
+            receiver.newFrame( frame );
49
+        }
50
+      }
51
+      catch( IOException e ) { }
52
+    }
53
+  }
54
+
55
+  public void terminate( )
56
+  {
57
+    termReq = true;
58
+    this.interrupt( );
59
+  }
60
+}
... ...
@@ -0,0 +1,52 @@
1
+/* BlinkenSim
2
+ * version 0.1 date 2006-07-28
3
+ * Copyright (C) 2004-2006: Stefan Schuermans <1stein@schuermans.info>
4
+ * Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html
5
+ * a blinkenarea.org project
6
+ */
7
+
8
+package org.blinkenarea.BlinkenSim;
9
+
10
+import java.lang.*;
11
+import java.applet.*;
12
+import java.awt.*;
13
+import java.io.*;
14
+import java.net.*;
15
+import org.blinkenarea.BlinkenSim.*;
16
+
17
+public class DynMcufClientSend extends Thread
18
+{
19
+  private DatagramSocket sock;
20
+  private DatagramPacket request;
21
+  private boolean termReq = false;
22
+
23
+  DynMcufClientSend( DatagramSocket sock, InetAddress host, int port )
24
+  {
25
+    this.sock = sock;
26
+    byte[] data = { 0x42, 0x42, 0x42, 0x42, 0, 0, 0, 0, 0, 0, 0, 0 };
27
+    request = new DatagramPacket( data, 12, host, port );
28
+  }
29
+
30
+  public void run( )
31
+  {
32
+    while( ! termReq )
33
+    {
34
+      try
35
+      {
36
+        sock.send( request );
37
+      }
38
+      catch( IOException e ) { }
39
+      try
40
+      {
41
+        sleep( 10000 );
42
+      }
43
+      catch( InterruptedException e ) { }
44
+    }
45
+  }
46
+
47
+  public void terminate( )
48
+  {
49
+    termReq = true;
50
+    this.interrupt( );
51
+  }
52
+}
... ...
@@ -0,0 +1,15 @@
1
+/* BlinkenSim
2
+ * version 0.1 date 2006-07-28
3
+ * Copyright (C) 2004-2006: Stefan Schuermans <1stein@schuermans.info>
4
+ * Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html
5
+ * a blinkenarea.org project
6
+ */
7
+
8
+package org.blinkenarea.BlinkenSim;
9
+
10
+import org.blinkenarea.BlinkenLib.*;
11
+
12
+public interface FrameReceiver
13
+{ 
14
+  public void newFrame( BlinkenFrame frame );
15
+}
... ...
@@ -0,0 +1,120 @@
1
+/* BlinkenSim
2
+ * version 0.1 date 2006-07-28
3
+ * Copyright (C) 2004-2006: Stefan Schuermans <1stein@schuermans.info>
4
+ * Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html
5
+ * a blinkenarea.org project
6
+ */
7
+
8
+package org.blinkenarea.BlinkenSim;
9
+
10
+import java.applet.*;
11
+import java.io.*;
12
+import java.net.*;
13
+import java.util.*;
14
+import org.blinkenarea.BlinkenLib.*;
15
+
16
+public class MoviePlayer extends DataSource {
17
+
18
+  BlinkenMovie [] movies = null;
19
+  int movieNo = 0, frameNo = 0;
20
+  FrameReceiver receiver = null;
21
+  Timer timer = null;
22
+  MoviePlayerTimerTask task = null;
23
+
24
+  protected MoviePlayer( ) {
25
+    // e.g. used by PlaylistPlayer
26
+  }
27
+
28
+  public MoviePlayer( Applet applet ) {
29
+
30
+    String movieName = applet.getParameter( "movie" );
31
+    if( movieName == null || movieName.length( ) <= 0 )
32
+      movieName = "movie.bml";
33
+
34
+    String [] movieNames = new String[1];
35
+    movieNames[0] = movieName;
36
+    setUp( applet, movieNames );
37
+
38
+  }
39
+
40
+  protected void setUp( Applet applet, String [] movieNames ) {
41
+
42
+    movies = new BlinkenMovie [movieNames.length];
43
+
44
+    for( int idx = 0; idx < movieNames.length; idx++ ) {
45
+
46
+      try {
47
+        URL base = applet.getDocumentBase( );
48
+        URL url;
49
+        if( base != null ) {
50
+          url = new URL( base, movieNames[idx] );
51
+        } else {
52
+          url = new URL( "file:" + movieNames[idx] );
53
+        }
54
+        movies[idx] = new BlinkenMovie( 1, 1, 1, 1 );
55
+        BufferedReader reader = new BufferedReader( new InputStreamReader( url.openStream( ) ) );
56
+        if( movieNames[idx].toLowerCase( ).endsWith( ".blm" ) ) {
57
+          movies[idx].loadBlm( reader );
58
+        } else if( movieNames[idx].toLowerCase( ).endsWith( ".bmm" ) ) {
59
+          movies[idx].loadBmm( reader );
60
+        } else if( movieNames[idx].toLowerCase( ).endsWith( ".bml" ) ) {
61
+          movies[idx].loadBml( reader );
62
+        }
63
+      } catch( MalformedURLException e ) {
64
+        movies[idx] = new BlinkenMovie( 1, 1, 1, 1 );
65
+      } catch( IOException e ) {
66
+        movies[idx] = new BlinkenMovie( 1, 1, 1, 1 );
67
+      }
68
+
69
+    }
70
+
71
+    movieNo = 0;
72
+    frameNo = 0;
73
+
74
+  }
75
+
76
+  public void start( FrameReceiver recv ) {
77
+    stop( );
78
+    movieNo = 0;
79
+    frameNo = 0;
80
+    receiver = recv;
81
+    nextFrame( );
82
+  }
83
+
84
+  public void stop( ) {
85
+    receiver = null;
86
+    timer = null;
87
+    task = null;
88
+  }
89
+
90
+  public void nextFrame( ) {
91
+
92
+    if( movies == null || movies.length <= 0 || receiver == null )
93
+      return;
94
+
95
+    if( movieNo >= movies.length )
96
+      movieNo = 0;
97
+    if( movies[movieNo] == null )
98
+      return;
99
+    BlinkenMovie movie = movies[movieNo];
100
+
101
+    if( frameNo >= movie.getFrameCnt( ) )
102
+      frameNo = 0;
103
+
104
+    BlinkenFrame frame = movie.getFrame( frameNo );
105
+    receiver.newFrame( frame );
106
+
107
+    timer = new Timer( );
108
+    task = new MoviePlayerTimerTask( this );
109
+    timer.schedule( task, frame.getDuration( ) );
110
+
111
+    frameNo++;
112
+    if( frameNo >= movie.getFrameCnt( ) ) {
113
+      frameNo = 0;
114
+      movieNo++;
115
+      if( movieNo >= movies.length )
116
+        movieNo++;
117
+    }
118
+  }
119
+
120
+} // class MoviePlayer
... ...
@@ -0,0 +1,24 @@
1
+/* BlinkenSim
2
+ * version 0.1 date 2006-07-28
3
+ * Copyright (C) 2004-2006: Stefan Schuermans <1stein@schuermans.info>
4
+ * Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html
5
+ * a blinkenarea.org project
6
+ */
7
+
8
+package org.blinkenarea.BlinkenSim;
9
+
10
+import java.util.*;
11
+
12
+public class MoviePlayerTimerTask extends TimerTask {
13
+
14
+  MoviePlayer player;
15
+
16
+  public MoviePlayerTimerTask( MoviePlayer pl ) {
17
+    player = pl;
18
+  }
19
+
20
+  public void run( ) {
21
+    player.nextFrame( );
22
+  }
23
+
24
+} // class MoviePlayerTimerTask
... ...
@@ -0,0 +1,64 @@
1
+/* BlinkenSim
2
+ * version 0.1 date 2006-07-28
3
+ * Copyright (C) 2004-2006: Stefan Schuermans <1stein@schuermans.info>
4
+ * Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html
5
+ * a blinkenarea.org project
6
+ */
7
+
8
+package org.blinkenarea.BlinkenSim;
9
+
10
+import java.applet.*;
11
+import java.io.*;
12
+import java.net.*;
13
+
14
+public class PlaylistPlayer extends MoviePlayer {
15
+
16
+  public PlaylistPlayer( Applet applet ) {
17
+
18
+    String playlistName = applet.getParameter( "playlist" );
19
+    if( playlistName == null || playlistName.length( ) <= 0 )
20
+      playlistName = "playlist";
21
+
22
+    try {
23
+
24
+      URL base = applet.getDocumentBase( );
25
+      URL url;
26
+      if( base != null ) {
27
+        url = new URL( base, playlistName );
28
+      } else {
29
+        url = new URL( "file:" + playlistName );
30
+      }
31
+
32
+      BufferedReader reader = new BufferedReader( new InputStreamReader( url.openStream( ) ) );
33
+
34
+      int len = 16, cnt = 0;
35
+      String [] names = new String [len];
36
+      try {
37
+        while( true ) {
38
+          String line = reader.readLine( );
39
+          if( line == null )
40
+            break;
41
+          names[cnt++] = line;
42
+          if( cnt >= len ) {
43
+			len *= 2;
44
+            String [] newNames = new String [len];
45
+            for( int i = 0; i < cnt; i++ )
46
+              newNames[i] = names[i];
47
+            names = newNames;
48
+          }
49
+        }
50
+      } catch( IOException e ) {
51
+      }
52
+
53
+      String [] movieNames = new String [cnt];
54
+      for( int i = 0; i < cnt; i++ )
55
+        movieNames[i] = names[i];
56
+      setUp( applet, movieNames );
57
+
58
+    } catch( MalformedURLException e ) {
59
+    } catch( IOException e ) {
60
+    }
61
+
62
+  }
63
+
64
+} // class PlaylistPlayer
... ...
@@ -0,0 +1,3 @@
1
+mymovie1.bml
2
+mymovie2.bml
3
+mymovie3.bml
... ...
@@ -0,0 +1,24 @@
1
+<html>
2
+  <head>
3
+    <title>BlinkenSimJava - bluebox - 512x210</title>
4
+  </head>
5
+  <body>
6
+    <applet archive="BlinkenSim.jar" code="org.blinkenarea.BlinkenSim.BlinkenSim" width="512" height="210">
7
+      <param name="pixelX" value="98">
8
+      <param name="pixelY" value="7">
9
+      <param name="colors" value="16">
10
+      <param name="background" value="bluebox-512x210-bg.png">
11
+      <param name="backgroundX" value="512">
12
+      <param name="backgroundY" value="210">
13
+      <param name="overlay" value="bluebox-512x210-ov.png">
14
+      <param name="windowX" value="4">
15
+      <param name="windowY" value="7">
16
+      <param name="startX" value="12">
17
+      <param name="startY" value="33">
18
+      <param name="distanceX" value="5">
19
+      <param name="distanceY" value="14">
20
+      <param name="mode" value="playlist">
21
+      <param name="playlist" value="playlist">
22
+    </applet>
23
+  </body>
24
+</html>
0 25