2007-05-28

Singleton in Java



Here is an example of the Singleton creational pattern in Java:


/*
Copyright (c) 2007 Mike Quentel

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/



public class SingletonExample  {

 /**
  * The Singleton contains a private static data member
  *   representing itself.
  */
 private static SingletonExample singleton;

 /**
  * Private constructor.
  */
 private SingletonExample() { }

 /**
  * The getSelf() accessor lazily instantiates
  *   the Singleton.
  *   The synchronized qualifier is
  *   used to prevent multiple threads
  *   from creating multiple instances.
  */
 public static synchronized SingletonExample getSelf() {
  if (singleton == null) {
    singleton = new SingletonExample();
  } //if (singleton == null)...
  return singleton;
 } //public static synchronized...

 /**
  * Clone() overridden to prevent cloning.
  */
 public Object clone() throws CloneNotSupportedException {
   throw new CloneNotSupportedException();
 } //public Object clone...

} //public class SingletonExample...

2007-05-27

Dapple



Recently, I downloaded a 3D map viewer, called "Dapple", built on top of NASA World Wind .NET version. Geosoft, Inc., took the .NET World Wind and extended it, as well as modified it in general, so as to appeal more to scientific users.
I love that Dapple has a clean user interface combined with an easy ability to add WMS layers. Also, one can use a "Dap Server", which Geosoft offer as an alternative means of storing and sharing geographic data.

Dapple is licensed under the very permissive and developer-friendly software licence known as MIT License. This gives one flexibility and freedom quite similar to that of BSD License.

In the above screen shot, you can see the TerraServer USGS Topo DRG WMS overlayed on the default NASA World Wind globe base layer. With the relief of the base layer, the topos take on a more interesting and meaningful appearance than flat 2D maps. If you might be wondering why the user interface has a tan-coloured appearance in some of the windows: that's just my selected Windows background colour. I like using this tan colour (RGB: 255,204,153 ; HEX: #FFCC99) for most of my applications (especially the background of a code editor).

I also like very much the navigation overview map in the lower left corner of the user interface. This provides a very easy navigation tool, especially if one uses Dapple on a laptop/notebook computer lacking a standard mouse.

Geosoft have started an excellent enhancement to World Wind, and I look forward to future functionality in this.

2007-05-26

Initialisation



This commences a new blog of software, electronics, and GIS-related ideas, thoughts, and opinions. There will exist here a mix of all the above technologies, and more. But in case you might wonder, I have developed GIS-related software for many years. During that time, I gained insights not only into geospatial application development, but many forms of software development in general.

The name "Mike Quentel Software" is just a blog title; not a company or organisation name.

I have other blogs and websites:
Mike Quentel -- main website and centre for all blogs and resources about Mike Quentel.
Meditations -- collection of observations and ideas of Mike Quentel concerning the world in general.
My Space
Facebook