CyDAS General Controls: Class ImageMapData

The class ImageMapData describes the data pertaining to an image map. Among them are the areas defined in the map, the image proper, and additional information for web use.

Overview


ImageMapData
New() 
Areas: ArrayList {readonly}
Bitmap: System.Drawing.Bitmap
DefaultOnclick: String
DefaultTarget: String
ImageBorder: Integer
ImageLocation: String
Name: String
Tag: Object
addArea(ByRef Area: ImageMapArea): Void
addAreas(ByRef Areas: ArrayList): Void
clone(): Object {implements IClonable.clone}
getMapHTML(): String
getSelectedArea(point: System.Drawing.Point): ImageMapArea
removeArea(ByRef area: ImageMapArea): Void
toHTML(): String
transformAreaCoordinates(addX: Integer, addY: Integer): Void

Programming Language

  • Microsoft Visual Basic .Net.

Availability

Constructors

Public Sub New()

Instantiates a new ImageMapData object.

Interfaces

ICloneable

is implemented with the clone function.

Enumerations

The class does not provide enumerations.

Properties

ReadOnly Property Areas As ArrayList

Gets an array list containing the ImageMapArea objects representing the distinct areas of the image map.

Property Value

  • an array list containing the ImageMapArea objects representing the distinct areas of the image map

Remarks

  • This property is read only. When you want to add or remove areas, use the addArea, addAreas and removeArea functions, resp.

Bitmap As System.Drawing.Bitmap

Gets or sets the image of the image map.

Property Value

  • the image of the image map.

Remarks

  • If the image is exchanged, the areas are not checked if they still reside inside the image.

ImageBorder As Integer

Gets or sets the thickness of the image border in web use.

Property Value

  • the thickness of the image border in web use.

Remarks

  • This property is intended for web use.
  • It is translated into the "border" element of the HTML "img" element.
  • The default value is 0, i.e. no border.

Examples

  • To set the border thickness to 1, do:

  • Dim oImageMap as ImageMapData
    oImageMap = New ImageMapData()
    oImageMap.ImageBorder = 1

ImageLocation As String

Gets or sets the URL of the image.

Property Value

  • the URL of the image.

Remarks

  • This property is intended for web use.
  • It is translated into the "src" element of the HTML "img" element.
  • The protocol type of the URL must be present.
  • For non-web use, the Bitmap property must be used instead.

Examples

  • If the image is located on a server at "http://www.mysite.com/img/map.gif", do:

  • Dim oImageMap as ImageMapData
    oImageMap = New ImageMapData()
    oImageMap.ImageLocation = "http://www.mysite.com/img/map.gif"

Name As String

Gets or sets the name of the image map.

Property Value

  • the name of the image map.

Remarks

  • This property is intended for web use.
  • It is translated into the "usemap" element of the HTML "img" element, and into the "name" element of the HTML "map" element.

Examples

  • To set the name of the image map to "MyImageMap", do:

  • Dim oImageMap as ImageMapData
    oImageMap = New ImageMapData()
    oImageMap.Name = "MyImageMap"

Tag As Object

Gets or sets an object associated with the image map.

Property Value

  • an object associated with the image map.

Remarks

  • This property is intended for non-web use.

DefaultTarget As String

Gets or sets the default value for the HTML target (name of the browser document window) the URL linked with an image map area is to be opened in.

Property Value

  • the default value for the HTML target for links associated with areas.

Remarks

  • This property is intended for web use.
  • It is passed through to the DefaultTarget property of the ImageMapArea elements. There, the DefaultTarget property is used if no Target property is available. It is translated into the  "target" element of an HTML link.
  • It does neither overwrite nor override the Target property of the ImageMapArea elements.

Examples

  • If links are to be opened in a new browser window by default, do:

  • Dim oImageMap as ImageMapData
    oImageMap = New ImageMapData()
    oImageMap.DefaultTarget = "_blank"

DefaultOnclick As String

Gets or sets the default value for the command to be executed by the browser (e.g. JavaScript) when an area of the image map is clicked.

