mapper Property

Summary

Gets or sets the mapper for this AnnContainer.

Syntax
TypeScript
JavaScript
Object.defineProperty(AnnContainer.prototype, 'mapper', 
	get: function(), 
	set: function(value) 
) 

Property Value

The mapper for this AnnContainer. The default value is the object created by AnnContainerMapper.CreateDefault.

Remarks

The mapper is used by this container when converting display, container and image coordinates. For more information, refer to AnnContainerMapper.

If you set the value of this property to null, then this container will use an object created from AnnContainerMapper.CreateDefault instead. Therefore, you will always get a valid object when querying the value of this property.

Example

This example will use the mapper to convert a rectangle value from annotation to image units and back.

TypeScript
JavaScript
var inch = 720.0; 
 
// Create a new annotation container, 8.5 by 11 inches 
var container = new lt.Annotations.Engine.AnnContainer(); 
// Size must be in annotation units (1/720 of an inch) 
container.set_size(lt.LeadSizeD.create(8.5 * inch, 11 * inch)); 
 
// Set its mapper, assuming the screen DPI is 96 and the image DPI is 300 
container.set_mapper(new lt.Annotations.Engine.AnnContainerMapper(96, 96, 300, 300)); 
 
// Add a blue on yellow rectangle from 3in 3in to 4in 4in 
var rectObj = new lt.Annotations.Engine.AnnRectangleObject(); 
rectObj.set_rect(lt.LeadRectD.create(3 * inch, 3 * inch, 1 * inch, 1 * inch)); 
rectObj.set_stroke(lt.Annotations.Engine.AnnStroke.create(lt.Annotations.Engine.AnnSolidColorBrush.create("blue"), lt.LeadLengthD.create(1))); 
rectObj.set_fill(lt.Annotations.Engine.AnnSolidColorBrush.create("yellow")); 
container.get_children().add(rectObj); 
 
// Get the rectangle in annotations units 
var rc = rectObj.get_rect(); 
alert("Annotations units: " + rc.get_left() + "," + rc.get_top() + "," + rc.get_right() + "," + rc.get_bottom()); 
 
// Convert it to image coordinates 
rc = container.get_mapper().rectFromContainerCoordinates(rc, lt.Annotations.Engine.AnnFixedStateOperations.none); 
alert("Image units (pixels): " + rc.get_left() + "," + rc.get_top() + "," + rc.get_right() + "," + rc.get_bottom()); 
 
// If this container is used with an image, you can use the pixels values above to find the exact value on the image 
 
// Convert it to back to annotations units 
rc = container.get_mapper().rectToContainerCoordinates(rc); 
alert("Original units: " + rc.get_left() + "," + rc.get_top() + "," + rc.get_right() + "," + rc.get_bottom()); 
const inch = 720.0; 
 
// Create a new annotation container, 8.5 by 11 inches 
const container: lt.Annotations.Engine.AnnContainer = new lt.Annotations.Engine.AnnContainer(); 
// Size must be in annotation units (1/720 of an inch) 
container.size = lt.LeadSizeD.create(8.5 * inch, 11 * inch); 
 
// Set its mapper, assuming the screen DPI is 96 and the image DPI is 300 
container.mapper = new lt.Annotations.Engine.AnnContainerMapper(96, 96, 300, 300); 
 
// Add a blue on yellow rectangle from 3in 3in to 4in 4in 
const rectObj: lt.Annotations.Engine.AnnRectangleObject = new lt.Annotations.Engine.AnnRectangleObject(); 
rectObj.rect = lt.LeadRectD.create(3 * inch, 3 * inch, 1 * inch, 1 * inch); 
rectObj.stroke = lt.Annotations.Engine.AnnStroke.create(lt.Annotations.Engine.AnnSolidColorBrush.create("blue"), lt.LeadLengthD.create(1)); 
rectObj.fill = lt.Annotations.Engine.AnnSolidColorBrush.create("yellow"); 
container.children.add(rectObj); 
 
// Get the rectangle in annotations units 
let rc: lt.LeadRectD = rectObj.rect; 
alert("Annotations units: " + rc.left + "," + rc.top + "," + rc.right + "," + rc.bottom); 
 
// Convert it to image coordinates 
rc = container.mapper.rectFromContainerCoordinates(rc, lt.Annotations.Engine.AnnFixedStateOperations.none); 
alert("Image units (pixels): " + rc.left + "," + rc.top + "," + rc.right + "," + rc.bottom); 
 
// If this container is used with an image, you can use the pixels values above to find the exact value on the image 
 
// Convert it to back to annotations units 
rc = container.mapper.rectToContainerCoordinates(rc); 
alert("Original units: " + rc.left + "," + rc.top + "," + rc.right + "," + rc.bottom); 

Requirements

Target Platforms

Help Version 20.0.2019.3.11
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2019 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Annotations.Engine Assembly