コード例 #1
0
 /** Produce the secondary radius based upon the second atom radius. */
 public float getSplitBondRadius(final Bond bond) {
   final Atom atom = bond.getAtom(1);
   final StructureMap structureMap = atom.getStructure().getStructureMap();
   final StructureStyles structureStyles = structureMap.getStructureStyles();
   final AtomStyle atomStyle = (AtomStyle) structureStyles.getStyle(atom);
   return this.scale * atomStyle.getAtomRadius(atom);
 }
コード例 #2
0
ファイル: Calc.java プロジェクト: andrewyatz/biojava
  /**
   * creates a virtual C-beta atom. this might be needed when working with GLY
   *
   * <p>thanks to Peter Lackner for a python template of this method.
   *
   * @param amino the amino acid for which a "virtual" CB atom should be calculated
   * @return a "virtual" CB atom
   * @throws StructureException
   */
  public static final Atom createVirtualCBAtom(AminoAcid amino) throws StructureException {

    AminoAcid ala = StandardAminoAcid.getAminoAcid("ALA");
    Atom aN = ala.getN();
    Atom aCA = ala.getCA();
    Atom aC = ala.getC();
    Atom aCB = ala.getCB();

    Atom[] arr1 = new Atom[3];
    arr1[0] = aN;
    arr1[1] = aCA;
    arr1[2] = aC;

    Atom[] arr2 = new Atom[3];
    arr2[0] = amino.getN();
    arr2[1] = amino.getCA();
    arr2[2] = amino.getC();

    // ok now we got the two arrays, do a SVD:

    SVDSuperimposer svd = new SVDSuperimposer(arr2, arr1);

    Matrix rotMatrix = svd.getRotation();
    Atom tranMatrix = svd.getTranslation();

    Calc.rotate(aCB, rotMatrix);

    Atom virtualCB = Calc.add(aCB, tranMatrix);
    virtualCB.setName("CB");
    virtualCB.setFullName(" CB ");

    return virtualCB;
  }
コード例 #3
0
    public void run() {
      if (isRunning) {

        int lasttime = currentTime;
        currentTime += (int) (System.currentTimeMillis() - lastSystemTime);
        lastSystemTime = System.currentTimeMillis();

        if (currentTime < indexmax) {
          for (; lasttime < currentTime; lasttime++) {
            TimedMessage m = parsedFile.get(new Integer((int) currentTime));
            if (m != null) m.readMessage();
          }
          outlet(1, currentTime);
        } else {
          Atom[] end = {Atom.newAtom("/loop"), Atom.newAtom("bang")};
          pause();
          outlet(2, end);
        }

        /*
        currentTime ++;
        TimedMessage m = parsedFile.get(new Integer ((int)currentTime));
        if (m != null) m.readMessage();
        System.out.println (currentTime);
        outlet (1, currentTime);
        */
      }
    }
コード例 #4
0
  public Calculator(String[] sa, Map<String, String> vars) {
    /* Populates the atom list.
     * Also collapses 2-part negative numbers into single Atoms. */
    if (vars.size() < 1) throw new IllegalArgumentException("No expression supplied");
    this.vars = vars;
    Atom atom = null, prePrevAtom;
    int prevIndex;
    NEXT_TOKEN:
    for (String token : sa)
      try {
        atom = new Atom(token);
        prevIndex = atoms.size() - 1;
        if (prevIndex < 0) continue;
        if (atoms.get(prevIndex).op != MathOp.SUBTRACT) continue;
        prePrevAtom = (prevIndex > 0) ? atoms.get(prevIndex - 1) : null;
        if (prePrevAtom != null && !TradOrLParen.contains(prePrevAtom.op)) continue;

        if (atom.op == null) {
          atoms.remove(prevIndex);
          atom.val *= -1;
        } else if (atom.op == MathOp.LPAREN) {
          atoms.remove(prevIndex);
          atoms.add(new Atom(-1L));
          atoms.add(new Atom(MathOp.MULTIPLY));
        }
      } finally {
        atoms.add(atom);
      }
  }
