Commit ee4bfa56 authored by Joshua Gould's avatar Joshua Gould

save image size

parent 2797fbab
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -2950,29 +2950,28 @@ morpheus.HeatMap.prototype = { ...@@ -2950,29 +2950,28 @@ morpheus.HeatMap.prototype = {
if (this.isDendrogramVisible(true)) { if (this.isDendrogramVisible(true)) {
totalSize.height += this.columnDendrogram.getUnscaledHeight(); totalSize.height += this.columnDendrogram.getUnscaledHeight();
} }
var maxHeaderHeight = 0; var maxRowHeaderHeight = 0;
var maxHeaderWidth = 0;
for (var i = 0, length = this.rowTracks.length; i < length; i++) { for (var i = 0, length = this.rowTracks.length; i < length; i++) {
var track = this.rowTracks[i]; var track = this.rowTracks[i];
if (track.isVisible()) { if (track.isVisible()) {
var headerSize = this.rowTrackHeaders[i].getPrintSize(); var headerSize = this.rowTrackHeaders[i].getPrintSize();
totalSize.width += Math.max(headerSize.width, track totalSize.width += Math.max(headerSize.width, track
.getPrintSize().width); .getPrintSize().width);
maxHeaderHeight = Math.max(maxHeaderHeight, headerSize.height); maxRowHeaderHeight = Math.max(maxRowHeaderHeight, headerSize.height);
} }
} }
totalSize.height += maxHeaderHeight; var maxColumnHeaderWidth = 0;
var columnTrackHeightSum = 0;
for (var i = 0, length = this.columnTracks.length; i < length; i++) { for (var i = 0, length = this.columnTracks.length; i < length; i++) {
var track = this.columnTracks[i]; var track = this.columnTracks[i];
if (track.isVisible()) { if (track.isVisible()) {
totalSize.height += track.getPrintSize().height; columnTrackHeightSum += track.getPrintSize().height;
maxHeaderWidth = Math.max(maxHeaderWidth, maxColumnHeaderWidth = Math.max(maxColumnHeaderWidth,
this.columnTrackHeaders[i].getPrintSize().width); this.columnTrackHeaders[i].getPrintSize().width);
} }
} }
maxHeaderWidth += 10; // spacer between column track header and heat totalSize.height += Math.max(columnTrackHeightSum, maxRowHeaderHeight) + morpheus.HeatMap.SPACE_BETWEEN_HEAT_MAP_AND_ANNOTATIONS;
// map totalSize.width += maxColumnHeaderWidth + morpheus.HeatMap.SPACE_BETWEEN_HEAT_MAP_AND_ANNOTATIONS;
totalSize.width += maxHeaderWidth;
// color legend // color legend
if (options.legend) { if (options.legend) {
var legendHeight = this.heatmap.getColorScheme().getNames() != null ? this.heatmap var legendHeight = this.heatmap.getColorScheme().getNames() != null ? this.heatmap
...@@ -3021,15 +3020,15 @@ morpheus.HeatMap.prototype = { ...@@ -3021,15 +3020,15 @@ morpheus.HeatMap.prototype = {
var totalSize = this.getTotalSize(options); var totalSize = this.getTotalSize(options);
var legendHeight = 0; var legendHeight = 0;
if (options.legend) { if (options.legend) {
legendHeight = this.heatmap.getColorScheme().getNames() != null ? this.heatmap
.getColorScheme().getNames().length * 14
: 40;
context.save(); context.save();
context.translate(50, 0); context.translate(50, 0);
morpheus.HeatMapColorSchemeLegend.drawColorScheme(context, morpheus.HeatMapColorSchemeLegend.drawColorScheme(context,
this.heatmap.getColorScheme(), 200, true); this.heatmap.getColorScheme(), 200, true);
context.restore(); context.restore();
legendHeight = this.heatmap.getColorScheme().getNames() != null ? this.heatmap
.getColorScheme().getNames().length * 14
: 40;
} }
context.save(); context.save();
context.translate(4, legendHeight); context.translate(4, legendHeight);
...@@ -3046,7 +3045,7 @@ morpheus.HeatMap.prototype = { ...@@ -3046,7 +3045,7 @@ morpheus.HeatMap.prototype = {
}), this.getProject().getColumnColorModel()); }), this.getProject().getColumnColorModel());
columnTrackLegend.draw({}, context); columnTrackLegend.draw({}, context);
context.restore(); context.restore();
// row color legend // row color legend to the right of column color legend
var columnTrackLegendSize = columnTrackLegend.getPreferredSize(); var columnTrackLegendSize = columnTrackLegend.getPreferredSize();
context.save(); context.save();
context.translate(4 + columnTrackLegendSize.width, legendHeight); context.translate(4 + columnTrackLegendSize.width, legendHeight);
...@@ -3066,22 +3065,25 @@ morpheus.HeatMap.prototype = { ...@@ -3066,22 +3065,25 @@ morpheus.HeatMap.prototype = {
columnTrackLegendSize.height); columnTrackLegendSize.height);
var heatmapY = this.isDendrogramVisible(true) ? this.columnDendrogram var heatmapY = this.isDendrogramVisible(true) ? this.columnDendrogram
.getUnscaledHeight() : 0; .getUnscaledHeight() : 0;
if (legendHeight > 0) { heatmapY += legendHeight;
heatmapY += legendHeight + morpheus.HeatMap.SPACE_BETWEEN_HEAT_MAP_AND_ANNOTATIONS;
}
var columnTrackY = heatmapY; var columnTrackY = heatmapY;
var heatmapX = this.isDendrogramVisible(false) ? this.rowDendrogram var heatmapX = this.isDendrogramVisible(false) ? this.rowDendrogram
.getUnscaledWidth() : 0; .getUnscaledWidth() : 0;
var isColumnTrackVisible = false;
for (var i = 0, length = this.columnTracks.length; i < length; i++) { for (var i = 0, length = this.columnTracks.length; i < length; i++) {
var track = this.columnTracks[i]; var track = this.columnTracks[i];
if (track.isVisible()) { if (track.isVisible()) {
var header = this.columnTrackHeaders[i]; var header = this.columnTrackHeaders[i];
heatmapX = Math.max(heatmapX, header.getPrintSize().width); heatmapX = Math.max(heatmapX, header.getPrintSize().width);
var height = track.getPrintSize().height; heatmapY += track.getPrintSize().height;
heatmapY += height; isColumnTrackVisible = true;
} }
} }
if (isColumnTrackVisible) {
heatmapY += morpheus.HeatMap.SPACE_BETWEEN_HEAT_MAP_AND_ANNOTATIONS;
}
// check if row headers are taller than column tracks
for (var i = 0, length = this.rowTracks.length; i < length; i++) { for (var i = 0, length = this.rowTracks.length; i < length; i++) {
var track = this.rowTracks[i]; var track = this.rowTracks[i];
if (track.isVisible()) { if (track.isVisible()) {
...@@ -3102,19 +3104,6 @@ morpheus.HeatMap.prototype = { ...@@ -3102,19 +3104,6 @@ morpheus.HeatMap.prototype = {
this.rowDendrogram.draw(rowDendrogramClip, context); this.rowDendrogram.draw(rowDendrogramClip, context);
context.restore(); context.restore();
} }
if (this.isDendrogramVisible(true)) {
context.save();
context.translate(heatmapX, legendHeight);
var columnDendrogramClip = {
x: 0,
y: 0,
width: heatmapPrefSize.width,
height: this.columnDendrogram.getUnscaledHeight()
};
this.columnDendrogram.prePaint(columnDendrogramClip, context);
this.columnDendrogram.draw(columnDendrogramClip, context);
context.restore();
}
for (var i = 0, length = this.columnTracks.length; i < length; i++) { for (var i = 0, length = this.columnTracks.length; i < length; i++) {
var track = this.columnTracks[i]; var track = this.columnTracks[i];
...@@ -3140,7 +3129,7 @@ morpheus.HeatMap.prototype = { ...@@ -3140,7 +3129,7 @@ morpheus.HeatMap.prototype = {
width: headerSize.width, width: headerSize.width,
height: headerSize.height height: headerSize.height
}; };
context.translate(heatmapX - 10, columnTrackY + trackClip.height); context.translate(heatmapX - 2, columnTrackY + trackClip.height);
header.print(headerClip, context); header.print(headerClip, context);
context.restore(); context.restore();
columnTrackY += Math.max(headerClip.height, trackClip.height); columnTrackY += Math.max(headerClip.height, trackClip.height);
......
...@@ -38,7 +38,7 @@ morpheus.HeatMapTrackColorLegend.prototype = { ...@@ -38,7 +38,7 @@ morpheus.HeatMapTrackColorLegend.prototype = {
} }
return { return {
width : xpix, width : xpix,
height : maxYPix > 0 ? (maxYPix + 30) : 0 height : maxYPix > 0 ? (maxYPix + 12) : 0
}; };
}, },
draw : function(clip, context) { draw : function(clip, context) {
......
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