Search Goondaba
Monday
Mar262012

Vaadin Portal Page Flow

In researching using Vaadin portlets within Liferay for a project, I came upon the need to implement some sort of portlet-to-portlet navigation (or page flow, in static html lingo).  And after searching around for a bit, I couldn't find anything to my liking.

What I really wanted to do was have a containing portlet with views I'd setup in a CustomComponent, and then swap out that CustomComponent for a new one on the fly.  So, being familiar with the iOS way of doing things, I simply used an iOS-style push/pop view concept.

In your Vaadin application, setup a function that takes a new CustomComponent; this function will be responsible for swapping out the components in the containing portlet. Then, in your CustomComponents, you can simply push a new view onto the stack, or pop the current one. Example below:

Vaadin Application

package Wizardry;

import com.vaadin.Application;
import com.vaadin.ui.Label;
import com.vaadin.ui.Window;
import com.vaadin.ui.CustomComponent;
import java.util.Stack;
public class WizardryApplication extends Application {
Window window;
Stack<CustomComponent> viewStack = new Stack<CustomComponent>();
public void init() {
window = new Window();
setMainWindow(window);
pushNewView(new FirstView());
}
public void pushNewView(CustomComponent givenComp){
if(viewStack.size() > 0){
if(viewStack.peek() != null){
window.removeComponent((CustomComponent) viewStack.peek());
}
}
window.addComponent(givenComp);
viewStack.push(givenComp);
}
public void popView(){
if(viewStack.size() > 0){
if(viewStack.peek() != null){
window.removeComponent((CustomComponent) viewStack.pop());
}
window.addComponent(viewStack.peek());
}
}
}

Push a new view

WizardryApplication myApp = (WizardryApplication) getApplication();
myApp.pushNewView(new SecondView());

Pop the current view

WizardryApplication myApp = (WizardryApplication) getApplication();
myApp.popView();
Wednesday
Feb012012

The Curious Case of the 8GB 3rd Gen iPod Touch

The Impetus

In developing some apps that had to support older devices, I had to acquire a previous generation iPod Touch for testing purposes. I figured a 3rd generation 8GB iPod Touch would be fine. So I set off to eBay to quickly grab an iPod. 

After a few days, my new-to-me-but-used iPod Touch arrived in the mail. I took it out of the box and plugged it into the iMac, only to have XCode tell me I had a 2nd gen iPod Touch in my possession.

I checked my eBay order to make sure I hadn't ordered the wrong thing. Nope; 3rd gen 8GB iPod Touch. So I assumed the seller had sent me the wrong item. I contacted the seller, and was informed I'd received the correct item. I was ready to go off on the seller, but I first checked the Apple page on identifying iPod models. It turns out, we were both kind of right.

You see, technically, there is no such thing as a 3rd generation 8GB iPod Touch.

The Confusion

In 2009, Apple introduced the 3rd Gen iPod touches; they released new 32GB and 64GB models, but didn't release a new 8GB model. So for a time Apple sold the 2nd gen 8GB iPod Touch alongside the new 3rd gen 32 & 64GB models (Wikipedia reference).

So what had occurred, was that the seller had identified the 8GB iPod as 3rd generation, because it was sold alongside the actual 3rd generation iPod Touches. It's easy to see how this confusion might occur, but in looking at Apple's own page on "Identifying iPod Models" (source):

iPod touch (3rd generation) features a 3.5-inch (diagonal) widescreen multi-touch display and 32 GB or 64 GB flash drive...
...The iPod touch (3rd generation) can be distinguished from iPod touch (2nd generation) by looking at the back of the device. In the text below the engraving, look for the model number. iPod touch (2nd generation) is model A1288, and iPod touch (3rd generation) is model A1318.

it becomes clear that there is no such thing as an 8GB 3rd generation iPod Touch. And that Apple would refer to the model number of the 2nd generation iPod Touch in the blurb about the 3rd gen suggests that this confusion may be common.

Why Does This Matter?

If this were simply a matter of getting the wrong model, that would be one thing. But if you look at the pricing (as of the date of this post) of the 8GB 2nd gen vs. the 8GB 3rd gen, there's a big difference:

