/**
   * Gets background color for cell for row ic. Override it if you want to change the color from the
   * default.
   */
  public Color getBackgroundColorOfCell(int it, boolean selected) {
    if (observedStates == null) {
      doCalcs();
      if (observedStates == null) return null;
    }
    if (observedStates.getParentData() != null) {
      captureCharacterDataFromObservedStates();

      Associable tInfo = data.getTaxaInfo(false);
      NameReference genBankColor = NameReference.getNameReference("genbankcolor");
      Object obj = tInfo.getAssociatedObject(genBankColor, it); // not saved to file
      if (obj instanceof Color) return (Color) obj;
    }
    if (bits == null || it < 0 || it > bits.getSize()) return null;
    String note = getNote(it);
    if (selected) {
      if (bits.isBitOn(it)) return ColorDistribution.darkGreen;
      else return ColorDistribution.darkRed;
    } else if (bits.isBitOn(it)) {
      if (StringUtil.blank(note)) return ColorDistribution.veryLightGreen;
      if (!(note.equalsIgnoreCase("x"))) return ColorDistribution.lightGreenYellowish;
      return ColorDistribution.lightGreenYellow;
    } else {
      if (StringUtil.blank(note)) return ColorDistribution.brown;
      if (!(note.equalsIgnoreCase("x"))) {
        return Color.red;
      }
      return ColorDistribution.lightRed;
    }
  }
 public String getStringForTaxon(int it) {
   String note = getNote(it);
   if (note != null) return note;
   if (observedStates == null) doCalcs();
   if (bits == null || it < 0 || it > bits.getSize()) return "?";
   if (bits.isBitOn(it)) return "Yes";
   else return "No Data";
 }
Beispiel #3
0
 public void readFrom(DataInput in) throws Exception {
   status = in.readInt();
   classname = Bits.readString(in);
   name = Bits.readString(in);
   start_time = in.readLong();
   stop_time = in.readLong();
   failure_type = Bits.readString(in);
   failure_msg = Bits.readString(in);
   stack_trace = Bits.readString(in);
 }
Beispiel #4
0
 public void writeTo(DataOutput out) throws Exception {
   out.writeInt(status);
   Bits.writeString(classname, out);
   Bits.writeString(name, out);
   out.writeLong(start_time);
   out.writeLong(stop_time);
   Bits.writeString(failure_type, out);
   Bits.writeString(failure_msg, out);
   Bits.writeString(stack_trace, out);
 }
Beispiel #5
0
 public void readFrom(DataInput in) throws Exception {
   type = in.readByte();
   switch (type) {
     case DATA:
       seqno = Bits.readLong(in);
       conn_id = in.readShort();
       first = in.readBoolean();
       break;
     case ACK:
       seqno = Bits.readLong(in);
       conn_id = in.readShort();
       break;
     case SEND_FIRST_SEQNO:
       seqno = Bits.readLong(in);
       break;
   }
 }
Beispiel #6
0
 public void writeTo(DataOutput out) throws Exception {
   out.writeByte(type);
   switch (type) {
     case DATA:
       Bits.writeLong(seqno, out);
       out.writeShort(conn_id);
       out.writeBoolean(first);
       break;
     case ACK:
       Bits.writeLong(seqno, out);
       out.writeShort(conn_id);
       break;
     case SEND_FIRST_SEQNO:
       Bits.writeLong(seqno, out);
       break;
   }
 }
Beispiel #7
0
 public final int size() {
   int retval = Global.BYTE_SIZE; // type
   switch (type) {
     case DATA:
       retval +=
           Bits.size(seqno) // seqno
               + Global.SHORT_SIZE // conn_id
               + Global.BYTE_SIZE; // first
       break;
     case ACK:
       retval += Bits.size(seqno) + Global.SHORT_SIZE; // conn_id
       break;
     case SEND_FIRST_SEQNO:
       retval += Bits.size(seqno);
       break;
   }
   return retval;
 }
  public void doCalcs() {
    if (bits != null) bits.clearAllBits();
    if (taxa == null) return;
    if (bits == null) bits = new Bits(taxa.getNumTaxa());
    else bits.resetSize(taxa.getNumTaxa());
    if (observedStates == null) {
      tInfo = null;
      observedStates = matrixSourceTask.getCurrentMatrix(taxa);
      if (observedStates != null) {
        captureCharacterDataFromObservedStates();

        if (data != null) tInfo = data.getTaxaInfo(true);
      }
    }
    if (observedStates == null) return;
    for (int it = 0; it < taxa.getNumTaxa(); it++) {
      if (hasData(it)) bits.setBit(it);
    }
  }
