"I Think, I Conceptualize, I Analyze, I Design, and I Create." ~ Puneet Kalra

Cognitive Robotics Research Centre Of University Of Wales, Newport Puneet Kalra

Home Studies Research Projects Tutorials Portfolio

Puneet Kalra - www.puneetk.com - Socializing Robots

Getting started with Eclipse

January 12th, 2012

Hey everyone,

In this post, I will discuss how to create projects within Eclipse.

Once Eclipse is installed (but I’m using portable version) and when you firstly run it. Follow the steps in order to create java projects :

1 – Click File menu or right click on the Project explorer.
2 – Select New menu and choose ‘Java Project’.

‘New Java Project’ wizard will open. The very first field is Project name, give it a meaningful project name. In this example, I’m giving it “Hello_World”. Make sure the latest or default JRE option is selected in JRE group. Then click ‘Next’ button. Next form allows you to check and modify Java build settings which you don’t really need to worry about now and simply click the ‘Finish’ button.

Now you can see your Project in Project Explorer. Double click on it, now you will see ’src’ node right under the Project. Right click on ’src’ node, select New menu and choose ‘Class’. ‘New Java Class’ wizard will open. Ignoring other advance fields, Simply enter the name of class in Class field. In this example, I’m using “HelloWorld”. Make sure modifier field is set to public and Superclass field is java.lang.Object. Also, tick the check box with public static void main(String[] args) and click ‘Finish’ button.

A new ‘HelloWorld.java’ tab will open in editor with code :

public class HelloWorld {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

	}

}

Right after the line : public static void main (String[] args)
Add another line : System.out.println(”Hello World”);

And all together, It should look like this :

public class HelloWorld {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		System.out.println("Hello World");
	}

}

To run it, right click anywhere in the HelloWorld.java tab, select ‘Run As’ menu and choose ‘Java Application’.

That’s it for this post. I will come up with more Java tasks for my portfolio work. PK!

Pwing Update – Introducing ‘PStylishFrame’

October 7th, 2010

Hello Everyone,

Now, This one is going to be completely Pwing Update! Better painting, more theme colors, supports more components and introducing ‘PStylishFrame’.

Lets talk about PStylishFrame, inspired from LooknFeel of Mozilla Firefox 4, Google Chrome and other latest web browsers. We ( I and my trainee’s ) decided to create one such stylish frame for Pwing users. So here’s the very first screen shot of Pwing’s PStylishFrame.
Pwing GUI Toolkit's JStylishFrame ScreenShot
We are not yet done with it. Currently it supports Pwing’s Black color theme only. It’s not resizeable. It supports PStatusBar, which is another new component added in Pwing toolkit.

We have made few changes in component painting for better performance. Changed the Pwing’s component Hierarchy. Now most of the components extends ‘PComponent’ as their Superclass. PComponent has all the basic properties required to create a Pwing based component.

Pwing supports 4 color themes now and those are Black, Blue, Pink and Green. Blue is default theme for all the components if you don’t set any Theme Controller (Controller class) on them.

List of new added Components : PComponent, PStylishFrame, PStatusBar and PProgressBar.
Upcoming Components : PStylishMenu, PScaleBar, and PSplash.

I will update source on SVN Repository but Binary/Source JARs will posted once components listed above are done and tested on all color themes.

Pwing’s Project Page

void(’PK’)

Basics of Java Speech Grammar Format ( JSGF )

March 12th, 2010

Hello Everyone,

This post is my response to those 4 help requests that i received in last few days. This one is going to be very basic and essentials of Java Speech Grammar Format ( JSGF ).

Every single file defines a single grammar only. Each grammar contains two parts:
The grammar header and the grammar body.

Grammar header format : #JSGF version char-encoding locale;

“#JSGF” is required and “version char-encoding locale;” is optional.

Grammar header example : #JSGF V1.0; & #JSGF V1.0 ISO8859-5 en;



After declaring Grammar Header, We need to specify the Grammar name.

Grammar name format : grammar grammarName;

This is a mandatory line. Else javax.speech.recognition.GrammarException will be thrown. Not only on Grammar Name, you will get GrammarExpection If you made any kind of mistake in grammar file.

