Commit 800d716b authored by Caillat Michel's avatar Caillat Michel
Browse files

A superclass for contour and box

parent 6199091b
<script>
class ShapesFactory {
static enter(what) {
console.group(this.name + "." + what);
}
static exit() {
console.groupEnd();
}
static get selection() { return this.hasOwnProperty('_selection') ? this._selection : void 0 ;}
static set selection(x) { this._selection = x; }
constructor (sliceViewer, infosBlock) {
ShapesFactory.enter(this.constructor.name);
this.sliceViewer = sliceViewer;
this.infosBlock = infosBlock;
this.map = sliceViewer.getMap();
this.source = new ol.source.Vector();
this.layer = new ol.layer.Vector({source: this.source, style: this.style_f});
this.map.addLayer(this.layer);
this.visible = true;
this.overlay = null;
this.container = document.getElementById('popup');
this.content = document.getElementById('popup-content');
this.closer = document.getElementById('popup-closer');
this.highlightStyle = new ol.style.Style({
fill: new ol.style.Fill({
color: 'rgba(255,255,255,0.7)'
}),
stroke: new ol.style.Stroke({
color: '#3399CC',
width: 3
})
});
this.style = {
'LineString': new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'blue',
//lineDash: [2],
width: 1
}),
fill: new ol.style.Fill({
color: 'rgba(0, 0, 255, 0.6)'
})
}),
'Polygon': new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'green',
lineDash: [2],
width: 1
}),
fill: new ol.style.Fill({
color: 'rgba(0, 0, 255, 0.1)'
})
})
};
this.style_f = (feature) => {
return this.style[feature.getGeometry().getType()];
};
ShapesFactory.exit()
};
highlight(shape) {
ShapesFactory.enter(this.highlight.name);
let selection = ShapesFactory.selection;
if (selection) {
selection.setStyle(undefined);
}
shape.setStyle(this.highlightStyle);
ShapesFactory.exit();
}
hide() {
ShapesFactory.enter(this.hide.name);
this.layer.setVisible(false);
ShapesFactory.exit();
}
show() {
ShapesFactory.enter(this.show.name);
this.layer.setVisible(true);
ShapesFactory.exit();
}
clear() {
ShapesFactory.enter(this.clear.name);
if (this.lastSelectedContour) this.lastSelectedContour.setStyle(undefined);
this.lastSelectedContour = null;
this.source.clear();
ShapesFactory.exit();
}
} // end of class ShapesFactory
</script>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment