Styling > Customizing User-Defined Business Objects > Customizing User-Defined Network Links

User-defined business objects can also be represented as links in the network and equipment components. All user-defined business classes that are links are rendered as a general link graphic object when they implement IlpObject directly, that is, when they do not extend a predefined business link class. The graphic representation is illustrated in the following figure:

images/GeneralLinkb.gif

Figure 4.4 A User-Defined Network Link

Refer to <installdir>/samples/network/customClasses for an example of how to customize user-defined business objects in the network component.

Customizing the Link

You can customize a network link using the following properties:

Table 4.6 CSS Properties for Network Links
Property Name 
Type 
Default Value 
Description 
alternateColor 
Color 
null 
Sets the alternate color. 
animateSpeed 
float 
0 
Sets the animate speed. 
arrowColor 
Color 
Color.black 
Sets the arrow color. 
arrowMode 
int 
ARROW_FILL 
Sets the arrow-drawing style. The possible values are: 
ARROW_FILL 
ARROW_OPEN 
ARROW_GRADIENT 
ARROW_DECOERRATION 
arrowPosition 
float 
1f 
Sets the position of the arrow as the ratio of the link length. For example, 0.5f is the middle of the link. 
arrowRatio 
float 
1f 
Sets the size of the arrow proportionately to the length of the link.  
borderColor 
Color 
null 
Sets the border color. 
borderColor2 
Color 
null 
Sets the lower border color. 
borderLineStyle 
float[] 
null 
Sets the array that represents the lengths of the dash segments for the border. The possible values are:  
Solid 
Dot 
Dash 
DashDot 
DashDoubleDot 
Alternate 
LongDash 
DoubleDot 
or an array that defines a new line style. 
borderLineStylePhase 
float 
0f 
Sets the dash pattern offset for the border. 
borderWidth 
float 
0f 
Sets the border width. 
curved 
float 
0f 
Sets the curved appearance and the smoothness of the spline. 
endCap 
int 
CAP_SQUARE 
Sets the decorations applied to the end of the polyline. The possible values are: 
CAP_BUTT 
CAP_ROUND 
CAP_SQUARE 
internalZoom 
float 
1f 
Sets the internal scale factor. 
lineJoin 
int 
JOIN_MITER 
Sets the decoration applied when two segments are joined. The possible values are: 
JOIN_BEVEL 
JOIN_MITER 
JOIN_ROUND 
lineStyle 
float[] 
null 
Sets the array that represents the lengths of the dash segments. The possible values are: 
Solid 
Dot 
Dash 
DashDot 
DashDoubleDot 
Alternate 
LongDash 
DoubleDot 
or an array that defines a new line style. 
lineStylePhase 
float 
0f 
Sets the dash pattern offset. 
lineWidth 
float 
5f 
Sets the line width. 
maxLineWidth 
float 
0 
Sets the maximum line width when zooming in. 
minLineWidth 
float 
0f 
Sets the minimum line width when zooming out. 
mode 
int 
MODE_GRADIENT 
Sets the link-drawing mode. The possible values are: 
MODE_TEXTURE 
MODE_UNICOLOR 
MODE_GRADIENT 
MODE_NEON 
Caution: Do not use the border with the mode ilog.views.sdm.graphic.IlvGeneralLink.MODE_NEON
oriented 
boolean 
false 
Sets the link as oriented or not oriented. 
qualityLevel 
int 
3 
Controls the quality of the rendering of the link. You can modify this property for faster interaction or high quality printing.  
The following values achieve the following effects respectively: 
0: The link is rendered as a single line only. 
1: MODE_UNICOLOR is forced, with no border, no wave effect, and a classic arrow. 
2: Gives the effect of 1 with a border. 
3: All, the default value. 
4: Very fine-gradient spectra. 
5: All BasicStroke with float value and no cache. 
wave 
String 
"0/0" 
Sets the wavy outline of the link. Use 0/0 to cancel the wave effect. The value is a formatted string that describes the wave. The format is a/p, where a is an int representing the amplitude of the wave in pixels and p is an int representing the period or length of the wave in pixels. 

How to Use Network Link Properties in a User-Defined Business Class
object."test.MyLink" {
    oriented: true;
    lineWidth: 5;
    lineStyle: "4,4,2";
    endCap: CAP_ROUND;
    wave: "1/2";
}

The following sections provide more information on the use of these properties:

Major Appearance Modes

The general link has three principal looks associated with the property mode. For the first two looks, the foreground property sets the main color.

images/generallinka.gif

Figure 4.5 Three Main Looks for Links

The properties of the first look shown in Figure 4.5 are composed as follows:

mode = MODE_UNICOLOR
lineWidth = 10
foreground = pink

The properties of the second look shown in Figure 4.5 are composed as follows:

mode = MODE_GRADIENT
lineWidth = 10
foreground = pink

The properties of the third look shown in Figure 4.5 are composed as follows:

mode = MODE_TEXTURE
lineWidth = 10
fillTexture = wood.png

The fillTexture property specifies the URL of an image file to use as a texture in TEXTURE mode. Note that the URL does not use the URL Access Service.

Adding a Border

A border is painted when the borderWidth property is greater than 0, the default value. The default border color is black. Two other properties control the line style (such as dashes).

images/generallink2a.gif

Figure 4.6 Rendering Links with Borders

The properties of the top link in Figure 4.6 are composed as follows:

lineWidth = 10
foreground = #90EE90
endCap = CAP_ROUND
borderWidth = 4
borderColor = red

The properties of the center link in Figure 4.6 are composed as follows:

lineWidth = 10
foreground = #90EE90
endCap = CAP_ROUND
borderWidth = 4
borderColor = gray
borderLineStyle = "10,5"

borderLineStyle is expressed as a float array.

The properties of the bottom link in Figure 4.6 are composed as follows:

lineWidth = 10
foreground = #90EE90
endCap = CAP_ROUND
borderWidth = 2

images/generallink3a.gif

Figure 4.7 Rendering Links with More Complex Borders

The properties of the top link in Figure 4.7 are composed as follows:

lineWidth = 10
mode = MODE_UNICOLOR
endCap = CAP_ROUND
lineJoin = JOIN_ROUND
borderWidth = 4
borderColor = white
borderColor2 = black
foreground = #FFAFAF

The properties of the center link in Figure 4.7 are composed as follows:

lineWidth = 10
mode = MODE_UNICOLOR
endCap = CAP_ROUND
lineJoin = JOIN_ROUND
borderWidth = 4
borderColor = white
borderColor2 = black
foreground = #FFC800
borderLineStyle = "10,10"

borderLineStyle is expressed as a float array.

The properties of the bottom link in Figure 4.7 are composed as follows:

lineWidth = 10
mode = MODE_UNICOLOR
endCap = IlvStroke.CAP_ROUND
lineJoin = IlvStroke.JOIN_ROUND
borderWidth = 4
borderColor = yellow
borderColor2 = blue
foreground = #1EC830

Experimenting with Stroke

The default stroke parameters are JOIN_MITER and CAP_SQUARE. You can change the end cap and join style, as shown in Figure 4.8, with the following values.

images/generallink4a.gif

Figure 4.8 Different Values for Stroke Parameters

The properties of the top link in Figure 4.8 are composed as follows:

lineWidth = 10
endCap = IlvStroke.CAP_ROUND
lineJoin = IlvStroke.JOIN_ROUND
borderWidth = 2
foreground = #9A9AFF

The properties of the center link in Figure 4.8 are composed as follows:

lineWidth = 10
endCap = CAP_BUTT
lineJoin = JOIN_MITER
borderWidth = 2
foreground = #9A9AFF

The properties of the bottom link in Figure 4.8 are composed as follows:

lineWidth = 10
endCap = CAP_SQUARE
lineJoin = JOIN_BEVEL
borderWidth = 2
foreground = #9A9AFF

Curves

The curved property uses the link points to feed a Bezier function which renders a curved link. Intermediate points show the path for the Bezier computation. With two points, a standard deviation applies, that is, at 1/4 before the end of the link. The curved value is a float between 0f and 1f. A value of 0 means no curve at all (the default), and a value of 1 means the sharpest curve. Use a value of 0.65f for an attractive curve.

