Showing posts with label eclipse. Show all posts
Showing posts with label eclipse. Show all posts

07 January 2016

Quick way to import a jar in Eclipse

Following is a quick demonstration to import .jar files via Eclipse IDE



See Also: TRIE ADT Tutorial


You will need to understand why you are doing this. Any java program, for it to execute, first needs to be compiled without errors. The compilation process (using "javac") is going to convert your source code into bytecode (.class) file which you can then use the "java" executable to run. An IDE like Eclipse will do the compilation automatically in the background. That is why when you have any sort of error in the program (syntax/logical etc.,), you see it getting highlighted immediately. 

So, when you are referencing an external library, javac executable needs to know which library you are referencing. You can do this by setting the CLASSPATH variable before executing the program if it is via command line. Eclipse makes it easier, instead of specifying the Java library file's location through the command line, you can do it through the editor by Right clicking on the project and selecting Build Path --> Configure Build Path. With the Libraries tab selected, click on "Add External Archives" and give your .jar files. Your program should now compile smoothly without errors.

Using an IDE introduces insane efficiency for designing and development. However, always have an understanding of what is going behind the scenes. Hope you learned something useful today!

Cheers!
Braga

05 February 2008

SWT / Java2D setTransform() problems!!!!

I will post one of the problems that i faced while i was in the design phase and was really confused about the strange features of RCP. That time, i wasnt knowing the solution and only few may have come across one. Eventually, i found the answer.



I may not know how many have you have come across this bug or error or impotentness..
Its between Java2d and swt..

Here is the snippet of java2d version

public void paint(Graphics g){
AffineTransform transform = new AffineTransform();
transform.scale(10,10);//any scale value am specifying
transform.translate(100,100);//any translation value

((Graphics2D)g).setStroke(new BasicStroke(0.0001f));
((Graphics2D)g).setTransform(transform);

g.draw( );//say a general path
}


Here is the swt version for the same
public void paintControl(PaintEvent e){
Transform transform = new Transform(e.getDevice());
transform.scale(10,10);//any scale value am specifying
transform.translate(100,100);//any translation value

e.gc.setLineWidth(1);//This is the least am able to specify
e.gc.draw(path);//Here path is org.eclipse.swt.graphics.Path
}


Both code looks almost the same. The basic problem here is this. In the former case, say i am giving a state boundary for the path and i am scaling the same. It is working just fine. (State boundary is the boundary of say Florida which might have latitude and longitude values like -83.45645631, 22.45646413)

But not so in SWT. In swt, the value of path variables are rounded off or casted to int and then the scale is applied which is a serious problem!!!!. Whereas, i need a mechanism where the scale is first applied and then it is casted to int. Moerover, the setLineWidth() method is taking a value of minimum 1 which when scaled to say 10 times, the thickness also is proportionately increasing.

This is killing me for the past one week and i cannot make any progress in this issue. If someone knows the internals or how to overcome this issue, kindly reply!!!!

Thanks in advance.

Braga




The solution to the above problem was simple : There is no solution.

Yes, At the time i was trying to create the application in RCP, it wont support Vector graphic features, which means you will not be able to draw images on the screen with double precision values. This was a huge setback for me. I thought of designing my full application in RCP and had a thorough understanding of the beautiful eclipse framework until i saw an IEEE paper presented by some college grads claiming the cons of RCP being its lack supportive towards Eclipse's RCP.

An application from the scratch

I have designed an application purely using java that has lots of spatial features. I had doubt of whether to use good old java swings or some other UI such as RCP. Well, I started my application in RCP first. The one good thing I did while creating it was the framework. I made it independent of the front end (doesn’t matter what UI you are gonna use, the core logic remains the same). What I mean to say is that, there are these map viewing/editing functionalities which do not depend on what UI being used. For example, take the simple zoom functionality. If I am going to zoom to some part of my map in the front end, all that has to happen in the background is to query for the newly zoomed area and send it back to the front end. Now, it can be sent to anywhere. It may be a swing front end or Eclipse RCP or even a C++ UI or you can even send it as a response to a HTTP request. That’s how flexible your app should be. I will provide as many details about the one I have done.

04 February 2008

Kick off

When I initially launched this website I thought I would fully focus on geo spatial applications but it was not a big hit. The following article was the first one I wrote regarding it and unfortunately it was the last one too as the ship turned direction towards DSA and Java. However, for memoir, I am keeping it.

Let me kick off with the basic understaing needed about a spatial application.

Your spatial application may be a,
1) Basic standalone version dealing with basic map viewing features such as zoom, pan etc which can be used for basic viewing purposes alone.
2) Advanced standalone version which combines the basic features along with area marking, advanced searching (searching with buffers), cartographic features etc.,
3) Web application which has a common server that serves a variety of clients who need to work on a particular region/area. It can even include ajax and web 2.0 capabilites.
Requirements are endless.

But why people really need all these? Why do they need a map viewing application?
Well, the answer is pretty straight forward. Cost cutting. There are lots of map viewing applications that are available in market which has a lot of features and cool tekniques that come with ready made frameworks. But they all have the following disadvantages,
1) As said earlier, cost is a major factor.
2) Just buying enough licenses from these spatial companies is never going to be enough. You need to have a in-depth understanding of your needs and a proper design has to be followed. Without that, whatever support or assistance you are going to get from the third party company will go into waste.
3) Limit to your imagination. If you want to develop a spatial application that need to address your expectation (mainly performance), then you should definitely ponder over your decision whether or not should i go for a third party application for my maps.
4) All major companies using geo spatial applications may at times blindly fall in trap for these geo spatial vendors without exploring enough on the beautiful open source communities (eg., www.opensourcegis.org ) available in the web and the range of free products they give.

I guess i will stop here for a kick-off. Will be back with more information. Till then, its bye from,
Bragaadeesh.