public void apply(final mpicbg.models.CoordinateTransform ct, final Area roi) { final double[] fp = new double[]{x, y}; ct.applyInPlace(fp); this.x = (float)fp[0]; this.y = (float)fp[1]; } public void apply(final VectorDataTransform vlocal) {
@Override public void applyInPlace( final double[] location ) { final double[] copy = b.apply( location ); a.applyInPlace( location ); for ( int d = 0; d < location.length; ++d ) { final double dd = copy[ d ] - location[ d ]; location[ d ] += lambda * dd; } } }
/** * Apply a {@link CoordinateTransform} to the {@link Point} by a given amount. * * Transfers the {@link #l local coordinates} to new * {@link #w world coordinates}. * * @param t * @param amount 0.0 -> no application, 1.0 -> full application */ final public void apply( final CoordinateTransform t, final double amount ) { final double[] a = t.apply( l ); for ( int i = 0; i < a.length; ++i ) w[ i ] += amount * ( a[ i ] - w[ i ] ); }
/** * Apply a {@link CoordinateTransform} to the {@link Point} by a given amount. * * Transfers the {@link #l local coordinates} to new * {@link #w world coordinates}. * * @param t * @param amount 0.0 -> no application, 1.0 -> full application */ final public void apply( final CoordinateTransform t, final double amount ) { final double[] a = t.apply( l ); for ( int i = 0; i < a.length; ++i ) w[ i ] += amount * ( a[ i ] - w[ i ] ); }
@Override final public void applyInPlace( final double[] location ) { for ( final E t : transforms ) t.applyInPlace( location ); }
@Override public void applyInPlace( final double[] location ) { final double[] copy = b.apply( location ); a.applyInPlace( location ); for ( int d = 0; d < location.length; ++d ) { final double dd = copy[ d ] - location[ d ]; location[ d ] += lambda * dd; } } }
/** Reuses the @param fp to apply in place. */ static public final void apply(final mpicbg.models.CoordinateTransform ict, final double[][] p, final int i, final double[] fp) { fp[0] = p[0][i]; fp[1] = p[1][i]; ict.applyInPlace(fp); p[0][i] = fp[0]; p[1][i] = fp[1]; }
@Override final public void applyInPlace( final double[] location ) { for ( final E t : transforms ) t.applyInPlace( location ); }
public CoordinateTransformMap2D( final CoordinateTransform t, final int width, final int height ) { this.width = width; this.height = height; map = new float[ height ][ width * 2 ]; final double[] l = new double[ 2 ]; for ( int y = 0; y < height; ++y ) { for ( int x = 0; x < width; ++x ) { l[ 0 ] = x; l[ 1 ] = y; t.applyInPlace( l ); map[ y ][ 2 * x ] = ( float )l[ 0 ]; map[ y ][ 2 * x + 1 ] = ( float )l[ 1 ]; } } }
public CoordinateTransformMap2D( final CoordinateTransform t, final int width, final int height ) { this.width = width; this.height = height; map = new float[ height ][ width * 2 ]; final double[] l = new double[ 2 ]; for ( int y = 0; y < height; ++y ) { for ( int x = 0; x < width; ++x ) { l[ 0 ] = x; l[ 1 ] = y; t.applyInPlace( l ); map[ y ][ 2 * x ] = ( float )l[ 0 ]; map[ y ][ 2 * x + 1 ] = ( float )l[ 1 ]; } } }
/** * Apply a {@link CoordinateTransform} to the {@link Point}. * * Transfers the {@link #l local coordinates} to new * {@link #w world coordinates}. * * @param t */ final public void apply( final CoordinateTransform t ) { System.arraycopy( l, 0, w, 0, l.length ); t.applyInPlace( w ); }
/** * Apply a {@link CoordinateTransform} to the {@link Point}. * * Transfers the {@link #l local coordinates} to new * {@link #w world coordinates}. * * @param t */ final public void apply( final CoordinateTransform t ) { System.arraycopy( l, 0, w, 0, l.length ); t.applyInPlace( w ); }
public void apply(final VectorDataTransform vlocal) { for (final VectorDataTransform.ROITransform rt : vlocal.transforms) { // Apply only the first one that contains the point if (rt.roi.contains(x, y)) { final double[] fp = new double[]{x, y}; rt.ct.applyInPlace(fp); x = (float)fp[0]; y = (float)fp[1]; break; } } } public Point3f asPoint() {
@Override public void apply(final VectorDataTransform vdt) { for (final VectorDataTransform.ROITransform rt : vdt.transforms) { // Apply only the first one that contains the point if (rt.roi.contains(x, y)) { // Store point final double ox = x, oy = y; // Transform point final double[] fp = new double[]{x, y}; rt.ct.applyInPlace(fp); x = ( float )fp[0]; y = ( float )fp[1]; // Transform the radius: assume it's a point to the right of the untransformed point if (0 != r) { fp[0] = ox + r; fp[1] = oy; rt.ct.applyInPlace(fp); r = ( float )Math.abs(fp[0] - this.x); } break; } } }
@Override public void apply(final mpicbg.models.CoordinateTransform ct, final Area roi) { // store the point final double ox = x, oy = y; // transform the point itself super.apply(ct, roi); // transform the radius: assume it's a point to its right if (0 != r) { final double[] fp = new double[]{ox + r, oy}; ct.applyInPlace(fp); r = ( float )Math.abs(fp[0] - this.x); } } @Override
@Override synchronized public boolean apply(final Layer la, final Area roi, final mpicbg.models.CoordinateTransform ict) throws Exception { // Considers only the point where this floating text label is. final double[] fp = new double[2]; // point is 0,0 this.at.transform(fp, 0, fp, 0, 1); // to world if (roi.contains(fp[0], fp[1])) { ict.applyInPlace(fp); this.at.createInverse().transform(fp, 0, fp, 0, 1); // back to local // as a result, there has been a translation: this.at.preConcatenate(new AffineTransform(1, 0, 0, 1, fp[0], fp[1])); return true; } return false; } @Override
@Override public boolean apply(final VectorDataTransform vdt) throws Exception { final double[] fp = new double[2]; // point is 0,0 this.at.transform(fp, 0, fp, 0, 1); // to world for (final VectorDataTransform.ROITransform rt : vdt.transforms) { if (rt.roi.contains(fp[0], fp[1])) { rt.ct.applyInPlace(fp); this.at.createInverse().transform(fp, 0, fp, 0, 1); // back to local // as a result, there has been a translation this.at.preConcatenate(new AffineTransform(1, 0, 0, 1, fp[0], fp[1])); return true; } } return false; } }
/** Return a new Area resulting from applying @param ict to @param a; * assumes areas consists of paths with moveTo, lineTo and close operations. */ static public final Area transform(final mpicbg.models.CoordinateTransform ict, final Area a) { final GeneralPath path = new GeneralPath(); final float[] coords = new float[6]; final double[] fp = new double[2]; for (final PathIterator pit = a.getPathIterator(null); !pit.isDone(); ) { final int seg_type = pit.currentSegment(coords); fp[0] = coords[0]; fp[1] = coords[1]; ict.applyInPlace(fp); switch (seg_type) { case PathIterator.SEG_MOVETO: path.moveTo(fp[0], fp[1]); break; case PathIterator.SEG_LINETO: case PathIterator.SEG_CLOSE: path.lineTo(fp[0], fp[1]); break; default: Utils.log2("WARNING: unhandled seg type."); break; } pit.next(); if (pit.isDone()) { break; } } return new Area(path); }
@Override public boolean apply(final VectorDataTransform vdt) throws Exception { final double[] fp = new double[2]; final VectorDataTransform vlocal = vdt.makeLocalTo(this); for (int i=0; i<n_points; i++) { if (vlocal.layer.getId() == p_layer[i]) { for (final VectorDataTransform.ROITransform rt : vlocal.transforms) { if (rt.roi.contains(p[0][i], p[1][i])) { // Keep point copy final double ox = p[0][i], oy = p[1][i]; // Transform the point M.apply(rt.ct, p, i, fp); // For radius, assume it's a point to the right of the center point fp[0] = (float)(ox + p_width[i]); fp[1] = (float)oy; rt.ct.applyInPlace(fp); p_width[i] = Math.sqrt(Math.pow(fp[0] - p[0][i], 2) + Math.pow(fp[1] - p[1][i], 2)); break; } } } } calculateBoundingBox(true, vlocal.layer); return true; }
final static protected void transform( final CoordinateTransform transform, final ImageProcessor source, final ImageProcessor target ) { for ( int y = 0; y < target.getHeight(); ++y ) { for ( int x = 0; x < target.getWidth(); ++x ) { final double[] t = new double[]{ x, y }; transform.applyInPlace( t ); target.putPixel( x, y, source.getPixel( ( int )t[ 0 ], ( int )t[ 1 ] ) ); } } }