Example #1
1
 public Collection ejbGetRuoliSicurezza_View() {
   BMPConnection bmp = getConnection();
   try {
     PreparedStatement ps =
         bmp.prepareStatement(
             "SELECT "
                 + "COD_RUO_SIC, NOM_RUO_SIC, DES_RUO_SIC "
                 + "FROM "
                 + "ANA_RUO_SIC_TAB "
                 + "ORDER BY "
                 + "NOM_RUO_SIC");
     ResultSet rs = ps.executeQuery();
     java.util.ArrayList al = new java.util.ArrayList();
     while (rs.next()) {
       RuoliSicurezza_View obj = new RuoliSicurezza_View();
       obj.COD_RUO_SIC = rs.getLong(1);
       obj.NOM_RUO_SIC = rs.getString(2);
       obj.DES_RUO_SIC = rs.getString(3);
       al.add(obj);
     }
     bmp.close();
     return al;
   } catch (Exception ex) {
     throw new EJBException(ex);
   } finally {
     bmp.close();
   }
 }
Example #2
1
	public D_MotionChoice[] getChoices() {
		if(DEBUG) System.out.println("VoteEditor: getChoices: start");
		D_MotionChoice[] choices = null;
		if(!initMotionOrg()){
			choices =  D_Organization.getDefaultMotionChoices(D_Organization.get_DEFAULT_OPTIONS());
			if(DEBUG)if(choices!=null)for(D_MotionChoice m : choices) System.out.println("VEditor:getChoices:1:"+m);
		}else{
			choices = getMotion().choices;
			if( (choices == null) || (choices.length==0)){
				choices = getMotion().organization.getDefaultMotionChoices();
				if(DEBUG)if(choices!=null)for(D_MotionChoice m : choices) System.out.println("VEditor:getChoices:2:"+m);
			}
			/*
			if( (choices == null) || (choices.length==0)) {
				choices = D_Organization.getDefaultMotionChoices(D_Organization.get_DEFAULT_OPTIONS());
				if(DEBUG)if(choices!=null)for(D_MotionChoice m : choices) System.out.println("VEditor:getChoices:3:"+m);
			}
			*/
		}
		ArrayList<D_MotionChoice> a =  new ArrayList<D_MotionChoice>();
		Collections.addAll(a,choices);//new ArrayList<D_MotionChoice>(Arrays.asList(choices));
		a.add(0, new D_MotionChoice("", null));
		choices = a.toArray(new D_MotionChoice[0]);
		if(DEBUG)if(choices!=null)for(D_MotionChoice m : choices) System.out.println("VEditor:getChoices:4:"+m);
		return choices;
	}
