Example #1
0
 @Override
 public boolean apply(final Layer la, final Area roi, final mpicbg.models.CoordinateTransform ict)
     throws Exception {
   double[] fp = null;
   mpicbg.models.CoordinateTransform chain = null;
   Area localroi = null;
   AffineTransform inverse = null;
   for (final Item item : al_items) {
     final long[] p_layer = item.p_layer;
     final double[][] p = item.p;
     for (int i = 0; i < item.n_points; i++) {
       if (p_layer[i] == la.getId()) {
         if (null == localroi) {
           inverse = this.at.createInverse();
           localroi = roi.createTransformedArea(inverse);
         }
         if (localroi.contains(p[0][i], p[1][i])) {
           if (null == chain) {
             chain = M.wrap(this.at, ict, inverse);
             fp = new double[2];
           }
           // Transform the point
           M.apply(chain, p, i, fp);
         }
       }
     }
   }
   if (null != chain) calculateBoundingBox(la);
   return true;
 }
Example #2
0
 // Expects graphics with an identity transform
 final void paint(final Graphics2D g, final AffineTransform aff, final Layer layer) {
   final int i_current = layer_set.indexOf(layer);
   int ii;
   final int M_radius = radius;
   final int EXTRA = 2;
   int paint_i = -1;
   for (int i = 0; i < n_points; i++) {
     ii = layer_set.getLayerIndex(p_layer[i]);
     if (ii == i_current - 1) g.setColor(Color.red);
     else if (ii == i_current) {
       paint_i = i;
       continue; // paint it last, on top of all
     } else if (ii == i_current + 1) g.setColor(Color.blue);
     else continue; // don't paint. Should just return, since points are in order
     // Convert point from local to world coordinates
     // Point2D.Double po = transformPoint(p[0][i], p[1][i]);
     // Convert point from world to screen coordinates
     // po = M.transform(gt, po.x, po.y);
     final Point2D.Double po = M.transform(aff, p[0][i], p[1][i]);
     final int px = (int) po.x;
     final int py = (int) po.y;
     g.drawOval(px - M_radius, py - M_radius, M_radius + M_radius, M_radius + M_radius);
     g.drawString(Integer.toString(tag), px + M_radius + EXTRA, py + M_radius);
   }
   // paint current:
   if (-1 != paint_i) {
     g.setColor(color); // the color of the Dissector
     // Convert point to world coordinates
     // Point2D.Double po = transformPoint(p[0][paint_i], p[1][paint_i]);
     // Convert point to screen coordinates
     // po = M.transform(gt, po.x, po.y);
     final Point2D.Double po = M.transform(aff, p[0][paint_i], p[1][paint_i]);
     final int px = (int) po.x;
     final int py = (int) po.y;
     g.drawRect(px - M_radius, py - M_radius, M_radius + M_radius, M_radius + M_radius);
     g.drawString(Integer.toString(tag), px + M_radius + EXTRA, py + M_radius);
   }
 }
Example #3
0
 final void addResults(final ResultsTable rt, final Calibration cal, final double nameid) {
   for (int i = 0; i < n_points; i++) {
     final Layer la = layer_set.getLayer(p_layer[i]);
     if (null == layer) {
       Utils.log("Dissector.addResults: could not find layer with id " + p_layer[i]);
       continue;
     }
     final Point2D.Double po = M.transform(Dissector.this.at, p[0][i], p[1][i]);
     rt.incrementCounter();
     rt.addLabel("units", cal.getUnit());
     rt.addValue(0, Dissector.this.id);
     rt.addValue(1, tag);
     rt.addValue(2, po.x * cal.pixelWidth);
     rt.addValue(3, po.y * cal.pixelHeight);
     rt.addValue(4, la.getZ() * cal.pixelWidth); // layer Z is in pixels
     rt.addValue(5, radius * cal.pixelWidth);
     rt.addValue(6, nameid);
   }
 }
Example #4
0
 @Override
 public boolean apply(final VectorDataTransform vdt) throws Exception {
   final double[] fp = new double[2];
   final VectorDataTransform vlocal = vdt.makeLocalTo(this);
   for (final Item item : al_items) {
     for (int i = 0; i < item.n_points; i++) {
       if (vdt.layer.getId() == item.p_layer[i]) {
         for (final VectorDataTransform.ROITransform rt : vlocal.transforms) {
           if (rt.roi.contains(item.p[0][i], item.p[1][i])) {
             // Transform the point
             M.apply(rt.ct, item.p, i, fp);
             break;
           }
         }
       }
     }
   }
   calculateBoundingBox(vlocal.layer);
   return true;
 }