AnnStickyNoteObject Object

Summary

Defines an annotation sticky note object.

Syntax
TypeScript
JavaScript
functionlt.Annotations.Engine.AnnStickyNoteObjectextendslt.Annotations.Engine.AnnObjectimplementsIAnnObjectCloneable
classlt.Annotations.Engine.AnnStickyNoteObject()extendsAnnObjectimplementsIAnnObjectCloneable
Remarks

The sticky note object is aPicturerendered around single point (the center). This point is the first entry in thePointscollection and all others are ignored. This object does not support fill, stroke nor font.

This object supports using theSelectionStrokeand by default when the value ofIsSelectedistrue, it will use the stroke to draw a rectangle around the image instead of using a selection thumb.

With the automated functions, in design mode, the sticky point object is formed with a click or tap event.

Programmatically, the boundaries and location of the sticky note object can be controlled using the following properties: Each object can be transformed with the following methods:

TheAnnStickyNoteObjectclass inherits a number of properties from theAnnObjectclass, it does not support fill, stroke or font by overridesSupportsSelectionStroketo returntrue. The name of the sticky note object can be controlled usingLabelsproperty, inherited from theAnnObjectclass. An object can be part of a group annotation object or part of a container object. It cannot be part of both a group and a container at the same time. The following properties can also be used to programmatically set characteristics of anAnnStickyNoteObject:

Example

This example creates a sticky note object and adds it to the automation container.

