Initial
This commit is contained in:
commit
594b336d46
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="TimeSpeaker" 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>
|
1247
nbproject/build-impl.xml
Normal file
1247
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=83c2feaf
|
||||||
|
build.xml.script.CRC32=5f3bfc00
|
||||||
|
build.xml.stylesheet.CRC32=9c6a911d
|
||||||
|
nbproject/build-impl.xml.data.CRC32=83c2feaf
|
||||||
|
nbproject/build-impl.xml.script.CRC32=fbedd971
|
||||||
|
nbproject/build-impl.xml.stylesheet.CRC32=e46c2d22
|
7
nbproject/private/private.properties
Normal file
7
nbproject/private/private.properties
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#Mon, 30 Apr 2012 02:28:02 +0300
|
||||||
|
app-version.autoincrement=true
|
||||||
|
config.active=
|
||||||
|
deployment.counter=7
|
||||||
|
deployment.number=0.0.6
|
||||||
|
javadoc.preview=true
|
||||||
|
netbeans.user=C\:\\Users\\aNNiMON\\.netbeans\\7.1
|
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>
|
106
nbproject/project.properties
Normal file
106
nbproject/project.properties
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
abilities=MMAPI=1.1,SATSAJCRMI=1.0,SATSACRYPTO=1.0,JSR82=1.1,NOKIAUI=1.0,JSR226=1.0,capuchin=1.0,MIDP=2.1,JSR229=1.1.0,SATSAAPDU=1.0,CLDC=1.1,JSR177=1.0,JSR179=1.0.1,eSWT=1.1,J2MEWS=1.0,VSCL=2.1,WMA=2.0,JSR172=1.0,JSR256=1.1,SEMC_EXT_JP8=1.0,ColorScreen,NokiaUI=1.0,OBEX=1.0,JSR238=1.0,JSR239=1.0,JSR211=1.0,JSR234=1.0,ScreenWidth=240,MascotV3=1.0,JSR75=1.0,IAPInfo=1.0,SATSAPKI=1.0,JSR184=1.1,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
|
||||||
|
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=TimeSpeaker.jad
|
||||||
|
dist.jar=TimeSpeaker.jar
|
||||||
|
dist.javadoc.dir=${dist.dir}/doc
|
||||||
|
dist.root.dir=dist
|
||||||
|
extra.classpath=
|
||||||
|
file.reference.TimeSpeaker-res=res
|
||||||
|
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=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=${file.reference.TimeSpeaker-res}
|
||||||
|
main.class=
|
||||||
|
main.class.class=applet
|
||||||
|
manifest.apipermissions=
|
||||||
|
manifest.file=manifest.mf
|
||||||
|
manifest.is.liblet=false
|
||||||
|
manifest.jad=
|
||||||
|
manifest.manifest=
|
||||||
|
manifest.midlets=MIDlet-1: TimeSpeaker, , Main\n
|
||||||
|
manifest.others=MIDlet-Vendor: Vendor\nMIDlet-Name: TimeSpeaker\nMIDlet-Version: 1.0\n
|
||||||
|
manifest.pushregistry=
|
||||||
|
name=TimeSpeaker
|
||||||
|
no.dependencies=false
|
||||||
|
nokiaS80.application.icon=
|
||||||
|
obfuscated.classes.dir=${build.dir}/obfuscated
|
||||||
|
obfuscation.custom=@E:\\SETUPS\\Disk\\Programming\\Java\\annimon.pro
|
||||||
|
obfuscation.level=1
|
||||||
|
obfuscator.destjar=${build.dir}/obfuscated.jar
|
||||||
|
obfuscator.srcjar=${build.dir}/before-obfuscation.jar
|
||||||
|
platform.active=Sony_Ericsson_SDK_2_5_0_6_for_the_Java_TM__ME_Platform_Emulator_
|
||||||
|
platform.active.description=Sony Ericsson SDK 2.5.0.6 for the Java(TM) ME Platform(Emulator)
|
||||||
|
platform.apis=WMA-2.0,JSR211-1.0,JSR82-1.1,JSR177-1.0,JSR234-1.0,SATSA-APDU-1.0,capuchin-1.0,J2ME-WS-1.0,J2ME-XMLRPC-1.0,SATSA-JCRMI-1.0,SATSA-CRYPTO-1.0,JSR239-1.0,MascotV3-1.0,JSR238-1.0,MMAPI-1.1,JSR256-1.1,NokiaUI-1.0,IAPInfo-1.0,JSR229-1.1.0,SATSA-PKI-1.0,JSR180-1.0.1,JSR226-1.0,SEMC_EXT_JP8-1.0,VSCL-2.0,VSCL-2.1,eSWT-1.1,JSR75-1.0,JSR184-1.1,JSR179-1.0.1
|
||||||
|
platform.bootclasspath=${platform.home}/lib/eswt.jar:${platform.home}/lib/mascotv3.jar:${platform.home}/lib/jsr226.jar:${platform.home}/lib/jsr256.jar:${platform.home}/lib/satsa-crypto.jar:${platform.home}/lib/jsr229.jar:${platform.home}/lib/jsr238.jar:${platform.home}/lib/j2me-xmlrpc.jar:${platform.home}/lib/jsr211.jar:${platform.home}/lib/vscl21.jar:${platform.home}/lib/satsa-jcrmi.jar:${platform.home}/lib/jsr082.jar:${platform.home}/lib/satsa-apdu.jar:${platform.home}/lib/jsr184.jar:${platform.home}/lib/nokiaext.jar:${platform.home}/lib/capuchin.jar:${platform.home}/lib/jsr239.jar:${platform.home}/lib/jsr75.jar:${platform.home}/lib/satsa-pki.jar:${platform.home}/lib/jsr179.jar:${platform.home}/lib/jsr180.jar:${platform.home}/lib/iapinfo.jar:${platform.home}/lib/vscl.jar:${platform.home}/lib/mmapi.jar:${platform.home}/lib/j2me-ws.jar:${platform.home}/lib/wma20.jar:${platform.home}/lib/jsr234.jar:${platform.home}/lib/semc_ext_jp8.jar:${platform.home}/lib/cldcapi10.jar:${platform.home}/lib/midpapi20.jar
|
||||||
|
platform.configuration=CLDC-1.0
|
||||||
|
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
|
||||||
|
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=E7748318
|
||||||
|
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>TimeSpeaker</name>
|
||||||
|
<minimum-ant-version>1.6</minimum-ant-version>
|
||||||
|
</data>
|
||||||
|
</configuration>
|
||||||
|
</project>
|
BIN
res/font.ppf
Normal file
BIN
res/font.ppf
Normal file
Binary file not shown.
BIN
res/icon.png
Normal file
BIN
res/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 342 B |
BIN
res/res/1.mp3
Normal file
BIN
res/res/1.mp3
Normal file
Binary file not shown.
BIN
res/res/10.mp3
Normal file
BIN
res/res/10.mp3
Normal file
Binary file not shown.
BIN
res/res/11.mp3
Normal file
BIN
res/res/11.mp3
Normal file
Binary file not shown.
BIN
res/res/12.mp3
Normal file
BIN
res/res/12.mp3
Normal file
Binary file not shown.
BIN
res/res/13.mp3
Normal file
BIN
res/res/13.mp3
Normal file
Binary file not shown.
BIN
res/res/14.mp3
Normal file
BIN
res/res/14.mp3
Normal file
Binary file not shown.
BIN
res/res/15.mp3
Normal file
BIN
res/res/15.mp3
Normal file
Binary file not shown.
BIN
res/res/16.mp3
Normal file
BIN
res/res/16.mp3
Normal file
Binary file not shown.
BIN
res/res/17.mp3
Normal file
BIN
res/res/17.mp3
Normal file
Binary file not shown.
BIN
res/res/18.mp3
Normal file
BIN
res/res/18.mp3
Normal file
Binary file not shown.
BIN
res/res/19.mp3
Normal file
BIN
res/res/19.mp3
Normal file
Binary file not shown.
BIN
res/res/1a.mp3
Normal file
BIN
res/res/1a.mp3
Normal file
Binary file not shown.
BIN
res/res/2.mp3
Normal file
BIN
res/res/2.mp3
Normal file
Binary file not shown.
BIN
res/res/20.mp3
Normal file
BIN
res/res/20.mp3
Normal file
Binary file not shown.
BIN
res/res/2a.mp3
Normal file
BIN
res/res/2a.mp3
Normal file
Binary file not shown.
BIN
res/res/3.mp3
Normal file
BIN
res/res/3.mp3
Normal file
Binary file not shown.
BIN
res/res/30.mp3
Normal file
BIN
res/res/30.mp3
Normal file
Binary file not shown.
BIN
res/res/4.mp3
Normal file
BIN
res/res/4.mp3
Normal file
Binary file not shown.
BIN
res/res/40.mp3
Normal file
BIN
res/res/40.mp3
Normal file
Binary file not shown.
BIN
res/res/5.mp3
Normal file
BIN
res/res/5.mp3
Normal file
Binary file not shown.
BIN
res/res/50.mp3
Normal file
BIN
res/res/50.mp3
Normal file
Binary file not shown.
BIN
res/res/6.mp3
Normal file
BIN
res/res/6.mp3
Normal file
Binary file not shown.
BIN
res/res/7.mp3
Normal file
BIN
res/res/7.mp3
Normal file
Binary file not shown.
BIN
res/res/8.mp3
Normal file
BIN
res/res/8.mp3
Normal file
Binary file not shown.
BIN
res/res/9.mp3
Normal file
BIN
res/res/9.mp3
Normal file
Binary file not shown.
BIN
res/res/hour1.mp3
Normal file
BIN
res/res/hour1.mp3
Normal file
Binary file not shown.
BIN
res/res/hour2.mp3
Normal file
BIN
res/res/hour2.mp3
Normal file
Binary file not shown.
BIN
res/res/hour3.mp3
Normal file
BIN
res/res/hour3.mp3
Normal file
Binary file not shown.
BIN
res/res/minute1.mp3
Normal file
BIN
res/res/minute1.mp3
Normal file
Binary file not shown.
BIN
res/res/minute2.mp3
Normal file
BIN
res/res/minute2.mp3
Normal file
Binary file not shown.
BIN
res/res/minute3.mp3
Normal file
BIN
res/res/minute3.mp3
Normal file
Binary file not shown.
33
src/Main.java
Normal file
33
src/Main.java
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* aNNiMON 2012
|
||||||
|
* For more info visit http://annimon.com/
|
||||||
|
*/
|
||||||
|
|
||||||
|
import javax.microedition.lcdui.Display;
|
||||||
|
import javax.microedition.midlet.MIDlet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author aNNiMON
|
||||||
|
*/
|
||||||
|
public class Main extends MIDlet {
|
||||||
|
|
||||||
|
public Display dsp;
|
||||||
|
public static Main midlet;
|
||||||
|
private TimeCanvas canv;
|
||||||
|
|
||||||
|
public Main() {
|
||||||
|
midlet = Main.this;
|
||||||
|
dsp = Display.getDisplay(Main.this);
|
||||||
|
canv = new TimeCanvas();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startApp() {
|
||||||
|
dsp.setCurrent(canv);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void pauseApp() {}
|
||||||
|
|
||||||
|
public void destroyApp(boolean ex) {
|
||||||
|
notifyDestroyed();
|
||||||
|
}
|
||||||
|
}
|
52
src/Sound.java
Normal file
52
src/Sound.java
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
import java.io.InputStream;
|
||||||
|
import javax.microedition.media.Manager;
|
||||||
|
import javax.microedition.media.Player;
|
||||||
|
import javax.microedition.media.PlayerListener;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* aNNiMON 2012
|
||||||
|
* For more info visit http://annimon.com/
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author aNNiMON
|
||||||
|
*/
|
||||||
|
public class Sound implements PlayerListener {
|
||||||
|
|
||||||
|
private Player plr;
|
||||||
|
private String[] soundsToPlay;
|
||||||
|
private int current;
|
||||||
|
|
||||||
|
public Sound(String[] soundsToPlay) {
|
||||||
|
this.soundsToPlay = soundsToPlay;
|
||||||
|
current = 0;
|
||||||
|
plr = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void speak() {
|
||||||
|
if (plr != null) {
|
||||||
|
plr.close();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
System.out.println(soundsToPlay[current]);
|
||||||
|
InputStream is = getClass().getResourceAsStream("/res/"+soundsToPlay[current]+".mp3");
|
||||||
|
plr = Manager.createPlayer(is, "audio/mpeg");
|
||||||
|
plr.realize();
|
||||||
|
plr.prefetch();
|
||||||
|
plr.addPlayerListener(this);
|
||||||
|
plr.start();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void playerUpdate(Player player, String event, Object eventData) {
|
||||||
|
if (event.equals(PlayerListener.END_OF_MEDIA)) {
|
||||||
|
current++;
|
||||||
|
if (current < soundsToPlay.length) speak();
|
||||||
|
else Main.midlet.destroyApp(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
43
src/TimeCanvas.java
Normal file
43
src/TimeCanvas.java
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* aNNiMON 2012
|
||||||
|
* For more info visit http://annimon.com/
|
||||||
|
*/
|
||||||
|
|
||||||
|
import com.annimon.ppf.PPFont;
|
||||||
|
import javax.microedition.lcdui.Canvas;
|
||||||
|
import javax.microedition.lcdui.Font;
|
||||||
|
import javax.microedition.lcdui.Graphics;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author aNNiMON
|
||||||
|
*/
|
||||||
|
public class TimeCanvas extends Canvas {
|
||||||
|
|
||||||
|
private int w, h;
|
||||||
|
private int fontWidth, fontHeight;
|
||||||
|
private PPFont font;
|
||||||
|
private Sound sound;
|
||||||
|
private String time;
|
||||||
|
|
||||||
|
public TimeCanvas() {
|
||||||
|
setFullScreenMode(true);
|
||||||
|
w = getWidth();
|
||||||
|
h = getHeight();
|
||||||
|
|
||||||
|
time = TimeUtil.getTime();
|
||||||
|
|
||||||
|
font = new PPFont("/font.ppf");
|
||||||
|
fontWidth = font.getTextWidth(time);
|
||||||
|
fontHeight = font.getFontHeight(true);
|
||||||
|
|
||||||
|
String[] names = TimeUtil.getStringsToSpeak();
|
||||||
|
sound = new Sound(names);
|
||||||
|
sound.speak();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void paint(Graphics g) {
|
||||||
|
g.setColor(0xFFFFFF);
|
||||||
|
g.fillRect(0, 0, w, h);
|
||||||
|
font.drawText(g, w/2-fontWidth/2, h/2-fontHeight/2, time);
|
||||||
|
}
|
||||||
|
}
|
110
src/TimeUtil.java
Normal file
110
src/TimeUtil.java
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* aNNiMON 2012
|
||||||
|
* For more info visit http://annimon.com/
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author aNNiMON
|
||||||
|
*/
|
||||||
|
public class TimeUtil {
|
||||||
|
|
||||||
|
private static final int[] NORMAL_1_TO_20 = {
|
||||||
|
12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
|
||||||
|
11, 12, 13, 14, 15, 16, 17, 18, 19, 20
|
||||||
|
};
|
||||||
|
|
||||||
|
private static final int[] NAMES_TEN = {
|
||||||
|
10, 20, 30, 40, 50
|
||||||
|
};
|
||||||
|
|
||||||
|
private static final String[] NAMES_1_2 = {
|
||||||
|
"1a", "2a"
|
||||||
|
};
|
||||||
|
|
||||||
|
private static final String[] NAMES_HOUR = {
|
||||||
|
"hour1", "hour2", "hour3"
|
||||||
|
};
|
||||||
|
|
||||||
|
private static final String[] NAMES_MINUTE = {
|
||||||
|
"minute1", "minute2", "minute3"
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Получить время
|
||||||
|
* @return строка с временем вида: HH:MM
|
||||||
|
*/
|
||||||
|
public static String getTime() {
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
Calendar cal = Calendar.getInstance();
|
||||||
|
// Час
|
||||||
|
int tmp = cal.get(Calendar.HOUR_OF_DAY);
|
||||||
|
if(tmp <= 9) sb.append('0');
|
||||||
|
sb.append(tmp);
|
||||||
|
sb.append(':');
|
||||||
|
// Минута
|
||||||
|
tmp = cal.get(Calendar.MINUTE);
|
||||||
|
if(tmp <= 9) sb.append('0');
|
||||||
|
sb.append(tmp);
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String[] getStringsToSpeak() {
|
||||||
|
Vector audioNames = new Vector();
|
||||||
|
Calendar cal = Calendar.getInstance();
|
||||||
|
// Час
|
||||||
|
int hour = cal.get(Calendar.HOUR_OF_DAY);
|
||||||
|
appendHourString(audioNames, hour);
|
||||||
|
// Минута
|
||||||
|
int minute = cal.get(Calendar.MINUTE);
|
||||||
|
appendMinuteString(audioNames, minute);
|
||||||
|
|
||||||
|
String[] out = new String[audioNames.size()];
|
||||||
|
audioNames.copyInto(out);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void appendHourString(Vector audioNames, int hour) {
|
||||||
|
int minHour = Math.min(hour, 20);
|
||||||
|
audioNames.addElement(String.valueOf(NORMAL_1_TO_20[minHour])); // 0..20
|
||||||
|
if (hour > 20) audioNames.addElement(String.valueOf(NORMAL_1_TO_20[hour % 20])); //21..23
|
||||||
|
// Час
|
||||||
|
if ( (hour == 1) || (hour == 21) ) audioNames.addElement(NAMES_HOUR[0]);
|
||||||
|
else if ( ((1 < hour) && (hour <= 4)) || ((21 < hour) && (hour <= 23)) ) audioNames.addElement(NAMES_HOUR[1]);
|
||||||
|
else audioNames.addElement(NAMES_HOUR[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void appendMinuteString(Vector audioNames, int minute) {
|
||||||
|
// Ноль минут нет
|
||||||
|
if (minute == 0) return;
|
||||||
|
|
||||||
|
// От пяти до двадцати одинаково
|
||||||
|
if ((5 <= minute) && (minute <= 20) ) {
|
||||||
|
audioNames.addElement(String.valueOf(NORMAL_1_TO_20[minute]));
|
||||||
|
audioNames.addElement(NAMES_MINUTE[0]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Десятки минут
|
||||||
|
int tenMinute = minute / 10;
|
||||||
|
if (tenMinute != 0) audioNames.addElement(String.valueOf(NAMES_TEN[tenMinute - 1]));
|
||||||
|
|
||||||
|
int modMinute = minute % 10;
|
||||||
|
// Одна минута / две минуты
|
||||||
|
if ( (modMinute == 1) || (modMinute == 2)) {
|
||||||
|
audioNames.addElement(NAMES_1_2[modMinute - 1]);
|
||||||
|
audioNames.addElement(NAMES_MINUTE[modMinute]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// без десятков
|
||||||
|
if (modMinute != 0) audioNames.addElement(String.valueOf(NORMAL_1_TO_20[modMinute]));
|
||||||
|
|
||||||
|
// x2, x3, x4 минуты
|
||||||
|
if ( (2 <= modMinute) && (modMinute <= 4) ) audioNames.addElement(NAMES_MINUTE[2]);
|
||||||
|
else audioNames.addElement(NAMES_MINUTE[0]); // минут
|
||||||
|
}
|
||||||
|
}
|
18
src/com/annimon/ppf/Char.java
Normal file
18
src/com/annimon/ppf/Char.java
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* aNNiMON 2011
|
||||||
|
* For more info visit http://annimon.com/
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.annimon.ppf;
|
||||||
|
|
||||||
|
import javax.microedition.lcdui.Image;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author aNNiMON
|
||||||
|
*/
|
||||||
|
public class Char {
|
||||||
|
|
||||||
|
public Image charImage;
|
||||||
|
short x, y, xx;
|
||||||
|
}
|
155
src/com/annimon/ppf/PPFont.java
Normal file
155
src/com/annimon/ppf/PPFont.java
Normal file
@ -0,0 +1,155 @@
|
|||||||
|
/*
|
||||||
|
* aNNiMON 2011
|
||||||
|
* For more info visit http://annimon.com/
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.annimon.ppf;
|
||||||
|
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.Hashtable;
|
||||||
|
import javax.microedition.lcdui.Graphics;
|
||||||
|
import javax.microedition.lcdui.Image;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author aNNiMON
|
||||||
|
*/
|
||||||
|
public class PPFont {
|
||||||
|
|
||||||
|
public Hashtable ht;
|
||||||
|
public boolean isModificated;
|
||||||
|
private String fontName;
|
||||||
|
private short fontHeight;
|
||||||
|
private short startIndex, endIndex;
|
||||||
|
private char[] charTable;
|
||||||
|
private int textcolor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Конструктор класса
|
||||||
|
* @param path - путь к ppf-шрифту
|
||||||
|
*/
|
||||||
|
public PPFont(String path) {
|
||||||
|
try {
|
||||||
|
InputStream is = getClass().getResourceAsStream(path);
|
||||||
|
DataInputStream dis = new DataInputStream(is);
|
||||||
|
//Проверка сигнатуры
|
||||||
|
if (dis.readInt() != 0x50504600) return;
|
||||||
|
fontName = dis.readUTF();//Название шрифта
|
||||||
|
fontHeight = dis.readShort();//размер шрифта
|
||||||
|
startIndex = dis.readShort();//начальный символ
|
||||||
|
endIndex = dis.readShort();//конечный символ
|
||||||
|
charTable = new char[endIndex-startIndex+1];
|
||||||
|
ht = new Hashtable(charTable.length);
|
||||||
|
for (int i = startIndex; i <= endIndex; i++) {
|
||||||
|
//Создаем объект для хранения данных
|
||||||
|
Char co = new Char();
|
||||||
|
//Читаем символ
|
||||||
|
char t = charTable[i-startIndex] = dis.readChar();
|
||||||
|
Character ch = new Character(t);
|
||||||
|
//Размеры символа и позиции
|
||||||
|
short width = dis.readShort();
|
||||||
|
short height = dis.readShort();
|
||||||
|
short x = dis.readShort();
|
||||||
|
short y = dis.readShort();
|
||||||
|
short xx = dis.readShort();//m.getAdvanceX()
|
||||||
|
int[] rgb = new int[width*height];
|
||||||
|
for (int j = 0; j < rgb.length; j++) {
|
||||||
|
rgb[j] = dis.readBoolean() ? 0xFF000000 : 0;//если true - цвет чёрный
|
||||||
|
}
|
||||||
|
//Записываем переменные в объект
|
||||||
|
co.charImage = Image.createRGBImage(rgb, width, height, true);
|
||||||
|
co.x = x;
|
||||||
|
co.y = y;
|
||||||
|
co.xx = xx;
|
||||||
|
ht.put(ch, co);
|
||||||
|
}
|
||||||
|
dis.close();
|
||||||
|
textcolor = 0xFF000000;
|
||||||
|
isModificated = false;
|
||||||
|
} catch (IOException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Изменить цвет шрифта
|
||||||
|
* @param newcolor - новый цвет
|
||||||
|
*/
|
||||||
|
public void setColor(int newcolor) {
|
||||||
|
if(newcolor==textcolor || isModificated) return;//предотвращение повторной установки цвета
|
||||||
|
if(newcolor==0) newcolor=0x10;//предотвращение установки цвета фона
|
||||||
|
for (int i = startIndex; i <= endIndex; i++) {
|
||||||
|
Character o = new Character(charTable[i-startIndex]);
|
||||||
|
//Получаем объект Char
|
||||||
|
Char co = (Char) ht.get(o);
|
||||||
|
Image charImage = co.charImage;
|
||||||
|
|
||||||
|
int width = charImage.getWidth();
|
||||||
|
int height = charImage.getHeight();
|
||||||
|
|
||||||
|
int length = width * height;
|
||||||
|
int[] rgb = new int[length];
|
||||||
|
charImage.getRGB(rgb, 0, width, 0, 0, width, height);
|
||||||
|
for (int pos = 0; pos < length; pos++) {
|
||||||
|
if (rgb[pos] != 0) {
|
||||||
|
rgb[pos] = newcolor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Записываем переменные в объект
|
||||||
|
co.charImage = Image.createRGBImage(rgb, width, height, true);
|
||||||
|
|
||||||
|
ht.put(o, co);
|
||||||
|
}
|
||||||
|
textcolor = newcolor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Отрисовка текста
|
||||||
|
* @param g - Graphics
|
||||||
|
* @param x - x-координата левого верхнего угла
|
||||||
|
* @param y - y-координата левого верхнего угла
|
||||||
|
* @param s - текст
|
||||||
|
* @return - ширина строки
|
||||||
|
*/
|
||||||
|
public int drawText(Graphics g, int x, int y, String s) {
|
||||||
|
int wdh = 0;
|
||||||
|
int length = s.length();
|
||||||
|
int temp = (fontHeight*3)/4;
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
Char co = (Char) ht.get(new Character(s.charAt(i)));
|
||||||
|
if (co != null && co.charImage != null) {
|
||||||
|
if(g!=null) g.drawImage(co.charImage, x + co.x + wdh, y + co.y + temp, 20);
|
||||||
|
wdh += co.xx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return wdh;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ширина строки
|
||||||
|
* @param s - текст
|
||||||
|
* @return - ширина строки s
|
||||||
|
*/
|
||||||
|
public int getTextWidth(String s) {
|
||||||
|
return drawText(null, 0, 0, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Высота шрифта
|
||||||
|
* @param absolute - true - высота шрифта, false - высота букв
|
||||||
|
* @return высота шрифта/букв
|
||||||
|
*/
|
||||||
|
public short getFontHeight(boolean absolute) {
|
||||||
|
return (short) (absolute ? fontHeight : (fontHeight * 3) / 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Получение названия шрифта
|
||||||
|
* @return - имя шрифта
|
||||||
|
*/
|
||||||
|
public String getFontName() {
|
||||||
|
return fontName;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user