Wednesday, 2 October 2013

pass by reference in java

In java there is no pointer concepts. So pass by reference using pointer is not possible in java. In java pass by reference is achieved by passing objects as arguments. It is possible to pass objects as argument to a function in java. In this post i am going to explain how to pass an object as reference in java.
Ads by Google


For better understanding consider the code segment given bellow. 
      class TestClass  
{
String msg;
public TestClass(String msg)
{
this.msg = msg;
}
public boolean checkObject(TestClass obj)
{
if(obj.msg.equals(msg))
return true;
else
return false;
}
}
public class ObjectPassing
{
public static void main(String args[])
{
TestClass test1 = new TestClass("Apple");
TestClass test2 = new TestClass("Orange");
TestClass test3 = new TestClass("Apple");
System.out.println("test1 = test2 :"+test1.checkObject(test2));
System.out.println("test1 = test3 :"+test1.checkObject(test3));
}
}

In this example the TestClass contain a method called checkObject, which accept an object as argument. Here you can see that the type of the argument is the name of the class.
     public boolean checkObject(TestClass obj)  
{
if(obj.msg.equals(msg))
return true;
else
return false;
}

Here we check the value of the variable "msg" for the three objects test1, test2 and test3. In this method if the value of the variable "msg" corresponding  to the two objects is found to be true, then it return true otherwise false.
Here is the output of the program.



Constructor Overloading                                        Index                 

Tuesday, 1 October 2013

constructor overloading in java

Like method overloading you can also overload a constructor in java. A constructor is a special purpose class member function for initializing the objects of a class.  A constructor is overloaded on the basis of the arguments or parameters available with it.
Ads by Google


Consider the following class.
     class ConstructorTest  
{
int a,b;
public ConstructorTest()
{
a = 10;
b = 20;
System.out.println("From the default constructor a = "+a+ " and b ="+b);
}
public ConstructorTest(int a,int b)
{
this.a = a;
this.b = b;
System.out.println("From the parameterised constructor a = "+a+ " and b ="+b);
}
}


In this class you can see that there is two constructors present. One is with no arguments and other is with two integer parameters. The compiler will invoke the appropriate constructor when a compatible object initialization found.

For example the statement "ConstructorTest t1 = new ConstructorTest();" will invokes the default constructor, while the statement" ConstructorTest t2 = new ConstructorTest(30,40);" will invoke a constructor with two integer parameters.

Method overloading                                           Index                                Pass by reference                                        



Dealing with the "Keyword not provided" problem in your statistics

This article explains why the proportion of "keyword not provided" visits to most websites is increasing, and gives you options for finding out what keywords people are searching for when they reach your blog.



Why the percentage of not-provided search visits to your blog has increased

If SEO is important for your blog, and if you therefore watch the Stats > Traffic Sources tab in your Blogger dashboard or your Google Analytics results, you'll probably have seen that proportion of your search-visitors whose keyword is "not provided" has gone up a lot recently, to be more-or-less 100% of your Google search traffic.   (In the Blogger Stats tab "not provided" isn't shown - but the number of visits per keyword is now massively less than the vists from Google.)

This is no accident: Google is now witholding the keywords that people use, and (says that) this to protect your visitor's privacy. The issue has been widely discussed in sites like SearchEngineLand.

Opinions vary, but many people believe that
"Not knowing keywords has big implications if you use data about what people search for to decide how to develop your blog." [tweet this quote].

For example,   I publish listings of the contents of old (ie graphical copyright expired) song-books in a particular niche on one of my blogs.  There are far too many songs for me to load the full text or sheet music of all of them. And this is a niche with lots of competition:   there are a zillion websites distributing song-lyrics (most illegally).  But by watching the search-terms that led people to arrive at certain pages, I can identify particular songs that people were looking for and not finding anywhere else (the so called "long tail" of search keywords). If these songs are now in the public domain, I can make a dedicated page for them, and share what I know - in many cases after doing more research and pulling together information from a range of different sources.    Not knowing the keywords that people use to get to the book-listing pages would totally destroy this approach.


What you can do about it

So far I've identified three alternative options for getting data about what my visitors are searching for.

Ask for user-provided information

I've used Google Docs to make a data-collection form, and invited my visitors to use it to tell me about songs they are looking for.

The advantage is that I can ask them for richer information than just the keywords, eg where / when they remembmer it from, multiple snatches of the lyrics, what style the music is, etc.

But the disadvantage - and it's a big one - is that it only works for people who actually get to my site and then go into the other page where this form is kept, and fill in the form. I don't want to go into details - but let's just say that I haven't been run off my feet!


