예제 #1
0
 /** returns the position of the category id */
 public int posOfCat(int id) {
   if (id < 0 || id >= cats)
     return Global.runtimeWarning(
         "SCatSequence on "
             + ((v == null) ? "<null>" : v.getName())
             + ": posOfCat("
             + id
             + ") out of range ("
             + cats
             + " cats)");
   return (catToSeq == null) ? id : catToSeq[id];
 }
예제 #2
0
 /** returns the category ID at position pos */
 public int catAtPos(int id) {
   if (id < 0 || id >= cats)
     return Global.runtimeWarning(
         "SCatSequence on "
             + ((v == null) ? "<null>" : v.getName())
             + ": catAtPos("
             + id
             + ") out of range ("
             + cats
             + " cats)");
   return (seqToCat == null) ? id : seqToCat[id];
 }
예제 #3
0
 public boolean moveCatAtPosTo(int p1, int p2) {
   if (p1 == p2) return true;
   if (p1 < 0 || p2 < 0 || p1 >= cats || p2 >= cats)
     return Global.runtimeWarning(
             "SCatSequence on "
                 + ((v == null) ? "<null>" : v.getName())
                 + ": moveCatAtPosTo("
                 + p1
                 + ","
                 + p2
                 + ") out of range ("
                 + cats
                 + " cats)")
         != -1;
   if (seqToCat == null) createFields();
   int c1 = seqToCat[p1];
   if (p1 < p2) { // move to back
     int r = p1;
     while (r < p2) {
       int c = seqToCat[r + 1];
       seqToCat[r] = c;
       catToSeq[c] = r;
       r++;
     }
     seqToCat[r] = c1;
     catToSeq[c1] = r;
   } else { // move to front
     int r = p1;
     while (r > p2) {
       int c = seqToCat[r - 1];
       seqToCat[r] = c;
       catToSeq[c] = r;
       r--;
     }
     seqToCat[r] = c1;
     catToSeq[c1] = r;
   }
   if (notifyVar) v.NotifyAll(new NotifyMsg(this, Common.NM_VarSeqChange));
   else NotifyAll(new NotifyMsg(this, Common.NM_CatSeqChange));
   return true;
 }
예제 #4
0
 public boolean swapCats(int c1, int c2) {
   if (c1 < 0 || c2 < 0 || c1 >= cats || c2 >= cats)
     return Global.runtimeWarning(
             "SCatSequence on "
                 + ((v == null) ? "<null>" : v.getName())
                 + ": swapCats("
                 + c1
                 + ","
                 + c2
                 + ") out of range ("
                 + cats
                 + " cats)")
         != -1;
   if (seqToCat == null) createFields();
   int p1 = catToSeq[c1];
   int p2 = catToSeq[c2];
   seqToCat[p1] = c2;
   seqToCat[p2] = c1;
   catToSeq[c1] = p2;
   catToSeq[c2] = p1;
   if (notifyVar) v.NotifyAll(new NotifyMsg(this, Common.NM_VarSeqChange));
   else NotifyAll(new NotifyMsg(this, Common.NM_CatSeqChange));
   return true;
 }