images/generallink5.gif

Figure 4.9 Curved Links

The properties of the top link in Figure 4.9 are composed as follows:

lineWidth = 10
endCap = CAP_ROUND
lineJoin = JOIN_ROUND
borderWidth = 2
foreground = #FFDAB9
curved = 0.65
mode = MODE_UNICOLOR

The properties of the center link in Figure 4.9 are composed as follows:

lineWidth = 10
endCap = CAP_SQUARE
lineJoin = JOIN_ROUND
borderWidth = 2
foreground = #FFDAB9
curved = 0.65
lineStyle = [10,20]

lineStyle is expressed as a float array.

The properties of the bottom link in Figure 4.9 are composed as follows:

lineWidth = 10
endCap = CAP_SQUARE
lineJoin = JOIN_BEVEL
borderWidth = 6
foreground = #FFDAB9
curved = 0.65
borderLineStyle = [1,10]

borderLineStyle is expressed as a float array.

Dashes

Dashes provide interesting effects together with endCap values. Dashes are controlled by the lineStyle property. They are expressed as a float array. Alternate entries in the array represent lengths of the opaque and transparent segments of the dashes.

Note that the dash specification also applies to the border unless the borderLineStyle property overrides it.

images/generallink6.gif

Figure 4.10 Links with Dashed Line Style

The properties of the top link in Figure 4.10 are composed as follows:

lineWidth = 10
endCap = CAP_ROUND
lineJoin = JOIN_ROUND
borderWidth = 2
foreground = #55BEF3
lineStyle = [1,15]

The properties of the center link in Figure 4.10 are composed as follows:

lineWidth = 10
endCap = CAP_ROUND
lineJoin = JOIN_ROUND
borderWidth = 2
foreground = #FFC800
lineStyle = [10,8,20,8]

The properties of the bottom link in Figure 4.10 are composed as follows:

lineWidth = 10
endCap = CAP_BUTT
lineJoin = JOIN_ROUND
borderWidth = 2
foreground = red
mode = MODE_UNICOLOR
lineStyle = [4,4]
curved = 0.65

Alternate Colors

The alternateColor property toggles the link in alternate mode with the specified color. The segment size equals the thickness of the link. Otherwise, the segment size can be specified with the lineStyle property.

The lineStylePhase property sets the initial offset. If no lineStyle is specified, the phase is proportional to twice the line width. In Figure 4.11, the bottom link starts the alternate color one segment later than the top one.

images/generallink7.gif

Figure 4.11 Links with Alternate Colors

The appropriate values for the links are as follows.

The properties of the top link in Figure 4.11 are composed as follows:

lineWidth = 10
endCap = CAP_BUTT
lineJoin = JOIN_ROUND
borderWidth = 2
foreground = yellow
alternateColor = darkGray
curved = 0.65

The properties of the center link in Figure 4.11 are composed as follows:

lineWidth = 10
endCap = CAP_BUTT
lineJoin = JOIN_ROUND
borderWidth = 2
foreground = yellow
alternateColor = darkGray
curved = 0.65
lineStyle = [4,3]

lineStyle is expressed as a float array.

The properties of the bottom link in Figure 4.11 are composed as follows:

lineWidth = 10
endCap = CAP_BUTT
lineJoin = JOIN_ROUND
borderWidth = 2
foreground = yellow
alternateColor = darkGray
curved = 0.65
lineStylePhase = 1
mode = MODE_UNICOLOR

Arrows

There are four modes for representing an arrow controlled by the arrowMode property.

Drawing an Arrow

In the first two modes, the arrowPosition property controls the position of the arrow along the link. Its value is a float between 0 and 1. A value of 0 means the start of the link. A value of 1 means the end of the link (the default). The arrow direction is aligned with the link segment below it.

The property arrowRatio controls the size of the arrow, which is proportional to the width of the link. A float value of 0.5 means the arrow is the same size as the link. The default value 1 means the arrow is twice as wide as the link. This property applies to all four arrow modes.

The default color of an arrow is black. The color can be set by the property arrowColor.

images/generallink9.gif

