Understanding the Data Types and Declarations

<< Click to Display Table of Contents >>

Navigation:  How To Use the VPE Control > VPE Java Control >

Understanding the Data Types and Declarations

Previous pageReturn to chapter overviewNext page

Because the properties and methods of the VPE Control (for .NET, Java, PHP, Python, Ruby, ActiveX and Delphi / C++ Builder VCL) are nearly 100% the same, we explain the API of the VPE control for all the different programming languages within this single book. We use a meta-description to describe the data types, properties, methods and parameters of the VPE API.

Here is how the meta-description is converted to Java:

Throughout this manual, methods and parameters are always declared in the form as it is done in Java. Only some data types are named differently.

 

Data Types:

VpeCoord is double

boolean is boolean

integer is int

long is long

string is String

Color is java.awt.Color

 

In addition there are defined many enumerations as data types for properties as well as for parameters of methods:

e.g. property PenStyle [integer] PenStyle
declares a property which has the enumeration type "PenStyle" and which is named "PenStyle".
Data types in square-brackets, like "[integer]" in the example above, are not of interest for Java users. They describe the data type for the ActiveX and VCL controls.

Example on using the above property: Doc.PenStyle = PenStyle.Solid

i.e. the property named PenStyle is assigned the value Solid of a pre-defined enumeration, which has the type PenStyle.

 

Methods:

The keyword method declares a method, e.g. method void CloseProgressBar().

Or method boolean WriteDoc(string FileName)

Please note that for methods, according to the Java naming conventions, the first letter is always lower-case. So for Java, void CloseProgressBar() translates into void closeProgressBar().

 

Properties:

The keyword property describes a property. In many programming languages a property is accessed like a class member variable, e.g. you can write Vpe.AutoDelete = true. But when this code is executed, in fact a setter-method is called behind the scenes, i.e. Vpe.setAutoDelete(true). The same applies to reading the value of a property, behind the scenes a getter-method is called, e.g. for code like status = Vpe.AutoDelete the following getter is called: status = Vpe.getAutoDelete().

Unfortunately, Java does not provide this elegant coding technique. Instead of properties, it does only provide getter- and setter-methods.

So when you encounter the keyword property in this manual, you need to translate it into getter- and setter-methods. The line below the declaration of the property specifies, how the property can be accessed. Each property is marked for read only (only a getter is present), write only (only a setter is present) or read / write (a getter and a setter is present).

It is also indicated, if the property can be accessed during runtime only, or also during design time. “Design Time” means: when the document is closed and “runtime” means: when the document is open, i.e. the method Vpe.openDoc() has been called. The term “Design Time” relates to programming tools with visual designers, where properties of graphical components can be modified by point-and-click during the design time of an application, for example with a Property Grid.

 

Example:

property boolean PageScrollerTracking

read / write; design- & runtime

means: the property is of type boolean, its name is PageScrollerTracking and it can be accessed for read (a getter is present) and for write (a setter is present) and it is available during runtime (when the document is open) and design time (when the document is closed).

For Java, this translates into the following getter and setter methods:

boolean getPageScrollerTracking ()

void setPageScrollerTracking (boolean value)

 

If the first letter of a property is lower-case, it must be converted to upper-case for getters and setters.

property VpeCoord nLeft

Translates into the following getter and setter methods:

double getNLeft ()

void setNLeft (double value)

 

The following members of the class VpeControl can be used as coordinates, if they are used read-only:

 public static final double nFree = -2147483549;

 public static final double nLeft = -2147483550;

 public static final double nRight = -2147483551;

 public static final double nLeftMargin = -2147483552;

 public static final double nRightMargin = -2147483553;

 public static final double nTop = -2147483554;

 public static final double nBottom = -2147483555;

 public static final double nTopMargin = -2147483556;

 public static final double nBottomMargin = -2147483557;

Example:

 doc.picture(1, 1, doc.nFree, doc.nFree, “sample.png”);