Example usage for java.awt.geom AffineTransform toString

List of usage examples for java.awt.geom AffineTransform toString

Introduction

In this page you can find the example usage for java.awt.geom AffineTransform toString.

Prototype

public String toString() 

Source Link

Document

Returns a String that represents the value of this Object .

Usage

From source file:edu.valelab.gaussianfit.datasettransformations.CoordinateMapper.java

public static void logAffineTransform(AffineTransform af) {
    AffineTransform tmp = new AffineTransform(af);
    try {// w w  w  .j  a  v a  2 s .  co  m
        AffineTransform inv = tmp.createInverse();
        ij.IJ.log(inv.toString());
    } catch (NoninvertibleTransformException ex) {
        ReportingUtils.logError(ex, "Problem while printing affine transform");
    }
}

From source file:org.micromanager.plugins.magellan.coordinates.AffineCalibrator.java

public void computeAffine() throws Exception {
    IJ.log("Automatic affine calibration.");
    IJ.log(" ");/*from w  ww .  java2 s.c  o  m*/
    IJ.log("This module will attempt to estimate the affine transformation matrix based on \n"
            + "three images of the same object in a different part of the field of view. Between \n"
            + "each successive image, the XY stage must be tranlsated so that the object is in a \n"
            + "different part of the field of view. The first image has already been captured.");
    CMMCore core = Magellan.getCore();
    String xyStage = core.getXYStageDevice();
    Point2D.Double[] stagePositions = new Point2D.Double[3], pixPositions = new Point2D.Double[3];

    stagePositions[0] = new Point2D.Double(core.getXPosition(xyStage), core.getYPosition(xyStage));
    TaggedImage img0 = snapAndAdd();
    nextImageLatch_ = new CountDownLatch(1);
    Log.log("Move stage to new position with same features visible, and press Capture");
    nextImageLatch_.await();
    if (abort_) {
        return;
    }

    stagePositions[1] = new Point2D.Double(core.getXPosition(xyStage), core.getYPosition(xyStage));
    TaggedImage img1 = snapAndAdd();
    nextImageLatch_ = new CountDownLatch(1);
    Log.log("Move stage to new position with same features visible, and press Capture");
    nextImageLatch_.await();
    if (abort_) {
        return;
    }

    stagePositions[2] = new Point2D.Double(core.getXPosition(xyStage), core.getYPosition(xyStage));
    TaggedImage img2 = snapAndAdd();

    //use Xcorr to calculate pixel coordinates
    ProgressBar progressBar = new ProgressBar("Computing affine transform (may take several minutes)", 0, 3);
    progressBar.setProgress(0);
    progressBar.setVisible(true);
    pixPositions[0] = new Point2D.Double(0, 0); // define first one as the origin
    progressBar.setProgress(1);
    pixPositions[1] = crossCorrelate(img0, img1);
    progressBar.setProgress(2);
    pixPositions[2] = crossCorrelate(img0, img2);
    progressBar.setProgress(3);
    progressBar.setVisible(false);

    //3) compute affine from three pairs of points
    AffineTransform transform = computeAffine(pixPositions[0], pixPositions[1], pixPositions[2],
            stagePositions[0], stagePositions[1], stagePositions[2]);

    //ask if user likes this affine transform and wants to store it
    int result = JOptionPane.showConfirmDialog(affineGui_,
            "Calulcated affine transform matrix: " + transform.toString()
                    + ". Would you like to store these settings?",
            "Store calculated affine transform?", JOptionPane.YES_NO_OPTION);
    if (result == JOptionPane.YES_OPTION) {
        //store affine
        AffineUtils.storeAffineTransform(core.getCurrentPixelSizeConfig(), transform);
        //mark as updated
        AffineUtils.transformUpdated(core.getCurrentPixelSizeConfig(), transform);
    }
}