Example #3
1
  private void displayFriendCount() {
    Collection<GraphUser> selectedFriends = HushApp.getSelectedUsers();

    if (selectedFriends == null || selectedFriends.size() == 0) {
      return;
    }
    numFriendsSelected = selectedFriends.size();

    Chatter chatter;
    final ArrayList<String> fbChatterIds = new ArrayList<String>();
    Collection<GraphUser> selection = HushApp.getSelectedUsers();
    for (GraphUser user : selection) {
      chatter = new Chatter(user.getId(), user.getName());
      fbChatterIds.add(user.getId());
      chatter.saveToParse();
      chat.addChatter(chatter);
    }

    // Send a push notification
    chat.saveToParseWithPush(
        this,
        HushPushNotifReceiver.PushType.NEW_CHAT.toString(),
        getString(R.string.new_chat_push_notif_message),
        fbChatterIds);
  }
 public void addHashtagsFromMessage(String message) {
   if (message == null) {
     return;
   }
   boolean changed = false;
   Pattern pattern = Pattern.compile("(^|\\s)#[\\w@\\.]+");
   Matcher matcher = pattern.matcher(message);
   while (matcher.find()) {
     int start = matcher.start();
     int end = matcher.end();
     if (message.charAt(start) != '@' && message.charAt(start) != '#') {
       start++;
     }
     String hashtag = message.substring(start, end);
     if (hashtagsByText == null) {
       hashtagsByText = new HashMap<>();
       hashtags = new ArrayList<>();
     }
     HashtagObject hashtagObject = hashtagsByText.get(hashtag);
     if (hashtagObject == null) {
       hashtagObject = new HashtagObject();
       hashtagObject.hashtag = hashtag;
       hashtagsByText.put(hashtagObject.hashtag, hashtagObject);
     } else {
       hashtags.remove(hashtagObject);
     }
     hashtagObject.date = (int) (System.currentTimeMillis() / 1000);
     hashtags.add(0, hashtagObject);
     changed = true;
   }
   if (changed) {
     putRecentHashtags(hashtags);
   }
 }
  private String[] expStringToArray(String exp) {

    String[] splitExp = new String[exp.length()];
    Arrays.fill(splitExp, "");

    int j = 0;
    for (int i = 0; i < exp.length(); ++i) {
      char ch = exp.charAt(i);

      if (ch == '+' || ch == '-') {
        splitExp[++j] += ch;
      } else if (ch == '*' || ch == '/') {
        splitExp[++j] += ch;
        ++j;
      } else {
        splitExp[j] += ch;
      }
    }

    ArrayList<String> utilityArray = new ArrayList<>(Arrays.asList(splitExp));
    Predicate<String> p = (s) -> s.equals("");

    utilityArray.removeIf(p);
    splitExp = new String[0];
    splitExp = utilityArray.toArray(splitExp);
    return splitExp;
  }
  /**
   * This function will get the current adjacencyStatus from the latest paths.
   *
   * @param currPathList
   * @return
   */
  private Map<Gate, ArrayList<Edge>> getCurrentAdjacencyStatus(ArrayList<Path> currPathList) {
    Map<Gate, ArrayList<Edge>> adjacencyStatus = new HashMap<Gate, ArrayList<Edge>>();

    for (Path path : currPathList) {
      Gate gate = new Gate(path.getStartNode());
      Edge edge = new Edge(new Gate(path.getEndNode()), path.getTravelTime());
      if (adjacencyStatus.containsKey(gate)) {
        ArrayList<Edge> edgeList = adjacencyStatus.get(gate);
        edgeList.add(edge);
        adjacencyStatus.put(gate, edgeList);
      } else {
        ArrayList<Edge> edgeList = new ArrayList<Edge>();
        edgeList.add(edge);
        adjacencyStatus.put(gate, edgeList);
      }
    }

    /*
    for(Map.Entry<Gate, ArrayList<Edge>> entry : adjacencyStatus.entrySet()){
    	System.out.println(" key "+entry.getKey());
    	for(Edge edge : entry.getValue()){
    		System.out.print(" value "+edge.destGate);
    	}

    }
     */

    return adjacencyStatus;
  }
  private static void generateNamesForCollectionType(
      PsiType type, Set<String> possibleNames, NameValidator validator) {
    PsiType componentType = getCollectionComponentType(type, validator.getProject());
    if (!(type instanceof PsiClassType) || componentType == null) return;
    PsiClass clazz = ((PsiClassType) type).resolve();
    if (clazz == null) return;
    String collectionName = clazz.getName();
    assert collectionName != null;

    String componentName = cleanTypeName(componentType.getPresentableText());
    if (componentType instanceof PsiClassType) {
      PsiClassType classType = (PsiClassType) componentType;
      PsiClass psiClass = classType.resolve();
      if (psiClass == null) return;
      componentName = psiClass.getName();
    }

    assert componentName != null;
    String candidateName = StringUtil.pluralize(GroovyNamesUtil.fromLowerLetter(componentName));
    generateCamelNames(possibleNames, validator, candidateName);

    ArrayList<String> camelizedName = GroovyNamesUtil.camelizeString(candidateName);
    candidateName = camelizedName.get(camelizedName.size() - 1);
    candidateName = collectionName.toLowerCase() + "Of" + fromUpperLetter(candidateName);
    possibleNames.add(validator.validateName(candidateName, true));
  }
