Many annotation objects utilize one or more rulers as part of the annotation.
The IAnnRulerObject interface provides a set of properties that are common to rulers and are utilized by any class of annotation object that utilizes rulers. This interface is implemented by several of the Annotation Object classes provided by LEADTOOLS. These include:
Each of these classes (either through the direct implementation of IAnnRulerObject or inheritance from the AnnRulerObject class which implements the IAnnRulerObject interface) accesses properties that control what aspects of the ruler are displayed and the unit of measure of the ruler. The MeasurementUnit property contains a value that indicates the unit of measure for the ruler. For each possible value of the MeasurementUnit property there is a corresponding abbreviation for the unit of measure. This abbreviation is given in the UnitAbbreviation property.
At each end of the ruler is a perpendicular line called a gauge. The length of the gauge is set or obtained through the GaugeLength property. The ShowGauge property indicates whether the gauges are displayed when the ruler is drawn. To display the gauges, set the ShowGauge property to true.
Along the length of the ruler are tick marks. The length of these tick marks can be set using the TickMarksLength property. To display the tick marks when the ruler is displayed, set the ShowTickMarks property to true. To display the length of the entire ruler, set the ShowLength property to true. The precision of the value displayed as the length of the ruler can be set using the Precision property. This property contains a value that indicates how many digits to display to the right of the decimal point in the length.
In the automation mode, it is possible to calibrate a ruler so it displays a specific length. For more information, refer to Calibrating Ruler Annotation Objects.Annotation objects from the above-mentioned classes also access the RulerImplemented property. This is a read-only property that is used internally. The toolkit checks this property to make sure it is true and uses this information to determine which tabs the toolkit should include when displaying property dialogs in automation mode.
If the user creates a custom annotation object by deriving a new class from the AnnObject class and includes a ruler in this new class, the user should implement the RulerImplemented property to always return "true".
For an example of user-defined annotation classes, refer to Implement User-Defined Objects with LEADTOOLS Annotations.
AnnRulerObject:
The AnnRulerObject class implements the IAnnRulerObject interface and accesses the common ruler properties mentioned above through this implementation. In addition, this class also inherits numerous properties and methods from the Object, AnnObject, AnnDrawable and AnnLineObject classes. The AnnRulerObject class expands on these inherited classes with several properties and methods. The Clone method makes an exact copy of the AnnRulerObject class object that calls it, while the Create method just creates a new AnnRulerObject class object. The GetObjectData method gets information required to serialize the annotation object. The HitTestInterior property is a read only property that indicates whether hit testing should be performed inside the annotation object. The bounding rectangle for a ruler object can be found in the BoundingRectangle property. This bounding rectangle contains the ruler itself, the gauge, the tick marks, and the units of measure, if visible. The GetGraphicsPath method returns a GraphicsPath representation of the ruler annotation object, and the DrawObject method draws the AnnRulerObject object to a specific surface.
Annotation objects can be transformed by applying any object transformation method. The GetTransformPoints method gets the array of points associated with the object that will be transformed. The TransformObjectMode property contains a value that indicates how the transformation method is applied. After the transformation method is applied, the transformed points can be set in the ruler object by calling the SetTransformPoints method.
AnnCrossProductObject:
The AnnCrossProduct Object class also implements the IAnnRulerObject interface and accesses the common ruler properties mentioned above through this implementation. In addition, this class also inherits numerous properties and methods from the Object, AnnObject, and AnnDrawable classes. The AnnCrossProductObject class expands on these inherited classes with several properties and methods.
The cross-product annotation object consists of two rulers intersecting at right angles. These two rulers are defined by the FirstStartPoint and FirstEndPoint properties for the first ruler and the SecondStartPoint and SecondEndPoint properties for the second ruler. The intersection point of these two rulers updates dynamically and can be obtained through the IntersectionPoint property . The bounding rectangle for a cross-product object can be found in the BoundingRectangle property. This bounding rectangle contains the 2 rulers, the gauge, tick marks, and the unit of measure, if visible.
The Clone method makes an exact copy of the AnnCrossProductObject class object that calls it, while the Create method just creates a new AnnCrossProductObject class object. The GetObjectData method gets information required to serialize the annotation object. The HitTestInterior property is a read only property that indicates whether hit testing should be performed inside the annotation object and the HitTest method actually performs the hit testing. The GetGraphicsPath method returns a GraphicsPath representation of the ruler annotation object, and the DrawObject method draws the AnnCrossProductObject object to a specific surface.
Annotation objects can be transformed by applying any object transformation method. The GetTransformPoints method gets the array of points associated with the object that will be transformed. The TransformObjectMode property contains a value that indicates how the transformation method is applied. After the transformation method is applied, the cross product object can have the transformed points set by calling the SetTransformPoints method.
AnnPolyRulerObject:
The AnnPolyRulerObject class also implements the IAnnRulerObject interface and accesses the common ruler properties mentioned above through this implementation. In addition, this class also inherits numerous properties and methods from the Object, AnnObject, AnnPolylineObject, and AnnDrawable classes. The AnnPolyRulerObject class expands on these inherited classes with several properties and methods.
The polyruler annotation object consists of an array of points that creates a sequence of joined rulers. This array of points is contained in the Points property, which is inherited from the AnnPolylineObject. The bounding rectangle for a polyruler object can be found in the BoundingRectangle property. This bounding rectangle contains all of the rulers, the gauges, tick marks, and the unit of measure, if visible.
The Clone method makes an exact copy of the AnnPolyRulerObject class object that calls it, while the Create method just creates a new AnnPolyRulerObject class object. The GetObjectData method gets information required to serialize the annotation object. The HitTestInterior property is a read only property that indicates whether hit testing should be performed inside the annotation object. The GetGraphicsPath method returns a GraphicsPath representation of the polyruler annotation object, and the DrawObject method draws the AnnPolyRulerObject object to a specific surface.
Annotation objects can be transformed by applying any object transformation method. The GetTransformPoints method gets the array of points associated with the object that will be transformed. The TransformObjectMode property contains a value that indicates how the transformation method is applied. After the transformation method is applied, the polyruler object can have the transformed points set by calling the SetTransformPoints method.
Like the AnnRulerObject class and the other classes mentioned in this section, the AnnGroupObject class implements the IAnnRulerObject interface. In addition, the AnnProtractorObject class also implements the IAnnRulerObject interface. For more information on the AnnProtractorObject class, refer to Using Protractors in Annotation Objects.