Move ol.DeclutterGroup to ol/render/canvas

This commit is contained in:
Michael Kuenzli
2018-04-18 14:55:48 +02:00
parent b740630e89
commit 3b983564b3
7 changed files with 29 additions and 30 deletions

View File

@@ -123,14 +123,14 @@ VectorContext.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) {}
/**
* @param {module:ol/style/Image~ImageStyle} imageStyle Image style.
* @param {ol.DeclutterGroup=} opt_declutterGroup Declutter.
* @param {module:ol/render/canvas~DeclutterGroup=} opt_declutterGroup Declutter.
*/
VectorContext.prototype.setImageStyle = function(imageStyle, opt_declutterGroup) {};
/**
* @param {module:ol/style/Text~Text} textStyle Text style.
* @param {ol.DeclutterGroup=} opt_declutterGroup Declutter.
* @param {module:ol/render/canvas~DeclutterGroup=} opt_declutterGroup Declutter.
*/
VectorContext.prototype.setTextStyle = function(textStyle, opt_declutterGroup) {};
export default VectorContext;

View File

@@ -55,6 +55,19 @@ import {create as createTransform} from '../transform.js';
*/
/**
* Container for decluttered replay instructions that need to be rendered or
* omitted together, i.e. when styles render both an image and text, or for the
* characters that form text along lines. The basic elements of this array are
* `[minX, minY, maxX, maxY, count]`, where the first four entries are the
* rendered extent of the group in pixel space. `count` is the number of styles
* in the group, i.e. 2 when an image and a text are grouped, or 1 otherwise.
* In addition to these four elements, declutter instruction arrays (i.e. the
* arguments to @{link ol.render.canvas.drawImage} are appended to the array.
* @typedef {Array.<*>} DeclutterGroup
*/
/**
* @const
* @type {string}

View File

@@ -23,7 +23,7 @@ const CanvasImageReplay = function(
/**
* @private
* @type {ol.DeclutterGroup}
* @type {module:ol/render/canvas~DeclutterGroup}
*/
this.declutterGroup_ = null;
@@ -217,7 +217,7 @@ CanvasImageReplay.prototype.setImageStyle = function(imageStyle, declutterGroup)
const origin = imageStyle.getOrigin();
this.anchorX_ = anchor[0];
this.anchorY_ = anchor[1];
this.declutterGroup_ = /** @type {ol.DeclutterGroup} */ (declutterGroup);
this.declutterGroup_ = /** @type {module:ol/render/canvas~DeclutterGroup} */ (declutterGroup);
this.hitDetectionImage_ = hitDetectionImage;
this.image_ = image;
this.height_ = size[1];

View File