コード例 #5
0
 private Atom getMDIAAtom() {
   Atom atom = new Atom("mdia");
   atom.addChild(getMDHDAtom());
   atom.addChild(getHDLRAtom());
   atom.addChild(getMINFAtom());
   return atom;
 }
コード例 #6
0
 private Atom getMINFAtom() {
   Atom atom = new Atom("minf");
   atom.addChild(getSMHDAtom());
   atom.addChild(getDINFAtom());
   atom.addChild(getSTBLAtom());
   return atom;
 }
コード例 #7
0
 private Atom getSTTSAtom() {
   Atom atom = new Atom("stts", (byte) 0, 0);
   int numAudioFrames = mFrameSize.length - 1;
   atom.setData(
       new byte[] {
         0,
         0,
         0,
         0x02, // entry count
         0,
         0,
         0,
         0x01, // first frame contains no audio
         0,
         0,
         0,
         0,
         (byte) ((numAudioFrames >> 24) & 0xFF),
         (byte) ((numAudioFrames >> 16) & 0xFF),
         (byte) ((numAudioFrames >> 8) & 0xFF),
         (byte) (numAudioFrames & 0xFF),
         0,
         0,
         0x04,
         0, // delay between frames = 1024 samples (cf. timescale = Fs)
       });
   return atom;
 }
コード例 #8
0
 private Atom getMDHDAtom() {
   Atom atom = new Atom("mdhd", (byte) 0, 0);
   atom.setData(
       new byte[] {
         mTime[0],
         mTime[1],
         mTime[2],
         mTime[3], // creation time.
         mTime[0],
         mTime[1],
         mTime[2],
         mTime[3], // modification time.
         (byte) (mSampleRate >> 24),
         (byte) (mSampleRate >> 16), // timescale = Fs =>
         (byte) (mSampleRate >> 8),
         (byte) (mSampleRate), // duration expressed in samples.
         mNumSamples[0],
         mNumSamples[1],
         mNumSamples[2],
         mNumSamples[3], // duration
         0,
         0, // languages
         0,
         0 // pre-defined
       });
   return atom;
 }
コード例 #9
0
  // return a byte array containing the full content of the atom (including header)
  public byte[] getBytes() {
    byte[] atom_bytes = new byte[mSize];
    int offset = 0;

    atom_bytes[offset++] = (byte) ((mSize >> 24) & 0xFF);
    atom_bytes[offset++] = (byte) ((mSize >> 16) & 0xFF);
    atom_bytes[offset++] = (byte) ((mSize >> 8) & 0xFF);
    atom_bytes[offset++] = (byte) (mSize & 0xFF);
    atom_bytes[offset++] = (byte) ((mType >> 24) & 0xFF);
    atom_bytes[offset++] = (byte) ((mType >> 16) & 0xFF);
    atom_bytes[offset++] = (byte) ((mType >> 8) & 0xFF);
    atom_bytes[offset++] = (byte) (mType & 0xFF);
    if (mVersion >= 0) {
      atom_bytes[offset++] = mVersion;
      atom_bytes[offset++] = (byte) ((mFlags >> 16) & 0xFF);
      atom_bytes[offset++] = (byte) ((mFlags >> 8) & 0xFF);
      atom_bytes[offset++] = (byte) (mFlags & 0xFF);
    }
    if (mData != null) {
      System.arraycopy(mData, 0, atom_bytes, offset, mData.length);
    } else if (mChildren != null) {
      byte[] child_bytes;
      for (Atom child : mChildren) {
        child_bytes = child.getBytes();
        System.arraycopy(child_bytes, 0, atom_bytes, offset, child_bytes.length);
        offset += child_bytes.length;
      }
    }
    return atom_bytes;
  }
