Tuesday, March 13, 2012

Wearable Android meetup - postcript

I attended the February 27 Meetup entitled "Wearable Android: Coming to a Wrist Near You", basically about how to program a new android capable device the size of a wrist watch.  Here's an excellent summary of the talk (taken from the Android Meetup page):

----------------


Wearable Android: Coming to a Wrist Near You

What do you get when you shrink Android down into a 32×36×12.5mm water-resistent package weighing only 22g, yet you manage to cram a capacitive touch screen, WiFi, Bluetooth, a bunch of sensors, and up to 32GB of storage? You get the latest in wearable computing, powered by your favorite OS*.

At this event, you'll hear from Ted Ladd, who comes to us from WiMM Labs (the creators of this amazing platform), and you'll learn about what happens when you put Android on a wrist near you. Oh, and you'll also get a chance to win one of these puppies!
WIMMIn the last few months, several companies have announced and launched wearable products with a variety of different hardware and software specs, price points, target segments, and different business models. This session will talk about the primary uses cases for wearable technology, and then dive into the details of the WIMM platform from WIMM Labs (www.WIMM.com), which combines hardware, Android software, and web services to provide subtle, glanceable micro-experiences. With its investor and partner Foxconn, the largest manufacturer of consumer electronics in the world, WIMM Labs licenses the platform to consumer brands to quickly customized and deliver wearable products to their own channel. We'll have several devices to demo and give away.

----------------

My overall impression is that this was a great new technology to start deploying BUT it's not a mobile phone nor should it be meant for one -- more like an enhanced wrist watch for receiving quick updates when you are not in a position to respond immediately.    The speaker gave some great examples of how you can use this device for medical monitoring situations which I thought was very interesting.



Wednesday, March 7, 2012

Use classes as much as possible

JSP servlets are very versatile but they should not contain a lot of code or complex logic -- if you end up doing some complex coding or  business logic, move it into a class method and call that method from a JSP page.

Tuesday, March 6, 2012

Using css and (optionally a Java class) to manipulate image

OK, this is not really about Java per se, it's about you can use only css to crop or resize an image
without having to rely on Java to do it for you (there are advantages and disadvantages to this approach)

I found these techniques by a Google search, here's an excellent article
that describes the concepts in greater detail:

http://cssglobe.com/post/6089/3-easy-and-fast-css-techniques-for-faux-image
(written by Allen Grakelik, Sept. 2009)

1. Create a css container to hold the canvas (where the image is placed) and apply
a background color for the canvas (if the image is getting resized to fit on the canvas)

2. Embed another css container to hold the actual image (that will be resized or cropped)

<style>
   #canvas {
       width: 600px;
        height: 400px;
       background-color: #aaaaaa;
   }
     #img-container {
         overflow:hidden !important /* this is the key */
     }        
    #img-container img {
          // the code in here will do the cropping of a square image so that it fits in the canvas
         width: 600px; // sets the full width of the image to the width of the canvas
         margin:  0px 0px -200px 0px;  // this will crop off 200px from the bottom of the actual image

        // code below resizes the image to 400x400 so it fits fully in the canvas
       
       height:400px; sets the dimension of the image
       padding-left: 100px; // centers the image on the canvas
    }
 </style>
 
 <div id='canvas'>
 <div id='img-container'>
           <img src='path_to_image'>
 </div>
  </div>
 
3.  You can generate the styling based on the image and canvas parameters and put that in a Java method to automate how you crop or resize an image, but it's not required.  Keep in mind you are not actually manipulating the image in java on the server (like you would in PHP using the GD library -- see my recent article here.)

The advantage of this method is that you can display the same image on a variety of different canvases without requiring Java, and it's very easy to set up.  The big disadvantage is that you have to load the full sized image first in the browser and then apply the css styling to it.  For extremely large images this approach is not recommended.  In such cases, it would be better to dynamically resize/crop the image on the server before sending it to the browser.

Monday, March 5, 2012

PHP/Java Bridge

These days I primarily build applications in Java, but there are times that I need to access PHP scripts, and if you work in Java, one of the best ways to integrate PHP into your Java environment (and vise versa if you are primarily working in PHP) is to use a very powerful utility called the PHP/Java Bridge.

http://php-java-bridge.sourceforge.net/pjb/how_it_works.php 

With the PHP/Java bridge you can connect to a Java VM from within a PHP application.  Conversely, you can call PHP from within a jsp page.

According to the bridge documentation, connecting to the JVM using the PHP/Java bridge is 50 times faster than using a local RPC/SOAP request, and requires no additional components.

A handy and easy to use application for administering databases is the well known PhpMyAdmin, and I've used the PHP/Java bridge to connect to this tool from a jsp servlet.




Saturday, March 3, 2012

Stackoverflow -- a great resource to help solve common Java problems

Picture this.  You need to format dates a certain way for an application your building.  You know how to use the Calendar and Date classes but are a little fuzzy on the details, so you fire up google and do some searches, and within a few minutes you have found an answer and can move on.

One of the first sites that always pops up near the top of these types of search(for solving these routine problems) is http://stackoverflow.com/.  I can't emphasize enough what a great resource it has been for me over the years.  I can usually find an answer within minutes and quickly code a solution or integrate it into a class method that I building for an application.

USE IT.  You'll be glad you did!

Monday, February 27, 2012

PHP vs. JAVA, part 1

I thought I should give my perspective from someone who has built applications in both PHP AND JAVA.  (And I love both platforms).

In a nutshell:

PHP is easy to learn, is loosely typed, and you can build rapidly build a website with it using a variety of tools and platforms -- (i.e. WordPress, Joomla, Drupal, Zend, etc..).  However, PHP is limited only to building websites (although some of the these websites are very large, Facebook for example is powered by PHP).   PHP primarily is a scripting language that makes it easier to interact w/ a database (like mySQL or Oracle).   You can't use it to build an android app for example, or to build a fully functioning desktop application like you can in C# or Java.

Java, on the other hand is strongly typed, has many libraries, and is a general purpose language that can be used to build many things besides websites.  One of the most popular uses of Java today of course is in building Android applications. 

Stay tuned.


Saturday, February 25, 2012

Meetups are a really great resource

Meetups are a great way to meet new people but also a great way to learn about what is happening in your industry, especially the tech industry.  The next event planned for the San Francisco Java Users Group is entitled "Tuning JVM for a VM".  Stay tuned.