Commit a620bde9 authored by Joshua Gould's avatar Joshua Gould

save image color bar size

parent bc8c2428
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -229,7 +229,7 @@ morpheus.ChartTool2 = function (chartOptions) {
morpheus.ChartTool2.getPlotlyDefaults = function () {
var layout = {
hovermode: 'closest',
autosize: false,
autosize: true,
paper_bgcolor: 'rgb(255,255,255)',
plot_bgcolor: 'rgb(229,229,229)',
showlegend: false,
......@@ -250,8 +250,7 @@ morpheus.ChartTool2.getPlotlyDefaults = function () {
showline: false,
showticklabels: true,
tickcolor: 'rgb(127,127,127)',
ticks: 'outside',
type: 'linear'
ticks: 'outside'
},
yaxis: {
zeroline: false,
......@@ -263,8 +262,7 @@ morpheus.ChartTool2.getPlotlyDefaults = function () {
showline: false,
showticklabels: true,
tickcolor: 'rgb(127,127,127)',
ticks: 'outside',
type: 'linear'
ticks: 'outside'
}
};
var config = {
......
morpheus.CanvasUtil = function() {
morpheus.CanvasUtil = function () {
};
morpheus.CanvasUtil.dragging = false;
morpheus.CanvasUtil.FONT_NAME = '"Helvetica Neue",Helvetica,Arial,sans-serif';
morpheus.CanvasUtil.FONT_COLOR = 'rgb(34, 34, 34)';
morpheus.CanvasUtil.getPreferredSize = function(c) {
morpheus.CanvasUtil.getPreferredSize = function (c) {
var size = c.getPreferredSize();
var prefWidth = c.getPrefWidth();
var prefHeight = c.getPrefHeight();
......@@ -24,7 +24,7 @@ if (typeof window !== 'undefined' && 'devicePixelRatio' in window) {
}
}
morpheus.CanvasUtil.setBounds = function(canvas, bounds) {
morpheus.CanvasUtil.setBounds = function (canvas, bounds) {
var backingScale = morpheus.CanvasUtil.BACKING_SCALE;
if (bounds.height != null) {
......@@ -43,7 +43,7 @@ morpheus.CanvasUtil.setBounds = function(canvas, bounds) {
}
};
morpheus.CanvasUtil.drawShape = function(context, shape, x, y, size2) {
morpheus.CanvasUtil.drawShape = function (context, shape, x, y, size2) {
if (size2 < 0) {
return;
}
......@@ -125,20 +125,20 @@ morpheus.CanvasUtil.drawShape = function(context, shape, x, y, size2) {
context.stroke();
};
morpheus.CanvasUtil.drawLine = function(context, x1, y1, x2, y2) {
morpheus.CanvasUtil.drawLine = function (context, x1, y1, x2, y2) {
context.beginPath();
context.moveTo(x1, y1);
context.lineTo(x2, y2);
context.stroke();
};
morpheus.CanvasUtil.resetTransform = function(context) {
morpheus.CanvasUtil.resetTransform = function (context) {
context.setTransform(1, 0, 0, 1, 0, 0);
if (morpheus.CanvasUtil.BACKING_SCALE !== 1) {
context.scale(morpheus.CanvasUtil.BACKING_SCALE,
morpheus.CanvasUtil.BACKING_SCALE);
morpheus.CanvasUtil.BACKING_SCALE);
}
};
morpheus.CanvasUtil.bezierCurveTo = function(context, start, end) {
morpheus.CanvasUtil.bezierCurveTo = function (context, start, end) {
var m1 = (start[1] + end[1]) / 2;
context.beginPath();
context.moveTo(start[0], start[1]);
......@@ -146,24 +146,24 @@ morpheus.CanvasUtil.bezierCurveTo = function(context, start, end) {
context.bezierCurveTo(start[0], m1, end[0], m1, end[0], end[1]);
context.stroke();
};
morpheus.CanvasUtil.createCanvas = function() {
morpheus.CanvasUtil.createCanvas = function () {
var $c = $('<canvas></canvas>');
$c.attr('tabindex', '0');
$c.css({
cursor : 'default',
outline : 0,
overflow : 'hidden',
position : 'absolute',
'z-index' : 1
cursor: 'default',
outline: 0,
overflow: 'hidden',
position: 'absolute',
'z-index': 1
});
return $c[0];
};
morpheus.CanvasUtil.getHeaderStringWidth = function(context, s) {
morpheus.CanvasUtil.getHeaderStringWidth = function (context, s) {
context.font = '14px ' + morpheus.CanvasUtil.FONT_NAME;
return context.measureText(s).width + 18;
};
morpheus.CanvasUtil.getVectorStringWidth = function(context, vector, positions,
end) {
morpheus.CanvasUtil.getVectorStringWidth = function (context, vector, positions,
end) {
if (positions.getSize() < 6) {
return 0;
}
......@@ -177,7 +177,8 @@ morpheus.CanvasUtil.getVectorStringWidth = function(context, vector, positions,
var toString = morpheus.VectorTrack.vectorToString(vector);
var maxWidth = 0;
// var maxWidth2 = 0;
for (var i = 0, n = end <= 0 ? vector.size() : Math.min(end, vector.size()); i < n; i++) {
var n = end <= 0 ? vector.size() : Math.min(end, vector.size());
for (var i = 0; i < n; i++) {
var value = vector.getValue(i);
if (value != null && value != '') {
value = toString(value);
......@@ -194,7 +195,7 @@ morpheus.CanvasUtil.getVectorStringWidth = function(context, vector, positions,
}
return maxWidth > 0 ? (maxWidth + 2) : maxWidth;
};
morpheus.CanvasUtil.clipString = function(context, string, availTextWidth) {
morpheus.CanvasUtil.clipString = function (context, string, availTextWidth) {
var textWidth = context.measureText(string).width;
if (textWidth <= availTextWidth) {
return string;
......@@ -215,32 +216,32 @@ morpheus.CanvasUtil.clipString = function(context, string, availTextWidth) {
}
return string + clipString;
};
morpheus.CanvasUtil.toSVG = function(drawable, file) {
morpheus.CanvasUtil.toSVG = function (drawable, file) {
var totalSize = {
width : drawable.getWidth(),
height : drawable.getHeight()
width: drawable.getWidth(),
height: drawable.getHeight()
};
var context = new C2S(totalSize.width, totalSize.height);
context.save();
drawable.draw({
x : 0,
y : 0,
width : totalSize.width,
height : totalSize.height
x: 0,
y: 0,
width: totalSize.width,
height: totalSize.height
}, context);
context.restore();
var svg = context.getSerializedSvg();
var blob = new Blob([ svg ], {
type : 'text/plain;charset=utf-8'
var blob = new Blob([svg], {
type: 'text/plain;charset=utf-8'
});
saveAs(blob, file);
};
morpheus.CanvasUtil.getMousePos = function(element, event, useDelta) {
morpheus.CanvasUtil.getMousePos = function (element, event, useDelta) {
return morpheus.CanvasUtil.getMousePosWithScroll(element, event, 0, 0,
useDelta);
useDelta);
};
morpheus.CanvasUtil.getClientXY = function(event, useDelta) {
morpheus.CanvasUtil.getClientXY = function (event, useDelta) {
var clientX;
var clientY;
if (event.pointers) {
......@@ -256,21 +257,21 @@ morpheus.CanvasUtil.getClientXY = function(event, useDelta) {
clientY = event.clientY;
}
return {
x : clientX,
y : clientY
x: clientX,
y: clientY
};
};
morpheus.CanvasUtil.getMousePosWithScroll = function(element, event, scrollX,
scrollY, useDelta) {
morpheus.CanvasUtil.getMousePosWithScroll = function (element, event, scrollX,
scrollY, useDelta) {
return morpheus.CanvasUtil._getMousePosWithScroll(element, scrollX,
scrollY, morpheus.CanvasUtil.getClientXY(event, useDelta));
scrollY, morpheus.CanvasUtil.getClientXY(event, useDelta));
};
morpheus.CanvasUtil._getMousePosWithScroll = function(element, scrollX,
scrollY, clientXY) {
morpheus.CanvasUtil._getMousePosWithScroll = function (element, scrollX,
scrollY, clientXY) {
var rect = element.getBoundingClientRect();
return {
x : clientXY.x - rect.left + scrollX,
y : clientXY.y - rect.top + scrollY
x: clientXY.x - rect.left + scrollX,
y: clientXY.y - rect.top + scrollY
};
};
......@@ -3033,7 +3033,6 @@ morpheus.HeatMap.prototype = {
var totalSize = this.getTotalSize(options);
var legendHeight = 0;
if (options.legend) {
context.save();
context.translate(50, 0);
morpheus.HeatMapColorSchemeLegend.drawColorScheme(context,
......@@ -3143,7 +3142,6 @@ morpheus.HeatMap.prototype = {
width: heatmapPrefSize.width,
height: track.getPrintSize().height
};
track.print(trackClip, context);
context.restore();
// draw header
......@@ -3154,7 +3152,7 @@ morpheus.HeatMap.prototype = {
x: 0,
y: 0,
width: headerSize.width,
height: headerSize.height
height: trackClip.height
};
context.translate(heatmapX - 2, columnTrackY + trackClip.height);
header.print(headerClip, context);
......
......@@ -258,7 +258,6 @@ morpheus.VectorTrack.prototype = {
if (this.isRenderAs(morpheus.VectorTrack.RENDER.BAR)) {
width += this.settings.barSize;
}
if (this.isRenderAs(morpheus.VectorTrack.RENDER.COLOR)) {
width += this.settings.colorBarSize;
}
......@@ -271,7 +270,6 @@ morpheus.VectorTrack.prototype = {
if (!forPrint && !this.isRenderAs(morpheus.VectorTrack.RENDER.MOLECULE)) {
width = Math.min(300, width);
}
if (this.isRenderAs(morpheus.VectorTrack.RENDER.ARC)) {
width += this.settings.arcSize;
}
......
......@@ -310,10 +310,11 @@ morpheus.VectorTrackHeader.prototype = {
var context = this.canvas.getContext('2d');
context.font = this.defaultFontHeight + 'px '
+ morpheus.CanvasUtil.FONT_NAME;
var width = 4 + context.measureText(this.name).width;
var textWidth = 4 + context.measureText(this.name).width;
return {
width: width,
height: this.getUnscaledHeight()
width: textWidth,
height: this.defaultFontHeight
+ morpheus.VectorTrackHeader.FONT_OFFSET
};
},
getSortKeys: function () {
......
Markdown is supported
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