Show:

ia.CartesianSpace Class

Module: ia

Maps a data space to a pixel space and vice versa.

The data space is defined by a {@link ia.BoundingBox}.

The pixel space is defined by the canvasX, canvasY, canvasWidth and canvasHeight properties.

Pixel coords are relative to the top left corner of the view. Data coords are relative to the bottom left corner of the view.

The data space may be adjusted to maintain its aspect ratio by setting the value of maintainAspectRatio to true.

Constructor

ia.CartesianSpace

(
  • [canvasX=0]
  • [canvasY=0]
  • [canvasWidth=0]
  • [canvasHeight=0]
)

Parameters:

  • [canvasX=0] Number optional

    The x-coord of the pixel space.

  • [canvasY=0] Number optional

    The y-coord of the pixel space.

  • [canvasWidth=0] Number optional

    The width of the pixel space.

  • [canvasHeight=0] Number optional

    The height of the pixel space.

Methods

addEventListener

(
  • eventType
  • fnc
  • obj
)

Add an event listener.

Parameters:

  • eventType String

    The type of event to listen for.

  • fnc Function

    The function to call when the event occurs.

  • obj Object

    An optional parent object.

adjustBBox

(
  • bb
)

Adjusts the bounding box to fit the pixel space whilst maintaining its aspect ratio.

Parameters:

adjustY

(
  • bb
)

Adjusts the y coords to fit the pixel space whilst maintaining x coords.

Parameters:

commitChanges

()

A call to commitChanges commits any changes made to canvasWidth, canvasHeight or bBox.

This function exists to allow properties to be changed without continuous updates to the object.

dispatchEvent

(
  • event
)

Dispatch an event to the listeners.

Parameters:

  • event Object

    The event object.

getBBox

() ia.BoundingBox

Gets the bounding box.

Returns:

ia.BoundingBox: The bounding box.

getDataBBox

(
  • rect
)
ia.BoundingBox

Converts a rectangle (pixel units) to a bBox (data units).

Parameters:

Returns:

ia.BoundingBox: A bBox (data units).

getDataHeight

(
  • dimension
)
Number

Converts a height from pixel units to data units.

Parameters:

  • dimension Number

    A height (pixel units).

Returns:

Number: A height (data units).

getDataPoint

(
  • p
)
ia.Point

Converts a point from pixel units to data units.

Parameters:

Returns:

ia.Point: A point (data units).

getDataWidth

(
  • dimension
)
Number

Converts a width from pixel units to data units.

Parameters:

  • dimension Number

    A width (pixel units).

Returns:

Number: A width (data units).

getDataX

(
  • x
)
Number

Converts an x-coord from pixel units to data units.

Parameters:

  • x Number

    An x-coord (pixel units).

Returns:

Number: An x-coord (data units).

getDataY

(
  • y
)
Number

Converts a y-coord from pixel units to data units.

Parameters:

  • y Number

    A y-coord (pixel units).

Returns:

Number: A y-coord (data units).

getPixelHeight

(
  • y
)
Number

Converts a height from data units to pixel units.

Parameters:

  • y Number

    A height (data units).

Returns:

Number: A height (pixel units).

getPixelPoint

(
  • p
)
ia.Point

Converts a point from data units to pixel units.

Parameters:

Returns:

ia.Point: A point (pixel units).

getPixelRect

(
  • bb
)
ia.Rectangle

Converts a bounding box (data units) to a rectangle (pixel units).

Parameters:

Returns:

ia.Rectangle: A rectangle (pixel units).

getPixelWidth

(
  • x
)
Number

Converts a width from data units to pixel units.

Parameters:

  • x Number

    A width (data units).

Returns:

Number: A width (pixel units).

getPixelX

(
  • x
)
Number

Converts an x-coord from data units to pixel units.

Parameters:

  • x Number

    An x-coord (data units).

Returns:

Number: An x-coord (pixel units).

getPixelY

(
  • y
)
Number

Converts a y-coord from data units to pixel units.

Parameters:

  • y Number

    A y-coord (data units).

Returns:

Number: A y-coord (pixel units).

removeListener

(
  • obj
)

Removes all event listeners for the given object.

Parameters:

  • obj Object

    The object.

setBBox

(
  • bBox
)

Sets the bounding box.

Parameters:

Properties

canvasHeight

Number

The pixel height.

Default: 0

canvasWidth

Number

The pixel width.

Default: 0

canvasX

Number

The pixel x-position.

Default: 0

canvasY

Number

The pixel y-position.

Default: 0

maintainAspectRatio

Boolean

The data space will often be a different shape to the pixel space it has to fill.

If set to true the data space is adjusted to maintain the aspect ratio.

If set to false the data space stretches to fit the pixel space. This will generally result in the aspect ratio changing (a stretching effect).

Default: false

maxZoom

Number

The maximum extent.

Default: -1

minZoom

Number

The minimum extent.

Default: -1