CyDAS General Controls: Class ImageMapArea

The class ImageMapArea describes one area of an interactive map.

It corresponds to an HTML element like e.g. "<area shape="myshape" href="myHREF.html" coords="225,160,495,210" title="my title">", but provides further properties for use outside the web.

Overview


ImageMapArea
New() 
New(shape: Shapes, coords: Integer(), href: String)
New(shape: Shapes, coords: Integer(), href: String, command: String)
New(shape: Shapes, coords: Integer(), href: String, command: String, title: String)
New(shape: Shapes, coords: Integer(), href: String, command: String, title: String, alt: String)
New(shape: Shapes, coords: Integer(), href: String, command: String, title: String, alt: String, onclick: String)
New(shape: Shapes, coords: Integer(), href: String, command: String, title: String, alt: String, onclick: String, tag: Object)
Shape: Shapes
Coords: Integer()
HREF: String
Command: String
Title: String
AltText: String
OnClick: String
Tag: Object
Target: String
clone(): Object {Implements ICloneable.Clone}
containsPoint(point: System.Drawing.Point): Boolean
toHTML(): String
transformCoordinates(addX: Integer, addY: Integer): Void

Programming Language

  • Microsoft Visual Basic .Net.

Availability

Constructors

Though all properties can be provided or changed after initialisation, the use of the parameterized constructors is recommended for clarity.

Public Sub New()

Instantiates a new ImageMapArea object.

Public Sub New(shape: Shapes, coords: Integer(), href: String)

Instantiates a new ImageMapArea object.

Parameters

  • shape: the shape of this area.
  • coords: the coordinates desribing this area.
  • href: a URL pointing to the page linked (for web use).

Exception

  • Exception if the number of coordinates given does not fit the shape.

Remarks

  • The command set to the href.
  • Coordinates are formally checked for compliance wuth the type of shape.

Public Sub New(shape: Shapes, coords: Integer(), href: String, command: String)

Instantiates a new ImageMapArea object.

Parameters

  • shape: the shape of this area.
  • coords: the coordinates desribing this area.
  • href: a URL pointing to the page linked (for web use).
  • command: a command to be executed when this area is clicked (for non-web use).

Exception

  • Exception if the number of coordinates given does not fit the shape.

Remarks

  • If no command was given, its value is set to the href.
  • Coordinates are formally checked for compliance wuth the type of shape.

Public Sub New(shape: Shapes, coords: Integer(), href: String, command: String, title: String)

Instantiates a new ImageMapArea object.

Parameters

  • shape: the shape of this area.
  • coords: the coordinates desribing this area.
  • href: a URL pointing to the page linked (for web use).
  • command: a command to be executed when this area is clicked (for non-web use).
  • title: a text to be displayed in a tooltip window when the mouse is over this area.

Exception

  • Exception if the number of coordinates given does not fit the shape.

Remarks

  • If no command was given, its value is set to the href.
  • Coordinates are formally checked for compliance wuth the type of shape.

Public Sub New(shape: Shapes, coords: Integer(), href: String, command: String, title: String, alt: String)

Instantiates a new ImageMapArea object.

Parameters

  • shape: the shape of this area.
  • coords: the coordinates desribing this area.
  • href: a URL pointing to the page linked (for web use).
  • command: a command to be executed when this area is clicked (for non-web use).
  • title: a text to be displayed in a tooltip window when the mouse is over this area.
  • alt: a text to be displayed in non-graphical browsers (for web use).

Exception

  • Exception if the number of coordinates given does not fit the shape.

Remarks

  • If no command was given, its value is set to the href.
  • Coordinates are formally checked for compliance wuth the type of shape.

Public Sub New(shape: Shapes, coords: Integer(), href: String, command: String, title: String, alt: String, onclick: String)

Instantiates a new ImageMapArea object.

Parameters

  • shape: the shape of this area.
  • coords: the coordinates desribing this area.
  • href: a URL pointing to the page linked (for web use).
  • command: a command to be executed when this area is clicked (for non-web use).
  • title: a text to be displayed in a tooltip window when the mouse is over this area.
  • alt: a text to be displayed in non-graphical browsers (for web use).
  • onclick: a command to be executed by the browser (e.g. JavaScript) when this area is clicked (for web use).

Exception

  • Exception if the number of coordinates given does not fit the shape.

Remarks

  • If no command was given, its value is set to the href.
  • Coordinates are formally checked for compliance wuth the type of shape.

Public Sub New(shape: Shapes, coords: Integer(), href: String, command: String, title: String, alt: String, onclick: String, tag: Object)

Instantiates a new ImageMapArea object.

Parameters

  • shape: the shape of this area.
  • coords: the coordinates desribing this area.
  • href: a URL pointing to the page linked (for web use).
  • command: a command to be executed when this area is clicked (for non-web use).
  • title: a text to be displayed in a tooltip window when the mouse is over this area.
  • alt: a text to be displayed in non-graphical browsers (for web use).
  • onclick: a command to be executed by the browser (e.g. JavaScript) when this area is clicked (for web use).
  • tag: an object linked to the element (for non-web use).

