コード例 #1
0
ファイル: Well.java プロジェクト: RoboSquirt/java
  /**
   * Called by the dispatcher, tells its well to paint itself at the proper location.
   *
   * @param g - graphics to paint on
   * @param sF - scale factor from cm to pixels
   */
  public void paint(Graphics g, double sF, boolean isRotated) {

    // get the graphics objects
    Graphics2D g2d = (Graphics2D) g;
    AffineTransform at = new AffineTransform();

    // draw well's outline
    at.translate(parentPlate.getTLcorner().getX() * sF, parentPlate.getTLcorner().getY() * sF);
    if (isRotated) {
      at.translate(parentPlate.getPlateSpecs().getBorderDimensions().getY() * sF, 0);
      at.rotate(Math.PI / 2);
    }
    at.translate(
        (relativeLocation.getX() - diameter / 2) * sF,
        (relativeLocation.getY() - diameter / 2) * sF);
    at.scale(sF, sF);

    g2d.setTransform(at);
    g2d.setColor(Color.BLACK);
    g2d.drawOval(0, 0, (int) diameter, (int) diameter);

    // highlight well if it is selected
    if (isSelected) {
      g2d.setColor(Color.LIGHT_GRAY);
      g2d.fillOval(0, 0, (int) diameter, (int) diameter);
    }
  }
コード例 #2
0
ファイル: Menu.java プロジェクト: pbmartins/P3
 public Plate searchPlate(String name) {
   Plate to_return = null;
   for (WeekDay day : days) {
     for (Plate p : menu.get(day)) {
       if (p.name().equals(name)) to_return = p;
     }
   }
   return to_return;
 }
コード例 #3
0
ファイル: Menu.java プロジェクト: pbmartins/P3
  @Override
  public String toString() {
    String to_return = new String();

    for (WeekDay day : days) {
      for (Plate p : menu.get(day)) to_return += p.toString() + ", dia " + day + "\n";
    }

    return to_return;
  }
コード例 #4
0
ファイル: WellVolume.java プロジェクト: hmsiccbl/screensaver
 private Volume calcTotalInitialVolume(Collection<WellCopy> wellCopies) {
   Volume totalInitialVolume = new Volume(0);
   if (wellCopies.size() > 0) {
     for (WellCopy wellCopy : wellCopies) {
       Plate plateForWellCopy = wellCopy.getCopy().getPlates().get(_well.getPlateNumber());
       if (plateForWellCopy != null && plateForWellCopy.getWellVolume() != null) {
         totalInitialVolume = totalInitialVolume.add(plateForWellCopy.getWellVolume());
       }
     }
   }
   return totalInitialVolume;
 }
コード例 #5
0
 public void run() {
   try {
     while (!Thread.interrupted()) {
       // Blocks until a course is ready
       Plate plate = filledOrders.take();
       print(this + "received " + plate + " delivering to " + plate.getOrder().getCustomer());
       plate.getOrder().getCustomer().deliver(plate);
     }
   } catch (InterruptedException e) {
     print(this + " interrupted");
   }
   print(this + " off duty");
 }
コード例 #6
0
ファイル: Well.java プロジェクト: RoboSquirt/java
 /** Returns the well's position in cm, with all modifiers. */
 public Point2D getAbsoluteLocation() {
   if (parentPlate.isRotated) {
     return new Point2D.Double(
         parentPlate.getTLcorner().getX()
             + parentPlate.getDimensions().getY()
             - relativeLocation.getY(),
         parentPlate.getTLcorner().getY() + relativeLocation.getX());
   } else {
     return new Point2D.Double(
         parentPlate.getTLcorner().getX() + relativeLocation.getX(),
         parentPlate.getTLcorner().getY() + relativeLocation.getY());
   }
 }
コード例 #7
0
ファイル: Screen.java プロジェクト: Jondeen/bioformats
  public boolean linkPlate(Plate o) {

    o.linkScreen(this);
    if (!plateLinks.contains(o)) {
      return plateLinks.add(o);
    }
    return false;
  }
