Wednesday, October 21, 2009

Readable text

My favourite eclipse code format

My favourite eclipse code format

Tuesday, October 20, 2009

Did you leave your shoes to the right or the left of the umbrella?

The umbrella

As tradition dictates, upon entering his Zen master’s house, the disciple left his shoes and umbrella outside.

“I saw through the window that you were arriving,” said the master. “Did you leave your shoes to the right or the left of the umbrella?”

“I haven’t the least idea. But what does that matter? I was thinking of the secret of Zen!”

“If you don’t pay attention in life, you will never learn anything. Communicate with life, pay each moment the attention it deserves – that is the only secret of Zen.”

Source: Warrior of the Light

Saturday, October 17, 2009

Creating text with images

This tutorial details the steps to create a wording with parts of an image in the foreground of the text. Like this:


First open up the image which needs to be in the foreground of the text.

Next, select the text tool from the tool box. I used the following settings:


Now type the desired text. I typed "Happy Diwali". Note that this new text creates a new layer.

The image now looks like this:

Next, select "Path from text" in the toolbox (without changing the tool selection)


Now make a selection of the text by clicking Select -> From Path


Now the image looks like this:

Now Select Edit -> Clear.


Now the image looks like this:


Now, select the text layer and click on "Layer to image size"


Then, select Select -> invert. This will select everything other than the text selected previously.


Select the bucket fill tool. This is what I used:


The final result looks like this:



Enjoy :-)

Tip: To make a selection from scissors select tool, click inside the selection

After making the selection with the scissors selection tool, click inside the selection to turn it into a selected area.

The Tools menu has the same options as the toolbox window. But the tools are categorized by type.

Thursday, October 15, 2009

Creating callouts or speech bubbles in GIMP

First open the basic image to which you would like to add the callouts to. This was my base image:



Add a new layer to the image by selecting Layer -> New Layer:



Give the new layer a new name (optional)


The new layer can now be found in the layers window:



Now select the Ellipse Select Tool from the Toolbox window



Draw an ellipse on the image where the callout is required:



In my case, I wanted the border line of the call out to have the same color as the cat's face. So I had to set my foreground colour to the cat's face color. To do so, select the Color picker tool in the toolbox. In the layer's window, select the Background layer.



With the Color picker tool click on the cat's face to set that color as the foreground color.



Select the new layer that was created in the first few steps:


Now select the fill tool and make sure "FG color fill" is selected.


Now click inside the ellipse. The image looks like this now:



Now click select -> Shrink.



In the next dialog, enter the size of the callout's border. In my case I wanted a 3 pixel border.



The selection now reduces by the number of pixels entered in the previous step:



Now click edit -> clear.


Now the border of the call out is nicely formed.



Now get rid of the selection (Select -> None)



Now to extend the call out, use the Path tool. Select click on points indicated:



After clicking on the 3rd point, hold the control key, hover over the 1st point and when the mouse pointer changes a little bit, click. This will make the selection a closed one.

Now draw lines over the selection by selecting Stroke selection:



In my case the size of the call out line is 3 pixels (entered previously in the shrink selection step). The same size is entered here too:



Now the image looks like this:



Using the same steps, make another call out for the mouse:



Now the lines within the call out arrows have to be removed. To do so, zoom in:



Select the Paths tool and go about clicking on the line segment that needs to be erased. Now select "Stock path" and select "Stock path from paint tool" and select "Erase" in the drop down (before doing this select the eraser tool in the tool bar and make sure the brush size [in the eraser tool properties] is correct) and stroke. This will erase the un-necessary parts and look like this:



Use, the Text tool and enter the desired text into the call out. Have Fun/ :-)

This tutorial is based on this article with more details and certain improvements.

Nice AOP articles

Spring Terminology: Weaving

