make the legend movable
The legend ("key" in Gnuplot speak) is no longer part of the image.
Instead it is a floating&movable overlay.
In the gallery we still use the legend/key in the image.
This commit is contained in:
@@ -3,7 +3,7 @@ package org.lucares.pdb.plot.api;
|
||||
public class RenderOptions {
|
||||
private int height;
|
||||
private int width;
|
||||
private boolean keyOutside;
|
||||
private boolean showKey;
|
||||
private boolean renderLabels;
|
||||
|
||||
public int getHeight() {
|
||||
@@ -22,12 +22,12 @@ public class RenderOptions {
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public boolean isKeyOutside() {
|
||||
return keyOutside;
|
||||
public boolean isShowKey() {
|
||||
return showKey;
|
||||
}
|
||||
|
||||
public void setKeyOutside(final boolean keyOutside) {
|
||||
this.keyOutside = keyOutside;
|
||||
public void setShowKey(final boolean showKey) {
|
||||
this.showKey = showKey;
|
||||
}
|
||||
|
||||
public boolean isRenderLabels() {
|
||||
|
||||
@@ -50,18 +50,16 @@ public class GnuplotFileGenerator implements Appender {
|
||||
|
||||
appendln(result, "set nokey");
|
||||
} else {
|
||||
if (settings.isKeyOutside()) {
|
||||
appendfln(result, "set key outside");
|
||||
} else {
|
||||
|
||||
// make sure left and right margins are always the same
|
||||
// this is need to be able to zoom in by selecting a region
|
||||
// (horizontal: 1 unit = 10px; vertical: 1 unit = 19px)
|
||||
appendln(result, "set lmargin 11"); // margin 11 -> 110px
|
||||
appendln(result, "set rmargin 11"); // margin 11 -> 110px
|
||||
appendln(result, "set tmargin 3"); // margin 3 -> 57px - marker (1)
|
||||
appendln(result, "set bmargin 4"); // margin 4 -> 76
|
||||
if (!settings.isShowKey()) {
|
||||
appendfln(result, "set nokey");
|
||||
}
|
||||
// make sure left and right margins are always the same
|
||||
// this is need to be able to zoom in by selecting a region
|
||||
// (horizontal: 1 unit = 10px; vertical: 1 unit = 19px)
|
||||
appendln(result, "set lmargin 11"); // margin 11 -> 110px
|
||||
appendln(result, "set rmargin 11"); // margin 11 -> 110px
|
||||
appendln(result, "set tmargin 3"); // margin 3 -> 57px - marker (1)
|
||||
appendln(result, "set bmargin 4"); // margin 4 -> 76
|
||||
}
|
||||
|
||||
// appendfln(result, "set xrange [-1:1]");
|
||||
|
||||
@@ -30,7 +30,7 @@ public class GnuplotSettings {
|
||||
private YAxisDefinition y1;
|
||||
private YAxisDefinition y2;
|
||||
private AggregateHandlerCollection aggregates;
|
||||
private boolean keyOutside = false;
|
||||
private boolean showKey = false;
|
||||
|
||||
private AxisSettings xAxisSettings = new AxisSettings();
|
||||
private boolean renderLabels = true;
|
||||
@@ -101,12 +101,12 @@ public class GnuplotSettings {
|
||||
return aggregates;
|
||||
}
|
||||
|
||||
public void setKeyOutside(final boolean keyOutside) {
|
||||
this.keyOutside = keyOutside;
|
||||
public void setShowKey(final boolean showKey) {
|
||||
this.showKey = showKey;
|
||||
}
|
||||
|
||||
public boolean isKeyOutside() {
|
||||
return keyOutside;
|
||||
public boolean isShowKey() {
|
||||
return showKey;
|
||||
}
|
||||
|
||||
public void renderLabels(final boolean renderLabels) {
|
||||
|
||||
@@ -126,7 +126,7 @@ public class Plotter {
|
||||
gnuplotSettings.setY1(plotSettings.getY1());
|
||||
gnuplotSettings.setY2(plotSettings.getY2());
|
||||
gnuplotSettings.setAggregates(plotSettings.getAggregates());
|
||||
gnuplotSettings.setKeyOutside(renderOptions.isKeyOutside());
|
||||
gnuplotSettings.setShowKey(renderOptions.isShowKey());
|
||||
gnuplotSettings.renderLabels(renderOptions.isRenderLabels());
|
||||
gnuplot.plot(gnuplotSettings, dataSeries);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user