PlotZoomPlug.js
4.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/**
* Project : AMDA-NG
* Name : PlotZoomPlug.js
* @plugin amdaPlotComp.PlotZoomPlug
* @extends Ext.util.Observable
* @ptype plotZoomPlugin
* @brief Plot Zoom UI (View)
* @author Benjamin
* @version $Id: PlotZoomPlug.js
********************************************************************************
* FT Id : Date : Name - Description
*******************************************************************************
*/
// Define a new class 'amdaPlotComp.PlotZoomPlug' that extends 'Ext.util.Observable'
Ext.define('amdaPlotComp.PlotZoomPlug', {
extend: 'Ext.util.Observable',
alias: 'plugin.plotZoomPlugin',
requires: ['amdaPlotComp.intervalSelection.IntervalSelection'],
// Declare a variable to hold the interval selection component
intervalSelectionCmp: null,
// Constructor function for the class
constructor: function (config) {
// Apply the configuration to this instance and call the parent class's constructor
Ext.apply(this, config);
this.callParent(arguments);
},
// Function to be called when the object is destroyed
onDestroy: function () {
// Set the interval selection component to null
this.intervalSelectionCmp = null;
},
// Initialization function for the class
init: function (cmp) {
// Set the host component for this instance
this.hostCmp = cmp;
},
// Function to set the minimum value of the interval selection component
setMinValue: function (min) {
if (!this.intervalSelectionCmp)
return;
this.intervalSelectionCmp.setField1Value(min);
},
// Function to set the maximum value of the interval selection component
setMaxValue: function (max) {
if (!this.intervalSelectionCmp)
return;
this.intervalSelectionCmp.setField2Value(max);
},
/**
* Function to create and show a window with specific configuration
*/
show: function (interactiveId, zoomType, panelId, panelContext) {
let config = {
id: 'plot-zoom-win-' + this.hostCmp.ownerCt.getId(),
interactiveId: interactiveId,
panelId: panelId,
panelContext: panelContext,
hostCmp: this.hostCmp,
renderTo: this.hostCmp.ownerCt.body,
listeners: {
scope: this,
beforeclose: function () {
this.hostCmp.panelImage.hidePanelMarker();
this.hostCmp.panelImage.stopZoom();
},
show: function (win, eOpts) {
this.hostCmp.panelImage.showPanelMarker(panelId);
}
},
getConstrainVector: function (constrainTo) {
const self = this;
if (self.constrain || self.constrainHeader) {
constrainTo = constrainTo || (self.floatParent && self.floatParent.getTargetEl()) || self.container || self.el.getScopeParent();
return (self.constrainHeader ? self.header.el : self.el).getConstrainVector(constrainTo);
}
}
};
if (this.intervalSelectionCmp) { this.close() };
let intervalSelectionCmpType;
switch (zoomType) {
case 'timeAxis':
intervalSelectionCmpType = 'amdaPlotComp.intervalSelection.DateZoomIntervalSelection';
break;
case 'y-left':
case 'y-right':
case 'xaxis_id':
intervalSelectionCmpType = 'amdaPlotComp.intervalSelection.NumberZoomIntervalSelection';
let title = "";
if (zoomType === 'y-left') {
title = 'Zoom on Y Left axis';
} else if (zoomType === 'y-right') {
title = 'Zoom on Y Right axis';
} else {
title = 'Zoom on X axis';
}
config["type"] = zoomType;
config["title"] = title;
break;
case 'plotFunction':
intervalSelectionCmpType = 'amdaPlotComp.intervalSelection.PlotFunctionIntervalSelection';
break;
}
// Create a new instance of the interval selection component with the specified type and configuration
this.intervalSelectionCmp = Ext.create(intervalSelectionCmpType, config);
// Add a listener for the destroy event of the interval selection component
this.intervalSelectionCmp.on('destroy', this.onDestroy, this);
// Show the interval selection component
this.intervalSelectionCmp.show();
},
// Function to close the interval selection component
close: function () {
if (this.intervalSelectionCmp == null)
return;
this.intervalSelectionCmp.close();
},
// Function to reset the minimum and maximum values of the interval selection component
resetMinMaxValue: function () {
this.intervalSelectionCmp.reset();
}
});