Property Value

  • the default value for the command to be executed by the browser linked with the areas of the map.

Remarks

  • This property is intended for web use.
  • It is passed through to the DefaultOnClick property of the ImageMapArea elements. There, the DefaultOnClick property is used if no OnClick property is available. It is translated into the  "onclick" element of an HTML link.
  • It does neither overwrite nor override the OnClick property of the ImageMapArea elements.

Examples

  • If a script called "getLink" with the parameters "document" and "link" is to be executed by default before following the link, do:

  • Dim oImageMap as ImageMapData
    oImageMap = New ImageMapData()
    oImageMap.DefaultOnClick = "getLink(document,this)"

Methods

Public Sub addArea(ByRef Area As ImageMapArea)

Adds a reference to an ImageMapArea object to the image map.

Return Value

  • none

Parameters

  • Area: a reference to an ImageMapArea obeject.

Remarks

  • Before adding the area to the map, the DefaultOnClick and DefaultTarget properties are set to conform with the ImageMap's values.
  • The areas are not checked for exclusiveness. Overlapping regions are accepted.
  • The areas are not checked if they reside on the image. Areas outside the image are accepted.

Public Sub addAreas(ByRef Areas As ArrayList)

Adds references to ImageMapArea objects to the image map.

Return Value

  • none

Parameters

  • Areas: a reference to a list of ImageMapAreas which are to be added.

Remarks

  • Before adding an area to the map, the DefaultOnClick and DefaultTarget properties are set to conform with the ImageMap's values.
  • The areas are not checked for exclusiveness. Overlapping regions are accepted.
  • The areas are not checked if they reside on the image. Areas outside the image are accepted.

Public Function clone() As Object

Returns a deep copy of the image map. The copy contains copies of the objects of the image map, whith the exception of the Tag property whose reference is copied.

Return Value

  • a deep copy of the image map.

Parameters

  • none

Implements

Remarks

  • A deep copy is created. I.e. for all objects of the image map, clones are created. An exception is the Tag property which can not be cloned and therefore its reference is added.

Public Function getMapHTML() As String

Returns an HTML representation of the HTML "map" element of the image map. The "img" element is not included.

Return Value

  • an HTML representation of the HTML "map" element of the image map.

Parameters

  • none

Remarks

  • The "map" element contains the map description proper and the HTML representation of all area elements.
  • The "img" element of the image map is not included. To get a full HTML representation of the image map, use the toHTML() function.

Public Function getSelectedArea(ByVal point As System.Drawing.Point) As ImageMapArea

Returns an ImageMapArea which contains the point.

Return Value

  • an ImageMapArea which contains the point.
  • Nothing, if no ImageMap area contains the point.

Parameters

  • point: a point on the image.

Remarks

  • The areas of an image map are not checked for exclusiveness. If more than one area contains the point, the first area encountered is returned.

Public Sub removeArea(ByRef area As ImageMapArea)

Removes an area from the image map.

Return Value

  • none.

Parameters

  • area: a reference to the area to be removed from the map.

Public Function toHTML() As String

Returns an HTML representation of the whole image map, including both the "img" and the "map" elements.

Return Value

  • an HTML representation of the image map.

Parameters

  • none

Remarks

  • This function is intended for web use. Its return value may be added e.g. to the InnerHTML property of an HtmlGenericControl in an aspx page.

Public Sub transformAreaCoordinates(ByVal addX As Integer, ByVal addY As Integer)

Transforms the coordinates of the areas of the image map by adding the given values to the x and y coordinates of the points of the areas.

Return Value

  • none

Parameters

  • addX: the change of the x coordinate values.
  • addY: the change of the y coordinate values.

Remarks

  • There is no safeguard to prevent useless negative coordinates or coordinates outside the image.

Interaction with other classes

Classes using ImageMapData

The ImageMapData class is the central data component of the ImageMapControl where it stores all information on the image map.

Classes used by ImageMapData

An ImageMapData object contains many references to ImageMapArea objects representing the area elements of the map.