Exception

  • Exception if the number of coordinates given does not fit the shape.

Remarks

  • If no command was given, its value is set to the href.
  • Coordinates are formally checked for compliance wuth the type of shape.

Interfaces

ICloneable

is implemented with the clone function.

Enumerations

The class provides enumerations for the Shape types of an ImageMap.

Enum Shapes

This enumeration describes the Shape types of an ImageMap. The acceptable types correspond to the types used with HTML image maps.
Value Meaning
rect rectangular
circle circular
poly polygonal

Properties

Shape As Shapes

Gets or sets the type of shape associated with this area. Acceptable values are defined by the Shapes enumeration.

Property Value

  • the type of shape associated with this area.

Remarks

  • The coordinates are not checked for consistency after changing the shape.

Coords As Integer

Gets or sets the array with the coordinates describing the shape.

Property Value

  • an array with the coordinates describing the shape.

Exceptions

  • Exception if the number of coordinates does not fit the number required by the type of shape.

Remarks

  • If the coordinates have to be changed because the shape is changed, the Shape property has to be changed first.

HREF As String

Gets or sets the URL the area is linked with.

Property Value

  • the URL the area is linked with.

Remarks

  • The URL must contain the protocol type (e.g. "http://") if the page is located on a different server.
  • Leave the HREF property empty, if this area is not linked to a URL. Do not use "nohref".
  • This property is meant for web applications.

Command As String

Gets or sets a command associated with the area.

Property Value

  • a command associated with the area.

Remarks

  • All values which can be evaluated by "System.Diagnostics.Process.Start" are useful; i.e. URLs starting with e.g. "http://" are acceptable.
  • This property is meant for non-web applications.

Title As String

Gets or sets the  text to be displayed in a tooltip window when the mouse is over this area.

Property Value

  • a text to be displayed in a tooltip window when the mouse is over this area.

Remarks

  • If used with web applications, this property is translated into the "title" element of an HTML link. The appearance of the text depends on the computer system and browser used.

AltText As String

Gets or sets the text to be displayed in non-graphical browsers.

Property Value

  • a text to be displayed in non-graphical browsers.

Remarks

  • This property is translated into the "alt" element of an HTML area.
  • This property is intended for web applications.

OnClick As String

Gets or sets the command to be executed by the browser (e.g. JavaScript) when this area is clicked.

Property Value

  • the command to be executed by the browser (e.g. JavaScript) when this area is clicked.

Remarks

  • This property is translated into the "onclick" element of an HTML link.
  • This property is intended for web applications.

Tag As Object

Gets or sets an object linked to the element.

Property Value

  • an object linked to the element

Remarks

  • This property is intended for non-web applications.

Target As String

Gets or sets the name of a browser document window associated with the HTML link to be followed.

Property Value

  • the name of a browser document window associated with the HTML link to be followed.

Remarks

  • This property is translated into the "target" element of an HTML link.
  • This property is intended for web applications.

Methods

Public Function clone() As Object

Returns a clone of the ImageMapArea object.

Return Value

  • a clone of the ImageMapArea object.

Parameters

  • none.

Implements

Remarks

  • While the Coords property can be cloned, cloning of the Tag property is not possible. I.e. changing properties of the Tag property of the clone may lead to changes in the Tag property of the original object.

Public Function containsPoint(ByVal point As System.Drawing.Point) As Boolean

Checks if the coordinates of point are inside the area.

Return Value

  • true if the coordinates of point are inside the area including its borders.
  • false in all other cases.

Remarks

  • If point lies on a line of a polygon, it may be said to be outside the polygon. Generally, this minor fuzziness does not matter.

Public Function toHTML() As String

Returns an HTML representation of the area element.

Return Value

  • an HTML representation of the area element.

Parameters

  • none

Remarks

  • If the HREF property is empty, a "nohref" element will be entered.
  • If the Target property is empty, the (friend) DefaultTarget property which can be set through the ImageMapData.DefaultTarget property will be used instead.
  • If the OnClick property is empty, the (friend) DefaultOnClick property which can be set through the ImageMapData.DefaultOnClick property will be used instead.

Examples

  • To generate an area element in circular shape at position (50;70) with radius 30 linked to "http://www.mysite.com/" which is to be opened in a new browser window and "Go to my site" is to be shown when the mouse is over the element, do:

  • Dim oArea as ImageMapArea
    Dim strHTML as String
    nCoords = New Integer() {50, 70, 30}
    oArea = New ImageMapArea(Shapes.circle, New Integer() {50, 70, 30}, "http://www.mysite.com/", "", "Go to my site")
    oArea.Target = "_blank"
    strHTML = oArea.toHTML()
    strHTML contains "<area shape="circle" coords="50,70,30" href="http://www.mysite.com/" target="_blank" title="Go to my site">"

Public Function transformCoordinates(ByVal addX As Integer, ByVal addY As Integer)

Transforms the coordinates of the area by adding the given values to the x and y coordinates of the points of the area.

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.

Interaction with other classes

Classes using ImageMapArea

ImageMapArea objects are stored in an arraylist in an ImageMapData object. There, they represent the area portions of the image map.