Initial
This commit is contained in:
commit
40e7969a62
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="Notations" 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>
|
1430
nbproject/build-impl.xml
Normal file
1430
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=99778a95
|
||||
build.xml.script.CRC32=27b3faaf
|
||||
build.xml.stylesheet.CRC32=9c6a911d
|
||||
nbproject/build-impl.xml.data.CRC32=99778a95
|
||||
nbproject/build-impl.xml.script.CRC32=a9e16bc6
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=7a0aeb65
|
8
nbproject/private/private.properties
Normal file
8
nbproject/private/private.properties
Normal file
@ -0,0 +1,8 @@
|
||||
#Sat, 02 Jul 2011 16:30:45 +0300
|
||||
#Sat Dec 19 15:21:38 EET 2009
|
||||
netbeans.user=C\:\\Users\\aNNiMON\\.netbeans\\7.0
|
||||
javadoc.preview=true
|
||||
config.active=
|
||||
deployment.counter=47
|
||||
app-version.autoincrement=true
|
||||
deployment.number=0.0.46
|
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>
|
142
nbproject/project.properties
Normal file
142
nbproject/project.properties
Normal file
@ -0,0 +1,142 @@
|
||||
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
|
||||
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=Notations.jad
|
||||
dist.jar=Notations.jar
|
||||
dist.javadoc.dir=${dist.dir}/doc
|
||||
dist.root.dir=dist
|
||||
extra.classpath=
|
||||
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=
|
||||
main.class=
|
||||
main.class.class=applet
|
||||
manifest.apipermissions=
|
||||
manifest.file=manifest.mf
|
||||
manifest.is.liblet=false
|
||||
manifest.jad=
|
||||
manifest.manifest=
|
||||
manifest.midlets=MIDlet-1: Notations,/icon.png,Main\n
|
||||
manifest.others=MIDlet-Vendor: aNNiMON\nMIDlet-Name: Notations\nMIDlet-Version: 2.0\n
|
||||
manifest.pushregistry=
|
||||
name=Notations
|
||||
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=@E:\\SETUPS\\Disk\\Programming\\Java\\annimon.pro\n-optimizationpasses 9
|
||||
obfuscation.level=0
|
||||
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,J2ME-WS-1.0,JSR239-1.0,JSR238-1.0,MMAPI-1.1,JSR226-1.0,JSR75-1.0,JSR184-1.1
|
||||
platform.bootclasspath=${platform.home}/lib/jsr226.jar:${platform.home}/lib/jsr238.jar:${platform.home}/lib/jsr211.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/jsr239.jar:${platform.home}/lib/jsr75.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/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=48759871
|
||||
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=E6184713
|
||||
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>Notations</name>
|
||||
<minimum-ant-version>1.6</minimum-ant-version>
|
||||
</data>
|
||||
</configuration>
|
||||
</project>
|
186
src/About.java
Normal file
186
src/About.java
Normal file
@ -0,0 +1,186 @@
|
||||
/*
|
||||
* aNNiMON 2010
|
||||
* For more info visit http://annimon.com/
|
||||
*/
|
||||
|
||||
/*
|
||||
* На основе класса MultiLineText от А.С. Ледкова
|
||||
* www.mobilab.ru
|
||||
*/
|
||||
import com.annimon.XID;
|
||||
import com.annimon.ui.ESkin;
|
||||
import com.annimon.ui.EWindow;
|
||||
import java.util.Vector;
|
||||
import javax.microedition.lcdui.*;
|
||||
|
||||
public class About extends EWindow {
|
||||
|
||||
private static final String PATH = "/about";
|
||||
private Font def;
|
||||
private int defHeight;
|
||||
private String str; // текст
|
||||
|
||||
private int mh, y0; // Положение верхнего края текста
|
||||
private int dy; // Шаг при прокрутке текста
|
||||
private int textheight; // Общая высота текста
|
||||
private Vector strLines;
|
||||
|
||||
public About(String about) {
|
||||
super(about);
|
||||
str = new XID().loadText(PATH);
|
||||
def = Font.getDefaultFont();
|
||||
dy = defHeight = def.getHeight()+2;
|
||||
mh = super.hh - 1;
|
||||
SetTextPar();
|
||||
}
|
||||
|
||||
public void paint(Graphics g, int w, int h) {
|
||||
g.setFont(def);
|
||||
g.setColor(ESkin.textColor);
|
||||
int y1 = y0;
|
||||
for (int i = 0; i < strLines.size(); i++) {
|
||||
if ((y1 + defHeight) > 0) {
|
||||
g.drawString(strLines.elementAt(i).toString(), 1, 3 + y1, Graphics.LEFT | Graphics.TOP);
|
||||
}
|
||||
y1 += defHeight;
|
||||
if (y1 > mh) break;
|
||||
}
|
||||
}
|
||||
|
||||
public void keyEvent(int key, byte state) {
|
||||
if(state!=RELEASED) {
|
||||
int ga = getGameAction(key);
|
||||
if(ga==UP) MoveUp();
|
||||
else if(ga==DOWN) MoveDown();
|
||||
else if(ga==LEFT) PageUp();
|
||||
else if(ga==RIGHT) PageDown();
|
||||
else if(ga==FIRE || key==KEY_LSK || key==KEY_RSK)
|
||||
Main.midlet.dsp.setCurrent(Main.midlet.main);
|
||||
redraw();
|
||||
}
|
||||
}
|
||||
|
||||
protected void pointerPressed(int x, int y) {
|
||||
int w3 = w/3;
|
||||
int h3 = h/3;
|
||||
if(y<h3 && (x>w3 && x<(w-w3))) keyPressed(UP);
|
||||
else if(y>(h-h3) && (x>w3 && x<(w-w3))) keyPressed(DOWN);
|
||||
|
||||
if(x<w3 && (y>h3 && y<(h-h3))) keyPressed(LEFT);
|
||||
else if(x>(w-w3) && (y>h3 && y<(h-h3))) keyPressed(RIGHT);
|
||||
|
||||
else if(x<w3 && y>(h-h3)) keyPressed(-6);
|
||||
else if(x>(w-w3) && y>(h-h3)) keyPressed(-7);
|
||||
else if( (x>w3 && x<(w-w3)) && (y>h3 && y<(h-h3)) ) keyPressed(FIRE);
|
||||
}
|
||||
|
||||
private void SetTextPar() {
|
||||
//Разбиваем строку на массив строк
|
||||
strLines = null;
|
||||
strLines = new Vector();
|
||||
String[] arr = splitString(str, "\n");
|
||||
for(int i=0; i<arr.length; i++) {
|
||||
String substr = arr[i];
|
||||
int i0 = 0, space = 0, in = 0, j = 0, jw = 0; //Смещение от начала строки
|
||||
int imax = substr.length(); //Длина строки
|
||||
boolean isexit = true;
|
||||
y0 = 0;
|
||||
while (isexit) {
|
||||
space = substr.indexOf(" ", i0 + 1);
|
||||
if (space <= i0) {
|
||||
space = imax;
|
||||
isexit = false;
|
||||
}
|
||||
|
||||
j = def.stringWidth(substr.substring(i0, space));
|
||||
if (jw + j < w) {//Слово умещается
|
||||
jw = jw + j;
|
||||
i0 = space;
|
||||
} else {//Слово не умещается
|
||||
strLines.addElement(substr.substring(in, i0));
|
||||
in = i0 + 1;
|
||||
jw = j;
|
||||
if (j > w) {//Слово полностью не умещается в строке
|
||||
space = i0;
|
||||
while (jw > w) {
|
||||
j = 0;
|
||||
while (j < w) {
|
||||
space++;
|
||||
j = def.stringWidth(substr.substring(in, space));
|
||||
}
|
||||
space = space - 1;
|
||||
j = def.stringWidth(substr.substring(in, space));
|
||||
strLines.addElement(substr.substring(in, space));
|
||||
jw = jw - j;
|
||||
i0 = space;
|
||||
in = space;
|
||||
}
|
||||
jw = 0;
|
||||
} else {
|
||||
i0 = space;
|
||||
}
|
||||
}
|
||||
}
|
||||
strLines.addElement(substr.substring(in, imax));
|
||||
}
|
||||
textheight = strLines.size() * defHeight;
|
||||
}
|
||||
|
||||
private void MoveDown() {
|
||||
if (textheight > mh) {
|
||||
y0 = y0 - dy;
|
||||
if (mh - y0 > textheight) {
|
||||
y0 = mh - textheight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void MoveUp() {
|
||||
if (textheight > mh) {
|
||||
y0 = y0 + dy;
|
||||
if (y0 > 0) {
|
||||
y0 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void PageUp() {
|
||||
if (textheight > mh) {
|
||||
y0 = y0 + mh;
|
||||
if (y0 > 0) {
|
||||
y0 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void PageDown() {
|
||||
if (textheight > mh) {
|
||||
y0 = y0 - mh;
|
||||
if (mh - y0 > textheight) {
|
||||
y0 = mh - textheight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String[] splitString(String str, String delim) {
|
||||
if ("".equals(str) || delim == null || delim.length() == 0) return new String[]{str};
|
||||
|
||||
Vector v = new Vector();
|
||||
int pos = 0;
|
||||
int newpos = str.indexOf(delim, 0);
|
||||
|
||||
while (newpos != -1) {
|
||||
v.addElement(str.substring(pos, newpos));
|
||||
pos = newpos + delim.length();
|
||||
newpos = str.indexOf(delim, pos);
|
||||
}
|
||||
v.addElement(str.substring(pos));
|
||||
|
||||
String[] s = new String[v.size()];
|
||||
v.copyInto(s);
|
||||
return s;
|
||||
}
|
||||
|
||||
}
|
125
src/Core.java
Normal file
125
src/Core.java
Normal file
@ -0,0 +1,125 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
import com.annimon.ui.ECanvas;
|
||||
import com.annimon.ui.ESkin;
|
||||
import javax.microedition.lcdui.*;
|
||||
|
||||
/**
|
||||
* @author aNNiMON
|
||||
*/
|
||||
public class Core extends ECanvas {
|
||||
|
||||
private static final byte DEC_TO_XXX = 0;
|
||||
private static final int STEP = 10;
|
||||
private static final int CELL_SIZE = 14;
|
||||
|
||||
private int x, y, mode;
|
||||
private Font fnt;
|
||||
private int fontHeight;
|
||||
private long num; // исходное число
|
||||
private int osn; // основание - в какую систему счисления переводить
|
||||
|
||||
public Core(long num, int osn) {
|
||||
super();
|
||||
this.num = num;
|
||||
this.osn = osn;
|
||||
x = y = 0;
|
||||
fnt = Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_PLAIN, Font.SIZE_SMALL);
|
||||
fontHeight = fnt.getHeight();
|
||||
mode = DEC_TO_XXX;
|
||||
}
|
||||
|
||||
public void paint(Graphics g) {
|
||||
g.setColor(ESkin.bg);
|
||||
g.fillRect(0, 0, w, h);
|
||||
// Клеточки
|
||||
g.setColor(ESkin.cellColor);
|
||||
int cellSize = CELL_SIZE * w / 240;
|
||||
int start = x % cellSize;
|
||||
for(int xx = start; xx < w; xx += cellSize) {
|
||||
g.drawLine(xx, 0, xx, h);
|
||||
}
|
||||
start = y % cellSize;
|
||||
for (int yy = start; yy < h; yy += cellSize) {
|
||||
g.drawLine(0, yy, w, yy);
|
||||
}
|
||||
g.setFont(fnt);
|
||||
if (mode == DEC_TO_XXX) {//DEC to ???
|
||||
drawDecToXXX(g, num, osn, x, y + fontHeight);
|
||||
String number = String.valueOf(num);
|
||||
String result = "";
|
||||
try {
|
||||
result = Long.toString(num, osn);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
g.drawString(number + "D = " + result, x, y, 20);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void sizeChanged(int w, int h) {
|
||||
super.sizeChanged(w, h);
|
||||
super.w = w;
|
||||
super.h = h;
|
||||
}
|
||||
|
||||
|
||||
private void drawDecToXXX(Graphics g, long num, int osn, int x, int y) {
|
||||
String number = String.valueOf(num);
|
||||
int wdh = g.getFont().stringWidth(number) + 2;
|
||||
g.setColor(0x00);
|
||||
g.drawString(number + " " + osn, x, y, 20);
|
||||
g.drawLine(x + wdh, y, x + wdh, y + 3 * fontHeight);
|
||||
g.drawLine(x + wdh, y + fontHeight, x + 2 * wdh, y + fontHeight);
|
||||
y += fontHeight;
|
||||
int digit = (int) (num % osn);
|
||||
g.drawString(String.valueOf(num - digit), x, y, 20);
|
||||
num /= osn;
|
||||
g.drawLine(x, y + fontHeight, x + wdh, y + fontHeight);
|
||||
g.setColor(0x0000FF);
|
||||
g.drawChar(toHex(digit), x + 1, y + fontHeight, 20);
|
||||
x += wdh + 2;
|
||||
if (num > 0) {
|
||||
drawDecToXXX(g, num, osn, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
private char toHex(int value) {
|
||||
if (value > 9) {
|
||||
return (char) (value - 10 + 'a');
|
||||
} else {
|
||||
return (char) (value + '0');
|
||||
}
|
||||
}
|
||||
|
||||
public void keyEvent(int key, byte state) {
|
||||
if(state != RELEASED) {
|
||||
int ga = getGameAction(key);
|
||||
switch (ga) {
|
||||
case RIGHT:
|
||||
x -= STEP;
|
||||
break;
|
||||
case LEFT:
|
||||
x += STEP;
|
||||
break;
|
||||
case DOWN:
|
||||
y -= STEP;
|
||||
break;
|
||||
case UP:
|
||||
y += STEP;
|
||||
break;
|
||||
case FIRE:
|
||||
x = y = 0;
|
||||
break;
|
||||
default:
|
||||
if(key==KEY_LSK || key==KEY_RSK || key==KEY_NUM0)
|
||||
Main.midlet.dsp.setCurrent(Main.midlet.main);
|
||||
break;
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
}
|
60
src/DecToXXX.java
Normal file
60
src/DecToXXX.java
Normal file
@ -0,0 +1,60 @@
|
||||
|
||||
import javax.microedition.lcdui.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author aNNiMON
|
||||
*/
|
||||
public class DecToXXX extends Form implements CommandListener {
|
||||
|
||||
private static final String ERROR = "Ошибка";
|
||||
private Command nextCMD, backCMD;
|
||||
private TextField numberTF, radixTF;
|
||||
|
||||
public DecToXXX() {
|
||||
super("Десятичная в ???");
|
||||
numberTF = new TextField("Исходное число в десятичной системе счисления", "", 10, TextField.NUMERIC);
|
||||
radixTF = new TextField("Система счисления, в которую переводим", "", 2, TextField.NUMERIC);
|
||||
nextCMD = new Command("Далее", Command.OK, 1);
|
||||
backCMD = new Command("На главную", Command.BACK, 2);
|
||||
addCommand(nextCMD);
|
||||
addCommand(backCMD);
|
||||
append(numberTF);
|
||||
append(radixTF);
|
||||
setCommandListener(DecToXXX.this);
|
||||
}
|
||||
|
||||
public void commandAction(Command c, Displayable d) {
|
||||
if (c.equals(List.SELECT_COMMAND) || c.equals(nextCMD)) {
|
||||
long num = 0;
|
||||
int osn = 2;
|
||||
try {
|
||||
String numStr = numberTF.getString();
|
||||
String osnStr = radixTF.getString();
|
||||
if ("".equals(numStr) || "".equals(osnStr)) {
|
||||
alert("Не заполнены поля");
|
||||
return;
|
||||
}
|
||||
num = Long.parseLong(numberTF.getString());
|
||||
osn = Integer.parseInt(radixTF.getString());
|
||||
if (osn < 2) {
|
||||
alert("Основание должно быть не меньше 2");
|
||||
return;
|
||||
}else if (osn > 36 ) {
|
||||
alert("Для систем счисления больше 36 просто не хватит символов =(");
|
||||
return;
|
||||
}
|
||||
} catch (NumberFormatException nun) {
|
||||
alert("Неверные данные");
|
||||
return;
|
||||
}
|
||||
Main.midlet.dsp.setCurrent(new Core(num, osn));
|
||||
} else if (c.equals(backCMD)) {
|
||||
Main.midlet.dsp.setCurrent(Main.midlet.main);
|
||||
}
|
||||
}
|
||||
|
||||
private void alert(String msg) {
|
||||
Main.midlet.dsp.setCurrent(new Alert(ERROR, msg, null, AlertType.ERROR), Main.midlet.dsp.getCurrent());
|
||||
}
|
||||
}
|
30
src/Main.java
Normal file
30
src/Main.java
Normal file
@ -0,0 +1,30 @@
|
||||
import javax.microedition.lcdui.*;
|
||||
import javax.microedition.midlet.*;
|
||||
|
||||
/**
|
||||
* @author aNNiMON
|
||||
*/
|
||||
public class Main extends MIDlet {
|
||||
|
||||
public Display dsp;
|
||||
public static Main midlet;
|
||||
public MenuCanvas main;
|
||||
|
||||
public Main() {
|
||||
midlet = Main.this;
|
||||
dsp = Display.getDisplay(Main.this);
|
||||
|
||||
}
|
||||
|
||||
public void startApp() {
|
||||
main = new MenuCanvas();
|
||||
dsp.setCurrent(main);
|
||||
}
|
||||
|
||||
public void pauseApp() {
|
||||
}
|
||||
|
||||
public void destroyApp(boolean un) {
|
||||
notifyDestroyed();
|
||||
}
|
||||
}
|
81
src/MenuCanvas.java
Normal file
81
src/MenuCanvas.java
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* aNNiMON 2011
|
||||
* For more info visit http://annimon.com/
|
||||
*/
|
||||
|
||||
import com.annimon.ui.EConst;
|
||||
import com.annimon.ui.ESkin;
|
||||
import com.annimon.ui.EWindow;
|
||||
import javax.microedition.lcdui.Graphics;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author aNNiMON
|
||||
*/
|
||||
public class MenuCanvas extends EWindow {
|
||||
|
||||
private String[] elements;
|
||||
/** Позиция первого пункта меню */
|
||||
private int firstItemPosition;
|
||||
/** Высота шрифта*/
|
||||
private int fontHeight;
|
||||
/** Текущий выбранный пункт */
|
||||
private int itemIndex;
|
||||
/** Плавность курсора */
|
||||
private int smoothCursor;
|
||||
|
||||
public MenuCanvas() {
|
||||
super("Notations");
|
||||
elements = new String[] {"DEC в ???", "??? в ???", "О программе", "Выход"};
|
||||
fontHeight = EConst.mainFont.getHeight() + 2;
|
||||
smoothCursor = 0;
|
||||
itemIndex = 0;
|
||||
firstItemPosition = hh / 6;
|
||||
}
|
||||
|
||||
public void paint(Graphics g, int w, int h) {
|
||||
int hc = firstItemPosition + smoothCursor + itemIndex * fontHeight;
|
||||
g.setFont(EConst.mainFont);
|
||||
g.setColor(ESkin.textColor2);
|
||||
for (int i = 0; i < elements.length; i++) {
|
||||
if (i == itemIndex) continue;
|
||||
g.drawString(elements[i], w / 2, firstItemPosition + i * fontHeight, Graphics.HCENTER | Graphics.TOP);
|
||||
}
|
||||
g.setColor(ESkin.textColor);
|
||||
g.drawRoundRect(5, hc, w - 10, fontHeight, 15, 15);
|
||||
g.drawString(elements[itemIndex], w / 2, firstItemPosition + itemIndex * fontHeight, Graphics.HCENTER | Graphics.TOP);
|
||||
if (smoothCursor < 0) {
|
||||
smoothCursor += 2;
|
||||
} else if (smoothCursor > 0) {
|
||||
smoothCursor -= 2;
|
||||
}
|
||||
if (smoothCursor > 1 || smoothCursor < -1) {
|
||||
redraw();
|
||||
}
|
||||
}
|
||||
|
||||
public void keyEvent(int key, byte state) {
|
||||
if (state != RELEASED) {
|
||||
int ga = getGameAction(key);
|
||||
if (ga == UP && itemIndex > 0) {
|
||||
itemIndex--;
|
||||
smoothCursor = fontHeight;
|
||||
} else if (ga == DOWN && itemIndex < elements.length - 1) {
|
||||
itemIndex++;
|
||||
smoothCursor = -fontHeight;
|
||||
} else if (ga == FIRE) {
|
||||
menuAction(itemIndex);
|
||||
}
|
||||
}
|
||||
redraw();
|
||||
}
|
||||
|
||||
private void menuAction(int itemIndex) {
|
||||
switch(itemIndex) {
|
||||
case 0: Main.midlet.dsp.setCurrent(new DecToXXX()); break;
|
||||
case 1: Main.midlet.dsp.setCurrent(new XXXToXXX()); break;
|
||||
case 2: Main.midlet.dsp.setCurrent(new About(elements[2])); break;
|
||||
case 3: Main.midlet.destroyApp(true); break;
|
||||
}
|
||||
}
|
||||
}
|
59
src/XXXToXXX.java
Normal file
59
src/XXXToXXX.java
Normal file
@ -0,0 +1,59 @@
|
||||
|
||||
import javax.microedition.lcdui.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author aNNiMON
|
||||
*/
|
||||
public class XXXToXXX extends Form implements CommandListener {
|
||||
|
||||
private Command calcCMD, backCMD;
|
||||
private TextField numberTF, radixToTF, radixFromTF, resultTF;
|
||||
|
||||
public XXXToXXX() {
|
||||
super("??? в ???");
|
||||
numberTF = new TextField("Исходное число", "", 10, TextField.ANY);
|
||||
radixFromTF = new TextField("Система счисления этого числа", "", 2, TextField.NUMERIC);
|
||||
radixToTF = new TextField("Система счисления, в которую переводим", "", 2, TextField.NUMERIC);
|
||||
resultTF = new TextField("Результат", "", 256, TextField.ANY);
|
||||
calcCMD = new Command("Расчет", Command.OK, 1);
|
||||
backCMD = new Command("На главную", Command.BACK, 2);
|
||||
addCommand(calcCMD);
|
||||
addCommand(backCMD);
|
||||
append(numberTF);
|
||||
append(radixFromTF);
|
||||
append(radixToTF);
|
||||
append(resultTF);
|
||||
setCommandListener(XXXToXXX.this);
|
||||
}
|
||||
|
||||
private void alert(String msg) {
|
||||
Main.midlet.dsp.setCurrent(new Alert("Ошибка", msg, null, AlertType.ERROR), Main.midlet.dsp.getCurrent());
|
||||
}
|
||||
|
||||
public void commandAction(Command c, Displayable d) {
|
||||
if (c.equals(List.SELECT_COMMAND) || c.equals(calcCMD)) {
|
||||
int s1 = 10;
|
||||
int s2 = 16;
|
||||
long n1 = 0;
|
||||
try {
|
||||
s1 = Integer.parseInt(radixFromTF.getString().trim());
|
||||
s2 = Integer.parseInt(radixToTF.getString().trim());
|
||||
} catch (Exception ne) {
|
||||
alert("Неверное число в качестве основания");
|
||||
}
|
||||
if ((s1 < 2) || (s1 > 36) || (s2 < 2) || (s2 > 36)) {
|
||||
alert("Основание должно быть от 2 до 36");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
n1 = Long.parseLong(numberTF.getString().trim(), s1);
|
||||
} catch (Exception ne) {
|
||||
alert("Неверное число для конвертирования");
|
||||
}
|
||||
resultTF.setString(Long.toString(n1, s2));
|
||||
} else if (c.equals(backCMD)) {
|
||||
Main.midlet.dsp.setCurrent(Main.midlet.main);
|
||||
}
|
||||
}
|
||||
}
|
29
src/com/annimon/StringEncoder.java
Normal file
29
src/com/annimon/StringEncoder.java
Normal file
@ -0,0 +1,29 @@
|
||||
package com.annimon;
|
||||
|
||||
public class StringEncoder {
|
||||
|
||||
protected static char[] cp1251 = {
|
||||
'\u0410', '\u0411', '\u0412', '\u0413', '\u0414', '\u0415', '\u0416',
|
||||
'\u0417', '\u0418', '\u0419', '\u041A', '\u041B', '\u041C', '\u041D',
|
||||
'\u041E', '\u041F', '\u0420', '\u0421', '\u0422', '\u0423', '\u0424',
|
||||
'\u0425', '\u0426', '\u0427', '\u0428', '\u0429', '\u042A', '\u042B',
|
||||
'\u042C', '\u042D', '\u042E', '\u042F', '\u0430', '\u0431', '\u0432',
|
||||
'\u0433', '\u0434', '\u0435', '\u0436', '\u0437', '\u0438', '\u0439',
|
||||
'\u043A', '\u043B', '\u043C', '\u043D', '\u043E', '\u043F', '\u0440',
|
||||
'\u0441', '\u0442', '\u0443', '\u0444', '\u0445', '\u0446', '\u0447',
|
||||
'\u0448', '\u0449', '\u044A', '\u044B', '\u044C', '\u044D', '\u044E',
|
||||
'\u044F'
|
||||
};
|
||||
|
||||
public static char decodeCharCP1251(byte b) {
|
||||
int ich = b & 0xff;
|
||||
if (ich == 0xb8) {
|
||||
return 0x0451;
|
||||
} else if (ich == 0xa8) {
|
||||
return 0x0401;
|
||||
} else if (ich >= 0xc0) {
|
||||
return cp1251[ich - 192];
|
||||
}
|
||||
return (char) ich;
|
||||
}
|
||||
}
|
47
src/com/annimon/XID.java
Normal file
47
src/com/annimon/XID.java
Normal file
@ -0,0 +1,47 @@
|
||||
package com.annimon;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author aNNiMON
|
||||
*/
|
||||
public class XID {
|
||||
|
||||
public String loadText(String path) {
|
||||
try {
|
||||
byte[] data = getBytes(path);
|
||||
StringBuffer text = new StringBuffer();
|
||||
for(int i = 0; i < data.length; i++) {
|
||||
text.append(StringEncoder.decodeCharCP1251(data[i]));
|
||||
}
|
||||
return text.toString();
|
||||
} catch (Exception in) {
|
||||
in.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] getBytes(String path) throws IOException {
|
||||
InputStream is = new DataInputStream(getClass().getResourceAsStream(path));
|
||||
int b1 = is.read();
|
||||
int b2 = is.read();
|
||||
int length = ((b2 << 8) | b1);
|
||||
byte[] data = new byte[length];
|
||||
is.read(data, 0, length);
|
||||
is.close();
|
||||
data = invertArray(data);
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private byte[] invertArray(byte[] fileData) {
|
||||
int len = fileData.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
fileData[i] ^= 119;
|
||||
}
|
||||
return fileData;
|
||||
}
|
||||
|
||||
}
|
50
src/com/annimon/ui/ECanvas.java
Normal file
50
src/com/annimon/ui/ECanvas.java
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* aNNiMON 2011
|
||||
* For more info visit http://annimon.com/
|
||||
*/
|
||||
|
||||
package com.annimon.ui;
|
||||
|
||||
import javax.microedition.lcdui.Canvas;
|
||||
|
||||
/**
|
||||
* Расширенный класс Canvas
|
||||
* @author aNNiMON
|
||||
*/
|
||||
public abstract class ECanvas extends Canvas {
|
||||
|
||||
public final int //константы клавиш
|
||||
KEY_LSK = -6, //левый софт
|
||||
KEY_RSK = -7; //правый софт
|
||||
public final byte
|
||||
PRESSED = 0,
|
||||
REPEATED = 1,
|
||||
RELEASED = 2;
|
||||
|
||||
public int w,h;
|
||||
|
||||
public ECanvas() {
|
||||
setFullScreenMode(true);
|
||||
w = getWidth();
|
||||
h = getHeight();
|
||||
}
|
||||
|
||||
public void keyPressed(int key) {
|
||||
keyEvent(key, PRESSED);
|
||||
}
|
||||
|
||||
public void keyRepeated(int key) {
|
||||
keyEvent(key, REPEATED);
|
||||
}
|
||||
|
||||
public void keyReleased(int key) {
|
||||
keyEvent(key, RELEASED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Обработчик клавиатуры
|
||||
* @param key - код клавиши
|
||||
* @param state - состояние клавиши (нажата, отпущена, зажата)
|
||||
*/
|
||||
public abstract void keyEvent(int key, byte state);
|
||||
}
|
19
src/com/annimon/ui/EConst.java
Normal file
19
src/com/annimon/ui/EConst.java
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* aNNiMON 2011
|
||||
* For more info visit http://annimon.com/
|
||||
*/
|
||||
|
||||
package com.annimon.ui;
|
||||
|
||||
import javax.microedition.lcdui.Font;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author aNNiMON
|
||||
*/
|
||||
public class EConst {
|
||||
|
||||
public static final Font titleFont = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_LARGE);
|
||||
public static final Font mainFont = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_MEDIUM);
|
||||
|
||||
}
|
21
src/com/annimon/ui/ESkin.java
Normal file
21
src/com/annimon/ui/ESkin.java
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* aNNiMON 2011
|
||||
* For more info visit http://annimon.com/
|
||||
*/
|
||||
|
||||
package com.annimon.ui;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author aNNiMON
|
||||
*/
|
||||
public class ESkin {
|
||||
|
||||
public static int
|
||||
cellColor = 0xADAFAF, // цвет клеток
|
||||
textColor = 0x4D3E7E, // цвет текста
|
||||
textColor2 = 0x5D5D5D, // цвет недоступного текста
|
||||
lineColor = 0xEE487A, // цвет линии полей
|
||||
|
||||
bg = 0xECF1FF; //фон
|
||||
}
|
87
src/com/annimon/ui/EWindow.java
Normal file
87
src/com/annimon/ui/EWindow.java
Normal file
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* aNNiMON 2011
|
||||
* For more info visit http://annimon.com/
|
||||
*/
|
||||
|
||||
package com.annimon.ui;
|
||||
|
||||
import javax.microedition.lcdui.Graphics;
|
||||
|
||||
/**
|
||||
* Класс окна EmOS
|
||||
* @author aNNiMON
|
||||
*/
|
||||
public abstract class EWindow extends ECanvas {
|
||||
|
||||
/** Отуступ */
|
||||
private static final int BORDER = 5;
|
||||
/** Размер клеточек */
|
||||
private static final int CELL_SIZE = 14;
|
||||
|
||||
/** Размеры рабочей области */
|
||||
protected int ww, hh;
|
||||
|
||||
/** Заголовок окна */
|
||||
private String title;
|
||||
/** Размер шрифта */
|
||||
private int fontHeight;
|
||||
|
||||
public EWindow(String title) {
|
||||
super();
|
||||
this.title = title;
|
||||
fontHeight = EConst.titleFont.getHeight();
|
||||
ww = w - BORDER * 2;
|
||||
hh = h - fontHeight - BORDER * 2;
|
||||
}
|
||||
|
||||
protected void sizeChanged(int w, int h) {
|
||||
super.w = w;
|
||||
super.h = h;
|
||||
ww = w - BORDER * 2;
|
||||
hh = h - fontHeight - BORDER * 2;
|
||||
super.sizeChanged(w, h);
|
||||
}
|
||||
|
||||
|
||||
public void paint(Graphics g) {
|
||||
// Задний фон
|
||||
g.setColor(ESkin.bg);
|
||||
g.fillRect(0, 0, w, h);
|
||||
// Клеточки
|
||||
g.setColor(ESkin.cellColor);
|
||||
int cellSize = CELL_SIZE * w / 240;
|
||||
for(int x = 0; x < w; x += cellSize) {
|
||||
g.drawLine(x, 0, x, h);
|
||||
}
|
||||
for (int y = 0; y < h; y += cellSize) {
|
||||
g.drawLine(0, y, w, y);
|
||||
}
|
||||
// Текст заголовка
|
||||
g.setFont(EConst.titleFont);
|
||||
g.setColor(ESkin.textColor);
|
||||
g.drawString(title, BORDER, 0, 20);
|
||||
// Линия полей
|
||||
g.setColor(ESkin.lineColor);
|
||||
int y = fontHeight + BORDER / 2;
|
||||
g.drawLine(0, y, w, y);
|
||||
// Ограничение рабочей области
|
||||
g.setClip(BORDER, fontHeight + BORDER, ww, hh);
|
||||
g.translate(BORDER, fontHeight + BORDER);
|
||||
|
||||
paint(g, ww, hh);
|
||||
}
|
||||
|
||||
/** Перерисовка рабочей области окна */
|
||||
protected void redraw() {
|
||||
repaint(BORDER, fontHeight + BORDER, ww, hh);
|
||||
}
|
||||
|
||||
/**
|
||||
* Метод отрисовки рабочей области окна
|
||||
* @param g - Graphics
|
||||
* @param w - ширина рабочей области
|
||||
* @param h - высота рабочей области
|
||||
*/
|
||||
public abstract void paint(Graphics g, int w, int h);
|
||||
|
||||
}
|
BIN
src/icon.png
Normal file
BIN
src/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 162 B |
Loading…
Reference in New Issue
Block a user