コード例 #8
0
ファイル: WellVolume.java プロジェクト: hmsiccbl/screensaver
  public WellVolume(Well well, Collection<WellCopy> wellCopies) {
    super(well.getEntityId());
    _well = well;

    List<WellCopy> activeVolumes = new ArrayList<WellCopy>();
    List<WellCopy> retiredVolumes = new ArrayList<WellCopy>();
    for (WellCopy wc : wellCopies) {
      Plate plate = wc.getCopy().getPlates().get(_well.getPlateNumber());
      if (plate == null || plate.getStatus() != PlateStatus.RETIRED) {
        activeVolumes.add(wc);
      } else if (plate.getStatus() == PlateStatus.RETIRED) {
        retiredVolumes.add(wc);
      }
    }

    _activeWellInfo = new AggregateWellInfo(activeVolumes);
    _retiredWellInfo = new AggregateWellInfo(retiredVolumes);
  }
コード例 #9
0
ファイル: Screen.java プロジェクト: Jondeen/bioformats
 public boolean link(Reference reference, OMEModelObject o) {
   boolean wasHandledBySuperClass = super.link(reference, o);
   if (wasHandledBySuperClass) {
     return true;
   }
   if (reference instanceof PlateRef) {
     Plate o_casted = (Plate) o;
     o_casted.linkScreen(this);
     if (!plateLinks.contains(o_casted)) {
       plateLinks.add(o_casted);
     }
     return true;
   }
   if (reference instanceof AnnotationRef) {
     Annotation o_casted = (Annotation) o;
     o_casted.linkScreen(this);
     if (!annotationLinks.contains(o_casted)) {
       annotationLinks.add(o_casted);
     }
     return true;
   }
   LOGGER.debug("Unable to handle reference of type: {}", reference.getClass());
   return false;
 }
コード例 #10
0
ファイル: PL02BranchGroup.java プロジェクト: bgarrels/jCAE
 /*
  * (non-Javadoc)
  *
  * @see syn3d.base.ActiveNode#highlight(boolean, java.lang.Object)
  */
 public void highlight(boolean on, Object parameter) {
   System.out.println("Total memory: " + Runtime.getRuntime().totalMemory());
   System.out.println("Free memory: " + Runtime.getRuntime().freeMemory());
   System.out.println(System.currentTimeMillis() + " starting highlight with " + parameter);
   if (parameter instanceof PickResult) {
     PickResult result = (PickResult) parameter;
     result.setFirstIntersectOnly(true);
     PickIntersection pi = result.getIntersection(0);
     // indices of the picked quad
     // Indices are set to vertex indices, as this is not an Index
     // Geometry object
     // => easy to find the plate index from this
     int[] idx = pi.getPrimitiveCoordinateIndices();
     int plateNum = idx[0] / 4;
     Plate p = plates[plateNum];
     Point3d point3d = pi.getPointCoordinates();
     point3d.get(point);
     FloatBuffer coords =
         (FloatBuffer) ((NioQuadArray) (shape.getGeometry())).getCoordRefBuffer().getBuffer();
     for (int i = 0; i < idx.length; ++i) {
       coords.position(idx[i] * 3);
       coords.get(vertices[i]);
     }
     int d1 = 0, d2 = 0;
     if (p instanceof PlateX) {
       d1 = 1;
       d2 = 2;
     } else if (p instanceof PlateY) {
       d1 = 0;
       d2 = 2;
     } else if (p instanceof PlateZ) {
       d1 = 0;
       d2 = 1;
     }
     int u =
         (int)
             Math.floor(
                 (point[d1] - vertices[0][d1])
                     * (p.max1 - p.min1)
                     / (vertices[3][d1] - vertices[0][d1]));
     int v =
         (int)
             Math.floor(
                 (point[d2] - vertices[0][d2])
                     * (p.max2 - p.min2)
                     / (vertices[1][d2] - vertices[0][d2]));
     int quadIdx = v * (p.max1 - p.min1) + u;
     u += p.min1;
     v += p.min2;
     System.out.println(
         (on ? "" : "de") + "selected quad " + quadIdx + " in plate " + plateNum + " in group ");
     System.out.println("Grid positions for the quad (x,y,z) indices:");
     int[] pos = p.getXYZGridIndices(u, v);
     System.out.println("vertex1 = (" + pos[0] + ", " + pos[1] + ", " + pos[2] + ")");
     pos = p.getXYZGridIndices(u, v + 1);
     System.out.println("vertex2 = (" + pos[0] + ", " + pos[1] + ", " + pos[2] + ")");
     pos = p.getXYZGridIndices(u + 1, v + 1);
     System.out.println("vertex3 = (" + pos[0] + ", " + pos[1] + ", " + pos[2] + ")");
     pos = p.getXYZGridIndices(u + 1, v);
     System.out.println("vertex4 = (" + pos[0] + ", " + pos[1] + ", " + pos[2] + ")");
     float[] color = getColorForOrder(groupIdx, on ? 1 : 0);
     for (int i = 0; i < idx.length; ++i) {
       colors.position(idx[i] * 3);
       colors.put(color);
     }
     toggleSelectedQuad(on, new SelectionQuad(p, u, v, groupIdx));
     // Use event propagation, but don't call
     // setAppearanceForHighlight
     FloatBuffer tmp = colors;
     colors = null;
     colors = tmp;
   }
   System.out.println(System.currentTimeMillis() + " end of highlight");
 }
