gt:         switch (field[iy][ix]) {
context: 
  import graviton.observerPattern.Observable;
  import graviton.observerPattern.ObserverManager;
  import highscore.HighScoreManager;
  import highscore.IHighScoreSubject;
  
  import java.util.Random;
  import java.util.Vector;
  
  import javax.microedition.content.Invocation;
  import javax.microedition.content.Registry;
  import javax.microedition.lcdui.Canvas;
  import javax.microedition.lcdui.Command;
  import javax.microedition.lcdui.CommandListener;
  import javax.microedition.lcdui.Displayable;
  import javax.microedition.lcdui.Form;
  import javax.microedition.lcdui.Graphics;
  import javax.microedition.lcdui.StringItem;
  import javax.microedition.midlet.MIDlet;
  import javax.microedition.midlet.MIDletStateChangeException;
  
  
  public class BubbletCanvas extends Canvas 
  							implements IHighScoreSubject, 
  										CommandListener, 
  										Observable {
      private int[][] field;
      private int score;
      private int screenWidth;
      private int screenHeight;
  
      private int cellWidth;
      private int cellHeight; 
  
      private int fieldWidth;
      private int fieldHeight;
  
      private int cursorIndexPosX;
      private int cursorIndexPosY;
  
      private Vector affectedSlices = new Vector(10);
      private Vector CellSet = new Vector(20);
  
      private Random rand = new Random(System.currentTimeMillis());
  
      private final int RED = 0;
      private final int GREEN = 1;
      private final int BLUE = 2;
      private final int PURPLE = 3;
      private final int YELLOW = 4;
      private final int TURQUOISE = 5;
      private final int WHITE = 6;
      private final int MARKED = 7;
  
      private boolean initialDraw = true;
      private boolean drawWholeScreen = false;
      private boolean updateCrosshairsOnly = false;
      private boolean gameFinished = false;
  
      private MIDlet bubblet;
      private Command exitCmd;
      private Command startCmd;
      private Command instructCmd;
      private Command backCmd;
      private Command aboutCmd;
      private Command highScoreCmd;
      private Command shareHighScoreCmd;
  
      private Form instructionForm;
      private Form aboutForm;
      private Form highScoreForm;
      
      private StringItem instructStringItem;
      private StringItem aboutStringItem;
      private StringItem highScoreStringItem;
      
      private ObserverManager observerManager;
      private HighScoreManager highScore;
      private Registry registry; 
      
      private int platform = 2; /* 1 = S40 fullTouch, 2 = ASHA 1.0*/
      private boolean sharingEnabled = false;
      public BubbletCanvas(final MIDlet pMidlet) {
  		
      	String myOS = System.getProperty("microedition.platform");
  		if(myOS.indexOf("Nokia_Asha_1_1") > 0)
  			sharingEnabled = true;
  		
          highScore = HighScoreManager.getInstance(5,false,"bubblet");
          observerManager = new ObserverManager();
          observerManager.addObserver(highScore);
          
          // Internal self reference for CommandListeners
          final Displayable bubbletCanvas = this;
  
          // Prepare Instructions Screen
          if(platform == 2)
              backCmd = new Command("Back", Command.BACK, 1);
          else
          	backCmd = new Command("Back", Command.SCREEN, 1);
          instructionForm = new Form("Instructions");
          instructStringItem = new StringItem(
                  "Bubblet Instructions",
                  "Search for contiguous cells (two or more) " +
                  "with the same color and touch them to dissolve them. " +
                  "Try to dissolve as many fields as possible.");
          instructionForm.append(instructStringItem);
          instructionForm.addCommand(backCmd);
          instructionForm.setCommandListener(new CommandListener() {
              public void commandAction(Command c, Displayable s) {
                  if (c == backCmd) {
                      updateCrosshairsOnly = false;
                      CellSet.removeAllElements();
                      drawWholeScreen = true;
                      ((Bubblet) bubblet).getDisplay().setCurrent(bubbletCanvas);
                  }
              }
          });
  
          // Prepare the About Screen
          aboutForm = new Form("About");
          aboutStringItem = new StringItem(
                  "Bubblet 1.0.5",
                  "Bubblet 1.0.5 for Nokia Asha by: Antti Pohjola\n"+
                  "Bubblet is licenced under GPLv2 licence \n"+
                  "You can get the source code from: https://github.com/Summeli/Bubblet \n\n" +
                  "This game was originally written by Juan Antonio Agudo at http://keyboardsamurais.de \n" +
                  "- it was strongly inspired by the original Bubblet at http://oopdreams.com " +
                  "and its Windows port by Daniel Klein at http://www.hobsoft.de. " +
                  "Special thanks go to M. Serhat Cinar at http://graviton.de for his kind advice.");
          aboutForm.append(aboutStringItem);
          aboutForm.addCommand(backCmd);
          aboutForm.setCommandListener(new CommandListener() {
              public void commandAction(Command c, Displayable s) {
                  if (c == backCmd) {
                      updateCrosshairsOnly = false;
                      CellSet.removeAllElements();
                      drawWholeScreen = true;
                      ((Bubblet) bubblet).getDisplay().setCurrent(bubbletCanvas);
                  }
              }
          });
  
          // prepare HighScore Screen
          highScoreForm= new Form("HighScore");
          highScoreForm.addCommand(backCmd);
          shareHighScoreCmd = new Command("Share", Command.ITEM, 2);
          if(platform == 2 && sharingEnabled)
          	highScoreForm.addCommand(shareHighScoreCmd);
          highScoreForm.setCommandListener(new CommandListener() {
              public void commandAction(Command c, Displayable s) {
                  if (c == backCmd || c.getCommandType() == Command.BACK) {
  		            score = 0;
  		            gameFinished = false;
  		            initialDraw = true;
  		            repaint();
  		            ((Bubblet) bubblet).getDisplay().setCurrent(bubbletCanvas);
                  }if( c== shareHighScoreCmd){
                  	registry = Registry.getRegistry(pMidlet.getClass().getName());
                  	Invocation invocation = new Invocation(null, "text/plain", "com.nokia.share");
                  	invocation.setAction("share");
                      String[] args = new String[1]; // Only the first element is required and used
                      args[0] = new String("text=my Bubblet highscore is "+highScore.getHighScore()); // Content to share
                  	invocation.setArgs(args);
                  	invocation.setResponseRequired(false);
                  	try {
  						registry.invoke(invocation);
  					} catch (Exception e) {
  						String foo = "bar";
  					}
                  	//return game into initial state
  		            score = 0;
  		            gameFinished = false;
  		            initialDraw = true;
  		            repaint();
  		            ((Bubblet) bubblet).getDisplay().setCurrent(bubbletCanvas);
                  }
              }
          });
  
          // Set the Display of our app
  
          bubblet = pMidlet;
  
          startCmd = new Command("Start", Command.SCREEN, 1);
          instructCmd = new Command("Help", Command.SCREEN, 2);
          aboutCmd = new Command("About", Command.SCREEN, 3);
          highScoreCmd = new Command("Highscore", Command.SCREEN, 4);
          exitCmd = new Command("Exit", Command.SCREEN, 5);
  
          addCommand(startCmd);
          addCommand(instructCmd);
          addCommand(aboutCmd);
          addCommand(highScoreCmd);
          if(platform == 1)
          	addCommand(exitCmd);
          setCommandListener(this);
  
          int width = getWidth();
          int height = getHeight();
          if( width == 240 && height == 342){
              fieldWidth = 17;
              fieldHeight = 12;
              platform = 1;
          } else {
          	fieldWidth = 13;
          	fieldHeight = 12;
          	platform = 2;
          }
          
          field = new int[fieldWidth][fieldHeight];
      }
  
  
      protected void drawCrosshairs(Graphics g) {
  	int x = cursorIndexPosX * cellWidth;
  	int y = cursorIndexPosY * cellHeight;
  
  	int x1 = x + 2;
  	int y1 = y + 2;
  	int x2 = x + cellWidth - 5;
  	int y2 = y + cellHeight - 6;
  
  	// Draw Crosshairs
  	g.setColor(0, 0, 0);
  	g.drawLine(x1, y1, x2, y2);
  	g.drawLine(x2, y1, x1, y2);
      }
  
      protected void paint(Graphics g) {
          if (initialDraw) {
              // initialize sizes of basic screen elements (only once)
          	screenWidth = g.getClipHeight();
              screenHeight = g.getClipWidth();
  
              cellWidth = 20;
              cellHeight = 20;
          
              // Draw blank screen
              g.setColor(255, 255, 255);
              g.fillRect(0, 0, screenWidth, screenHeight);
  
              // initialize random game field
              for (int i = 0; i < fieldWidth; i++) {
                  for (int j = 0; j < fieldHeight; j++) {
                      field[i][j] = getRandomNumber();
                  }
              }
  //            int [][] field =  {{0,0,0,0,6,6,6,6,6,6 },
  //                               {0,0,0,0,6,6,6,6,6,6 },
  //                               {0,0,0,0,6,6,6,6,6,6 },
  //                               {0,0,0,0,6,6,6,6,6,6 },
  //                               {0,0,0,0,6,6,6,6,6,6 },
  //                               {0,0,0,0,6,6,6,6,6,6 },
  //                               {0,0,0,0,6,6,6,6,6,6 },
  //                               {0,0,0,0,6,1,1,1,6,0 },
  //                               {0,0,0,0,6,1,0,1,6,0 },
  //                               {0,0,0,0,1,1,0,1,1,1 }};
  //            this.field = field;
              // Draw all cells
              drawWholeBoard(g);
  
              // Initialize crosshairs coordinates on first paint() call
              cursorIndexPosX = 0;
              cursorIndexPosY = 0;
  
              initialDraw = false;
  
          } else if (updateCrosshairsOnly && CellSet.size() > 0) {
              // Redraw last field that was touched by the crosshair
              CellBlock crosshairCell = (CellBlock) CellSet.firstElement();
              drawField(g, crosshairCell.xval, crosshairCell.yval);
              CellSet.removeAllElements();
  
              updateCrosshairsOnly = false;
          } else if (gameFinished) {
              // Draw blank screen
              observerManager.notifyObservers(this);
  	        highScoreStringItem = new StringItem("Your score is: "+score+" Highscores: ",highScore.getSimpleList());
  			if(highScoreForm.size() == 0){
  				highScoreForm.append(highScoreStringItem);
  			}else{
  		        highScoreForm.set(0,highScoreStringItem);
  			}
  	        ((Bubblet) bubblet).getDisplay().setCurrent(highScoreForm);
  	        return;
          }else if(drawWholeScreen){
              g.setColor(255, 255, 255);
              g.fillRect(0, 0, screenWidth * 2, screenHeight * 2);
              drawWholeBoard(g);
          } else {
              // draw board after the dissolve of some fields
              for (int i = 0; i < affectedSlices.size(); i++) {
                  for (int j = 0; j < fieldHeight; j++) {
                      drawField(g, ((Integer) affectedSlices.elementAt(i)).intValue(), j);
                  }
              }
              affectedSlices.removeAllElements();
          }
  /*
          if (!gameFinished)
          	drawCrosshairs(g);*/
      }
  
      private void drawWholeBoard(Graphics g){
          for (int y = 0; y < fieldWidth; y++) {
              for (int x = 0; x < fieldHeight; x++) {
                  drawField(g, x, y);
              }
          }
      }
      
      private void drawField(Graphics g, int ix, int iy) {
          // Determine cell color
  