Defines the base class for all line ending styles.
function lt.Annotations.Engine.AnnLineEnding class lt.Annotations.Engine.AnnLineEnding() The line ending styles are the shapes that can be added to the starting and ending points of the polyline object.
The AnnLineEnding Members class provides all the basic functionality common to all LEADTOOLS line ending styles. AnnLineEnding Members is an abstract class: you cannot instantiate objects of this class directly. Instead, you create an instance of a derived class such as AnnArrowLineEnding or AnnButtLineEnding and use the methods and properties of the base AnnLineEnding class through the derived class.
Line ending styles cannot be added to closed polyline objects.
This example creates a list of polyline objects, creates all ending style types and sets them to polyline objects ending styles.
import { EngineHelper } from "../../utilities/EngineHelper";export class AnnObject_AnnLineEnding {constructor() {const helper = new EngineHelper();helper.run(this.create);}create = (automation: lt.Annotations.Automation.AnnAutomation) => {// assumes _automation is validconst inch = 720.0;// Create polyline object and add it the automation containerlet polyLine: lt.Annotations.Engine.AnnPolylineObject = new lt.Annotations.Engine.AnnPolylineObject();polyLine.points.add(lt.LeadPointD.create(1 * inch, 1 * inch));polyLine.points.add(lt.LeadPointD.create(2 * inch, 1 * inch));automation.container.children.add(polyLine);// Create arrow line ending style and set some propertiesconst arrowStyle: lt.Annotations.Engine.AnnArrowLineEnding = new lt.Annotations.Engine.AnnArrowLineEnding();arrowStyle.closed = true;arrowStyle.reversed = true;arrowStyle.fill = lt.Annotations.Engine.AnnSolidColorBrush.create("Yellow");// Set the created arrow style to polyline start and end stylepolyLine.startStyle = arrowStyle;polyLine.endStyle = arrowStyle;// Create another polyline object and add it the automation containerpolyLine = new lt.Annotations.Engine.AnnPolylineObject();polyLine.points.add(lt.LeadPointD.create(1 * inch, 1.2 * inch));polyLine.points.add(lt.LeadPointD.create(2 * inch, 1.2 * inch));automation.container.children.add(polyLine);// Create butt line ending styleconst buttStyle: lt.Annotations.Engine.AnnButtLineEnding = new lt.Annotations.Engine.AnnButtLineEnding();// Set the created butt style to polyline start and end stylepolyLine.startStyle = buttStyle;polyLine.endStyle = buttStyle;// Create another polyline object and add it the automation containerpolyLine = new lt.Annotations.Engine.AnnPolylineObject();polyLine.points.add(lt.LeadPointD.create(1 * inch, 1.4 * inch));polyLine.points.add(lt.LeadPointD.create(2 * inch, 1.4 * inch));automation.container.children.add(polyLine);// Create slash line ending styleconst slashStyle: lt.Annotations.Engine.AnnSlashLineEnding = new lt.Annotations.Engine.AnnSlashLineEnding();// Set the created slash style to polyline start and end stylepolyLine.startStyle = slashStyle;polyLine.endStyle = slashStyle;// Create another polyline object and add it the automation containerpolyLine = new lt.Annotations.Engine.AnnPolylineObject();polyLine.points.add(lt.LeadPointD.create(1 * inch, 1.6 * inch));polyLine.points.add(lt.LeadPointD.create(2 * inch, 1.6 * inch));automation.container.children.add(polyLine);// Create square line ending stylevar squareStyle: lt.Annotations.Engine.AnnSquareLineEnding = new lt.Annotations.Engine.AnnSquareLineEnding();// Set the created square style to polyline start and end stylepolyLine.startStyle = squareStyle;polyLine.endStyle = squareStyle;// Create another polyline object and add it the automation containerpolyLine = new lt.Annotations.Engine.AnnPolylineObject();polyLine.points.add(lt.LeadPointD.create(1 * inch, 1.8 * inch));polyLine.points.add(lt.LeadPointD.create(2 * inch, 1.8 * inch));automation.container.children.add(polyLine);// Create diamond line ending styleconst diamondStyle: lt.Annotations.Engine.AnnDiamondLineEnding = new lt.Annotations.Engine.AnnDiamondLineEnding();// Set the created diamond style to polyline start and end stylepolyLine.startStyle = diamondStyle;polyLine.endStyle = diamondStyle;// Create another polyline object and add it the automation containerpolyLine = new lt.Annotations.Engine.AnnPolylineObject();polyLine.points.add(lt.LeadPointD.create(1 * inch, 2 * inch));polyLine.points.add(lt.LeadPointD.create(2 * inch, 2 * inch));automation.container.children.add(polyLine);// Create round line ending styleconst roundStyle: lt.Annotations.Engine.AnnRoundLineEnding = new lt.Annotations.Engine.AnnRoundLineEnding();// Set the created round style to polyline start and end stylepolyLine.startStyle = roundStyle;polyLine.endStyle = roundStyle;// Repaint to see the objectsautomation.invalidate(lt.LeadRectD.empty);}}
export class EngineHelper {// Automation objectprotected _automation: lt.Annotations.Automation.AnnAutomation = null;// Image viewerprotected _viewer: lt.Controls.ImageViewer = null;constructor() {// Set the LEADTOOLS license. Replace this with your actual license filelt.RasterSupport.setLicenseUri("https://demo.leadtools.com/licenses/v200/LEADTOOLSEVAL.txt", "EVAL", null);}public run(callback?: (automation: lt.Annotations.Automation.AnnAutomation, viewer: lt.Controls.ImageViewer) => void): void {// Create the viewerconst imageViewerDiv = document.getElementById("imageViewerDiv");const createOptions: lt.Controls.ImageViewerCreateOptions = new lt.Controls.ImageViewerCreateOptions(imageViewerDiv);const viewer: lt.Controls.ImageViewer = new lt.Controls.ImageViewer(createOptions);viewer.autoCreateCanvas = true;this._viewer = viewer;// PanZoom interactive modeconst panZoom: lt.Controls.ImageViewerPanZoomInteractiveMode = new lt.Controls.ImageViewerPanZoomInteractiveMode();// Create an instance of the Automation control object that works with LEADTOOLS ImageViewerconst imageViewerAutomationControl: lt.Demos.Annotations.ImageViewerAutomationControl = new lt.Demos.Annotations.ImageViewerAutomationControl();// Attach our image viewerimageViewerAutomationControl.imageViewer = viewer;// Set the image viewer interactive modeconst automationInteractiveMode: lt.Demos.Annotations.AutomationInteractiveMode = new lt.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 engineconst renderingEngine: lt.Annotations.Rendering.AnnHtml5RenderingEngine = new lt.Annotations.Rendering.AnnHtml5RenderingEngine();const manager: lt.Annotations.Automation.AnnAutomationManager = lt.Annotations.Automation.AnnAutomationManager.create(renderingEngine);// Create default automation objectsmanager.createDefaultObjects();// Add the objects to the objects select elementconst currentObjectIdSelect = document.getElementById("currentObjectIdSelect") as HTMLSelectElement;// Add the PanZoom optioncurrentObjectIdSelect.options[currentObjectIdSelect.options.length] = new Option("Pan/Zoom", lt.Annotations.Engine.AnnObject.none.toString());const automationObjCount: number = manager.objects.count;for (let i = 0; i < automationObjCount; i++) {// Get the objectconst automationObj: lt.Annotations.Automation.AnnAutomationObject = manager.objects.item(i);// Add its name to the select elementconst name: string = automationObj.name;const id: string = automationObj.id.toString();currentObjectIdSelect.options[currentObjectIdSelect.options.length] = new Option(name, id);}// Hook to its change eventcurrentObjectIdSelect.addEventListener("change", () => {// Get the object IDconst id: 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;}else {viewer.defaultInteractiveMode = automationInteractiveMode;}});// When the current object ID changes, we need to update our selectmanager.add_currentObjectIdChanged((sender, e) => {const currentObjectId: number = manager.currentObjectId;for (let i = 0; i < currentObjectIdSelect.options.length; i++) {const id: 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)const automation: lt.Annotations.Automation.AnnAutomation = new lt.Annotations.Automation.AnnAutomation(manager, imageViewerAutomationControl);this._automation = automation;// Add handler to update the container size when the image size changesviewer.itemChanged.add((sender, e) => {const container: lt.Annotations.Engine.AnnContainer = automation.container;container.size = container.mapper.sizeToContainerCoordinates(viewer.imageSize);//Create new canvas data provider for the new imageconst canvasDataProvider: lt.Demos.Annotations.CanvasDataProvider = new lt.Demos.Annotations.CanvasDataProvider(viewer.activeItem.canvas);imageViewerAutomationControl.automationDataProvider = canvasDataProvider;});// set up this automation as the active onethis._automation.active = true;const exampleButton = document.getElementById("exampleButton");exampleButton.onclick = () => {if(callback)callback(this._automation, this._viewer);}}}
import { EngineHelper } from "../../utilities/EngineHelper";export class AnnObject_AnnLineEnding {constructor() {const helper = new EngineHelper();helper.run(this.create);}create = (automation) => {// assumes _automation is validconst inch = 720.0;// Create polyline object and add it the automation containerlet polyLine = new lt.Annotations.Engine.AnnPolylineObject();polyLine.points.add(lt.LeadPointD.create(1 * inch, 1 * inch));polyLine.points.add(lt.LeadPointD.create(2 * inch, 1 * inch));automation.container.children.add(polyLine);// Create arrow line ending style and set some propertiesconst arrowStyle = new lt.Annotations.Engine.AnnArrowLineEnding();arrowStyle.closed = true;arrowStyle.reversed = true;arrowStyle.fill = lt.Annotations.Engine.AnnSolidColorBrush.create("Yellow");// Set the created arrow style to polyline start and end stylepolyLine.startStyle = arrowStyle;polyLine.endStyle = arrowStyle;// Create another polyline object and add it the automation containerpolyLine = new lt.Annotations.Engine.AnnPolylineObject();polyLine.points.add(lt.LeadPointD.create(1 * inch, 1.2 * inch));polyLine.points.add(lt.LeadPointD.create(2 * inch, 1.2 * inch));automation.container.children.add(polyLine);// Create butt line ending styleconst buttStyle = new lt.Annotations.Engine.AnnButtLineEnding();// Set the created butt style to polyline start and end stylepolyLine.startStyle = buttStyle;polyLine.endStyle = buttStyle;// Create another polyline object and add it the automation containerpolyLine = new lt.Annotations.Engine.AnnPolylineObject();polyLine.points.add(lt.LeadPointD.create(1 * inch, 1.4 * inch));polyLine.points.add(lt.LeadPointD.create(2 * inch, 1.4 * inch));automation.container.children.add(polyLine);// Create slash line ending styleconst slashStyle = new lt.Annotations.Engine.AnnSlashLineEnding();// Set the created slash style to polyline start and end stylepolyLine.startStyle = slashStyle;polyLine.endStyle = slashStyle;// Create another polyline object and add it the automation containerpolyLine = new lt.Annotations.Engine.AnnPolylineObject();polyLine.points.add(lt.LeadPointD.create(1 * inch, 1.6 * inch));polyLine.points.add(lt.LeadPointD.create(2 * inch, 1.6 * inch));automation.container.children.add(polyLine);// Create square line ending stylevar squareStyle = new lt.Annotations.Engine.AnnSquareLineEnding();// Set the created square style to polyline start and end stylepolyLine.startStyle = squareStyle;polyLine.endStyle = squareStyle;// Create another polyline object and add it the automation containerpolyLine = new lt.Annotations.Engine.AnnPolylineObject();polyLine.points.add(lt.LeadPointD.create(1 * inch, 1.8 * inch));polyLine.points.add(lt.LeadPointD.create(2 * inch, 1.8 * inch));automation.container.children.add(polyLine);// Create diamond line ending styleconst diamondStyle = new lt.Annotations.Engine.AnnDiamondLineEnding();// Set the created diamond style to polyline start and end stylepolyLine.startStyle = diamondStyle;polyLine.endStyle = diamondStyle;// Create another polyline object and add it the automation containerpolyLine = new lt.Annotations.Engine.AnnPolylineObject();polyLine.points.add(lt.LeadPointD.create(1 * inch, 2 * inch));polyLine.points.add(lt.LeadPointD.create(2 * inch, 2 * inch));automation.container.children.add(polyLine);// Create round line ending styleconst roundStyle = new lt.Annotations.Engine.AnnRoundLineEnding();// Set the created round style to polyline start and end stylepolyLine.startStyle = roundStyle;polyLine.endStyle = roundStyle;// Repaint to see the objectsautomation.invalidate(lt.LeadRectD.empty);}}
export class EngineHelper {// Automation object_automation = null;// Image viewer_viewer = null;constructor() {// Set the LEADTOOLS license. Replace this with your actual license filelt.RasterSupport.setLicenseUri("https://demo.leadtools.com/licenses/v200/LEADTOOLSEVAL.txt", "EVAL", null);}run(callback) {// Create the viewerconst imageViewerDiv = document.getElementById("imageViewerDiv");const createOptions = new lt.Controls.ImageViewerCreateOptions(imageViewerDiv);const viewer = new lt.Controls.ImageViewer(createOptions);viewer.autoCreateCanvas = true;this._viewer = viewer;// PanZoom interactive modeconst panZoom = new lt.Controls.ImageViewerPanZoomInteractiveMode();// Create an instance of the Automation control object that works with LEADTOOLS ImageViewerconst imageViewerAutomationControl = new lt.Demos.Annotations.ImageViewerAutomationControl();// Attach our image viewerimageViewerAutomationControl.imageViewer = viewer;// Set the image viewer interactive modeconst automationInteractiveMode = new lt.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 engineconst renderingEngine = new lt.Annotations.Rendering.AnnHtml5RenderingEngine();const manager = lt.Annotations.Automation.AnnAutomationManager.create(renderingEngine);// Create default automation objectsmanager.createDefaultObjects();// Add the objects to the objects select elementconst currentObjectIdSelect = document.getElementById("currentObjectIdSelect");// Add the PanZoom optioncurrentObjectIdSelect.options[currentObjectIdSelect.options.length] = new Option("Pan/Zoom", lt.Annotations.Engine.AnnObject.none.toString());const automationObjCount = manager.objects.count;for (let i = 0; i < automationObjCount; i++) {// Get the objectconst automationObj = manager.objects.item(i);// Add its name to the select elementconst name = automationObj.name;const id = automationObj.id.toString();currentObjectIdSelect.options[currentObjectIdSelect.options.length] = new Option(name, id);}// Hook to its change eventcurrentObjectIdSelect.addEventListener("change", () => {// Get the object IDconst id = 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;}else {viewer.defaultInteractiveMode = automationInteractiveMode;}});// When the current object ID changes, we need to update our selectmanager.add_currentObjectIdChanged((sender, e) => {const currentObjectId = manager.currentObjectId;for (let i = 0; i < currentObjectIdSelect.options.length; i++) {const id = 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)const automation = new lt.Annotations.Automation.AnnAutomation(manager, imageViewerAutomationControl);this._automation = automation;// Add handler to update the container size when the image size changesviewer.itemChanged.add((sender, e) => {const container = automation.container;container.size = container.mapper.sizeToContainerCoordinates(viewer.imageSize);//Create new canvas data provider for the new imageconst canvasDataProvider = new lt.Demos.Annotations.CanvasDataProvider(viewer.activeItem.canvas);imageViewerAutomationControl.automationDataProvider = canvasDataProvider;});// set up this automation as the active onethis._automation.active = true;const exampleButton = document.getElementById("exampleButton");exampleButton.onclick = () => {if(callback)callback(this._automation, this._viewer);}}}
<!doctype html><html lang="en"><title>AnnObject Example | AnnLineEnding</title><head><script src="https://code.jquery.com/jquery-2.2.4.min.js"integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script><script src="../LT/Leadtools.js"></script><script src="../LT/Leadtools.Controls.js"></script><script src="../LT/Leadtools.Annotations.Engine.js"></script><script src="../LT/Leadtools.Annotations.Designers.js"></script><script src="../LT/Leadtools.Annotations.Rendering.Javascript.js"></script><script src="../LT/Leadtools.Annotations.Automation.js"></script><script src="../LT/Leadtools.Annotations.BatesStamp.js"></script><script src="../LT/Leadtools.Demos.js"></script><script src="../LT/Leadtools.Demos.Annotations.js"></script><style>#imageViewerDiv {border: 1px solid #000000;width: 800px;height: 800px;background-color: #7F7F7F;}</style><!-- All demo files are bundled and appended to the window --><script src="../../bundle.js" type="text/javascript"></script></head><body><p>Either Pan/Zoom or Annotations mode. In annotations mode, draw new objects or edit them.</p><div><select id="currentObjectIdSelect"></select></div><div><input type="button" id="exampleButton" value="Example" /><label id="exampleLabel" /></div><div id="imageViewerDiv" /></body><script>window.onload = () => new window.examples.AnnObject.AnnLineEnding();</script></html>
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
