mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 13:16:10 +03:00
add documentation; remove unnecessary deprecated code
This commit is contained in:
parent
3a5a738508
commit
cc412f0a20
@ -81,7 +81,7 @@ class Context2dDrawer extends $.DrawerBase{
|
|||||||
/**
|
/**
|
||||||
* @returns {Boolean} true if canvas is supported by the browser, otherwise false
|
* @returns {Boolean} true if canvas is supported by the browser, otherwise false
|
||||||
*/
|
*/
|
||||||
isSupported(){
|
static isSupported(){
|
||||||
return $.supportsCanvas;
|
return $.supportsCanvas;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,11 +76,6 @@ $.DrawerBase = class DrawerBase{
|
|||||||
this.debugGridColor = typeof options.debugGridColor === 'string' ? [options.debugGridColor] : options.debugGridColor || $.DEFAULT_SETTINGS.debugGridColor;
|
this.debugGridColor = typeof options.debugGridColor === 'string' ? [options.debugGridColor] : options.debugGridColor || $.DEFAULT_SETTINGS.debugGridColor;
|
||||||
this.options = options.options || {};
|
this.options = options.options || {};
|
||||||
|
|
||||||
// TO DO: This was deprectated previously. Can we get rid of it at this point?
|
|
||||||
if (options.opacity) {
|
|
||||||
$.console.error( "[Drawer] options.opacity is no longer accepted; set the opacity on the TiledImage instead" );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The parent element of this Drawer instance, passed in when the Drawer was created.
|
* The parent element of this Drawer instance, passed in when the Drawer was created.
|
||||||
* The parent of {@link OpenSeadragon.DrawerBase#canvas}.
|
* The parent of {@link OpenSeadragon.DrawerBase#canvas}.
|
||||||
@ -130,7 +125,7 @@ $.DrawerBase = class DrawerBase{
|
|||||||
/**
|
/**
|
||||||
* @returns {Boolean} whether the drawer implementation is supported by the browser
|
* @returns {Boolean} whether the drawer implementation is supported by the browser
|
||||||
*/
|
*/
|
||||||
isSupported() {
|
static isSupported() {
|
||||||
$.console.error('Drawer.isSupported must be implemented by child class');
|
$.console.error('Drawer.isSupported must be implemented by child class');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,7 +216,7 @@ $.DrawerBase = class DrawerBase{
|
|||||||
/**
|
/**
|
||||||
* This event is fired just before the tile is drawn giving the application a chance to alter the image.
|
* This event is fired just before the tile is drawn giving the application a chance to alter the image.
|
||||||
*
|
*
|
||||||
* NOTE: This event is only fired in certain drawing contexts: either the 'context2d' drawer is
|
* NOTE: This event is only fired in certain drawing contexts: either the 'canvas' drawer is
|
||||||
* being used, or the 'webgl' drawer with 'drawerOptions.webgl.continuousTileRefresh'.
|
* being used, or the 'webgl' drawer with 'drawerOptions.webgl.continuousTileRefresh'.
|
||||||
*
|
*
|
||||||
* @event tile-drawing
|
* @event tile-drawing
|
||||||
|
@ -61,7 +61,7 @@ class HTMLDrawer extends $.DrawerBase{
|
|||||||
/**
|
/**
|
||||||
* @returns {Boolean} always true
|
* @returns {Boolean} always true
|
||||||
*/
|
*/
|
||||||
isSupported(){
|
static isSupported(){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,6 +195,8 @@
|
|||||||
/**
|
/**
|
||||||
* Destroys ImageTileSource
|
* Destroys ImageTileSource
|
||||||
* @function
|
* @function
|
||||||
|
* @param {OpenSeadragon.Viewer} viewer the viewer that is calling
|
||||||
|
* destroy on the ImageTileSource
|
||||||
*/
|
*/
|
||||||
destroy: function (viewer) {
|
destroy: function (viewer) {
|
||||||
this._freeupCanvasMemory(viewer);
|
this._freeupCanvasMemory(viewer);
|
||||||
@ -273,6 +275,7 @@
|
|||||||
this.levels[i].context2D.canvas.height = 0;
|
this.levels[i].context2D.canvas.height = 0;
|
||||||
this.levels[i].context2D.canvas.width = 0;
|
this.levels[i].context2D.canvas.width = 0;
|
||||||
|
|
||||||
|
if(viewer){
|
||||||
/**
|
/**
|
||||||
* Triggered when an image has just been unloaded
|
* Triggered when an image has just been unloaded
|
||||||
*
|
*
|
||||||
@ -285,6 +288,8 @@
|
|||||||
context2D: this.levels[i].context2D
|
context2D: this.levels[i].context2D
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -190,8 +190,8 @@
|
|||||||
* Zoom level to use when image is first opened or the home button is clicked.
|
* Zoom level to use when image is first opened or the home button is clicked.
|
||||||
* If 0, adjusts to fit viewer.
|
* If 0, adjusts to fit viewer.
|
||||||
*
|
*
|
||||||
* @property {String|DrawerImplementation|Array} [drawer = ['webgl', 'context2d', 'html']]
|
* @property {String|DrawerImplementation|Array} [drawer = ['webgl', 'canvas', 'html']]
|
||||||
* Which drawer to use. Valid strings are 'context2d' and 'html'. Valid drawer
|
* Which drawer to use. Valid strings are 'webgl', 'canvas', and 'html'. Valid drawer
|
||||||
* implementations are constructors of classes that extend OpenSeadragon.DrawerBase.
|
* implementations are constructors of classes that extend OpenSeadragon.DrawerBase.
|
||||||
* An array of strings and/or constructors can be used to indicate the priority
|
* An array of strings and/or constructors can be used to indicate the priority
|
||||||
* of different implementations, which will be tried in order based on browser support.
|
* of different implementations, which will be tried in order based on browser support.
|
||||||
@ -1346,8 +1346,7 @@ function OpenSeadragon( options ){
|
|||||||
compositeOperation: null, // to be passed into each TiledImage
|
compositeOperation: null, // to be passed into each TiledImage
|
||||||
|
|
||||||
// DRAWER SETTINGS
|
// DRAWER SETTINGS
|
||||||
drawer: ['webgl', 'context2d', 'html'], // prefer using webgl, context2d, fallback to html
|
drawer: ['webgl', 'canvas', 'html'], // prefer using webgl, context2d, fallback to html
|
||||||
useCanvas: true, // deprecated - set drawer and drawerOptions
|
|
||||||
/**
|
/**
|
||||||
* drawerOptions dictionary.
|
* drawerOptions dictionary.
|
||||||
* @type {Object} drawerOptions
|
* @type {Object} drawerOptions
|
||||||
|
@ -423,41 +423,6 @@ $.TileSource.prototype = {
|
|||||||
return new $.Rect( px * scale, py * scale, sx * scale, sy * scale );
|
return new $.Rect( px * scale, py * scale, sx * scale, sy * scale );
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* @function
|
|
||||||
* @param {Number} level
|
|
||||||
* @param {Number} x
|
|
||||||
* @param {Number} y
|
|
||||||
* @param {Boolean} [isSource=false] Whether to return the source bounds of the tile.
|
|
||||||
* @returns {OpenSeadragon.Rect} Either where this tile fits (in normalized coordinates unless imageCoordinates == true) or the
|
|
||||||
* portion of the tile to use as the source of the drawing operation (in pixels), depending on
|
|
||||||
* the isSource parameter, without overlap.
|
|
||||||
*/
|
|
||||||
getTileBoundsNoOverlap: function( level, x, y, isSource, imageCoordinates ) {
|
|
||||||
var dimensionsScaled = this.dimensions.times( this.getLevelScale( level ) ),
|
|
||||||
tileWidth = this.getTileWidth(level),
|
|
||||||
tileHeight = this.getTileHeight(level),
|
|
||||||
tileOverlap = this.tileOverlap || 0,
|
|
||||||
px = tileWidth * x,
|
|
||||||
py = tileHeight * y,
|
|
||||||
sx = tileWidth,
|
|
||||||
sy = tileHeight,
|
|
||||||
scale = 1.0 / dimensionsScaled.x;
|
|
||||||
|
|
||||||
sx = Math.min( sx, dimensionsScaled.x - px );
|
|
||||||
sy = Math.min( sy, dimensionsScaled.y - py );
|
|
||||||
|
|
||||||
if (isSource) {
|
|
||||||
return new $.Rect((x === 0 ? 0 : tileOverlap), (y === 0 ? 0 : tileOverlap), sx, sy);
|
|
||||||
} else if ( imageCoordinates ){
|
|
||||||
return new $.Rect( px, py, sx, sy).times(scale * this.width);
|
|
||||||
} else {
|
|
||||||
return new $.Rect( px, py, sx, sy).times(scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Responsible for retrieving, and caching the
|
* Responsible for retrieving, and caching the
|
||||||
|
@ -446,7 +446,7 @@ $.Viewer = function( options ) {
|
|||||||
delete this.drawerOptions.useCanvas;
|
delete this.drawerOptions.useCanvas;
|
||||||
}
|
}
|
||||||
let drawerPriority = Array.isArray(this.drawer) ? this.drawer : [this.drawer];
|
let drawerPriority = Array.isArray(this.drawer) ? this.drawer : [this.drawer];
|
||||||
let drawersToTry = drawerPriority.filter(d => ['webgl', 'context2d', 'html'].includes(d) || (d.prototype && d.prototype.isOpenSeadragonDrawer) );
|
let drawersToTry = drawerPriority.filter(d => ['webgl', 'canvas', 'html'].includes(d) || (d.prototype && d.prototype.isOpenSeadragonDrawer) );
|
||||||
if(drawerPriority.length !== drawersToTry.length){
|
if(drawerPriority.length !== drawersToTry.length){
|
||||||
$.console.error('An invalid drawer was requested.');
|
$.console.error('An invalid drawer was requested.');
|
||||||
}
|
}
|
||||||
@ -460,9 +460,9 @@ $.Viewer = function( options ) {
|
|||||||
let Drawer = drawersToTry[i];
|
let Drawer = drawersToTry[i];
|
||||||
let optsKey = null;
|
let optsKey = null;
|
||||||
// replace text-based option with appropriate constructor
|
// replace text-based option with appropriate constructor
|
||||||
if (Drawer === 'context2d'){
|
if (Drawer === 'canvas'){
|
||||||
Drawer = $.Context2dDrawer;
|
Drawer = $.Context2dDrawer;
|
||||||
optsKey = 'context2d';
|
optsKey = 'canvas';
|
||||||
} else if (Drawer === 'html'){
|
} else if (Drawer === 'html'){
|
||||||
Drawer = $.HTMLDrawer;
|
Drawer = $.HTMLDrawer;
|
||||||
optsKey = 'html';
|
optsKey = 'html';
|
||||||
@ -473,7 +473,7 @@ $.Viewer = function( options ) {
|
|||||||
optsKey = 'custom';
|
optsKey = 'custom';
|
||||||
}
|
}
|
||||||
// if the drawer is supported, create it and break the loop
|
// if the drawer is supported, create it and break the loop
|
||||||
if (Drawer.prototype.isSupported()){
|
if (Drawer.isSupported()){
|
||||||
this.drawer = new Drawer({
|
this.drawer = new Drawer({
|
||||||
viewer: this,
|
viewer: this,
|
||||||
viewport: this.viewport,
|
viewport: this.viewport,
|
||||||
|
@ -237,7 +237,7 @@
|
|||||||
* @returns {Boolean} returns true if canvas and webgl are supported and
|
* @returns {Boolean} returns true if canvas and webgl are supported and
|
||||||
* three.js has been exposed as a global variable named THREE
|
* three.js has been exposed as a global variable named THREE
|
||||||
*/
|
*/
|
||||||
isSupported(){
|
static isSupported(){
|
||||||
let canvasElement = document.createElement( 'canvas' );
|
let canvasElement = document.createElement( 'canvas' );
|
||||||
let webglContext = $.isFunction( canvasElement.getContext ) &&
|
let webglContext = $.isFunction( canvasElement.getContext ) &&
|
||||||
canvasElement.getContext( 'webgl' );
|
canvasElement.getContext( 'webgl' );
|
||||||
|
@ -242,6 +242,9 @@ $.extend( $.World.prototype, $.EventSource.prototype, /** @lends OpenSeadragon.W
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates (i.e. animates bounds of) all items.
|
* Updates (i.e. animates bounds of) all items.
|
||||||
|
* @function
|
||||||
|
* @param viewportChanged Whether the viewport changed, which indicates that
|
||||||
|
* all TiledImages need to be updated.
|
||||||
*/
|
*/
|
||||||
update: function(viewportChanged) {
|
update: function(viewportChanged) {
|
||||||
var animated = false;
|
var animated = false;
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
// debugMode: true,
|
// debugMode: true,
|
||||||
zoomPerScroll: 1.02,
|
zoomPerScroll: 1.02,
|
||||||
showNavigator: testNavigator,
|
showNavigator: testNavigator,
|
||||||
drawer: ['context2d', 'html'],
|
drawer: ['canvas', 'html'],
|
||||||
// defaultZoomLevel: 2,
|
// defaultZoomLevel: 2,
|
||||||
// homeFillsViewer: true,
|
// homeFillsViewer: true,
|
||||||
// sequenceMode: true,
|
// sequenceMode: true,
|
||||||
|
@ -65,7 +65,7 @@
|
|||||||
<div class="mirrored">
|
<div class="mirrored">
|
||||||
<div>
|
<div>
|
||||||
<h3>Context2d drawer (default in OSD <= 4.1.0)</h3>
|
<h3>Context2d drawer (default in OSD <= 4.1.0)</h3>
|
||||||
<div id="context2d" class="viewer-container"></div>
|
<div id="canvasdrawer" class="viewer-container"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
@ -15,9 +15,9 @@ const labels = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Double viewer setup for comparison - Context2dDrawer and WebGLDrawer
|
//Double viewer setup for comparison - Context2dDrawer and WebGLDrawer
|
||||||
// viewer1: context2d drawer
|
// viewer1: canvas drawer
|
||||||
let viewer1 = window.viewer1 = OpenSeadragon({
|
let viewer1 = window.viewer1 = OpenSeadragon({
|
||||||
id: "context2d",
|
id: "canvasdrawer",
|
||||||
prefixUrl: "../../build/openseadragon/images/",
|
prefixUrl: "../../build/openseadragon/images/",
|
||||||
minZoomImageRatio:0.01,
|
minZoomImageRatio:0.01,
|
||||||
maxZoomPixelRatio:100,
|
maxZoomPixelRatio:100,
|
||||||
@ -25,7 +25,7 @@ let viewer1 = window.viewer1 = OpenSeadragon({
|
|||||||
crossOriginPolicy: 'Anonymous',
|
crossOriginPolicy: 'Anonymous',
|
||||||
ajaxWithCredentials: false,
|
ajaxWithCredentials: false,
|
||||||
// maxImageCacheCount: 30,
|
// maxImageCacheCount: 30,
|
||||||
drawer:'context2d',
|
drawer:'canvas',
|
||||||
blendTime:0
|
blendTime:0
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -241,7 +241,7 @@
|
|||||||
* @returns {Boolean} returns true if canvas and webgl are supported and
|
* @returns {Boolean} returns true if canvas and webgl are supported and
|
||||||
* three.js has been exposed as a global variable named THREE
|
* three.js has been exposed as a global variable named THREE
|
||||||
*/
|
*/
|
||||||
isSupported(){
|
static isSupported(){
|
||||||
let canvasElement = document.createElement( 'canvas' );
|
let canvasElement = document.createElement( 'canvas' );
|
||||||
let webglContext = $.isFunction( canvasElement.getContext ) &&
|
let webglContext = $.isFunction( canvasElement.getContext ) &&
|
||||||
canvasElement.getContext( 'webgl' );
|
canvasElement.getContext( 'webgl' );
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
var done = assert.async();
|
var done = assert.async();
|
||||||
createViewer({
|
createViewer({
|
||||||
tileSources: '/test/data/testpattern.dzi',
|
tileSources: '/test/data/testpattern.dzi',
|
||||||
drawer: 'context2d', // this test only makes sense for certain drawers
|
drawer: 'canvas', // this test only makes sense for certain drawers
|
||||||
});
|
});
|
||||||
|
|
||||||
viewer.addHandler('open', function handler(event) {
|
viewer.addHandler('open', function handler(event) {
|
||||||
@ -76,7 +76,7 @@
|
|||||||
var done = assert.async();
|
var done = assert.async();
|
||||||
createViewer({
|
createViewer({
|
||||||
tileSources: '/test/data/testpattern.dzi',
|
tileSources: '/test/data/testpattern.dzi',
|
||||||
drawer: 'context2d' // test only makes sense for this drawer
|
drawer: 'canvas' // test only makes sense for this drawer
|
||||||
});
|
});
|
||||||
var drawer = viewer.drawer;
|
var drawer = viewer.drawer;
|
||||||
|
|
||||||
|
@ -45,9 +45,9 @@
|
|||||||
// if ( viewer && viewer.close ) {
|
// if ( viewer && viewer.close ) {
|
||||||
// viewer.close();
|
// viewer.close();
|
||||||
// }
|
// }
|
||||||
// if (viewer && viewer.destroy){
|
if (viewer && viewer.destroy){
|
||||||
// viewer.destroy();
|
viewer.destroy();
|
||||||
// }
|
}
|
||||||
|
|
||||||
viewer = null;
|
viewer = null;
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@
|
|||||||
QUnit.test('update', function(assert) {
|
QUnit.test('update', function(assert) {
|
||||||
var done = assert.async();
|
var done = assert.async();
|
||||||
var handlerCount = 0;
|
var handlerCount = 0;
|
||||||
var testTileDrawingEvent = viewer.drawerOptions.type === 'context2d';
|
var testTileDrawingEvent = viewer.drawerOptions.type === 'canvas';
|
||||||
let expectedHandlers = testTileDrawingEvent ? 4 : 3;
|
let expectedHandlers = testTileDrawingEvent ? 4 : 3;
|
||||||
|
|
||||||
viewer.addHandler('open', function(event) {
|
viewer.addHandler('open', function(event) {
|
||||||
|
Loading…
Reference in New Issue
Block a user