@@ -208,7 +208,7 @@ CanvasReplay.prototype.replayTextBackground_ = function(context, p1, p2, p3, p4,
* @param {HTMLImageElement|HTMLCanvasElement|HTMLVideoElement} image Image.
* @param {number} anchorX Anchor X.
* @param {number} anchorY Anchor Y.
* @param {ol.DeclutterGroup} declutterGroup Declutter group.
* @param {module:ol/render/canvas~DeclutterGroup} declutterGroup Declutter group.
* @param {number} height Height.
* @param {number} opacity Opacity.
* @param {number} originX Origin X.
@@ -486,7 +486,7 @@ CanvasReplay.prototype.setStrokeStyle_ = function(context, instruction) {
/**
* @param {ol.DeclutterGroup} declutterGroup Declutter group.
* @param {module:ol/render/canvas~DeclutterGroup} declutterGroup Declutter group.
* @param {module:ol/Feature~Feature|ol.render.Feature} feature Feature.
*/
CanvasReplay.prototype.renderDeclutter_ = function(declutterGroup, feature) {
@@ -656,7 +656,7 @@ CanvasReplay.prototype.replay_ = function(
// Remaining arguments in DRAW_IMAGE are in alphabetical order
anchorX = /** @type {number} */ (instruction[4]);
anchorY = /** @type {number} */ (instruction[5]);
declutterGroup = featureCallback ? null : /** @type {ol.DeclutterGroup} */ (instruction[6]);
declutterGroup = featureCallback ? null : /** @type {module:ol/render/canvas~DeclutterGroup} */ (instruction[6]);
const height = /** @type {number} */ (instruction[7]);
const opacity = /** @type {number} */ (instruction[8]);
const originX = /** @type {number} */ (instruction[9]);
@@ -695,7 +695,7 @@ CanvasReplay.prototype.replay_ = function(
const begin = /** @type {number} */ (instruction[1]);
const end = /** @type {number} */ (instruction[2]);
const baseline = /** @type {number} */ (instruction[3]);
declutterGroup = featureCallback ? null : /** @type {ol.DeclutterGroup} */ (instruction[4]);
declutterGroup = featureCallback ? null : /** @type {module:ol/render/canvas~DeclutterGroup} */ (instruction[4]);
const overflow = /** @type {number} */ (instruction[5]);
const fillKey = /** @type {string} */ (instruction[6]);
const maxAngle = /** @type {number} */ (instruction[7]);

View File

@@ -21,7 +21,7 @@ import {create as createTransform, compose as composeTransform} from '../../tran
/**
* @type {Object.<ol.render.ReplayType,
* function(new: ol.render.canvas.Replay, number, module:ol/extent~Extent,
* number, number, boolean, Array.<ol.DeclutterGroup>)>}
* number, number, boolean, Array.<module:ol/render/canvas~DeclutterGroup>)>}
*/
const BATCH_CONSTRUCTORS = {
'Circle': CanvasPolygonReplay,
@@ -57,7 +57,7 @@ const CanvasReplayGroup = function(
this.declutterTree_ = declutterTree;
/**
* @type {ol.DeclutterGroup}
* @type {module:ol/render/canvas~DeclutterGroup}
* @private
*/
this.declutterGroup_ = null;
@@ -219,7 +219,7 @@ export function replayDeclutter(declutterReplays, context, rotation) {
/**
* @param {boolean} group Group with previous replay.
* @return {ol.DeclutterGroup} Declutter instruction group.
* @return {module:ol/render/canvas~DeclutterGroup} Declutter instruction group.
*/
CanvasReplayGroup.prototype.addDeclutter = function(group) {
let declutter = null;
@@ -290,7 +290,7 @@ CanvasReplayGroup.prototype.finish = function() {
* to skip.
* @param {function((module:ol/Feature~Feature|ol.render.Feature)): T} callback Feature
* callback.
* @param {Object.<string, ol.DeclutterGroup>} declutterReplays Declutter
* @param {Object.<string, module:ol/render/canvas~DeclutterGroup>} declutterReplays Declutter
* replays.
* @return {T|undefined} Callback result.
* @template T
@@ -457,7 +457,7 @@ CanvasReplayGroup.prototype.isEmpty = function() {
* to skip.
* @param {Array.<ol.render.ReplayType>=} opt_replayTypes Ordered replay types
* to replay. Default is {@link ol.render.replay.ORDER}
* @param {Object.<string, ol.DeclutterGroup>=} opt_declutterReplays Declutter
* @param {Object.<string, module:ol/render/canvas~DeclutterGroup>=} opt_declutterReplays Declutter
* replays.
*/
CanvasReplayGroup.prototype.replay = function(context,

View File

@@ -32,7 +32,7 @@ const CanvasTextReplay = function(
/**
* @private
* @type {ol.DeclutterGroup}
* @type {module:ol/render/canvas~DeclutterGroup}
*/
this.declutterGroup_;
@@ -381,7 +381,7 @@ CanvasTextReplay.prototype.drawTextImage_ = function(label, begin, end) {
* @private
* @param {number} begin Begin.
* @param {number} end End.
* @param {ol.DeclutterGroup} declutterGroup Declutter group.
* @param {module:ol/render/canvas~DeclutterGroup} declutterGroup Declutter group.
*/
CanvasTextReplay.prototype.drawChars_ = function(begin, end, declutterGroup) {
const strokeState = this.textStrokeState_;
@@ -466,7 +466,7 @@ CanvasTextReplay.prototype.setTextStyle = function(textStyle, declutterGroup) {
if (!textStyle) {
this.text_ = '';
} else {
this.declutterGroup_ = /** @type {ol.DeclutterGroup} */ (declutterGroup);
this.declutterGroup_ = /** @type {module:ol/render/canvas~DeclutterGroup} */ (declutterGroup);
const textFillStyle = textStyle.getFill();
if (!textFillStyle) {

View File

@@ -21,20 +21,6 @@ const ol = {};
*/
/**
* Container for decluttered replay instructions that need to be rendered or
* omitted together, i.e. when styles render both an image and text, or for the
* characters that form text along lines. The basic elements of this array are
* `[minX, minY, maxX, maxY, count]`, where the first four entries are the
* rendered extent of the group in pixel space. `count` is the number of styles
* in the group, i.e. 2 when an image and a text are grouped, or 1 otherwise.
* In addition to these four elements, declutter instruction arrays (i.e. the
* arguments to @{link ol.render.canvas.drawImage} are appended to the array.
* @typedef {Array.<*>}
*/
ol.DeclutterGroup;
/**
* A function that takes an {@link module:ol/extent~Extent} and a resolution as arguments, and
* returns an array of {@link module:ol/extent~Extent} with the extents to load. Usually this