Weaving is the process of applying Aspects to Targets to create Proxies. The aspects are woven into the target at the specified joinpoints. This process can happen at different stages of the Target's life
1. Compile Time: Aspects woven into targets when target class is compiled. This requires a special compiler though. Aspectj's weaving compiler weaves aspect this way.
2. Classload time: Aspects woven into targets when target class is loaded into the JVM. This requires a special class loader that enhances the target class's byte code before it is introduced to the application. Aspectj 5's load time weaving (LTW) support is based on this approach.
3. Runtime: Aspects woven into targets when target class is invoked. Typically an AOP container will generate a proxy object that will deliver the aspect functionality before or after delegating to the target object. This is how Spring AOP aspects are woven.

Source: My understanding from reading "Spring In Action"

Spring Terminology: Proxy

When an advice is applied to a Target, it becomes a Proxy. To the clients of the Target, the Target (Pre-AOP) and the Proxy (Post-AOP) are the same. There are no differences in the public APIs exposed by both of the objects. The Delta between the proxy and the target is the implementation to address cross-cutting concerns that are hosted in the Advice.

Source: My understanding from reading "Spring In Action"

Spring Terminology: Target

A target is the object that is being advised. This could be a third party object and a self-written home-grown object. If there was no AOP then then object would handle both its primary logic and cross cutting concern. With AOP this object's responsibility is restored to its code logic and it does not know that it is being advised.

Source: My understanding from reading "Spring In Action"

Spring Terminology: Introductiion

Introduction gives new behavior and state to existing classes without having to change the existing classes. This is achieved by adding new methods and properties to existing classes.


Source: My understanding from reading "Spring In Action"

Wednesday, October 14, 2009

Spring terminology: Aspect revisited

See previous post titled “What is Cross Cutting Concern? Why AOP? What is Aspect?” before reading this.

 

An Aspect is an amalgam/merger of advice (what and when) and pointcuts (where) [see previous posts on advice and pointcuts].

 

 

Spring Terminology: PointCut

An Aspect (see previous post on what an Aspect is) need not handle all Join points of an application. A specific Aspect can be made responsible for a subset of Join points. PointCuts are used to define the subset of join points that a given Aspect is responsible for handling. In other words PointCuts defines the join points where the aspect logic is to be applied. This “where” can be defined on specific, explicit class and method names or through regular expressions that apply to classes and method names that match the pattern.  

Spring Terminology: Join Point

Points in application logic where the aspect’s (see previous posts on what an Aspect is) functionality is to be applied or plugged in. This point could be a method invocation, field write/modification or exception thrown. There are points where the aspect’s logic can be pluged in to add new behaviour.

Spring Terminology: Advice

Defines the responsibility of the Aspect (see previous posts on what an Aspect is) in terms of what (will be performed) and when (it will be performed – before/after/before and after/only on exception).

Brittle means Fragile

 

What is Cross Cutting Concern? Why AOP? What is Aspect?

There are certain aspects of the application that has to be addressed at every layer of the application and cannot be categorized to be a responsibility of any one single layer. Examples are logging, transaction management, security, Caching, Validation etc…

These aspects that span across the several layers of the application are cross cutting concerns. AOP helps decouple cross cutting concerns from the application logic that they impact.

If there was no AOP, one would have to implement common functionality in a base class and have all classes make use it. But this will make the object hierarchy brittle. Other common approach is to delegate common functionality is to utility class. But this will require calls to the utility method spread all across application logic code.



In AOP, the common functionality is implemented in a single class. But this class is invoked by declaratively defining how and where the functionality needs to be applied without having to modify the class to which the functionality is applied to.


These classes that hold common functionality are called Aspects.


Now, the application logic code or service modules contain code pertaining only to their primary responsibility or primary concern and secondary concerns move to aspects. The second advantage is that all common functionality is nicely held in a single place.


Why Dependency Injections

Dependency Injections helps decouple the various components of the application by

  1. Having the components reference each other through abstract interfaces and
  2. Delegate instantiation of concrete implementation classes to a dependency injection framework like Spring