docs: private void expandToLimit(AreaImpl sub, Rectangular gp, Rectangular limit, AreaImpl template, 
      							boolean hsep, boolean vsep,
      							short prefDir, short required)
      {
      	//System.out.println();
      	System.out.println("  Expand " + sub + " DIR=" + prefDir + " sep=" + hsep + ":" + vsep);
      	//debugColor = new java.awt.Color(debugColor.getBlue(), debugColor.getRed(), debugColor.getGreen());*/
          //hsep = true;
          //vsep = true;
          if (getTopology().getTopologyWidth() > 0 && getTopology().getTopologyHeight() > 0 && !sub.isBackgroundSeparated())
          {
              int dir = prefDir;
              int attempts = 0;
              while (attempts < 4 && !limitReached(gp, limit, required))
              {
                  boolean change = false;
                  int newx, newy;
                  //System.out.println(dir + " - " +gp);
                  
                  switch (dir)
                  {
                      case DIR_DOWN:
                          //expand down
                          if (gp.getY2() < limit.getY2() && 
                              (!hsep || !separatorDown(sub.getGridPosition().replaceY(gp)))) //look for the separator under the current expanded bounds
                          {
                              newy = expandVertically(gp, limit, template, true, hsep);
                              if (newy > gp.getY2())
                              {
                                  gp.setY2(newy);
                                  change = true;
                              }
                          }
                          break;
                          
                      case DIR_RIGHT:
                          //expand right
                          if (gp.getX2() < limit.getX2() &&
                              (!vsep || !separatorRight(sub.getGridPosition().replaceX(gp))))
                          {
                              newx = expandHorizontally(gp, limit, template, true, vsep);
                              if (newx > gp.getX2())
                              {
                                  gp.setX2(newx);
                                  change = true;
                              }
                          }
                          break;
                          
                      case DIR_UP:
                          //expand up
                          if (gp.getY1() > limit.getY1() &&
                              (!hsep || !separatorUp(sub.getGridPosition().replaceY(gp))))
                          {
                              newy = expandVertically(gp, limit, template, false, hsep);
                              if (newy < gp.getY1())
                              {
                                  gp.setY1(newy);
                                  change = true;
                              }
                          }
                          break;
                          
                      case DIR_LEFT:
                          //expand left
                          if (gp.getX1() > limit.getX1() && 
                              (!vsep || !separatorLeft(sub.getGridPosition().replaceX(gp))))
                          {
                              newx = expandHorizontally(gp, limit, template, false, vsep);
                              if (newx < gp.getX1())
                              {
                                  gp.setX1(newx);
                                  change = true;
                              }
                          }
                          break;
                  }
                  
                  if (!change) //not succeeded in this direction 
                  {
                      dir++; //another direction
                      if (dir >= 4) dir = 0;
                      attempts++;
                  }
                  else //succeeded - keep the direction
                  {
                      attempts = 0;
                  }
                  
                  /*if (Config.DEBUG_AREAS)
                  {
                      dispArea(gp);
                      wait(Config.DEBUG_DELAY);
                  }*/
              }
          }
      }