These are the exact same thing; iPod Touch model A1288. It would appear that sellers on eBay are profiting from this confusion; selling the mislabeled 2nd gen iPod Touch for a higher price than the correctly labeled 2nd gen 8GB iPod Touches. Whether this is intentional or not is difficult to say, but it is something you should be aware of if you're in the market for a used iPod Touch.

In my case the seller was friendly and willing to accept a refund, but not everyone might be so fortunate.

Bottom Line

If you're looking to buy a used 8GB 3rd generation iPod Touch (or any used iPod Touch, really), refer to Apple's page on "Identifying iPod Models" first to make sure you know what you're looking for, and don't end up paying more than you should.

Monday
Jan302012

What's That Colour?

Ever need help telling what a colour is?

What's That Colour to the rescue!

Just tap to find a colour name, as well as RGB values for anything you can point your camera at.

Get it now!

Tuesday
Aug092011

Sketch : Review

I've been messing around with Inkscape lately, just for fun.  But what's not fun is seeing your Core i7 iMac struggling to redraw your document while zooming in.  You see, Inkscape isn't multi-threaded. So, during intensive tasks I'll just see a single core at 100% while the other 7 are just chilling, presumably talking smack about integers.

Thus began my search for a cheap, Mac-native vector drawing application.  And after a grueling 10 minute search of the internets, I decided to try out Sketch.

Initial Impressions

 

Sketch touts "Infinite Size" documents as one of its features.  When you open Sketch, you have an infinite sized canvas on which to do your vector drawing thing.  When you've achieved something worth exporting, you make a "slice" or selection of your canvas to export. That's nifty.

I was using a mouse when I started up Sketch, and was going nuts trying to find a way to scroll around the canvas.  I went into the toolbar configuration, and found that there was indeed a hand tool; it just wasn't in the default toolbar. "Why is that?", I wondered. But switching to the Magic Trackpad, I was easily able to scroll and zoom my way around using the two-finger scroll and pinch.  It seems Sketch was made for use with the trackpad, so that's something to keep in mind.

Sketch has a stroke width tool that's easy to use, and the transforms (stretch, scale, skew) are easy to apply. But that's where the ease stops.

Annoyances

I spent a few minutes trying to figure out how to select a vector I'd already drawn. Not modifying it; just selecting it. You see, Sketch doesn't have a mouse tool. Whenever I tried to select a vector, I'd find myself applying the effect of whatever tool I had selected. It wasn't until I realized I had to deselect my current tool, that I could select elements. That was annoying.

Also, Sketch seems very green; it feels buggy in places.  Selecting layers and then deleting them doesn't always work on the first try.  Additionally, a reference layer I had put in the document and hid, wouldn't then un-hide. Useful.

Which brings me to the layers.  Sketch definitely supports layers, but that isn't apparent when you open up the application.  You have to enable layers in the View menu.  And once you have your list of layers, you might be inclined to order them… Well, good luck with that.

For whatever reason, Sketch has decided to make the process of ordering layers as maddening as possible.  You might assume that sending a layer backwards, would change the relative order of the selected layer. Guess again! Rather, in order to send a layer backwards, you must first click the behind tool, then click on the layer you want your selected layer to go behind. Get it? It's so intuitive!

Sketch also includes a set of distortions:

These distortions are easy enough to use, but they aren't very precise. Thus, I don't really find them that useful. But you know what are useful? Bezier handles.

In working with already made vectors, I found it difficult to grab the Bezier handles; sometimes they were easily visible, other times they weren't.

Bottom Line

Sketch seems very promising, and I look forward to updates and seeing where it goes.  But for right now, I'll put up with the sluggishness and stick with Inkscape. 

Sketch is made by Bohemian Coding, and is available on the Mac App Store for USD 39.99.

Tuesday
Aug092011

Apple & Google: Different Goals

Apple's goal has been to achieve maximum profit from the sale of hardware:

"Apple captured two thirds of available mobile phone profits in Q2"

Success.

 

Google's goal has been to increase the number of eyeballs looking at ads, growing the search market:

"Android takes almost 50% share of worldwide smart phone market"

Success.

 

Everybody wins. I don't see what all the bickering is about.