Initial
This commit is contained in:
commit
32c727a3db
83
build.xml
Normal file
83
build.xml
Normal file
@ -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="SensorBalls" 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>
|
1368
nbproject/build-impl.xml
Normal file
1368
nbproject/build-impl.xml
Normal file
File diff suppressed because it is too large
Load Diff
8
nbproject/genfiles.properties
Normal file
8
nbproject/genfiles.properties
Normal file
@ -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=4d28f8ef
|
||||
build.xml.script.CRC32=be49422b
|
||||
build.xml.stylesheet.CRC32=03eab09b
|
||||
nbproject/build-impl.xml.data.CRC32=4d28f8ef
|
||||
nbproject/build-impl.xml.script.CRC32=69b85b0f
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=a4fc63f1
|
8
nbproject/private/private.properties
Normal file
8
nbproject/private/private.properties
Normal file
@ -0,0 +1,8 @@
|
||||
#Sun Jun 20 10:53:31 EEST 2010
|
||||
netbeans.user=C\:\\Users\\aNNiMON\\.netbeans\\6.9m1
|
||||
javadoc.preview=true
|
||||
file.reference.jsr256.jar=D\:\\Program Files\\Sony Ericsson\\JavaME_SDK_CLDC\\WTK2\\lib\\jsr256.jar
|
||||
config.active=
|
||||
deployment.counter=82
|
||||
app-version.autoincrement=true
|
||||
deployment.number=0.0.81
|
4
nbproject/private/private.xml
Normal file
4
nbproject/private/private.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?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/1"/>
|
||||
</project-private>
|
140
nbproject/project.properties
Normal file
140
nbproject/project.properties
Normal file
@ -0,0 +1,140 @@
|
||||
abilities=MMAPI=1.1,SATSAJCRMI=1.0,SATSACRYPTO=1.0,JSR82=1.1,NOKIAUI=1.0,JSR226=1.0,MIDP=2.1,JSR229=1.1.0,SATSAAPDU=1.0,CLDC=1.1,JSR177=1.0,JSR179=1.0.1,J2MEWS=1.0,VSCL=2.1,WMA=2.0,JSR172=1.0,SEMC_EXT_JP8=1.0,ColorScreen,OBEX=1.0,NokiaUI=1.0,JSR238=1.0,JSR239=1.0,JSR211=1.0,JSR234=1.0,ScreenWidth=240,lib/semc_ext_jp8.jar=1.0,MascotV3=1.0,JSR75=1.0,JSR184=1.1,SATSAPKI=1.0,ScreenHeight=321,ScreenColorDepth=8,JSR180=1.0.1,J2MEXMLRPC=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
|
||||
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=SensorVisualizer_v1_2.jad
|
||||
dist.jar=SensorVisualizer_v1_2.jar
|
||||
dist.javadoc.dir=${dist.dir}/doc
|
||||
dist.root.dir=dist
|
||||
extra.classpath=${file.reference.jsr256.jar}
|
||||
filter.exclude.tests=false
|
||||
filter.excludes=
|
||||
filter.more.excludes=**/overview.html,**/package.html
|
||||
filter.use.standard=true
|
||||
jar.compress=true
|
||||
javac.debug=true
|
||||
javac.deprecation=false
|
||||
javac.encoding=windows-1251
|
||||
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=${file.reference.jsr256.jar}
|
||||
main.class=
|
||||
main.class.class=applet
|
||||
manifest.apipermissions=
|
||||
manifest.file=manifest.mf
|
||||
manifest.jad=
|
||||
manifest.manifest=
|
||||
manifest.midlets=MIDlet-1: SensorVisualizer, /icon.png, SensorVisualizer\n
|
||||
manifest.others=MIDlet-Vendor: aNNiMON\nSEMC-StandbyApplication: Y\nMIDlet-Name: SensorVisualizer\nSEMC-Screen-Size: 240,320\nMIDlet-Version: 1.2\n
|
||||
manifest.pushregistry=
|
||||
name=SensorBalls
|
||||
no.dependencies=false
|
||||
nokiaS80.application.icon=
|
||||
nsicom.application.monitorhost=
|
||||
nsicom.application.runremote=
|
||||
nsicom.application.runverbose=
|
||||
nsicom.remoteapp.location=\\My Documents\\NetBeans Applications
|
||||
nsicom.remotevm.location=\\Windows\\creme\\bin\\CrEme.exe
|
||||
obfuscated.classes.dir=${build.dir}/obfuscated
|
||||
obfuscation.custom=-keep public class * extends javax.microedition.midlet.MIDlet \n-obfuscationdictionary compact.txt\n-dontusemixedcaseclassnames
|
||||
obfuscation.level=1
|
||||
obfuscator.destjar=${build.dir}/obfuscated.jar
|
||||
obfuscator.srcjar=${build.dir}/before-obfuscation.jar
|
||||
platform.active=Sony_Ericsson_SDK_2_5_0_4_for_the_Java_TM__ME_Platform_Emulator_
|
||||
platform.active.description=Sony Ericsson SDK 2.5.0.4 for the Java(TM) ME Platform(Emulator)
|
||||
platform.apis=MMAPI-1.1,NokiaUI-1.0
|
||||
platform.bootclasspath=${platform.home}/lib/nokiaext.jar:${platform.home}/lib/mmapi.jar:${platform.home}/lib/cldcapi11.jar:${platform.home}/lib/midpapi20.jar
|
||||
platform.configuration=CLDC-1.1
|
||||
platform.device=SonyEricsson_JP8_240x320_Emu
|
||||
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
|
||||
ricoh.application.email=
|
||||
ricoh.application.fax=
|
||||
ricoh.application.icon=
|
||||
ricoh.application.target-jar=
|
||||
ricoh.application.telephone=
|
||||
ricoh.application.uid=21076268
|
||||
ricoh.application.version=
|
||||
ricoh.dalp.application-desc.auto-run=false
|
||||
ricoh.dalp.application-desc.energy-save=
|
||||
ricoh.dalp.application-desc.exec-auth=
|
||||
ricoh.dalp.application-desc.visible=true
|
||||
ricoh.dalp.argument=
|
||||
ricoh.dalp.codebase=
|
||||
ricoh.dalp.display-mode.color=true
|
||||
ricoh.dalp.display-mode.is-4line-support=false
|
||||
ricoh.dalp.display-mode.is-hvga-support=true
|
||||
ricoh.dalp.display-mode.is-vga-support=false
|
||||
ricoh.dalp.display-mode.is-wvga-support=false
|
||||
ricoh.dalp.information.abbreviation=
|
||||
ricoh.dalp.information.icon.basepath=
|
||||
ricoh.dalp.information.icon.location=
|
||||
ricoh.dalp.information.is-icon-used=true
|
||||
ricoh.dalp.install.destination=hdd
|
||||
ricoh.dalp.install.mode.auto=true
|
||||
ricoh.dalp.install.work-dir=hdd
|
||||
ricoh.dalp.is-managed=true
|
||||
ricoh.dalp.resources.dsdk.version=2.0
|
||||
ricoh.dalp.resources.jar.basepath=
|
||||
ricoh.dalp.resources.jar.version=
|
||||
ricoh.dalp.version=
|
||||
ricoh.icon.invert=false
|
||||
ricoh.platform.target.version=
|
||||
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=E0572419
|
||||
semc.certificate.path=
|
||||
semc.private.key.password=
|
||||
semc.private.key.path=
|
||||
sign.alias=
|
||||
sign.enabled=false
|
||||
sign.keystore=
|
||||
src.dir=src
|
||||
use.emptyapis=true
|
||||
use.preprocessor=true
|
10
nbproject/project.xml
Normal file
10
nbproject/project.xml
Normal file
@ -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>SensorBalls</name>
|
||||
<minimum-ant-version>1.6</minimum-ant-version>
|
||||
</data>
|
||||
</configuration>
|
||||
</project>
|
202
src/Canv.java
Normal file
202
src/Canv.java
Normal file
@ -0,0 +1,202 @@
|
||||
|
||||
import com.nokia.mid.ui.DeviceControl;
|
||||
import java.io.IOException;
|
||||
import java.util.Random;
|
||||
import javax.microedition.io.Connector;
|
||||
import javax.microedition.lcdui.*;
|
||||
import javax.microedition.lcdui.game.Sprite;
|
||||
import javax.microedition.sensor.*;
|
||||
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @author aNNiMON
|
||||
*/
|
||||
public class Canv extends Canvas implements DataListener {
|
||||
|
||||
private int w,h;
|
||||
private int cx, cy, cz;
|
||||
private int tx, ty, tz;
|
||||
private int x, y, z;
|
||||
private int _x, _y, _z;
|
||||
private boolean auto,flash;
|
||||
|
||||
private int fl,sc,mode,alpha;
|
||||
|
||||
private Image I;
|
||||
private Graphics G;
|
||||
|
||||
private int[] channels = new int[3];
|
||||
private String[] channelNames = new String[3];
|
||||
private SensorConnection sensor;
|
||||
private String URL;
|
||||
|
||||
public Canv() {
|
||||
setFullScreenMode(true);
|
||||
flash = auto = false;
|
||||
fl = alpha = 0;
|
||||
w = getWidth();
|
||||
h = getHeight();
|
||||
cx=cy=cz=tx=ty=tz;
|
||||
I = Image.createImage(w, h);
|
||||
G = I.getGraphics();
|
||||
G.setColor(0);
|
||||
G.fillRect(0, 0, w, h);
|
||||
sc = h/2;
|
||||
getInfo();
|
||||
}
|
||||
|
||||
protected void paint(Graphics g) {
|
||||
if(auto) {
|
||||
Random rnd = new Random();
|
||||
if(((rnd.nextInt()>>>1)%20)==5)
|
||||
mode=(rnd.nextInt()>>>1)%5;
|
||||
}
|
||||
if(flash) {
|
||||
/*try {
|
||||
DeviceControl.setLights(0, fl += 5);
|
||||
} catch (Exception e) {
|
||||
DeviceControl.setLights(0, 100);
|
||||
}*/
|
||||
DeviceControl.setLights(0, 0);
|
||||
DeviceControl.setLights(0, 100);
|
||||
if(fl++>2) flash = false;
|
||||
}
|
||||
if(mode!=3) drawPlayerCanvas(G);
|
||||
else drawRoundCanvas(G);
|
||||
|
||||
if(mode==1 || mode==3) {
|
||||
g.drawImage(I, w/2, 0, 24);
|
||||
g.drawImage(Image.createImage(I, 0, 0, I.getWidth(), I.getHeight(), Sprite.TRANS_MIRROR), w/2, 0, 20);
|
||||
}
|
||||
else if(mode==2) {
|
||||
g.drawImage(Image.createImage(I, 0, 0, I.getWidth(), I.getHeight(), Sprite.TRANS_ROT90), 0, h/2, 36);
|
||||
g.drawImage(Image.createImage(I, 0, 0, I.getWidth(), I.getHeight(), Sprite.TRANS_MIRROR_ROT90), 0, h/2, 20);
|
||||
}else if(mode==4) {
|
||||
try {
|
||||
g.setColor((1024 + x) / 8, (1024 + y) / 8, (1024 + z) / 8);
|
||||
} catch (Exception e) {
|
||||
g.setColor(0xffffff);
|
||||
}
|
||||
g.fillRect(0, 0, w, h);
|
||||
int yyy = 800;
|
||||
if((Math.abs(_x-x)>yyy) || (Math.abs(_y-y)>yyy) || (Math.abs(_z-z)>yyy)) {
|
||||
flash = true;
|
||||
fl = 0;
|
||||
}
|
||||
}else{
|
||||
g.drawImage(I, 0, 0, 20);
|
||||
}
|
||||
}
|
||||
|
||||
protected void keyPressed(int key) {
|
||||
int ga = getGameAction(key);
|
||||
if(ga==FIRE) {mode++; if(mode>4) mode=0;}
|
||||
if(key==KEY_NUM0) {alpha+=10; if(alpha>100) alpha=0;}
|
||||
if(key==KEY_STAR) {auto=!auto;}
|
||||
}
|
||||
|
||||
private void drawPlayerCanvas(Graphics g) {
|
||||
g.drawImage(I, -2, 0, 20);
|
||||
ACLS(g, w, h, alpha, 0);
|
||||
//g.fillRect(I.getWidth()-3, 0, 3, h);
|
||||
//x
|
||||
g.setColor(0xFF0000);
|
||||
g.drawLine(I.getWidth()-2, tx, I.getWidth(), cx);
|
||||
|
||||
//y
|
||||
g.setColor(0x00FF00);
|
||||
g.drawLine(I.getWidth()-2, ty, I.getWidth(), cy);
|
||||
|
||||
//z
|
||||
g.setColor(0x0000FF);
|
||||
g.drawLine(I.getWidth()-2, tz, I.getWidth(), cz);
|
||||
|
||||
}
|
||||
|
||||
private void drawRoundCanvas(Graphics g) {
|
||||
g.drawImage(I, -2, 0, 20);
|
||||
|
||||
ACLS(g, 3, h, alpha, 0);
|
||||
//g.fillRect(I.getWidth()-3, 0, 3, h);
|
||||
//x
|
||||
g.setColor(0xFF0000);
|
||||
drawOval(g, I.getWidth()-2, tx, Math.abs(tx-cx));
|
||||
|
||||
//y
|
||||
g.setColor(0x00FF00);
|
||||
drawOval(g, I.getWidth()-2, ty, Math.abs(ty-cy));
|
||||
|
||||
//z
|
||||
g.setColor(0x0000FF);
|
||||
drawOval(g, I.getWidth()-2, tz, Math.abs(tz-cz));
|
||||
|
||||
}
|
||||
|
||||
public void setPositions(int x, int y, int z) {
|
||||
this._x = this.x; this._y = this.y; this._z = this.z;
|
||||
this.x = x; this.y = y; this.z = z;
|
||||
tx=cx; cx=(int) ((x * sc)/1024+sc);
|
||||
ty=cy; cy=(int) ((y * sc)/1024+sc);
|
||||
tz=cz; cz=(int) ((z * sc)/1024+sc);
|
||||
}
|
||||
|
||||
public void dataReceived(SensorConnection sensor, Data[] data, boolean isDataLost) {
|
||||
//Save the data
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
if (data[i].getChannelInfo().getName().compareTo(channelNames[0]) == 0) {
|
||||
channels[0] = data[i].getIntValues()[0];
|
||||
} else if (data[i].getChannelInfo().getName().compareTo(channelNames[1]) == 0) {
|
||||
channels[1] = data[i].getIntValues()[0];
|
||||
} else if (data[i].getChannelInfo().getName().compareTo(channelNames[2]) == 0) {
|
||||
channels[2] = data[i].getIntValues()[0];
|
||||
}
|
||||
}
|
||||
setPositions(channels[0], channels[1], channels[2]);
|
||||
com.nokia.mid.ui.DeviceControl.setLights(0, 100);
|
||||
repaint();
|
||||
}
|
||||
|
||||
private void getInfo() {
|
||||
SensorInfo[] info = SensorManager.findSensors("acceleration", null);
|
||||
for (int i = 0; i < info.length; i++) {
|
||||
SensorInfo s = info[i];
|
||||
URL = s.getUrl();
|
||||
ChannelInfo[] ci = s.getChannelInfos();
|
||||
for (int r = 0; r < ci.length; r++) {
|
||||
ChannelInfo c = ci[r];
|
||||
channelNames[r] = c.getName();
|
||||
}
|
||||
}
|
||||
try {
|
||||
sensor = (SensorConnection) Connector.open(URL);
|
||||
sensor.setDataListener(this, 1);
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void drawOval(Graphics g, int x0, int y0, int r) {
|
||||
g.drawArc(x0-r, y0-r, 2*r, 2*r, 0, 360);
|
||||
}
|
||||
|
||||
private void ACLS(Graphics g, int w, int h, int k, int color) {
|
||||
if(k==0) {
|
||||
CLS(g,w,h,color); return;
|
||||
}
|
||||
int[] pixelArray = new int[w * h];
|
||||
for (int io = 0; io < pixelArray.length; io++) {
|
||||
pixelArray[io] = (int) (101-k << 24) | color;
|
||||
}
|
||||
g.drawRGB(pixelArray, 0, w, I.getWidth()-3, 0, w, h, true);
|
||||
}
|
||||
|
||||
private void CLS(Graphics g, int w, int h, int color) {
|
||||
g.setColor(color);
|
||||
g.fillRect(I.getWidth()-3, 0, w, h);
|
||||
}
|
||||
}
|
29
src/SensorVisualizer.java
Normal file
29
src/SensorVisualizer.java
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
import javax.microedition.lcdui.*;
|
||||
import javax.microedition.midlet.*;
|
||||
|
||||
/**
|
||||
* @author aNNiMON
|
||||
*/
|
||||
public class SensorVisualizer extends MIDlet {
|
||||
|
||||
public static SensorVisualizer midlet;
|
||||
public Display dsp;
|
||||
public Canv cnv;
|
||||
|
||||
public void startApp() {
|
||||
cnv = new Canv();
|
||||
dsp = Display.getDisplay(this);
|
||||
dsp.setCurrent(cnv);
|
||||
}
|
||||
|
||||
public void pauseApp() {
|
||||
}
|
||||
|
||||
public void destroyApp(boolean unconditional) {
|
||||
}
|
||||
}
|
BIN
src/icon.png
Normal file
BIN
src/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
Loading…
Reference in New Issue
Block a user