Beispiel #9
0
 public int getElementType() {
   return Bits.maskBits(getLayoutHelper() >> LH_ELEMENT_TYPE_SHIFT, 0xFF);
 }
Beispiel #10
0
 public int getLog2ElementSize() {
   return Bits.maskBits(getLayoutHelper() >> LH_LOG2_ELEMENT_SIZE_SHIFT, 0xFF);
 }
Beispiel #11
0
 public long getArrayHeaderInBytes() {
   return Bits.maskBits(getLayoutHelper() >> LH_HEADER_SIZE_SHIFT, 0xFF);
 }
  public void testRandom() throws Exception {

    int num = atLeast(2);
    for (int iter = 0; iter < num; iter++) {
      if (VERBOSE) {
        System.out.println("TEST: iter=" + iter);
      }

      Directory dir = newDirectory();

      IndexWriter w =
          new IndexWriter(
              dir,
              newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()))
                  .setMergePolicy(NoMergePolicy.COMPOUND_FILES));
      _TestUtil.keepFullyDeletedSegments(w);

      Map<BytesRef, List<Integer>> docs = new HashMap<BytesRef, List<Integer>>();
      Set<Integer> deleted = new HashSet<Integer>();
      List<BytesRef> terms = new ArrayList<BytesRef>();

      int numDocs = _TestUtil.nextInt(random(), 1, 100 * RANDOM_MULTIPLIER);
      Document doc = new Document();
      Field f = newStringField("field", "", Field.Store.NO);
      doc.add(f);
      Field id = newStringField("id", "", Field.Store.NO);
      doc.add(id);

      boolean onlyUniqueTerms = random().nextBoolean();
      if (VERBOSE) {
        System.out.println("TEST: onlyUniqueTerms=" + onlyUniqueTerms + " numDocs=" + numDocs);
      }
      Set<BytesRef> uniqueTerms = new HashSet<BytesRef>();
      for (int i = 0; i < numDocs; i++) {

        if (!onlyUniqueTerms && random().nextBoolean() && terms.size() > 0) {
          // re-use existing term
          BytesRef term = terms.get(random().nextInt(terms.size()));
          docs.get(term).add(i);
          f.setStringValue(term.utf8ToString());
        } else {
          String s = _TestUtil.randomUnicodeString(random(), 10);
          BytesRef term = new BytesRef(s);
          if (!docs.containsKey(term)) {
            docs.put(term, new ArrayList<Integer>());
          }
          docs.get(term).add(i);
          terms.add(term);
          uniqueTerms.add(term);
          f.setStringValue(s);
        }
        id.setStringValue("" + i);
        w.addDocument(doc);
        if (random().nextInt(4) == 1) {
          w.commit();
        }
        if (i > 0 && random().nextInt(20) == 1) {
          int delID = random().nextInt(i);
          deleted.add(delID);
          w.deleteDocuments(new Term("id", "" + delID));
          if (VERBOSE) {
            System.out.println("TEST: delete " + delID);
          }
        }
      }

      if (VERBOSE) {
        List<BytesRef> termsList = new ArrayList<BytesRef>(uniqueTerms);
        Collections.sort(termsList, BytesRef.getUTF8SortedAsUTF16Comparator());
        System.out.println("TEST: terms in UTF16 order:");
        for (BytesRef b : termsList) {
          System.out.println("  " + UnicodeUtil.toHexString(b.utf8ToString()) + " " + b);
          for (int docID : docs.get(b)) {
            if (deleted.contains(docID)) {
              System.out.println("    " + docID + " (deleted)");
            } else {
              System.out.println("    " + docID);
            }
          }
        }
      }

      IndexReader reader = w.getReader();
      w.close();
      if (VERBOSE) {
        System.out.println("TEST: reader=" + reader);
      }

      Bits liveDocs = MultiFields.getLiveDocs(reader);
      for (int delDoc : deleted) {
        assertFalse(liveDocs.get(delDoc));
      }

      for (int i = 0; i < 100; i++) {
        BytesRef term = terms.get(random().nextInt(terms.size()));
        if (VERBOSE) {
          System.out.println(
              "TEST: seek term=" + UnicodeUtil.toHexString(term.utf8ToString()) + " " + term);
        }

        DocsEnum docsEnum = _TestUtil.docs(random(), reader, "field", term, liveDocs, null, 0);
        assertNotNull(docsEnum);

        for (int docID : docs.get(term)) {
          if (!deleted.contains(docID)) {
            assertEquals(docID, docsEnum.nextDoc());
          }
        }
        assertEquals(DocIdSetIterator.NO_MORE_DOCS, docsEnum.nextDoc());
      }

      reader.close();
      dir.close();
    }
  }