How to crop an image in Blackberry

The basic to crop an image in a blackberry application is using the functions of Bitmap class, Bitmap.getARGB() and Bitmap.setARGB()

  1. /**
  2.  *Crops a bitmap with from center, with a defined size by width and height
  3.  *
  4.  */
  5. public static Bitmap cropBitmap(Bitmap original, int width, int height) {
  6. Bitmap bmp = new Bitmap(width, height);
  8. int x = (original.getWidth() / 2) - (width / 2); // Center the new size by width
  9. int y = (original.getHeight() / 2) - (height / 2); // Center the new size by height
  10. int[] argb = new int[width * height];

Utilizando Hibernate Con Java Server Pages y jQuery.

Deseo compartir este tutorial con toda aquella gente seguidora de las tecnologias
en java para el manejo de la capa de acceso a datos, en este se explica y se da una introduccion de como utilizar hibernate desde un aplicacion web dinamica, implementando jquery con jsp, talvez para muchos que apenas se vienen empapando del tema.

Espero que lo disfruten...

Tres Amigos of Persistance (DAO - DAOFactory - BO)

Nowadays, even with all the good accumulated knowledge we have in design patterns, software engineers still tend to program classes where business logic is mixed with persistence logic. Even some experienced developers omit this important aspect of software architecture maybe for lack of knowledge, or just for the rush to start programming quickly. I consider the last reason is the most common of all.

Now why should we bother too much about this separation? well, the idea is not to develop a case for what is basic in software architecture:

Log Friendly Exception Handling

Normally for a typical junior, "in a rush", programmer, exception handling is something that is quickly solved by suppressing the exception, or catching it just to simply log the entire stack trace.

I can say that because I used to do it, not to care too much about the correct treatment of exceptions. Sometimes we tend to think that the most considerable approach is to log the exception and throw it up repeating the process in the subsequent classes.

  1. public class A {
  2. public void callB() throws {
  3. try {
  4. new B().doSomething();

Iterating Complex Map Structures

Have you ever encountered yourself with nested data structures mixed with generics syntax? Even worse, have you or have you been creating this confuse statements in your code?

Let me show you an example of what I mean and what I had found in some interactions with colleague's programming code.

In our example application we need to store and show the enrollment data for a university quatrimester. The data is structured in a hierarchical fashion where we have as first node the year, then the quatrimesters, the courses and at the bottom the students enlisted in those courses.


Profiling our web application with TPTP

Using a profiler tool is a good way to find out bottlenecks inside our Web Application. Today I want to recommend one tool I'd used in the past. There might be more suitable tools but for now I will describe very quickly the one I know: TPTP (Test and Perfomance Tools Platform).

Idea para la estrategia de distribucion JPA

En algunas ocasiones distribuimos las tablas de la base de datos, de tal manera que algunos servidores tengan tablas de solo lectura y otras de escritura, replicando la información de una a otra, y contando con conexiones de lectura y escritura respectivamente, así pues podemos mejorar el desempeño del acceso de nuestra base de datos.

"Domain" vs "Business"

I was reading a book about design patterns and found this interesting note:

"Design Note: business Objects in a non-business space

The term Business Object works in a majority of problem spaces we deal with, we have chosen it as the pattern name. However, in some "non-business" problem
domain, the term Business Object might not be well accepted. Some examples of such problem spaces are health care, government organizations, the military, and

About Briged Methods

I was reading the book Java Generics and Collections by Maurice Naftalin and Phillip Wadler and I learned something very interesting that I want to share with you.

Now, the introduction of generics created a problem to the concept of method signature when it came to interacting with legacy code. Let's see an example with the implementation of the Comparable interface prior to Java 1.5. The Integer class would look somewhat like this:

  1. public interface {
  2. public int compareTo( o);
  3. }
  5. public final class implements {

About Generics and Method Signatures

Prior to the advent of JDK 1.5 the Java Language Specification gave the following explanation about the meaning of method signature:

"A method signature consists of the name of the method, and the number and types of the formal parameters to the method. A class may not declare two methods with the same method signature, or a compile-time error occurs." [JLS 8.4.2]

Syndicate content