コード例 #11
0
ファイル: PL02BranchGroup.java プロジェクト: bgarrels/jCAE
  protected void makeGroups() {
    int totalQuads = 0;
    int totalInternalEdges = 0;
    int totalExternalEdges = 0;
    // loop over each group
    // loop over each group
    int[] groupID = provider.getDomainIDs();

    for (int g = 0; g < groupID.length; ++g) {
      LOGGER.finest("generating java3d tree for group number " + groupID[g]);
      // Set of EdgeLine objects. Overlapping edges on the same line are
      // merged together
      HashMap<EdgeLine, EdgeLine> externalEdges = new HashMap<EdgeLine, EdgeLine>();
      // Same trick for internal edges.
      HashMap<EdgeLine, EdgeLine> internalEdges = new HashMap<EdgeLine, EdgeLine>();
      FDDomain fdDomain = (FDDomain) provider.getDomain(groupID[g]);
      baseColor.put(new Integer(g), fdDomain.getColor());
      Plate[] plates = domainToPlates(fdDomain);

      if (plates.length == 0) continue;

      // Create plates for this group
      FloatBuffer nioCoords =
          ByteBuffer.allocateDirect(plates.length * 4 * 3 * 4)
              .order(ByteOrder.nativeOrder())
              .asFloatBuffer();
      FloatBuffer nioColors =
          ByteBuffer.allocateDirect(plates.length * 4 * 3 * 4)
              .order(ByteOrder.nativeOrder())
              .asFloatBuffer();
      float[] baseColor = getColorForOrder(g, 0);
      // System.out.println(baseColor[0]+" "+baseColor[1]+" "+baseColor[2]);
      for (int np = 0; np < plates.length; ++np) {
        Plate p = plates[np];
        // put coordinates
        nioCoords.put(p.getCoordinates(grid));
        // put colors for the 4 vertices
        nioColors.put(baseColor);
        nioColors.put(baseColor);
        nioColors.put(baseColor);
        nioColors.put(baseColor);
        // Merge external edges
        addEdge(externalEdges, getLine(p, 2, p.min1), p.min2, p.max2);
        addEdge(externalEdges, getLine(p, 2, p.max1), p.min2, p.max2);
        addEdge(externalEdges, getLine(p, 1, p.min2), p.min1, p.max1);
        addEdge(externalEdges, getLine(p, 1, p.max2), p.min1, p.max1);
        // Merge internal edges
        for (int i = p.min1 + 1; i < p.max1; ++i)
          addEdge(internalEdges, getLine(p, 2, i), p.min2, p.max2);
        for (int j = p.min2 + 1; j < p.max2; ++j)
          addEdge(internalEdges, getLine(p, 1, j), p.min1, p.max1);
      }
      // use by reference array of colors => fast to change!
      QuadArray qa =
          new NioQuadArray(plates.length * 4, GeometryArray.COORDINATES | GeometryArray.COLOR_3);
      qa.setCoordRefBuffer(new J3DBuffer(nioCoords));
      qa.setColorRefBuffer(new J3DBuffer(nioColors));
      qa.setCapability(GeometryArray.ALLOW_COLOR_WRITE);
      qa.setCapabilityIsFrequent(GeometryArray.ALLOW_COLOR_WRITE);
      Appearance a = new Appearance();
      PolygonAttributes pa =
          new PolygonAttributes(PolygonAttributes.POLYGON_FILL, PolygonAttributes.CULL_NONE, 0);
      pa.setPolygonOffset(1);
      pa.setPolygonOffsetFactor(1);
      a.setPolygonAttributes(pa);
      Shape3D s3d = new Shape3D(qa, a);
      PickTool.setCapabilities(s3d, PickTool.INTERSECT_FULL);
      s3d.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
      s3d.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
      s3d.setCapability(Node.ALLOW_PICKABLE_READ);
      s3d.setCapability(Node.ALLOW_PICKABLE_WRITE);
      s3d.setPickable(true);
      s3d.setUserData(new BehindShape(s3d, plates, g));

      this.addChild(s3d);

      // Create edge shapes directly, don't make them appear in graph
      int nInternalEdges = 0;
      for (Iterator<EdgeLine> it = internalEdges.keySet().iterator(); it.hasNext(); ) {
        EdgeLine el = it.next();
        nInternalEdges += el.getNumberOfEdges();
      }
      if (nInternalEdges > 0) {
        DoubleBuffer nioInternalEdges =
            ByteBuffer.allocateDirect(nInternalEdges * 2 * 3 * 8)
                .order(ByteOrder.nativeOrder())
                .asDoubleBuffer();
        // create edge coords
        for (Iterator<EdgeLine> it = internalEdges.keySet().iterator(); it.hasNext(); ) {
          EdgeLine el = it.next();
          nioInternalEdges.put(el.getCoords(grid));
        }
        LineArray la =
            new NioLineArray(nInternalEdges * 2, GeometryArray.COORDINATES | GeometryArray.COLOR_3);
        la.setCoordRefBuffer(new J3DBuffer(nioInternalEdges));
        int colSize = nInternalEdges * 2 * 3;
        FloatBuffer nioInternalColors =
            ByteBuffer.allocateDirect(colSize * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();
        float[] colors = getColorForOrder(g, 2);
        for (int i = 0; i < colSize; i += 3) nioInternalColors.put(colors);
        la.setColorRefBuffer(new J3DBuffer(nioInternalColors));
        la.setUserData(new int[] {g, 2});
        a = new Appearance();
        // pa = new PolygonAttributes(PolygonAttributes.POLYGON_LINE,
        // PolygonAttributes.CULL_NONE, 0);
        // pa.setPolygonOffset(4);
        // pa.setPolygonOffsetFactor(4);
        // a.setPolygonAttributes(pa);
        // LineAttributes lat = new LineAttributes();
        // lat.setLineAntialiasingEnable(true);
        // a.setLineAttributes(lat);
        // RenderingAttributes ra = new RenderingAttributes();
        // ra.setAlphaTestFunction(RenderingAttributes.GREATER);
        // ra.setAlphaTestValue(0.5f);
        // a.setRenderingAttributes(ra);
        s3d = new Shape3D(la, a);
        PickTool.setCapabilities(s3d, PickTool.INTERSECT_FULL);
        s3d.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
        s3d.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
        s3d.setCapability(Node.ALLOW_PICKABLE_READ);
        s3d.setCapability(Node.ALLOW_PICKABLE_WRITE);
        s3d.setPickable(false); // by default, see actions
        s3d.setUserData(this); // this object will handle edges
        this.addChild(s3d);
        allEdgeShapes.add(s3d);
      }
      // Now, create external edge
      int nExternalEdges = 0;
      for (Iterator<EdgeLine> it = externalEdges.keySet().iterator(); it.hasNext(); ) {
        EdgeLine el = it.next();
        nExternalEdges += el.getNumberOfEdges();
      }
      if (nExternalEdges > 0) {
        DoubleBuffer nioExternalEdges =
            ByteBuffer.allocateDirect(nExternalEdges * 2 * 3 * 8)
                .order(ByteOrder.nativeOrder())
                .asDoubleBuffer();
        // create edge coords
        for (Iterator<EdgeLine> it = externalEdges.keySet().iterator(); it.hasNext(); ) {
          EdgeLine el = it.next();
          nioExternalEdges.put(el.getCoords(grid));
        }
        LineArray la =
            new NioLineArray(nExternalEdges * 2, GeometryArray.COORDINATES | GeometryArray.COLOR_3);
        la.setCoordRefBuffer(new J3DBuffer(nioExternalEdges));
        int colSize = nExternalEdges * 2 * 3;
        FloatBuffer nioExternalColors =
            ByteBuffer.allocateDirect(colSize * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();
        float[] colors = getColorForOrder(g, 4);
        for (int i = 0; i < colSize; i += 3) nioExternalColors.put(colors);
        la.setColorRefBuffer(new J3DBuffer(nioExternalColors));
        la.setUserData(new int[] {g, 4});
        a = new Appearance();
        // pa = new PolygonAttributes(PolygonAttributes.POLYGON_LINE,
        // PolygonAttributes.CULL_NONE, 0);
        // pa.setPolygonOffset(3);
        // pa.setPolygonOffsetFactor(3);
        // a.setPolygonAttributes(pa);
        s3d = new Shape3D(la, a);
        PickTool.setCapabilities(s3d, PickTool.INTERSECT_FULL);
        s3d.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
        s3d.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
        s3d.setCapability(Node.ALLOW_PICKABLE_READ);
        s3d.setCapability(Node.ALLOW_PICKABLE_WRITE);
        s3d.setPickable(false); // by default, see actions
        s3d.setUserData(this); // this object will handle edges
        this.addChild(s3d);
        allEdgeShapes.add(s3d);
      }
      totalQuads += plates.length;
      totalInternalEdges += nInternalEdges;
      totalExternalEdges += nExternalEdges;
    }
    System.out.println("Total quads: " + totalQuads);
    System.out.println("Total Internal Plate edges: " + totalInternalEdges);
    System.out.println("Total External Plate edges: " + totalExternalEdges);
  }
コード例 #12
0
ファイル: Screen.java プロジェクト: Jondeen/bioformats
  protected Element asXMLElement(Document document, Element Screen_element) {
    // Creating XML block for Screen

    if (Screen_element == null) {
      Screen_element = document.createElementNS(NAMESPACE, "Screen");
    }

    if (name != null) {
      // Attribute property Name
      Screen_element.setAttribute("Name", name.toString());
    }
    if (protocolDescription != null) {
      // Attribute property ProtocolDescription
      Screen_element.setAttribute("ProtocolDescription", protocolDescription.toString());
    }
    if (protocolIdentifier != null) {
      // Attribute property ProtocolIdentifier
      Screen_element.setAttribute("ProtocolIdentifier", protocolIdentifier.toString());
    }
    if (reagentSetDescription != null) {
      // Attribute property ReagentSetDescription
      Screen_element.setAttribute("ReagentSetDescription", reagentSetDescription.toString());
    }
    if (type != null) {
      // Attribute property Type
      Screen_element.setAttribute("Type", type.toString());
    }
    if (id != null) {
      // Attribute property ID
      Screen_element.setAttribute("ID", id.toString());
    }
    if (reagentSetIdentifier != null) {
      // Attribute property ReagentSetIdentifier
      Screen_element.setAttribute("ReagentSetIdentifier", reagentSetIdentifier.toString());
    }
    if (description != null) {
      // Element property Description which is not complex (has no
      // sub-elements)
      Element description_element = document.createElementNS(NAMESPACE, "Description");
      description_element.setTextContent(description.toString());
      Screen_element.appendChild(description_element);
    }
    if (reagents != null) {
      // Element property Reagent which is complex (has
      // sub-elements) and occurs more than once
      for (Reagent reagents_value : reagents) {
        Screen_element.appendChild(reagents_value.asXMLElement(document));
      }
    }
    if (plateLinks != null) {
      // Reference property PlateRef which occurs more than once
      for (Plate plateLinks_value : plateLinks) {
        PlateRef o = new PlateRef();
        o.setID(plateLinks_value.getID());
        Screen_element.appendChild(o.asXMLElement(document));
      }
    }
    if (annotationLinks != null) {
      // Reference property AnnotationRef which occurs more than once
      for (Annotation annotationLinks_value : annotationLinks) {
        AnnotationRef o = new AnnotationRef();
        o.setID(annotationLinks_value.getID());
        Screen_element.appendChild(o.asXMLElement(document));
      }
    }
    return super.asXMLElement(document, Screen_element);
  }
コード例 #13
0
ファイル: Screen.java プロジェクト: Jondeen/bioformats
  public boolean unlinkPlate(Plate o) {

    o.unlinkScreen(this);
    return plateLinks.remove(o);
  }
コード例 #14
0
ファイル: Well.java プロジェクト: RoboSquirt/java
 /** @return amount of liquid each well can hold, as per plate specifications */
 public double getMaxVolume() {
   return parentPlate.getMaxWellVolume();
 }
コード例 #15
0
  public JSONObject saveImportedElements(HttpSession session, JSONObject json) {
    if (json.has("elements")) {
      Plate currentPlate = null;
      Pool currentPool = null;

      try {
        String description = json.getString("description");
        String creationDate = json.getString("creationDate");
        String plateMaterialType = null;
        if (json.has("plateMaterialType") && !json.getString("plateMaterialType").equals("")) {
          plateMaterialType = json.getString("plateMaterialType");
        }

        JSONObject elements = json.getJSONObject("elements");
        JSONArray pools = JSONArray.fromObject(elements.get("pools"));
        JSONArray savedPlates = new JSONArray();
        ObjectMapper mapper = new ObjectMapper();

        for (JSONArray innerPoolList : (Iterable<JSONArray>) pools) {
          for (JSONObject pool : (Iterable<JSONObject>) innerPoolList) {
            log.info(pool.toString());

            PlatePool platePool =
                mapper.readValue(pool.toString(), new TypeReference<PlatePool>() {});
            currentPool = platePool;

            for (Plate<LinkedList<Library>, Library> plate : platePool.getPoolableElements()) {
              JSONObject j = new JSONObject();

              //              if (json.has("tagBarcode")) {
              //                String tagBarcode = json.getString("tagBarcode");
              //
              // plate.setTagBarcode(requestManager.listAllTagBarcodesByStrategyName());
              //              }

              if (plate.getDescription() == null) {
                plate.setDescription(description);
              }

              if (plate.getCreationDate() == null) {
                // plate.setCreationDate(DateFormat.getInstance().parse(creationDate));
              }

              if (plate.getPlateMaterialType() == null && plateMaterialType != null) {
                plate.setPlateMaterialType(PlateMaterialType.valueOf(plateMaterialType));
              }
              log.info("Saving plate: " + plate.toString());
              currentPlate = plate;
              long plateId = requestManager.savePlate(plate);
              j.put("plateId", plateId);
              savedPlates.add(j);
              currentPlate = null;
            }

            log.info("Saving pool: " + pool.toString());
            requestManager.savePool(platePool);
            currentPool = null;
          }
        }
        JSONObject resp = new JSONObject();
        resp.put("plates", savedPlates);
        return resp;
      } catch (IOException e) {
        if (currentPool != null) {
          log.error(
              "Error saving pool elements on new plate save. Deleting pool "
                  + currentPool.toString());
          // clear out child elements to make sure plate meets delete requirements
          currentPool.getPoolableElements().clear();
          try {
            requestManager.deletePool(currentPool);
          } catch (IOException e1) {
            log.error("Cannot delete pool. Nothing left to do.");
            e1.printStackTrace();
          }
        }

        if (currentPlate != null) {
          log.error(
              "Error saving plate elements on new plate save. Deleting plate "
                  + currentPlate.toString());
          // clear out child elements to make sure plate meets delete requirements
          currentPlate.getElements().clear();
          try {
            requestManager.deletePlate(currentPlate);
          } catch (IOException e1) {
            log.error("Cannot delete plate. Nothing left to do.");
            e1.printStackTrace();
          }
        }

        log.error("Caused by...");
        e.printStackTrace();
        return JSONUtils.SimpleJSONError("Cannot save imported plate: " + e.getMessage());
      }
    } else {
      return JSONUtils.SimpleJSONError("No valid plates available to save");
    }
  }
コード例 #16
0
ファイル: PL02BranchGroup.java プロジェクト: bgarrels/jCAE
 /**
  * @param coords A coordinate buffer
  * @param i The index in this buffer where to put the 12 components of this quad
  */
 public void updateCoords(float[][] grid, float[] coords, int i) {
   System.arraycopy(p.getCoordinates(grid, u, v), 0, coords, i, 3);
   System.arraycopy(p.getCoordinates(grid, u, v + 1), 0, coords, i + 3, 3);
   System.arraycopy(p.getCoordinates(grid, u + 1, v + 1), 0, coords, i + 6, 3);
   System.arraycopy(p.getCoordinates(grid, u + 1, v), 0, coords, i + 9, 3);
 }
コード例 #17
0
ファイル: PL02BranchGroup.java プロジェクト: bgarrels/jCAE
  private Plate[] domainToPlates(FDDomain domain) {
    LOGGER.finest("<creating plates >");
    int n = domain.getNumberOfXPlate() + domain.getNumberOfYPlate() + domain.getNumberOfZPlate();
    LOGGER.finest("number of plates in domain is " + n);
    Plate[] plates = new Plate[n];

    Iterator<int[]> it = domain.getXPlateIterator();
    int i = 0;
    while (it.hasNext()) {
      int[] indices = it.next();
      Plate p = new PlateX();
      p.position = indices[0];
      p.min1 = indices[1];
      p.min2 = indices[2];
      p.max1 = indices[3];
      p.max2 = indices[4];
      plates[i] = p;
      i++;
    }

    if (i != domain.getNumberOfXPlate())
      throw new IllegalStateException(i + "!=" + domain.getNumberOfXPlate());

    it = domain.getYPlateIterator();
    while (it.hasNext()) {
      int[] indices = it.next();
      Plate p = new PlateY();
      p.position = indices[0];
      p.min1 = indices[1];
      p.min2 = indices[2];
      p.max1 = indices[3];
      p.max2 = indices[4];
      plates[i] = p;
      i++;
    }

    if (i != domain.getNumberOfXPlate() + domain.getNumberOfYPlate())
      throw new IllegalStateException(
          i + "!=" + domain.getNumberOfXPlate() + domain.getNumberOfYPlate());

    it = domain.getZPlateIterator();
    while (it.hasNext()) {
      int[] indices = it.next();
      Plate p = new PlateZ();
      p.position = indices[0];
      p.min1 = indices[1];
      p.min2 = indices[2];
      p.max1 = indices[3];
      p.max2 = indices[4];
      plates[i] = p;
      i++;
    }

    if (i != n) throw new IllegalStateException(i + "!=" + n);

    LOGGER.finest("</creating plates>");
    return plates;
  }
コード例 #18
0
ファイル: OME.java プロジェクト: hflynn/bioformats
  protected Element asXMLElement(Document document, Element OME_element) {
    // Creating XML block for OME

    if (OME_element == null) {
      OME_element = document.createElementNS(NAMESPACE, "OME");
    }

    if (uuid != null) {
      // Attribute property UUID
      OME_element.setAttribute("UUID", uuid.toString());
    }
    if (creator != null) {
      // Attribute property Creator
      OME_element.setAttribute("Creator", creator.toString());
    }
    if (projects != null) {
      // Element property Project which is complex (has
      // sub-elements) and occurs more than once
      for (Project projects_value : projects) {
        OME_element.appendChild(projects_value.asXMLElement(document));
      }
    }
    if (datasets != null) {
      // Element property Dataset which is complex (has
      // sub-elements) and occurs more than once
      for (Dataset datasets_value : datasets) {
        OME_element.appendChild(datasets_value.asXMLElement(document));
      }
    }
    if (experiments != null) {
      // Element property Experiment which is complex (has
      // sub-elements) and occurs more than once
      for (Experiment experiments_value : experiments) {
        OME_element.appendChild(experiments_value.asXMLElement(document));
      }
    }
    if (plates != null) {
      // Element property Plate which is complex (has
      // sub-elements) and occurs more than once
      for (Plate plates_value : plates) {
        OME_element.appendChild(plates_value.asXMLElement(document));
      }
    }
    if (screens != null) {
      // Element property Screen which is complex (has
      // sub-elements) and occurs more than once
      for (Screen screens_value : screens) {
        OME_element.appendChild(screens_value.asXMLElement(document));
      }
    }
    if (experimenters != null) {
      // Element property Experimenter which is complex (has
      // sub-elements) and occurs more than once
      for (Experimenter experimenters_value : experimenters) {
        OME_element.appendChild(experimenters_value.asXMLElement(document));
      }
    }
    if (experimenterGroups != null) {
      // Element property ExperimenterGroup which is complex (has
      // sub-elements) and occurs more than once
      for (ExperimenterGroup experimenterGroups_value : experimenterGroups) {
        OME_element.appendChild(experimenterGroups_value.asXMLElement(document));
      }
    }
    if (instruments != null) {
      // Element property Instrument which is complex (has
      // sub-elements) and occurs more than once
      for (Instrument instruments_value : instruments) {
        OME_element.appendChild(instruments_value.asXMLElement(document));
      }
    }
    if (images != null) {
      // Element property Image which is complex (has
      // sub-elements) and occurs more than once
      for (Image images_value : images) {
        OME_element.appendChild(images_value.asXMLElement(document));
      }
    }
    if (structuredAnnotations != null) {
      // Element property StructuredAnnotations which is complex (has
      // sub-elements)
      OME_element.appendChild(structuredAnnotations.asXMLElement(document));
    }
    if (roIs != null) {
      // Element property ROI which is complex (has
      // sub-elements) and occurs more than once
      for (ROI roIs_value : roIs) {
        OME_element.appendChild(roIs_value.asXMLElement(document));
      }
    }
    if (binaryOnly != null) {
      // Element property BinaryOnly which is complex (has
      // sub-elements)
      OME_element.appendChild(binaryOnly.asXMLElement(document));
    }
    return super.asXMLElement(document, OME_element);
  }