Implementing Annotations

Summary

Annotations are based on vector drawing functions and are associated with bitmaps as an overlay of the displayed image. LEADTOOLS supports a number of annotation types, including lines, rectangles, hotspots, redact objects, polygons, and containers. A container is a specialized annotation object that lets you position and group other annotation objects, including other container objects.

Support for the various annotation objects is provided by the various annotation object classes, which are named using the format AnnXXXXObject where XXXX is the type of object. For a full list of available annotation object classes, refer to Types Of Annotation Objects. LEADTOOLS maintains annotations separately from images. Your application code is responsible for maintaining the relationships between images and annotations. For example, The annotation example that ships with LEADTOOLS creates an Annotation file that has the same name as its associated image file, but uses a different extension. When the image file is loaded, the program looks for an associated annotation file and loads it as well.

Annotations can be saved using the AnnCodecs.Save method in any of the following formats:

  • AnnFormat.XML - a text-based format for storing LEAD annotations that follows the XML (Extensible Markup Language) format.

Non-automated Annotations

Non-automated annotations allow you to customize the creation of and interaction with annotations to suit your own needs. When programming non-automated annotations, it is important to remember:

  • You must provide any menus or dialogs you wish to use for entering annotation data.
  • You must also provide your own means of drawing and interacting with the annotations.
  • No hyperlink activation is provided for non-automated annotations. In addition to providing the code for entering hyperlink type and associated parameters, you must also provide the code for accessing the default web browser and calling any programs to be run through a hyperlink.

Automated Annotations

Automated annotations require an automation object to be associated with an ImageViewer. This automation object lets you maintain default properties for all objects. For example, you can use it to set the default font and the default line width. Keep in mind, however, that scaling factors affect the appearance of these default measurements. The values are set based on the scaling factors that are in effect at the time you create the object. Features associated with automated annotations are:

  • Automated annotation menus that appear when you right-click in design mode.
  • Automated drawing that lets you use mouse and touch-based gestures to draw annotations in design mode.
  • Programmatic hyperlink activation (by LEADTOOLS).
  • Undo/redo of a number of user actions executed using the automated annotations functions.

The user interface for the automated annotations has several options that allow you to control the behavior of the annotation objects. Such options include those that allow you to perform the following actions:

  • Use Rotate Control Points
  • Maintain Aspect Ratio

For more information, refer to Annotation Rotation Options.

Annotation Classes

The following paragraphs provide a brief introduction to the major classes that are used to implement support for annotations:

The AnnAutomationObject class defines all the properties needed to automate an Annotation object. You create an instance of this class and fill it up with the properties you want and then you add it to the Objects collection. At any time, enumerate the Objects collection and add, remove, or modify any properties you want. The CreateDefaultObjects method creates the default AnnAutomationObject objects for the default annotation objects. LEADTOOLS will create the automation properties for the default annotation objects. You can change any property behavior by overriding members of this class or deriving your own. Use the CreateDefaultObjects method to create the default automation annotation objects.

Use the FindObjectById method to find the AnnAutomationObject associated with a certain id.

The AnnAutomationManager class holds the collection of all AnnAutomation objects in the application as well the annotation toolbar. Cursor, keyboard, context-sensitive menus, property dialogs and various other user interface options and settings are stored here as well. An automated annotation application usually creates one AnnAutomationManager object per application.

When working with annotations, the background brush (the brush that fills the interior) of many objects can be changed by changing the object's "fill," and line characteristics can be changed by changing the object's "stroke." For more information, refer to Changing Annotation Automation Background Brushes. Support for annotation brushes/strokes is provided by the AnnBrush and its derived classes.

The AnnCodecs class handles loading and saving operations. The following methods let you load annotations from a file or save them to a file:

The AnnContainer class represents an annotation container, a rectangular area that holds annotation objects. The container is responsible for maintaining these objects as well as rendering them.

The AnnDesigner class is the base class for all the designers in the annotation toolkit. An AnnDesigner derived class controls the user interface involved in drawing, editing or running an object. This class provides the basic functionality common to all the designers such as hooking into a container, clipping the mouse cursor, etc. You assign an AnnContainer object to the Container member. Then, based on the exact designer functionality, it will hook into the various mouse events to draw a new, edit an existing (by moving, resizing, etc.) or run (if the container is in Run user mode) an AnnObject. The AnnDesigner classes provide properties and methods for editing annotation objects interactively.

The AnnObject class is the base class for all annotation objects used in the annotations class library. This class holds common drawing information shared by all annotation objects. You can query the properties of this class to easily determine whether a certain class supports stroke, fill or font and quickly change them.

Events

Use the following events to adapt your application:

Annotation Object Labels

Use annotation object labels to differentiate between multiple objects in a container or to control the various text elements that an annotation object displays. For more information, refer to Annotation Object Labels.

User Interface, Automation Mode

Grouping and Ungrouping

The following methods let you group or ungroup annotation objects:

For more information on grouping and ungrouping, refer to Grouping and Ungrouping Annotation Objects.

Undo

The LEADTOOLS annotation features include an undo engine for undoing annotation automation operations. The AnnAutomation.UndoCapacity property specifies the number of operations that can be undone. The default is 10 actions. LEADTOOLS provides a number of methods and properties for handling undo capabilities in non-automated operations. For more information, refer to Undoing Annotation Automation Operations.

User Modes

Use the UserMode property to get or set the current user mode. The AnnUserMode.Design mode is for creating objects; the AnnUserMode.Run mode is for viewing them. The UserModeChanged event is fired whenever the UserMode property is changed. The following properties and methods let you create and customize the interface used in automation mode:

Related Topics

Implementing User-Defined Thumb Styles With LEADTOOLS Annotations
Implementing User-Defined Objects With LEADTOOLS Annotations
Annotation Files
Annotation Rotation Option
Changing Annotation Automation Background Brushes
Fixed Annotations
Grouping and Ungrouping Annotation Objects
Implementing Annotation Security
Types of Annotation Objects
Undoing Annotation Automation Operations
Using Pictures in Annotation Objects
Using Protractors in Annotation Objects
Using Rulers in Annotation Objects
Using Text in Annotation Objects
Help Version 21.0.2021.7.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS HTML5 JavaScript
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.