NTNUJAVA Virtual Physics Laboratory
Enjoy the fun of physics with simulations!
Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/

Easy Java Simulations (2001- ) => Questions related to EJS => Topic started by: lookang on August 13, 2007, 08:40:38 am



Title: can the interface - field - format show special characters like alpha
Post by: lookang on August 13, 2007, 08:40:38 am
hihi,

please advise how can i get the symbol alpha to display under the format of a field 2.0.


original result it shown as 
(http://)

i keyed in the α into the format, before compling looks correct
(http://)

after compling, a ? appears in place of α
(http://)

thanks for helping  ;D


Title: Re: can the interface - field - format show special characters like alpha
Post by: lookang on August 13, 2007, 08:55:07 am
attached is my xml.

thanks!


Title: Re: can the interface - field - format show special characters like alpha
Post by: Fu-Kwun Hwang on August 13, 2007, 12:10:23 pm
It works on my computer. May be your computer did not support such font?
Please check out the attached file.


Title: Re: can the interface - field - format show special characters like alpha
Post by: lookang on August 13, 2007, 12:42:20 pm
interesting!!!

i will try at home later.

by the way, can i download your  xml file to see if it works on this pc :)

thanks


Title: Re: can the interface - field - format show special characters like alpha
Post by: Fu-Kwun Hwang on August 13, 2007, 01:28:31 pm
File is attached!


Title: Re: can the interface - field - format show special characters like alpha
Post by: lookang on August 13, 2007, 01:39:44 pm
i am in a dilemma.

I think the problem is the pc here.

the alpha (in your system) is display as some funny thing (pound sign and a stroke) on this pc.

I will try to sort things out on my end.

thanks for your help :)



Title: Re: can the interface - field - format show special characters like alpha
Post by: Fu-Kwun Hwang on August 13, 2007, 02:31:35 pm
It is related to character coding system used in the operating system.
Because I used Chinese operating system, the character code is not unisersal for those special characters(fonts).
Unless it was translated into UTF-8 code, otherwise, you would not be able to see it correctly.
 


Title: Re: can the interface - field - format show special characters like alpha
Post by: lookang on August 13, 2007, 11:19:19 pm
i tried using TT fonts , seems to work.

the closest match the alpha i can find is this one.

don't seems to work if i use those O fonts on the interface text field.

any tips ? :D


Title: Re: can the interface - field - format show special characters like alpha
Post by: Fu-Kwun Hwang on August 13, 2007, 11:22:25 pm
I do not understand what do you mean by
"using TT fonts, seems to work. ... don't seems to work if i use those O fonts on the interface text field."


Title: Re: can the interface - field - format show special characters like alpha
Post by: lookang on August 13, 2007, 11:29:16 pm
i was experiment with true type fonts TT, the pound sign work!!, then i tried others, seems to work


i previously tried those with O , because alpha symbol is from say times news roman. It seems the text field can't recognise the true alpha symbol in java text field.

am i on the right track ?

the pictures may explain what is O(not sure what it means) and TT(true type)


Title: Re: can the interface - field - format show special characters like alpha
Post by: Fu-Kwun Hwang on August 14, 2007, 12:02:33 am
I found out how to make it from the web search.
The String value for alpha (http://www.fileformat.info/info/unicode/char/03b1/index.htm) is "\u03B1"

So if you define s="\u03B1=2.3"; as a variable in the ejs model and asign s to variable for text field
It should display as what you want. Please check out the attached file.
And it should work for all the operating system.

You can find the unicode for other characters from Unicode Character Search (http://www.fileformat.info/info/unicode/char/search.htm)


Title: Re: can the interface - field - format show special characters like alpha
Post by: lookang on August 14, 2007, 12:31:34 am
thanks for help.

i understand the idea about making it to strings.

but i think i do it for the plotting panel only.

EJS keep hanging on me when i tried to change the field_old 1.0 to take the string.

2 times already.

appreciate the help, this idea i going to use it on the plotting panel to show the angle with a polygon.

my next design improvement :D


Title: Re: can the interface - field - format show special characters like alpha
Post by: lookang on August 14, 2007, 07:45:58 am
i did it!!

thanks prof hwang for the idea of using text field , i horizontal box with the field.

in the variable for text field %alphasymbol%

alphasymbol is defined as a string in the declaration as "\u03B1"

thanks for your advice.

BTW

my xml file is getting big ~100 kb, soon i will be unable to upload the xml here.


Title: Re: can the interface - field - format show special characters like alpha
Post by: lookang on August 14, 2007, 07:56:22 am
supporting pictures of what i meant.

for the rest learning from forum.


Title: Re: can the interface - field - format show special characters like alpha
Post by: Fu-Kwun Hwang on August 14, 2007, 01:02:05 pm
thanks for help.

i understand the idea about making it to strings.

but i think i do it for the plotting panel only.

EJS keep hanging on me when i tried to change the field_old 1.0 to take the string.

2 times already.

appreciate the help, this idea i going to use it on the plotting panel to show the angle with a polygon.

my next design improvement :D

You should be able to use the same technique for the textString GUI element (to be added into the PlottingPanel).
Check out the EjsConsole, it will provide information about run time error to know why the ejs was hanging.


Title: Re: can the interface - field - format show special characters like alpha
Post by: lookang on December 04, 2008, 10:46:25 am
found another way to draw symbol in EJS thanks to http://www.compadre.org/OSP/document/ServeFile.cfm?ID=8243&DocID=881  Rocket Car on an Inclined Plane Model
written by Wolfgang Christian, Francisco Esquembre, and Mario Belloni

I look at the source code and realise how they implement:

Quote
\$\\beta\$
                by changing beta to gamma , alpha , theta

interesting huh?

for your info

BTW the text \$\\beta\$
dollarsign\\betadollarsign cannot display


Title: Re: can the interface - field - format show special characters like alpha
Post by: Fu-Kwun Hwang on December 04, 2008, 04:55:28 pm
It is because this forum will display mathematic equation if you put some TeX syntax between dollar sign.
For example:
\$ \alpha+ \beta +\Gamma \$
will display
$ \alpha+ \beta +\Gamma $
(It is similar to what will be display in EJS when you type equations in TeX format.  Because EJS code was compiled with java , so you need to add two backslashes to translate into one backslashes during the java string processing.)

You can also use _ and ^ to get subscript and superscript effect (and many more TeX mathematic equation features.)

If you want to display dollar sign, please add a backslash in front of dollar sign.
\\$


Title: Re: can the interface - field - format show special characters like alpha
Post by: lookang on December 04, 2008, 05:10:51 pm
that's cool! will try next time!