Example #8
0
  public ArrayList<SmallPrayer> getTodayServices() {
    ArrayList<String> services = new ArrayList<String>();

    AppUser appUserInstance = AppUser.getInstance();
    ArrayList<DailyEvents> dailyEvents = appUserInstance.getCurrentCommunity().getDailyEvents();

    Calendar calendar = Calendar.getInstance();
    String day = String.valueOf(calendar.get(Calendar.DAY_OF_MONTH));
    String month = String.valueOf(calendar.get(Calendar.MONTH) + 1);
    String year = String.valueOf(calendar.get(Calendar.YEAR));

    if (Integer.valueOf(day) < 10) day = "0" + day;

    if (Integer.valueOf(month) < 10) month = "0" + month;

    String todayDateString =
        String.valueOf(
            String.valueOf(day) + "/" + String.valueOf(month) + "/" + String.valueOf(year));

    for (int i = 0; i < dailyEvents.size(); i++) {
      DailyEvents singleDay = dailyEvents.get(i);
      if (todayDateString.equals(singleDay.getDate())) {
        if (singleDay.getPrayers().size() > 0) {
          return singleDay.getPrayers().get(0).getSmallPrayers();
        }
      }
    }

    return null;
  }
Example #9
0
 /**
  * Add an undo log entry to this session.
  *
  * @param table the table
  * @param operation the operation type (see {@link UndoLogRecord})
  * @param row the row
  */
 public void log(Table table, short operation, Row row) {
   if (undoLogEnabled) {
     UndoLogRecord log = new UndoLogRecord(table, operation, row);
     // called _after_ the row was inserted successfully into the table,
     // otherwise rollback will try to rollback a not-inserted row
     if (SysProperties.CHECK) {
       int lockMode = database.getLockMode();
       if (lockMode != Constants.LOCK_MODE_OFF && !database.isMultiVersion()) {
         String tableType = log.getTable().getTableType();
         if (locks.indexOf(log.getTable()) < 0
             && !Table.TABLE_LINK.equals(tableType)
             && !Table.EXTERNAL_TABLE_ENGINE.equals(tableType)) {
           DbException.throwInternalError();
         }
       }
     }
     undoLog.add(log);
   } else {
     if (database.isMultiVersion()) {
       // see also UndoLogRecord.commit
       ArrayList<Index> indexes = table.getIndexes();
       for (int i = 0, size = indexes.size(); i < size; i++) {
         Index index = indexes.get(i);
         index.commit(operation, row);
       }
       row.commit();
     }
   }
 }
 private static List<String> initInstaceGroupTypes() {
   ArrayList<String> tmpList = new ArrayList<String>();
   tmpList.add("cluster");
   tmpList.add("master");
   tmpList.add("slaves");
   return Collections.unmodifiableList(tmpList);
 }
  @Override
  public void authRequest(Uri url, HashMap<String, String> doneSoFar) {
    if (mProgressDialog.isShowing()) {
      // should always be showing here
      mProgressDialog.dismiss();
    }

    // add our list of completed uploads to "completed"
    // and remove them from our toSend list.
    ArrayList<Long> workingSet = new ArrayList<Long>();
    Collections.addAll(workingSet, mInstancesToSend);
    if (doneSoFar != null) {
      Set<String> uploadedInstances = doneSoFar.keySet();
      Iterator<String> itr = uploadedInstances.iterator();

      while (itr.hasNext()) {
        Long removeMe = Long.valueOf(itr.next());
        boolean removed = workingSet.remove(removeMe);
        if (removed) {
          Log.i(t, removeMe + " was already sent, removing from queue before restarting task");
        }
      }
      mUploadedInstances.putAll(doneSoFar);
    }

    // and reconstruct the pending set of instances to send
    Long[] updatedToSend = new Long[workingSet.size()];
    for (int i = 0; i < workingSet.size(); ++i) {
      updatedToSend[i] = workingSet.get(i);
    }
    mInstancesToSend = updatedToSend;

    mUrl = url.toString();
    showDialog(AUTH_DIALOG);
  }
 private BxBounds parseElementContainingVertexes(Element el) {
   ArrayList<Element> vs = getChildren("Vertex", el);
   if (vs.isEmpty()) {
     return null;
   }
   ArrayList<ComparablePair<Integer, Integer>> list =
       new ArrayList<ComparablePair<Integer, Integer>>();
   int minx = Integer.MAX_VALUE;
   int maxx = Integer.MIN_VALUE;
   int miny = Integer.MAX_VALUE;
   int maxy = Integer.MIN_VALUE;
   for (Element v : vs) {
     int x = Integer.parseInt(v.getAttribute("x"));
     if (x < minx) minx = x;
     if (x > maxx) maxx = x;
     int y = Integer.parseInt(v.getAttribute("y"));
     if (y < miny) miny = y;
     if (y > maxy) maxy = y;
     list.add(new ComparablePair<Integer, Integer>(x, y));
   }
   Collections.sort(list);
   ComparablePair<Integer, Integer> mine = list.get(0);
   ComparablePair<Integer, Integer> maxe = list.get(list.size() - 1);
   BxBounds ret = new BxBounds(minx, miny, maxx - minx, maxy - miny);
   if (ret.getHeight() == 0 || ret.getWidth() == 0) {
     log.warn("problems with height or width points are:");
     for (ComparablePair<Integer, Integer> pa : list) {
       log.warn("\t" + pa.o1 + " , " + pa.o2);
     }
   }
   return ret;
 }
  @Override
  public ArrayList<Datum> readOneTuple() {
    if (buffer == null) return null;
    String line = null;

    try {
      line = buffer.readLine();
    } catch (IOException e) {
      //			e.printStackTrace();
      return null;
    }

    if (line == null || line.isEmpty()) {
      try {
        buffer.close();
        return null;
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      return null;
    }

    String col[] = line.split("\\|");
    ArrayList<Datum> tuples = new ArrayList<>();
    for (int counter = 0; counter < col.length; counter++) {
      if (indexMaps.containsKey(counter)) {
        String type = indexMaps.get(counter);
        tuples.add(new Datum(type.toLowerCase(), col[counter]));
      }
    }
    return tuples;
  }
  public void setbutton() {
    for (int index = 0; index < list.size(); index++) {
      Attendance detail = list.get(index);

      if (Login.getUserid() == detail.getId()) {
        if (detail.getDate().equalsIgnoreCase(date)) {
          if (detail.getIntime() == null) {
            btnintime.setEnabled(true);
            btnouttime.setEnabled(false);
            btnadimlogin.setEnabled(false);
            btnleaverequest.setEnabled(false);
            btnchangepass.setEnabled(false);
          } else {
            btnintime.setEnabled(false);
            btnouttime.setEnabled(true);
            btnadimlogin.setEnabled(true);
            btnleaverequest.setEnabled(true);
            btnchangepass.setEnabled(true);
          }
          if (detail.getIntime() != null && detail.getOuttime() != null) {
            btnintime.setEnabled(false);
            btnouttime.setEnabled(false);
            btnadimlogin.setEnabled(true);
            btnleaverequest.setEnabled(true);
            btnchangepass.setEnabled(true);
          }
        }
      }
    }
    Fetch fetch = new Fetch(Login.getUserid());

    if (fetch.getUsertype().equals("REGULAR EMPLOYEE")) btnleaverequest.setEnabled(true);
    else btnleaverequest.setEnabled(false);
  }
  private void writetodb() {

    for (int index = 0; index < list.size(); index++) {
      Attendance detail = list.get(index);

      if (Login.getUserid() == detail.getId()) {
        if (detail.getDate().equalsIgnoreCase(date)) ;
        {
          if (detail.getIntime() == null) {
            detail.setIntime(intime);
            int latemin = DaysDifference.getTimeDifference("09:00:00", intime);
            if (latemin > 0) {
              detail.setLatemin(latemin);
            }
          } else if (detail.getOuttime() == null) {
            detail.setOuttime(outtime);
          }
        }
      }
    }

    try {
      AttendanceStorge.writingToUserAttendanceDB(list);

    } catch (Exception exp) {
      System.out.println("Cannot write to database");
    }
    setbutton();
  }
 public void clear() {
   if (Refs.sim.isPlaying()) clear = true;
   else {
     ents.clear();
     purgatory.clear();
   }
 }
  /**
   * Set the id associated with each quadrant. The quadrants are laid out: TopLeft, TopRight, Bottom
   * Left, Bottom Right
   *
   * @param keys
   */
  public void setDivisionIds(List<Object> keys) {
    if (keys.size() > MAX_DIVISIONS) {
      throw new IllegalArgumentException("too many divisionIds: " + keys);
    }

    boolean needClear = getDivisionCount() != keys.size();
    if (!needClear) {
      for (int i = 0; i < keys.size(); i++) {
        String divisionId = transformKeyToDivisionId(keys.get(i));
        // different item or different place
        if (!mDivisionMap.containsKey(divisionId) || mDivisionMap.get(divisionId) != i) {
          needClear = true;
          break;
        }
      }
    }

    if (needClear) {
      mDivisionMap.clear();
      mDivisionImages.clear();
      int i = 0;
      for (Object key : keys) {
        String divisionId = transformKeyToDivisionId(key);
        mDivisionMap.put(divisionId, i);
        mDivisionImages.add(null);
        i++;
      }
    }
  }
Example #18
0
  @Override
  public View getView(int position, View bankView, ViewGroup parent) {
    // set the rowview
    View rowView = bankView;
    // reuse views
    if (rowView == null) {
      // if the row view is not null then inflate for display
      LayoutInflater inflater =
          (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      rowView = inflater.inflate(R.layout.password_bank_item, null);
    }

    // get the text views and set the values to the values in the list
    TextView username = (TextView) rowView.findViewById(R.id.value_username);
    TextView website = (TextView) rowView.findViewById(R.id.value_website);
    TextView password = (TextView) rowView.findViewById(R.id.value_password);
    TextView expiration = (TextView) rowView.findViewById(R.id.value_expires);

    username.setText(PasswordInfoArrayList.get(position).getUsername());
    website.setText(PasswordInfoArrayList.get(position).getWebsite());
    password.setText(PasswordInfoArrayList.get(position).getPassword());

    DateHelper expires = PasswordInfoArrayList.get(position).getExpiration();
    boolean expired = expires.isLaterThan(DateHelper.getCurrentDate());
    if (expired) {
      expiration.setTextColor(Color.RED);
    }
    String expStr = PasswordInfoArrayList.get(position).getExpiration().toString();
    expiration.setText(expStr);

    return rowView;
  }
Example #19
0
  public ArrayList<Entity> getEntitiesFromFile(String filePath) {
    ArrayList<Entity> entities = new ArrayList<>();
    try {
      d = db.parse(filePath);

      NodeList entityMentions = d.getElementsByTagName("entity_mention");
      for (int i = 0; i < entityMentions.getLength(); i++) {
        Element entityMention = (Element) entityMentions.item(i);
        NodeList heads = entityMention.getElementsByTagName("head");
        Element head = (Element) heads.item(0);
        NodeList charseqs = head.getElementsByTagName("charseq");
        Element charseq = (Element) charseqs.item(0);
        int start = Integer.parseInt(charseq.getAttribute("START"));
        int end = Integer.parseInt(charseq.getAttribute("END"));
        String value = charseq.getFirstChild().getNodeValue();
        // value = value.replaceAll("\n", "");
        String id = entityMention.getAttribute("ID");
        Element entityParent = (Element) entityMention.getParentNode();
        String type = entityParent.getAttribute("TYPE");
        // String subType = entityParent.getAttribute("SUBTYPE");
        Entity entity = new Entity(value, start, end, type, id);
        entities.add(entity);
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    return entities;
  }
  public void setData(int x, int y, int z, DarkFieldPCA myPCA) {

    SimpleMatrix eigenVectors = myPCA.getEigenVectors();
    SimpleVector eigenValues = myPCA.getEigenValues();

    for (int i = 0; i < fieldList.size(); i++) {
      SimpleVector eigenVec = eigenVectors.getCol(i);
      double eigenVal = eigenValues.getElement(i);
      eigenVec = eigenVec.multipliedBy(eigenVal);
      fieldList.get(i).setVector(x, y, z, eigenVec);
    }

    //		/**
    //		 * Threshold that checks, if 3 component of eigenvalues is too small
    //		 * If 3 component is too small, don't consider it as a fiber orientation
    //		 * and ignore it
    //		 */
    //		double th = 1E-10;

    //		SimpleVector fiberDir;
    //		if(myPCA.getEigenValues().getElement(2)<th){
    //			fiberDir = new SimpleVector(3);
    //		}else{
    //			fiberDir = myPCA.getEigenVectors().getCol(2).normalizedL2();
    //			fiberDir.multiplyBy(myPCA.getEigenValues().getElement(2));
    //		}

  }
Example #21
0
  public ArrayList get2DImageDataList(String urlString, ArrayList list) {

    try {

      ReadXML readXML = new ReadXML();

      System.out.println("************************URLString is******************* - " + urlString);
      String xmlString = readXML.convertFromURLToString(urlString);

      System.out.println("XMLString is - " + xmlString);
      list = readXML.getImageData(xmlString);
      System.out.println("List Size is - " + list.size());

      Iterator iterator = list.iterator();
      /*			CentralServiceVO vo = null;
      			while (iterator.hasNext()) {
      				vo = (CentralServiceVO)iterator.next();
      				//System.out.println("URL = "+vo.getWms());
      				//System.out.println("TFW Values = "+vo.getTfwValues());
      			}
      */
    } catch (Exception e) {
      e.printStackTrace();
    }

    return list;
  }
Example #22
0
 /**
  * 将数组中重复的字符串 去除
  *
  * @param destmsisdns
  * @return
  */
 public static String removeSameDestmsisdn(String destmsisdns) {
   String tmp = null;
   StringBuffer sb_destmsisdn = new StringBuffer();
   String[] destmsisdnArray = destmsisdns.split(",");
   if (destmsisdnArray == null || destmsisdnArray.length == 0) {
     return null;
   }
   ArrayList<String> resultList = new ArrayList<String>();
   for (int i = 0; i < destmsisdnArray.length; i++) {
     if (resultList.contains(destmsisdnArray[i])) {
       continue;
     } else {
       resultList.add(destmsisdnArray[i]);
     }
   }
   for (int i = 0; i < resultList.size(); i++) {
     sb_destmsisdn.append(resultList.get(i));
     sb_destmsisdn.append(",");
   }
   if (sb_destmsisdn.length() > 0) {
     tmp = sb_destmsisdn.substring(0, sb_destmsisdn.length() - 1);
   } else {
     tmp = sb_destmsisdn.toString();
   }
   return tmp;
 }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int count = sc.nextInt();
    int digitsNum;

    for (int i = 0; i < count; i++) {
      ArrayList<Integer> digits = new ArrayList<>();
      digitsNum = sc.nextInt();
      int result = 0;

      while (digitsNum > 0) {
        digits.add(digitsNum % 10);
        digitsNum = digitsNum / 10;
      }

      Collections.reverse(digits);

      for (int j = 0; j < digits.size(); j++) {
        int digit = digits.get(j);
        result += digit * (j + 1);
      }

      System.out.print(result + " ");
    }

    sc.close();
  }
  public ArrayList<Contact> getAllContacts() {

    ArrayList<Contact> contactList = new ArrayList<Contact>();

    String selectQuery = "SELECT  * FROM " + TABLE_DETAILS;

    SQLiteDatabase db = this.getWritableDatabase();
    Cursor cursor = db.rawQuery(selectQuery, null);

    if (cursor.moveToFirst()) { // if (cursor != null)
      do {
        Contact contact = new Contact();
        contact.setName(cursor.getString(1));
        contact.setAddress(cursor.getString(4));
        contact.setPhone(cursor.getString(5));

        String interest = getInterest(cursor.getInt(0));
        contact.setInterest(interest);

        contactList.add(contact);

      } while (cursor.moveToNext());
    }
    return contactList;
  }
Example #25
0
  private static boolean expandMediaSet(
      ArrayList<MediaPath> items, MediaSet set, int maxSelection) {
    int subCount = set.getSubMediaSetCount();
    for (int i = 0; i < subCount; i++) {
      if (!expandMediaSet(items, set.getSubMediaSet(i), maxSelection)) {
        return false;
      }
    }
    int total = set.getMediaItemCount();
    int batch = 50;
    int index = 0;

    while (index < total) {
      int count = index + batch < total ? batch : total - index;
      ArrayList<MediaItem> list = set.getMediaItem(index, count);
      if (list != null && list.size() > (maxSelection - items.size())) {
        return false;
      }
      for (MediaItem item : list) {
        items.add(item.getPath());
      }
      index += batch;
    }
    return true;
  }
  public static ArrayList<Long> getCalendarList(Context c) {
    ArrayList<Long> calendarIdList = new ArrayList<Long>();
    try {
      Cursor cur =
          c.getApplicationContext()
              .getContentResolver()
              .query(
                  CalendarContract.Calendars.CONTENT_URI,
                  CALENDAR_PROJECTION,
                  selection,
                  selectionArgs,
                  null);
      while (cur.moveToNext()) {
        long calID = 0;

        // Get the field values
        calID = cur.getLong(PROJECTION_ID_INDEX);

        calendarIdList.add(calID);
      }
    } catch (SecurityException e) {
      e.printStackTrace();
    } catch (Exception e) {
      e.printStackTrace();
    }
    return calendarIdList;
  }
Example #27
0
  /** creates obstacles out of the tiles, horizontally optimized */
  public void createObstacles() {
    boolean isObstacleInCreation = false;
    double oX = 0, oY = 0;
    int oWidth = 0;
    int oHeight = 0;

    for (int i = 0; i < height; i++) {
      for (int j = 0; j < width; j++) { // was: j < tilePosition.length;
        if (getTile(j, i).isSolid()) {
          if (!isObstacleInCreation) {
            oX = j * Tile.TILEWIDTH;
            oY = i * Tile.TILEHEIGHT;
            oWidth = Tile.TILEWIDTH;
            oHeight = Tile.TILEHEIGHT;
            isObstacleInCreation = true;
          } else {
            oWidth += Tile.TILEWIDTH;
          }
        } else {
          if (isObstacleInCreation) {
            tileObstacles.add(new Obstacle(oX, oY, oWidth, oHeight));
            isObstacleInCreation = false;
          }
        }
      }
      if (isObstacleInCreation) {
        tileObstacles.add(new Obstacle(oX, oY, oWidth, oHeight));
        isObstacleInCreation = false;
      }
    }
    // System.out.println(tileObstacles.size());
    optimizeObstaclesVertically();
  }
 public void cleanUp() {
   for (int i = 0; i < ents.size(); i++)
     if (ents.get(i).shouldKill()) {
       ents.remove(i);
       i--;
     }
 }
  /** Show this next page in the wizard */
  protected void showNextPage() {
    if (currPageIndex.equals(pages.size() - 1)) {
      // Last page so dispose

      cleanup();
      return;
    }

    AbstractWizardPanel page = pages.get(currPageIndex);

    // Remove page from ignored list if requested
    if (page.getEnablePageClassArray().size() > 0) {
      for (Class<? extends AbstractWizardPanel> ignorePage : page.getEnablePageClassArray()) {
        ignoredPages.remove(ignorePage);
      }
    }

    // Add page to ignored list if requested
    if (page.getDisablePageClassArray().size() > 0) {
      for (Class<? extends AbstractWizardPanel> ignorePage : page.getDisablePageClassArray()) {
        if (!ignoredPages.contains(ignorePage)) {
          ignoredPages.add(ignorePage);
        }
      }
    }

    showPage(currPageIndex + 1, Direction.FORWARD);
  }
  /**
   * Extract blob.
   *
   * @param id ID.
   * @param fastBitmap Image to be processed.
   * @return Image with the extracted blob.
   */
  public FastBitmap Extract(int id, FastBitmap fastBitmap) {

    // Check if blobs list is null.
    if (this.blobs == null) this.blobs = new BlobDetection().ProcessImage(fastBitmap);

    FastBitmap image;

    if (fastBitmap.isGrayscale()) {
      image =
          new FastBitmap(
              fastBitmap.getWidth(), fastBitmap.getHeight(), FastBitmap.ColorSpace.Grayscale);
      for (IntPoint p : blobs.get(id).getPoints()) {
        image.setGray(p.x, p.y, fastBitmap.getGray(p.x, p.y));
      }
    } else {
      image =
          new FastBitmap(fastBitmap.getWidth(), fastBitmap.getHeight(), FastBitmap.ColorSpace.RGB);
      for (IntPoint p : blobs.get(id).getPoints()) {
        image.setRed(p.x, p.y, fastBitmap.getRed(p.x, p.y));
        image.setGreen(p.x, p.y, fastBitmap.getGreen(p.x, p.y));
        image.setBlue(p.x, p.y, fastBitmap.getBlue(p.x, p.y));
      }
    }
    return image;
  }