AnnStickyNote.ts
EngineHelper.ts
AnnStickyNote.js
EngineHelper.js
AnnStickyNote.html
import{EngineHelper } from"../../utilities/EngineHelper";exportclassAnnObjects_StickyNote {constructor() {consthelper =newEngineHelper();helper.run(this.create);}create = (automation: lt.Annotations.Automation.AnnAutomation) => {// Create a new instance of AnnResources if the automation manager does not already have onelet resources: lt.Annotations.Engine.AnnResources = automation.manager.resources;if(resources ==null) {resources =newlt.Annotations.Engine.AnnResources();automation.manager.resources = resources;}// Get the images collectionconstimagesResources: lt.Annotations.Engine.AnnPicture[] = resources.images;// Add our picture to itimagesResources.push(newlt.Annotations.Engine.AnnPicture("Resources/Objects/StickyNote.png"));constpictureIndex:number= imagesResources.length - 1;// assumes _automation is validconstinch:number= 720.0;// Add a sticky note objectconstannObj: lt.Annotations.Engine.AnnStickyNoteObject =newlt.Annotations.Engine.AnnStickyNoteObject();// Set the points for the hotspotannObj.points.add(lt.LeadPointD.create(1 * inch, 1 * inch));annObj.points.add(lt.LeadPointD.create(2 * inch, 1 * inch));annObj.points.add(lt.LeadPointD.create(2 * inch, 2 * inch));annObj.points.add(lt.LeadPointD.create(1 * inch, 2 * inch));// Set the pictureannObj.defaultPicture = pictureIndex;// Add the object to the automation containerautomation.container.children.add(annObj);// Select the objectautomation.selectObject(annObj);// Hook to rendering engine loadPicture event to render the container immediately after resources get loadedautomation.manager.renderingEngine.add_loadPicture((sender, e) => {automation.invalidate(lt.LeadRectD.empty);});}}
exportclassEngineHelper {// Automation objectprotected_automation: lt.Annotations.Automation.AnnAutomation =null;// Image viewerprotected_viewer: lt.Controls.ImageViewer =null;constructor() {/ /设置LEADTOOLS许可证。用你替换这个ur actual license filelt.RasterSupport.setLicenseUri("https://demo.leadtools.com/licenses/v200/LEADTOOLSEVAL.txt","EVAL",null);}publicrun(callback?: (automation: lt.Annotations.Automation.AnnAutomation, viewer: lt.Controls.ImageViewer) =>void):void// Create the viewerconstimageViewerDiv = document.getElementById("imageViewerDiv");constcreateOptions: lt.Controls.ImageViewerCreateOptions =newlt.Controls.ImageViewerCreateOptions(imageViewerDiv);constviewer: lt.Controls.ImageViewer =newlt.Controls.ImageViewer(createOptions);viewer.autoCreateCanvas =true;this._viewer = viewer;// PanZoom interactive modeconstpanZoom: lt.Controls.ImageViewerPanZoomInteractiveMode =newlt.Controls.ImageViewerPanZoomInteractiveMode();// Create an instance of the Automation control object that works with LEADTOOLS ImageViewerconstimageViewerAutomationControl: lt.Demos.Annotations.ImageViewerAutomationControl =newlt.Demos.Annotations.ImageViewerAutomationControl();// Attach our image viewerimageViewerAutomationControl.imageViewer = viewer;// Set the image viewer interactive modeconstautomationInteractiveMode: lt.Demos.Annotations.AutomationInteractiveMode =newlt.Demos.Annotations.AutomationInteractiveMode();automationInteractiveMode.automationControl = imageViewerAutomationControl;// Set the image URLviewer.imageUrl ="http://demo.leadtools.com/images/png/pngimage.png";// Create and set up the automation manager using the HTML5 rendering engineconstrenderingEngine: lt.Annotations.Rendering.AnnHtml5RenderingEngine =newlt.Annotations.Rendering.AnnHtml5RenderingEngine();constmanager: lt.Annotations.Automation.AnnAutomationManager = lt.Annotations.Automation.AnnAutomationManager.create(renderingEngine);// Create default automation objectsmanager.createDefaultObjects();// Add the objects to the objects select elementconstcurrentObjectIdSelect = document.getElementById("currentObjectIdSelect") as HTMLSelectElement;// Add the PanZoom optioncurrentObjectIdSelect.options[currentObjectIdSelect.options.length] =newOption("Pan/Zoom", lt.Annotations.Engine.AnnObject.none.toString());constautomationObjCount:number= manager.objects.count;for(let i = 0; i < automationObjCount; i++) {// Get the objectconstautomationObj: lt.Annotations.Automation.AnnAutomationObject = manager.objects.item(i);// Add its name to the select elementconstname:string= automationObj.name;constid:string= automationObj.id.toString();currentObjectIdSelect.options[currentObjectIdSelect.options.length] =newOption(name, id);}// Hook to its change eventcurrentObjectIdSelect.addEventListener("change", () => {// Get the object IDconstid:number= parseInt(currentObjectIdSelect.options[currentObjectIdSelect.selectedIndex].value);// Set it as the current object in the managermanager.currentObjectId = id;// If this is the "Pan/Zoom" option, then back to pan zoom, otherwise, set our automation controlif(id == lt.Annotations.Engine.AnnObject.none) {viewer.defaultInteractiveMode = panZoom;}elseviewer.defaultInteractiveMode = automationInteractiveMode;}});// When the current object ID changes, we need to update our selectmanager.add_currentObjectIdChanged((sender, e) => {constcurrentObjectId:number= manager.currentObjectId;for(let i = 0; i < currentObjectIdSelect.options.length; i++) {constid:number= parseInt(currentObjectIdSelect.options[i].value);if(id === currentObjectId) {currentObjectIdSelect.selectedIndex = i;break;}}});// Pan zoom by defaultviewer.defaultInteractiveMode = panZoom;// set up the automation (will create the container as well)constautomation: lt.Annotations.Automation.AnnAutomation =newlt.Annotations.Automation.AnnAutomation(manager, imageViewerAutomationControl);this._automation = automation;// Add handler to update the container size when the image size changesviewer.itemChanged.add((sender, e) => {constcontainer: lt.Annotations.Engine.AnnContainer = automation.container;container.size = container.mapper.sizeToContainerCoordinates(viewer.imageSize);//Create new canvas data provider for the new imageconstcanvasDataProvider: lt.Demos.Annotations.CanvasDataProvider =newlt.Demos.Annotations.CanvasDataProvider(viewer.activeItem.canvas);imageViewerAutomationControl.automationDataProvider = canvasDataProvider;});// set up this automation as the active onethis._automation.active =true;constexampleButton = document.getElementById("exampleButton");exampleButton.onclick = () => {if(callback)callback(this._automation,this._viewer);}}}
import{EngineHelper } from"../../utilities/EngineHelper";exportclassAnnObjects_StickyNote {constructor() {consthelper =newEngineHelper();helper.run(this.create);}create = (automation) => {// Create a new instance of AnnResources if the automation manager does not already have onelet resources = automation.manager.resources;if(resources ==null) {resources =newlt.Annotations.Engine.AnnResources();automation.manager.resources = resources;}// Get the images collectionconstimagesResources = resources.images;// Add our picture to itimagesResources.push(newlt.Annotations.Engine.AnnPicture("Resources/Objects/StickyNote.png"));constpictureIndex = imagesResources.length - 1;// assumes _automation is validconstinch = 720.0;// Add a sticky note objectconstannObj =newlt.Annotations.Engine.AnnStickyNoteObject();// Set the points for the hotspotannObj.points.add(lt.LeadPointD.create(1 * inch, 1 * inch));annObj.points.add(lt.LeadPointD.create(2 * inch, 1 * inch));annObj.points.add(lt.LeadPointD.create(2 * inch, 2 * inch));annObj.points.add(lt.LeadPointD.create(1 * inch, 2 * inch));// Set the pictureannObj.defaultPicture = pictureIndex;// Add the object to the automation containerautomation.container.children.add(annObj);// Select the objectautomation.selectObject(annObj);// Hook to rendering engine loadPicture event to render the container immediately after resources get loadedautomation.manager.renderingEngine.add_loadPicture((sender, e) => {automation.invalidate(lt.LeadRectD.empty);});}}
exportclassEngineHelper {// Automation object_automation =null;// Image viewer_viewer =null;constructor() {/ /设置LEADTOOLS许可证。用你替换这个ur actual license filelt.RasterSupport.setLicenseUri("https://demo.leadtools.com/licenses/v200/LEADTOOLSEVAL.txt","EVAL",null);}run(callback) {// Create the viewerconstimageViewerDiv = document.getElementById("imageViewerDiv");constcreateOptions =newlt.Controls.ImageViewerCreateOptions(imageViewerDiv);constviewer =newlt.Controls.ImageViewer(createOptions);viewer.autoCreateCanvas =true;this._viewer = viewer;// PanZoom interactive modeconstpanZoom =newlt.Controls.ImageViewerPanZoomInteractiveMode();// Create an instance of the Automation control object that works with LEADTOOLS ImageViewerconstimageViewerAutomationControl =newlt.Demos.Annotations.ImageViewerAutomationControl();// Attach our image viewerimageViewerAutomationControl.imageViewer = viewer;// Set the image viewer interactive modeconstautomationInteractiveMode =newlt.Demos.Annotations.AutomationInteractiveMode();automationInteractiveMode.automationControl = imageViewerAutomationControl;// Set the image URLviewer.imageUrl ="http://demo.leadtools.com/images/png/pngimage.png";// Create and set up the automation manager using the HTML5 rendering engineconstrenderingEngine =newlt.Annotations.Rendering.AnnHtml5RenderingEngine();constmanager = lt.Annotations.Automation.AnnAutomationManager.create(renderingEngine);// Create default automation objectsmanager.createDefaultObjects();// Add the objects to the objects select elementconstcurrentObjectIdSelect = document.getElementById("currentObjectIdSelect");// Add the PanZoom optioncurrentObjectIdSelect.options[currentObjectIdSelect.options.length] =newOption("Pan/Zoom", lt.Annotations.Engine.AnnObject.none.toString());constautomationObjCount = manager.objects.count;for(let i = 0; i < automationObjCount; i++) {// Get the objectconstautomationObj = manager.objects.item(i);// Add its name to the select elementconstname = automationObj.name;constid = automationObj.id.toString();currentObjectIdSelect.options[currentObjectIdSelect.options.length] =newOption(name, id);}// Hook to its change eventcurrentObjectIdSelect.addEventListener("change", () => {// Get the object IDconstid = parseInt(currentObjectIdSelect.options[currentObjectIdSelect.selectedIndex].value);// Set it as the current object in the managermanager.currentObjectId = id;// If this is the "Pan/Zoom" option, then back to pan zoom, otherwise, set our automation controlif(id == lt.Annotations.Engine.AnnObject.none) {viewer.defaultInteractiveMode = panZoom;}elseviewer.defaultInteractiveMode = automationInteractiveMode;}});// When the current object ID changes, we need to update our selectmanager.add_currentObjectIdChanged((sender, e) => {constcurrentObjectId = manager.currentObjectId;for(let i = 0; i < currentObjectIdSelect.options.length; i++) {constid = parseInt(currentObjectIdSelect.options[i].value);if(id === currentObjectId) {currentObjectIdSelect.selectedIndex = i;break;}}});// Pan zoom by defaultviewer.defaultInteractiveMode = panZoom;// set up the automation (will create the container as well)constautomation =newlt.Annotations.Automation.AnnAutomation(manager, imageViewerAutomationControl);this._automation = automation;// Add handler to update the container size when the image size changesviewer.itemChanged.add((sender, e) => {constcontainer = automation.container;container.size = container.mapper.sizeToContainerCoordinates(viewer.imageSize);//Create new canvas data provider for the new imageconstcanvasDataProvider =newlt.Demos.Annotations.CanvasDataProvider(viewer.activeItem.canvas);imageViewerAutomationControl.automationDataProvider = canvasDataProvider;});// set up this automation as the active onethis._automation.active =true;constexampleButton = document.getElementById("exampleButton");exampleButton.onclick = () => {if(callback)callback(this._automation,this._viewer);}}}
"en">AnnObject Example | AnnStickyNote




Either Pan/Zoom or Annotations mode. In annotations mode, drawnewobjects or edit them.

"button"id="exampleButton"value="Example"/>
"imageViewerDiv"/>
Requirements
Target Platforms
Leadtools.Annotations.Engine Assembly
188金宝搏的网址客服|Support|Contact Us|Intellectual Property Notices
© 1991-2021LEAD Technologies, Inc.All Rights Reserved.