commit 32c727a3db5da062164faa3c2d8498b3381b73e0 Author: Victor Date: Thu Nov 15 12:21:06 2018 +0200 Initial diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..4a3c628 --- /dev/null +++ b/build.xml @@ -0,0 +1,83 @@ + + + + + + Builds, tests, and runs the project . + + + diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml new file mode 100644 index 0000000..c0f5283 --- /dev/null +++ b/nbproject/build-impl.xml @@ -0,0 +1,1368 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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. + Platform home (platform.home property) is not set. Value of this property should be ${platform.active.description} emulator home directory location. + 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. + Must set src.dir + Must set build.dir + Must set dist.dir + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set preprocessed.dir + + + + + + + + + + + + + + + + + + Must set build.classes.dir + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + Must set obfuscated.classes.dir + + + + Must set obfuscated.classes.dir + Must set obfuscator.srcjar + Must set obfuscator.destjar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set preverify.classes.dir + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MicroEdition-Configuration: ${platform.configuration} + + MicroEdition-Configuration: ${platform.configuration} + + + + MicroEdition-Profile: ${platform.profile} + + MicroEdition-Profile: ${platform.profile} + + + + Must set dist.jad + + + + + + + + + + + + + + + + + + + + + + + + ${manifest.midlets}${evaluated.manifest.apipermissions}${evaluated.manifest.pushregistry}${manifest.others}${manifest.jad} + ${manifest.midlets}${evaluated.manifest.apipermissions}${evaluated.manifest.pushregistry}${manifest.others}${manifest.manifest} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Starting emulator with port number ${active.debug.port} + + + + + + + + + + + + Starting emulator with port number ${active.debug.port} + + + + + + + + + + + + + + + + + Must set dist.javadoc.dir + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${all.configurations} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Property deployment.${deployment.method}.scriptfile not set. The property should point to an Ant script providing ${deployment.method} deployment. + + + + + + + + Classpath to Ant Contrib library (libs.ant-contrib.classpath property) is not set. + + + + + + + + + Active project configuration: @{cfg} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Property build.root.dir is not set. By default its value should be \"build\". + Property dist.root.dir is not set. By default its value should be \"dist\". + + + + + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties new file mode 100644 index 0000000..d286602 --- /dev/null +++ b/nbproject/genfiles.properties @@ -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 diff --git a/nbproject/private/private.properties b/nbproject/private/private.properties new file mode 100644 index 0000000..8798c70 --- /dev/null +++ b/nbproject/private/private.properties @@ -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 diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml new file mode 100644 index 0000000..c1f155a --- /dev/null +++ b/nbproject/private/private.xml @@ -0,0 +1,4 @@ + + + + diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 0000000..07d4d08 --- /dev/null +++ b/nbproject/project.properties @@ -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 diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 0000000..72574cd --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,10 @@ + + + org.netbeans.modules.kjava.j2meproject + + + SensorBalls + 1.6 + + + diff --git a/src/Canv.java b/src/Canv.java new file mode 100644 index 0000000..a254b16 --- /dev/null +++ b/src/Canv.java @@ -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); + } +} \ No newline at end of file diff --git a/src/SensorVisualizer.java b/src/SensorVisualizer.java new file mode 100644 index 0000000..a918273 --- /dev/null +++ b/src/SensorVisualizer.java @@ -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) { + } +} diff --git a/src/icon.png b/src/icon.png new file mode 100644 index 0000000..eb1a9bd Binary files /dev/null and b/src/icon.png differ