Grammar Name Example : grammar helloWorld;



Once you are done with above part, you next step will be defining Grammar body.
The grammar body defines rules. you can define a rule only once. If you declare same rule twice then it will overwritten.

Rule Definition Format : public <ruleName> = ruleExpansion;

“public” is optional and remaining part is mandatory.
The rule expansion defines how the rule may be spoken. It is a logical combination of tokens (text that may be spoken) and references to other rules.

Rule Example : public <greet> = Hello;

The rule <greet> refers to a single token Hello. So to say rule <greet>, User must say word “Hello”.

A simple rule expansion can refer to one or more tokens or rules.

public <greet> = Hello;
public <completeGreet> = <greet> World;

Now, rule <completeGreet> refers to rule <greet> and token World. To say rule <completeGreet>, User must say “Hello World”.

Lets complete a simple “Hello World” grammar file.

#JSGF V1.0;

grammar simpleExample;

public <greet> = Hello;
public <completeGreet> = <greet> World;

This grammar file will allow you SR application to recognize 2 sentences. “Hello” and “Hello World”.

Now lets play a little bit with rule expansions.

Alternatives : “|”

public <greet> = Hello | Hey | Hi;

To say rule <greet>, User must say “Hello” or “Hey” or “Hi” But ONLY one of these three words.

Parentheses : “( )”

public <greet> = Hello ( World | User | Friend );
public <command> = ( Open | Close ) ( Door | Window );

To say rule <greet>, User must say “Hello World” or “Hello User” or “Hello Friend”.
And, to say rule <command>, User must say “Open Door” or “Open Window” or “Close Door” or “Close Window”.

Optional Grouping : “[ ]”

public <greet> = [ Hello ] World;

To say rule <greet>, User must say “Hello World” or “World”. As “Hello” is defined inside the Optional Grouping. So user may say it or not but “World” is mandatory.

Kleene Star : “*”

public <greet> = ( Hello | Hey | Hi )* World;

Any group or expansion followed by asterisk symbol indicates that it may be spoken zero or more times. For example “Hey Hello World” or “World” or “Hello Hello Hello World”.

Plus Operator : “+”

public <greet> = ( Hello | Hey | Hi )+ World;

A Plus Operator works same as “Kleene Star”, The only thing that makes difference is any group or expansion followed by plus symbol indicates that it may be spoken one ( NOT ZERO ) or more times.

You can also add comments in grammar file.

// One line comment
/* Multiple lines comment*/
/**
* Documentation comment
* @author Puneet Kalra
*/


Hope this tutorial clears all your doubts on JSGF.

More updates to come soon!
Regards,

Another Open Source Project (Pwing)

January 28th, 2010

Finally,

We have published “Pwing”, An other Open Source project.

Pwing Logo Pwing is a GUI toolkit, Is a set of widgets/components for use in designing applications with graphical user interfaces (GUI’s). It is based on Swing toolkit, part of Sun Microsystem’s Java Foundation Classes (JFC) API. It is developed to provide a better set of components to create more interactive GUI based applications in Java. Each component facilitates a specific user-computer interaction, and appears as a visible part of the computer’s GUI.
 

Pwing Example

 



Examples, Executable JAR’s , Source JAR’s and Complete package is available for download.


Official Pwing Website : http://puneetk.com/pwing
Pwing’s SF Website : http://sourceforge.net/projects/pwing/


Regards,

Pwing

January 22nd, 2010
Pwing - Custom GUI for Java

Pwing - Custom GUI for Java

Introducing Pwing ..

Pwing is a GUI toolkit, Is a set of widgets/components for use in designing applications with graphical user interfaces (GUI’s). It is based on Swing toolkit, part of Sun Microsystem’s Java Foundation Classes (JFC) API. It is developed to provide a better set of components to create more interactive GUI based applications in Java. Each component facilitates a specific user-computer interaction, and appears as a visible part of the computer’s GUI.

Pwing is currently being developed by a merge team of my trainees and Parul Kalra’s trainees at MBN Informatics. Soon it will be published as Open Source project on SourceForge.

Stay tuned !