コード例 #10
0
  public void centerResidues() {
    double globalCenterX = 0d;
    double globalCenterY = 0d;
    double globalCenterZ = 0d;
    int count = 0;

    for (Residue res : residueList) {
      for (Atom atom : res.getAtomList()) {
        globalCenterX += atom.getCoordinates()[0];
        globalCenterY += atom.getCoordinates()[1];
        globalCenterZ += atom.getCoordinates()[2];
      }
      count += res.getAtomList().size();
    }

    globalCenterX /= count;
    globalCenterY /= count;
    globalCenterZ /= count;

    for (Node node : root.pdbObjects.getChildren()) {

      node.setTranslateX(node.getTranslateX() - globalCenterX);
      node.setTranslateY(node.getTranslateY() - globalCenterY);
      node.setTranslateZ(node.getTranslateZ() - globalCenterZ);
    }
  }
コード例 #11
0
 @Override
 protected void writeContents(GuardedOutputStream out) throws IOException {
   out.write(version);
   Atom.write24Int(out, flags);
   Atom.write16Int(out, balance);
   Atom.write16Int(out, 0);
 }
コード例 #12
0
  public static double getDist(Atom a, Atom b) {
    double xDist = a.getPoint().x - b.getPoint().x;
    double yDist = a.getPoint().y - b.getPoint().y;

    double dist = Math.sqrt((xDist * xDist) + (yDist * yDist));
    return dist;
  }
コード例 #13
0
 protected SoundMediaInformationHeaderAtom(Atom parent, InputStream in) throws IOException {
   super(parent);
   version = in.read();
   flags = Atom.read24Int(in);
   balance = Atom.read16Int(in);
   Atom.read16Int(in); // reserved unused space
 }
コード例 #14
0
ファイル: FigurePaisley.java プロジェクト: evsc/MXJfigure
 /* return color in atom format */
 private Atom[] pColor(int _i) {
   return new Atom[] {
     Atom.newAtom(patternColor[_i][0]),
     Atom.newAtom(patternColor[_i][1]),
     Atom.newAtom(patternColor[_i][2])
   };
 }
コード例 #15
0
ファイル: Bond.java プロジェクト: aniketisin/INCAR
 void setShapeVisibility(boolean isVisible) {
   boolean wasVisible = ((shapeVisibilityFlags & myVisibilityFlag) != 0);
   if (wasVisible == isVisible) return;
   atom1.addDisplayedBond(myVisibilityFlag, isVisible);
   atom2.addDisplayedBond(myVisibilityFlag, isVisible);
   if (isVisible) shapeVisibilityFlags |= myVisibilityFlag;
   else shapeVisibilityFlags &= ~myVisibilityFlag;
 }
コード例 #16
0
 /**
  * Determines if this substitution is a homomorphism
  *
  * @param a1 set of variables
  * @param a2 set of values
  * @return True is it is a homomorphism, False otherwise
  */
 public boolean isHomomorphismTest(ArrayList<Atom> a1, TreeSet<Atom> a2) {
   Atom aSubstituer;
   for (Atom a : a1) {
     aSubstituer = a.applySubtitution(this);
     if (!a2.contains(aSubstituer)) return false;
   }
   return true;
 }
コード例 #17
0
 private Atom getSMHDAtom() {
   Atom atom = new Atom("smhd", (byte) 0, 0);
   atom.setData(
       new byte[] {
         0, 0, // balance (center)
         0, 0 // reserved
       });
   return atom;
 }
コード例 #18
0
 private Atom getSTSDAtom() {
   Atom atom = new Atom("stsd", (byte) 0, 0);
   byte[] mp4a = getMP4AAtom().getBytes();
   byte[] data = new byte[4 + mp4a.length];
   data[3] = 0x01; // entry count = 1
   System.arraycopy(mp4a, 0, data, 4, mp4a.length);
   atom.setData(data);
   return atom;
 }
