Skip to content

Commit

Permalink
Added style typedefs.
Browse files Browse the repository at this point in the history
Moved all style specifications into jsdoc typedefs called
`<class>.styleSpec`.
  • Loading branch information
manthey committed Aug 28, 2018
1 parent a0f418b commit 5ad09a0
Show file tree
Hide file tree
Showing 12 changed files with 236 additions and 189 deletions.
1 change: 1 addition & 0 deletions src/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*
* @namespace
* @alias geo.action
* @enum {string}
*/
var geo_action = {
momentum: 'geo_action_momentum',
Expand Down
46 changes: 19 additions & 27 deletions src/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -1082,13 +1082,10 @@ var annotation = function (type, args) {
* coordinates. These must be in order around the perimeter of the
* rectangle (in either direction).
* @property {geo.geoPosition[]} [coordinates] An alternate name for `corners`.
* @property {object} [style] The style to apply to a finished rectangle. This
* uses styles for polygons, including `fill`, `fillColor`, `fillOpacity`,
* `stroke`, `strokeWidth`, `strokeColor`, and `strokeOpacity`.
* @property {object} [editStyle] The style to apply to a rectangle in edit
* mode. This uses styles for polygons and lines, including `fill`,
* `fillColor`, `fillOpacity`, `stroke`, `strokeWidth`, `strokeColor`, and
* `strokeOpacity`.
* @property {geo.polygonFeature.styleSpec} [style] The style to apply to a
* finished rectangle. This uses styles for {@link geo.polygonFeature}.
* @property {geo.polygonFeature.styleSpec} [editStyle] The style to apply to a
* rectangle in edit mode.
*/

/**
Expand Down Expand Up @@ -1470,13 +1467,10 @@ registerAnnotation('rectangle', rectangleAnnotation, rectangleRequiredFeatures);
* (in either direction).
* @property {geo.geoPosition[]} [coordinates] An alternate name for
* `vertices`.
* @property {object} [style] The style to apply to a finished polygon. This
* uses styles for polygons, including `fill`, `fillColor`, `fillOpacity`,
* `stroke`, `strokeWidth`, `strokeColor`, and `strokeOpacity`.
* @property {object} [editStyle] The style to apply to a polygon in edit mode.
* This uses styles for polygons and lines, including `fill`, `fillColor`,
* `fillOpacity`, `stroke`, `strokeWidth`, `strokeColor`, and
* `strokeOpacity`.
* @property {geo.polygonFeature.styleSpec} [style] The style to apply to a
* finished polygon. This uses styles for {@link geo.polygonFeature}.
* @property {geo.polygonFeature.styleSpec} [editStyle] The style to apply to ai
* polygon in edit mode.
*/

/**
Expand Down Expand Up @@ -1735,12 +1729,10 @@ registerAnnotation('polygon', polygonAnnotation, polygonRequiredFeatures);
* coordinates.
* @property {geo.geoPosition[]} [coordinates] An alternate name for
* `vertices`.
* @property {object} [style] The style to apply to a finished line. This uses
* styles for lines, including `strokeWidth`, `strokeColor`,
* `strokeOpacity`, `strokeOffset`, `closed`, `lineCap`, and `lineJoin`.
* @property {object} [editStyle] The style to apply to a line in edit mode.
* This uses styles for lines, including `strokeWidth`, `strokeColor`,
* `strokeOpacity`, `strokeOffset`, `closed`, `lineCap`, and `lineJoin`.
* @property {geo.lineFeature.styleSpec} [style] The style to apply to a
* finished line. This uses styles for {@link geo.lineFeature}.
* @property {geo.lineFeature.styleSpec} [editStyle] The style to apply to a
* line in edit mode.
*/

/**
Expand Down Expand Up @@ -2120,14 +2112,14 @@ registerAnnotation('line', lineAnnotation, lineRequiredFeatures);
* @property {geo.geoPosition} [position] A coordinate in map gcs coordinates.
* @property {geo.geoPosition[]} [coordinates] An array with one coordinate to
* use in place of `position`.
* @property {object} [style] The style to apply to a finished point. This
* uses styles for points, including `radius`, `fill`, `fillColor`,
* `fillOpacity`, `stroke`, `strokeWidth`, `strokeColor`, `strokeOpacity`,
* and `scaled`. If `scaled` is `false`, the point is not scaled with zoom
* level. If it is `true`, the radius is based on the zoom level at first
* instantiation. Otherwise, if it is a number, the radius is used at that
* @property {geo.pointFeature.styleSpec} [style] The style to apply to a
* finished point. This uses styles for {@link geo.pointFeature}.
* @property {boolean|number} [style.scaled=false] If `false`, the point is not
* scaled with zoom level. If `true`, the radius is based on the zoom level
* at first instantiation. If a number, the radius is used at the `scaled`
* zoom level.
* @property {object} [editStyle] The style to apply to a point in edit mode.
* @property {geo.pointFeature.styleSpec} [editStyle] The style to apply to a
* point in edit mode.
*/

/**
Expand Down
29 changes: 17 additions & 12 deletions src/contourFeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,27 @@ var meshFeature = require('./meshFeature');
* @typedef {geo.feature.spec} geo.contourFeature.spec
* @property {object[]} [data=[]] An array of arbitrary objects used to
* construct the feature.
* @property {object} [style] An object that contains style values for the
* feature.
* @property {number|function} [style.opacity=1] The opacity on a scale of 0 to
* 1.
* @property {geo.geoPosition|function} [style.position=data] The position of
* each data element. This defaults to just using `x`, `y`, and `z`
* properties of the data element itself. The position is in the feature's
* gcs coordinates.
* @property {number|function} [style.value=data.z] The value of each data
* element. This defaults `z` properties of the data element. If the value
* of a grid point is `null` or `undefined`, that point and elements that
* use that point won't be included in the results.
* @property {geo.contourFeature.styleSpec} [style] An object that contains
* style values for the feature.
* @property {geo.contourFeature.contourSpec} [contour] The contour
* specification for the feature.
*/

/**
* Style specification for a contour feature.
*
* @typedef {geo.feature.styleSpec} geo.contourFeature.styleSpec
* @extends geo.feature.styleSpec
* @property {geo.geoPosition|function} [position=data] The position of each
* data element. This defaults to just using `x`, `y`, and `z` properties
* of the data element itself. The position is in the feature's gcs
* coordinates.
* @property {number|function} [value=data.z] The value of each data element.
* This defaults to the `z` property of the data elements. If the value of
* a grid point is `null` or `undefined`, the point and elements that use
* that point won't be included in the results.
*/

/**
* Contour specification. All of these properties can be functions, which get
* passed the {@link geo.meshFeature.meshInfo} object.
Expand Down
18 changes: 12 additions & 6 deletions src/feature.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,16 @@ var geo_event = require('./event');
* feature within its parent's list of children as the bin number.
* @property {geo.renderer?} [renderer] A reference to the renderer used for
* the feature.
* @property {object} [style] An object that contains style values for the
* feature.
* @property {number|function} [style.opacity=1] The opacity on a scale of 0 to
* 1.
* @property {geo.feature.styleSpec} [style] An object that contains style
* values for the feature.
*/

/**
* Style specification for a feature.
*
* @typedef {object} geo.feature.styleSpec
* @property {number|function} [style.opacity=1] The opacity for the whole
* feature on a scale of 0 to 1.
*/

/**
Expand Down Expand Up @@ -408,8 +414,8 @@ var feature = function (arg) {
* has a subfeature style, with `(subfeatureElement, subfeatureIndex,
* dataElement, dataIndex)`.
*
* See the feature's specification ({@link geo.feature.spec}) for available
* styles.
* See the feature's specification ({@link geo.feature.styleSpec}) for
* available styles.
*
* @param {string|object} [arg1] If `undefined`, return the current style
* object. If a string and `arg2` is undefined, return the style
Expand Down
59 changes: 33 additions & 26 deletions src/isolineFeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,44 @@ var util = require('./util');
* @typedef {geo.feature.spec} geo.isolineFeature.spec
* @property {object[]} [data=[]] An array of arbitrary objects used to
* construct the feature.
* @property {object} [style] An object that contains style values for the
* feature. This includes {@link geo.lineFeature} and
* {@link geo.textFeature} style values.
* @property {number|function} [style.opacity=1] Overall opacity on a scale of
* 0 to 1.
* @property {geo.geoPosition|function} [style.position=data] The position of
* each data element. This defaults to just using `x`, `y`, and `z`
* properties of the data element itself. The position is in thea feature's
* gcs coordinates.
* @property {number|function} [style.value=data.z] The value of each data
* element. This defaults `z` properties of the data element. If the value
* of a grid point is `null` or `undefined`, that point and elements that
* use that point won't be included in the results.
* @property {geo.geoColor|function} [style.strokeColor='black'] Color to
* stroke each line.
* @property {number|function} [style.strokeWidth] The weight of the line
* stroke in pixels. This defaults to the line value's level + 0.5.
* @property {boolean|function} [style.rotateWithMap=true] Rotate label text
* when the map rotates.
* @property {number|function} [style.rotation] Text rotation in radians. This
* @property {geo.isolineFeature.styleSpec} [style] An object that contains
* style values for the feature.
* @property {geo.isolineFeature.isolineSpec} [isoline] The isoline
* specification for the feature.
*/

/**
* Style specification for an isoline feature. Extends
* {@link geo.lineFeasture.styleSpec} and {@link geo.textFeasture.styleSpec}.
*
* @typedef {geo.feature.styleSpec} geo.isolineFeature.styleSpec
* @extends geo.feature.styleSpec
* @extends geo.textFeature.styleSpec
* @extends geo.lineFeature.styleSpec
* @property {geo.geoPosition|function} [position=data] The position of each
* data element. This defaults to just using `x`, `y`, and `z` properties
* of the data element itself. The position is in the feature's gcs
* coordinates.
* @property {number|function} [value=data.z] The value of each data element.
* This defaults to the `z` property of the data elements. If the value of
* a grid point is `null` or `undefined`, the point and elements that use
* that point won't be included in the results.
* @property {geo.geoColor|function} [strokeColor='black'] Color to stroke each
* line.
* @property {number|function} [strokeWidth] The weight of the line stroke in
* pixels. This defaults to the line value's level + 0.5.
* @property {boolean|function} [rotateWithMap=true] Rotate label text when the
* map rotates.
* @property {number|function} [rotation] Text rotation in radians. This
* defaults to the label oriented so that top of the text is toward the
* higher value. There is a utility function that can be used for common
* rotation preferences. See {@link geo.isolineFeature#rotationFunction}.
* For instance, `rotation=geo.isolineFeature.rotationFunction('map')`.
* @property {string|function} [style.fontSize='12px'] The font size.
* @property {geo.geoColor|function} [style.textStrokeColor='white'] Text
* @property {string|function} [fontSize='12px'] The font size.
* @property {geo.geoColor|function} [textStrokeColor='white'] Text
* stroke color. This adds contrast between the label and the isoline.
* @property {geo.geoColor|function} [style.textStrokeWidth=2] Text stroke
* width in pixels.
* @property {geo.isolineFeature.isolineSpec} [isoline] The isoline
* specification for the feature.
* @property {geo.geoColor|function} [textStrokeWidth=2] Text stroke width in
* pixels.
*/

/**
Expand Down
48 changes: 28 additions & 20 deletions src/lineFeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,41 @@ var util = require('./util');
* points. Only lines that have at least two points are rendered. The
* position function is called for each point as `position(linePoint,
* pointIndex, lineEntry, lineEntryIndex)`.
* @property {object} [style] Style object with default style options.
* @property {geo.geoColor|function} [style.strokeColor] Color to stroke each
* line. The color can vary by point.
* @property {number|function} [style.strokeOpacity] Opacity for each line
* stroke. The opacity can vary by point. Opacity is on a [0-1] scale.
* @property {number|function} [style.strokeWidth] The weight of the line
* stroke in pixels. The width can vary by point.
* @property {number|function} [style.strokeOffset] This is a value from -1
* (left) to 1 (right), with 0 being centered. This can vary by point.
* @property {string|function} [style.lineCap='butt'] One of 'butt', 'square',
* or 'round'. This can vary by point.
* @property {string|function} [style.lineJoin='miter'] One of 'miter',
* 'bevel', 'round', or 'miter-clip'. This can vary by point.
* @property {boolean|function} [style.closed=false] If true and the renderer
* @property {geo.lineFeature.styleSpec} [style] Style object with default
* style options.
*/

/**
* Style specification for a line feature.
*
* @typedef {geo.feature.styleSpec} geo.lineFeature.styleSpec
* @extends geo.feature.styleSpec
* @property {geo.geoColor|function} [strokeColor] Color to stroke each line.
* The color can vary by point.
* @property {number|function} [strokeOpacity] Opacity for each line stroke.
* The opacity can vary by point. Opacity is on a [0-1] scale.
* @property {number|function} [strokeWidth] The weight of the line stroke in
* pixels. The width can vary by point.
* @property {number|function} [strokeOffset] This is a value from -1 (left) to
* 1 (right), with 0 being centered. This can vary by point.
* @property {string|function} [lineCap='butt'] One of 'butt', 'square', or
* 'round'. This can vary by point.
* @property {string|function} [lineJoin='miter'] One of 'miter', 'bevel',
* 'round', or 'miter-clip'. This can vary by point.
* @property {boolean|function} [closed=false] If true and the renderer
* supports it, connect the first and last points of a line if the line has
* more than two points. This applies per line (if a function, it is called
* with `(lineEntry, lineEntryIndex)`.
* @property {number|function} [style.miterLimit=10] For lines of more than two
* @property {number|function} [miterLimit=10] For lines of more than two
* segments that are mitered, if the miter length exceeds the `strokeWidth`
* divided by the sine of half the angle between segments, then a bevel join
* is used instead. This is a single value that applies to all lines. If a
* function, it is called with `(data)`.
* @property {number|function} [style.antialiasing] Antialiasing distance in
* pixels. Values must be non-negative. A value greater than 1 will produce
* a visible gradient. This is a single value that applies to all lines.
* @property {string|function} [style.debug] If 'debug', render lines in debug
* mode. This is a single value that applies to all lines.
* @property {number|function} [antialiasing] Antialiasing distance in pixels.
* Values must be non-negative. A value greater than 1 will produce a
* visible gradient. This is a single value that applies to all lines.
* @property {string|function} [debug] If 'debug', render lines in debug mode.
* This is a single value that applies to all lines.
*/

/**
Expand Down
12 changes: 12 additions & 0 deletions src/meshFeature.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
var inherit = require('./inherit');
var feature = require('./feature');

/**
* Mesh feature specification.
*
* @typedef {geo.feature.spec} geo.meshFeature.spec
* @property {object[]} [data=[]] An array of arbitrary objects used to
* construct the feature.
* @property {geo.feature.styleSpec} [style] An object that contains style
* values for the feature.
* @property {geo.meshFeature.meshSpec} [mesh] The mesh specification for the
* feature.
*/

/**
* A mesh formed by a set of triangular or square elements or a
* squarely-connected grid that is of rectangular extent. The gird can be
Expand Down
15 changes: 7 additions & 8 deletions src/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ var object = function () {
* Trigger an event (or events) on this object and call all handlers.
*
* @param {string|string[]} event An event or list of events from
* {@link geo.event} or defined by the user.
* {@link geo.event} or defined by the user.
* @param {object} [args] Additional information to add to the
* {@link geo.event} object passed to the handlers.
* {@link geo.event} object passed to the handlers.
* @returns {this}
*/
this.geoTrigger = function (event, args) {
Expand Down Expand Up @@ -169,11 +169,11 @@ var object = function () {
* provided all handlers will be removed.
*
* @param {string|string[]} [event] An event or a list of events from
* {@link geo.event} or defined by the user, or `undefined` to remove
* all events (in which case `arg` is ignored).
* {@link geo.event} or defined by the user, or `undefined` to remove all
* events (in which case `arg` is ignored).
* @param {(function|function[])?} [arg] A function or array of functions to
* remove from the events or a falsey value to remove all handlers
* from the events.
* remove from the events or a falsy value to remove all handlers from the
* events.
* @returns {this}
*/
this.geoOff = function (event, arg) {
Expand All @@ -199,8 +199,7 @@ var object = function () {
if (m_eventHandlers.hasOwnProperty(event)) {
m_eventHandlers[event] = m_eventHandlers[event].filter(function (f) {
return f !== arg;
}
);
});
}
return m_this;
};
Expand Down
36 changes: 21 additions & 15 deletions src/pointFeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,8 @@ var feature = require('./feature');
* @typedef {geo.feature.spec} geo.pointFeature.spec
* @property {geo.geoPosition|function} [position] Position of the data.
* Default is (data).
* @property {object} [style] Style object with default style options.
* @property {number|function} [style.radius=5] Radius of each point in pixels.
* This is the fill radius inside of the stroke.
* @property {boolean|function} [style.stroke=true] True to stroke point.
* @property {geo.geoColor|function} [style.strokeColor] Color to stroke each
* point.
* @property {number|function} [style.strokeOpacity=1] Opacity for each point's
* stroke. Opacity is on a [0-1] scale.
* @property {number|function} [style.strokeWidth=1.25] The weight of the
* point's stroke in pixels.
* @property {boolean|function} [style.fill=true] True to fill point.
* @property {geo.geoColor|function} [style.fillColor] Color to fill each
* point/
* @property {number|function} [style.fillOpacity=1] Opacity for each point.
* Opacity is on a [0-1] scale.
* @property {geo.pointFeature.styleSpec} [style] Style object with default
* style options.
* @property {boolean|geo.pointFeature.clusteringSpec} [clustering=false]
* Enable point clustering.
* @property {string} [primitiveShape='sprite'] For the gl renderer, select the
Expand All @@ -33,6 +20,25 @@ var feature = require('./feature');
* truthy, webgl source buffers can be modifies and updated directly.
*/

/**
* Style specification for a point feature.
*
* @typedef {geo.feature.styleSpec} geo.pointFeature.styleSpec
* @extends geo.feature.styleSpec
* @property {number|function} [radius=5] Radius of each point in pixels. This
* is the fill radius inside of the stroke.
* @property {boolean|function} [stroke=true] True to stroke point.
* @property {geo.geoColor|function} [strokeColor] Color to stroke each point.
* @property {number|function} [strokeOpacity=1] Opacity for each point's
* stroke. Opacity is on a [0-1] scale.
* @property {number|function} [strokeWidth=1.25] The weight of the point's
* stroke in pixels.
* @property {boolean|function} [fill=true] True to fill point.
* @property {geo.geoColor|function} [fillColor] Color to fill each point.
* @property {number|function} [fillOpacity=1] Opacity for each point. Opacity
* is on a [0-1] scale.
*/

/**
* Point clustering specification.
*
Expand Down
Loading

0 comments on commit 5ad09a0

Please sign in to comment.