DEADSOFTWARE

Initial commit.
authorAnna Ivanova <kalterfx@gmail.com>
Thu, 11 Aug 2016 05:26:23 +0000 (10:26 +0500)
committerAnna Ivanova <kalterfx@gmail.com>
Thu, 11 Aug 2016 05:26:23 +0000 (10:26 +0500)
112 files changed:
Crypto/build.xml [new file with mode: 0644]
Crypto/nbproject/build-impl.xml [new file with mode: 0644]
Crypto/nbproject/genfiles.properties [new file with mode: 0644]
Crypto/nbproject/private/config.properties [new file with mode: 0644]
Crypto/nbproject/private/private.properties [new file with mode: 0644]
Crypto/nbproject/private/private.xml [new file with mode: 0644]
Crypto/nbproject/project.properties [new file with mode: 0644]
Crypto/nbproject/project.xml [new file with mode: 0644]
Crypto/src/code/kalter/longflight/crypto/CIStream.java [new file with mode: 0644]
Crypto/src/code/kalter/longflight/crypto/Crypto.java [new file with mode: 0644]
Crypto/src/code/kalter/longflight/crypto/Random.java [new file with mode: 0644]
README.MD [new file with mode: 0644]
build.xml [new file with mode: 0644]
nbproject/build-impl.xml [new file with mode: 0644]
nbproject/genfiles.properties [new file with mode: 0644]
nbproject/private/private.properties [new file with mode: 0644]
nbproject/private/private.xml [new file with mode: 0644]
nbproject/project.properties [new file with mode: 0644]
nbproject/project.xml [new file with mode: 0644]
src/code/kalter/longflight/Animation.java [new file with mode: 0644]
src/code/kalter/longflight/Area.java [new file with mode: 0644]
src/code/kalter/longflight/Arrays.java [new file with mode: 0644]
src/code/kalter/longflight/ByteArrayInputStream.java [new file with mode: 0644]
src/code/kalter/longflight/ByteArrayOutputStream.java [new file with mode: 0644]
src/code/kalter/longflight/Color.java [new file with mode: 0644]
src/code/kalter/longflight/EventListener.java [new file with mode: 0644]
src/code/kalter/longflight/FPS.java [new file with mode: 0644]
src/code/kalter/longflight/Font.java [new file with mode: 0644]
src/code/kalter/longflight/Loader.java [new file with mode: 0644]
src/code/kalter/longflight/LongFlight.java [new file with mode: 0644]
src/code/kalter/longflight/ObjectItem.java [new file with mode: 0644]
src/code/kalter/longflight/Pointer.java [new file with mode: 0644]
src/code/kalter/longflight/Quote.java [new file with mode: 0644]
src/code/kalter/longflight/Sound.java [new file with mode: 0644]
src/code/kalter/longflight/Sprite.java [new file with mode: 0644]
src/code/kalter/longflight/StringReader.java [new file with mode: 0644]
src/code/kalter/longflight/Time.java [new file with mode: 0644]
src/code/kalter/longflight/crypto/CIStream.java [new file with mode: 0644]
src/code/kalter/longflight/crypto/Random.java [new file with mode: 0644]
src/code/kalter/longflight/game/Bullet.java [new file with mode: 0644]
src/code/kalter/longflight/game/ColorEffect.java [new file with mode: 0644]
src/code/kalter/longflight/game/Enemy.java [new file with mode: 0644]
src/code/kalter/longflight/game/Gamer.java [new file with mode: 0644]
src/code/kalter/longflight/game/bullet/Collisionable.java [new file with mode: 0644]
src/code/kalter/longflight/game/bullet/Gun.java [new file with mode: 0644]
src/code/kalter/longflight/game/explosion/Detonator.java [new file with mode: 0644]
src/code/kalter/longflight/game/explosion/Explosion.java [new file with mode: 0644]
src/code/kalter/longflight/game/ship/Ship.java [new file with mode: 0644]
src/code/kalter/longflight/game/ship/ShipEnemy.java [new file with mode: 0644]
src/code/kalter/longflight/game/ship/ShipGamer.java [new file with mode: 0644]
src/code/kalter/longflight/rms/RMS.java [new file with mode: 0644]
src/code/kalter/longflight/rms/RecordNotFoundException.java [new file with mode: 0644]
src/code/kalter/longflight/screen/About.java [new file with mode: 0644]
src/code/kalter/longflight/screen/Crash.java [new file with mode: 0644]
src/code/kalter/longflight/screen/EnableSound.java [new file with mode: 0644]
src/code/kalter/longflight/screen/Game.java [new file with mode: 0644]
src/code/kalter/longflight/screen/HighScore.java [new file with mode: 0644]
src/code/kalter/longflight/screen/Loading.java [new file with mode: 0644]
src/code/kalter/longflight/screen/Menu.java [new file with mode: 0644]
src/code/kalter/longflight/screen/Pause.java [new file with mode: 0644]
src/code/kalter/longflight/screen/Screen.java [new file with mode: 0644]
src/code/kalter/longflight/screen/SelectShip.java [new file with mode: 0644]
src/code/kalter/longflight/screen/Splash.java [new file with mode: 0644]
src/code/kalter/longflight/space/Egg.java [new file with mode: 0644]
src/code/kalter/longflight/space/Planet.java [new file with mode: 0644]
src/code/kalter/longflight/space/Space.java [new file with mode: 0644]
src/code/kalter/longflight/space/Star.java [new file with mode: 0644]
src/code/kalter/longflight/space/Tile.java [new file with mode: 0644]
src/gfx/about/window.png [new file with mode: 0644]
src/gfx/awt/down_panel.png [new file with mode: 0644]
src/gfx/awt/left_soft.png [new file with mode: 0644]
src/gfx/awt/right_soft.png [new file with mode: 0644]
src/gfx/boom.png [new file with mode: 0644]
src/gfx/bullet/0.png [new file with mode: 0644]
src/gfx/bullet/1.png [new file with mode: 0644]
src/gfx/crash/window.png [new file with mode: 0644]
src/gfx/enable_sound/choise.png [new file with mode: 0644]
src/gfx/enable_sound/window.png [new file with mode: 0644]
src/gfx/font.png [new file with mode: 0644]
src/gfx/game/down_panel.png [new file with mode: 0644]
src/gfx/game/life.png [new file with mode: 0644]
src/gfx/game/overheat.png [new file with mode: 0644]
src/gfx/game/right_soft.png [new file with mode: 0644]
src/gfx/game/up_panel.png [new file with mode: 0644]
src/gfx/hscore/window.png [new file with mode: 0644]
src/gfx/icon.png [new file with mode: 0644]
src/gfx/loading/loading.png [new file with mode: 0644]
src/gfx/menu/choise.png [new file with mode: 0644]
src/gfx/menu/window.png [new file with mode: 0644]
src/gfx/pause/choise.png [new file with mode: 0644]
src/gfx/pause/window.png [new file with mode: 0644]
src/gfx/select_ship/frame.png [new file with mode: 0644]
src/gfx/select_ship/lr_button.png [new file with mode: 0644]
src/gfx/select_ship/window.png [new file with mode: 0644]
src/gfx/ship/0.png [new file with mode: 0644]
src/gfx/ship/1.png [new file with mode: 0644]
src/gfx/ship/2.png [new file with mode: 0644]
src/gfx/ship/3.png [new file with mode: 0644]
src/gfx/ship/5.png [new file with mode: 0644]
src/gfx/ship/nozzle.png [new file with mode: 0644]
src/gfx/space/background.png [new file with mode: 0644]
src/gfx/space/planet/0.png [new file with mode: 0644]
src/gfx/space/planet/1.png [new file with mode: 0644]
src/gfx/space/planet/2.png [new file with mode: 0644]
src/gfx/space/planet/3.png [new file with mode: 0644]
src/gfx/space/planet/4.png [new file with mode: 0644]
src/gfx/splash/0.png [new file with mode: 0644]
src/gfx/splash/1.png [new file with mode: 0644]
src/quote.txt [new file with mode: 0644]
src/song/iha.mid [new file with mode: 0644]
src/song/mobscene.mid [new file with mode: 0644]
src/song/monster.mid [new file with mode: 0644]