コード例 #19
0
ファイル: NthRoot.java プロジェクト: dualsky/jlatexmath
  public Box createBox(TeXEnvironment env) {
    // first create a simple square root construction

    TeXFont tf = env.getTeXFont();
    int style = env.getStyle();
    // calculate minimum clearance clr
    float clr, drt = tf.getDefaultRuleThickness(style);
    if (style < TeXConstants.STYLE_TEXT)
      clr = tf.getXHeight(style, tf.getChar(sqrtSymbol, style).getFontCode());
    else clr = drt;
    clr = drt + Math.abs(clr) / 4;

    // cramped style for the formula under the root sign
    Box bs = base.createBox(env.crampStyle());
    HorizontalBox b = new HorizontalBox(bs);
    b.add(new SpaceAtom(TeXConstants.UNIT_MU, 1, 0, 0).createBox(env.crampStyle()));
    // create root sign
    float totalH = b.getHeight() + b.getDepth();
    Box rootSign = DelimiterFactory.create(sqrtSymbol, env, totalH + clr + drt);

    // add half the excess to clr
    float delta = rootSign.getDepth() - (totalH + clr);
    clr += delta / 2;

    // create total box
    rootSign.setShift(-(b.getHeight() + clr));
    OverBar ob = new OverBar(b, clr, rootSign.getHeight());
    ob.setShift(-(b.getHeight() + clr + drt));
    HorizontalBox squareRoot = new HorizontalBox(rootSign);
    squareRoot.add(ob);

    if (root == null)
      // simple square root
      return squareRoot;
    else { // nthRoot, not a simple square root

      // create box from root
      Box r = root.createBox(env.rootStyle());

      // shift root up
      float bottomShift = FACTOR * (squareRoot.getHeight() + squareRoot.getDepth());
      r.setShift(squareRoot.getDepth() - r.getDepth() - bottomShift);

      // negative kern
      Box negativeKern = new SpaceAtom(TeXConstants.UNIT_MU, -10f, 0, 0).createBox(env);

      // arrange both boxes together with the negative kern
      Box res = new HorizontalBox();
      float pos = r.getWidth() + negativeKern.getWidth();
      if (pos < 0) res.add(new StrutBox(-pos, 0, 0, 0));

      res.add(r);
      res.add(negativeKern);
      res.add(squareRoot);
      return res;
    }
  }
コード例 #20
0
 private Atom getDREFAtom() {
   Atom atom = new Atom("dref", (byte) 0, 0);
   byte[] url = getURLAtom().getBytes();
   byte[] data = new byte[4 + url.length];
   data[3] = 0x01; // entry count = 1
   System.arraycopy(url, 0, data, 4, url.length);
   atom.setData(data);
   return atom;
 }
コード例 #21
0
 private Atom getSTBLAtom() {
   Atom atom = new Atom("stbl");
   atom.addChild(getSTSDAtom());
   atom.addChild(getSTTSAtom());
   atom.addChild(getSTSCAtom());
   atom.addChild(getSTSZAtom());
   atom.addChild(getSTCOAtom());
   return atom;
 }
コード例 #22
0
ファイル: CQ.java プロジェクト: edgarRd/ClipperExperiments
 // compute new Head for the qPrime if there is an individual in the
 // renamingVars
 private Atom computeNewHead(Variable x, Constant d, Atom oldHead) {
   Atom newHead = oldHead;
   for (Term termOfHead : oldHead.getTerms()) {
     List<Term> newTermsForHead = new ArrayList<Term>();
     if (this.computeRenamingVars(x).contains(termOfHead)) newTermsForHead.add(d);
     else newTermsForHead.add(termOfHead);
     newHead = new Atom(oldHead.getPredicate(), newTermsForHead);
   }
   return newHead;
 }