Figure 4.12 Links with Arrows

The properties of the top link in Figure 4.12 are composed as follows:

lineWidth = 10
endCap = CAP_BUTT
lineJoin = JOIN_ROUND
borderWidth = 2
foreground = #FF82AB
arrowMode = ARROW_GRADIENT
oriented = true

The properties of the center link in Figure 4.12 are composed as follows:

lineWidth = 10
endCap = CAP_BUTT
lineJoin = JOIN_ROUND
borderWidth = 2
foreground = #FF82AB
arrowMode = ARROW_GRADIENT
oriented = true
mode = MODE_UNICOLOR
arrowMode = ARROW_FILL

The properties of the bottom link in Figure 4.12 are composed as follows:

lineWidth = 10
endCap = CAP_BUTT
lineJoin = JOIN_ROUND
borderWidth = 2
foreground = #FF82AB
arrowMode = ARROW_OPEN
oriented = true
arrowColor = #A3056E
arrowPosition = 0.2

Waves

A wave effect is very effective for representing a wireless connection. The wave specification consists of two numbers in pixels representing the wave amplitude and its period. The property type is String, where two integers separated by a forward slash or solidus (/) represent the amplitude and period respectively. The effect is rendered best with straight lines, but remains compatible with any shape.

The wave effect can also be combined with dashes, border, arrow, and so on.

images/generallink10.gif

Figure 4.13 Link with Wave Effect

The properties of the link in Figure 4.13 are composed as follows:

lineWidth = 10
endCap = CAP_ROUND
lineJoin = JOIN_ROUND
borderWidth = 2
foreground = #EEAEEE
wave = 20/30

Animation

A link with dashes (see the lineStyle property) or alternate colors (see the alternateColor property) can be animated. The animation consists of incrementing the lineStylePhase value at regular intervals, so that the dash pattern is shifted at each animation frame. The current implementation updates every 500 ms.

The animateSpeed property controls animation of the link and how much the phase is incremented. If the value is 0, the animation is stopped. Otherwise, the value must be between 0f and 1f and represents a fraction of the dash pattern length. For example, 0.1 means that ten frames elapse before seeing the first frame again. Note that 0.9 represents the same increment but in the reverse direction.

Zoom

The maxLineWidth property sets the maximum width of the line. The link is zoomable only if one edge node is zoomable. Note that the link border cannot be zoomed.

The minLineWidth property sets the minimum width of the line.

Other Effects

MODE_NEON is a minor mode that is a variation of MODE_GRADIENT. It displays the link with transparent colors, giving a glowing effect. (This effect works best with larger links and with darker backgrounds.) The border is automatically disabled in this mode. Neon mode could be used to mark link selection, for example.

The preceding figures show some of the diversity offered in the appearance of links. By combining some of the properties, you can obtain some special effects, such as the road link in Figure 4.14, where the large border is the same gray color as the link foreground and the white value of the alternateColor property looks like the center line of a road.

images/generallink11.gif

Figure 4.14 Links with Other and Special Effects

The style of the top link in Figure 4.14 is composed as follows:

lineWidth = 20
endCap = CAP_ROUND
lineJoin = JOIN_ROUND
foreground = #FFB5C5
mode = MODE_NEON

The properties of the center link in Figure 4.14 are composed as follows:

lineWidth = 10
endCap = CAP_ROUND
lineJoin = JOIN_ROUND
foreground = #FFB5C5

The properties of the bottom link in Figure 4.14 are composed as follows:

lineWidth = 15
endCap = CAP_BUTT
lineJoin = JOIN_ROUND
borderWidth = 12
foreground = #404040
borderColor = #404040
alternateColor = white
curved = 0.65
mode = MODE_UNICOLOR
LineStyle = [20,10]

lineStyle is expressed as a float array.

Customizing the Link Label

The label decoration is customized using the same properties as for the predefined business objects.

How to Use Label Properties in a User-Defined Business Class
object."test.MyNetworkElement" {
  labelBackground: white;
  labelForeground: blue;
  labelPosition: Right;
  label: @name;
  labelVisible: true;
}

Refer to Customizing the Label of Business Objects for a complete list of the available properties.