int lineLength = cross.getHorizontalLength(); if (lineLength > 100) { monitor.setRealScaleFactor(unit.getConvFactor() * val / lineLength); monitor.setRealScaleFactor(unit.getConvFactor() * val / lineLength); double h = bound.getHeight() * bound.getHeight(); double realHeight = Math.sqrt(val * val * h / (w + h)); monitor.setRealScaleFactor(unit.getConvFactor() * realHeight / bound.getHeight());
Unit down = ajustUnit; while ((down = down.getDownUnit()) != null) { double length = scaleLength * down.getConversionRatio(unit[0].getConvFactor()); if (length > 1) { ajustUnit = down; Unit up = ajustUnit; while ((up = up.getUpUnit()) != null) { double length = scaleLength * up.getConversionRatio(unit[0].getConvFactor()); if (length < 1) { break;
public MeasurementsAdapter getMeasurementAdapter(Unit displayUnit, Point offset) { Unit unit = displayUnit; if (unit == null || pixelSpacingUnit == null || pixelSpacingUnit.equals(Unit.PIXEL)) { unit = Unit.PIXEL; } double unitRatio; if (unit.equals(Unit.PIXEL)) { unitRatio = 1.0; } else { unitRatio = getPixelSize() * unit.getConversionRatio(pixelSpacingUnit.getConvFactor()); } int offsetx = offset == null ? 0 : -offset.x; int offsety = offset == null ? 0 : -offset.y; return new MeasurementsAdapter(unitRatio, offsetx, offsety, false, 0, unit.getAbbreviation()); }
@Override public double getRealWorldViewScale() { double viewScale = 0.0; E img = getImage(); if (img != null) { Window win = SwingUtilities.getWindowAncestor(this); if (win != null) { GraphicsConfiguration config = win.getGraphicsConfiguration(); Monitor monitor = MeasureTool.viewSetting.getMonitor(config.getDevice()); if (monitor != null) { double realFactor = monitor.getRealScaleFactor(); if (realFactor > 0.0) { Unit imgUnit = img.getPixelSpacingUnit(); if (!Unit.PIXEL.equals(imgUnit)) { viewScale = imgUnit.getConvFactor() * img.getPixelSize() / realFactor; viewScale = -adjustViewScale(viewScale); } } } } } return viewScale; }
attrs.setString(Tag.PixelSpacingCalibrationDescription, VR.LO, "Used fiducial"); //$NON-NLS-1$ double unitRatio = imageElement.getPixelSize() * Unit.MILLIMETER.getConversionRatio(imageElement.getPixelSpacingUnit().getConvFactor()); attrs.setDouble(Tag.PixelSpacing, VR.DS, unitRatio, unitRatio);