コード例 #23
0
ファイル: CQ.java プロジェクト: edgarRd/ClipperExperiments
 public List<Term> computeRenamingVars(Variable x) {
   List<Term> vars = new ArrayList<Term>();
   for (Atom atom : body) {
     // Need to deal with inverse role
     if (atom.getTerms().contains(x) && atom.getPredicate().getArity() == 2) {
       for (Term term : atom.getTerms()) if (!term.equals(x)) vars.add(term);
     }
   }
   return vars;
 }
コード例 #24
0
ファイル: Calc.java プロジェクト: andrewyatz/biojava
  /**
   * Returns the Vector that needs to be applied to shift a set of atoms to the Centroid, if the
   * centroid is already known
   *
   * @param atomSet array of Atoms
   * @return the vector needed to shift the set of atoms to its geometric center
   */
  public static final Atom getCenterVector(Atom[] atomSet, Atom centroid) {

    double[] coords = new double[3];
    coords[0] = 0 - centroid.getX();
    coords[1] = 0 - centroid.getY();
    coords[2] = 0 - centroid.getZ();

    Atom shiftVec = new AtomImpl();
    shiftVec.setCoords(coords);
    return shiftVec;
  }
コード例 #25
0
 private Atom getFTYPAtom() {
   Atom atom = new Atom("ftyp");
   atom.setData(
       new byte[] {
         'M', '4', 'A', ' ', // Major brand
         0, 0, 0, 0, // Minor version
         'M', '4', 'A', ' ', // compatible brands
         'm', 'p', '4', '2', 'i', 's', 'o', 'm'
       });
   return atom;
 }
コード例 #26
0
ファイル: Bond.java プロジェクト: aniketisin/INCAR
 public String getIdentity() {
   return (index + 1)
       + " "
       + getOrderNumberAsString()
       + " "
       + atom1.getInfo()
       + " -- "
       + atom2.getInfo()
       + " "
       + atom1.distance(atom2);
 }
コード例 #27
0
 private Atom getSTCOAtom() {
   Atom atom = new Atom("stco", (byte) 0, 0);
   atom.setData(
       new byte[] {
         0, 0, 0, 0x01, // entry count
         0, 0, 0, 0 // chunk offset. Set to 0 here. Must be set later. Here it should be
         // the size of the complete header, as the AAC stream will follow
         // immediately.
       });
   return atom;
 }
コード例 #28
0
 public void onDraw(Canvas canvas) {
   // TODO Set style!
   white.setColor(Color.WHITE);
   white.setStyle(Style.FILL);
   black.setColor(Color.BLACK);
   black.setStyle(Style.FILL);
   canvas.drawCircle(location.x, location.y, 25, white);
   String symbol = atom.getSymbol();
   if (symbol.length() == 1)
     canvas.drawText(atom.getSymbol(), location.x - 4, location.y + 4, black);
   else canvas.drawText(atom.getSymbol(), location.x - 6, location.y + 4, black);
 }
コード例 #29
0
ファイル: pingseq.java プロジェクト: shreeswifty/pingseq
    public void draw() {
      sketch.send("moveto", coords);
      sketch.send("framecircle", new Atom[] {Atom.newAtom(size)});
      if (triggered) {
        sketch.send("circle", new Atom[] {Atom.newAtom(size)});
      } else if (hover) {
        sketch.send("circle", new Atom[] {Atom.newAtom(size)});

      } else if (selected) {
        sketch.send("circle", new Atom[] {Atom.newAtom(size)});
      }
    }
コード例 #30
0
ファイル: CQ.java プロジェクト: edgarRd/ClipperExperiments
  public TIntHashSet computeTypeOfX(Variable x) {
    TIntHashSet bs = new TIntHashSet();
    for (Atom atom : body) {
      int typeOfX = 0;
      if (atom.getPredicate().getArity() == 1 && atom.getTerms().contains(x)) {
        typeOfX = atom.getPredicate().getEncoding();
        bs.add(typeOfX);
      }
    }

    return bs;
  }