EqapColorient (version 1.1, 26.01.2006)

The EqapColorient is a part of EqapPackage and is a visual component designed to manage a gradient color scheme and apply this scheme for different purposes. For example, there are numerical values that represent parabolic curve as function of value index. The component EqapColorient can be used to obtain an array of colors which are corresponding to the numerical array - the higher a numerical value the higher the corresponding color.


1. Appearance

The EqapColorient component (Fig. 1) is a gradient color scheme area (a) which contains sliders (b) used to modify the current color scheme.

Fig. 1. EqapColorient component

Each slider has specified color and position within a color scheme. To move a slider click and hold left mouse on the slider and move it to the desired position. To add a new slider click right mouse anywhere away from the existing sliders and choose "Add" from the popup menu (see Fig. 1). To delete existing slider click right mouse on the slider and choose "Delete" from the popup menu. To set the slider color click right mouse on the slider and choose "Set color" from popup menu.


2. Properties and events

The EqapColorBox inherits properties and events of TPanel except all of those used for visual drawing and text appearance (Alignment, AutoSize, BevelInner, BevelOuter, BorderStyle, Caption, Font etc.), and has own properties and events:

Properties

ColorPoints: TColorPoints - the set of color points (sliders). Each color point has Color (TColor) and Position (integer) properties. The Position value must be between "0" and "100".

Orientation: TEqapColorientOrientation - the orientation of gradient drawing. The possible values are ecoHorizontal (sliders are drawn vertically and can be moved from left to right) and ecoVertical (slider are drawn horizontally and can be moved from top to bottom). The default value is "ecoHorizontal".

Palette: TEqapColorientPalette - the current color scheme (or palette) which depends on the set of color points. The possible values are: ectpBlackWhite (gray-scaled gradient is used, black and white color points are predefined), ectpCustom (arbitrary set of color points) and ectpRainbow (rainbow gradient is used, 8 color points with rainbow colors are predefined). When ectpBlackWhite or ectpRainbow is selected, all the existing color points will be destroyed and predefined color points are used with the parameters that appropriate for the color scheme. The default value is "ectpCustom".

SliderSize: integer - the size of sliders (width when Orientation property is set to ecoHorizontal or height if Orientation property is set to ecoVertical). Should be between "2" and "20". The default value is "3".

Events

OnAddColorPoint: TNotifyEvent - event arises when a new color point is added.

OnDeleteColorPoint: TNotifyEvent - event arises when an existing color point is deleted.

OnSetColorPoint: TNotifyEvent - event arises when a new color is set for existing point.

OnSliding: TNotifyEvent - event arises when any slider is moved.


3. Procedures and functions

The following public-declared procedures and functions are registered for the EqapColorient component:

procedure AddColorPoint(Color: TColor; Position: integer): adds a new color point with the Color to the Position.

procedure ClearColorPoints: deletes all existing color points.

procedure DeleteColorPoint(Index: integer): deletes an Index-th point.

procedure GetColors(ValueArray: TDoubleArray; var Colors: TColorArray): gets the array of Colors (array of TColor) which correspond to the ValueArray (array of double) (calculation is on the basis of current gradient color scheme).

procedure GetColorsA(Colors: TColorArray; Positions: TIntegerArray; ValueArray: TDoubleArray; var NewColors: TColorArray): gets the array of NewColors (array of TColor), which correspond to the ValueArray (array of double) (calculation is on the basis of arbitrary Colors and Positions values).

function GetHighestPosition: integer: gets maximal position within existing color points.

function GetLowestPosition: integer: gets minimal position within existing color points.

function GetHighestPositionIndex: integer: gets an index of color point that has maximal position.

function GetLowestPositionIndex: integer: gets an index of color point that has minimal position.


4. The example of using

The program code with an example of use of EqapColorient is downloadable here. This example illustrates how you can change color of each point in a series of TChart when OnSliding event of EqapColorient is occurred.

Figure 2 illustrates the form with RadioGroup1, Chart1 and EqapColorient1 components. RadioGroup1 has two values used to select the black-and-white or rainbow palette of EqapColorient1. Add TPointSeries to the Chart1 in Design-time mode and enable 3D view of Chart1. In the program code you have to declare a global variable Values (TDoubleArray); to do this you should also include EqapCommon unit, the part of EqapPackage. On the form creation (OnCreate event) the Values is filled with numerical values; these values are used to fill the series on Chart1. The OnSliding event of EqapColorient1 is also assigned in such a way, which makes possible to change color of series points by moving the sliders of EqapColorient1.

Fig. 2. The example of using EqapColorient


All the software products are free for use. Any commercial using is not permitted without author's permission (o.lookin@iip.uran.ru).

 

Hosted by uCoz