Minor cosmetics -- added option to (de)activate numbering of graph legend entries.

This commit is contained in:
Marcel Kronfeld 2010-09-01 14:39:19 +00:00
parent 49b4c99529
commit 8aeb94411e
8 changed files with 44 additions and 31 deletions

View File

@ -84,6 +84,11 @@ public class FunctionArea extends DArea implements Serializable {
* Indicate whether graphs should be annotated with tool tips if pointed to with the mouse.
*/
private boolean doShowGraphToolTips = true;
/**
* Indicate whether graph legend entries should show their unique number.
*/
private boolean appendIndexInLegend = true;
/**
*
@ -1101,7 +1106,7 @@ public class FunctionArea extends DArea implements Serializable {
if (!on)
legendBox = null;
else
legendBox = new GraphPointSetLegend(m_PointSetContainer, true);
legendBox = new GraphPointSetLegend(m_PointSetContainer, isAppendIndexInLegend());
repaint();
}
@ -1154,7 +1159,7 @@ public class FunctionArea extends DArea implements Serializable {
*
*/
public void updateLegend() {
GraphPointSetLegend lb = new GraphPointSetLegend(m_PointSetContainer, true);
GraphPointSetLegend lb = new GraphPointSetLegend(m_PointSetContainer, isAppendIndexInLegend() );
setLegend(lb);
}
@ -1176,4 +1181,12 @@ public class FunctionArea extends DArea implements Serializable {
public boolean isShowGraphToolTips() {
return doShowGraphToolTips;
}
public void setAppendIndexInLegend(boolean appendIndexInLegend) {
this.appendIndexInLegend = appendIndexInLegend;
}
public boolean isAppendIndexInLegend() {
return appendIndexInLegend;
}
}

View File

@ -83,7 +83,7 @@ public class GraphWindow {
try {
if ((client==null) || client.getHostName().equals(InetAddress.getLocalHost().getHostName())) {
if (TRACE) System.out.println("no RMI");
m_Plotter = new Plot(PlotName,strx,stry);
m_Plotter = new Plot(PlotName, strx, stry, true);
}
else {
m_Plotter = (PlotInterface) RMIProxyRemote.newInstance(new Plot(PlotName,strx,stry,false), m_MainAdapterClient);

View File

@ -74,14 +74,8 @@ public class Plot implements PlotInterface, Serializable {
* You might want to try to assign the x-range as x and y-range as y array
* parameters.
*/
public Plot(String PlotName, String xname, String yname, double[] x,
double[] y) {
if (TRACE)
System.out.println("Constructor Plot " + PlotName);
m_xname = xname;
m_yname = yname;
m_PlotName = PlotName;
init();
public Plot(String PlotName, String xname, String yname, double[] x, double[] y) {
this(PlotName, xname, yname, true);
DPointSet points = new DPointSet();
for (int i = 0; i < x.length; i++) {
points.addDPoint(x[i], y[i]);
@ -90,7 +84,12 @@ public class Plot implements PlotInterface, Serializable {
}
/**
*
* A basic constructor.
*
* @param PlotName
* @param xname
* @param yname
* @param init
*/
public Plot(String PlotName, String xname, String yname, boolean init) {
if (TRACE)
@ -102,18 +101,6 @@ public class Plot implements PlotInterface, Serializable {
init();
}
/**
*
*/
public Plot(String PlotName, String xname, String yname) {
if (TRACE)
System.out.println("Constructor Plot " + PlotName);
m_xname = xname;
m_yname = yname;
m_PlotName = PlotName;
init();
}
protected void installButtons(JPanel buttonPan) {
JButton ClearButton = new JButton("Clear");
ClearButton.addActionListener(new ActionListener() {
@ -245,6 +232,20 @@ public class Plot implements PlotInterface, Serializable {
m_Frame.setVisible(true);
}
/**
* Indicate whether graph legend entries should show their unique number.
*/
public void setAppendIndexInLegend(boolean appendIndexInLegend) {
this.m_PlotArea.setAppendIndexInLegend(appendIndexInLegend);
}
/**
* Indicates whether graph legend entries show their unique number.
*/
public boolean isAppendIndexInLegend() {
return m_PlotArea.isAppendIndexInLegend();
}
/**
* Indicate whether the graphs are annotated by tool tip info strings.
* @return true if the graphs are annotated by tool tip info strings

View File

@ -41,7 +41,7 @@ public class TopoPlot extends Plot {
*
*/
public TopoPlot(String PlotName,String xname,String yname) {
super(PlotName, xname, yname);
super(PlotName, xname, yname, true);
//if (TRACE) System.out.println("Constructor TopoPlot "+PlotName);
}
public TopoPlot(String PlotName,String xname,String yname,double[] a, double[] b) {

View File

@ -50,7 +50,7 @@ public class ArchivingPESAII extends AbstractArchiving implements java.io.Serial
////////////////////////////////////////////////////////////////////////////////////
if (this.m_Debug) {
this.m_Plot = new eva2.gui.Plot("Debug SPEAII", "Y1", "Y2");
this.m_Plot = new eva2.gui.Plot("Debug SPEAII", "Y1", "Y2", true);
System.out.println("Population size: " + pop.size());
// plot the population
this.m_Plot.setUnconnectedPoint(0, 0, 11);

View File

@ -51,7 +51,7 @@ public class ArchivingSPEAII extends AbstractArchiving implements java.io.Serial
////////////////////////////////////////////////////////////////////////////////////
if (this.m_Debug) {
this.m_Plot = new eva2.gui.Plot("Debug SPEAII", "Y1", "Y2");
this.m_Plot = new eva2.gui.Plot("Debug SPEAII", "Y1", "Y2", true);
System.out.println("Population size: " + pop.size());
// plot the population
this.m_Plot.setUnconnectedPoint(0, 0, 11);
@ -349,7 +349,7 @@ public class ArchivingSPEAII extends AbstractArchiving implements java.io.Serial
}
if (this.soutDebug) {
for (int i = 0; i < result.length; i++) System.out.println("Result "+i+": "+result[i]);
this.m_Plot = new eva2.gui.Plot("Debug SPEAII", "Y1", "Y2");
this.m_Plot = new eva2.gui.Plot("Debug SPEAII", "Y1", "Y2", true);
this.m_Plot.setUnconnectedPoint(0, 0, 11);
this.m_Plot.setUnconnectedPoint(1.2, 2.0, 11);
GraphPointSet mySet = new GraphPointSet(10, this.m_Plot.getFunctionArea());

View File

@ -1758,8 +1758,6 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
* @return
*/
public static double[] getCorrelations(Population pop) {
double[] cors = new double[pop.size()*(pop.size()-1)/2];
if (pop.size()<2) {
return new double[]{1.,1.,1.,1.};
}
@ -1767,6 +1765,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
// EVAERROR.errorMsgOnce("Warning: population correlations can only be calculated for double valued data!");
return new double[]{Double.NaN,Double.NaN,Double.NaN,Double.NaN};
}
double[] cors = new double[pop.size()*(pop.size()-1)/2];
int index=0;
double corsSum=0, minCor = 10., maxCor=-10.;
for (int i = 0; i < pop.size()-1; i++) {

View File

@ -39,7 +39,7 @@ public class F5Problem extends AbstractProblemDoubleOffset implements java.io.Se
double[] result = new double[1];
double tmp;
result[0] = m_YOffSet;
for (int i = 0; i < x.length-1; i++) {
for (int i = 0; i < x.length; i++) {
tmp = 0;
for (int j = 0; j <= i; j++) {
tmp += x[j]-m_XOffSet;