diff --git a/Crypto/build.xml b/Crypto/build.xml
new file mode 100644 (file)
index 0000000..3ed3d73
--- /dev/null
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- You may freely edit this file. See commented blocks below for -->
+<!-- some examples of how to customize the build. -->
+<!-- (If you delete it and reopen the project it will be recreated.) -->
+<!-- By default, only the Clean and Build commands use this build script. -->
+<!-- Commands such as Run, Debug, and Test only use this build script if -->
+<!-- the Compile on Save feature is turned off for the project. -->
+<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
+<!-- in the project's Project Properties dialog box.-->
+<project name="Crypto" default="default" basedir=".">
+    <description>Builds, tests, and runs the project Crypto.</description>
+    <import file="nbproject/build-impl.xml"/>
+    <!--
+
+    There exist several targets which are by default empty and which can be 
+    used for execution of your tasks. These targets are usually executed 
+    before and after some main targets. They are: 
+
+      -pre-init:                 called before initialization of project properties
+      -post-init:                called after initialization of project properties
+      -pre-compile:              called before javac compilation
+      -post-compile:             called after javac compilation
+      -pre-compile-single:       called before javac compilation of single file
+      -post-compile-single:      called after javac compilation of single file
+      -pre-compile-test:         called before javac compilation of JUnit tests
+      -post-compile-test:        called after javac compilation of JUnit tests
+      -pre-compile-test-single:  called before javac compilation of single JUnit test
+      -post-compile-test-single: called after javac compilation of single JUunit test
+      -pre-jar:                  called before JAR building
+      -post-jar:                 called after JAR building
+      -post-clean:               called after cleaning build products
+
+    (Targets beginning with '-' are not intended to be called on their own.)
+
+    Example of inserting an obfuscator after compilation could look like this:
+
+        <target name="-post-compile">
+            <obfuscate>
+                <fileset dir="${build.classes.dir}"/>
+            </obfuscate>
+        </target>
+
+    For list of available properties check the imported 
+    nbproject/build-impl.xml file. 
+
+
+    Another way to customize the build is by overriding existing main targets.
+    The targets of interest are: 
+
+      -init-macrodef-javac:     defines macro for javac compilation
+      -init-macrodef-junit:     defines macro for junit execution
+      -init-macrodef-debug:     defines macro for class debugging
+      -init-macrodef-java:      defines macro for class execution
+      -do-jar:                  JAR building
+      run:                      execution of project 
+      -javadoc-build:           Javadoc generation
+      test-report:              JUnit report generation
+
+    An example of overriding the target for project execution could look like this:
+
+        <target name="run" depends="Crypto-impl.jar">
+            <exec dir="bin" executable="launcher.exe">
+                <arg file="${dist.jar}"/>
+            </exec>
+        </target>
+
+    Notice that the overridden target depends on the jar target and not only on 
+    the compile target as the regular run target does. Again, for a list of available 
+    properties which you can use, check the target you are overriding in the
+    nbproject/build-impl.xml file. 
+
+    -->
+</project>
diff --git a/Crypto/nbproject/build-impl.xml b/Crypto/nbproject/build-impl.xml
new file mode 100644 (file)
index 0000000..b6aec53
--- /dev/null
@@ -0,0 +1,1413 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+*** GENERATED FROM project.xml - DO NOT EDIT  ***
+***         EDIT ../build.xml INSTEAD         ***
+
+For the purpose of easier reading the script
+is divided into following sections:
+
+  - initialization
+  - compilation
+  - jar
+  - execution
+  - debugging
+  - javadoc
+  - test compilation
+  - test execution
+  - test debugging
+  - applet
+  - cleanup
+
+        -->
+<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="Crypto-impl">
+    <fail message="Please build using Ant 1.8.0 or higher.">
+        <condition>
+            <not>
+                <antversion atleast="1.8.0"/>
+            </not>
+        </condition>
+    </fail>
+    <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
+    <!-- 
+                ======================
+                INITIALIZATION SECTION 
+                ======================
+            -->
+    <target name="-pre-init">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="-pre-init" name="-init-private">
+        <property file="nbproject/private/config.properties"/>
+        <property file="nbproject/private/configs/${config}.properties"/>
+        <property file="nbproject/private/private.properties"/>
+    </target>
+    <target depends="-pre-init,-init-private" name="-init-user">
+        <property file="${user.properties.file}"/>
+        <!-- The two properties below are usually overridden -->
+        <!-- by the active platform. Just a fallback. -->
+        <property name="default.javac.source" value="1.4"/>
+        <property name="default.javac.target" value="1.4"/>
+    </target>
+    <target depends="-pre-init,-init-private,-init-user" name="-init-project">
+        <property file="nbproject/configs/${config}.properties"/>
+        <property file="nbproject/project.properties"/>
+    </target>
+    <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
+        <property name="platform.java" value="${java.home}/bin/java"/>
+        <available file="${manifest.file}" property="manifest.available"/>
+        <condition property="splashscreen.available">
+            <and>
+                <not>
+                    <equals arg1="${application.splash}" arg2="" trim="true"/>
+                </not>
+                <available file="${application.splash}"/>
+            </and>
+        </condition>
+        <condition property="main.class.available">
+            <and>
+                <isset property="main.class"/>
+                <not>
+                    <equals arg1="${main.class}" arg2="" trim="true"/>
+                </not>
+            </and>
+        </condition>
+        <condition property="profile.available">
+            <and>
+                <isset property="javac.profile"/>
+                <length length="0" string="${javac.profile}" when="greater"/>
+                <matches pattern="1\.[89](\..*)?" string="${javac.source}"/>
+            </and>
+        </condition>
+        <condition property="do.archive">
+            <or>
+                <not>
+                    <istrue value="${jar.archive.disabled}"/>
+                </not>
+                <istrue value="${not.archive.disabled}"/>
+            </or>
+        </condition>
+        <condition property="do.mkdist">
+            <and>
+                <isset property="do.archive"/>
+                <isset property="libs.CopyLibs.classpath"/>
+                <not>
+                    <istrue value="${mkdist.disabled}"/>
+                </not>
+            </and>
+        </condition>
+        <condition property="do.archive+manifest.available">
+            <and>
+                <isset property="manifest.available"/>
+                <istrue value="${do.archive}"/>
+            </and>
+        </condition>
+        <condition property="do.archive+main.class.available">
+            <and>
+                <isset property="main.class.available"/>
+                <istrue value="${do.archive}"/>
+            </and>
+        </condition>
+        <condition property="do.archive+splashscreen.available">
+            <and>
+                <isset property="splashscreen.available"/>
+                <istrue value="${do.archive}"/>
+            </and>
+        </condition>
+        <condition property="do.archive+profile.available">
+            <and>
+                <isset property="profile.available"/>
+                <istrue value="${do.archive}"/>
+            </and>
+        </condition>
+        <condition property="have.tests">
+            <or>
+                <available file="${test.src.dir}"/>
+            </or>
+        </condition>
+        <condition property="have.sources">
+            <or>
+                <available file="${src.dir}"/>
+            </or>
+        </condition>
+        <condition property="netbeans.home+have.tests">
+            <and>
+                <isset property="netbeans.home"/>
+                <isset property="have.tests"/>
+            </and>
+        </condition>
+        <condition property="no.javadoc.preview">
+            <and>
+                <isset property="javadoc.preview"/>
+                <isfalse value="${javadoc.preview}"/>
+            </and>
+        </condition>
+        <property name="run.jvmargs" value=""/>
+        <property name="run.jvmargs.ide" value=""/>
+        <property name="javac.compilerargs" value=""/>
+        <property name="work.dir" value="${basedir}"/>
+        <condition property="no.deps">
+            <and>
+                <istrue value="${no.dependencies}"/>
+            </and>
+        </condition>
+        <property name="javac.debug" value="true"/>
+        <property name="javadoc.preview" value="true"/>
+        <property name="application.args" value=""/>
+        <property name="source.encoding" value="${file.encoding}"/>
+        <property name="runtime.encoding" value="${source.encoding}"/>
+        <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
+            <and>
+                <isset property="javadoc.encoding"/>
+                <not>
+                    <equals arg1="${javadoc.encoding}" arg2=""/>
+                </not>
+            </and>
+        </condition>
+        <property name="javadoc.encoding.used" value="${source.encoding}"/>
+        <property name="includes" value="**"/>
+        <property name="excludes" value=""/>
+        <property name="do.depend" value="false"/>
+        <condition property="do.depend.true">
+            <istrue value="${do.depend}"/>
+        </condition>
+        <path id="endorsed.classpath.path" path="${endorsed.classpath}"/>
+        <condition else="" property="endorsed.classpath.cmd.line.arg" value="-Xbootclasspath/p:'${toString:endorsed.classpath.path}'">
+            <and>
+                <isset property="endorsed.classpath"/>
+                <not>
+                    <equals arg1="${endorsed.classpath}" arg2="" trim="true"/>
+                </not>
+            </and>
+        </condition>
+        <condition else="" property="javac.profile.cmd.line.arg" value="-profile ${javac.profile}">
+            <isset property="profile.available"/>
+        </condition>
+        <condition else="false" property="jdkBug6558476">
+            <and>
+                <matches pattern="1\.[56]" string="${java.specification.version}"/>
+                <not>
+                    <os family="unix"/>
+                </not>
+            </and>
+        </condition>
+        <property name="javac.fork" value="${jdkBug6558476}"/>
+        <property name="jar.index" value="false"/>
+        <property name="jar.index.metainf" value="${jar.index}"/>
+        <property name="copylibs.rebase" value="true"/>
+        <available file="${meta.inf.dir}/persistence.xml" property="has.persistence.xml"/>
+        <condition property="junit.available">
+            <or>
+                <available classname="org.junit.Test" classpath="${run.test.classpath}"/>
+                <available classname="junit.framework.Test" classpath="${run.test.classpath}"/>
+            </or>
+        </condition>
+        <condition property="testng.available">
+            <available classname="org.testng.annotations.Test" classpath="${run.test.classpath}"/>
+        </condition>
+        <condition property="junit+testng.available">
+            <and>
+                <istrue value="${junit.available}"/>
+                <istrue value="${testng.available}"/>
+            </and>
+        </condition>
+        <condition else="testng" property="testng.mode" value="mixed">
+            <istrue value="${junit+testng.available}"/>
+        </condition>
+        <condition else="" property="testng.debug.mode" value="-mixed">
+            <istrue value="${junit+testng.available}"/>
+        </condition>
+    </target>
+    <target name="-post-init">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
+        <fail unless="src.dir">Must set src.dir</fail>
+        <fail unless="test.src.dir">Must set test.src.dir</fail>
+        <fail unless="build.dir">Must set build.dir</fail>
+        <fail unless="dist.dir">Must set dist.dir</fail>
+        <fail unless="build.classes.dir">Must set build.classes.dir</fail>
+        <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
+        <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
+        <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
+        <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
+        <fail unless="dist.jar">Must set dist.jar</fail>
+    </target>
+    <target name="-init-macrodef-property">
+        <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
+            <attribute name="name"/>
+            <attribute name="value"/>
+            <sequential>
+                <property name="@{name}" value="${@{value}}"/>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-ap-cmdline-properties" if="ap.supported.internal" name="-init-macrodef-javac-with-processors">
+        <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${src.dir}" name="srcdir"/>
+            <attribute default="${build.classes.dir}" name="destdir"/>
+            <attribute default="${javac.classpath}" name="classpath"/>
+            <attribute default="${javac.processorpath}" name="processorpath"/>
+            <attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/>
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="${javac.debug}" name="debug"/>
+            <attribute default="${empty.dir}" name="sourcepath"/>
+            <attribute default="${empty.dir}" name="gensrcdir"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <property location="${build.dir}/empty" name="empty.dir"/>
+                <mkdir dir="${empty.dir}"/>
+                <mkdir dir="@{apgeneratedsrcdir}"/>
+                <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">
+                    <src>
+                        <dirset dir="@{gensrcdir}" erroronmissingdir="false">
+                            <include name="*"/>
+                        </dirset>
+                    </src>
+                    <classpath>
+                        <path path="@{classpath}"/>
+                    </classpath>
+                    <compilerarg line="${endorsed.classpath.cmd.line.arg}"/>
+                    <compilerarg line="${javac.profile.cmd.line.arg}"/>
+                    <compilerarg line="${javac.compilerargs}"/>
+                    <compilerarg value="-processorpath"/>
+                    <compilerarg path="@{processorpath}:${empty.dir}"/>
+                    <compilerarg line="${ap.processors.internal}"/>
+                    <compilerarg line="${annotation.processing.processor.options}"/>
+                    <compilerarg value="-s"/>
+                    <compilerarg path="@{apgeneratedsrcdir}"/>
+                    <compilerarg line="${ap.proc.none.internal}"/>
+                    <customize/>
+                </javac>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-ap-cmdline-properties" name="-init-macrodef-javac-without-processors" unless="ap.supported.internal">
+        <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${src.dir}" name="srcdir"/>
+            <attribute default="${build.classes.dir}" name="destdir"/>
+            <attribute default="${javac.classpath}" name="classpath"/>
+            <attribute default="${javac.processorpath}" name="processorpath"/>
+            <attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/>
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="${javac.debug}" name="debug"/>
+            <attribute default="${empty.dir}" name="sourcepath"/>
+            <attribute default="${empty.dir}" name="gensrcdir"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <property location="${build.dir}/empty" name="empty.dir"/>
+                <mkdir dir="${empty.dir}"/>
+                <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">
+                    <src>
+                        <dirset dir="@{gensrcdir}" erroronmissingdir="false">
+                            <include name="*"/>
+                        </dirset>
+                    </src>
+                    <classpath>
+                        <path path="@{classpath}"/>
+                    </classpath>
+                    <compilerarg line="${endorsed.classpath.cmd.line.arg}"/>
+                    <compilerarg line="${javac.profile.cmd.line.arg}"/>
+                    <compilerarg line="${javac.compilerargs}"/>
+                    <customize/>
+                </javac>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-macrodef-javac-with-processors,-init-macrodef-javac-without-processors" name="-init-macrodef-javac">
+        <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${src.dir}" name="srcdir"/>
+            <attribute default="${build.classes.dir}" name="destdir"/>
+            <attribute default="${javac.classpath}" name="classpath"/>
+            <sequential>
+                <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
+                    <classpath>
+                        <path path="@{classpath}"/>
+                    </classpath>
+                </depend>
+            </sequential>
+        </macrodef>
+        <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${build.classes.dir}" name="destdir"/>
+            <sequential>
+                <fail unless="javac.includes">Must set javac.includes</fail>
+                <pathconvert pathsep="${line.separator}" property="javac.includes.binary">
+                    <path>
+                        <filelist dir="@{destdir}" files="${javac.includes}"/>
+                    </path>
+                    <globmapper from="*.java" to="*.class"/>
+                </pathconvert>
+                <tempfile deleteonexit="true" property="javac.includesfile.binary"/>
+                <echo file="${javac.includesfile.binary}" message="${javac.includes.binary}"/>
+                <delete>
+                    <files includesfile="${javac.includesfile.binary}"/>
+                </delete>
+                <delete>
+                    <fileset file="${javac.includesfile.binary}"/>
+                </delete>
+            </sequential>
+        </macrodef>
+    </target>
+    <target if="${junit.available}" name="-init-macrodef-junit-init">
+        <condition else="false" property="nb.junit.batch" value="true">
+            <and>
+                <istrue value="${junit.available}"/>
+                <not>
+                    <isset property="test.method"/>
+                </not>
+            </and>
+        </condition>
+        <condition else="false" property="nb.junit.single" value="true">
+            <and>
+                <istrue value="${junit.available}"/>
+                <isset property="test.method"/>
+            </and>
+        </condition>
+    </target>
+    <target name="-init-test-properties">
+        <property name="test.binaryincludes" value="&lt;nothing&gt;"/>
+        <property name="test.binarytestincludes" value=""/>
+        <property name="test.binaryexcludes" value=""/>
+    </target>
+    <target if="${nb.junit.single}" name="-init-macrodef-junit-single" unless="${nb.junit.batch}">
+        <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <property name="junit.forkmode" value="perTest"/>
+                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}">
+                    <test methods="@{testmethods}" name="@{testincludes}" todir="${build.test.results.dir}"/>
+                    <syspropertyset>
+                        <propertyref prefix="test-sys-prop."/>
+                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
+                    </syspropertyset>
+                    <formatter type="brief" usefile="false"/>
+                    <formatter type="xml"/>
+                    <jvmarg value="-ea"/>
+                    <customize/>
+                </junit>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-test-properties" if="${nb.junit.batch}" name="-init-macrodef-junit-batch" unless="${nb.junit.single}">
+        <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <property name="junit.forkmode" value="perTest"/>
+                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}">
+                    <batchtest todir="${build.test.results.dir}">
+                        <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
+                            <filename name="@{testincludes}"/>
+                        </fileset>
+                        <fileset dir="${build.test.classes.dir}" excludes="@{excludes},${excludes},${test.binaryexcludes}" includes="${test.binaryincludes}">
+                            <filename name="${test.binarytestincludes}"/>
+                        </fileset>
+                    </batchtest>
+                    <syspropertyset>
+                        <propertyref prefix="test-sys-prop."/>
+                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
+                    </syspropertyset>
+                    <formatter type="brief" usefile="false"/>
+                    <formatter type="xml"/>
+                    <jvmarg value="-ea"/>
+                    <customize/>
+                </junit>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-macrodef-junit-init,-init-macrodef-junit-single, -init-macrodef-junit-batch" if="${junit.available}" name="-init-macrodef-junit"/>
+    <target if="${testng.available}" name="-init-macrodef-testng">
+        <macrodef name="testng" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <condition else="" property="testng.methods.arg" value="@{testincludes}.@{testmethods}">
+                    <isset property="test.method"/>
+                </condition>
+                <union id="test.set">
+                    <fileset dir="${test.src.dir}" excludes="@{excludes},**/*.xml,${excludes}" includes="@{includes}">
+                        <filename name="@{testincludes}"/>
+                    </fileset>
+                </union>
+                <taskdef classname="org.testng.TestNGAntTask" classpath="${run.test.classpath}" name="testng"/>
+                <testng classfilesetref="test.set" failureProperty="tests.failed" listeners="org.testng.reporters.VerboseReporter" methods="${testng.methods.arg}" mode="${testng.mode}" outputdir="${build.test.results.dir}" suitename="Crypto" testname="TestNG tests" workingDir="${work.dir}">
+                    <xmlfileset dir="${build.test.classes.dir}" includes="@{testincludes}"/>
+                    <propertyset>
+                        <propertyref prefix="test-sys-prop."/>
+                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
+                    </propertyset>
+                    <customize/>
+                </testng>
+            </sequential>
+        </macrodef>
+    </target>
+    <target name="-init-macrodef-test-impl">
+        <macrodef name="test-impl" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <element implicit="true" name="customize" optional="true"/>
+            <sequential>
+                <echo>No tests executed.</echo>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-macrodef-junit" if="${junit.available}" name="-init-macrodef-junit-impl">
+        <macrodef name="test-impl" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <element implicit="true" name="customize" optional="true"/>
+            <sequential>
+                <j2seproject3:junit excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
+                    <customize/>
+                </j2seproject3:junit>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-macrodef-testng" if="${testng.available}" name="-init-macrodef-testng-impl">
+        <macrodef name="test-impl" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <element implicit="true" name="customize" optional="true"/>
+            <sequential>
+                <j2seproject3:testng excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
+                    <customize/>
+                </j2seproject3:testng>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-macrodef-test-impl,-init-macrodef-junit-impl,-init-macrodef-testng-impl" name="-init-macrodef-test">
+        <macrodef name="test" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <sequential>
+                <j2seproject3:test-impl excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
+                    <customize>
+                        <classpath>
+                            <path path="${run.test.classpath}"/>
+                        </classpath>
+                        <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
+                        <jvmarg line="${run.jvmargs}"/>
+                        <jvmarg line="${run.jvmargs.ide}"/>
+                    </customize>
+                </j2seproject3:test-impl>
+            </sequential>
+        </macrodef>
+    </target>
+    <target if="${junit.available}" name="-init-macrodef-junit-debug" unless="${nb.junit.batch}">
+        <macrodef name="junit-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <property name="junit.forkmode" value="perTest"/>
+                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}">
+                    <test methods="@{testmethods}" name="@{testincludes}" todir="${build.test.results.dir}"/>
+                    <syspropertyset>
+                        <propertyref prefix="test-sys-prop."/>
+                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
+                    </syspropertyset>
+                    <formatter type="brief" usefile="false"/>
+                    <formatter type="xml"/>
+                    <jvmarg value="-ea"/>
+                    <jvmarg line="${debug-args-line}"/>
+                    <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
+                    <customize/>
+                </junit>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-test-properties" if="${nb.junit.batch}" name="-init-macrodef-junit-debug-batch">
+        <macrodef name="junit-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <property name="junit.forkmode" value="perTest"/>
+                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}">
+                    <batchtest todir="${build.test.results.dir}">
+                        <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
+                            <filename name="@{testincludes}"/>
+                        </fileset>
+                        <fileset dir="${build.test.classes.dir}" excludes="@{excludes},${excludes},${test.binaryexcludes}" includes="${test.binaryincludes}">
+                            <filename name="${test.binarytestincludes}"/>
+                        </fileset>
+                    </batchtest>
+                    <syspropertyset>
+                        <propertyref prefix="test-sys-prop."/>
+                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
+                    </syspropertyset>
+                    <formatter type="brief" usefile="false"/>
+                    <formatter type="xml"/>
+                    <jvmarg value="-ea"/>
+                    <jvmarg line="${debug-args-line}"/>
+                    <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
+                    <customize/>
+                </junit>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-macrodef-junit-debug,-init-macrodef-junit-debug-batch" if="${junit.available}" name="-init-macrodef-junit-debug-impl">
+        <macrodef name="test-debug-impl" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <element implicit="true" name="customize" optional="true"/>
+            <sequential>
+                <j2seproject3:junit-debug excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
+                    <customize/>
+                </j2seproject3:junit-debug>
+            </sequential>
+        </macrodef>
+    </target>
+    <target if="${testng.available}" name="-init-macrodef-testng-debug">
+        <macrodef name="testng-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${main.class}" name="testClass"/>
+            <attribute default="" name="testMethod"/>
+            <element name="customize2" optional="true"/>
+            <sequential>
+                <condition else="-testclass @{testClass}" property="test.class.or.method" value="-methods @{testClass}.@{testMethod}">
+                    <isset property="test.method"/>
+                </condition>
+                <condition else="-suitename Crypto -testname @{testClass} ${test.class.or.method}" property="testng.cmd.args" value="@{testClass}">
+                    <matches pattern=".*\.xml" string="@{testClass}"/>
+                </condition>
+                <delete dir="${build.test.results.dir}" quiet="true"/>
+                <mkdir dir="${build.test.results.dir}"/>
+                <j2seproject3:debug classname="org.testng.TestNG" classpath="${debug.test.classpath}">
+                    <customize>
+                        <customize2/>
+                        <jvmarg value="-ea"/>
+                        <arg line="${testng.debug.mode}"/>
+                        <arg line="-d ${build.test.results.dir}"/>
+                        <arg line="-listener org.testng.reporters.VerboseReporter"/>
+                        <arg line="${testng.cmd.args}"/>
+                    </customize>
+                </j2seproject3:debug>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-macrodef-testng-debug" if="${testng.available}" name="-init-macrodef-testng-debug-impl">
+        <macrodef name="testng-debug-impl" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${main.class}" name="testClass"/>
+            <attribute default="" name="testMethod"/>
+            <element implicit="true" name="customize2" optional="true"/>
+            <sequential>
+                <j2seproject3:testng-debug testClass="@{testClass}" testMethod="@{testMethod}">
+                    <customize2/>
+                </j2seproject3:testng-debug>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-macrodef-junit-debug-impl" if="${junit.available}" name="-init-macrodef-test-debug-junit">
+        <macrodef name="test-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <attribute default="${main.class}" name="testClass"/>
+            <attribute default="" name="testMethod"/>
+            <sequential>
+                <j2seproject3:test-debug-impl excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
+                    <customize>
+                        <classpath>
+                            <path path="${run.test.classpath}"/>
+                        </classpath>
+                        <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
+                        <jvmarg line="${run.jvmargs}"/>
+                        <jvmarg line="${run.jvmargs.ide}"/>
+                    </customize>
+                </j2seproject3:test-debug-impl>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-macrodef-testng-debug-impl" if="${testng.available}" name="-init-macrodef-test-debug-testng">
+        <macrodef name="test-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <attribute default="${main.class}" name="testClass"/>
+            <attribute default="" name="testMethod"/>
+            <sequential>
+                <j2seproject3:testng-debug-impl testClass="@{testClass}" testMethod="@{testMethod}">
+                    <customize2>
+                        <syspropertyset>
+                            <propertyref prefix="test-sys-prop."/>
+                            <mapper from="test-sys-prop.*" to="*" type="glob"/>
+                        </syspropertyset>
+                    </customize2>
+                </j2seproject3:testng-debug-impl>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-macrodef-test-debug-junit,-init-macrodef-test-debug-testng" name="-init-macrodef-test-debug"/>
+    <!--
+                pre NB7.2 profiling section; consider it deprecated
+            -->
+    <target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile, -profile-init-check" if="profiler.info.jvmargs.agent" name="profile-init"/>
+    <target if="profiler.info.jvmargs.agent" name="-profile-pre-init">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target if="profiler.info.jvmargs.agent" name="-profile-post-init">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target if="profiler.info.jvmargs.agent" name="-profile-init-macrodef-profile">
+        <macrodef name="resolve">
+            <attribute name="name"/>
+            <attribute name="value"/>
+            <sequential>
+                <property name="@{name}" value="${env.@{value}}"/>
+            </sequential>
+        </macrodef>
+        <macrodef name="profile">
+            <attribute default="${main.class}" name="classname"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <property environment="env"/>
+                <resolve name="profiler.current.path" value="${profiler.info.pathvar}"/>
+                <java classname="@{classname}" dir="${profiler.info.dir}" fork="true" jvm="${profiler.info.jvm}">
+                    <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
+                    <jvmarg value="${profiler.info.jvmargs.agent}"/>
+                    <jvmarg line="${profiler.info.jvmargs}"/>
+                    <env key="${profiler.info.pathvar}" path="${profiler.info.agentpath}:${profiler.current.path}"/>
+                    <arg line="${application.args}"/>
+                    <classpath>
+                        <path path="${run.classpath}"/>
+                    </classpath>
+                    <syspropertyset>
+                        <propertyref prefix="run-sys-prop."/>
+                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
+                    </syspropertyset>
+                    <customize/>
+                </java>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile" if="profiler.info.jvmargs.agent" name="-profile-init-check">
+        <fail unless="profiler.info.jvm">Must set JVM to use for profiling in profiler.info.jvm</fail>
+        <fail unless="profiler.info.jvmargs.agent">Must set profiler agent JVM arguments in profiler.info.jvmargs.agent</fail>
+    </target>
+    <!--
+                end of pre NB7.2 profiling section
+            -->
+    <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
+        <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
+            <attribute default="${main.class}" name="name"/>
+            <attribute default="${debug.classpath}" name="classpath"/>
+            <attribute default="" name="stopclassname"/>
+            <sequential>
+                <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
+                    <classpath>
+                        <path path="@{classpath}"/>
+                    </classpath>
+                </nbjpdastart>
+            </sequential>
+        </macrodef>
+        <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
+            <attribute default="${build.classes.dir}" name="dir"/>
+            <sequential>
+                <nbjpdareload>
+                    <fileset dir="@{dir}" includes="${fix.classes}">
+                        <include name="${fix.includes}*.class"/>
+                    </fileset>
+                </nbjpdareload>
+            </sequential>
+        </macrodef>
+    </target>
+    <target name="-init-debug-args">
+        <property name="version-output" value="java version &quot;${ant.java.version}"/>
+        <condition property="have-jdk-older-than-1.4">
+            <or>
+                <contains string="${version-output}" substring="java version &quot;1.0"/>
+                <contains string="${version-output}" substring="java version &quot;1.1"/>
+                <contains string="${version-output}" substring="java version &quot;1.2"/>
+                <contains string="${version-output}" substring="java version &quot;1.3"/>
+            </or>
+        </condition>
+        <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
+            <istrue value="${have-jdk-older-than-1.4}"/>
+        </condition>
+        <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
+            <os family="windows"/>
+        </condition>
+        <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
+            <isset property="debug.transport"/>
+        </condition>
+    </target>
+    <target depends="-init-debug-args" name="-init-macrodef-debug">
+        <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${main.class}" name="classname"/>
+            <attribute default="${debug.classpath}" name="classpath"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <java classname="@{classname}" dir="${work.dir}" fork="true">
+                    <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
+                    <jvmarg line="${debug-args-line}"/>
+                    <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
+                    <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
+                    <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
+                    <jvmarg line="${run.jvmargs}"/>
+                    <jvmarg line="${run.jvmargs.ide}"/>
+                    <classpath>
+                        <path path="@{classpath}"/>
+                    </classpath>
+                    <syspropertyset>
+                        <propertyref prefix="run-sys-prop."/>
+                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
+                    </syspropertyset>
+                    <customize/>
+                </java>
+            </sequential>
+        </macrodef>
+    </target>
+    <target name="-init-macrodef-java">
+        <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
+            <attribute default="${main.class}" name="classname"/>
+            <attribute default="${run.classpath}" name="classpath"/>
+            <attribute default="jvm" name="jvm"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <java classname="@{classname}" dir="${work.dir}" fork="true">
+                    <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
+                    <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
+                    <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
+                    <jvmarg line="${run.jvmargs}"/>
+                    <jvmarg line="${run.jvmargs.ide}"/>
+                    <classpath>
+                        <path path="@{classpath}"/>
+                    </classpath>
+                    <syspropertyset>
+                        <propertyref prefix="run-sys-prop."/>
+                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
+                    </syspropertyset>
+                    <customize/>
+                </java>
+            </sequential>
+        </macrodef>
+    </target>
+    <target name="-init-macrodef-copylibs">
+        <macrodef name="copylibs" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${manifest.file}" name="manifest"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
+                <pathconvert property="run.classpath.without.build.classes.dir">
+                    <path path="${run.classpath}"/>
+                    <map from="${build.classes.dir.resolved}" to=""/>
+                </pathconvert>
+                <pathconvert pathsep=" " property="jar.classpath">
+                    <path path="${run.classpath.without.build.classes.dir}"/>
+                    <chainedmapper>
+                        <flattenmapper/>
+                        <filtermapper>
+                            <replacestring from=" " to="%20"/>
+                        </filtermapper>
+                        <globmapper from="*" to="lib/*"/>
+                    </chainedmapper>
+                </pathconvert>
+                <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
+                <copylibs compress="${jar.compress}" excludeFromCopy="${copylibs.excludes}" index="${jar.index}" indexMetaInf="${jar.index.metainf}" jarfile="${dist.jar}" manifest="@{manifest}" rebase="${copylibs.rebase}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
+                    <fileset dir="${build.classes.dir}" excludes="${dist.archive.excludes}"/>
+                    <manifest>
+                        <attribute name="Class-Path" value="${jar.classpath}"/>
+                        <customize/>
+                    </manifest>
+                </copylibs>
+            </sequential>
+        </macrodef>
+    </target>
+    <target name="-init-presetdef-jar">
+        <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
+            <jar compress="${jar.compress}" index="${jar.index}" jarfile="${dist.jar}">
+                <j2seproject1:fileset dir="${build.classes.dir}" excludes="${dist.archive.excludes}"/>
+            </jar>
+        </presetdef>
+    </target>
+    <target name="-init-ap-cmdline-properties">
+        <property name="annotation.processing.enabled" value="true"/>
+        <property name="annotation.processing.processors.list" value=""/>
+        <property name="annotation.processing.processor.options" value=""/>
+        <property name="annotation.processing.run.all.processors" value="true"/>
+        <property name="javac.processorpath" value="${javac.classpath}"/>
+        <property name="javac.test.processorpath" value="${javac.test.classpath}"/>
+        <condition property="ap.supported.internal" value="true">
+            <not>
+                <matches pattern="1\.[0-5](\..*)?" string="${javac.source}"/>
+            </not>
+        </condition>
+    </target>
+    <target depends="-init-ap-cmdline-properties" if="ap.supported.internal" name="-init-ap-cmdline-supported">
+        <condition else="" property="ap.processors.internal" value="-processor ${annotation.processing.processors.list}">
+            <isfalse value="${annotation.processing.run.all.processors}"/>
+        </condition>
+        <condition else="" property="ap.proc.none.internal" value="-proc:none">
+            <isfalse value="${annotation.processing.enabled}"/>
+        </condition>
+    </target>
+    <target depends="-init-ap-cmdline-properties,-init-ap-cmdline-supported" name="-init-ap-cmdline">
+        <property name="ap.cmd.line.internal" value=""/>
+    </target>
+    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-test,-init-macrodef-test-debug,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar,-init-ap-cmdline" name="init"/>
+    <!--
+                ===================
+                COMPILATION SECTION
+                ===================
+            -->
+    <target name="-deps-jar-init" unless="built-jar.properties">
+        <property location="${build.dir}/built-jar.properties" name="built-jar.properties"/>
+        <delete file="${built-jar.properties}" quiet="true"/>
+    </target>
+    <target if="already.built.jar.${basedir}" name="-warn-already-built-jar">
+        <echo level="warn" message="Cycle detected: Crypto was already built"/>
+    </target>
+    <target depends="init,-deps-jar-init" name="deps-jar" unless="no.deps">
+        <mkdir dir="${build.dir}"/>
+        <touch file="${built-jar.properties}" verbose="false"/>
+        <property file="${built-jar.properties}" prefix="already.built.jar."/>
+        <antcall target="-warn-already-built-jar"/>
+        <propertyfile file="${built-jar.properties}">
+            <entry key="${basedir}" value=""/>
+        </propertyfile>
+    </target>
+    <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
+    <target depends="init" name="-check-automatic-build">
+        <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
+    </target>
+    <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
+        <antcall target="clean"/>
+    </target>
+    <target depends="init,deps-jar" name="-pre-pre-compile">
+        <mkdir dir="${build.classes.dir}"/>
+    </target>
+    <target name="-pre-compile">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target if="do.depend.true" name="-compile-depend">
+        <pathconvert property="build.generated.subdirs">
+            <dirset dir="${build.generated.sources.dir}" erroronmissingdir="false">
+                <include name="*"/>
+            </dirset>
+        </pathconvert>
+        <j2seproject3:depend srcdir="${src.dir}:${build.generated.subdirs}"/>
+    </target>
+    <target depends="init,deps-jar,-pre-pre-compile,-pre-compile, -copy-persistence-xml,-compile-depend" if="have.sources" name="-do-compile">
+        <j2seproject3:javac gensrcdir="${build.generated.sources.dir}"/>
+        <copy todir="${build.classes.dir}">
+            <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
+        </copy>
+    </target>
+    <target if="has.persistence.xml" name="-copy-persistence-xml">
+        <mkdir dir="${build.classes.dir}/META-INF"/>
+        <copy todir="${build.classes.dir}/META-INF">
+            <fileset dir="${meta.inf.dir}" includes="persistence.xml orm.xml"/>
+        </copy>
+    </target>
+    <target name="-post-compile">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
+    <target name="-pre-compile-single">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
+        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
+        <j2seproject3:force-recompile/>
+        <j2seproject3:javac excludes="" gensrcdir="${build.generated.sources.dir}" includes="${javac.includes}" sourcepath="${src.dir}"/>
+    </target>
+    <target name="-post-compile-single">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
+    <!--
+                ====================
+                JAR BUILDING SECTION
+                ====================
+            -->
+    <target depends="init" name="-pre-pre-jar">
+        <dirname file="${dist.jar}" property="dist.jar.dir"/>
+        <mkdir dir="${dist.jar.dir}"/>
+    </target>
+    <target name="-pre-jar">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init" if="do.archive" name="-do-jar-create-manifest" unless="manifest.available">
+        <tempfile deleteonexit="true" destdir="${build.dir}" property="tmp.manifest.file"/>
+        <touch file="${tmp.manifest.file}" verbose="false"/>
+    </target>
+    <target depends="init" if="do.archive+manifest.available" name="-do-jar-copy-manifest">
+        <tempfile deleteonexit="true" destdir="${build.dir}" property="tmp.manifest.file"/>
+        <copy file="${manifest.file}" tofile="${tmp.manifest.file}"/>
+    </target>
+    <target depends="init,-do-jar-create-manifest,-do-jar-copy-manifest" if="do.archive+main.class.available" name="-do-jar-set-mainclass">
+        <manifest file="${tmp.manifest.file}" mode="update">
+            <attribute name="Main-Class" value="${main.class}"/>
+        </manifest>
+    </target>
+    <target depends="init,-do-jar-create-manifest,-do-jar-copy-manifest" if="do.archive+profile.available" name="-do-jar-set-profile">
+        <manifest file="${tmp.manifest.file}" mode="update">
+            <attribute name="Profile" value="${javac.profile}"/>
+        </manifest>
+    </target>
+    <target depends="init,-do-jar-create-manifest,-do-jar-copy-manifest" if="do.archive+splashscreen.available" name="-do-jar-set-splashscreen">
+        <basename file="${application.splash}" property="splashscreen.basename"/>
+        <mkdir dir="${build.classes.dir}/META-INF"/>
+        <copy failonerror="false" file="${application.splash}" todir="${build.classes.dir}/META-INF"/>
+        <manifest file="${tmp.manifest.file}" mode="update">
+            <attribute name="SplashScreen-Image" value="META-INF/${splashscreen.basename}"/>
+        </manifest>
+    </target>
+    <target depends="init,-init-macrodef-copylibs,compile,-pre-pre-jar,-pre-jar,-do-jar-create-manifest,-do-jar-copy-manifest,-do-jar-set-mainclass,-do-jar-set-profile,-do-jar-set-splashscreen" if="do.mkdist" name="-do-jar-copylibs">
+        <j2seproject3:copylibs manifest="${tmp.manifest.file}"/>
+        <echo level="info">To run this application from the command line without Ant, try:</echo>
+        <property location="${dist.jar}" name="dist.jar.resolved"/>
+        <echo level="info">java -jar "${dist.jar.resolved}"</echo>
+    </target>
+    <target depends="init,compile,-pre-pre-jar,-pre-jar,-do-jar-create-manifest,-do-jar-copy-manifest,-do-jar-set-mainclass,-do-jar-set-profile,-do-jar-set-splashscreen" if="do.archive" name="-do-jar-jar" unless="do.mkdist">
+        <j2seproject1:jar manifest="${tmp.manifest.file}"/>
+        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
+        <property location="${dist.jar}" name="dist.jar.resolved"/>
+        <pathconvert property="run.classpath.with.dist.jar">
+            <path path="${run.classpath}"/>
+            <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
+        </pathconvert>
+        <condition else="" property="jar.usage.message" value="To run this application from the command line without Ant, try:${line.separator}${platform.java} -cp ${run.classpath.with.dist.jar} ${main.class}">
+            <isset property="main.class.available"/>
+        </condition>
+        <condition else="debug" property="jar.usage.level" value="info">
+            <isset property="main.class.available"/>
+        </condition>
+        <echo level="${jar.usage.level}" message="${jar.usage.message}"/>
+    </target>
+    <target depends="-do-jar-copylibs" if="do.archive" name="-do-jar-delete-manifest">
+        <delete>
+            <fileset file="${tmp.manifest.file}"/>
+        </delete>
+    </target>
+    <target depends="init,compile,-pre-pre-jar,-pre-jar,-do-jar-create-manifest,-do-jar-copy-manifest,-do-jar-set-mainclass,-do-jar-set-profile,-do-jar-set-splashscreen,-do-jar-jar,-do-jar-delete-manifest" name="-do-jar-without-libraries"/>
+    <target depends="init,compile,-pre-pre-jar,-pre-jar,-do-jar-create-manifest,-do-jar-copy-manifest,-do-jar-set-mainclass,-do-jar-set-profile,-do-jar-set-splashscreen,-do-jar-copylibs,-do-jar-delete-manifest" name="-do-jar-with-libraries"/>
+    <target name="-post-jar">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,compile,-pre-jar,-do-jar-without-libraries,-do-jar-with-libraries,-post-jar" name="-do-jar"/>
+    <target depends="init,compile,-pre-jar,-do-jar,-post-jar" description="Build JAR." name="jar"/>
+    <!--
+                =================
+                EXECUTION SECTION
+                =================
+            -->
+    <target depends="init,compile" description="Run a main class." name="run">
+        <j2seproject1:java>
+            <customize>
+                <arg line="${application.args}"/>
+            </customize>
+        </j2seproject1:java>
+    </target>
+    <target name="-do-not-recompile">
+        <property name="javac.includes.binary" value=""/>
+    </target>
+    <target depends="init,compile-single" name="run-single">
+        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
+        <j2seproject1:java classname="${run.class}"/>
+    </target>
+    <target depends="init,compile-test-single" name="run-test-with-main">
+        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
+        <j2seproject1:java classname="${run.class}" classpath="${run.test.classpath}"/>
+    </target>
+    <!--
+                =================
+                DEBUGGING SECTION
+                =================
+            -->
+    <target depends="init" if="netbeans.home" name="-debug-start-debugger">
+        <j2seproject1:nbjpdastart name="${debug.class}"/>
+    </target>
+    <target depends="init" if="netbeans.home" name="-debug-start-debugger-main-test">
+        <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${debug.class}"/>
+    </target>
+    <target depends="init,compile" name="-debug-start-debuggee">
+        <j2seproject3:debug>
+            <customize>
+                <arg line="${application.args}"/>
+            </customize>
+        </j2seproject3:debug>
+    </target>
+    <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
+    <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
+        <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
+    </target>
+    <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
+    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
+        <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
+        <j2seproject3:debug classname="${debug.class}"/>
+    </target>
+    <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
+    <target depends="init,compile-test-single" if="netbeans.home" name="-debug-start-debuggee-main-test">
+        <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
+        <j2seproject3:debug classname="${debug.class}" classpath="${debug.test.classpath}"/>
+    </target>
+    <target depends="init,compile-test-single,-debug-start-debugger-main-test,-debug-start-debuggee-main-test" if="netbeans.home" name="debug-test-with-main"/>
+    <target depends="init" name="-pre-debug-fix">
+        <fail unless="fix.includes">Must set fix.includes</fail>
+        <property name="javac.includes" value="${fix.includes}.java"/>
+    </target>
+    <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
+        <j2seproject1:nbjpdareload/>
+    </target>
+    <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
+    <!--
+                =================
+                PROFILING SECTION
+                =================
+            -->
+    <!--
+                pre NB7.2 profiler integration
+            -->
+    <target depends="profile-init,compile" description="Profile a project in the IDE." if="profiler.info.jvmargs.agent" name="-profile-pre72">
+        <fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>
+        <nbprofiledirect>
+            <classpath>
+                <path path="${run.classpath}"/>
+            </classpath>
+        </nbprofiledirect>
+        <profile/>
+    </target>
+    <target depends="profile-init,compile-single" description="Profile a selected class in the IDE." if="profiler.info.jvmargs.agent" name="-profile-single-pre72">
+        <fail unless="profile.class">Must select one file in the IDE or set profile.class</fail>
+        <fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>
+        <nbprofiledirect>
+            <classpath>
+                <path path="${run.classpath}"/>
+            </classpath>
+        </nbprofiledirect>
+        <profile classname="${profile.class}"/>
+    </target>
+    <target depends="profile-init,compile-single" if="profiler.info.jvmargs.agent" name="-profile-applet-pre72">
+        <fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>
+        <nbprofiledirect>
+            <classpath>
+                <path path="${run.classpath}"/>
+            </classpath>
+        </nbprofiledirect>
+        <profile classname="sun.applet.AppletViewer">
+            <customize>
+                <arg value="${applet.url}"/>
+            </customize>
+        </profile>
+    </target>
+    <target depends="profile-init,compile-test-single" if="profiler.info.jvmargs.agent" name="-profile-test-single-pre72">
+        <fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>
+        <nbprofiledirect>
+            <classpath>
+                <path path="${run.test.classpath}"/>
+            </classpath>
+        </nbprofiledirect>
+        <junit dir="${profiler.info.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" jvm="${profiler.info.jvm}" showoutput="true">
+            <env key="${profiler.info.pathvar}" path="${profiler.info.agentpath}:${profiler.current.path}"/>
+            <jvmarg value="${profiler.info.jvmargs.agent}"/>
+            <jvmarg line="${profiler.info.jvmargs}"/>
+            <test name="${profile.class}"/>
+            <classpath>
+                <path path="${run.test.classpath}"/>
+            </classpath>
+            <syspropertyset>
+                <propertyref prefix="test-sys-prop."/>
+                <mapper from="test-sys-prop.*" to="*" type="glob"/>
+            </syspropertyset>
+            <formatter type="brief" usefile="false"/>
+            <formatter type="xml"/>
+        </junit>
+    </target>
+    <!--
+                end of pre NB72 profiling section
+            -->
+    <target if="netbeans.home" name="-profile-check">
+        <condition property="profiler.configured">
+            <or>
+                <contains casesensitive="true" string="${run.jvmargs.ide}" substring="-agentpath:"/>
+                <contains casesensitive="true" string="${run.jvmargs.ide}" substring="-javaagent:"/>
+            </or>
+        </condition>
+    </target>
+    <target depends="-profile-check,-profile-pre72" description="Profile a project in the IDE." if="profiler.configured" name="profile" unless="profiler.info.jvmargs.agent">
+        <startprofiler/>
+        <antcall target="run"/>
+    </target>
+    <target depends="-profile-check,-profile-single-pre72" description="Profile a selected class in the IDE." if="profiler.configured" name="profile-single" unless="profiler.info.jvmargs.agent">
+        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
+        <startprofiler/>
+        <antcall target="run-single"/>
+    </target>
+    <target depends="-profile-test-single-pre72" description="Profile a selected test in the IDE." name="profile-test-single"/>
+    <target depends="-profile-check" description="Profile a selected test in the IDE." if="profiler.configured" name="profile-test" unless="profiler.info.jvmargs">
+        <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
+        <startprofiler/>
+        <antcall target="test-single"/>
+    </target>
+    <target depends="-profile-check" description="Profile a selected class in the IDE." if="profiler.configured" name="profile-test-with-main">
+        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
+        <startprofiler/>
+        <antcal target="run-test-with-main"/>
+    </target>
+    <target depends="-profile-check,-profile-applet-pre72" if="profiler.configured" name="profile-applet" unless="profiler.info.jvmargs.agent">
+        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
+        <startprofiler/>
+        <antcall target="run-applet"/>
+    </target>
+    <!--
+                ===============
+                JAVADOC SECTION
+                ===============
+            -->
+    <target depends="init" if="have.sources" name="-javadoc-build">
+        <mkdir dir="${dist.javadoc.dir}"/>
+        <condition else="" property="javadoc.endorsed.classpath.cmd.line.arg" value="-J${endorsed.classpath.cmd.line.arg}">
+            <and>
+                <isset property="endorsed.classpath.cmd.line.arg"/>
+                <not>
+                    <equals arg1="${endorsed.classpath.cmd.line.arg}" arg2=""/>
+                </not>
+            </and>
+        </condition>
+        <condition else="" property="bug5101868workaround" value="*.java">
+            <matches pattern="1\.[56](\..*)?" string="${java.version}"/>
+        </condition>
+        <javadoc additionalparam="-J-Dfile.encoding=${file.encoding} ${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
+            <classpath>
+                <path path="${javac.classpath}"/>
+            </classpath>
+            <fileset dir="${src.dir}" excludes="${bug5101868workaround},${excludes}" includes="${includes}">
+                <filename name="**/*.java"/>
+            </fileset>
+            <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
+                <include name="**/*.java"/>
+                <exclude name="*.java"/>
+            </fileset>
+            <arg line="${javadoc.endorsed.classpath.cmd.line.arg}"/>
+        </javadoc>
+        <copy todir="${dist.javadoc.dir}">
+            <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
+                <filename name="**/doc-files/**"/>
+            </fileset>
+            <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
+                <include name="**/doc-files/**"/>
+            </fileset>
+        </copy>
+    </target>
+    <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
+        <nbbrowse file="${dist.javadoc.dir}/index.html"/>
+    </target>
+    <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
+    <!--
+                =========================
+                TEST COMPILATION SECTION
+                =========================
+            -->
+    <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
+        <mkdir dir="${build.test.classes.dir}"/>
+    </target>
+    <target name="-pre-compile-test">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target if="do.depend.true" name="-compile-test-depend">
+        <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
+    </target>
+    <target depends="init,deps-jar,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
+        <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" processorpath="${javac.test.processorpath}" srcdir="${test.src.dir}"/>
+        <copy todir="${build.test.classes.dir}">
+            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
+        </copy>
+    </target>
+    <target name="-post-compile-test">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
+    <target name="-pre-compile-test-single">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,deps-jar,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
+        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
+        <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
+        <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" processorpath="${javac.test.processorpath}" sourcepath="${test.src.dir}" srcdir="${test.src.dir}"/>
+        <copy todir="${build.test.classes.dir}">
+            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
+        </copy>
+    </target>
+    <target name="-post-compile-test-single">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
+    <!--
+                =======================
+                TEST EXECUTION SECTION
+                =======================
+            -->
+    <target depends="init" if="have.tests" name="-pre-test-run">
+        <mkdir dir="${build.test.results.dir}"/>
+    </target>
+    <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
+        <j2seproject3:test includes="${includes}" testincludes="**/*Test.java"/>
+    </target>
+    <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
+        <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
+    </target>
+    <target depends="init" if="have.tests" name="test-report"/>
+    <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
+    <target depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests." name="test"/>
+    <target depends="init" if="have.tests" name="-pre-test-run-single">
+        <mkdir dir="${build.test.results.dir}"/>
+    </target>
+    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
+        <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
+        <j2seproject3:test excludes="" includes="${test.includes}" testincludes="${test.includes}"/>
+    </target>
+    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
+        <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
+    </target>
+    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>
+    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single-method">
+        <fail unless="test.class">Must select some files in the IDE or set test.class</fail>
+        <fail unless="test.method">Must select some method in the IDE or set test.method</fail>
+        <j2seproject3:test excludes="" includes="${javac.includes}" testincludes="${test.class}" testmethods="${test.method}"/>
+    </target>
+    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single-method" if="have.tests" name="-post-test-run-single-method">
+        <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
+    </target>
+    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single-method,-post-test-run-single-method" description="Run single unit test." name="test-single-method"/>
+    <!--
+                =======================
+                TEST DEBUGGING SECTION
+                =======================
+            -->
+    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-debug-start-debuggee-test">
+        <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
+        <j2seproject3:test-debug excludes="" includes="${javac.includes}" testClass="${test.class}" testincludes="${javac.includes}"/>
+    </target>
+    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-debug-start-debuggee-test-method">
+        <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
+        <fail unless="test.method">Must select some method in the IDE or set test.method</fail>
+        <j2seproject3:test-debug excludes="" includes="${javac.includes}" testClass="${test.class}" testMethod="${test.method}" testincludes="${test.class}" testmethods="${test.method}"/>
+    </target>
+    <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
+        <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
+    </target>
+    <target depends="init,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
+    <target depends="init,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test-method" name="debug-test-method"/>
+    <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
+        <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
+    </target>
+    <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
+    <!--
+                =========================
+                APPLET EXECUTION SECTION
+                =========================
+            -->
+    <target depends="init,compile-single" name="run-applet">
+        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
+        <j2seproject1:java classname="sun.applet.AppletViewer">
+            <customize>
+                <arg value="${applet.url}"/>
+            </customize>
+        </j2seproject1:java>
+    </target>
+    <!--
+                =========================
+                APPLET DEBUGGING  SECTION
+                =========================
+            -->
+    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
+        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
+        <j2seproject3:debug classname="sun.applet.AppletViewer">
+            <customize>
+                <arg value="${applet.url}"/>
+            </customize>
+        </j2seproject3:debug>
+    </target>
+    <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
+    <!--
+                ===============
+                CLEANUP SECTION
+                ===============
+            -->
+    <target name="-deps-clean-init" unless="built-clean.properties">
+        <property location="${build.dir}/built-clean.properties" name="built-clean.properties"/>
+        <delete file="${built-clean.properties}" quiet="true"/>
+    </target>
+    <target if="already.built.clean.${basedir}" name="-warn-already-built-clean">
+        <echo level="warn" message="Cycle detected: Crypto was already built"/>
+    </target>
+    <target depends="init,-deps-clean-init" name="deps-clean" unless="no.deps">
+        <mkdir dir="${build.dir}"/>
+        <touch file="${built-clean.properties}" verbose="false"/>
+        <property file="${built-clean.properties}" prefix="already.built.clean."/>
+        <antcall target="-warn-already-built-clean"/>
+        <propertyfile file="${built-clean.properties}">
+            <entry key="${basedir}" value=""/>
+        </propertyfile>
+    </target>
+    <target depends="init" name="-do-clean">
+        <delete dir="${build.dir}"/>
+        <delete dir="${dist.dir}" followsymlinks="false" includeemptydirs="true"/>
+    </target>
+    <target name="-post-clean">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
+    <target name="-check-call-dep">
+        <property file="${call.built.properties}" prefix="already.built."/>
+        <condition property="should.call.dep">
+            <and>
+                <not>
+                    <isset property="already.built.${call.subproject}"/>
+                </not>
+                <available file="${call.script}"/>
+            </and>
+        </condition>
+    </target>
+    <target depends="-check-call-dep" if="should.call.dep" name="-maybe-call-dep">
+        <ant antfile="${call.script}" inheritall="false" target="${call.target}">
+            <propertyset>
+                <propertyref prefix="transfer."/>
+                <mapper from="transfer.*" to="*" type="glob"/>
+            </propertyset>
+        </ant>
+    </target>
+</project>
diff --git a/Crypto/nbproject/genfiles.properties b/Crypto/nbproject/genfiles.properties
new file mode 100644 (file)
index 0000000..652dcb1
--- /dev/null
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=7f90a431
+build.xml.script.CRC32=a2c5abf7
+build.xml.stylesheet.CRC32=8064a381@1.75.2.48
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=7f90a431
+nbproject/build-impl.xml.script.CRC32=bbf0bcf8
+nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48
diff --git a/Crypto/nbproject/private/config.properties b/Crypto/nbproject/private/config.properties
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/Crypto/nbproject/private/private.properties b/Crypto/nbproject/private/private.properties
new file mode 100644 (file)
index 0000000..845c36f
--- /dev/null
@@ -0,0 +1,6 @@
+compile.on.save=true
+do.depend=false
+do.jar=true
+javac.debug=true
+javadoc.preview=true
+user.properties.file=C:\\Users\\Kalter\\AppData\\Roaming\\NetBeans\\8.0.1\\build.properties
diff --git a/Crypto/nbproject/private/private.xml b/Crypto/nbproject/private/private.xml
new file mode 100644 (file)
index 0000000..6807a2b
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
+    <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
+    <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
+        <group/>
+    </open-files>
+</project-private>
diff --git a/Crypto/nbproject/project.properties b/Crypto/nbproject/project.properties
new file mode 100644 (file)
index 0000000..c43d30e
--- /dev/null
@@ -0,0 +1,75 @@
+annotation.processing.enabled=true
+annotation.processing.enabled.in.editor=false
+annotation.processing.processors.list=
+annotation.processing.run.all.processors=true
+annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+application.title=Crypto
+application.vendor=Kalter
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+# Uncomment to specify the preferred debugger connection transport:
+#debug.transport=dt_socket
+debug.classpath=\
+    ${run.classpath}
+debug.test.classpath=\
+    ${run.test.classpath}
+# \u0424\u0430\u0439\u043b\u044b \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 build.classes.dir, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438\u0437 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0430\u0440\u0445\u0438\u0432\u0430 jar
+dist.archive.excludes=
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/Crypto.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+endorsed.classpath=
+excludes=
+includes=**
+jar.compress=false
+javac.classpath=
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.processorpath=\
+    ${javac.classpath}
+javac.source=1.8
+javac.target=1.8
+javac.test.classpath=\
+    ${javac.classpath}:\
+    ${build.classes.dir}
+javac.test.processorpath=\
+    ${javac.test.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+main.class=code.kalter.longflight.crypto.Crypto
+manifest.file=manifest.mf
+meta.inf.dir=${src.dir}/META-INF
+mkdist.disabled=false
+platform.active=default_platform
+run.classpath=\
+    ${javac.classpath}:\
+    ${build.classes.dir}
+# Space-separated list of JVM arguments used when running the project.
+# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
+# To set system properties for unit tests define test-sys-prop.name=value:
+run.jvmargs=
+run.test.classpath=\
+    ${javac.test.classpath}:\
+    ${build.test.classes.dir}
+source.encoding=UTF-8
+src.dir=src
+test.src.dir=test
diff --git a/Crypto/nbproject/project.xml b/Crypto/nbproject/project.xml
new file mode 100644 (file)
index 0000000..7af0877
--- /dev/null
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://www.netbeans.org/ns/project/1">
+    <type>org.netbeans.modules.java.j2seproject</type>
+    <configuration>
+        <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
+            <name>Crypto</name>
+            <source-roots>
+                <root id="src.dir"/>
+            </source-roots>
+            <test-roots>
+                <root id="test.src.dir"/>
+            </test-roots>
+        </data>
+    </configuration>
+</project>
diff --git a/Crypto/src/code/kalter/longflight/crypto/CIStream.java b/Crypto/src/code/kalter/longflight/crypto/CIStream.java
new file mode 100644 (file)
index 0000000..ded156e
--- /dev/null
@@ -0,0 +1,38 @@
+package code.kalter.longflight.crypto;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Шифровальный входной поток
+ *
+ * @author Kalter
+ */
+public class CIStream extends InputStream {
+    
+    private final InputStream istream;
+    private final Random random;
+    
+    public CIStream(InputStream istream, int key) {
+        this.istream = istream;
+        this.random = new Random(key);
+    }
+    
+    @Override
+    public int read() throws IOException {
+        int b = istream.read();
+        b = (b << 4) | (b >> 4);
+        b ^= random.random(0xFF);
+        return b;
+    }
+    
+    @Override
+    public int available() throws IOException {
+        return istream.available();
+    }
+    
+    @Override
+    public void close() throws IOException {
+        istream.close();
+    }
+}
diff --git a/Crypto/src/code/kalter/longflight/crypto/Crypto.java b/Crypto/src/code/kalter/longflight/crypto/Crypto.java
new file mode 100644 (file)
index 0000000..876384c
--- /dev/null
@@ -0,0 +1,33 @@
+package code.kalter.longflight.crypto;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * Главный класс
+ *
+ * @author Kalter
+ */
+public class Crypto {
+
+    public static void main(String[] args) throws IOException {
+        final String iname = args[0];
+        final String oname = args[1];
+        final int key = Integer.parseInt(args[2], 16);
+        try (InputStream fistream = new CIStream(new FileInputStream(iname), key);
+                OutputStream fostream = new FileOutputStream("_" + oname);) {
+            while (fistream.available() > 0) {
+                fostream.write(fistream.read());
+            }
+        } catch (FileNotFoundException e) {
+            System.out.println("File not found");
+            e.printStackTrace();
+        } catch (IOException e) {
+            System.out.println("I/O error");
+        }
+    }
+}
diff --git a/Crypto/src/code/kalter/longflight/crypto/Random.java b/Crypto/src/code/kalter/longflight/crypto/Random.java
new file mode 100644 (file)
index 0000000..408bde0
--- /dev/null
@@ -0,0 +1,26 @@
+package code.kalter.longflight.crypto;
+
+/**
+ * ГПСЧ
+ *
+ * @author Kalter
+ */
+public class Random {
+
+    private int next;
+
+    public Random(int next) {
+        this.next = next;
+    }
+
+    public int random() {
+        next ^= (next << 13);
+        next ^= (next >>> 17);
+        next ^= (next << 5);
+        return Math.abs(next);
+    }
+
+    public int random(int max) {
+        return random() % max;
+    }
+}
diff --git a/README.MD b/README.MD
new file mode 100644 (file)
index 0000000..2ba189e
--- /dev/null
+++ b/README.MD
@@ -0,0 +1,3 @@
+Long Flight - game for Java ME
+
+All files *.png encrypted
\ No newline at end of file
diff --git a/build.xml b/build.xml
new file mode 100644 (file)
index 0000000..efaedac
--- /dev/null
+++ b/build.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- You may freely edit this file. See commented blocks below for -->
+<!-- some examples of how to customize the build. -->
+<!-- (If you delete it and reopen the project it will be recreated.) -->
+<project name="Long_Flight" default="jar" basedir=".">
+    <description>Builds, tests, and runs the project .</description>
+    <import file="nbproject/build-impl.xml"/>
+    <!--
+
+            There exist several targets which are by default empty and which can be
+            used for execution of your tasks. These targets are usually executed
+            before and after some main targets. They are:
+
+            pre-init:                 called before initialization of project properties
+            post-init:                called after initialization of project properties
+            pre-preprocess:           called before text preprocessing of sources
+            post-preprocess:          called after text preprocessing of sources
+            pre-compile:              called before source compilation
+            post-compile:             called after source compilation
+            pre-obfuscate:            called before obfuscation 
+            post-obfuscate:           called after obfuscation
+            pre-preverify:            called before preverification
+            post-preverify:           called after preverification
+            pre-jar:                  called before jar building
+            post-jar:                 called after jar building
+            pre-build:                called before final distribution building
+            post-build:               called after final distribution building
+            pre-clean:                called before cleaning build products
+            post-clean:               called after cleaning build products
+
+            Example of pluging a my-special-task after the compilation could look like
+
+            <target name="post-compile">
+            <my-special-task>
+            <fileset dir="${build.classes.dir}"/>
+            </my-special-task>
+            </target>
+
+            For list of available properties check the imported
+            nbproject/build-impl.xml file.
+
+            Other way how to customize the build is by overriding existing main targets.
+            The target of interest are:
+
+            preprocess:               preprocessing
+            extract-libs:             extraction of libraries and resources
+            compile:                  compilation
+            create-jad:               construction of jad and jar manifest source
+            obfuscate:                obfuscation
+            preverify:                preverification
+            jar:                      jar archive building
+            run:                      execution
+            debug:                    execution in debug mode
+            build:                    building of the final distribution
+            javadoc:                  javadoc generation
+
+            Example of overriding the target for project execution could look like
+
+            <target name="run" depends="init,jar">
+            <my-special-exec jadfile="${dist.dir}/${dist.jad}"/>
+            </target>
+
+            Be careful about correct dependencies when overriding original target. 
+            Again, for list of available properties which you can use check the target 
+            you are overriding in nbproject/build-impl.xml file.
+
+            A special target for-all-configs can be used to run some specific targets for
+            all project configurations in a sequence. File nbproject/build-impl.xml 
+            already contains some "for-all" targets:
+    
+            jar-all
+            javadoc-all
+            clean-all
+      
+            Example of definition of target iterating over all project configurations:
+    
+            <target name="jar-all">
+            <property name="target.to.call" value="jar"/>
+            <antcall target="for-all-configs"/>
+            </target>
+
+            -->
+</project>
diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml
new file mode 100644 (file)
index 0000000..b42e8ce
--- /dev/null
@@ -0,0 +1,1250 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- *** GENERATED FROM project.xml - DO NOT EDIT *** -->
+<project name="Long_Flight-impl" default="jar" basedir="..">
+    <!--load-properties-->
+    <target name="pre-load-properties">
+        <property file="nbproject/private/private.properties"/>
+        <property name="user.properties.file" location="${netbeans.user}/build.properties"/>
+        <available property="user.properties.file.exists" file="${user.properties.file}"/>
+    </target>
+    <target name="exists.config.active" unless="config.active">
+        <echo level="warning" message="Active configuration (config.active property) is not set - using default."/>
+        <property value="" name="config.active"/>
+    </target>
+    <target name="exists.netbeans.user" unless="netbeans.user">
+        <echo level="warning" message="NetBeans IDE user directory (netbeans.user property) is not set. By specifying this property many properties required by the project will be automatically evaluated (e.g.: ant-ext library home, ...). You could also open this project in the NetBeans IDE - in this case this property would be set automatically."/>
+    </target>
+    <target name="exists.user.properties.file" unless="user.properties.file.exists">
+        <echo level="warning" message="User properties file (user.properties.file) property is not set. By specifying this property many properties required by the project will be automatically evaluated (e.g.: libraries, platforms, ...)."/>
+    </target>
+    <target name="load-properties" depends="pre-load-properties,exists.config.active,exists.netbeans.user,exists.user.properties.file">
+        <loadproperties srcfile="nbproject/project.properties">
+            <filterchain>
+                <containsregex pattern="^configs\.${config.active}\.(.*)" replace="\1"/>
+                <concatfilter prepend="nbproject/project.properties"/>
+                <containsregex pattern="^platform.active=|^deployment.method=|^deployment.instance="/>
+            </filterchain>
+        </loadproperties>
+        <property name="deployment.instance" value="default"/>
+        <loadproperties srcfile="${user.properties.file}">
+            <filterchain>
+                <replaceregex pattern="^platforms\.${platform.active}\." replace="platform."/>
+                <replaceregex pattern="^deployment\.${deployment.method}\.scriptfile=" replace="deployment.scriptfile="/>
+                <replaceregex pattern="^deployments\.${deployment.method}\.${deployment.instance}\.([^=]+)=" replace="\1="/>
+            </filterchain>
+        </loadproperties>
+        <loadproperties srcfile="nbproject/project.properties">
+            <filterchain>
+                <containsregex pattern="^configs\.${config.active}\.(.*)" replace="\1"/>
+                <concatfilter prepend="nbproject/project.properties"/>
+            </filterchain>
+        </loadproperties>
+    </target>
+    <!--basic-init-->
+    <target name="exists.platform.active" unless="platform.active">
+        <echo level="warning" message="Active platform (platform.active property) in not set. If you set this and user.properties.file property, many properties required by the project will be automatically evaluated (e.g.: platform home, platform classpath, ...)."/>
+    </target>
+    <target name="exists.platform.configuration" unless="platform.configuration">
+        <echo level="warning" message="Platform configuration (platform.configuration) is not set. Using default (CLDC-1.0) configuration."/>
+        <property name="platform.configuration" value="CLDC-1.0"/>
+    </target>
+    <target name="exists.platform.profile" unless="platform.profile">
+        <echo level="warning" message="Platform profile (platform.profile) is not set. Using default (MIDP-1.0) profile."/>
+        <property name="platform.profile" value="MIDP-1.0"/>
+    </target>
+    <target name="basic-init" depends="exists.platform.active,exists.platform.configuration,exists.platform.profile">
+        <fail unless="libs.j2me_ant_ext.classpath">Classpath to J2ME Ant extension library (libs.j2me_ant_ext.classpath property) is not set. For example: location of mobility/modules/org-netbeans-mobility-antext.jar file in the IDE installation directory.</fail>
+        <fail unless="platform.home">Platform home (platform.home property) is not set. Value of this property should be ${platform.active.description} emulator home directory location.</fail>
+        <fail unless="platform.bootclasspath">Platform boot classpath (platform.bootclasspath property) is not set. Value of this property should be ${platform.active.description} emulator boot classpath containing all J2ME classes provided by emulator.</fail>
+        <fail unless="src.dir">Must set src.dir</fail>
+        <fail unless="build.dir">Must set build.dir</fail>
+        <fail unless="dist.dir">Must set dist.dir</fail>
+        <fail unless="dist.jar">Must set dist.jar</fail>
+        <property name="javac.source" value="1.3"/>
+        <property name="javac.target" value="1.1"/>
+        <property name="javac.encoding" value="${file.encoding}"/>
+        <property name="deployment.number" value="0.0.1"/>
+        <property name="deployment.counter" value="000002"/>
+        <condition property="no.deps">
+            <istrue value="${no.dependencies}"/>
+        </condition>
+        <condition property="no.preprocess">
+            <isfalse value="${use.preprocessor}"/>
+        </condition>
+        <condition property="no.javadoc.preview">
+            <isfalse value="${javadoc.preview}"/>
+        </condition>
+        <condition property="filter.excludes.evaluated" value="${filter.excludes},${filter.more.excludes},**/*Test.java,**/test,**/test/**">
+            <istrue value="${filter.exclude.tests}"/>
+        </condition>
+        <property name="filter.excludes.evaluated" value="${filter.excludes},${filter.more.excludes}"/>
+        <condition property="deployment.do.override.jarurl" value="">
+            <istrue value="${deployment.override.jarurl}"/>
+        </condition>
+        <condition property="config.active.name" value="DefaultConfiguration">
+            <length string="${config.active}" trim="true" length="0"/>
+        </condition>
+        <property name="config.active.name" value="${config.active}"/>
+        <taskdef resource="org/netbeans/mobility/antext/defs.properties">
+            <classpath>
+                <pathelement path="${libs.j2me_ant_ext.classpath}"/>
+            </classpath>
+        </taskdef>
+        <condition property="skip.deployment">
+            <equals arg1="${deployment.method}" arg2="NONE" casesensitive="false" trim="true"/>
+        </condition>
+        <condition property="app-version.autoincrement.trigger">
+            <istrue value="${app-version.autoincrement}"/>
+        </condition>
+        <condition property="debug.timeout" value="30000">
+            <or>
+                <equals arg1="${debugger.timeout}" arg2="" trim="true"/>
+                <not>
+                    <isset property="debugger.timeout"/>
+                </not>
+            </or>
+        </condition>
+        <property name="debug.timeout" value="${debugger.timeout}"/>
+        <nb-overrideproperty name="buildsystem.baton" value="${src.dir}"/>
+    </target>
+    <!--cldc-init-->
+    <target name="cldc-pre-init">
+        <condition property="cldc-platform.trigger">
+            <equals arg1="CLDC" arg2="${platform.trigger}" casesensitive="false"/>
+        </condition>
+    </target>
+    <target name="cldc-init" depends="cldc-pre-init" if="cldc-platform.trigger">
+        <property name="preverify.sources.dir" location="${build.dir}/preverifysrc"/>
+        <property name="manifest.build.file" location="${build.dir}/manifest.mf"/>
+        <property name="platform.device" value=""/>
+        <property name="dist.jad.url" value="file://"/>
+        <property name="run.cmd.options" value=""/>
+        <condition property="evaluated.run.security.domain" value="">
+            <isfalse value="${run.use.security.domain}"/>
+        </condition>
+        <property name="evaluated.run.security.domain" value="${run.security.domain}"/>
+        <condition property="override.jarurl.trigger">
+            <and>
+                <istrue value="${cldc-platform.trigger}"/>
+                <istrue value="${deployment.override.jarurl}"/>
+            </and>
+        </condition>
+        <property name="deployment.jad" location="${dist.dir}/${dist.jad}"/>
+        <property name="deployment.jar" location="${dist.dir}/${dist.jar}"/>
+        <property name="deployment.dir" location="${dist.dir}"/>
+        <patternset id="deployment.patternset">
+            <include name="${dist.jad}"/>
+            <include name="${dist.jar}"/>
+        </patternset>
+    </target>
+    <!--cdc-init-->
+    <target name="cdc-init">
+        <condition property="cdc-platform.trigger">
+            <equals arg1="CDC" arg2="${platform.trigger}" casesensitive="false"/>
+        </condition>
+        <available file="${manifest.file}" property="manifest.available"/>
+        <condition property="main.class.applet">
+            <equals arg1="${main.class.class}" arg2="applet" casesensitive="false"/>
+        </condition>
+        <condition property="main.class.xlet">
+            <equals arg1="${main.class.class}" arg2="xlet" casesensitive="false"/>
+        </condition>
+        <condition property="manifest.available+main.class+fat.jar">
+            <and>
+                <isset property="manifest.available"/>
+                <isset property="main.class"/>
+                <istrue value="${platform.fat.jar}"/>
+                <not>
+                    <equals arg1="${main.class}" arg2="" trim="true"/>
+                </not>
+            </and>
+        </condition>
+        <condition property="manifest.available+main.class">
+            <and>
+                <isset property="manifest.available"/>
+                <isset property="main.class"/>
+                <isfalse value="${platform.fat.jar}"/>
+                <not>
+                    <equals arg1="${main.class}" arg2="" trim="true"/>
+                </not>
+            </and>
+        </condition>
+        <condition property="application.version.invalid" value="true">
+            <equals arg1="${deployment.number}" arg2="" trim="true"/>
+        </condition>
+        <fail if="application.version.invalid" message="Property deployment.number must not be empty and must contain version in format %d.%d.%d!"/>
+        <condition property="sign.jar.trigger" value="true">
+            <and>
+                <isset property="cdc-platform.trigger"/>
+                <istrue value="${sign.enabled}"/>
+            </and>
+        </condition>
+    </target>
+    <!--semc-init-->
+    <target name="semc-pre-init" if="cdc-platform.trigger">
+        <condition property="semc-platform.trigger">
+            <equals arg1="semc" arg2="${platform.type}" casesensitive="false"/>
+        </condition>
+    </target>
+    <target name="semc-init" depends="semc-pre-init" if="semc-platform.trigger">
+        <condition property="semc.icon.invalid" value="true">
+            <or>
+                <contains string="${semc.application.icon}" substring="$${"/>
+                <equals arg1="${semc.application.icon}" arg2="" trim="true"/>
+            </or>
+        </condition>
+        <condition property="no.certificateorkey" value="true">
+            <or>
+                <isset property="no.application.uid"/>
+                <equals arg1="${semc.certificate.path}" arg2="" trim="true"/>
+                <contains string="${semc.certificate.path}" substring="$${semc.certificate.path"/>
+                <equals arg1="${semc.private.key.path}" arg2="" trim="true"/>
+                <contains string="${semc.private.key.path}" substring="$${semc.private.key.path"/>
+            </or>
+        </condition>
+        <property name="j9.dist" location="${build.dir}/j9/${semc.application.uid}.j9"/>
+        <taskdef resource="org/netbeans/modules/j2me/cdc/project/defs.properties">
+            <classpath>
+                <pathelement path="${libs.cdc-ant-utils.classpath}"/>
+            </classpath>
+        </taskdef>
+        <taskdef resource="org/netbeans/modules/j2me/cdc/project/semc/defs.properties">
+            <classpath>
+                <pathelement path="${libs.semc-ant-utils.classpath}"/>
+            </classpath>
+        </taskdef>
+        <property name="deployment.dir" location="${dist.dir}"/>
+        <patternset id="deployment.patternset">
+            <include name="*.sis"/>
+            <include name="*.SIS"/>
+        </patternset>
+    </target>
+    <!--savaje-init-->
+    <target name="savaje-pre-init" if="cdc-platform.trigger">
+        <condition property="savaje-platform.trigger">
+            <equals arg1="savaje" arg2="${platform.type}" casesensitive="false"/>
+        </condition>
+    </target>
+    <target name="savaje-init" depends="savaje-pre-init" if="savaje-platform.trigger">
+        <property name="savaje.application.uid" value="TBD"/>
+        <condition property="savaje.bundle.base.invalid" value="true">
+            <or>
+                <equals arg1="${savaje.bundle.base}" arg2="" trim="true"/>
+                <contains string="${savaje.bundle.base}" substring="$${savaje.bundle.base"/>
+            </or>
+        </condition>
+        <condition property="savaje.unsupported.main" value="true">
+            <or>
+                <equals arg1="${main.class.applet}" arg2="true"/>
+            </or>
+        </condition>
+        <condition property="savaje.icon.invalid" value="true">
+            <or>
+                <isset property="no.application.uid"/>
+                <contains string="${savaje.application.icon}" substring="$${"/>
+                <equals arg1="${savaje.application.icon}" arg2="" trim="true"/>
+            </or>
+        </condition>
+        <property name="jnlp.dist" value="${build.dir}/jnlp/bundle.jnlp"/>
+        <property name="deployment.dir" location="${dist.dir}"/>
+        <patternset id="deployment.patternset">
+            <include name="bundle.jnlp"/>
+            <include name="bundle.policy"/>
+            <include name="lib/*"/>
+        </patternset>
+    </target>
+    <!--sjmc-init-->
+    <target name="sjmc-pre-init" if="cdc-platform.trigger">
+        <condition property="sjmc-platform.trigger">
+            <equals arg1="sjmc" arg2="${platform.type}" casesensitive="false"/>
+        </condition>
+    </target>
+    <target name="sjmc-init" depends="sjmc-pre-init" if="sjmc-platform.trigger"/>
+    <!--ojec-init-->
+    <target name="ojec-pre-init" if="cdc-platform.trigger">
+        <condition property="ojec-platform.trigger">
+            <equals arg1="ojec" arg2="${platform.type}" casesensitive="false"/>
+        </condition>
+    </target>
+    <target name="ojec-init" depends="ojec-pre-init" if="ojec-platform.trigger"/>
+    <!--cdc-hi-init-->
+    <target name="cdc-hi-pre-init" if="cdc-platform.trigger">
+        <condition property="cdc-hi-platform.trigger">
+            <equals arg1="cdc-hi" arg2="${platform.type}" casesensitive="false"/>
+        </condition>
+    </target>
+    <target name="cdc-hi-init" depends="cdc-hi-pre-init" if="cdc-hi-platform.trigger"/>
+    <!--nokiaS80-init-->
+    <target name="nokiaS80-pre-init" if="cdc-platform.trigger">
+        <condition property="nokiaS80-platform.trigger">
+            <equals arg1="nokiaS80" arg2="${platform.type}" casesensitive="false"/>
+        </condition>
+    </target>
+    <target name="nokiaS80-init" depends="nokiaS80-pre-init" if="nokiaS80-platform.trigger">
+        <property name="j9.dist" location="${build.dir}/j9/NOKIA.j9"/>
+        <property name="manifest.build.file" location="${build.dir}/manifest.mf"/>
+        <condition property="nokia.icon.invalid">
+            <or>
+                <contains string="${nokiaS80.application.icon}" substring="$${"/>
+                <equals arg1="${nokiaS80.application.icon}" arg2="" trim="true"/>
+            </or>
+        </condition>
+        <property name="deployment.dir" location="${dist.dir}"/>
+        <patternset id="deployment.patternset">
+            <include name="${dist.jar}"/>
+        </patternset>
+    </target>
+    <!--init-->
+    <target name="pre-init"/>
+    <target name="post-init"/>
+    <target name="init" depends="pre-init,load-properties,basic-init,cldc-init,cdc-init,semc-init,savaje-init,sjmc-init,ojec-init,cdc-hi-init,nokiaS80-init,post-init"/>
+    <!--conditional clean-->
+    <target name="conditional-clean-init">
+        <uptodate property="no.clean.before.build" targetfile="${build.dir}/.timestamp">
+            <srcfiles dir="nbproject">
+                <include name="project.properties"/>
+                <include name="build-impl.xml"/>
+            </srcfiles>
+        </uptodate>
+    </target>
+    <target name="conditional-clean" depends="init,conditional-clean-init" unless="no.clean.before.build" description="Clean project in case its meta information has changed.">
+        <antcall target="do-clean" inheritall="true" inheritrefs="true"/>
+    </target>
+    <!--deps-jar-->
+    <target name="deps-jar" depends="conditional-clean" unless="no.deps"/>
+    <!--preprocess-->
+    <target name="pre-preprocess"/>
+    <target name="do-preprocess" unless="no.preprocess">
+        <fail unless="preprocessed.dir">Must set preprocessed.dir</fail>
+        <property name="abilities" value=""/>
+        <property name="debug.level" value="debug"/>
+        <mkdir dir="${preprocessed.dir}"/>
+        <echo message="ignore me" file="${build.dir}/.timestamp"/>
+        <nb-prep destdir="${preprocessed.dir}" preprocessfor="${config.active.name},${abilities},DebugLevel=${debug.level}" encoding="${javac.encoding}">
+            <fileset dir="${buildsystem.baton}" defaultexcludes="${filter.use.standard}" excludes="${filter.excludes.evaluated}"/>
+        </nb-prep>
+        <copy todir="${preprocessed.dir}">
+            <fileset dir="${buildsystem.baton}" defaultexcludes="${filter.use.standard}" excludes="${filter.excludes.evaluated},${build.classes.excludes}"/>
+        </copy>
+        <nb-overrideproperty name="buildsystem.baton" value="${preprocessed.dir}"/>
+    </target>
+    <target name="post-preprocess"/>
+    <target name="preprocess" depends="deps-jar,pre-preprocess,do-preprocess,post-preprocess" description="Preprocess project sources."/>
+    <!--compile-->
+    <target name="pre-compile"/>
+    <target name="do-compile">
+        <fail unless="build.classes.dir">Must set build.classes.dir</fail>
+        <mkdir dir="${build.classes.dir}"/>
+        <javac includeantruntime="false" source="${javac.source}" target="${javac.target}" deprecation="${javac.deprecation}" optimize="${javac.optimize}" debug="${javac.debug}" destdir="${build.classes.dir}" srcdir="${buildsystem.baton}" bootclasspath="${platform.bootclasspath}" encoding="${javac.encoding}">
+            <classpath>
+                <path path="${libs.classpath}"/>
+            </classpath>
+        </javac>
+        <copy todir="${build.classes.dir}">
+            <fileset dir="${buildsystem.baton}" defaultexcludes="${filter.use.standard}" excludes="${filter.excludes.evaluated},${build.classes.excludes}"/>
+        </copy>
+        <nb-overrideproperty name="buildsystem.baton" value="${build.classes.dir}"/>
+    </target>
+    <target name="extract-libs" description="Extracts all bundled libraries.">
+        <mkdir dir="${build.classes.dir}"/>
+        <nb-extract dir="${build.classes.dir}" excludeManifest="true" classpath="${libs.classpath}" excludeclasspath="${extra.classpath}"/>
+    </target>
+    <target name="post-compile"/>
+    <target name="compile" depends="preprocess,pre-compile,extract-libs,do-compile,post-compile" description="Compile project classes."/>
+    <!--compile-single-->
+    <target name="pre-compile-single"/>
+    <target name="do-compile-single">
+        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
+        <mkdir dir="${build.classes.dir}"/>
+        <javac includeantruntime="false" source="${javac.source}" target="${javac.target}" deprecation="${javac.deprecation}" optimize="${javac.optimize}" debug="${javac.debug}" srcdir="${buildsystem.baton}" destdir="${build.classes.dir}" bootclasspath="${platform.bootclasspath}" includes="${javac.includes}" encoding="${javac.encoding}">
+            <classpath>
+                <path path="${libs.classpath}"/>
+            </classpath>
+        </javac>
+    </target>
+    <target name="post-compile-single"/>
+    <target name="compile-single" depends="preprocess,pre-compile-single,do-compile-single,post-compile-single" description="Compile selected project classes."/>
+    <!--proguard-->
+    <target name="proguard-init" description="Up-to-date check before obfuscation.">
+        <property name="obfuscation.level" value="0"/>
+        <condition property="no.obfusc">
+            <or>
+                <equals arg1="${obfuscation.level}" arg2="0"/>
+                <uptodate targetfile="${obfuscator.destjar}">
+                    <srcfiles dir="${buildsystem.baton}"/>
+                </uptodate>
+            </or>
+        </condition>
+        <uptodate property="obfuscation.up-to-date" targetfile="${obfuscator.destjar}">
+            <srcfiles dir="${buildsystem.baton}"/>
+        </uptodate>
+    </target>
+    <target name="skip-obfuscation" depends="proguard-init" if="obfuscation.up-to-date">
+        <fail unless="obfuscated.classes.dir">Must set obfuscated.classes.dir</fail>
+        <nb-overrideproperty name="buildsystem.baton" value="${obfuscated.classes.dir}"/>
+    </target>
+    <target name="proguard" depends="skip-obfuscation" description="Obfuscate project classes." unless="no.obfusc">
+        <fail unless="obfuscated.classes.dir">Must set obfuscated.classes.dir</fail>
+        <fail unless="obfuscator.srcjar">Must set obfuscator.srcjar</fail>
+        <fail unless="obfuscator.destjar">Must set obfuscator.destjar</fail>
+        <property name="obfuscator.classpath" value=""/>
+        <dirname file="${obfuscator.srcjar}" property="obfuscator.srcjar.dir"/>
+        <dirname file="${obfuscator.destjar}" property="obfuscator.destjar.dir"/>
+        <mkdir dir="${obfuscator.srcjar.dir}"/>
+        <mkdir dir="${obfuscator.destjar.dir}"/>
+        <jar jarfile="${obfuscator.srcjar}" basedir="${buildsystem.baton}"/>
+        <property name="obfuscation.custom" value=""/>
+        <nb-obfuscate srcjar="${obfuscator.srcjar}" destjar="${obfuscator.destjar}" obfuscatorclasspath="${obfuscator.classpath}" classpath="${platform.bootclasspath}:${extra.classpath}" obfuscationLevel="${obfuscation.level}" extraScript="${obfuscation.custom}"/>
+        <mkdir dir="${obfuscated.classes.dir}"/>
+        <unjar src="${obfuscator.destjar}" dest="${obfuscated.classes.dir}"/>
+        <nb-overrideproperty name="buildsystem.baton" value="${obfuscated.classes.dir}"/>
+    </target>
+    <!--obfuscate-->
+    <target name="pre-obfuscate"/>
+    <target name="post-obfuscate"/>
+    <target name="obfuscate" depends="compile,pre-obfuscate,proguard,post-obfuscate" description="Obfuscate project classes."/>
+    <!--lwuit-build-->
+    <import file="lwuit.xml" optional="true"/>
+    <target name="-lwuit-check">
+        <condition property="lwuit.allowed">
+            <and>
+                <available file="nbproject/lwuit.xml"/>
+                <isset property="is.mesdk_lwuit"/>
+            </and>
+        </condition>
+    </target>
+    <target name="-pre-lwuit-build" depends="-lwuit-check" if="lwuit.allowed"/>
+    <target name="-lwuit-build" depends="-lwuit-check" if="lwuit.allowed">
+        <antcall target="lwuit_build"/>
+    </target>
+    <target name="-post-lwuit-build" depends="-lwuit-check" if="lwuit.allowed"/>
+    <target name="lwuit-build" depends="-lwuit-check,-pre-lwuit-build, -lwuit-build, -post-lwuit-build" if="lwuit.allowed"/>
+    <!--preverify-->
+    <target name="pre-preverify"/>
+    <target name="do-preverify" if="cldc-platform.trigger">
+        <fail unless="preverify.classes.dir">Must set preverify.classes.dir</fail>
+        <mkdir dir="${preverify.sources.dir}"/>
+        <copy todir="${preverify.sources.dir}">
+            <fileset dir="${buildsystem.baton}" includes="**/*.class"/>
+        </copy>
+        <mkdir dir="${preverify.classes.dir}"/>
+        <nb-preverify srcdir="${preverify.sources.dir}" destdir="${preverify.classes.dir}" classpath="${platform.bootclasspath}:${extra.classpath}" configuration="${platform.configuration}" platformhome="${platform.home}" platformtype="${platform.type}" commandline="${platform.preverifycommandline}"/>
+        <copy todir="${preverify.classes.dir}">
+            <fileset dir="${buildsystem.baton}" defaultexcludes="${filter.use.standard}" excludes="${filter.excludes.evaluated},${build.classes.excludes}"/>
+        </copy>
+        <nb-overrideproperty name="buildsystem.baton" value="${preverify.classes.dir}"/>
+    </target>
+    <target name="post-preverify"/>
+    <target name="preverify" depends="obfuscate,lwuit-build,pre-preverify,do-preverify,post-preverify" description="Preverify project classes."/>
+    <!--set-password-->
+    <target name="set-password-init">
+        <property name="sign.enabled" value="false"/>
+        <condition property="skip-sign-keystore-password-input">
+            <or>
+                <isfalse value="${sign.enabled}"/>
+                <and>
+                    <isset property="sign.keystore"/>
+                    <isset property="sign.keystore.password"/>
+                    <not>
+                        <equals arg1="${sign.keystore}" arg2="" trim="true"/>
+                    </not>
+                    <not>
+                        <equals arg1="${sign.keystore.password}" arg2="" trim="true"/>
+                    </not>
+                </and>
+            </or>
+        </condition>
+        <condition property="skip-sign-alias-password-input">
+            <or>
+                <isfalse value="${sign.enabled}"/>
+                <and>
+                    <isset property="sign.keystore"/>
+                    <isset property="sign.alias"/>
+                    <isset property="sign.alias.password"/>
+                    <not>
+                        <equals arg1="${sign.keystore}" arg2="" trim="true"/>
+                    </not>
+                    <not>
+                        <equals arg1="${sign.alias}" arg2="" trim="true"/>
+                    </not>
+                    <not>
+                        <equals arg1="${sign.alias.password}" arg2="" trim="true"/>
+                    </not>
+                </and>
+            </or>
+        </condition>
+    </target>
+    <target name="set-keystore-password" if="netbeans.home" unless="skip-sign-keystore-password-input">
+        <nb-enter-password keystore="${sign.keystore}" passwordproperty="sign.keystore.password"/>
+    </target>
+    <target name="set-alias-password" if="netbeans.home" unless="skip-sign-alias-password-input">
+        <nb-enter-password keystore="${sign.keystore}" keyalias="${sign.alias}" passwordproperty="sign.alias.password"/>
+    </target>
+    <target name="set-password" depends="set-password-init,set-keystore-password,set-alias-password"/>
+    <!--create JAD-->
+    <target name="add-configuration" unless="contains.manifest.configuration">
+        <nb-output file="${dist.dir}/${dist.jad}" encoding="UTF-8" append="true">MicroEdition-Configuration: ${platform.configuration}
+</nb-output>
+        <nb-output file="${manifest.build.file}" encoding="UTF-8" append="true">MicroEdition-Configuration: ${platform.configuration}
+</nb-output>
+    </target>
+    <target name="add-profile" unless="contains.manifest.profile">
+        <nb-output file="${dist.dir}/${dist.jad}" encoding="UTF-8" append="true">MicroEdition-Profile: ${platform.profile}
+</nb-output>
+        <nb-output file="${manifest.build.file}" encoding="UTF-8" append="true">MicroEdition-Profile: ${platform.profile}
+</nb-output>
+    </target>
+    <target name="create-jad" if="cldc-platform.trigger">
+        <fail unless="dist.jad">Must set dist.jad</fail>
+        <mkdir dir="${build.dir}"/>
+        <dirname file="${dist.dir}/${dist.jad}" property="dist.jad.dir"/>
+        <mkdir dir="${dist.jad.dir}"/>
+        <condition property="evaluated.manifest.apipermissions" value="${manifest.apipermissions}">
+            <not>
+                <equals arg1="${platform.profile}" arg2="MIDP-1.0"/>
+            </not>
+        </condition>
+        <condition property="evaluated.manifest.pushregistry" value="${manifest.pushregistry}">
+            <not>
+                <equals arg1="${platform.profile}" arg2="MIDP-1.0"/>
+            </not>
+        </condition>
+        <condition property="contains.manifest.configuration">
+            <contains substring="MicroEdition-Configuration: " string="${manifest.others}"/>
+        </condition>
+        <condition property="contains.manifest.profile">
+            <contains substring="MicroEdition-Profile: " string="${manifest.others}"/>
+        </condition>
+        <property value="" name="evaluated.manifest.apipermissions"/>
+        <property value="" name="evaluated.manifest.pushregistry"/>
+        <property name="manifest.jad" value=""/>
+        <property name="manifest.manifest" value=""/>
+        <nb-output file="${dist.dir}/${dist.jad}" encoding="UTF-8">${manifest.midlets}${evaluated.manifest.apipermissions}${evaluated.manifest.pushregistry}${manifest.others}${manifest.jad}</nb-output>
+        <nb-output file="${manifest.build.file}" encoding="UTF-8">${manifest.midlets}${evaluated.manifest.apipermissions}${evaluated.manifest.pushregistry}${manifest.others}${manifest.manifest}</nb-output>
+        <antcall target="add-configuration" inheritall="true" inheritrefs="true"/>
+        <antcall target="add-profile" inheritall="true" inheritrefs="true"/>
+        <property name="manifest.available" value="true"/>
+    </target>
+    <!--do-extra-libs-->
+    <target name="do-extra-libs" if="extra.classpath">
+        <property name="dist.lib.dir" value="${dist.dir}/lib"/>
+        <mkdir dir="${dist.lib.dir}"/>
+        <copy todir="${dist.lib.dir}">
+            <path path="${extra.classpath}"/>
+            <flattenmapper/>
+        </copy>
+    </target>
+    <!--nokiaS80-manifest-->
+    <target name="nokiaS80-prepare-j9" if="nokiaS80-platform.trigger">
+        <fail message="Main class is not set!">
+            <condition>
+                <equals arg1="${main.class}" arg2="" trim="true"/>
+            </condition>
+        </fail>
+        <mkdir dir="${build.dir}/j9"/>
+        <taskdef name="j9builder" classname="org.netbeans.modules.j2me.cdc.project.J9Builder" classpath="${libs.cdc-ant-utils.classpath}"/>
+        <j9builder jvmargs="${run.jvmargs}" mainclass="${main.class}" args="${application.args}" home="${platform.home}" dist="${j9.dist}" id="NOKIA" platform="${platform.type}" xlet="${main.class.xlet}" applet="${main.class.applet}" jarname="${dist.jar}"/>
+        <copy file="${manifest.file}" tofile="${manifest.build.file}" failonerror="false"/>
+        <property name="manifest.available" value="true"/>
+        <loadfile property="nokia.manifest.j9" srcFile="${j9.dist}"/>
+    </target>
+    <target name="nokiaS80-prepare-manifest" depends="nokiaS80-prepare-j9" if="nokiaS80-platform.trigger" unless="nokia.icon.invalid">
+        <pathconvert property="logo.icon.name" pathsep=" ">
+            <path path="${nokiaS80.application.icon}"/>
+            <chainedmapper>
+                <flattenmapper/>
+                <globmapper from="*" to="*"/>
+            </chainedmapper>
+        </pathconvert>
+        <copy file="${nokiaS80.application.icon}" todir="${buildsystem.baton}"/>
+        <manifest file="${manifest.build.file}" mode="update">
+            <attribute name="Main-Class" value="${main.class}"/>
+            <attribute name="PproApp-Name" value="${application.name}"/>
+            <attribute name="PproApp-Vendor" value="${application.vendor}"/>
+            <attribute name="PproApp-Version" value="${deployment.number}"/>
+            <attribute name="PproApp-Icon" value="${logo.icon.name}"/>
+            <attribute name="x-ibm-pp-j9" value="${nokia.manifest.j9}"/>
+        </manifest>
+    </target>
+    <target name="nokiaS80-prepare-manifest-no-icon" depends="nokiaS80-prepare-j9" if="nokia.icon.invalid">
+        <manifest file="${manifest.build.file}" mode="update">
+            <attribute name="Main-Class" value="${main.class}"/>
+            <attribute name="PproApp-Name" value="${application.name}"/>
+            <attribute name="PproApp-Vendor" value="${application.vendor}"/>
+            <attribute name="PproApp-Version" value="${deployment.number}"/>
+            <attribute name="x-ibm-pp-j9" value="${nokia.manifest.j9}"/>
+        </manifest>
+    </target>
+    <target name="nokiaS80-create-manifest" depends="nokiaS80-prepare-j9,nokiaS80-prepare-manifest,nokiaS80-prepare-manifest-no-icon" if="nokiaS80-platform.trigger"/>
+    <!--jad-jsr211-properties-->
+    <target name="jad-jsr211-properties.check">
+        <condition property="jad-jsr211-properties.allowed">
+            <and>
+                <isset property="cldc-platform.trigger"/>
+                <isset property="netbeans.home"/>
+                <isset property="is.mesdk_jsr211"/>
+            </and>
+        </condition>
+    </target>
+    <target name="jad-jsr211-properties" description="Updates JAD and manifest with JSR211 properties." depends="jad-jsr211-properties.check" if="jad-jsr211-properties.allowed">
+        <jadjsr211properties jadfile="${dist.dir}/${dist.jad}" manifestfile="${build.dir}/${manifest.file}"/>
+    </target>
+    <!--semc-build-j9-->
+    <target name="semc-build-j9" if="semc-platform.trigger">
+        <epocpathsetter home="${platform.home}"/>
+        <property name="semc.application.caps" value=""/>
+        <mkdir dir="${platform.home}/epoc32/winscw/c/private/${semc.application.uid}"/>
+        <mkdir dir="${build.dir}/j9"/>
+        <fail message="Main class is not set!">
+            <condition>
+                <equals arg1="${main.class}" arg2="" trim="true"/>
+            </condition>
+        </fail>
+        <j9builder jvmargs="${run.jvmargs}" mainclass="${main.class}" args="${application.args}" home="${platform.home}" dist="${j9.dist}" id="${semc.application.uid}" platform="${platform.type}" xlet="${main.class.xlet}" applet="${main.class.applet}" jarname="${dist.jar}"/>
+    </target>
+    <!--do-jar-->
+    <target name="do-jar" if="manifest.available">
+        <dirname file="${dist.dir}/${dist.jar}" property="dist.jar.dir"/>
+        <mkdir dir="${dist.jar.dir}"/>
+        <property name="manifest.build.file" location="${manifest.file}"/>
+        <jar compress="${jar.compress}" jarfile="${dist.dir}/${dist.jar}" manifest="${manifest.build.file}" manifestencoding="UTF-8">
+            <fileset dir="${buildsystem.baton}"/>
+        </jar>
+    </target>
+    <!--do-jar-no-manifest-->
+    <target name="do-jar-no-manifest" unless="manifest.available">
+        <dirname file="${dist.dir}/${dist.jar}" property="dist.jar.dir"/>
+        <mkdir dir="${dist.jar.dir}"/>
+        <jar compress="${jar.compress}" jarfile="${dist.dir}/${dist.jar}">
+            <fileset dir="${buildsystem.baton}"/>
+        </jar>
+    </target>
+    <!--update-jad-->
+    <target name="update-jad" if="cldc-platform.trigger">
+        <nb-jad jadfile="${dist.dir}/${dist.jad}" jarfile="${dist.dir}/${dist.jar}" url="${dist.jar}" sign="${sign.enabled}" keystore="${sign.keystore}" keystorepassword="${sign.keystore.password}" alias="${sign.alias}" aliaspassword="${sign.alias.password}" encoding="UTF-8"/>
+    </target>
+    <target name="sign-jar" if="sign.jar.trigger">
+        <signjar jar="${dist.dir}/${dist.jar}" alias="${sign.alias}" keystore="${sign.keystore}" storepass="${sign.keystore.password}" keypass="${sign.alias.password}"/>
+    </target>
+    <!--savaje-build-jnlp-->
+    <target name="savaje-prepare-icon" if="savaje-platform.trigger" unless="savaje.icon.invalid">
+        <pathconvert property="savaje.application.icon.name" pathsep=" ">
+            <path path="${savaje.application.icon}"/>
+            <chainedmapper>
+                <flattenmapper/>
+                <globmapper from="*" to="*"/>
+            </chainedmapper>
+        </pathconvert>
+        <mkdir dir="${dist.dir}/lib"/>
+        <copy tofile="${dist.dir}/lib/${savaje.application.icon.name}" file="${savaje.application.icon}" overwrite="true" failonerror="false"/>
+    </target>
+    <target name="savaje-build-jnlp" depends="savaje-prepare-icon" if="savaje-platform.trigger">
+        <mkdir dir="${build.dir}/jnlp/"/>
+        <taskdef resource="org/netbeans/modules/j2me/cdc/project/savaje/defs.properties">
+            <classpath>
+                <pathelement path="${libs.savaje-ant-utils.classpath}"/>
+            </classpath>
+        </taskdef>
+        <jnlp dir="${build.dir}/jnlp/" file="bundle.jnlp" codebase="WTK_AGUI" distjar="lib/${dist.jar.name}" applicationicon="lib/${savaje.application.icon.name}" smallicon="${savaje.application.icon.small}" focusedicon="${savaje.application.icon.focused}" applicationtitle="${application.name}" applicationvendor="${application.vendor}" applicationDescription="${application.description}" applicationArgs="${application.args}" mainClass="${main.class}" debug="${savaje.bundle.debug}" debugport="${savaje.bundle.debug.port}">
+            <fileset dir="${dist.dir}/lib"/>
+        </jnlp>
+        <policy file="${build.dir}/jnlp/bundle.policy" codebase="WTK_AGUI"/>
+        <copy tofile="${dist.dir}/lib/classes.jar" file="${dist.dir}/${dist.jar}" overwrite="true"/>
+        <copy todir="${dist.dir}" file="${build.dir}/jnlp/bundle.jnlp" overwrite="true"/>
+        <copy tofile="${dist.dir}/bundle.policy" file="${build.dir}/jnlp/bundle.policy" overwrite="true"/>
+        <copy todir="${dist.dir}/lib" overwrite="true" failonerror="false">
+            <fileset dir="${resources.dir}"/>
+        </copy>
+    </target>
+    <!--jar-->
+    <target name="pre-jar"/>
+    <target name="post-jar"/>
+    <target name="jar" depends="preverify,pre-jar,set-password,create-jad,do-extra-libs,nokiaS80-create-manifest,jad-jsr211-properties,semc-build-j9,do-jar,do-jar-no-manifest,update-jad,sign-jar,savaje-build-jnlp,post-jar" description="Build jar and application descriptor."/>
+    <!--override-jad-->
+    <target name="override-jad" if="override.jarurl.trigger">
+        <property name="deployment.jarurl" value="${dist.jar}"/>
+        <nb-jad jadfile="${dist.dir}/${dist.jad}" jarfile="${dist.dir}/${dist.jar}" url="${deployment.jarurl}" sign="${sign.enabled}" keystore="${sign.keystore}" keystorepassword="${sign.keystore.password}" alias="${sign.alias}" aliaspassword="${sign.alias.password}" encoding="UTF-8"/>
+    </target>
+    <!--semc-make-sis-->
+    <target name="-semc-sis-init" if="semc-platform.trigger" description="Init necessary properties for SEMC platform">
+        <property name="pprolauncher.dir" value="${platform.home}/epoc32/tools/ppro-custom-launcher/output/arm/PProLauncher${semc.application.uid}"/>
+    </target>
+    <target name="semc-ppro-arm" if="semc-platform.trigger" description="Builds neccessary files for semc device">
+        <exec executable="${platform.home}/epoc32/tools/create-ppro-app.bat" dir="${platform.home}/epoc32/tools/">
+            <arg value="arm"/>
+            <arg value="${application.name}"/>
+            <arg value="${semc.application.uid}"/>
+            <arg value="${j9.dist}"/>
+            <arg value="${semc.application.caps}"/>
+            <env key="SDKDRIVE" value="${sdkdrive}"/>
+            <env key="EPOCROOT" value="${epocroot}"/>
+            <env key="Path" value="${epocpath}"/>
+        </exec>
+    </target>
+    <target name="semc-make-sis-icon" if="semc-platform.trigger" unless="semc.icon.invalid">
+        <copy file="${semc.application.icon}" tofile="${pprolauncher.dir}/${semc.application.uid}.mbm" failonerror="false"/>
+    </target>
+    <target name="semc-make-sis" depends="semc-ppro-arm,semc-make-sis-icon" if="semc-platform.trigger" unless="no.application.uid" description="Builds SIS file for device">
+        <property name="dll.dir" location="dll"/>
+        <mkdir dir="${dll.dir}"/>
+        <copy todir="${pprolauncher.dir}">
+            <fileset dir="${dist.dir}">
+                <exclude name="javadoc/**"/>
+            </fileset>
+        </copy>
+        <copy todir="${pprolauncher.dir}">
+            <fileset dir="${dll.dir}">
+                <include name="**/*.dll"/>
+            </fileset>
+        </copy>
+        <copy todir="${pprolauncher.dir}" failonerror="false">
+            <fileset dir="${resources.dir}"/>
+        </copy>
+        <pkgmake workdir="${pprolauncher.dir}" id="${semc.application.uid}" appname="${application.name}" appicon="${semc.application.uid}.mbm" vendor="${application.vendor}" version="${deployment.number}" logo="${logo.image}" logoinstallonly="${logo.image.installonly}">
+            <fileset dir="${dist.dir}">
+                <exclude name="javadoc/**"/>
+            </fileset>
+            <fileset dir="${dll.dir}">
+                <include name="**/*.dll"/>
+            </fileset>
+            <fileset dir="${resources.dir}"/>
+        </pkgmake>
+        <exec executable="${platform.home}/epoc32/tools/makesis" dir="${pprolauncher.dir}">
+            <arg value="-d${pprolauncher.dir}"/>
+            <arg value="PProLauncher${semc.application.uid}.pkg"/>
+            <arg value="${application.name}.sis"/>
+            <env key="SDKDRIVE" value="${sdkdrive}"/>
+            <env key="EPOCROOT" value="${epocroot}"/>
+            <env key="Path" value="${epocpath}"/>
+        </exec>
+        <copy todir="${dist.dir}">
+            <fileset dir="${pprolauncher.dir}">
+                <include name="**/*.SIS"/>
+                <include name="**/*.sis"/>
+            </fileset>
+        </copy>
+    </target>
+    <target name="semc-sign-sis" if="semc-platform.trigger" depends="semc-make-sis" unless="no.certificateorkey" description="Sign SIS file">
+        <exec executable="${platform.home}/epoc32/tools/signsis" dir="${pprolauncher.dir}">
+            <arg value="-s"/>
+            <arg value="${pprolauncher.dir}/${application.name}.sis"/>
+            <arg value="${pprolauncher.dir}/${application.name}-SIGNED.sis"/>
+            <arg value="${semc.certificate.path}"/>
+            <arg value="${semc.private.key.path}"/>
+            <arg value="${semc.private.key.password}"/>
+            <env key="SDKDRIVE" value="${sdkdrive}"/>
+            <env key="EPOCROOT" value="${epocroot}"/>
+            <env key="Path" value="${epocpath}"/>
+        </exec>
+        <copy todir="${dist.dir}">
+            <fileset dir="${pprolauncher.dir}">
+                <include name="**/*.SIS"/>
+                <include name="**/*.sis"/>
+            </fileset>
+        </copy>
+    </target>
+    <target name="semc-no-sign-sis" depends="semc-make-sis" if="no.certificateorkey" unless="no.application.uid" description="Prints out only info when SIS is not signed ">
+        <echo message="Signed SIS was not created! Set up path to certificate and private key in project properties!"/>
+    </target>
+    <target name="-pre-semc-sis" if="semc-platform.trigger" description="Customizable target called before SIS file is built"/>
+    <target name="semc-sis" if="semc-platform.trigger" depends="-semc-sis-init, -pre-semc-sis, semc-sign-sis,semc-no-sign-sis, -post-semc-sis" unless="no.application.uid"/>
+    <target name="-post-semc-sis" if="semc-platform.trigger" description="Customizable target called after SIS file is built"/>
+    <!--increment-app-version-->
+    <target name="increment-app-version" if="app-version.autoincrement.trigger">
+        <propertyfile file="nbproject/private/private.properties">
+            <entry key="deployment.counter" type="int" operation="+" default="2" pattern="0"/>
+            <entry key="deployment.number" value="000000${deployment.counter}"/>
+        </propertyfile>
+        <property name="deployment.number.pattern" value="\2\3.\5\6.\8\9"/>
+        <replaceregexp byline="true" file="nbproject/private/private.properties" match="^deployment.number=[0-9]*(0|([1-9]))([0-9])(0|([1-9]))([0-9])(0|([1-9]))([0-9])$" replace="deployment.number=${deployment.number.pattern}"/>
+    </target>
+    <!--build-->
+    <target name="pre-build"/>
+    <target name="post-build"/>
+    <target name="build" depends="jar,pre-build,override-jad,semc-sis,increment-app-version,post-build" description="Builds final distribution of the application."/>
+    <!--open-netmon-->
+    <target name="netmon.check">
+        <condition property="netmon.allowed">
+            <and>
+                <not>
+                    <isset property="bdj-platform.trigger"/>
+                </not>
+                <isset property="netbeans.home"/>
+                <isset property="is.mesdk_netmon"/>
+            </and>
+        </condition>
+    </target>
+    <target name="open-netmon" description="Open network monitor" depends="netmon.check" if="netmon.allowed">
+        <opennetmon device="${platform.device}"/>
+    </target>
+    <!--cldc-run-->
+    <target name="cldc-run" if="cldc-platform.trigger">
+        <nb-run jadfile="${dist.dir}/${dist.jad}" jarfile="${dist.dir}/${dist.jar}" jadurl="${dist.jad.url}" device="${platform.device}" platformhome="${platform.home}" platformtype="${platform.type}" execmethod="${run.method}" securitydomain="${evaluated.run.security.domain}" commandline="${platform.runcommandline}" classpath="${platform.bootclasspath}:${dist.dir}/${dist.jar}" cmdoptions="${run.cmd.options}"/>
+    </target>
+    <!--semc-run-and-debug-prepare-targets-->
+    <target name="semc-icon-assembly" if="semc-platform.trigger" unless="semc.icon.invalid">
+        <copy file="${semc.application.icon}" tofile="${platform.home}/epoc32/release/winscw/udeb/z/Resource/Apps/${semc.application.uid}.mbm" failonerror="false"/>
+        <iconassembly home="${platform.home}" uid="${semc.application.uid}" count="${application.icon.count}"/>
+    </target>
+    <target name="semc-ppro-emulator" if="semc-platform.trigger" description="Builds neccessary files for semc emulator">
+        <exec executable="${platform.home}/epoc32/tools/create-ppro-app.bat" dir="${platform.home}/epoc32/tools/">
+            <arg value="win32"/>
+            <arg value="${application.name}"/>
+            <arg value="${semc.application.uid}"/>
+            <arg value="${j9.dist}"/>
+            <arg value="${semc.application.caps}"/>
+            <env key="SDKDRIVE" value="${sdkdrive}"/>
+            <env key="EPOCROOT" value="${epocroot}"/>
+            <env key="Path" value="${epocpath}"/>
+        </exec>
+    </target>
+    <target name="semc-do-run" if="semc-platform.trigger" description="Prepare log folders, copy necessary files">
+        <copy todir="${platform.home}/epoc32/winscw/C/private/${semc.application.uid}">
+            <fileset dir="${dist.dir}">
+                <exclude name="javadoc/**"/>
+            </fileset>
+        </copy>
+        <mkdir dir="${platform.home}/epoc32/winscw/c/logs/j9vm"/>
+        <epocinipath file="${platform.home}/epoc32/data/epoc.ini"/>
+        <exec executable="${platform.home}/epoc32/release/winscw/udeb/epoc.exe">
+            <env key="SDKDRIVE" value="${sdkdrive}"/>
+            <env key="EPOCROOT" value="${epocroot}"/>
+            <env key="Path" value="${epocpath}"/>
+        </exec>
+    </target>
+    <!--semc-run-->
+    <target name="semc-run" depends="semc-icon-assembly,semc-ppro-emulator,semc-do-run" if="semc-platform.trigger"/>
+    <!--savaje-run-->
+    <target name="savaje-run" if="savaje-platform.trigger">
+        <sunEmulatorExec home="${platform.home}" mainclass="${main.class}" args="${application.args}" jvmargs="${run.cmd.options}" device="${platform.device}" profile="${platform.profile}" xlet="${main.class.xlet}" applet="${main.class.applet}">
+            <fileset dir="${dist.dir}">
+                <exclude name="javadoc/**"/>
+            </fileset>
+        </sunEmulatorExec>
+    </target>
+    <!--sjmc-run-->
+    <target name="sjmc-run" if="sjmc-platform.trigger">
+        <taskdef name="sjmcEmulatorExec" classname="org.netbeans.modules.j2me.cdc.project.sjmc.SJMCToolkitEmulatorExecTask" classpath="${libs.sjmc-ant-utils.classpath}"/>
+        <sjmcEmulatorExec home="${platform.home}" mainclass="${main.class}" args="${application.args}" jvmargs="${run.cmd.options}" device="${platform.device}" profile="${platform.profile}" xlet="${main.class.xlet}" applet="${main.class.applet}">
+            <fileset dir="${dist.dir}">
+                <exclude name="javadoc/**"/>
+            </fileset>
+        </sjmcEmulatorExec>
+    </target>
+    <!--ojec-run-->
+    <target name="ojec-run" if="ojec-platform.trigger">
+        <taskdef name="ojecEmulatorExec" classname="org.netbeans.modules.j2me.cdc.project.ojec.OJECToolkitEmulatorExecTask" classpath="${libs.ojec-ant-utils.classpath}"/>
+        <ojecEmulatorExec home="${platform.home}" mainclass="${main.class}" args="${application.args}" jvmargs="${run.cmd.options}" device="${platform.device}" profile="${platform.profile}" xlet="${main.class.xlet}" applet="${main.class.applet}">
+            <fileset dir="${dist.dir}">
+                <exclude name="javadoc/**"/>
+            </fileset>
+        </ojecEmulatorExec>
+    </target>
+    <!--nokiaS80-run-->
+    <target name="nokiaS80-run" if="nokiaS80-platform.trigger">
+        <mkdir dir="${platform.home}/epoc32/wins/c/PP_Applications"/>
+        <mkdir dir="${platform.home}/epoc32/wins/c/logs/j9vm"/>
+        <taskdef name="nokiaexec" classname="org.netbeans.modules.j2me.cdc.project.nokiaS80.NokiaEmulatorExecTask" classpath="${libs.nokiaS80-ant-utils.classpath}"/>
+        <nokiaexec jvmargs="${run.jvmargs}" mainclass="${main.class}" args="${application.args}" home="${platform.home}" device="${platform.device}" xlet="${main.class.xlet}" applet="${main.class.applet}">
+            <fileset dir="${dist.dir}">
+                <exclude name="javadoc/**"/>
+            </fileset>
+        </nokiaexec>
+    </target>
+    <!--cdc-hi-run-->
+    <target name="-pre-cdc-hi-run" if="cdc-hi-platform.trigger"/>
+    <target name="-cdc-hi-run" if="cdc-hi-platform.trigger">
+        <fail message="Main class is not set!">
+            <condition>
+                <equals arg1="${main.class}" arg2=""/>
+            </condition>
+        </fail>
+        <exec executable="${platform.home}/bin/emulator">
+            <arg value="-cp"/>
+            <arg value="${basedir}/${dist.dir}/${dist.jar}"/>
+            <arg value="-Xdevice:${platform.device}"/>
+            <arg value="${run.cmd.options}"/>
+            <arg value="-Xmain:${main.class}"/>
+            <arg value="${application.args}"/>
+        </exec>
+    </target>
+    <target name="-post-cdc-hi-run" if="cdc-hi-platform.trigger"/>
+    <target name="cdc-hi-run" if="cdc-hi-platform.trigger" depends="-pre-cdc-hi-run, -cdc-hi-run, -post-cdc-hi-run"/>
+    <!--open-profiler-->
+    <target name="profiler.check">
+        <condition property="profiler.allowed">
+            <and>
+                <not>
+                    <isset property="bdj-platform.trigger"/>
+                </not>
+                <isset property="netbeans.home"/>
+                <isset property="is.mesdk_profiler"/>
+            </and>
+        </condition>
+    </target>
+    <target name="open-profiler" description="Open profiler snapshot" depends="profiler.check" if="profiler.allowed">
+        <openprofiler device="${platform.device}"/>
+    </target>
+    <!--run-->
+    <target name="pre-run"/>
+    <target name="run" depends="jar,pre-run,open-netmon,cldc-run,semc-run,savaje-run,sjmc-run,ojec-run,nokiaS80-run,cdc-hi-run,open-profiler" description="Run MIDlet suite."/>
+    <target name="run-no-build" depends="init,pre-run,open-netmon,cldc-run,semc-run,savaje-run,sjmc-run,ojec-run,nokiaS80-run,cdc-hi-run,open-profiler" description="Quick Run already built MIDlet suite."/>
+    <!--cldc-debug-->
+    <target name="cldc-debug" if="cldc-platform.trigger">
+        <parallel>
+            <nb-run debug="true" debugsuspend="true" debugserver="true" debuggeraddressproperty="jpda.port" platformtype="${platform.type}" platformhome="${platform.home}" device="${platform.device}" jadfile="${dist.dir}/${dist.jad}" jadurl="${dist.jad.url}" jarfile="${dist.dir}/${dist.jar}" execmethod="${run.method}" securitydomain="${evaluated.run.security.domain}" commandline="${platform.debugcommandline}" classpath="${platform.bootclasspath}:${dist.dir}/${dist.jar}" cmdoptions="${run.cmd.options}"/>
+            <sequential>
+                <sleep seconds="5"/>
+                <antcall target="nbdebug"/>
+            </sequential>
+        </parallel>
+    </target>
+    <!--semc-debug-->
+    <!--semc-build-j9-debug-->
+    <target name="semc-build-j9-debug" if="semc-platform.trigger">
+        <fail message="Main class is not set!">
+            <condition>
+                <equals arg1="${main.class}" arg2=""/>
+            </condition>
+        </fail>
+        <j9builder jvmargs="${run.jvmargs} -Xrunjdwp:server=n,address=${jpda.port}" mainclass="${main.class}" args="${application.args}" platform="${platform.type}" home="${platform.home}" dist="${j9.dist}" id="${semc.application.uid}" xlet="${main.class.xlet}" applet="${main.class.applet}" jarname="${dist.jar}"/>
+    </target>
+    <target name="semc-debug-start" if="semc-platform.trigger">
+        <nbjpdastart transport="dt_socket" addressproperty="jpda.port" name="${main.class}">
+            <classpath>
+                <path path="${build.classes.dir}"/>
+            </classpath>
+            <bootclasspath>
+                <path path="${platform.bootclasspath}"/>
+            </bootclasspath>
+        </nbjpdastart>
+    </target>
+    <target name="semc-debug" depends="semc-debug-start,semc-build-j9-debug,semc-icon-assembly,semc-ppro-emulator,semc-do-run" if="semc-platform.trigger"/>
+    <!--savaje-debug-->
+    <target name="savaje-debug" if="savaje-platform.trigger">
+        <parallel>
+            <sunEmulatorExec home="${platform.home}" mainclass="${main.class}" args="${application.args}" jvmargs="${run.cmd.options}" device="${platform.device}" profile="${platform.profile}" xlet="${main.class.xlet}" applet="${main.class.applet}" debug="true" debuggeraddressproperty="jpda.port">
+                <fileset dir="${dist.dir}">
+                    <exclude name="javadoc/**"/>
+                </fileset>
+            </sunEmulatorExec>
+            <sequential>
+                <sleep seconds="5"/>
+                <antcall target="nbdebug"/>
+            </sequential>
+        </parallel>
+    </target>
+    <!--sjmc-debug-->
+    <target name="sjmc-debug" if="sjmc-platform.trigger">
+        <taskdef name="sjmcEmulatorExec" classname="org.netbeans.modules.j2me.cdc.project.sjmc.SJMCToolkitEmulatorExecTask" classpath="${libs.sjmc-ant-utils.classpath}"/>
+        <parallel>
+            <sjmcEmulatorExec home="${platform.home}" mainclass="${main.class}" args="${application.args}" jvmargs="${run.cmd.options}" device="${platform.device}" profile="${platform.profile}" xlet="${main.class.xlet}" applet="${main.class.applet}" debug="true" debuggeraddressproperty="jpda.port">
+                <fileset dir="${dist.dir}">
+                    <exclude name="javadoc/**"/>
+                </fileset>
+            </sjmcEmulatorExec>
+            <sequential>
+                <sleep seconds="1"/>
+                <antcall target="nbdebug"/>
+            </sequential>
+        </parallel>
+    </target>
+    <!--ojec-debug-->
+    <target name="ojec-debug" if="ojec-platform.trigger">
+        <taskdef name="ojecEmulatorExec" classname="org.netbeans.modules.j2me.cdc.project.ojec.OJECToolkitEmulatorExecTask" classpath="${libs.ojec-ant-utils.classpath}"/>
+        <parallel>
+            <ojecEmulatorExec home="${platform.home}" mainclass="${main.class}" args="${application.args}" jvmargs="${run.cmd.options}" device="${platform.device}" profile="${platform.profile}" xlet="${main.class.xlet}" applet="${main.class.applet}" debug="true" debuggeraddressproperty="jpda.port">
+                <fileset dir="${dist.dir}">
+                    <exclude name="javadoc/**"/>
+                </fileset>
+            </ojecEmulatorExec>
+            <sequential>
+                <sleep seconds="1"/>
+                <antcall target="nbdebug"/>
+            </sequential>
+        </parallel>
+    </target>
+    <!--cdc-hi-debug-->
+    <target name="-pre-cdc-hi-debug" if="cdc-hi-platform.trigger"/>
+    <target name="-cdc-hi-debug" if="cdc-hi-platform.trigger">
+        <taskdef name="freePortRetriever" classname="org.netbeans.modules.j2me.cdc.project.savaje.FreePortRetriever" classpath="${libs.savaje-ant-utils.classpath}"/>
+        <freePortRetriever debuggerPortProperty="active.debug.port"/>
+        <parallel>
+            <exec executable="${platform.home}/bin/emulator">
+                <arg value="-cp"/>
+                <arg value="${basedir}/${dist.dir}/${dist.jar}"/>
+                <arg value="-Xdevice:${platform.device}"/>
+                <arg value="-Xmain:${main.class}"/>
+                <arg value="-Xrunjdwp:transport=dt_socket,address=${active.debug.port},server=y,suspend=y"/>
+                <arg value="-Xdebug"/>
+            </exec>
+            <sequential>
+                <property name="debug.delay" value="500"/>
+                <nb-mobility-debug address="${active.debug.port}" name="${app.codename}" delay="${debug.delay}" timeout="${debug.timeout}" period="2000"/>
+            </sequential>
+        </parallel>
+    </target>
+    <target name="-post-cdc-hi-debug" if="cdc-hi-platform.trigger"/>
+    <target name="cdc-hi-debug" if="cdc-hi-platform.trigger" depends="-pre-cdc-hi-debug, -cdc-hi-debug, -post-cdc-hi-debug"/>
+    <!--nokiaS80-debug-->
+    <target name="nokiaS80-debug" if="nokiaS80-platform.trigger">
+        <taskdef name="j9builder" classname="org.netbeans.modules.j2me.cdc.project.J9Builder" classpath="${libs.cdc-ant-utils.classpath}"/>
+        <j9builder jvmargs="${run.jvmargs} -Xrunjdwp:server=n,address=${jpda.port}" mainclass="${main.class}" args="${application.args}" platform="${platform.type}" home="${platform.home}" dist="${j9.dist}" id="NOKIA" xlet="${main.class.xlet}" applet="${main.class.applet}" jarname="${dist.jar}"/>
+        <mkdir dir="${platform.home}/epoc32/wins/c/logs/j9vm"/>
+        <taskdef name="nokiaexec" classname="org.netbeans.modules.j2me.cdc.project.nokiaS80.NokiaEmulatorExecTask" classpath="${libs.nokiaS80-ant-utils.classpath}"/>
+        <parallel>
+            <nokiaexec debug="true" debuggeraddressproperty="jpda.port" jvmargs="${run.jvmargs}" mainclass="${main.class}" args="${application.args}" home="${platform.home}" device="${platform.device}" xlet="${main.class.xlet}" applet="${main.class.applet}">
+                <fileset dir="${dist.dir}">
+                    <exclude name="javadoc/**"/>
+                </fileset>
+            </nokiaexec>
+            <sequential>
+                <sleep seconds="10"/>
+                <antcall target="nbdebug"/>
+            </sequential>
+        </parallel>
+    </target>
+    <!--debug-->
+    <target name="remove-timestamp">
+        <delete file="$/.timestamp"/>
+    </target>
+    <target name="pre-debug"/>
+    <target name="debug" description="Debug project." depends="clean,jar,remove-timestamp,pre-debug,cldc-debug,semc-debug,savaje-debug,sjmc-debug,ojec-debug,cdc-hi-debug,nokiaS80-debug"/>
+    <target name="nbdebug" description="Start NetBeans debugger" if="netbeans.home">
+        <property name="debug.delay" value="5000"/>
+        <nb-mobility-debug address="${jpda.port}" name="${app.codename}" delay="${debug.delay}" timeout="${debug.timeout}" period="2000"/>
+    </target>
+    <target name="debug-run-base" depends="cldc-debug-run,cdc-hi-debug-run"/>
+    <target name="-pre-cldc-debug-run" if="cldc-platform.trigger"/>
+    <target name="-cldc-debug-run" depends="init,jar" if="cldc-platform.trigger">
+        <echo> Starting emulator with port number ${active.debug.port} </echo>
+        <exec executable="${platform.home}/bin/emulator">
+            <arg value="-Xdescriptor:${basedir}/${dist.dir}/${dist.jad}"/>
+            <arg value="-Xdevice:${platform.device}"/>
+            <arg value="-Xdebug"/>
+            <arg value="-Xrunjdwp:transport=dt_socket,address=${active.debug.port},server=y,suspend=y"/>
+        </exec>
+    </target>
+    <target name="-post-cldc-debug-run" if="cldc-platform.trigger"/>
+    <target name="cldc-debug-run" if="cldc-platform.trigger" depends="-pre-cldc-debug-run, -cldc-debug-run, -post-cldc-debug-run"/>
+    <target name="-pre-cdc-hi-debug-run" if="cdc-hi-platform.trigger"/>
+    <target name="-cdc-hi-debug-run" depends="init,jar" if="cdc-hi-platform.trigger">
+        <fail message="Main class is not set!">
+            <condition>
+                <equals arg1="${main.class}" arg2=""/>
+            </condition>
+        </fail>
+        <echo> Starting emulator with port number ${active.debug.port} </echo>
+        <exec executable="${platform.home}/bin/emulator">
+            <arg value="-cp"/>
+            <arg value="${basedir}/${dist.dir}/${dist.jar}"/>
+            <arg value="-Xdevice:${platform.device}"/>
+            <arg value="-Xmain:${main.class}"/>
+            <arg value="-Xdebug"/>
+            <arg value="-Xrunjdwp:transport=dt_socket,address=${active.debug.port},server=y,suspend=y"/>
+        </exec>
+    </target>
+    <target name="-post-cdc-hi-debug-run" if="cdc-hi-platform.trigger"/>
+    <target name="cdc-hi-debug-run" if="cdc-hi-platform.trigger" depends="-pre-cdc-hi-debug-run, -cdc-hi-debug-run, -post-cdc-hi-debug-run"/>
+    <!--javadoc-->
+    <target name="browse-javadoc" if="netbeans.home" unless="no.javadoc.preview">
+        <nbbrowse file="${dist.javadoc.dir}/index.html"/>
+    </target>
+    <target name="javadoc" depends="preprocess">
+        <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
+        <mkdir dir="${dist.javadoc.dir}"/>
+        <copy todir="${buildsystem.baton}">
+            <fileset dir="${src.dir}" includes="**/*.html"/>
+        </copy>
+        <javadoc source="${javac.source}" destdir="${dist.javadoc.dir}" bootclasspath="${platform.bootclasspath}" notree="${javadoc.notree}" use="${javadoc.use}" nonavbar="${javadoc.nonavbar}" noindex="${javadoc.noindex}" splitindex="${javadoc.splitindex}" author="${javadoc.author}" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}" private="${javadoc.private}" encoding="${javac.encoding}" docencoding="${javac.encoding}" charset="${javac.encoding}">
+            <classpath>
+                <path path="${libs.classpath}"/>
+            </classpath>
+            <sourcepath>
+                <pathelement location="${buildsystem.baton}"/>
+            </sourcepath>
+        </javadoc>
+        <antcall target="browse-javadoc"/>
+    </target>
+    <!--clean and build-->
+    <target name="rebuild" depends="clean,build" description="Rebuild the application."/>
+    <target name="clean-timestamp">
+        <delete file="${build.dir}/.timestamp"/>
+    </target>
+    <target name="clean-preprocessed">
+        <delete dir="${preprocessed.dir}"/>
+    </target>
+    <target name="clean-classes">
+        <delete dir="${build.classes.dir}"/>
+    </target>
+    <target name="clean-obfuscated">
+        <delete file="${obfuscator.srcjar}"/>
+        <delete file="${obfuscator.destjar}"/>
+        <delete dir="${obfuscated.classes.dir}"/>
+    </target>
+    <target name="clean-preverified">
+        <delete dir="${preverify.sources.dir}"/>
+        <delete dir="${preverify.classes.dir}"/>
+    </target>
+    <target name="clean-manifest" if="manifest.build.file">
+        <delete file="${manifest.build.file}"/>
+    </target>
+    <target name="clean-jar">
+        <delete file="${dist.dir}/${dist.jar}"/>
+    </target>
+    <target name="clean-jad">
+        <delete file="${dist.dir}/${dist.jad}"/>
+    </target>
+    <target name="clean-javadoc">
+        <delete dir="${dist.javadoc.dir}"/>
+    </target>
+    <target name="clean-j9" if="j9.dist">
+        <delete file="${j9.dist}"/>
+    </target>
+    <target name="clean-semc" if="semc-platform.trigger">
+        <delete dir="${dist.dir}" includes="*.sis,*.SIS"/>
+        <delete dir="${platform.home}/epoc32/tools/ppro-custom-launcher/output/win32/PProLauncher${semc.application.uid}"/>
+        <delete dir="${platform.home}/epoc32/tools/ppro-custom-launcher/output/arm/PProLauncher${semc.application.uid}"/>
+        <delete file="${platform.home}/epoc32/release/winscw/udeb/PProLauncher${semc.application.uid}.exe"/>
+        <delete file="${platform.home}/epoc32/release/winscw/udeb/z/Resource/Apps/PProLauncher${semc.application.uid}.rsc"/>
+        <delete file="${platform.home}/epoc32/release/winscw/udeb/z/private/10003a3f/apps/PProLauncher${semc.application.uid}_reg.rsc"/>
+        <delete file="${platform.home}/epoc32/release/winscw/udeb/z/Resource/Apps/PProLauncher${semc.application.uid}_loc.R01"/>
+        <delete file="${platform.home}/epoc32/release/winscw/udeb/z/Resource/Apps/${semc.application.uid}.mbm"/>
+        <delete file="${platform.home}/epoc32/data/Z/private/10003a3f/apps/PProLauncher${semc.application.uid}_reg.rsc"/>
+        <delete file="${platform.home}/epoc32/data/Z/Resource/Apps/PProLauncher${semc.application.uid}.rsc"/>
+        <delete file="${platform.home}/epoc32/data/Z/Resource/Apps/PProLauncher${semc.application.uid}_loc.R01"/>
+        <delete dir="${platform.home}/epoc32/winscw/C/private/${semc.application.uid}"/>
+    </target>
+    <target name="clean-savaje" if="savaje-platform.trigger">
+        <delete dir="${build.dir}/jnlp"/>
+        <delete file="${dist.dir}/bundle.jnlp"/>
+        <delete file="${dist.dir}/bundle.policy"/>
+        <delete dir="${dist.dir}/lib"/>
+    </target>
+    <target name="clean-sjmc" if="sjmc-platform.trigger">
+        <delete dir="${dist.dir}/lib"/>
+    </target>
+    <target name="clean-ojec" if="ojec-platform.trigger">
+        <delete dir="${dist.dir}/lib"/>
+    </target>
+    <!--clean-->
+    <target name="pre-clean"/>
+    <target name="post-clean"/>
+    <target name="-clean-configuration">
+        <condition property="can.clean.config.completely">
+            <not>
+                <equals arg1="${config.active}" arg2="" trim="true"/>
+            </not>
+        </condition>
+    </target>
+    <target name="-clean-configuration-root" depends="-clean-configuration" if="can.clean.config.completely">
+        <delete dir="${build.dir}"/>
+        <delete dir="${dist.dir}"/>
+        <available property="dist.dir.exists" file="dist"/>
+        <condition property="dist.dir.empty">
+            <and>
+                <isset property="dist.dir.exists"/>
+                <resourcecount count="0">
+                    <fileset dir="dist"/>
+                </resourcecount>
+            </and>
+        </condition>
+    </target>
+    <target name="-clean-default-configuration-root" depends="-clean-configuration" unless="can.clean.config.completely">
+        <tempfile deleteonexit="true" property="tmp.exclude" prefix="convert"/>
+        <echo file="${tmp.exclude}">${all.configurations}</echo>
+        <replaceregexp file="${tmp.exclude}" match="(.)(,|$)" replace="\1/**\2" flags="g"/>
+        <loadfile srcfile="${tmp.exclude}" property="exclude.pattern"/>
+        <delete file="${tmp.exclude}"/>
+        <delete quiet="true">
+            <fileset dir="${build.dir}" excludes="${exclude.pattern}"/>
+        </delete>
+        <delete quiet="true">
+            <fileset dir="${dist.dir}" excludes="${exclude.pattern}"/>
+        </delete>
+        <delete quiet="true">
+            <fileset dir="${dist.dir}/lib"/>
+        </delete>
+        <available property="dist.dir.exists" file="dist"/>
+        <condition property="dist.dir.empty">
+            <and>
+                <isset property="dist.dir.exists"/>
+                <resourcecount count="0">
+                    <fileset dir="dist"/>
+                </resourcecount>
+            </and>
+        </condition>
+    </target>
+    <target name="-clean-completely" if="dist.dir.empty">
+        <delete dir="build" quiet="true"/>
+        <delete dir="dist" quiet="true"/>
+    </target>
+    <target name="do-clean" depends="pre-clean,clean-timestamp,clean-preprocessed,clean-classes,clean-obfuscated,clean-preverified,clean-manifest,clean-jar,clean-jad,clean-javadoc,clean-j9,clean-semc,clean-savaje,clean-sjmc,clean-ojec,-clean-default-configuration-root,-clean-configuration-root,-clean-completely,post-clean"/>
+    <target name="clean" depends="conditional-clean" if="no.clean.before.build" description="Clean build products.">
+        <antcall target="do-clean" inheritall="true" inheritrefs="true"/>
+    </target>
+    <!--deploy-->
+    <target name="pre-deploy"/>
+    <target name="do-deploy" if="deployment.method" unless="skip.deployment">
+        <fail unless="deployment.scriptfile">Property deployment.${deployment.method}.scriptfile not set. The property should point to an Ant script providing ${deployment.method} deployment.</fail>
+        <ant antfile="${deployment.scriptfile}" inheritall="true" inheritrefs="true"/>
+        <antcall target="post-deploy" inheritall="true" inheritrefs="true"/>
+    </target>
+    <target name="post-deploy"/>
+    <target name="deploy" depends="build,pre-deploy,do-deploy,post-deploy"/>
+    <!--for-all-configs targets-->
+    <target name="for-all-configs" depends="load-properties">
+        <fail unless="libs.ant-contrib.classpath">Classpath to Ant Contrib library (libs.ant-contrib.classpath property) is not set.</fail>
+        <property name="selected.configurations" value="${all.configurations}"/>
+        <taskdef resource="net/sf/antcontrib/antlib.xml">
+            <classpath>
+                <pathelement path="${libs.ant-contrib.classpath}"/>
+            </classpath>
+        </taskdef>
+        <for list="${selected.configurations}" param="cfg" keepgoing="true" trim="true">
+            <sequential>
+                <echo>Active project configuration: @{cfg}</echo>
+                <antcall target="${target.to.call}" inheritall="false" inheritrefs="false">
+                    <param name="config.active" value="@{cfg}"/>
+                    <propertyset>
+                        <propertyref name="no.deps"/>
+                    </propertyset>
+                </antcall>
+                <property name="no.deps" value="true"/>
+            </sequential>
+        </for>
+    </target>
+    <target name="jar-all">
+        <antcall target="for-all-configs">
+            <param name="target.to.call" value="jar"/>
+        </antcall>
+    </target>
+    <target name="build-all">
+        <antcall target="for-all-configs">
+            <param name="target.to.call" value="build"/>
+        </antcall>
+    </target>
+    <target name="javadoc-all">
+        <antcall target="for-all-configs">
+            <param name="target.to.call" value="javadoc"/>
+        </antcall>
+    </target>
+    <target name="deploy-all">
+        <antcall target="for-all-configs">
+            <param name="target.to.call" value="deploy"/>
+        </antcall>
+    </target>
+    <target name="rebuild-all">
+        <antcall target="for-all-configs">
+            <param name="target.to.call" value="rebuild"/>
+        </antcall>
+    </target>
+    <target name="clean-all">
+        <property file="nbproject/project.properties"/>
+        <fail unless="build.root.dir">Property build.root.dir is not set. By default its value should be \"build\".</fail>
+        <fail unless="dist.root.dir">Property dist.root.dir is not set. By default its value should be \"dist\".</fail>
+        <antcall target="for-all-configs">
+            <param name="target.to.call" value="clean"/>
+        </antcall>
+    </target>
+</project>
diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties
new file mode 100644 (file)
index 0000000..6243a0e
--- /dev/null
@@ -0,0 +1,8 @@
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+build.xml.data.CRC32=df8d64c8
+build.xml.script.CRC32=06525edf
+build.xml.stylesheet.CRC32=9c6a911d
+nbproject/build-impl.xml.data.CRC32=df8d64c8
+nbproject/build-impl.xml.script.CRC32=f96173cd
+nbproject/build-impl.xml.stylesheet.CRC32=051c3749
diff --git a/nbproject/private/private.properties b/nbproject/private/private.properties
new file mode 100644 (file)
index 0000000..4672260
--- /dev/null
@@ -0,0 +1,8 @@
+#Sun, 11 Jan 2015 18:45:51 +0600
+app-version.autoincrement=true
+config.active=
+deployment.counter=601
+deployment.number=0.6.0
+javadoc.preview=true
+netbeans.user=C\:\\Users\\Kalter\\AppData\\Roaming\\NetBeans\\8.0.1
+platform.apis.defaults=MMAPI-1.2,JSR238-1.0,J2ME-WS-1.0,JSR293-2.0,JSR82-1.1,JSR211-1.0,JSR234-1.0,JSR280-1.0,JSR75-1.0,JSR258-1.0,JSR226-1.0,JSR281-1.0,JSR256-1.2,JSR184-1.1,JSR239-1.0,JSR180-1.1.0,JSR253-1.0,JSR229-1.1,JSR177-1.0,WMA-1.1,WMA-2.0,JSR257-1.0,JSR179-1.0
diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml
new file mode 100644 (file)
index 0000000..5af0ed1
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
+    <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="1"/>
+    <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
+        <group/>
+    </open-files>
+</project-private>
diff --git a/nbproject/project.properties b/nbproject/project.properties
new file mode 100644 (file)
index 0000000..965e13f
--- /dev/null
@@ -0,0 +1,106 @@
+abilities=ColorScreen,MIDP=2.1,ScreenHeight=320,JSR229=1.1,JSR226=1.0,JSR184=1.1,JSR82=1.1,JSR281=1.0,JSR180=1.1.0,JSR280=1.0,OBEX=1.0,SATSA=1.0,WMA=2.0,ScreenColorDepth=16,JSR238=1.0,JSR239=1.0,JSR258=1.0,JSR234=1.0,JSR179=1.0,JSR256=1.2,JSR257=1.0,JSR177=1.0,JSR211=1.0,CLDC=1.1.1,J2MEWS=1.0,ScreenWidth=240,JSR253=1.0,MMAPI=1.2,TouchScreen,JSR293=2.0,JSR172=1.0,JSR75=1.0,
+all.configurations=\ 
+application.args=
+application.description=
+application.description.detail=
+application.name=
+application.vendor=Vendor
+build.classes.dir=${build.dir}/compiled
+build.classes.excludes=**/*.java,**/*.form,**/*.class,**/.nbintdb,**/*.mvd,**/*.wsclient,**/*.vmd
+build.dir=build/${config.active}
+build.root.dir=build
+debug.level=debug
+debugger.timeout=
+deployment.copy.target=deploy
+deployment.instance=default
+deployment.jarurl=${dist.jar}
+deployment.method=NONE
+deployment.override.jarurl=false
+dist.dir=dist/${config.active}
+dist.jad=Long_Flight.jad
+dist.jar=Long_Flight.jar
+dist.javadoc.dir=${dist.dir}/doc
+dist.root.dir=dist
+extra.classpath=
+file.reference.builtin.ks=${netbeans.user}/config/j2me/builtin.ks
+filter.exclude.tests=false
+filter.excludes=
+filter.more.excludes=**/overview.html,**/package.html
+filter.use.standard=true
+jar.compress=false
+javac.debug=true
+javac.deprecation=false
+javac.encoding=UTF-8
+javac.optimize=false
+javac.source=1.3
+javac.target=1.3
+javadoc.author=false
+javadoc.encoding=
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+libs.classpath=
+main.class=
+main.class.class=applet
+manifest.apipermissions=
+manifest.file=manifest.mf
+manifest.is.liblet=false
+manifest.jad=
+manifest.manifest=
+manifest.midlets=MIDlet-1: Long Flight,/gfx/icon.png,code.kalter.longflight.LongFlight\n
+manifest.others=MIDlet-Vendor: Kalter\nMIDlet-Version: 1.0\nMIDlet-Name: Long Flight\n
+manifest.pushregistry=
+name=Long Flight
+no.dependencies=false
+nokiaS80.application.icon=
+obfuscated.classes.dir=${build.dir}/obfuscated
+obfuscation.custom=
+obfuscation.level=0
+obfuscator.destjar=${build.dir}/obfuscated.jar
+obfuscator.srcjar=${build.dir}/before-obfuscation.jar
+platform.active=Oracle_Java_TM__Platform_Micro_Edition_SDK_3_0_5
+platform.active.description=Oracle Java(TM) Platform Micro Edition SDK 3.0.5
+platform.apis=WMA-1.1,WMA-2.0,MMAPI-1.2,JSR238-1.0,JSR211-1.0,JSR82-1.1,JSR177-1.0,JSR179-1.0,JSR234-1.0,JSR257-1.0,JSR281-1.0,J2ME-WS-1.0,JSR239-1.0,JSR293-2.0,JSR256-1.2,JSR253-1.0,JSR258-1.0,JSR229-1.1,JSR180-1.1.0,JSR226-1.0,JSR280-1.0,JSR75-1.0,JSR184-1.1
+platform.bootclasspath=${platform.home}/lib/jsr281_1.0.jar:${platform.home}/lib/jsr177_1.0.jar:${platform.home}/lib/jsr082_1.1.jar:${platform.home}/lib/jsr253_1.0.jar:${platform.home}/lib/jsr234_1.0.jar:${platform.home}/lib/jsr226_1.0.jar:${platform.home}/lib/jsr75_1.0.jar:${platform.home}/lib/jsr211_1.0.jar:${platform.home}/lib/jsr239_1.0.jar:${platform.home}/lib/jsr179_1.0.jar:${platform.home}/lib/jsr238_1.0.jar:${platform.home}/lib/jsr205_2.0.jar:${platform.home}/lib/jsr180_1.1.jar:${platform.home}/lib/jsr258_1.0.jar:${platform.home}/lib/jsr120_1.1.jar:${platform.home}/lib/jsr229_1.1.jar:${platform.home}/lib/jsr257_1.0.jar:${platform.home}/lib/jsr135_1.2.jar:${platform.home}/lib/jsr256_1.2.jar:${platform.home}/lib/jsr293_1.0.jar:${platform.home}/lib/jsr172_1.0.jar:${platform.home}/lib/jsr280_1.0.jar:${platform.home}/lib/jsr184_1.1.jar:${platform.home}/lib/midp_2.0.jar:${platform.home}/lib/cldc_1.1.jar
+platform.configuration=CLDC-1.1
+platform.device=DefaultCldcPhone1
+platform.fat.jar=true
+platform.profile=MIDP-2.0
+platform.trigger=CLDC
+platform.type=UEI-1.0.1
+preprocessed.dir=${build.dir}/preprocessed
+preverify.classes.dir=${build.dir}/preverified
+preverify.sources.dir=${build.dir}/preverifysrc
+resources.dir=resources
+run.cmd.options=
+run.jvmargs=
+run.method=STANDARD
+run.security.domain=trusted
+run.use.security.domain=false
+savaje.application.icon=
+savaje.application.icon.focused=
+savaje.application.icon.small=
+savaje.application.uid=TBD
+savaje.bundle.base=
+savaje.bundle.debug=false
+savaje.bundle.debug.port=
+semc.application.caps=
+semc.application.icon=
+semc.application.icon.count=
+semc.application.icon.splash=
+semc.application.icon.splash.installonly=false
+semc.application.uid=E4379672
+semc.certificate.path=
+semc.private.key.password=
+semc.private.key.path=
+sign.alias=minimal
+sign.enabled=false
+sign.keystore=${file.reference.builtin.ks}
+src.dir=src
+use.emptyapis=true
+use.preprocessor=true
diff --git a/nbproject/project.xml b/nbproject/project.xml
new file mode 100644 (file)
index 0000000..7baa9cf
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://www.netbeans.org/ns/project/1">
+    <type>org.netbeans.modules.kjava.j2meproject</type>
+    <configuration>
+        <data xmlns="http://www.netbeans.org/ns/j2me-project">
+            <name>Long Flight</name>
+            <minimum-ant-version>1.6</minimum-ant-version>
+        </data>
+    </configuration>
+</project>
diff --git a/src/code/kalter/longflight/Animation.java b/src/code/kalter/longflight/Animation.java
new file mode 100644 (file)
index 0000000..84f2a9c
--- /dev/null
@@ -0,0 +1,166 @@
+package code.kalter.longflight;
+
+import java.io.IOException;
+import javax.microedition.lcdui.Graphics;
+import javax.microedition.lcdui.Image;
+
+/**
+ * Реализация анимации: покадровая смена кадра из массива картинок за
+ * определённое время. Можно запустить как конечную анимацию, так и бесконечную
+ * 
+ * @author KalterFive
+ */
+public class Animation {
+
+    public static Animation createAnimation(String path, int width,
+            int deltaTime) throws IOException {
+        final Loader loader = Loader.getInstance();
+        final Image image = loader.getImage(path);
+        return createAnimation(image, width, deltaTime);
+    }
+
+    public static Animation createAnimation(String path, int width, int height,
+            int deltaTime) throws IOException {
+        final Loader loader = Loader.getInstance();
+        final Image image = loader.getImage(path);
+        return createAnimation(image, width, height, deltaTime);
+    }
+
+    public static Animation createAnimation(Image source, int width,
+            int deltaTime) {
+        final int height = source.getHeight();
+        return createAnimation(source, width, height, deltaTime);
+    }
+
+    public static Animation createAnimation(Image source, int width, int height,
+            int deltaTime) {
+        final Image[] still = new Image[source.getWidth() / width];
+        for (int i = 0; i < still.length; i++) {
+            still[i] = Image.createImage(source, i * width, 0,
+                    width, height, 0);
+        }
+        return createAnimation(still, width, height, deltaTime);
+    }
+
+    public static Animation createAnimation(Image[] still, int deltaTime) {
+        int width = still[0].getWidth();
+        int height = still[0].getHeight();
+        for (int i = 1; i < still.length; i++) {
+            if (still[i].getWidth() > width) {
+                width = still[i].getWidth();
+            }
+            if (still[i].getHeight() > height) {
+                height = still[i].getHeight();
+            }
+        }
+        return createAnimation(still, width, height, deltaTime);
+    }
+
+    public static Animation createAnimation(Image[] still,
+            int width, int height, int deltaTime) {
+        return new Animation(still, width, height, deltaTime);
+    }
+
+    private final Image[] still; // кадры
+    private final int width;
+    private final int height;
+    //=======================
+    private long lastTime; // необходимо для засекания времени
+    private int deltaTime; // скорость смены кадров
+    //=======================
+    private int position;
+    private boolean animationLoop;
+
+    private Animation(Image[] still, int width, int height, int deltaTime) {
+        this.still = still;
+        this.width = width;
+        this.height = height;
+        this.deltaTime = deltaTime;
+        lastTime = System.currentTimeMillis();
+        position = 0;
+        animationLoop = true;
+    }
+
+    public Image getStill(int index) {
+        if (index < 0) {
+            throw new IllegalArgumentException("index < 0");
+        }
+        if (index >= still.length) {
+            throw new ArrayIndexOutOfBoundsException("i >= length");
+        }
+        return still[index];
+    }
+
+    public int getWidth() {
+        return width;
+    }
+
+    public int getHeight() {
+        return height;
+    }
+
+    public int getDeltaTime() {
+        return deltaTime;
+    }
+
+    public void setDeltaTime(int deltaTime) {
+        if (deltaTime < 0) {
+            throw new IllegalArgumentException("delta time < 0");
+        }
+        this.deltaTime = deltaTime;
+    }
+
+    public int getPosition() {
+        return position;
+    }
+
+    // использование нежелательно, но безопасно
+    public void setPosition(int position) {
+        if (position < 0) {
+            throw new IllegalArgumentException("index < 0");
+        }
+        if (position >= still.length) {
+            throw new ArrayIndexOutOfBoundsException("i >= length");
+        }
+        this.position = position;
+    }
+
+    public void start() {
+        animationLoop = true;
+        position = 0;
+    }
+
+    public void stop() {
+        animationLoop = false;
+    }
+
+    public boolean getState() {
+        return animationLoop;
+    }
+
+    public void nextToInfinity() {
+        final long time = System.currentTimeMillis() - lastTime;
+        if (time > deltaTime) {
+            lastTime = System.currentTimeMillis();
+            if (++position >= still.length) {
+                start();
+            }
+        }
+    }
+
+    public void next() {
+        final long time = System.currentTimeMillis() - lastTime;
+        if (getState() && time > deltaTime) {
+            lastTime = System.currentTimeMillis();
+            if (++position >= still.length) {
+                stop();
+            }
+        }
+    }
+
+    public void paint(Graphics graphics, int x, int y) {
+        if (animationLoop) {
+            graphics.drawImage(still[position], x, y, 0);
+        }
+    }
+}
diff --git a/src/code/kalter/longflight/Area.java b/src/code/kalter/longflight/Area.java
new file mode 100644 (file)
index 0000000..2b0dcb5
--- /dev/null
@@ -0,0 +1,45 @@
+package code.kalter.longflight;
+
+/**
+ * Площадь прямоугольника
+ * 
+ * @author KalterFive
+ */
+public class Area {
+
+    private final int positionX;
+    private final int positionY;
+    private final int endPositionX;
+    private final int endPositionY;
+
+    public Area(int positionX, int positionY,
+            int endPositionX, int endPositionY) {
+        this.positionX = positionX;
+        this.positionY = positionY;
+        this.endPositionX = endPositionX;
+        this.endPositionY = endPositionY;
+    }
+
+    public boolean isEntry(int positionX, int positionY) {
+        return (positionX > this.positionX)
+                && (positionX < this.endPositionX)
+                && (positionY > this.positionY)
+                && (positionY < this.endPositionY);
+    }
+
+    public int getPositionX() {
+        return positionX;
+    }
+
+    public int getPositionY() {
+        return positionY;
+    }
+
+    public int getEndPositionX() {
+        return endPositionX;
+    }
+
+    public int getEndPositionY() {
+        return endPositionY;
+    }
+}
diff --git a/src/code/kalter/longflight/Arrays.java b/src/code/kalter/longflight/Arrays.java
new file mode 100644 (file)
index 0000000..d73fd85
--- /dev/null
@@ -0,0 +1,25 @@
+package code.kalter.longflight;
+
+/**
+ * Некоторые полезные методы для работы с массивами
+ * 
+ * @author KalterFive
+ */
+public class Arrays {
+
+    public static void insertShiftRight(int[] array, int value, int position) {
+        for (int i = position; i < array.length; i++) {
+            swap(array, i, position);
+        }
+        array[position] = value;
+    }
+
+    public static void swap(int[] array, int i, int j) {
+        int tmp = array[i];
+        array[i] = array[j];
+        array[j] = tmp;
+    }
+
+    private Arrays() {
+    }
+}
diff --git a/src/code/kalter/longflight/ByteArrayInputStream.java b/src/code/kalter/longflight/ByteArrayInputStream.java
new file mode 100644 (file)
index 0000000..4a38c16
--- /dev/null
@@ -0,0 +1,72 @@
+package code.kalter.longflight;
+
+/**
+ * Удобное чтение разных типов с байтового массива
+ *
+ * @author KalterFive
+ */
+public class ByteArrayInputStream {
+
+    private final byte[] array;
+    private int position;
+
+    public ByteArrayInputStream(byte[] array) {
+        this.array = array;
+        position = 0;
+    }
+
+    public byte readByte() {
+        return array[position++];
+    }
+
+    public short readShort() {
+        // AND для того, чтобы читать байт без знака
+        final short a = (short) (readByte() & 0x00FF);
+        final short b = (short) (readByte() & 0x00FF);
+        return (short) ((a << 8) | b);
+    }
+
+    public int readInteger() {
+        final int a = readShort();
+        final int b = readShort();
+        return (int) ((a << 16) | b);
+    }
+
+    public long readLong() {
+        final long a = readInteger();
+        final long b = readInteger();
+        return (long) ((a << 32) | b);
+    }
+
+    public byte[] toByteArray(int size) {
+        final byte[] array = new byte[size];
+        for (int i = 0; i < size; i++) {
+            array[i] = readByte();
+        }
+        return array;
+    }
+
+    public short[] toShortArray(int size) {
+        final short[] array = new short[size];
+        for (int i = 0; i < size; i++) {
+            array[i] = readShort();
+        }
+        return array;
+    }
+
+    public int[] toIntArray(int size) {
+        final int[] array = new int[size];
+        for (int i = 0; i < size; i++) {
+            array[i] = readInteger();
+        }
+        return array;
+    }
+
+    public long[] toLongArray(int size) {
+        final long[] array = new long[size];
+        for (int i = 0; i < size; i++) {
+            array[i] = readLong();
+        }
+        return array;
+    }
+}
diff --git a/src/code/kalter/longflight/ByteArrayOutputStream.java b/src/code/kalter/longflight/ByteArrayOutputStream.java
new file mode 100644 (file)
index 0000000..35dc765
--- /dev/null
@@ -0,0 +1,64 @@
+package code.kalter.longflight;
+
+/**
+ * Удобная запись разных типов в байтовый массив
+ * 
+ * @author KalterFive
+ */
+public class ByteArrayOutputStream {
+
+    private final byte[] array;
+    private int position;
+
+    public ByteArrayOutputStream(int size) {
+        array = new byte[size];
+        position = 0;
+    }
+
+    public void writeByte(byte b) {
+        array[position++] = b;
+    }
+
+    public void writeShort(short s) {
+        writeByte((byte) (s >> 8));
+        writeByte((byte) s);
+    }
+
+    public void writeInt(int i) {
+        writeShort((short) (i >> 16));
+        writeShort((short) i);
+    }
+
+    public void writeLong(long l) {
+        writeInt((int) (l >> 32));
+        writeInt((int) l);
+    }
+
+    public void writeByteArray(byte[] array, int length) {
+        for (int i = 0; i < length; i++) {
+            writeByte(array[i]);
+        }
+    }
+
+    public void writeShortArray(short[] array, int length) {
+        for (int i = 0; i < length; i++) {
+            writeShort(array[i]);
+        }
+    }
+
+    public void writeIntArray(int[] array, int length) {
+        for (int i = 0; i < length; i++) {
+            writeInt(array[i]);
+        }
+    }
+
+    public void writeLongArray(long[] array, int length) {
+        for (int i = 0; i < length; i++) {
+            writeLong(array[i]);
+        }
+    }
+
+    public byte[] toArray() {
+        return array;
+    }
+}
diff --git a/src/code/kalter/longflight/Color.java b/src/code/kalter/longflight/Color.java
new file mode 100644 (file)
index 0000000..9440fa6
--- /dev/null
@@ -0,0 +1,20 @@
+package code.kalter.longflight;
+
+/**
+ * @author KalterFive
+ */
+public class Color {
+
+    public static final int BLACK = 0x000000;
+    public static final int BLUE = 0x0000FF;
+    public static final int GREEN = 0x00FF00;
+    public static final int RED = 0xFF0000;
+    public static final int WHITE = 0xFFFFFF;
+
+    public static int maskRGB(int r, int g, int b) {
+        return (r << 16) | (g << 8) | b;
+    }
+
+    private Color() {
+    }
+}
diff --git a/src/code/kalter/longflight/EventListener.java b/src/code/kalter/longflight/EventListener.java
new file mode 100644 (file)
index 0000000..f7c4ce9
--- /dev/null
@@ -0,0 +1,13 @@
+package code.kalter.longflight;
+
+/**
+ * Простое событие: событие и условие, при котором оно возбуждается
+ * 
+ * @author KalterFive
+ */
+public interface EventListener {
+
+    boolean is();
+
+    void event();
+}
diff --git a/src/code/kalter/longflight/FPS.java b/src/code/kalter/longflight/FPS.java
new file mode 100644 (file)
index 0000000..60b58e0
--- /dev/null
@@ -0,0 +1,46 @@
+package code.kalter.longflight;
+
+/**
+ * Ограничитель кадров
+ *
+ * @author KalterFive
+ */
+public class FPS {
+
+    private static FPS instance;
+
+    public static FPS getInstance(int max) {
+        if (instance == null) {
+            instance = new FPS(max);
+        }
+        return instance;
+    }
+
+    private long fpsTime;
+    private long fpsDt;
+    private int max; // кол-во кадров в секунду
+
+    private FPS(int max) {
+        this.max = max;
+        this.fpsTime = System.currentTimeMillis();
+        this.fpsDt = 1;
+    }
+
+    // обновляет необходимые данные и возвращает текущий fps
+    public long process() {
+        long dt;
+        if ((dt = System.currentTimeMillis() - fpsTime) != 0) {
+            fpsDt = dt;
+        }
+        fpsTime = System.currentTimeMillis();
+        return 1000 / fpsDt;
+    }
+
+    // останавливает программу, пока скорость смены кадров больше заданной
+    public void max() {
+        long dt = System.currentTimeMillis() - fpsTime;
+        while (dt < max) {
+            dt = System.currentTimeMillis() - fpsTime;
+        }
+    }
+}
diff --git a/src/code/kalter/longflight/Font.java b/src/code/kalter/longflight/Font.java
new file mode 100644 (file)
index 0000000..fe2655d
--- /dev/null
@@ -0,0 +1,127 @@
+package code.kalter.longflight;
+
+import java.io.IOException;
+import javax.microedition.lcdui.Graphics;
+import javax.microedition.lcdui.Image;
+
+/**
+ * Костыль - и этим всё сказанно
+ *
+ * @author KalterFive
+ */
+public class Font {
+
+    private static Font instance;
+
+    public static Font getInstance() throws IOException {
+        if (instance == null) {
+            instance = new Font();
+        }
+        return instance;
+    }
+
+    private final Image[] ascii;
+
+    private Font() throws IOException {
+        Image font = Loader.getInstance().getImage("/gfx/font.png");
+        ascii = new Image[0x7F];
+        int x = 0;
+        for (int i = 0x41; i <= 0x5A; i++, x += 5) {
+            ascii[i] = Image.createImage(font, x, 0, 5, 9, 0);
+        }
+        for (int i = 0x61; i <= 0x7A; i++, x += 5) {
+            ascii[i] = Image.createImage(font, x, 0, 5, 9, 0);
+        }
+        for (int i = 0x30; i <= 0x39; i++, x += 5) {
+            ascii[i] = Image.createImage(font, x, 0, 5, 9, 0);
+        }
+        ascii[0x21] = Image.createImage(font, x, 0, 5, 9, 0);
+        ascii[0x22] = Image.createImage(font, x += 5, 0, 5, 9, 0);
+        ascii[0x27] = Image.createImage(font, x += 5, 0, 5, 9, 0);
+        ascii[0x2C] = Image.createImage(font, x += 5, 0, 5, 9, 0);
+        ascii[0x2D] = Image.createImage(font, x += 5, 0, 5, 9, 0);
+        ascii[0x2E] = Image.createImage(font, x += 5, 0, 5, 9, 0);
+        ascii[0x3A] = Image.createImage(font, x += 5, 0, 5, 9, 0);
+        ascii[0x28] = Image.createImage(font, x += 5, 0, 5, 9, 0);
+        ascii[0x29] = Image.createImage(font, x += 5, 0, 4, 9, 0);
+    }
+
+    public int getWidth(String text) {
+        return text.length() * 6;
+    }
+
+    public void paint(Graphics graphics, String text, int x, int y) {
+        for (int i = 0, px = x; i < text.length(); i++) {
+            final char c = text.charAt(i);
+            switch (c) {
+                case '\r':
+                    x = px;
+                    break;
+
+                case '\n':
+                    y += 10;
+                    break;
+
+                case ' ':
+                    x += 6;
+                    break;
+
+                default:
+                    graphics.drawImage(ascii[c], x, y, 0);
+                    x += 6;
+                    break;
+            }
+        }
+    }
+
+    public void paint(Graphics graphics, String text,
+            int x, int y, int width) {
+        String[] word = split(text);
+        int px = x;
+        for (int i = 0; i < word.length; i++) {
+            paint(graphics, word[i], px, y);
+            int length = (getWidth(word[i])) + 6;
+            if ((px += length) + length > width) {
+                px = x;
+                y += 10;
+            }
+        }
+    }
+
+    public int getHeight(String text, int width) {
+        String[] word = split(text);
+        int result = 0;
+        for (int i = 0, x = 0; i < word.length; i++) {
+            int length = (getWidth(word[i])) + 6;
+            if ((x += length) + length > width) {
+                x = 0;
+                result += 10;
+            }
+        }
+        return result;
+    }
+
+    private String[] split(String text) {
+        String[] result;
+        int length = 1;
+        for (int i = 0; i < text.length(); i++) {
+            if (text.charAt(i) == ' ') {
+                length++;
+            }
+        }
+        result = new String[length];
+        StringBuffer word = new StringBuffer();
+        int j = 0;
+        for (int i = 0; i < text.length(); i++) {
+            char c = text.charAt(i);
+            if (c == ' ') {
+                result[j++] = word.toString();
+                word = new StringBuffer();
+            } else {
+                word.append(c);
+            }
+        }
+        result[j] = word.toString();
+        return result;
+    }
+}
diff --git a/src/code/kalter/longflight/Loader.java b/src/code/kalter/longflight/Loader.java
new file mode 100644 (file)
index 0000000..25f5c3a
--- /dev/null
@@ -0,0 +1,71 @@
+package code.kalter.longflight;
+
+import code.kalter.longflight.crypto.CIStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Vector;
+import javax.microedition.lcdui.Image;
+import javax.microedition.media.Manager;
+import javax.microedition.media.MediaException;
+import javax.microedition.media.Player;
+
+/**
+ * Дабы избежать повторных загрузок из разных мест программы, а так же
+ * обеспечить загрузку с расшифкой создан это класс
+ *
+ * @author KalterFive
+ */
+public class Loader {
+
+    private static final int KEY = 5; // шифровальный XOR ключ
+
+    private static Loader instance;
+
+    public static Loader getInstance() {
+        if (instance == null) {
+            instance = new Loader();
+        }
+        return instance;
+    }
+
+    private final Vector dump; // все успешно загруженные ресурсы
+
+    private Loader() {
+        dump = new Vector();
+    }
+
+    public Object getObject(String path) {
+        Object result = null;
+        for (int i = 0; i < dump.size(); i++) {
+            ObjectItem item = (ObjectItem) dump.elementAt(i);
+            if (item.get(path) != null) {
+                result = item.get(path);
+                break;
+            }
+        }
+        return result;
+    }
+
+    public Image getImage(String path) throws IOException {
+        Image result = (Image) getObject(path);
+        if (result == null) {
+            final InputStream istream = getClass().getResourceAsStream(path);
+            final InputStream cistream = new CIStream(istream, KEY);
+            result = Image.createImage(cistream);
+            cistream.close();
+            dump.addElement(new ObjectItem(result, path));
+        }
+        return result;
+    }
+
+    public Player getPlayer(String path, String type) throws
+            IOException, MediaException {
+        Player result = (Player) getObject(path);
+        if (result == null) {
+            final InputStream iStream = getClass().getResourceAsStream(path);
+            result = Manager.createPlayer(iStream, type);
+            dump.addElement(new ObjectItem(result, path));
+        }
+        return result;
+    }
+}
diff --git a/src/code/kalter/longflight/LongFlight.java b/src/code/kalter/longflight/LongFlight.java
new file mode 100644 (file)
index 0000000..79a43d1
--- /dev/null
@@ -0,0 +1,140 @@
+package code.kalter.longflight;
+
+import code.kalter.longflight.screen.About;
+import code.kalter.longflight.screen.Crash;
+import code.kalter.longflight.screen.EnableSound;
+import code.kalter.longflight.screen.Game;
+import code.kalter.longflight.screen.HighScore;
+import code.kalter.longflight.screen.Loading;
+import code.kalter.longflight.screen.Menu;
+import code.kalter.longflight.screen.Pause;
+import code.kalter.longflight.screen.Screen;
+import code.kalter.longflight.screen.SelectShip;
+import code.kalter.longflight.screen.Splash;
+import java.io.IOException;
+import javax.microedition.lcdui.Display;
+import javax.microedition.media.MediaException;
+import javax.microedition.midlet.MIDlet;
+
+/**
+ * Главный класс
+ *
+ * @author KalterFive
+ */
+public final class LongFlight extends MIDlet {
+
+    public static LongFlight link;
+
+    // screens
+    public static final int SPLASH = 0;
+    public static final int GAME = 1;
+    public static final int MENU = 2;
+    public static final int SELECT_SHIP = 3;
+    public static final int ABOUT = 4;
+    public static final int HIGH_SCORE = 5;
+    public static final int LOADING = 6;
+    public static final int PAUSE = 7;
+    public static final int ENABLE_SOUND = 8;
+    public static final int CRASH = 9;
+
+    private Sound music;
+    private Screen[] screen;
+    private int screenID;
+    private int previosScreenID;
+
+    public LongFlight() {
+        screenID = SPLASH;
+        link = this;
+        try {
+            screen = new Screen[]{
+                new Splash(),
+                new Game(),
+                new Menu(),
+                new SelectShip(),
+                new About(),
+                new HighScore(),
+                new Loading(),
+                new Pause(),
+                new EnableSound(),
+                new Crash()
+            };
+        } catch (Exception e) {
+            catchException(e);
+        }
+    }
+
+    // override
+    public void startApp() {
+        Display.getDisplay(this).setCurrent(screen[ENABLE_SOUND]);
+        screen[ENABLE_SOUND].start();
+    }
+
+    // override
+    public void pauseApp() {
+        // TODO
+    }
+
+    // override
+    public void destroyApp(boolean unconditional) {
+        try {
+            if (music != null) {
+                music.stop();
+            }
+        } catch (MediaException e) {
+            catchException(e);
+        }
+        notifyDestroyed();
+    }
+
+    public void catchException(Exception e) {
+        if (screen != null) {
+            screen[screenID].stop();
+        }
+        System.out.println(e.getMessage());
+        e.printStackTrace();
+        destroyApp(true);
+    }
+
+    public void setScreen(int screenID) {
+        previosScreenID = this.screenID;
+        screen[this.screenID].stop();
+        screen[screenID].start();
+        this.screenID = screenID;
+        Display.getDisplay(this).setCurrent(screen[screenID]);
+    }
+
+    // принудительно, то есть без остановки текущего
+    public void $setScreen(int screenID) {
+        previosScreenID = this.screenID;
+        screen[this.screenID = screenID].start();
+        Display.getDisplay(this).setCurrent(screen[screenID]);
+    }
+
+    public int getPreviosScreenID() {
+        return previosScreenID;
+    }
+
+    // для облегчения жизни
+    public void sleep(long millis) {
+        try {
+            Thread.sleep(millis);
+        } catch (InterruptedException interruptedException) {
+            catchException(interruptedException);
+        }
+    }
+
+    public void playMusic() {
+        try {
+            music = new Sound() {{
+                add("/song/monster.mid", "audio/midi");
+                add("/song/mobscene.mid", "audio/midi");
+                add("/song/iha.mid", "audio/midi");
+                play();
+            }};
+        } catch (IOException e) {
+            catchException(e);
+        } catch (MediaException e) {
+            catchException(e);
+        }
+    }
+}
diff --git a/src/code/kalter/longflight/ObjectItem.java b/src/code/kalter/longflight/ObjectItem.java
new file mode 100644 (file)
index 0000000..a452dad
--- /dev/null
@@ -0,0 +1,26 @@
+package code.kalter.longflight;
+
+import java.io.IOException;
+
+/**
+ * Объект и путь к нему
+ *
+ * @author KalterFive
+ */
+public class ObjectItem {
+
+    private final Object image;
+    private final String path;
+
+    public ObjectItem(Object object, String path) throws IOException {
+        this.path = path;
+        this.image = object;
+    }
+
+    public Object get(String path) {
+        if (this.path.equals(path)) {
+            return image;
+        }
+        return null;
+    }
+}
diff --git a/src/code/kalter/longflight/Pointer.java b/src/code/kalter/longflight/Pointer.java
new file mode 100644 (file)
index 0000000..a343039
--- /dev/null
@@ -0,0 +1,59 @@
+package code.kalter.longflight;
+
+/**
+ * Координаты, нажатые и отпущенные на экране
+ *
+ * @author KalterFive
+ */
+public class Pointer {
+    
+    // нажатые координаты
+    private int xPressed;
+    private int yPressed;
+    
+    // отпущенные координаты
+    private int xReleased;
+    private int yReleased;
+
+    public void setPressed(int xPressed, int yPressed) {
+        setXPressed(xPressed);
+        setYPressed(yPressed);
+    }
+
+    public void setXPressed(int xPressed) {
+        this.xPressed = xPressed;
+    }
+
+    public void setYPressed(int yPressed) {
+        this.yPressed = yPressed;
+    }
+
+    public void setReleased(int xReleased, int yReleased) {
+        setXReleased(xReleased);
+        setYReleased(yReleased);
+    }
+
+    public void setXReleased(int xReleased) {
+        this.xReleased = xReleased;
+    }
+
+    public void setYReleased(int yReleased) {
+        this.yReleased = yReleased;
+    }
+
+    public int getXPressed() {
+        return xPressed;
+    }
+
+    public int getYPressed() {
+        return yPressed;
+    }
+
+    public int getXReleased() {
+        return xReleased;
+    }
+
+    public int getYReleased() {
+        return yReleased;
+    }
+}
diff --git a/src/code/kalter/longflight/Quote.java b/src/code/kalter/longflight/Quote.java
new file mode 100644 (file)
index 0000000..e57a969
--- /dev/null
@@ -0,0 +1,25 @@
+package code.kalter.longflight;
+
+/**
+ * Цитата и её автор
+ * 
+ * @author KalterFive
+ */
+public class Quote {
+
+    private final String quote;
+    private final String author;
+
+    public Quote(String quote, String author) {
+        this.author = author;
+        this.quote = quote;
+    }
+
+    public String getQuote() {
+        return quote;
+    }
+
+    public String getAuthor() {
+        return "(c) " + author;
+    }
+}
diff --git a/src/code/kalter/longflight/Sound.java b/src/code/kalter/longflight/Sound.java
new file mode 100644 (file)
index 0000000..9dbd3d3
--- /dev/null
@@ -0,0 +1,85 @@
+package code.kalter.longflight;
+
+import java.io.IOException;
+import java.util.Vector;
+import javax.microedition.media.MediaException;
+import javax.microedition.media.Player;
+import javax.microedition.media.PlayerListener;
+
+/**
+ * Фоновая музыка: поочерёдное воспроизведение с цикличностью. Для создания
+ * необходимо применить трюк Double-Brace, где сначала нужно загрузить ресурсы,
+ * а после запустить
+ *
+ * @author KalterFive
+ */
+public class Sound {
+
+    // вызывается для смены текущей мелодии
+    private final PlayerListener playerListener;
+
+    {
+        playerListener = new PlayerListener() {
+            // override
+            public void playerUpdate(Player player, String event,
+                    Object eventData) {
+                if (event.equals(PlayerListener.END_OF_MEDIA)) {
+                    try {
+                        player.stop();
+                        player.deallocate();
+                        play();
+                    } catch (MediaException e) {
+                        LongFlight.link.catchException(e);
+                    }
+                }
+            }
+        };
+    }
+
+    private final Vector dump;
+    private int active;
+
+    public Sound() throws MediaException {
+        active = -1;
+        dump = new Vector();
+    }
+
+    // останавливает каждый плеер, освобождает ресурсы и закрывает
+    public void stop() throws MediaException {
+        for (int i = 0; i < dump.size(); i++) {
+            final Player player = (Player) dump.elementAt(i);
+            if (i == active) {
+                player.stop();
+                player.deallocate();
+            }
+            player.close();
+        }
+    }
+    
+    /*
+     * Берёт из вектора следующий плеер, реализует, упреждает выборку, ставит
+     * воспроизведение на начало и включает
+     */
+    protected void play() throws MediaException {
+        if (++active >= dump.size()) {
+            active = 0;
+        }
+        final Player player = (Player) dump.elementAt(active);
+        player.realize();
+        player.prefetch();
+        player.setMediaTime(0);
+        player.start();
+    }
+
+    // добавляет загруженный плеер в вектор - ничего более
+    protected void add(Player player) throws MediaException {
+        player.addPlayerListener(playerListener);
+        dump.addElement(player);
+    }
+
+    protected void add(String path, String type) throws IOException,
+            MediaException {
+        final Loader loader = Loader.getInstance();
+        add(loader.getPlayer(path, type));
+    }
+}
diff --git a/src/code/kalter/longflight/Sprite.java b/src/code/kalter/longflight/Sprite.java
new file mode 100644 (file)
index 0000000..bd05c7c
--- /dev/null
@@ -0,0 +1,109 @@
+package code.kalter.longflight;
+
+import java.io.IOException;
+import java.util.Vector;
+import javax.microedition.lcdui.Graphics;
+import javax.microedition.lcdui.Image;
+
+/**
+ * Спрайт - основной графический элемент
+ *
+ * @author KalterFive
+ */
+public class Sprite {
+
+    protected final Image image;
+    private int positionX;
+    private int positionY;
+
+    // события
+    private Vector eventListener;
+
+    public Sprite(Image image, int positionX, int positionY) {
+        this.image = image;
+        this.positionX = positionX;
+        this.positionY = positionY;
+        eventListener = new Vector(1);
+    }
+
+    public Sprite(String path, int positionX, int positionY)
+            throws IOException {
+        this(Image.createImage(path), positionX, positionY);
+    }
+
+    public void paint(Graphics graph) {
+        graph.drawImage(image, positionX, positionY, 0);
+    }
+
+    public void addEvent(EventListener event) {
+        eventListener.addElement(event);
+    }
+
+    // попытаться возбудить события
+    public void exciteEvent() {
+        for (int i = 0; i < eventListener.size(); i++) {
+            EventListener event = (EventListener) eventListener.elementAt(i);
+            if ((event != null) && (event.is())) {
+                event.event();
+            }
+        }
+    }
+
+    public EventListener getEvent(int number)
+            throws ArrayIndexOutOfBoundsException {
+        return (EventListener) eventListener.elementAt(number);
+    }
+
+    // удалить событие без сдвига (то есть оnullить его)
+    public void removeEvent(int number)
+            throws ArrayIndexOutOfBoundsException {
+        eventListener.setElementAt(null, number);
+    }
+
+    public boolean isEntrySet(int positionX, int positionY) {
+        return (positionX >= this.positionX)
+                && (positionX <= this.positionX + getWidth())
+                && (positionY >= this.positionY)
+                && (positionY <= this.positionY + getHeight());
+    }
+
+    public void moveDown(int speed) {
+        positionY += speed;
+    }
+
+    public void moveRight(int speed) {
+        positionX += speed;
+    }
+
+    public void moveUp(int speed) {
+        moveDown(-speed);
+    }
+
+    public void moveLeft(int speed) {
+        moveRight(-speed);
+    }
+
+    public int getX() {
+        return positionX;
+    }
+
+    public int getY() {
+        return positionY;
+    }
+
+    public int getWidth() {
+        return image.getWidth();
+    }
+
+    public int getHeight() {
+        return image.getHeight();
+    }
+
+    protected void setX(int x) {
+        this.positionX = x;
+    }
+
+    protected void setY(int y) {
+        this.positionY = y;
+    }
+}
diff --git a/src/code/kalter/longflight/StringReader.java b/src/code/kalter/longflight/StringReader.java
new file mode 100644 (file)
index 0000000..4b8793c
--- /dev/null
@@ -0,0 +1,70 @@
+package code.kalter.longflight;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Для удобного чтения строк и других типов из файла. Является не более, чем
+ * обёрткой для Inputstream
+ *
+ * @author KalterFive
+ */
+public class StringReader {
+
+    private final InputStream inputStream;
+
+    public StringReader(InputStream inputStream) {
+        this.inputStream = inputStream;
+    }
+
+    public String nextString() throws IOException {
+        StringBuffer stringBuffer = new StringBuffer();
+        int c = inputStream.read();
+        while (c != '\r' && c != -1) {
+            stringBuffer.append((char) c);
+            c = inputStream.read();
+        }
+        inputStream.read();
+        return stringBuffer.toString();
+    }
+
+    // читает true or false
+    public boolean nextBool() throws IOException {
+        String line = nextString();
+        if (line.equals("true")) {
+            return true;
+        } else if (line.equals("false")) {
+            return false;
+        } else {
+            throw new IllegalArgumentException(line);
+        }
+    }
+
+    public byte nextByte() throws IOException {
+        return Byte.parseByte(nextString());
+    }
+
+    public short nextShort() throws IOException {
+        return Short.parseShort(nextString());
+    }
+
+    public int nextInt() throws IOException {
+        return Integer.parseInt(nextString());
+    }
+
+    public long nextLong() throws IOException {
+        return Long.parseLong(nextString());
+    }
+
+    public float nextFloat() throws IOException {
+        return Float.parseFloat(nextString());
+    }
+
+    public double nextDouble() throws IOException {
+        return Double.parseDouble(nextString());
+    }
+
+    public void close() throws IOException {
+        inputStream.close();
+    }
+}
diff --git a/src/code/kalter/longflight/Time.java b/src/code/kalter/longflight/Time.java
new file mode 100644 (file)
index 0000000..bed35f7
--- /dev/null
@@ -0,0 +1,52 @@
+package code.kalter.longflight;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Timer;
+import java.util.TimerTask;
+
+/**
+ * Класс, определяющий текущее время (используется для вывода даты на экране)
+ *
+ * @author KalterFive
+ */
+public class Time extends TimerTask {
+
+    private static Time instance;
+
+    public static Time getInstance(int step) {
+        if (instance == null) {
+            instance = new Time(step);
+        }
+        return instance;
+    }
+
+    private final Timer updating;
+    private String time;
+
+    // step - шаг обновления даты
+    private Time(int step) {
+        time = "Long Flight";
+        updating = new Timer();
+        updating.schedule(this, 0, step);
+    }
+
+    // override
+    public void run() {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(new Date(System.currentTimeMillis()));
+        int minute = calendar.get(Calendar.MINUTE);
+        int hour = calendar.get(Calendar.HOUR);
+        int ampm = calendar.get(Calendar.AM_PM);
+        int day = calendar.get(Calendar.DAY_OF_MONTH);
+        int month = calendar.get(Calendar.MONTH) + 1;
+        int year = calendar.get(Calendar.YEAR) + 1000;
+        time = hour + ":" + minute + " " + (ampm == 1 ? "AM" : "PM") + " "
+                + day + "." + month + "." + year;
+    }
+
+    // override
+    public String toString() {
+        return time;
+    }
+}
diff --git a/src/code/kalter/longflight/crypto/CIStream.java b/src/code/kalter/longflight/crypto/CIStream.java
new file mode 100644 (file)
index 0000000..894f5d2
--- /dev/null
@@ -0,0 +1,37 @@
+package code.kalter.longflight.crypto;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Шифровальный входной поток (обёртка для InputStream). Дешифровка:
+ * xor -> xchgb
+ *
+ * @author KalterFive
+ */
+public class CIStream extends InputStream {
+
+    private final InputStream istream;
+    private final Random random;
+
+    // key - ключ для ГПСЧ
+    public CIStream(InputStream istream, int key) {
+        this.istream = istream;
+        this.random = new Random(key);
+    }
+
+    public int read() throws IOException {
+        int b = istream.read();
+        b ^= random.random(0xFF);
+        b = (b << 4) | (b >> 4);
+        return b;
+    }
+
+    public int available() throws IOException {
+        return istream.available();
+    }
+
+    public void close() throws IOException {
+        istream.close();
+    }
+}
diff --git a/src/code/kalter/longflight/crypto/Random.java b/src/code/kalter/longflight/crypto/Random.java
new file mode 100644 (file)
index 0000000..63555f6
--- /dev/null
@@ -0,0 +1,31 @@
+package code.kalter.longflight.crypto;
+
+/**
+ * Простой Генератор Псевдослучайных Чисел
+ *
+ * @author KalterFive
+ */
+public class Random {
+
+    private int next;
+
+    public Random(int next) {
+        this.next = next;
+    }
+
+    public Random() {
+        this((int) System.currentTimeMillis());
+    }
+
+    public int random() {
+        next ^= (next << 13);
+        next ^= (next >>> 17);
+        next ^= (next << 5);
+        return Math.abs(next);
+    }
+
+    // random от [0] до [max - 1]
+    public int random(int max) {
+        return random() % max;
+    }
+}
diff --git a/src/code/kalter/longflight/game/Bullet.java b/src/code/kalter/longflight/game/Bullet.java
new file mode 100644 (file)
index 0000000..18fdda8
--- /dev/null
@@ -0,0 +1,98 @@
+package code.kalter.longflight.game;
+
+import code.kalter.longflight.Loader;
+import code.kalter.longflight.game.bullet.Collisionable;
+import code.kalter.longflight.game.bullet.Gun;
+import java.io.IOException;
+import javax.microedition.lcdui.Graphics;
+import javax.microedition.lcdui.Image;
+
+/**
+ * Пули!
+ *
+ * @author KalterFive
+ */
+public class Bullet implements Gun {
+
+    private final int SIZE = 128;
+    private final int screenH;
+
+    private final Image[] gfx;
+
+    private final int[] positionX;
+    private final int[] positionY;
+    private final int[] type;
+
+    private Collisionable[] object;
+
+    public Bullet(int screenH) throws IOException {
+        this.screenH = screenH;
+        positionX = new int[SIZE];
+        positionY = new int[SIZE];
+        type = new int[SIZE];
+        Loader imageLoader = Loader.getInstance();
+        gfx = new Image[]{
+            imageLoader.getImage("/gfx/bullet/0.png"),
+            imageLoader.getImage("/gfx/bullet/1.png")
+        };
+    }
+
+    // магия - все пули исчезают
+    public void setNull() {
+        for (int i = 0; i < SIZE; i++) {
+            type[i] = NULL;
+        }
+    }
+
+    public void setCollisionable(Collisionable[] object) {
+        this.object = object;
+    }
+
+    public void update() {
+        for (int i = 0; i < SIZE; i++) {
+            if (type[i] == NULL) {
+                continue;
+            }
+            collision(i);
+            positionY[i] += (type[i] * 2 - 1) * 5;
+            if ((positionY[i] < -10) || (positionY[i] > screenH)) {
+                type[i] = NULL;
+            }
+        }
+    }
+
+    public void paint(Graphics graphics) {
+        for (int i = 0; i < SIZE; i++) {
+            if (type[i] == NULL) {
+                continue;
+            }
+            graphics.drawImage(gfx[type[i]], positionX[i], positionY[i], 0);
+        }
+    }
+
+    // override
+    public void fire(int type, int positionX, int positionY) {
+        for (int i = 0; i < SIZE; i++) {
+            if (this.type[i] != NULL) {
+                continue;
+            }
+            this.type[i] = type;
+            this.positionX[i] = positionX;
+            this.positionY[i] = positionY;
+            break;
+        }
+    }
+
+    private void collision(int i) {
+        for (int j = 0; j < object.length; j++) {
+            if (type[i] == object[j].getType()) {
+                continue;
+            }
+            if (object[j].isCollisionOfBullet(positionX[i], positionY[i])) {
+                object[j].boomOfBullet();
+                type[i] = NULL;
+                break;
+            }
+        }
+    }
+}
diff --git a/src/code/kalter/longflight/game/ColorEffect.java b/src/code/kalter/longflight/game/ColorEffect.java
new file mode 100644 (file)
index 0000000..ea92234
--- /dev/null
@@ -0,0 +1,41 @@
+package code.kalter.longflight.game;
+
+import javax.microedition.lcdui.Graphics;
+
+/**
+ * Цветовой эффект при попадании пули в игрока
+ *
+ * @author KalterFive
+ */
+public class ColorEffect {
+
+    private final int screenW;
+    private final int screenH;
+
+    private final int color;
+    //==========================
+    private final int number; // количество кадров для рисования цветного экрана
+    private int count;        // счётчик
+    //==========================
+    private boolean is;
+
+    public ColorEffect(int color, int number, int screenW, int screenH) {
+        this.color = color;
+        this.number = number;
+        this.screenW = screenW;
+        this.screenH = screenH;
+    }
+
+    public void activate() {
+        is = true;
+        count = 0;
+    }
+
+    public void paint(Graphics graphics) {
+        if (is) {
+            graphics.setColor(color);
+            graphics.fillRect(0, 0, screenW, screenH);
+            is = ++count < number;
+        }
+    }
+}
diff --git a/src/code/kalter/longflight/game/Enemy.java b/src/code/kalter/longflight/game/Enemy.java
new file mode 100644 (file)
index 0000000..3e879c1
--- /dev/null
@@ -0,0 +1,232 @@
+package code.kalter.longflight.game;
+
+import code.kalter.longflight.game.bullet.Collisionable;
+import code.kalter.longflight.game.bullet.Gun;
+import code.kalter.longflight.game.explosion.Detonator;
+import code.kalter.longflight.game.ship.Ship;
+import code.kalter.longflight.game.ship.ShipEnemy;
+import java.io.IOException;
+import java.util.Random;
+import java.util.Timer;
+import java.util.TimerTask;
+import javax.microedition.lcdui.Graphics;
+
+/**
+ * Враги и всё связанное с ними
+ *
+ * @author KalterFive
+ */
+public class Enemy implements Collisionable {
+
+    private static final int COUNT = 28;
+    
+    // специальное обозначение для несуществующего врага
+    private static final int NULL = 666;
+
+    private final int screenW;
+    private final int screenH;
+
+    private final Gamer gamer;
+    private final Detonator detonator;
+    private final ShipEnemy ship;
+    private final Gun gun;
+    private final Random random;
+    private Timer createEnemy;
+
+    // enemy...
+    private final int[] x;
+    private final int[] y;
+    private final int[] type;
+    private final int[] life;
+    private final long[] lastFire;
+
+    private int score;
+    private int numKill;
+    private int boom; // индекс врага, в которого попала пуля
+
+    public Enemy(int screenW, int screenH, Gun gun,
+            Detonator detonator, Gamer gamer) throws IOException {
+        this.screenW = screenW;
+        this.screenH = screenH;
+        this.gun = gun;
+        this.detonator = detonator;
+        this.gamer = gamer;
+        ship = ShipEnemy.getInstance();
+        random = new Random();
+        x = new int[COUNT];
+        y = new int[COUNT];
+        type = new int[COUNT];
+        life = new int[COUNT];
+        lastFire = new long[COUNT];
+    }
+
+    // очистка всех врагов
+    public void setNull() {
+        for (int i = 0; i < COUNT; i++) {
+            type[i] = NULL;
+        }
+        numKill = score = 0;
+    }
+
+    public void update() {
+        for (int i = 0; i < COUNT; i++) {
+            if (type[i] == NULL) {
+                continue;
+            }
+            switch (type[i]) {
+                case Ship.LAX:
+                    aiLax(i);
+                    break;
+
+                case Ship.POWERFUL:
+                    aiPowerful(i);
+                    break;
+
+                case Ship.UNIVERSAL:
+                    aiUniversal(i);
+                    break;
+
+                case Ship.STRONG:
+                    aiStrong(i);
+                    break;
+            }
+        }
+    }
+
+    public void paint(Graphics graphics) {
+        for (int i = 0; i < COUNT; i++) {
+            if (type[i] == NULL) {
+                continue;
+            }
+            graphics.drawImage(ship.getImage(type[i]), x[i], y[i], 0);
+        }
+    }
+
+    // override
+    public boolean isCollisionOfBullet(int bx, int by) {
+        for (int i = 0; i < COUNT; i++) {
+            if (type[i] == NULL) {
+                continue;
+            }
+            if ((bx > x[i]) && (bx < x[i] + Ship.SIZE)
+                    && (by > y[i]) && (by < y[i] + Ship.SIZE)) {
+                boom = i;
+                return true;
+            }
+        }
+        return false;
+    }
+
+    // override
+    public void boomOfBullet() {
+        if (--life[boom] <= 0) {
+            numKill++;
+            score += (((type[boom] + 1) * 2) - 1);
+            type[boom] = NULL;
+            detonator.activate(x[boom], y[boom]);
+        }
+    }
+
+    // override
+    public int getType() {
+        return Gun.ENEMY;
+    }
+
+    public void activateCreator() {
+        createEnemy = new Timer();
+        createEnemy.schedule(new TimerTask() {
+            // override
+            public void run() {
+                for (int i = 0; i < COUNT; i++) {
+                    if (type[i] != NULL) {
+                        continue;
+                    }
+                    int type = random.nextInt(numKill / 30 + 1);
+                    Enemy.this.type[i] = type >= Ship.COUNT ? Ship.COUNT - 1 : type < 0 ? 0 : type;
+                    life[i] = ship.getLife(Enemy.this.type[i]);
+                    lastFire[i] = System.currentTimeMillis();
+                    x[i] = random.nextInt(screenW - Ship.SIZE);
+                    y[i] = -Ship.SIZE;
+                    break;
+                }
+            }
+        }, 2500, 2500);
+    }
+
+    public void deactivateCreator() {
+        createEnemy.cancel();
+    }
+
+    public int getScore() {
+        return score;
+    }
+
+    private void aiLax(int i) {
+        y[i] += ship.getSpeed(type[i]);
+        if (y[i] > screenH) {
+            type[i] = NULL;
+        }
+        if (y[i] > gamer.getY()) {
+            return;
+        }
+        fire(i);
+        if (x[i] > gamer.getX()) {
+            x[i] -= ship.getSpeed(type[i]) / 2;
+        }
+        if (x[i] < gamer.getX()) {
+            x[i] += ship.getSpeed(type[i]) / 2;
+        }
+    }
+
+    private void aiPowerful(int i) {
+        y[i] += ship.getSpeed(type[i]);
+        if (y[i] > screenH) {
+            type[i] = NULL;
+        }
+        if (y[i] > gamer.getY()) {
+            return;
+        }
+        fire(i);
+    }
+
+    private void aiUniversal(int i) {
+        if (y[i] < screenH / 3) {
+            y[i] += ship.getSpeed(type[i]);
+        }
+        fire(i);
+        if (x[i] > gamer.getX()) {
+            x[i] -= ship.getSpeed(type[i]) / 2;
+        }
+        if (x[i] < gamer.getX()) {
+            x[i] += ship.getSpeed(type[i]) / 2;
+        }
+    }
+
+    private void aiStrong(int i) {
+        y[i] += ship.getSpeed(type[i]);
+        if (y[i] > screenH) {
+            type[i] = NULL;
+        }
+        if (y[i] > gamer.getY()) {
+            return;
+        }
+        if (x[i] > gamer.getX()) {
+            x[i] -= ship.getSpeed(type[i]);
+        }
+        if (x[i] < gamer.getX()) {
+            x[i] += ship.getSpeed(type[i]);
+        }
+        final int deltaX = Math.abs(x[i] - gamer.getX());
+        if (deltaX < Ship.SIZE * 2) {
+            fire(i);
+        }
+    }
+
+    private void fire(int i) {
+        if (System.currentTimeMillis() - lastFire[i] > ship.getDeltaFire(type[i])) {
+            gun.fire(Gun.ENEMY, x[i] + 4, y[i] + 38);
+            gun.fire(Gun.ENEMY, x[i] + 30, y[i] + 38);
+            lastFire[i] = System.currentTimeMillis();
+        }
+    }
+}
diff --git a/src/code/kalter/longflight/game/Gamer.java b/src/code/kalter/longflight/game/Gamer.java
new file mode 100644 (file)
index 0000000..1fbc72a
--- /dev/null
@@ -0,0 +1,206 @@
+package code.kalter.longflight.game;
+
+import code.kalter.longflight.ByteArrayInputStream;
+import code.kalter.longflight.Color;
+import code.kalter.longflight.Loader;
+import code.kalter.longflight.LongFlight;
+import code.kalter.longflight.game.bullet.Collisionable;
+import code.kalter.longflight.game.bullet.Gun;
+import code.kalter.longflight.game.explosion.Detonator;
+import code.kalter.longflight.game.ship.Ship;
+import code.kalter.longflight.game.ship.ShipGamer;
+import code.kalter.longflight.rms.RMS;
+import code.kalter.longflight.screen.Game;
+import java.io.IOException;
+import javax.microedition.lcdui.Graphics;
+import javax.microedition.lcdui.Image;
+import javax.microedition.rms.RecordStoreException;
+
+/**
+ * Игрок, и всё связанное с ним
+ *
+ * @author KalterFive
+ */
+public class Gamer implements Collisionable {
+
+    private final int screenW;
+    private final int screenH;
+
+    private final Image nozzle;
+
+    private final ColorEffect colorEffect;
+    private final Detonator detonator;
+    private final ShipGamer ship;
+    private final Gun gun;
+    private boolean alive;
+    private int overheat;
+    private int type;
+    private int life;
+    private int speedX;
+    private int speedY;
+    private int positionX;
+    private int positionY;
+
+    private long lastFireTime;
+
+    public Gamer(int screenW, int screenH, Gun gun, Detonator detonator)
+            throws IOException {
+        this.screenW = screenW;
+        this.screenH = screenH;
+        this.gun = gun;
+        this.detonator = detonator;
+        this.colorEffect = new ColorEffect(Color.WHITE, 2, screenW, screenH);
+        ship = ShipGamer.getInstance();
+        Loader imageLoader = Loader.getInstance();
+        nozzle = imageLoader.getImage("/gfx/ship/nozzle.png");
+    }
+
+    // ставим игрока на своё место
+    public void setNull() {
+        alive = true;
+        lastFireTime = System.currentTimeMillis();
+        speedX = speedY = 0;
+        overheat = 0;
+        positionX = (screenW - Ship.SIZE) / 2;
+        positionY = screenH - 80;
+        try {
+            RMS rms = new RMS("longflight", true);
+            ByteArrayInputStream byteReader = rms.get(1);
+            type = byteReader.readByte();
+            rms.close();
+        } catch (RecordStoreException e) {
+            LongFlight.link.catchException(e);
+        }
+        life = ship.getLife(type);
+    }
+
+    public void paint(Graphics graphics) {
+        if (alive) {
+            graphics.drawImage(ship.getImage(type), positionX, positionY, 0);
+        }
+        if (speedY < 0) {
+            graphics.drawImage(nozzle, positionX + 16, positionY + 36, 0);
+        }
+        colorEffect.paint(graphics);
+    }
+
+    public void update() {
+        // охлаждение
+        overheat -= overheat > 0 ? 1 : 0;
+
+        // перемещение
+        positionX += speedX / ship.getTime(type);
+        positionY += speedY / ship.getTime(type);
+
+        // ограничение перемещения
+        // position x
+        if (positionX < 0) {
+            positionX = 0;
+        } else if (positionX > screenW - Ship.SIZE) {
+            positionX = screenW - Ship.SIZE;
+        }
+        // position y
+        if (positionY < 18) {
+            positionY = 18;
+        } else if (positionY > screenH - Ship.SIZE - 22) {
+            positionY = screenH - Ship.SIZE - 22;
+        }
+        
+        // ускорение стремится к нулю
+        speedX = speedX < 0 ? ++speedX : speedX > 0 ? --speedX : speedX;
+        speedY = speedY < 0 ? ++speedY : speedY > 0 ? --speedY : speedY;
+    }
+
+    // override
+    public boolean isCollisionOfBullet(int bx, int by) {
+        return alive && bx > positionX && bx < positionX + Ship.SIZE && by > positionY && by < positionY + Ship.SIZE;
+    }
+
+    // override
+    public void boomOfBullet() {
+        if (alive) {
+            colorEffect.activate();
+            if (--life < 0) {
+                alive = false;
+                Game.link.stop();
+                detonator.activate(positionX, positionY);
+            }
+        }
+    }
+
+    // override
+    public int getType() {
+        return Gun.GAMER;
+    }
+
+    public void moveLeft() {
+        speedX -= ship.getAcceleration(type);
+        if (speedX < (-ship.getVelocityMax(type))) {
+            speedX = (-ship.getVelocityMax(type));
+        }
+    }
+
+    public void moveRight() {
+        speedX += ship.getAcceleration(type);
+        if (speedX > ship.getVelocityMax(type)) {
+            speedX = ship.getVelocityMax(type);
+        }
+    }
+
+    public void moveUp() {
+        speedY -= ship.getAcceleration(type);
+        if (speedY < (-ship.getVelocityMax(type))) {
+            speedY = (-ship.getVelocityMax(type));
+        }
+    }
+
+    public void moveDown() {
+        speedY += ship.getAcceleration(type);
+        if (speedY > ship.getVelocityMax(type)) {
+            speedY = ship.getVelocityMax(type);
+        }
+    }
+
+    public void fire() {
+        overheat += overheat < 160 ? ship.getSpeedOverheat(type) : 0;
+        if (!isGetFire()) {
+            return;
+        }
+        gun.fire(Gun.GAMER, getX() + 4, getY());
+        gun.fire(Gun.GAMER, getX() + 30, getY());
+    }
+
+    public int getX() {
+        return positionX;
+    }
+
+    public int getY() {
+        return positionY;
+    }
+
+    public int getSpeedX() {
+        return speedX;
+    }
+
+    public int getSpeedY() {
+        return speedY;
+    }
+
+    private boolean isGetFire() {
+        boolean result = false;
+        if (System.currentTimeMillis() - lastFireTime > ship.getDeltaFire(type)) {
+            lastFireTime = System.currentTimeMillis();
+            result = true;
+        }
+        return result && overheat < 160;
+    }
+
+    public int getLife() {
+        return life * 4;
+    }
+
+    public int getOverheat() {
+        int result = overheat / 3;
+        return result > 48 ? 48 : result;
+    }
+}
diff --git a/src/code/kalter/longflight/game/bullet/Collisionable.java b/src/code/kalter/longflight/game/bullet/Collisionable.java
new file mode 100644 (file)
index 0000000..b7d695b
--- /dev/null
@@ -0,0 +1,20 @@
+package code.kalter.longflight.game.bullet;
+
+/**
+ * Для проверки столновений пуль с объектами
+ *
+ * @author KalterFive
+ */
+public interface Collisionable {
+
+    int UP = 0;
+    int DOWN = 1;
+    int LEFT = 2;
+    int RIGHT = 3;
+
+    boolean isCollisionOfBullet(int x, int y);
+
+    int getType();
+
+    void boomOfBullet();
+}
diff --git a/src/code/kalter/longflight/game/bullet/Gun.java b/src/code/kalter/longflight/game/bullet/Gun.java
new file mode 100644 (file)
index 0000000..4d4625a
--- /dev/null
@@ -0,0 +1,15 @@
+package code.kalter.longflight.game.bullet;
+
+/**
+ * Интерфейс для Bullet для стрельбы врагов
+ *
+ * @author KalterFive
+ */
+public interface Gun {
+
+    int GAMER = 0;
+    int ENEMY = 1;
+    int NULL = 666;
+
+    void fire(int t, int x, int y);
+}
diff --git a/src/code/kalter/longflight/game/explosion/Detonator.java b/src/code/kalter/longflight/game/explosion/Detonator.java
new file mode 100644 (file)
index 0000000..10e23b2
--- /dev/null
@@ -0,0 +1,11 @@
+package code.kalter.longflight.game.explosion;
+
+/**
+ * Взрыватель!
+ *
+ * @author KalterFive
+ */
+public interface Detonator {
+
+    void activate(int x, int y);
+}
diff --git a/src/code/kalter/longflight/game/explosion/Explosion.java b/src/code/kalter/longflight/game/explosion/Explosion.java
new file mode 100644 (file)
index 0000000..7d82a2f
--- /dev/null
@@ -0,0 +1,70 @@
+package code.kalter.longflight.game.explosion;
+
+import code.kalter.longflight.Animation;
+import code.kalter.longflight.Loader;
+import java.io.IOException;
+import javax.microedition.lcdui.Graphics;
+import javax.microedition.lcdui.Image;
+
+/**
+ * Не приблежаться, рванёт!
+ *
+ * @author KalterFive
+ */
+public class Explosion implements Detonator {
+
+    public static Explosion createExplosion(String path) throws IOException {
+        final Loader loader = Loader.getInstance();
+        final Image image = loader.getImage(path);
+        return createExplosion(image);
+    }
+
+    public static Explosion createExplosion(Image image) {
+        return new Explosion(image);
+    }
+
+    private static final int MAX = 5;
+    private final Animation[] boom;
+    private final int[] positionX;
+    private final int[] positionY;
+
+    // каждый кадр должен быть квадратным
+    private Explosion(Image explosion) {
+        boom = new Animation[MAX];
+        positionX = new int[MAX];
+        positionY = new int[MAX];
+        for (int i = 0; i < MAX; i++) {
+            boom[i] = Animation.createAnimation(explosion,
+                    explosion.getHeight(), 80);
+        }
+    }
+
+    public void deactivateAll() {
+        for (int i = 0; i < boom.length; i++) {
+            boom[i].stop();
+        }
+    }
+
+    public void activate(int x, int y) {
+        for (int i = 0; i < boom.length; i++) {
+            if (!boom[i].getState()) {
+                boom[i].start();
+                this.positionX[i] = x;
+                this.positionY[i] = y;
+                break;
+            }
+        }
+    }
+
+    public void paint(Graphics graphics) {
+        for (int i = 0; i < boom.length; i++) {
+            boom[i].paint(graphics, positionX[i], positionY[i]);
+        }
+    }
+
+    public void update() {
+        for (int i = 0; i < boom.length; i++) {
+            boom[i].next();
+        }
+    }
+}
diff --git a/src/code/kalter/longflight/game/ship/Ship.java b/src/code/kalter/longflight/game/ship/Ship.java
new file mode 100644 (file)
index 0000000..f01dbd6
--- /dev/null
@@ -0,0 +1,17 @@
+package code.kalter.longflight.game.ship;
+
+/**
+ * Основные константы: типы, количество типов, размер w|h квадратного (!)
+ * кораблика
+ *
+ * @author KalterFive
+ */
+public interface Ship {
+
+    int COUNT = 4;
+    int SIZE = 40;
+    int LAX = 0;
+    int POWERFUL = 1;
+    int UNIVERSAL = 2;
+    int STRONG = 3;
+}
diff --git a/src/code/kalter/longflight/game/ship/ShipEnemy.java b/src/code/kalter/longflight/game/ship/ShipEnemy.java
new file mode 100644 (file)
index 0000000..529cc54
--- /dev/null
@@ -0,0 +1,87 @@
+package code.kalter.longflight.game.ship;
+
+import code.kalter.longflight.Loader;
+import java.io.IOException;
+import javax.microedition.lcdui.Image;
+import javax.microedition.lcdui.game.Sprite;
+
+/**
+ * Свойства всех корабликов врага
+ *
+ * @author KalterFive
+ */
+public class ShipEnemy implements Ship {
+
+    private static ShipEnemy instance;
+
+    public static ShipEnemy getInstance() throws IOException {
+        if (instance == null) {
+            instance = new ShipEnemy();
+        }
+        return instance;
+    }
+
+    private final int[] deltaFire;
+    private final int[] life;
+    private final int[] speed;
+    private final Image[] image;
+
+    private ShipEnemy() throws IOException {
+        deltaFire = new int[4];
+        life = new int[4];
+        speed = new int[4];
+        image = new Image[4];
+
+        Loader imageLoader = Loader.getInstance();
+
+        //TYPE: LAX
+        deltaFire[LAX] = 2000;
+        life[LAX] = 3;
+        speed[LAX] = 2;
+        image[LAX] = imageLoader.getImage("/gfx/ship/" + LAX + ".png");
+        image[LAX] = Image.createImage(image[LAX], 0, 0, 40, 40,
+                Sprite.TRANS_MIRROR_ROT180);
+
+        //TYPE: POWERFUL
+        deltaFire[POWERFUL] = 3000;
+        life[POWERFUL] = 6;
+        speed[POWERFUL] = 1;
+        image[POWERFUL] = imageLoader.getImage("/gfx/ship/" + POWERFUL
+                + ".png");
+        image[POWERFUL] = Image.createImage(image[POWERFUL], 0, 0, 40, 40,
+                Sprite.TRANS_MIRROR_ROT180);
+
+        //TYPE: UNIVERSAL
+        deltaFire[UNIVERSAL] = 3000;
+        life[UNIVERSAL] = 3;
+        speed[UNIVERSAL] = 2;
+        image[UNIVERSAL] = imageLoader.getImage("/gfx/ship/" + UNIVERSAL
+                + ".png");
+        image[UNIVERSAL] = Image.createImage(image[UNIVERSAL], 0, 0, 40, 40,
+                Sprite.TRANS_MIRROR_ROT180);
+
+        //TYPE: STRONG
+        deltaFire[STRONG] = 1500;
+        life[STRONG] = 6;
+        speed[STRONG] = 1;
+        image[STRONG] = imageLoader.getImage("/gfx/ship/" + STRONG + ".png");
+        image[STRONG] = Image.createImage(image[STRONG], 0, 0, 40, 40,
+                Sprite.TRANS_MIRROR_ROT180);
+    }
+
+    public int getDeltaFire(int type) {
+        return deltaFire[type];
+    }
+
+    public int getLife(int type) {
+        return life[type];
+    }
+
+    public int getSpeed(int type) {
+        return speed[type];
+    }
+
+    public Image getImage(int type) {
+        return image[type];
+    }
+}
diff --git a/src/code/kalter/longflight/game/ship/ShipGamer.java b/src/code/kalter/longflight/game/ship/ShipGamer.java
new file mode 100644 (file)
index 0000000..bcfc92d
--- /dev/null
@@ -0,0 +1,109 @@
+package code.kalter.longflight.game.ship;
+
+import code.kalter.longflight.Loader;
+import code.kalter.longflight.LongFlight;
+import java.io.IOException;
+import javax.microedition.lcdui.Image;
+
+/**
+ * Все свойства корабликов игрока
+ *
+ * @author KalterFive
+ */
+public class ShipGamer implements Ship {
+
+    private static ShipGamer instance;
+
+    public static ShipGamer getInstance() throws IOException {
+        if (instance == null) {
+            instance = new ShipGamer();
+        }
+        return instance;
+    }
+
+    private final int[] life;
+    private final int[] time;
+    private final int[] acceleration;
+    private final int[] velocityMax;
+    private final int[] deltaFire;
+    private final int[] speedOverheat;
+    private final Image[] image;
+
+    public ShipGamer() throws IOException {
+        life = new int[COUNT];
+        time = new int[COUNT];
+        acceleration = new int[COUNT];
+        velocityMax = new int[COUNT];
+        deltaFire = new int[COUNT];
+        speedOverheat = new int[COUNT];
+        image = new Image[COUNT];
+
+        Loader imageLoader = Loader.getInstance();
+
+        //TYPE: LAX
+        life[LAX] = 3;
+        time[LAX] = 2;
+        acceleration[LAX] = 2;
+        velocityMax[LAX] = 6;
+        deltaFire[LAX] = 250;
+        speedOverheat[LAX] = 4;
+        image[LAX] = imageLoader.getImage("/gfx/ship/" + LAX + ".png");
+
+        //TYPE: POWERFUL
+        life[POWERFUL] = 10;
+        time[POWERFUL] = 2;
+        acceleration[POWERFUL] = 2;
+        velocityMax[POWERFUL] = 4;
+        deltaFire[POWERFUL] = 300;
+        speedOverheat[POWERFUL] = 4;
+        image[POWERFUL] = imageLoader.getImage("/gfx/ship/" + POWERFUL
+                + ".png");
+
+        //TYPE: UNIVERSAL
+        life[UNIVERSAL] = 5;
+        time[UNIVERSAL] = 2;
+        acceleration[UNIVERSAL] = 2;
+        velocityMax[UNIVERSAL] = 8;
+        deltaFire[UNIVERSAL] = 200;
+        speedOverheat[UNIVERSAL] = 4;
+        image[UNIVERSAL] = imageLoader.getImage("/gfx/ship/" + UNIVERSAL
+                + ".png");
+
+        //TYPE: STRONG
+        life[STRONG] = 6;
+        time[STRONG] = 4;
+        acceleration[STRONG] = 4;
+        velocityMax[STRONG] = 24;
+        deltaFire[STRONG] = 200;
+        speedOverheat[STRONG] = 4;
+        image[STRONG] = imageLoader.getImage("/gfx/ship/" + STRONG + ".png");
+    }
+
+    public int getLife(int type) {
+        return life[type];
+    }
+
+    public int getTime(int type) {
+        return time[type];
+    }
+
+    public int getAcceleration(int type) {
+        return acceleration[type];
+    }
+
+    public int getVelocityMax(int type) {
+        return velocityMax[type];
+    }
+
+    public int getDeltaFire(int type) {
+        return deltaFire[type];
+    }
+
+    public int getSpeedOverheat(int type) {
+        return speedOverheat[type];
+    }
+
+    public Image getImage(int type) {
+        return image[type];
+    }
+}
diff --git a/src/code/kalter/longflight/rms/RMS.java b/src/code/kalter/longflight/rms/RMS.java
new file mode 100644 (file)
index 0000000..c64d97a
--- /dev/null
@@ -0,0 +1,50 @@
+package code.kalter.longflight.rms;
+
+import code.kalter.longflight.ByteArrayInputStream;
+import code.kalter.longflight.ByteArrayOutputStream;
+import javax.microedition.rms.InvalidRecordIDException;
+import javax.microedition.rms.RecordStore;
+import javax.microedition.rms.RecordStoreException;
+
+/**
+ * Удобная работа с RMS
+ *
+ * @author KalterFive
+ */
+public class RMS {
+
+    public final RecordStore recordStore;
+
+    public RMS(String name, boolean createIfRecordStoreNotFound)
+            throws RecordStoreException {
+        recordStore = RecordStore.openRecordStore(name,
+                createIfRecordStoreNotFound);
+    }
+
+    public ByteArrayInputStream get(int id) throws RecordStoreException,
+            RecordNotFoundException {
+        if (recordStore.getNumRecords() < id) {
+            throw new RecordNotFoundException();
+        }
+        return new ByteArrayInputStream(recordStore.getRecord(id));
+    }
+
+    /*
+     * Если запись с номером не будет найдена, то массив байтов запишется в
+     * новую запись, после последней
+     */
+    public void put(int id, ByteArrayOutputStream bytes)
+            throws RecordStoreException {
+        final byte[] array = bytes.toArray();
+        final int length = array.length;
+        try {
+            recordStore.setRecord(id, array, 0, length);
+        } catch (InvalidRecordIDException e) {
+            recordStore.addRecord(array, 0, length);
+        }
+    }
+
+    public void close() throws RecordStoreException {
+        recordStore.closeRecordStore();
+    }
+}
diff --git a/src/code/kalter/longflight/rms/RecordNotFoundException.java b/src/code/kalter/longflight/rms/RecordNotFoundException.java
new file mode 100644 (file)
index 0000000..e0cc709
--- /dev/null
@@ -0,0 +1,11 @@
+package code.kalter.longflight.rms;
+
+import javax.microedition.rms.RecordStoreException;
+
+/**
+ * Формируется в случае, если в хранилище ну будет найдена искомая запись
+ *
+ * @author KalterFive
+ */
+public class RecordNotFoundException extends RecordStoreException {
+}
diff --git a/src/code/kalter/longflight/screen/About.java b/src/code/kalter/longflight/screen/About.java
new file mode 100644 (file)
index 0000000..92ef50f
--- /dev/null
@@ -0,0 +1,139 @@
+package code.kalter.longflight.screen;
+
+import code.kalter.longflight.EventListener;
+import code.kalter.longflight.Loader;
+import code.kalter.longflight.LongFlight;
+import code.kalter.longflight.Sprite;
+import java.io.IOException;
+import javax.microedition.lcdui.Image;
+
+/**
+ * Экран информации об игре
+ *
+ * @author Kalter
+ */
+public class About extends Screen {
+
+    private final Sprite window;
+    private final Sprite leftSoft;
+    private final Sprite rightSoft;
+    private final Image downPanel;
+
+    public About() throws IOException {
+        Loader loader = Loader.getInstance();
+
+        // window
+        Image windowImage = loader.getImage("/gfx/about/window.png");
+        int windowX = (screenW - windowImage.getWidth()) / 2;
+        int windowY = (screenH - windowImage.getHeight()) / 2;
+        window = new Sprite(windowImage, windowX, windowY);
+        window.addEvent(new EventListener() {
+            // override
+            public boolean is() {
+                return window.isEntrySet(getXPressed(), getYPressed());
+            }
+
+            // override
+            public void event() {
+                setScreenMenu();
+            }
+        });
+
+        // left soft
+        Image leftSoftImage = loader.getImage("/gfx/awt/left_soft.png");
+        int leftSoftX = 0;
+        int leftSoftY = screenH - leftSoftImage.getHeight();
+        leftSoft = new Sprite(leftSoftImage, leftSoftX, leftSoftY);
+        leftSoft.addEvent(new EventListener() {
+            // override
+            public boolean is() {
+                return leftSoft.isEntrySet(getXPressed(), getYPressed());
+            }
+
+            // override
+            public void event() {
+                setScreenMenu();
+            }
+        });
+
+        // right soft
+        Image rightSoftImage = loader.getImage("/gfx/awt/right_soft.png");
+        int rightSoftX = screenW - rightSoftImage.getWidth();
+        int rightSoftY = screenH - rightSoftImage.getHeight();
+        rightSoft = new Sprite(rightSoftImage, rightSoftX, rightSoftY);
+        rightSoft.addEvent(new EventListener() {
+            // override
+            public boolean is() {
+                return rightSoft.isEntrySet(getXPressed(), getYPressed());
+            }
+
+            // override
+            public void event() {
+                setScreenMenu();
+            }
+        });
+
+        // down panel
+        downPanel = loader.getImage("/gfx/awt/down_panel.png");
+    }
+
+    // override
+    public void start() {
+        setDate(39, screenH - 9);
+        super.start();
+    }
+
+    // override
+    public void run() {
+        while (getGameLoop()) {
+            fps.process();
+            update();
+            paint();
+            LongFlight.link.sleep(20);
+            fps.max();
+        }
+    }
+
+    // override
+    public void keyPressed(int keyCode) {
+        switch (getGameAction(keyCode)) {
+            case FIRE:
+                keyCode = RIGHT_SOFT;
+                break;
+        }
+        switch (keyCode) {
+            case RIGHT_SOFT:
+            case LEFT_SOFT:
+                setScreenMenu();
+                break;
+        }
+    }
+
+    // override
+    public void pointerPressed(int x, int y) {
+        super.pointerPressed(x, y);
+        leftSoft.exciteEvent();
+        rightSoft.exciteEvent();
+        window.exciteEvent();
+    }
+
+    private void setScreenMenu() {
+        LongFlight.link.setScreen(LongFlight.MENU);
+    }
+
+    private void update() {
+        space.update();
+    }
+
+    private void paint() {
+        space.paint(graphics);
+        window.paint(graphics);
+        for (int i = 0; i < screenW; i += 128) {
+            graphics.drawImage(downPanel, i, screenH - 18, 0);
+        }
+        leftSoft.paint(graphics);
+        rightSoft.paint(graphics);
+        paintDate();
+        flushGraphics();
+    }
+}
diff --git a/src/code/kalter/longflight/screen/Crash.java b/src/code/kalter/longflight/screen/Crash.java
new file mode 100644 (file)
index 0000000..0129813
--- /dev/null
@@ -0,0 +1,127 @@
+package code.kalter.longflight.screen;
+
+import code.kalter.longflight.EventListener;
+import code.kalter.longflight.Loader;
+import code.kalter.longflight.LongFlight;
+import code.kalter.longflight.Sprite;
+import java.io.IOException;
+import javax.microedition.lcdui.Image;
+
+/**
+ * Экран информации о уничтожении
+ *
+ * @author Kalter
+ */
+public class Crash extends Screen {
+
+    private final Sprite window;
+    private final Sprite leftSoft;
+    private final Sprite rightSoft;
+    private final Image downPanel;
+
+    public Crash() throws IOException {
+        Loader loader = Loader.getInstance();
+
+        // window
+        Image windowImage = loader.getImage("/gfx/crash/window.png");
+        int windowX = (screenW - windowImage.getWidth()) / 2;
+        int windowY = (screenH - windowImage.getHeight()) / 2;
+        window = new Sprite(windowImage, windowX, windowY);
+        // здесь для окошка не обрабатываются события
+
+        // right soft
+        Image rightSoftImage = loader.getImage("/gfx/awt/right_soft.png");
+        int rightSoftX = screenW - rightSoftImage.getWidth();
+        int rightSoftY = screenH - rightSoftImage.getHeight();
+        rightSoft = new Sprite(rightSoftImage, rightSoftX, rightSoftY);
+        rightSoft.addEvent(new EventListener() {
+            // override
+            public boolean is() {
+                return rightSoft.isEntrySet(getXPressed(), getYPressed());
+            }
+
+            // override
+            public void event() {
+                keyPressed(LEFT_SOFT);
+            }
+        });
+
+        //left soft
+        Image leftSoftImage = loader.getImage("/gfx/awt/left_soft.png");
+        int leftSoftX = 0;
+        int leftSoftY = screenH - leftSoftImage.getHeight();
+        leftSoft = new Sprite(leftSoftImage, leftSoftX, leftSoftY);
+        leftSoft.addEvent(new EventListener() {
+            // override
+            public boolean is() {
+                return leftSoft.isEntrySet(getXPressed(), getYPressed());
+            }
+
+            // override
+            public void event() {
+                keyPressed(LEFT_SOFT);
+            }
+        });
+
+        // down panel
+        downPanel = loader.getImage("/gfx/awt/down_panel.png");
+    }
+
+    // override
+    public void start() {
+        setDate(39, screenH - 9);
+        super.start();
+    }
+
+    // override
+    public void run() {
+        while (getGameLoop()) {
+            fps.process();
+            update();
+            paint();
+            LongFlight.link.sleep(20);
+            fps.max();
+        }
+    }
+
+    // override
+    public void keyPressed(int keyCode) {
+        switch (getGameAction(keyCode)) {
+            case FIRE:
+                keyCode = LEFT_SOFT;
+                break;
+        }
+        switch (keyCode) {
+            case LEFT_SOFT:
+            case RIGHT_SOFT:
+                LongFlight.link.setScreen(LongFlight.MENU);
+                break;
+        }
+    }
+
+    // override
+    public void pointerPressed(int x, int y) {
+        super.pointerPressed(x, y);
+        window.exciteEvent();
+        rightSoft.exciteEvent();
+        leftSoft.exciteEvent();
+    }
+
+    private void update() {
+        space.update();
+        Game.link.updateElements();
+    }
+
+    private void paint() {
+        space.paint(graphics);
+        Game.link.paintElements(graphics);
+        window.paint(graphics);
+        for (int i = 0; i < screenW; i += downPanel.getWidth()) {
+            graphics.drawImage(downPanel, i, screenH - downPanel.getHeight(), 0);
+        }
+        leftSoft.paint(graphics);
+        rightSoft.paint(graphics);
+        paintDate();
+        flushGraphics();
+    }
+}
diff --git a/src/code/kalter/longflight/screen/EnableSound.java b/src/code/kalter/longflight/screen/EnableSound.java
new file mode 100644 (file)
index 0000000..b8b3773
--- /dev/null
@@ -0,0 +1,213 @@
+package code.kalter.longflight.screen;
+
+import code.kalter.longflight.EventListener;
+import code.kalter.longflight.Loader;
+import code.kalter.longflight.LongFlight;
+import code.kalter.longflight.Sprite;
+import java.io.IOException;
+import javax.microedition.lcdui.Image;
+
+/**
+ * Включение / не включение звука
+ *
+ * @author KalterFive
+ */
+public class EnableSound extends Screen {
+
+    private static final int COUNT = 2; // of choise
+
+    private static final int YES = 0;
+    private static final int NO = 1;
+
+    private int position;
+    private final Sprite window;
+    private final Sprite leftSoft;
+    private final Sprite[] choise;
+    private final Sprite[] selectChoise;
+    private final Image downPanel;
+
+    public EnableSound() throws IOException {
+        position = 0;
+        Loader loader = Loader.getInstance();
+
+        // window
+        Image windowImage = loader.getImage("/gfx/enable_sound/window.png");
+        int windowX = (screenW - windowImage.getWidth()) / 2;
+        int windowY = (screenH - windowImage.getHeight()) / 2;
+        window = new Sprite(windowImage, windowX, windowY);
+
+        // left panel
+        Image leftSoftImage = loader.getImage("/gfx/awt/left_soft.png");
+        int leftSoftX = 0;
+        int leftSoftY = screenH - leftSoftImage.getHeight();
+        leftSoft = new Sprite(leftSoftImage, leftSoftX, leftSoftY);
+        leftSoft.addEvent(new EventListener() {
+            // override
+            public boolean is() {
+                return leftSoft.isEntrySet(getXPressed(), getYPressed());
+            }
+
+            // override
+            public void event() {
+                leftSoftPressed();
+            }
+        });
+
+        // choises
+        Image choiseCrop = loader.getImage("/gfx/enable_sound/choise.png");
+        choise = new Sprite[COUNT];
+        selectChoise = new Sprite[COUNT];
+        for (int i = 0; i < COUNT; i++) {
+            // choise
+            Image c = Image.createImage(choiseCrop, 0, i * 22, 102, 22, 0);
+            int choiseX = (screenW - 102) / 2;
+            int choiseY = window.getY() + 51 + i * 24;
+            choise[i] = new Sprite(c, choiseX, choiseY);
+
+            // selectchoise
+            Image sc = Image.createImage(choiseCrop, 102, i * 22, 102, 22, 0);
+            int selectChoiseX = choise[i].getX();
+            int selectChoiseY = choise[i].getY();
+            selectChoise[i] = new Sprite(sc, selectChoiseX, selectChoiseY);
+        }
+
+        // down panel
+        downPanel = loader.getImage("/gfx/awt/down_panel.png");
+
+        // adding event listener for choise about of "yes"
+        choise[YES].addEvent(new EventListener() {
+            // override
+            public boolean is() {
+                return choise[YES].isEntrySet(getXPressed(), getYPressed());
+            }
+
+            // override
+            public void event() {
+                yes();
+            }
+        });
+        selectChoise[YES].addEvent(choise[YES].getEvent(0));
+
+        // adding event listener for choise about of "no"
+        choise[NO].addEvent(new EventListener() {
+            // override
+            public boolean is() {
+                return choise[NO].isEntrySet(getXPressed(), getYPressed());
+            }
+
+            // override
+            public void event() {
+                no();
+            }
+        });
+        selectChoise[NO].addEvent(choise[NO].getEvent(0));
+    }
+
+    // override
+    public void start() {
+        setDate(39, screenH - 9);
+        super.start();
+    }
+
+    // override
+    public void pointerPressed(int x, int y) {
+        super.pointerPressed(x, y);
+        leftSoft.exciteEvent();
+        choise[YES].exciteEvent();
+        choise[NO].exciteEvent();
+    }
+
+    // override
+    public void keyPressed(int keyCode) {
+        switch (getGameAction(keyCode)) {
+            case UP:
+                upPressed();
+                break;
+
+            case DOWN:
+                downPressed();
+                break;
+
+            case FIRE:
+                firePressed();
+                break;
+        }
+        switch (keyCode) {
+            case LEFT_SOFT:
+                leftSoftPressed();
+                break;
+        }
+    }
+
+    // override
+    public void run() {
+        while (getGameLoop()) {
+            fps.process();
+            update();
+            paint();
+            LongFlight.link.sleep(20);
+            fps.max();
+        }
+        LongFlight.link.setScreen(LongFlight.SPLASH);
+    }
+
+    private void paint() {
+        space.paint(graphics);
+        for (int i = 0; i < screenW; i += 128) {
+            graphics.drawImage(downPanel, i, screenH - 18, 0);
+        }
+        paintDate();
+        leftSoft.paint(graphics);
+        window.paint(graphics);
+        for (int i = 0; i < COUNT; i++) {
+            if (position == i) {
+                selectChoise[i].paint(graphics);
+            } else {
+                choise[i].paint(graphics);
+            }
+        }
+        flushGraphics();
+    }
+
+    private void update() {
+        space.update();
+    }
+
+    private void leftSoftPressed() {
+        firePressed();
+    }
+
+    private void upPressed() {
+        if (--position < 0) {
+            position = 0;
+        }
+    }
+
+    private void downPressed() {
+        if (++position >= COUNT) {
+            position = COUNT - 1;
+        }
+    }
+
+    private void firePressed() {
+        switch (position) {
+            case YES:
+                yes();
+                break;
+
+            case NO:
+                no();
+                break;
+        }
+    }
+
+    private void yes() {
+        choise[YES].removeEvent(0);
+        LongFlight.link.playMusic();
+        stop();
+    }
+
+    private void no() {
+        stop();
+    }
+}
diff --git a/src/code/kalter/longflight/screen/Game.java b/src/code/kalter/longflight/screen/Game.java
new file mode 100644 (file)
index 0000000..905440c
--- /dev/null
@@ -0,0 +1,345 @@
+package code.kalter.longflight.screen;
+
+import code.kalter.longflight.Arrays;
+import code.kalter.longflight.ByteArrayOutputStream;
+import code.kalter.longflight.EventListener;
+import code.kalter.longflight.Loader;
+import code.kalter.longflight.LongFlight;
+import code.kalter.longflight.Sprite;
+import code.kalter.longflight.game.Bullet;
+import code.kalter.longflight.game.Enemy;
+import code.kalter.longflight.game.Gamer;
+import code.kalter.longflight.game.bullet.Collisionable;
+import code.kalter.longflight.game.explosion.Explosion;
+import code.kalter.longflight.rms.RMS;
+import code.kalter.longflight.rms.RecordNotFoundException;
+import java.io.IOException;
+import javax.microedition.lcdui.Graphics;
+import javax.microedition.lcdui.Image;
+import javax.microedition.rms.RecordStoreException;
+
+/**
+ * Игровой экран. Остаётся активным во время паузы и информации о уничтожении. В
+ * меню паузы происходит отрисовка элементов (см. метод
+ * paintElements), а в меню информации о уничтожении происходит и
+ * отрисовка (см. метод updateElements), и обновление, но без
+ * создания новых врагов
+ *
+ * @author KalterFive
+ */
+public class Game extends Screen {
+
+    public static Game link;
+
+    // keys
+    private boolean up;
+    private boolean down;
+    private boolean left;
+    private boolean right;
+    private boolean fire;
+    private boolean pointerPressed;
+
+    private final Gamer gamer;
+    private final Bullet bullet;
+    private final Enemy enemy;
+    private final Explosion explosion;
+
+    private final Sprite rightSoft;
+    private final Sprite lifeStatus;
+    private final Sprite overheatStatus;
+    private final Image downPanel;
+    private final Image upPanel;
+
+    private boolean isPause; // для проверки на переход в меню паузы
+
+    public Game() throws IOException {
+        explosion = Explosion.createExplosion("/gfx/boom.png");
+        bullet = new Bullet(screenH);
+        gamer = new Gamer(screenW, screenH, bullet, explosion);
+        enemy = new Enemy(screenW, screenH, bullet, explosion, gamer);
+        bullet.setCollisionable(new Collisionable[]{gamer, enemy});
+
+        Loader loader = Loader.getInstance();
+
+        // right soft
+        Image rightSoftImage = loader.getImage("/gfx/game/right_soft.png");
+        int rightSoftX = screenW - rightSoftImage.getWidth();
+        int rightSoftY = screenH - rightSoftImage.getHeight();
+        rightSoft = new Sprite(rightSoftImage, rightSoftX, rightSoftY);
+        rightSoft.addEvent(new EventListener() {
+            // override
+            public boolean is() {
+                return rightSoft.isEntrySet(getXPressed(), getYPressed());
+            }
+
+            // override
+            public void event() {
+                rightSoftPressed();
+            }
+        });
+
+        // life status
+        Image lifeStatusImage = loader.getImage("/gfx/game/life.png");
+        int lifeStatusX = 2;
+        int lifeStatusY = screenH - 20;
+        lifeStatus = new Sprite(lifeStatusImage, lifeStatusX, lifeStatusY);
+
+        // overheat status
+        Image overheatStatusImage = loader.getImage("/gfx/game/overheat.png");
+        int overheatStatusX = screenW - overheatStatusImage.getWidth() - 2;
+        int overheatStatusY = screenH - 20;
+        overheatStatus = new Sprite(overheatStatusImage,
+                overheatStatusX, overheatStatusY);
+
+        // up & down panel
+        downPanel = loader.getImage("/gfx/game/down_panel.png");
+        upPanel = loader.getImage("/gfx/game/up_panel.png");
+
+        link = this;
+    }
+
+    // override
+    public void start() {
+        try {
+            up = down = right = left = fire = pointerPressed = false;
+            enemy.activateCreator();
+            if (isPause) {
+                isPause = false;
+                return;
+            }
+            explosion.deactivateAll();
+            gamer.setNull();
+            bullet.setNull();
+            enemy.setNull();
+            setDate(2, screenH - 9);
+        } catch (Exception e) {
+            LongFlight.link.catchException(e);
+        } finally {
+            isPause = false;
+            super.start();
+        }
+    }
+
+    // override
+    public void run() {
+        while (getGameLoop()) {
+            fps.process();
+            paint();
+            checkKey();
+            update();
+            LongFlight.link.sleep(20);
+            fps.max();
+        }
+        if (isPause) {
+            return;
+        }
+        LongFlight.link.$setScreen(LongFlight.CRASH);
+    }
+
+    // override
+    public void keyPressed(int keyCode) {
+        switch (keyCode) {
+            case RIGHT_SOFT:
+                setPauseScreen();
+                break;
+        }
+        switch (getGameAction(keyCode)) {
+            case UP:
+                up = true;
+                break;
+
+            case DOWN:
+                down = true;
+                break;
+
+            case LEFT:
+                left = true;
+                break;
+
+            case RIGHT:
+                right = true;
+                break;
+
+            case FIRE:
+                fire = true;
+                break;
+        }
+    }
+
+    // override
+    public void keyReleased(int keyCode) {
+        switch (getGameAction(keyCode)) {
+            case UP:
+                up = false;
+                break;
+
+            case DOWN:
+                down = false;
+                break;
+
+            case LEFT:
+                left = false;
+                break;
+
+            case RIGHT:
+                right = false;
+                break;
+
+            case FIRE:
+                fire = false;
+                break;
+        }
+    }
+
+    // override
+    public void pointerReleased(int x, int y) {
+        pointerPressed = false;
+    }
+
+    // override
+    public void pointerPressed(int x, int y) {
+        super.pointerPressed(x, y);
+        rightSoft.exciteEvent();
+        pointerPressed = true;
+    }
+
+    // override
+    public void stop() {
+        enemy.deactivateCreator();
+        super.stop();
+    }
+
+    public Explosion getExplosion() {
+        return explosion;
+    }
+
+    public void setNullPause() {
+        isPause = false;
+    }
+
+    public void save() {
+        final int score = enemy.getScore();
+        try {
+            final RMS rms = new RMS("longflight", true);
+            try {
+                final int[] record = rms.get(2).toIntArray(5);
+                for (int i = 0; i < 5; i++) {
+                    if (score > record[i]) {
+                        Arrays.insertShiftRight(record, score, i);
+                        break;
+                    }
+                }
+                saveRecord(rms, record);
+            } catch (RecordNotFoundException e) {
+                saveRecord(rms, new int[]{score, 0, 0, 0, 0});
+            }
+            rms.close();
+        } catch (RecordStoreException e) {
+            LongFlight.link.catchException(e);
+        }
+    }
+
+    private void rightSoftPressed() {
+        setPauseScreen();
+    }
+
+    private void checkKey() {
+        if (pointerPressed) {
+            if (isPointerUp()) {
+                gamer.moveUp();
+            }
+            if (isPointerDown()) {
+                gamer.moveDown();
+            }
+            if (isPointerLeft()) {
+                gamer.moveLeft();
+            }
+            if (isPointerRight()) {
+                gamer.moveRight();
+            }
+            if (isPointerFire()) {
+                gamer.fire();
+            }
+        }
+        if (up) {
+            gamer.moveUp();
+        }
+        if (down) {
+            gamer.moveDown();
+        }
+        if (left) {
+            gamer.moveLeft();
+        }
+        if (right) {
+            gamer.moveRight();
+        }
+        if (fire) {
+            gamer.fire();
+        }
+    }
+
+    private void update() {
+        updateElements();
+        space.update();
+    }
+
+    private void paint() {
+        space.paint(graphics);
+        paintElements(graphics);
+        paintGui();
+        flushGraphics();
+    }
+
+    public void updateElements() {
+        gamer.update();
+        bullet.update();
+        enemy.update();
+        explosion.update();
+    }
+
+    public void paintElements(Graphics graphics) {
+        enemy.paint(graphics);
+        gamer.paint(graphics);
+        bullet.paint(graphics);
+        explosion.paint(graphics);
+    }
+
+    private void paintGui() {
+        // up & down panel
+        for (int i = 0; i < screenW; i += 128) {
+            graphics.drawImage(upPanel, i, 0, 0);
+            graphics.drawImage(downPanel, i, screenH - 27, 0);
+        }
+        overheatStatus.paint(graphics);
+        lifeStatus.paint(graphics);
+        rightSoft.paint(graphics);
+        paintDate();
+        
+        // score
+        font.paint(graphics, "Score: " + enemy.getScore(), 2, 2);
+        
+        // life
+        graphics.setColor(0xBF0B10);
+        graphics.fillRect(4, screenH - 19, gamer.getLife(), 2);
+        graphics.setColor(0x001A27);
+        graphics.fillRect(4 + gamer.getLife(), screenH - 19, 1, 2);
+        
+        // overheat
+        graphics.setColor(0xBFCA10);
+        graphics.fillRect(screenW - 52, screenH - 19, gamer.getOverheat(), 2);
+        graphics.setColor(0x001A27);
+        graphics.fillRect(screenW - 52 + gamer.getOverheat(), screenH - 19,
+                1, 2);
+    }
+
+    private void setPauseScreen() {
+        isPause = true;
+        LongFlight.link.setScreen(LongFlight.PAUSE);
+    }
+
+    private void saveRecord(RMS rms, int[] record) throws RecordStoreException {
+        final ByteArrayOutputStream byteWriter = new ByteArrayOutputStream(20);
+        byteWriter.writeIntArray(record, 5);
+        rms.put(2, byteWriter);
+    }
+}
diff --git a/src/code/kalter/longflight/screen/HighScore.java b/src/code/kalter/longflight/screen/HighScore.java
new file mode 100644 (file)
index 0000000..2cf419d
--- /dev/null
@@ -0,0 +1,160 @@
+package code.kalter.longflight.screen;
+
+import code.kalter.longflight.ByteArrayInputStream;
+import code.kalter.longflight.EventListener;
+import code.kalter.longflight.Loader;
+import code.kalter.longflight.LongFlight;
+import code.kalter.longflight.Sprite;
+import code.kalter.longflight.rms.RMS;
+import code.kalter.longflight.rms.RecordNotFoundException;
+import java.io.IOException;
+import javax.microedition.lcdui.Image;
+import javax.microedition.rms.RecordStoreException;
+
+/**
+ * Экран отображения лучших рекордов
+ *
+ * @author KalterFive
+ */
+public class HighScore extends Screen {
+
+    private String score;
+    private final Sprite window;
+    private final Sprite leftSoft;
+    private final Sprite rightSoft;
+    private final Image downPanel;
+
+    public HighScore() throws IOException {
+        Loader loader = Loader.getInstance();
+
+        // window
+        Image windowImage = loader.getImage("/gfx/hscore/window.png");
+        int windowX = (screenW - windowImage.getWidth()) / 2;
+        int windowY = (screenH - windowImage.getHeight()) / 2;
+        window = new Sprite(windowImage, windowX, windowY);
+        window.addEvent(new EventListener() {
+            // override
+            public boolean is() {
+                return window.isEntrySet(getXPressed(), getYPressed());
+            }
+
+            // override
+            public void event() {
+                setScreenMenu();
+            }
+        });
+
+        // left soft
+        Image leftSoftImage = loader.getImage("/gfx/awt/left_soft.png");
+        int leftSoftX = 0;
+        int leftSoftY = screenH - leftSoftImage.getHeight();
+        leftSoft = new Sprite(leftSoftImage, leftSoftX, leftSoftY);
+        leftSoft.addEvent(new EventListener() {
+            // override
+            public boolean is() {
+                return leftSoft.isEntrySet(getXPressed(), getYPressed());
+            }
+
+            // override
+            public void event() {
+                setScreenMenu();
+            }
+        });
+
+        // right soft
+        Image rightSoftImage = loader.getImage("/gfx/awt/right_soft.png");
+        int rightSoftX = screenW - rightSoftImage.getWidth();
+        int rightSoftY = screenH - rightSoftImage.getHeight();
+        rightSoft = new Sprite(rightSoftImage, rightSoftX, rightSoftY);
+        rightSoft.addEvent(new EventListener() {
+            // override
+            public boolean is() {
+                return rightSoft.isEntrySet(getXPressed(), getYPressed());
+            }
+
+            // override
+            public void event() {
+                setScreenMenu();
+            }
+        });
+
+        // down panel
+        downPanel = loader.getImage("/gfx/awt/down_panel.png");
+    }
+
+    // override
+    public void start() {
+        score = "";
+        try {
+            RMS rms = new RMS("longflight", true);
+            ByteArrayInputStream byteReader = rms.get(2);
+            rms.close();
+            for (int i = 0; i < 5; i++) {
+                score += (i + 1) + ". " + byteReader.readInteger() + "\r\n";
+            }
+        } catch (RecordNotFoundException e) {
+            for (int i = 0; i < 5; i++) {
+                score += (i + 1) + ". 0\r\n";
+            }
+        } catch (RecordStoreException e) {
+            LongFlight.link.catchException(e);
+        }
+        setDate(39, screenH - 9);
+        super.start();
+    }
+
+    // override
+    public void run() {
+        while (getGameLoop()) {
+            fps.process();
+            update();
+            paint();
+            LongFlight.link.sleep(20);
+            fps.max();
+        }
+    }
+
+    // override
+    public void keyPressed(int keyCode) {
+        switch (getGameAction(keyCode)) {
+            case FIRE:
+                keyCode = LEFT_SOFT;
+                break;
+        }
+        switch (keyCode) {
+            case LEFT_SOFT:
+            case RIGHT_SOFT:
+                setScreenMenu();
+                break;
+        }
+    }
+
+    // override
+    public void pointerPressed(int x, int y) {
+        super.pointerPressed(x, y);
+        rightSoft.exciteEvent();
+        leftSoft.exciteEvent();
+        window.exciteEvent();
+    }
+
+    private void setScreenMenu() {
+        LongFlight.link.setScreen(LongFlight.MENU);
+    }
+
+    private void update() {
+        space.update();
+    }
+
+    private void paint() {
+        space.paint(graphics);
+        window.paint(graphics);
+        for (int i = 0; i < screenW; i += 128) {
+            graphics.drawImage(downPanel, i, screenH - 18, 0);
+        }
+        leftSoft.paint(graphics);
+        rightSoft.paint(graphics);
+        font.paint(graphics, score, window.getX() + 10, window.getY() + 37);
+        paintDate();
+        flushGraphics();
+    }
+}
diff --git a/src/code/kalter/longflight/screen/Loading.java b/src/code/kalter/longflight/screen/Loading.java
new file mode 100644 (file)
index 0000000..5309b6b
--- /dev/null
@@ -0,0 +1,99 @@
+package code.kalter.longflight.screen;
+
+import code.kalter.longflight.Loader;
+import code.kalter.longflight.LongFlight;
+import code.kalter.longflight.Quote;
+import code.kalter.longflight.Sprite;
+import code.kalter.longflight.StringReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Random;
+import javax.microedition.lcdui.Image;
+
+/**
+ * Фейковая загрузка
+ *
+ * @author KalterFive
+ */
+public class Loading extends Screen {
+
+    private static final long SLEEP = 8000;
+
+    private final int COUNT; // of quots
+    private final Quote[] quote;
+
+    private final Sprite loading;
+    private int quoteID;
+
+    private long lastTime;
+
+    public Loading() throws IOException {
+        final InputStream file = getClass().getResourceAsStream("/quote.txt");
+        final StringReader reader = new StringReader(file);
+        COUNT = reader.nextInt();
+        quote = new Quote[COUNT];
+        for (int i = 0; i < COUNT; i++) {
+            String q = reader.nextString(); // quote
+            String a = reader.nextString(); // author
+            quote[i] = new Quote(q, a);
+        }
+        reader.close();
+
+        Loader loader = Loader.getInstance();
+
+        // loading
+        Image loadingImage = loader.getImage("/gfx/loading/loading.png");
+        int loadingX = screenW - loadingImage.getWidth();
+        int loadingY = 15;
+        loading = new Sprite(loadingImage, loadingX, loadingY);
+    }
+
+    // override
+    public void start() {
+        lastTime = System.currentTimeMillis();
+        quoteID = new Random().nextInt(COUNT);
+        super.start();
+    }
+
+    // override
+    public void run() {
+        while (getGameLoop()) {
+            fps.process();
+            update();
+            paint();
+            LongFlight.link.sleep(20);
+            fps.max();
+        }
+        LongFlight.link.setScreen(LongFlight.GAME);
+    }
+
+    private void update() {
+        if (System.currentTimeMillis() - lastTime > SLEEP) {
+            stop();
+        }
+    }
+
+    private void paint() {
+        // gfx
+        graphics.setColor(0x002C40);
+        graphics.fillRect(0, 0, screenW, screenH);
+        graphics.setColor(0x004C6F);
+        graphics.fillRect(0, 22, screenW, 2);
+        loading.paint(graphics);
+
+        // quote
+        String quoteText = quote[quoteID].getQuote();
+        int quoteX = 10;
+        int quoteY = 30;
+        int quoteHeight = screenW - 10;
+        font.paint(graphics, quoteText, quoteX, quoteY, quoteHeight);
+
+        // author
+        String author = quote[quoteID].getAuthor();
+        int authorX = 10;
+        int authorY = 18 + quoteY + font.getHeight(quoteText, quoteHeight);
+        int authorHeight = screenW - 10;
+        font.paint(graphics, author, authorX, authorY, authorHeight);
+        flushGraphics();
+    }
+}
diff --git a/src/code/kalter/longflight/screen/Menu.java b/src/code/kalter/longflight/screen/Menu.java
new file mode 100644 (file)
index 0000000..1cd9121
--- /dev/null
@@ -0,0 +1,293 @@
+package code.kalter.longflight.screen;
+
+import code.kalter.longflight.EventListener;
+import code.kalter.longflight.Loader;
+import code.kalter.longflight.LongFlight;
+import code.kalter.longflight.Sprite;
+import java.io.IOException;
+import javax.microedition.lcdui.Image;
+
+/**
+ * Экран главного меню
+ *
+ * @author KalterFive
+ */
+public class Menu extends Screen {
+
+    private static final int COUNT_CHOISE = 3;
+
+    private static final int FIGHT = 0;
+    private static final int HSCORE = 1;
+    private static final int ABOUT = 2;
+
+    private final Sprite[] choise;
+    private final Sprite[] selectChoise;
+    private final Sprite window;
+    private final Sprite leftSoft;
+    private final Sprite rightSoft;
+    private final Image downPanel;
+
+    private int position;
+
+    public Menu() throws IOException {
+        position = 0;
+        Loader loader = Loader.getInstance();
+
+        // window
+        Image windowImage = loader.getImage("/gfx/menu/window.png");
+        int windowX = (screenW - windowImage.getWidth()) / 2;
+        int windowY = (screenH - windowImage.getHeight()) / 2;
+        window = new Sprite(windowImage, windowX, windowY);
+        //===========================================================[Пасхалка]
+        window.addEvent(new EventListener() {
+            // override
+            public boolean is() {
+                return (getXReleased() > getXPressed())
+                        && (window.isEntrySet(getXPressed(), getYPressed()))
+                        && (window.isEntrySet(getXReleased(), getYReleased()))
+                        && (Math.abs(getXPressed() - getXReleased())
+                                > window.getWidth() / 2);
+            }
+
+            // override
+            public void event() {
+                space.activateEgg();
+            }
+        });
+
+        // left panel
+        Image leftSoftImage = loader.getImage("/gfx/awt/left_soft.png");
+        int leftSoftX = 0;
+        int leftSoftY = screenH - leftSoftImage.getHeight();
+        leftSoft = new Sprite(leftSoftImage, leftSoftX, leftSoftY);
+        leftSoft.addEvent(new EventListener() {
+            // override
+            public boolean is() {
+                return leftSoft.isEntrySet(getXPressed(), getYPressed());
+            }
+
+            // override
+            public void event() {
+                leftSoftPressed();
+            }
+        });
+
+        // right panel
+        Image rightSoftImage = loader.getImage("/gfx/awt/right_soft.png");
+        int rightSoftX = screenW - rightSoftImage.getWidth();
+        int rightSoftY = screenH - rightSoftImage.getHeight();
+        rightSoft = new Sprite(rightSoftImage, rightSoftX, rightSoftY);
+        rightSoft.addEvent(new EventListener() {
+            // override
+            public boolean is() {
+                return rightSoft.isEntrySet(getXPressed(), getYPressed());
+            }
+
+            // override
+            public void event() {
+                rightSoftPressed();
+            }
+        });
+
+        // down panel
+        downPanel = loader.getImage("/gfx/awt/down_panel.png");
+
+        // choises
+        Image choiseCrop = loader.getImage("/gfx/menu/choise.png");
+        choise = new Sprite[COUNT_CHOISE];
+        selectChoise = new Sprite[COUNT_CHOISE];
+        for (int i = 0; i < COUNT_CHOISE; i++) {
+            // choise
+            Image c = Image.createImage(choiseCrop, 0, i * 22, 102, 22, 0);
+            int choiseX = (screenW - 102) / 2;
+            int choiseY = window.getY() + 34 + i * 24;
+            choise[i] = new Sprite(c, choiseX, choiseY);
+
+            // selectchoise
+            Image sc = Image.createImage(choiseCrop, 102, i * 22, 102, 22, 0);
+            int selectChoiseX = choise[i].getX();
+            int selectChoiseY = choise[i].getY();
+            selectChoise[i] = new Sprite(sc, selectChoiseX, selectChoiseY);
+        }
+
+        // adding event listener for choise about of "fight"
+        choise[FIGHT].addEvent(new EventListener() {
+            // override
+            public boolean is() {
+                return choise[FIGHT].isEntrySet(getXPressed(), getYPressed());
+            }
+
+            // override
+            public void event() {
+                position = FIGHT;
+                firePressed();
+            }
+        });
+        selectChoise[FIGHT].addEvent(choise[FIGHT].getEvent(0));
+
+        // adding event listener for choise about of "high score"
+        choise[HSCORE].addEvent(new EventListener() {
+            // override
+            public boolean is() {
+                return choise[HSCORE].isEntrySet(getXPressed(), getYPressed());
+            }
+
+            // override
+            public void event() {
+                position = HSCORE;
+                firePressed();
+            }
+        });
+        selectChoise[HSCORE].addEvent(choise[HSCORE].getEvent(0));
+
+        // adding event listener for choise about of "about"
+        choise[ABOUT].addEvent(new EventListener() {
+            // override
+            public boolean is() {
+                return choise[ABOUT].isEntrySet(getXPressed(), getYPressed());
+            }
+
+            // override
+            public void event() {
+                position = ABOUT;
+                firePressed();
+            }
+        });
+        selectChoise[ABOUT].addEvent(choise[ABOUT].getEvent(0));
+    }
+
+    // override
+    public void start() {
+        final int previosScreenID = LongFlight.link.getPreviosScreenID();
+        if (previosScreenID == LongFlight.CRASH
+                || previosScreenID == LongFlight.PAUSE) {
+            Game.link.save();
+        }
+        setDate(39, screenH - 9);
+        super.start();
+    }
+
+    // override
+    public void run() {
+        while (getGameLoop()) {
+            fps.process();
+            update();
+            paint();
+            LongFlight.link.sleep(20);
+            fps.max();
+        }
+    }
+
+    // override
+    public void keyPressed(int keyCode) {
+        switch (getGameAction(keyCode)) {
+            case UP:
+                upPressed();
+                break;
+
+            case DOWN:
+                downPressed();
+                break;
+
+            case FIRE:
+                firePressed();
+                break;
+        }
+        switch (keyCode) {
+            case RIGHT_SOFT:
+                rightSoftPressed();
+                break;
+
+            case LEFT_SOFT:
+                leftSoftPressed();
+                break;
+        }
+    }
+
+    // override
+    public void keyReleased(int keyCode) {
+        switch (keyCode) {
+            //=======================================================[Пасхалка]
+            case KEY_NUM0:
+                space.activateEgg();
+                break;
+        }
+    }
+
+    // override
+    public void pointerReleased(int x, int y) {
+        super.pointerReleased(x, y);
+        window.exciteEvent();
+    }
+
+    // override
+    public void pointerPressed(int x, int y) {
+        super.pointerPressed(x, y);
+        rightSoft.exciteEvent();
+        leftSoft.exciteEvent();
+        choise[FIGHT].exciteEvent();
+        choise[HSCORE].exciteEvent();
+        choise[ABOUT].exciteEvent();
+    }
+
+    private void upPressed() {
+        position--;
+        if (position < 0) {
+            position = 0;
+        }
+    }
+
+    private void downPressed() {
+        position++;
+        if (position >= COUNT_CHOISE) {
+            position = COUNT_CHOISE - 1;
+        }
+    }
+
+    private void firePressed() {
+        leftSoftPressed();
+    }
+
+    private void rightSoftPressed() {
+        LongFlight.link.destroyApp(true);
+    }
+
+    private void leftSoftPressed() {
+        switch (position) {
+            case FIGHT:
+                LongFlight.link.setScreen(LongFlight.SELECT_SHIP);
+                break;
+
+            case HSCORE:
+                LongFlight.link.setScreen(LongFlight.HIGH_SCORE);
+                break;
+
+            case ABOUT:
+                LongFlight.link.setScreen(LongFlight.ABOUT);
+                break;
+        }
+    }
+
+    private void update() {
+        space.update();
+    }
+
+    private void paint() {
+        space.paint(graphics);
+        window.paint(graphics);
+        for (int i = 0; i < COUNT_CHOISE; i++) {
+            if (i == position) {
+                selectChoise[i].paint(graphics);
+            } else {
+                choise[i].paint(graphics);
+            }
+        }
+        for (int i = 0; i < screenW; i += 128) {
+            graphics.drawImage(downPanel, i, screenH - 18, 0);
+        }
+        leftSoft.paint(graphics);
+        rightSoft.paint(graphics);
+        paintDate();
+        flushGraphics();
+    }
+}
diff --git a/src/code/kalter/longflight/screen/Pause.java b/src/code/kalter/longflight/screen/Pause.java
new file mode 100644 (file)
index 0000000..7a5e536
--- /dev/null
@@ -0,0 +1,243 @@
+package code.kalter.longflight.screen;
+
+import code.kalter.longflight.EventListener;
+import code.kalter.longflight.Loader;
+import code.kalter.longflight.LongFlight;
+import code.kalter.longflight.Sprite;
+import java.io.IOException;
+import javax.microedition.lcdui.Image;
+
+/**
+ * Специальный экран, предназначенный для временной задержки действующего экрана
+ * и одновременным контактом с пользователем. Жёстко привязан к игровому экрану
+ *
+ * @author KalterFive
+ */
+public class Pause extends Screen {
+
+    private static final int COUNT = 2; //choise
+
+    private static final int FIGHT = 0;
+    private static final int MENU = 1;
+
+    private final Sprite[] choise;
+    private final Sprite[] selectChoise;
+    private final Sprite window;
+    private final Sprite leftSoft;
+    private final Sprite rightSoft;
+    private final Image downPanel;
+
+    private int position;
+
+    public Pause() throws IOException {
+        position = 0;
+        Loader loader = Loader.getInstance();
+
+        // window
+        Image windowImage = loader.getImage("/gfx/pause/window.png");
+        int windowX = (screenW - windowImage.getWidth()) / 2;
+        int windowY = (screenH - windowImage.getHeight()) / 2;
+        window = new Sprite(windowImage, windowX, windowY);
+
+        // right soft
+        Image rightSoftImage = loader.getImage("/gfx/awt/right_soft.png");
+        int rightSoftX = screenW - rightSoftImage.getWidth();
+        int rightSoftY = screenH - rightSoftImage.getHeight();
+        rightSoft = new Sprite(rightSoftImage, rightSoftX, rightSoftY);
+        rightSoft.addEvent(new EventListener() {
+            // override
+            public boolean is() {
+                return rightSoft.isEntrySet(getXPressed(), getYPressed());
+            }
+
+            // override
+            public void event() {
+                rightSoftPressed();
+            }
+        });
+
+        // left soft
+        Image leftSoftImage = loader.getImage("/gfx/awt/left_soft.png");
+        int leftSoftX = 0;
+        int leftSoftY = screenH - leftSoftImage.getHeight();
+        leftSoft = new Sprite(leftSoftImage, leftSoftX, leftSoftY);
+        leftSoft.addEvent(new EventListener() {
+            // override
+            public boolean is() {
+                return leftSoft.isEntrySet(getXPressed(), getYPressed());
+            }
+
+            // override
+            public void event() {
+                leftSoftPressed();
+            }
+        });
+
+        // down panel
+        downPanel = loader.getImage("/gfx/awt/down_panel.png");
+
+        // choises
+        Image choiseCrop = loader.getImage("/gfx/pause/choise.png");
+        choise = new Sprite[COUNT];
+        selectChoise = new Sprite[COUNT];
+        for (int i = 0; i < COUNT; i++) {
+            // choise
+            Image c = Image.createImage(choiseCrop, 0, i * 22, 102, 22, 0);
+            int choiseX = (screenW - 102) / 2;
+            int choiseY = window.getY() + 34 + i * 24;
+            choise[i] = new Sprite(c, choiseX, choiseY);
+
+            // selectchoise
+            Image sc = Image.createImage(choiseCrop, 102, i * 22, 102, 22, 0);
+            int selectChoiseX = choise[i].getX();
+            int selectChoiseY = choise[i].getY();
+            selectChoise[i] = new Sprite(sc, selectChoiseX, selectChoiseY);
+        }
+
+        // adding event listener for choise about of "fight"
+        choise[FIGHT].addEvent(new EventListener() {
+            // override
+            public boolean is() {
+                return choise[FIGHT].isEntrySet(getXPressed(), getYPressed());
+            }
+
+            // override
+            public void event() {
+                position = FIGHT;
+                firePressed();
+            }
+        });
+
+        // adding event listener for choise about of "menu"
+        choise[MENU].addEvent(new EventListener() {
+            // override
+            public boolean is() {
+                return choise[MENU].isEntrySet(getXPressed(), getYPressed());
+            }
+
+            // override
+            public void event() {
+                position = MENU;
+                firePressed();
+            }
+        });
+    }
+
+    //override
+    public void run() {
+        while (getGameLoop()) {
+            fps.process();
+            update();
+            paint();
+            LongFlight.link.sleep(20);
+            fps.max();
+        }
+    }
+
+    // override
+    public void start() {
+        setDate(39, screenH - 9);
+        super.start();
+    }
+
+    // override
+    public void keyPressed(int keyCode) {
+        switch (getGameAction(keyCode)) {
+            case UP:
+                upPressed();
+                break;
+
+            case DOWN:
+                downPressed();
+                break;
+
+            case FIRE:
+                firePressed();
+                break;
+        }
+        switch (keyCode) {
+            case LEFT_SOFT:
+                leftSoftPressed();
+                break;
+
+            case RIGHT_SOFT:
+                rightSoftPressed();
+                break;
+        }
+    }
+
+    // override
+    public void pointerPressed(int x, int y) {
+        super.pointerPressed(x, y);
+        leftSoft.exciteEvent();
+        rightSoft.exciteEvent();
+        choise[FIGHT].exciteEvent();
+        choise[MENU].exciteEvent();
+    }
+
+    private void upPressed() {
+        if (--position < 0) {
+            position = 0;
+        }
+    }
+
+    private void downPressed() {
+        if (++position >= COUNT) {
+            position = COUNT - 1;
+        }
+    }
+
+    private void leftSoftPressed() {
+        firePressed();
+    }
+
+    private void rightSoftPressed() {
+        position = FIGHT;
+        firePressed();
+    }
+
+    private void firePressed() {
+        switch (position) {
+            case FIGHT:
+                LongFlight.link.setScreen(LongFlight.GAME);
+                break;
+
+            case MENU:
+                Game.link.setNullPause();
+                LongFlight.link.setScreen(LongFlight.MENU);
+                break;
+        }
+    }
+
+    private void update() {
+        space.update();
+    }
+
+    private void paint() {
+        space.paint(graphics);
+        Game.link.paintElements(graphics);
+        window.paint(graphics);
+        paintChoise();
+        paintDownPanel();
+        leftSoft.paint(graphics);
+        rightSoft.paint(graphics);
+        paintDate();
+        flushGraphics();
+    }
+
+    private void paintChoise() {
+        for (int i = 0; i < COUNT; i++) {
+            if (i == position) {
+                selectChoise[i].paint(graphics);
+            } else {
+                choise[i].paint(graphics);
+            }
+        }
+    }
+
+    private void paintDownPanel() {
+        for (int i = 0; i < screenW; i += 128) {
+            graphics.drawImage(downPanel, i, screenH - 18, 0);
+        }
+    }
+}
diff --git a/src/code/kalter/longflight/screen/Screen.java b/src/code/kalter/longflight/screen/Screen.java
new file mode 100644 (file)
index 0000000..012f043
--- /dev/null
@@ -0,0 +1,143 @@
+package code.kalter.longflight.screen;
+
+import code.kalter.longflight.Area;
+import code.kalter.longflight.FPS;
+import code.kalter.longflight.Font;
+import code.kalter.longflight.Pointer;
+import code.kalter.longflight.Time;
+import code.kalter.longflight.space.Space;
+import java.io.IOException;
+import javax.microedition.lcdui.Graphics;
+import javax.microedition.lcdui.game.GameCanvas;
+
+/**
+ * Абстрактный класс для всех экранов
+ *
+ * @author KalterFive
+ */
+public abstract class Screen extends GameCanvas implements Runnable {
+
+    // софт-кнопки
+    public final int LEFT_SOFT = -6;
+    public final int RIGHT_SOFT = -7;
+
+    // некоторые свойства, характерные каждому экрану
+    protected final Graphics graphics;
+    protected final FPS fps;
+    protected final Space space;
+    protected final Font font;
+    protected final int screenW;
+    protected final int screenH;
+
+    // нажатие и области нажатия
+    private final Pointer pointer;
+    private final Area upArea;
+    private final Area downArea;
+    private final Area leftArea;
+    private final Area rightArea;
+    private final Area fireArea;
+    
+    // текущее время и его координаты
+    private final Time time;
+    private int timeXPosition;
+    private int timeYPosition;
+
+    private Thread thread;
+    protected boolean gameLoop;
+
+    public Screen() throws IOException {
+        super(false);
+        setFullScreenMode(true);
+        graphics = getGraphics();
+        screenW = getWidth();
+        screenH = getHeight();
+        fps = FPS.getInstance(30);
+        space = Space.getInstance(screenW, screenH);
+        font = Font.getInstance();
+        time = Time.getInstance(60000);
+        pointer = new Pointer();
+        upArea = new Area(screenW / 3, 0, screenW - screenW / 3, screenH / 3);
+        downArea = new Area(screenW / 3, screenH - screenH / 3,
+                screenW - screenW / 3, screenH);
+        leftArea = new Area(0, 0, screenW / 3, screenH);
+        rightArea = new Area(screenW - screenW / 3, 0, screenW, screenH);
+        fireArea = new Area(screenW / 3, screenH / 3,
+                screenW - screenW / 3, screenH - screenH / 3);
+    }
+
+    public void start() {
+        showNotify();
+        space.paint(graphics);
+        gameLoop = true;
+        thread = new Thread(this);
+        thread.start();
+    }
+
+    public void stop() {
+        hideNotify();
+        gameLoop = false;
+    }
+
+    // override
+    public void pointerPressed(int x, int y) {
+        pointer.setPressed(x, y);
+    }
+
+    // override
+    public void pointerReleased(int x, int y) {
+        pointer.setReleased(x, y);
+    }
+
+    public final boolean getGameLoop() {
+        return gameLoop;
+    }
+
+    public int getXPressed() {
+        return pointer.getXPressed();
+    }
+
+    public int getYPressed() {
+        return pointer.getYPressed();
+    }
+
+    public int getXReleased() {
+        return pointer.getXReleased();
+    }
+
+    public int getYReleased() {
+        return pointer.getYReleased();
+    }
+
+    public boolean isPointerUp() {
+        return isPointerArea(upArea);
+    }
+
+    public boolean isPointerDown() {
+        return isPointerArea(downArea);
+    }
+
+    public boolean isPointerLeft() {
+        return isPointerArea(leftArea);
+    }
+
+    public boolean isPointerRight() {
+        return isPointerArea(rightArea);
+    }
+
+    public boolean isPointerFire() {
+        return isPointerArea(fireArea);
+    }
+
+    public boolean isPointerArea(Area area) {
+        return area.isEntry(pointer.getXPressed(), pointer.getYPressed());
+    }
+
+    protected final void setDate(int x, int y) {
+        this.timeXPosition = x;
+        this.timeYPosition = y;
+    }
+
+    protected final void paintDate() {
+        font.paint(graphics, time.toString(), timeXPosition, timeYPosition);
+    }
+}
diff --git a/src/code/kalter/longflight/screen/SelectShip.java b/src/code/kalter/longflight/screen/SelectShip.java
new file mode 100644 (file)
index 0000000..5af5185
--- /dev/null
@@ -0,0 +1,292 @@
+package code.kalter.longflight.screen;
+
+import code.kalter.longflight.ByteArrayOutputStream;
+import code.kalter.longflight.EventListener;
+import code.kalter.longflight.Loader;
+import code.kalter.longflight.LongFlight;
+import code.kalter.longflight.Sprite;
+import code.kalter.longflight.game.ship.Ship;
+import code.kalter.longflight.game.ship.ShipGamer;
+import code.kalter.longflight.rms.RMS;
+import java.io.IOException;
+import javax.microedition.lcdui.Image;
+import javax.microedition.rms.RecordStoreException;
+
+/**
+ * Выбор кораблика
+ *
+ * @author KalterFive
+ */
+public class SelectShip extends Screen {
+
+    private int position;
+    private final Sprite window;
+    private final Sprite frame;
+    private final Sprite leftSoft;
+    private final Sprite rightSoft;
+    private final Sprite[] leftButton;
+    private final Sprite[] rightButton;
+    private final Sprite[] ship;
+    private final Image downPanel;
+
+    public SelectShip() throws IOException {
+        Loader loader = Loader.getInstance();
+
+        // window
+        Image windowImage = loader.getImage("/gfx/select_ship/window.png");
+        int windowX = (screenW - windowImage.getWidth()) / 2;
+        int windowY = (screenH - windowImage.getHeight()) / 2;
+        window = new Sprite(windowImage, windowX, windowY);
+        window.addEvent(new EventListener() {
+            // override
+            public boolean is() {
+                return window.isEntrySet(getXPressed(), getYPressed())
+                        && getXPressed() == getXReleased()
+                        && getYPressed() == getYReleased();
+            }
+
+            // override
+            public void event() {
+                firePressed();
+            }
+        });
+        window.addEvent(new EventListener() {
+            // override
+            public boolean is() {
+                return window.isEntrySet(getXPressed(), getYPressed())
+                        && window.isEntrySet(getXReleased(), getYReleased())
+                        && Math.abs(getXReleased() - getXPressed()) > 50
+                        && Math.abs(getYReleased() - getYPressed()) < 50;
+            }
+
+            // override
+            public void event() {
+                if (getXPressed() < getXReleased()) {
+                    leftPressed();
+                }
+                if (getXPressed() > getXReleased()) {
+                    rightPressed();
+                }
+            }
+        });
+
+        // left soft
+        Image leftSoftImage = loader.getImage("/gfx/awt/left_soft.png");
+        int leftSoftX = 0;
+        int leftSoftY = screenH - leftSoftImage.getHeight();
+        leftSoft = new Sprite(leftSoftImage, leftSoftX, leftSoftY);
+        leftSoft.addEvent(new EventListener() {
+            // override
+            public boolean is() {
+                return leftSoft.isEntrySet(getXPressed(), getYPressed());
+            }
+
+            // override
+            public void event() {
+                leftSoftPressed();
+            }
+        });
+
+        // right soft
+        Image rightSoftImage = loader.getImage("/gfx/awt/right_soft.png");
+        int rightSoftX = screenW - rightSoftImage.getWidth();
+        int rightSoftY = screenH - rightSoftImage.getHeight();
+        rightSoft = new Sprite(rightSoftImage, rightSoftX, rightSoftY);
+        rightSoft.addEvent(new EventListener() {
+            // override
+            public boolean is() {
+                return rightSoft.isEntrySet(getXPressed(), getYPressed());
+            }
+
+            // override
+            public void event() {
+                rightSoftPressed();
+            }
+        });
+
+        // down panel
+        downPanel = loader.getImage("/gfx/awt/down_panel.png");
+
+        // frame
+        Image frameImage = loader.getImage("/gfx/select_ship/frame.png");
+        int frameX = window.getX()
+                + (window.getWidth() - frameImage.getWidth()) / 2;
+        int frameY = window.getY() + 14
+                + (window.getHeight() - frameImage.getHeight()) / 2;
+        frame = new Sprite(frameImage, frameX, frameY);
+
+        // ships
+        ship = new Sprite[4];
+        for (int i = 0; i < Ship.COUNT; i++) {
+            Image shipImage = ShipGamer.getInstance().getImage(i);
+            int shipX = frame.getX()
+                    + (frame.getWidth() - shipImage.getWidth()) / 2;
+            int shipY = frame.getY()
+                    + (frame.getHeight() - shipImage.getHeight()) / 2;
+            ship[i] = new Sprite(shipImage, shipX, shipY);
+        }
+
+        // left / right buttons
+        Image button = loader.getImage("/gfx/select_ship/lr_button.png");
+        leftButton = new Sprite[2];
+        rightButton = new Sprite[2];
+
+        // left button
+        Image leftButtonImage = Image.createImage(button, 0, 0, 6, 11, 0);
+        int leftButtonX = window.getX() + 15;
+        int leftButtonY = frame.getY() + (frame.getHeight() - 11) / 2;
+        leftButton[0] = new Sprite(leftButtonImage, leftButtonX, leftButtonY);
+
+        // select left button
+        Image selectLeftButtonImage = Image.createImage(button, 0, 11,
+                6, 11, 0);
+        int selectLeftButtonX = leftButton[0].getX();
+        int selectLeftButtonY = leftButton[0].getY();
+        leftButton[1] = new Sprite(selectLeftButtonImage,
+                selectLeftButtonX, selectLeftButtonY);
+
+        // right button
+        Image rightButtonImage = Image.createImage(button, 6, 0, 6, 11, 0);
+        int rightButtonX = window.getX() + window.getWidth() - 21;
+        int rightButtonY = frame.getY() + (frame.getHeight() - 11) / 2;
+        rightButton[0] = new Sprite(rightButtonImage, 
+                rightButtonX, rightButtonY);
+
+        // select right button
+        Image selectRightButtonImage = Image.createImage(button, 6, 11,
+                6, 11, 0);
+        int selectRightButtonX = rightButton[0].getX();
+        int selectRightButtonY = rightButton[0].getY();
+        rightButton[1] = new Sprite(selectRightButtonImage,
+                selectRightButtonX, selectRightButtonY);
+    }
+
+    // override
+    public void start() {
+        position = 0;
+        setDate(39, screenH - 9);
+        super.start();
+    }
+
+    // override
+    public void stop() {
+        super.stop();
+    }
+
+    // override
+    public void run() {
+        while (getGameLoop()) {
+            fps.process();
+            update();
+            paint();
+            LongFlight.link.sleep(20);
+            fps.max();
+        }
+    }
+
+    // override
+    public void keyPressed(int keyCode) {
+        switch (getGameAction(keyCode)) {
+            case LEFT:
+                leftPressed();
+                break;
+
+            case RIGHT:
+                rightPressed();
+                break;
+
+            case FIRE:
+                firePressed();
+                break;
+        }
+        switch (keyCode) {
+            case RIGHT_SOFT:
+                rightSoftPressed();
+                break;
+
+            case LEFT_SOFT:
+                leftSoftPressed();
+                break;
+        }
+    }
+
+    // override
+    public void pointerPressed(int x, int y) {
+        super.pointerPressed(x, y);
+        rightSoft.exciteEvent();
+        leftSoft.exciteEvent();
+    }
+
+    // override
+    public void pointerReleased(int x, int y) {
+        super.pointerReleased(x, y);
+        window.exciteEvent();
+    }
+
+    private void leftPressed() {
+        if (--position < 0) {
+            position = Ship.COUNT - 1;