Leadtools.Annotations.Core名前空間 > AnnContainerクラス :Mapperプロパティ |
public AnnContainerMapper Mapper {get; set;}
'Declaration
Public Property Mapper As AnnContainerMapper
public AnnContainerMapper Mapper {get; set;}
@property (nonatomic) LTAnnContainerMapper* mapper;
public AnnContainerMapper getMapper() public void setMapper(AnnContainerMapper mapper)
get_Mapper();
set_Mapper(value);
Object.defineProperty('Mapper');
マッパーは、表示、コンテナとimage座標を変換するとき、このコンテナにより用いられます。詳細については、「AnnContainerMapper」を参照してください。
このプロパティの値をnullに設定するならば、このコンテナは代わりにAnnContainerMapper.CreateDefaultから作成されるオブジェクトを使います。したがって、このプロパティの値を問い合わせるとき、常に有効なオブジェクトを取得します。
このサンプルでは、マッパーを使って長方形値をアノテーションから画像ユニットに変換し、戻します。
using Leadtools.Annotations.Automation; using Leadtools.Annotations.Core; using Leadtools.Codecs; using Leadtools.Annotations.WinForms; public void AnnContainer_Mapper() { double inch = 720.0; // Create a new annotation container, 8.5 by 11 inches AnnContainer container = new AnnContainer(); // Size must be in annotation units (1/720 of an inch) container.Size = 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 AnnContainerMapper(96, 96, 300, 300); // Add a blue on yellow rectangle from 3in 3in to 4in 4in AnnRectangleObject rectObj = new AnnRectangleObject(); rectObj.Rect = LeadRectD.Create(3 * inch, 3 * inch, 1 * inch, 1 * inch); rectObj.Stroke = AnnStroke.Create(AnnSolidColorBrush.Create("Blue"), LeadLengthD.Create(1)); rectObj.Fill = AnnSolidColorBrush.Create("Yellow"); container.Children.Add(rectObj); // Get the rectangle in annotations units LeadRectD rc = rectObj.Rect; Debug.WriteLine("Annotations units: " + rc.X + "," + rc.Y + "," + rc.Width + "," + rc.Height); // Convert it to image coordinates rc = container.Mapper.RectFromContainerCoordinates(rc, AnnFixedStateOperations.None); Debug.WriteLine("Image units (pixels): " + rc.X + "," + rc.Y + "," + rc.Width + "," + rc.Height); // 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); Debug.WriteLine("Original units: " + rc.X + "," + rc.Y + "," + rc.Width + "," + rc.Height); }
using Leadtools.Converters; using Leadtools.Annotations.Automation; using Leadtools.Controls; using Leadtools.Annotations.Core; using Leadtools.Codecs; public void AnnContainer_Mapper() { double inch = 720.0; // Create a new annotation container, 8.5 by 11 inches AnnContainer container = new AnnContainer(); // Size must be in annotation units (1/720 of an inch) container.Size = LeadSizeDHelper.Create(8.5 * inch, 11 * inch); // Set its mapper, assuming the screen DPI is 96 and the image DPI is 300 container.Mapper = new AnnContainerMapper(96, 96, 300, 300); // Add a blue on yellow rectangle from 3in 3in to 4in 4in AnnRectangleObject rectObj = new AnnRectangleObject(); rectObj.Rect = LeadRectDHelper.Create(3 * inch, 3 * inch, 1 * inch, 1 * inch); rectObj.Stroke = AnnStroke.Create(AnnSolidColorBrush.Create("Blue"), LeadLengthDHelper.Create(1)); rectObj.Fill = AnnSolidColorBrush.Create("Yellow"); container.Children.Add(rectObj); // Get the rectangle in annotations units LeadRectD rc = rectObj.Rect; Debug.WriteLine("Annotations units: " + rc.X + "," + rc.Y + "," + rc.Width + "," + rc.Height); // Convert it to image coordinates rc = container.Mapper.RectFromContainerCoordinates(rc, AnnFixedStateOperations.None); Debug.WriteLine("Image units (pixels): " + rc.X + "," + rc.Y + "," + rc.Width + "," + rc.Height); // 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); Debug.WriteLine("Original units: " + rc.X + "," + rc.Y + "," + rc.Width + "," + rc.Height); }