Get data from WebMaster Central

If you have verified your blog in Google Webmaster Tools, then the Search traffic > Search Queries tab shows the queries that have caused your blog to show up in search results pages, as well as how many times this has happened and what position, on average, you had in these pages.

This is richer information than you get from Analytics or Blogger-Stats, which only tell you about people who actually visited your blog.

But the disadvantages are that data is only kept for 90 days, and it only shows the top 2000 keywords.   Both of these are issues for me - some of my song-book contents are seasonal - if something is being looked for now, then the moment (week, month) may have passed by the time that I've noticed the trend, researched the song and written it up to a standard that I'm happy to publish. So really I want to checking the logs for nine months ago, so I can research things that are likely to be popular again next year.


Get data from AdWords

Advertising campaigns are the one place where Google is passing the search-keywords through to back-end systems. And because of this, Adwords does have data about what your visitors are searching for - provided you've set it up to collect this data. To get it up:

Firstly, sign up for an AdWords account. You probably have to deposit $10 into the account to get started - but you don't actually need to set up any advertising campaigns or spend any money after that.

Then link your AdWords account to your Google Webmaster Central account.

Once this is done, Adwords will start collecting the search-keywords for your blog. To get at the data:
  • Log in to AdWords
  • Select "All Online Campaigns,"
  • Make an empty campaign (if you haven't got one already)
  • Go to the "Dimensions" tab
  • Change "View" to "Paid & organic".

AdWords will display your stats, since you signed up and linked your account. This includes the top search terms that users got to your site with, number of clicks, number of queries and some other measures too.

I'm only just starting to assess how well this will for for my song-listing site - will update this post when I have more specific information about how well it works and whether I can get actionable results from it.


What other alternatives have you found?

Leave a comment below, and I'll expand this list as we find out more options for accessing keyword-based search traffic information.




Related Articles:

Using Google Docs to put a survey questionnaire into Blogger

Six reasons why SEO doesn't matter for your blog

Monday, 30 September 2013

Valyria Tear 0.6.0 released

I have to admit that we are a bit slow on reporting the news on FOSS gaming projects with we actually host ourselves via the freegamedev.net forums. Valyria Tear is sadly no exception, and their new 0.6.0 release has been out a few days already. Sorry to all whom this may concern.

For those not in the loop, Valyria Tear is based on the engine of Hero of Allacrost and aims to be an all FOSS jRPG. To give you a better idea of the game-play, here is a (slightly older) cool video of it done by some Linux enthusiasts:



(Thanks also to Rootgamer who reminded me of this news).

If you like the new release, give them some praise on our forums!

Saturday, 28 September 2013

How to edit a picture in Picasa Web Albums or Google+ Photos

This article is about how to edit pictures in Picasa web albums, and how to use Picasa-destop to edit pictures in your Google+ Photos.


Picasa-web-albums vs Google+ Photos

Picasa-web-albums is a on-line photo storage and management tool, now owned by Google.   It is the on-line version of Picasa, a desktop-tool.   (Learn more about PWA and Picasa here.).

Google would ideally  like everyone to use Google+ Photos.

But there are many people who store pictures in albums that are not associated with their personal Google+ accounts:  these may be for businesses, schools, clubs, etc.

So it is likely PWA will continue to exist for a good while yet.   And I am sure that Google appreciate this:  they have made a number of changes to Picasa-web-albums to make it work better both with Google+ and without it.


Options for editing pictures that are are uploaded to Google

  • If you have a Google+ account, then there are two ways of editing photos that you have loaded to Google (it doesn't matter whether you loaded them using Picasa-web or Google+Photos).  

    Both of these options are described below.   Using the Google+ editor (option 1) doesn't need any software installed on your PC.   But it's very slow to load, offers you less control, and is currently missing some key features - and it only works if you are using Chrome as your web-browser, not Firefox or Internet Explorer.
  • If you don't have a Google+ account, then Google / Blogger only provides only one way to edit photos that you have loaded to it (apart from downloading the photo, editing it on your PC and re-uploading it - which changes the URL you need to use to link to the photo).   This is Option 2 below.

Option 1: Using Google + edit a picture in Picasa-web-albums

Log in to Picasa-web-albums, using your Google+ account.  
(See here for what do to if you are automatically re-directed from PWA to Google + Photos)


Navigate to the photo that you want to edit.  
(Make sure you're looking just at that photo, not at the album it is in - this can be confusing in cases when the photo is also the album cover.)

Choose Edit in Google+ from the Actions drop-down menu.

This opens a new window or tab.

If you are not signed in with your Google + account, you will be invited to join.

If necessary, sign-up for Google+, or sign in with the correct account, and start again.

Now, you will be looking at the photo in the Google+ Photos picture view.   From here you can do simple edits:
  • Crop the photo
  • Tag people
  • Rotate the photo
as well as using the other Google+ Photos features (share, slideshow, delete, zoom)

To do more changes, choose Edit (yes, you need to choose it a 2nd time) from the top menu.

If you are not using Google Chrome, then you will get a message saying that the Google+ photo editor only works with Chrome, and giving you a link to download it.    If necessary, switch to Chrome and start again.

Wait while the photo editing tools are loaded  (this does take a while, perhaps even a minute or two).

Once loading is finished, the current Google + Photo editor functions are available from the right-hand bar, like this:



At the moment these are:
  • Tune (brightness, contrast, saturation, shadows, warmth)
  • Selective Adjustment (lets you specific areas for other options to be applied to)
  • Details (sharpness and structure)
  • Crop and Rotate
  • Black and white
  • Centre focus (adjust brightness and blur around the centre)
  • Drama
  • Frames
  • Tilt-shift
  • Vintage
  • Retrolux.

When you  are happy with your photo, click the Finished Editing tick box at the bottom of the right-hand bar, and the changes will be saved (this may take a few moments).

You are left in the open Google+ Photos tab or window, not returned to Picasa-web-albums.   When you go back to Picasa-web-albums and refresh the page (F5), the changes that you made in Google+ photos will be shown.


Option 2:   How to use Picasa-desktop edit a picture in Picasa-web-albums

This option only works if you have Picasa desktop software installed on your computer.

Log in to Picasa-web-albums, using your Google account.

Navigate to the photo that you want to edit.   (Make sure you're looking just at that photo, not at the album it is in - this can be confusing in cases when the photo is also the album cover.)

Choose Edit in Picasa from the Actions drop-down menu.

A pop-up window will tell you that your web browser wants to open another program (ie Picasa-desktop) to do the editing.

(The exact text is something like:   "External Protocol Request:  [your web browser] needs to launch an external application to handle picasa: links.   The link requested is ... The following application will be launched if you accept this request   c:\Program Files\Google\Picasa\Picasa3.exe ... If you did not initiate this request, it may represent an attempted attack on your system.   Unless you took an explicit action to initiate this request, you should press Do Nothing.")

Choose Launch Application.

Picasa will load on your computer, and you will be asked to confirm that you do want to edit the selected picture.   Choose Edit Image.

A copy of the picture that you want to edit is opened in the desktop-Picasa editing tools window.

From here you have access to all Picasa's standard photo editing tools (including the text tool for adding watermarks).

The photo you are working in is a copy taken from your Picasa-web-albums, it is not the same as the copy of the picture which may already be on your computer.   It is stored in a directory of your Picasa-installation called "Online Edits", not in your main My Pictures directory.   So if you choose a function like "Back to Library" you are taken to the Online Edits folder inside Picasa-desktop.

From here you can use all of Picasa-desktop's editing features, including straightening, red-eye reduction, text-editing, re-setting the neutral colour.    The only exception is the Edit in Creative Kit option:  this is still one of the options in Picasa-desktop, but if you use it, it takes a long time to load and then eventually says "Error connecting to Creative Kit... error 500" - and explains that Creative Kit has now been discontinued.

When you are finished editing, to put the edited photo back into the same Picasa-web-album that it came from, with the same file name and URL:
  • Make sure that you are logged in from Picasa-desktop to the same Google account that you were using initially.  
    (Picasa-desktop remembers your sign-in details from the last time you used it - if it's different from what you need, just choose sign-out from the top-right corner, and then sign in to the correct account when asked.)    
  • EITHER:
  • Choose Share on Google+    (if you are using a Google + account)
  • In the sharing-details window that opens, change the Album-name from Online Edits to  the album that the photo came from originally and choose Upload

    OR
  • Return to the Online Edits folder / library
  • Save the changes using the Save icon
  • Choose Enable Synch from the Sharing drop down.
  • Wait for the changed photo to upload.

    (I think Google have some work to do here - you can only control synching for the whole album, not for individual photos.   I expect this to be improved in the future.)




Job Done:  your Picasa-desktop-edited photo appears back in your online Picasa-web-albums with the changes that you just made, and any existing links to it (eg from your blog posts) will show the changed version of the picture.   And you can put the edited picture into your blog posts or other websites in the usual way.



Related Articles

Introducing Picasa and Picasa-web-albums:   an overview

Stop automatic redirection to Google+ Photos

How to put a picture into a blog-post

Tools for applying copyright protection to your blog