Reformat all Code.

This commit is contained in:
2013-07-22 15:37:52 +02:00
parent 4bbcf937dc
commit 09cf295554
681 changed files with 57140 additions and 51465 deletions

View File

@@ -5,6 +5,7 @@
package eva2.gui; package eva2.gui;
import eva2.tools.BasicResourceLoader; import eva2.tools.BasicResourceLoader;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
@@ -13,7 +14,6 @@ import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener; import javax.swing.event.HyperlinkListener;
/** /**
*
* @author becker * @author becker
*/ */
public class AboutDialog extends JDialog { public class AboutDialog extends JDialog {
@@ -50,9 +50,9 @@ public class AboutDialog extends JDialog {
add(imageLabel, gbConstraints); add(imageLabel, gbConstraints);
String infoMessage = "<html><head></head><body>" String infoMessage = "<html><head></head><body>"
+"<p>EvA2 (an Evolutionary Algorithms framework, revised version 2) is a comprehensive heuristic optimization framework with emphasis on Evolutionary Algorithms implemented in Java™.</p>" + "<p>EvA2 (an Evolutionary Algorithms framework, revised version 2) is a comprehensive heuristic optimization framework with emphasis on Evolutionary Algorithms implemented in Java™.</p>"
+"<p>For more information, please visit the <a href=\"http://www.cogsys.cs.uni-tuebingen.de/software/JavaEvA/\">EvA2 Homepage</a>.</p>" + "<p>For more information, please visit the <a href=\"http://www.cogsys.cs.uni-tuebingen.de/software/JavaEvA/\">EvA2 Homepage</a>.</p>"
+"</body></html>"; + "</body></html>";
infoEditorPane = new JEditorPane("text/html", infoMessage); infoEditorPane = new JEditorPane("text/html", infoMessage);
infoEditorPane.setEditable(false); infoEditorPane.setEditable(false);

View File

@@ -6,6 +6,7 @@ import eva2.tools.Pair;
import eva2.tools.SelectedTag; import eva2.tools.SelectedTag;
import eva2.tools.StringTools; import eva2.tools.StringTools;
import eva2.tools.Tag; import eva2.tools.Tag;
import java.beans.BeanInfo; import java.beans.BeanInfo;
import java.beans.IntrospectionException; import java.beans.IntrospectionException;
import java.beans.Introspector; import java.beans.Introspector;
@@ -23,7 +24,6 @@ import java.util.logging.Logger;
* generic display. * generic display.
* *
* @author mkron, Holger Ulmer, Felix Streichert, Hannes Planatscher * @author mkron, Holger Ulmer, Felix Streichert, Hannes Planatscher
*
*/ */
public class BeanInspector { public class BeanInspector {
private static final Logger LOGGER = Logger.getLogger(BeanInspector.class.getName()); private static final Logger LOGGER = Logger.getLogger(BeanInspector.class.getName());
@@ -108,9 +108,9 @@ public class BeanInspector {
/** /**
* Produce a String representation of an arbitrary object. * Produce a String representation of an arbitrary object.
* *
* @see #toString(Object, char, boolean, String)
* @param obj * @param obj
* @return * @return
* @see #toString(Object, char, boolean, String)
*/ */
public static String toString(Object obj) { public static String toString(Object obj) {
return toString(obj, ';', false, "", 1, false); return toString(obj, ';', false, "", 1, false);
@@ -574,7 +574,6 @@ public class BeanInspector {
/** /**
* For a Java primitive wrapper class return the corresponding primitive * For a Java primitive wrapper class return the corresponding primitive
* class. * class.
*
*/ */
public static Class getUnboxedType(Class cls) { public static Class getUnboxedType(Class cls) {
if (cls == Double.class) { if (cls == Double.class) {

View File

@@ -9,10 +9,12 @@ package eva2.gui;
* $Date: 2007-11-27 14:37:05 +0100 (Tue, 27 Nov 2007) $ * $Date: 2007-11-27 14:37:05 +0100 (Tue, 27 Nov 2007) $
* $Author: mkron $ * $Author: mkron $
*/ */
import eva2.optimization.OptimizationStateListener; import eva2.optimization.OptimizationStateListener;
import eva2.optimization.modules.ModuleAdapter; import eva2.optimization.modules.ModuleAdapter;
import eva2.optimization.stat.OptimizationJob; import eva2.optimization.stat.OptimizationJob;
import eva2.tools.ToolBoxGui; import eva2.tools.ToolBoxGui;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.io.Serializable; import java.io.Serializable;

View File

@@ -7,6 +7,7 @@ package eva2.gui;
import eva2.optimization.go.InterfaceNotifyOnInformers; import eva2.optimization.go.InterfaceNotifyOnInformers;
import eva2.optimization.problems.InterfaceAdditionalPopulationInformer; import eva2.optimization.problems.InterfaceAdditionalPopulationInformer;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.io.Serializable; import java.io.Serializable;
@@ -86,8 +87,8 @@ public class EvATabbedFrameMaker implements Serializable, PanelMaker, InterfaceN
} }
/** /**
* @deprecated
* @return The toolbar with control buttons * @return The toolbar with control buttons
* @deprecated
*/ */
public JExtToolBar getToolBar() { public JExtToolBar getToolBar() {
return extToolBar; return extToolBar;
@@ -222,7 +223,7 @@ class ClosableTabComponent extends JPanel {
final int tabPosition = i; final int tabPosition = i;
pane.remove(i); pane.remove(i);
if(pane.getTabCount() == 0) { if (pane.getTabCount() == 0) {
pane.setVisible(false); pane.setVisible(false);
} }
/* Create a button to be shown in the ToolBar */ /* Create a button to be shown in the ToolBar */
@@ -240,15 +241,15 @@ class ClosableTabComponent extends JPanel {
pane.setTabComponentAt(tabPosition, ClosableTabComponent.this); pane.setTabComponentAt(tabPosition, ClosableTabComponent.this);
pane.setVisible(true); pane.setVisible(true);
/* Remove the Button */ /* Remove the Button */
toolBar.remove((Component)e.getSource()); toolBar.remove((Component) e.getSource());
/* If the Button was the last one, hide ToolBar again */ /* If the Button was the last one, hide ToolBar again */
if(toolBar.getComponentCount() == 0) { if (toolBar.getComponentCount() == 0) {
toolBar.setVisible(false); toolBar.setVisible(false);
} }
} }
}); });
/* Add it to the ToolBar */ /* Add it to the ToolBar */
if(!toolBar.isVisible()) { if (!toolBar.isVisible()) {
toolBar.setVisible(true); toolBar.setVisible(true);
} }
toolBar.add(tabButton); toolBar.add(tabButton);

View File

@@ -9,16 +9,15 @@ import javax.swing.tree.DefaultMutableTreeNode;
* The tree is constructed using the reflection functionality of PropertySheetPanel * The tree is constructed using the reflection functionality of PropertySheetPanel
* which is also used to generate the nested panels for parameter configuration. * which is also used to generate the nested panels for parameter configuration.
* *
* @author mkron
* @see PropertySheetPanel * @see PropertySheetPanel
* @see GOParameters * @see GOParameters
* @author mkron
*
*/ */
public class EvATreeNode extends DefaultMutableTreeNode { public class EvATreeNode extends DefaultMutableTreeNode {
private String[] childrenNames = null; private String[] childrenNames = null;
private Object[] childrenValues = null; private Object[] childrenValues = null;
private String myName="EvATreeNode"; private String myName = "EvATreeNode";
private boolean doListPrimitives=false; private boolean doListPrimitives = false;
/** /**
* A default constructor setting the name and target object of * A default constructor setting the name and target object of
@@ -54,7 +53,7 @@ public class EvATreeNode extends DefaultMutableTreeNode {
} }
public void setName(String name) { public void setName(String name) {
myName=name; myName = name;
} }
public String getName() { public String getName() {
@@ -65,8 +64,8 @@ public class EvATreeNode extends DefaultMutableTreeNode {
* Actually create child nodes. * Actually create child nodes.
*/ */
private void initChildren() { private void initChildren() {
for (int i=0; i<childrenValues.length; i++) { for (int i = 0; i < childrenValues.length; i++) {
if (childrenValues[i]!=null) { if (childrenValues[i] != null) {
if (doListPrimitives || !(BeanInspector.isJavaPrimitive(childrenValues[i].getClass()))) { if (doListPrimitives || !(BeanInspector.isJavaPrimitive(childrenValues[i].getClass()))) {
super.add(new EvATreeNode(childrenNames[i], childrenValues[i])); super.add(new EvATreeNode(childrenNames[i], childrenValues[i]));
} }
@@ -76,16 +75,15 @@ public class EvATreeNode extends DefaultMutableTreeNode {
@Override @Override
public String toString() { public String toString() {
String extendedInfo=null; String extendedInfo = null;
try { try {
extendedInfo=(String)BeanInspector.callIfAvailable(this.getUserObject(), "getName", new Object[]{}); extendedInfo = (String) BeanInspector.callIfAvailable(this.getUserObject(), "getName", new Object[]{});
} catch (Exception e) { } catch (Exception e) {
extendedInfo=null; extendedInfo = null;
} }
if (extendedInfo != null) { if (extendedInfo != null) {
return myName + " - "+ extendedInfo; return myName + " - " + extendedInfo;
} } else {
else {
return myName; return myName;
} }
} }

View File

@@ -15,11 +15,11 @@ import javax.swing.tree.TreePath;
* to react to selection changes in the tree view (and update the parameter panel), * to react to selection changes in the tree view (and update the parameter panel),
* and the property change listener to * and the property change listener to
* react to changes in the parameters (and update the tree). * react to changes in the parameters (and update the tree).
* @author mkron
* *
* @author mkron
*/ */
public class EvATreeSelectionListener implements TreeSelectionListener, PropertyChangeListener { public class EvATreeSelectionListener implements TreeSelectionListener, PropertyChangeListener {
private PropertyEditor goe=null; private PropertyEditor goe = null;
private EvATreeNode root = null; private EvATreeNode root = null;
private JTree jtree = null; private JTree jtree = null;
public static final boolean TRACE = true; public static final boolean TRACE = true;
@@ -37,10 +37,10 @@ public class EvATreeSelectionListener implements TreeSelectionListener, Property
root = rootNode; root = rootNode;
jtree = jt; jtree = jt;
if (jtree!=null) { if (jtree != null) {
jtree.addTreeSelectionListener(this); jtree.addTreeSelectionListener(this);
} // listen to tree selection changes } // listen to tree selection changes
if (goEditor!=null) { if (goEditor != null) {
goEditor.addPropertyChangeListener(this); goEditor.addPropertyChangeListener(this);
} // listen to changes to the parameters } // listen to changes to the parameters
} }
@@ -52,15 +52,16 @@ public class EvATreeSelectionListener implements TreeSelectionListener, Property
} }
TreePath tp = e.getPath(); TreePath tp = e.getPath();
if (TRACE) { if (TRACE) {
for (int i=tp.getPathCount()-1; i>=0; i--) { for (int i = tp.getPathCount() - 1; i >= 0; i--) {
System.out.println("* " + i + " " + tp.getPathComponent(i)); System.out.println("* " + i + " " + tp.getPathComponent(i));
} } }
EvATreeNode leafNode = (EvATreeNode)tp.getLastPathComponent(); }
EvATreeNode leafNode = (EvATreeNode) tp.getLastPathComponent();
// goe.setValue(leafNode.getUserObject()); // goe.setValue(leafNode.getUserObject());
Component editComp = goe.getCustomEditor(); Component editComp = goe.getCustomEditor();
if (editComp instanceof GOEPanel) { if (editComp instanceof GOEPanel) {
// update the object in the main GOEPanel // update the object in the main GOEPanel
((GOEPanel)editComp).setTarget(leafNode.getUserObject()); ((GOEPanel) editComp).setTarget(leafNode.getUserObject());
} else { } else {
System.err.println("Error, unable to notify custom editor of type " + editComp.getClass() + ", expected GOEPanel (EvATreeSelectionListener)"); System.err.println("Error, unable to notify custom editor of type " + editComp.getClass() + ", expected GOEPanel (EvATreeSelectionListener)");
} }
@@ -72,7 +73,7 @@ public class EvATreeSelectionListener implements TreeSelectionListener, Property
System.out.println("EvATreeNode received change event " + evt); System.out.println("EvATreeNode received change event " + evt);
} }
root.setObject(evt.getNewValue(), true); root.setObject(evt.getNewValue(), true);
if (jtree !=null) { if (jtree != null) {
jtree.setModel(new DefaultTreeModel(root)); jtree.setModel(new DefaultTreeModel(root));
} // TODO this should be done differently so that the tree is not collapsed on each change! } // TODO this should be done differently so that the tree is not collapsed on each change!
} }

View File

@@ -6,19 +6,18 @@ import eva2.tools.chart2d.DFunction;
* Represents an exponential scaling function. * Represents an exponential scaling function.
* MK: added a guard against undefined values: the smallest positive position can * MK: added a guard against undefined values: the smallest positive position can
* be stored and used instead of invalid points. * be stored and used instead of invalid points.
*
*/ */
public class Exp extends DFunction { public class Exp extends DFunction {
private double minValue = 1e-10; // think of a minimal value we want to show in case invalid (<=0) values are requested private double minValue = 1e-10; // think of a minimal value we want to show in case invalid (<=0) values are requested
public void setMinValue(double v) { public void setMinValue(double v) {
if (v>0) { if (v > 0) {
minValue = v; minValue = v;
} } else {
else {
System.err.println("Error, minimal value for Exp must be positive!"); System.err.println("Error, minimal value for Exp must be positive!");
} }
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see eva2.tools.chart2d.DFunction#isDefinedAt(double) * @see eva2.tools.chart2d.DFunction#isDefinedAt(double)
@@ -62,8 +61,8 @@ public class Exp extends DFunction {
} }
public void updateMinValue(double y) { public void updateMinValue(double y) {
if (y<minValue && (y>0)) { if (y < minValue && (y > 0)) {
minValue=y; minValue = y;
} }
} }
} }

View File

@@ -12,10 +12,12 @@ package eva2.gui;
/*==========================================================================* /*==========================================================================*
* IMPORTS * IMPORTS
*==========================================================================*/ *==========================================================================*/
import javax.swing.AbstractAction; import javax.swing.AbstractAction;
import javax.swing.Action; import javax.swing.Action;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.KeyStroke; import javax.swing.KeyStroke;
/** /**
* *
*/ */
@@ -24,46 +26,51 @@ public abstract class ExtAction extends AbstractAction {
public final static String MNEMONIC = "Mnemonic"; public final static String MNEMONIC = "Mnemonic";
public final static String TOOLTIP = "ToolTip"; public final static String TOOLTIP = "ToolTip";
public final static String KEYSTROKE = "KeyStroke"; public final static String KEYSTROKE = "KeyStroke";
/** /**
* *
*/ */
private void setValues(String s, String toolTip){ private void setValues(String s, String toolTip) {
Mnemonic m = new Mnemonic(s); Mnemonic m = new Mnemonic(s);
putValue(MNEMONIC, new Character(m.getMnemonic())); putValue(MNEMONIC, new Character(m.getMnemonic()));
putValue(Action.NAME, m.getText()); putValue(Action.NAME, m.getText());
putValue(TOOLTIP, toolTip); putValue(TOOLTIP, toolTip);
} }
/** /**
* *
*/ */
public ExtAction(String s, Icon i, String toolTip, KeyStroke key){ public ExtAction(String s, Icon i, String toolTip, KeyStroke key) {
this(s, i, toolTip); this(s, i, toolTip);
if (i==null) { if (i == null) {
System.out.println("Icon == null"); System.out.println("Icon == null");
} }
putValue(KEYSTROKE, key); putValue(KEYSTROKE, key);
} }
/** /**
* *
*/ */
public ExtAction(String s, Icon i, String toolTip){ public ExtAction(String s, Icon i, String toolTip) {
super(null, i); super(null, i);
if (i==null) { if (i == null) {
System.out.println("Icon == null"); System.out.println("Icon == null");
} }
setValues(s, toolTip); setValues(s, toolTip);
} }
/** /**
* *
*/ */
public ExtAction(String s, String toolTip, KeyStroke key){ public ExtAction(String s, String toolTip, KeyStroke key) {
this(s, toolTip); this(s, toolTip);
putValue(KEYSTROKE, key); putValue(KEYSTROKE, key);
} }
/** /**
* *
*/ */
public ExtAction(String s, String toolTip){ public ExtAction(String s, String toolTip) {
super(); super();
setValues(s, toolTip); setValues(s, toolTip);
} }

View File

@@ -12,30 +12,35 @@ package eva2.gui;
/*==========================================================================* /*==========================================================================*
* IMPORTS * IMPORTS
*==========================================================================*/ *==========================================================================*/
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import javax.swing.JComponent; import javax.swing.JComponent;
/** /**
* *
*/ */
public abstract class ExtActionChangedListener implements PropertyChangeListener{ public abstract class ExtActionChangedListener implements PropertyChangeListener {
protected JComponent component; protected JComponent component;
/** /**
* *
*/ */
ExtActionChangedListener(JComponent c){ ExtActionChangedListener(JComponent c) {
super(); super();
setTarget(c); setTarget(c);
} }
/** /**
* *
*/ */
@Override @Override
public abstract void propertyChange(PropertyChangeEvent e); public abstract void propertyChange(PropertyChangeEvent e);
/** /**
* *
*/ */
public void setTarget(JComponent c){ public void setTarget(JComponent c) {
component = c; component = c;
} }
} }

View File

@@ -9,6 +9,7 @@ package eva2.gui;
* $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $ * $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $
* $Author: streiche $ * $Author: streiche $
*/ */
import java.awt.Component; import java.awt.Component;
import java.awt.Event; import java.awt.Event;
import java.util.logging.Level; import java.util.logging.Level;

View File

@@ -5,6 +5,7 @@ import eva2.optimization.tools.FileTools;
import eva2.tools.BasicResourceLoader; import eva2.tools.BasicResourceLoader;
import eva2.tools.EVAHELP; import eva2.tools.EVAHELP;
import eva2.tools.SerializedObject; import eva2.tools.SerializedObject;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;

View File

@@ -9,8 +9,10 @@ package eva2.gui;
* $Date: 2007-10-23 16:58:12 +0200 (Tue, 23 Oct 2007) $ * $Date: 2007-10-23 16:58:12 +0200 (Tue, 23 Oct 2007) $
* $Author: mkron $ * $Author: mkron $
*/ */
import eva2.EvAInfo; import eva2.EvAInfo;
import eva2.tools.BasicResourceLoader; import eva2.tools.BasicResourceLoader;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Toolkit; import java.awt.Toolkit;
@@ -25,24 +27,28 @@ import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener; import javax.swing.event.HyperlinkListener;
import javax.swing.text.html.HTMLDocument; import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.HTMLFrameHyperlinkEvent; import javax.swing.text.html.HTMLFrameHyperlinkEvent;
/** /**
* *
*/ */
public class HtmlDemo { public class HtmlDemo {
private JEditorPane m_html; private JEditorPane m_html;
private String m_name; private String m_name;
/** /**
* *
*/ */
public HtmlDemo(String name) { public HtmlDemo(String name) {
m_name = name; m_name = name;
} }
/** /**
* *
*/ */
public JEditorPane getPane() { public JEditorPane getPane() {
return m_html; return m_html;
} }
/** /**
* *
*/ */
@@ -52,21 +58,22 @@ public class HtmlDemo {
} }
public boolean resourceExists() { public boolean resourceExists() {
URL url = ClassLoader.getSystemResource("html/"+m_name); URL url = ClassLoader.getSystemResource("html/" + m_name);
return (url != null); return (url != null);
} }
public static boolean resourceExists(String mname) { public static boolean resourceExists(String mname) {
URL url = ClassLoader.getSystemResource("html/"+mname); URL url = ClassLoader.getSystemResource("html/" + mname);
return (url != null); return (url != null);
} }
/** /**
* *
*/ */
public void show() { public void show() {
try { try {
URL url = null; URL url = null;
url = this.getClass().getClassLoader().getSystemResource("html/"+m_name); url = this.getClass().getClassLoader().getSystemResource("html/" + m_name);
try { try {
m_html = new JEditorPane(url); m_html = new JEditorPane(url);
@@ -86,14 +93,14 @@ public class HtmlDemo {
e.printStackTrace(); e.printStackTrace();
return; return;
} }
JFrame frame = new JFrame (m_name); JFrame frame = new JFrame(m_name);
BasicResourceLoader loader = BasicResourceLoader.instance(); BasicResourceLoader loader = BasicResourceLoader.instance();
byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation, true); byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation, true);
frame.setIconImage(Toolkit.getDefaultToolkit().createImage(bytes)); frame.setIconImage(Toolkit.getDefaultToolkit().createImage(bytes));
JScrollPane scroller = new JScrollPane(); JScrollPane scroller = new JScrollPane();
JViewport vp = scroller.getViewport(); JViewport vp = scroller.getViewport();
vp.add(m_html); vp.add(m_html);
scroller.setPreferredSize( new Dimension(600,500) ); scroller.setPreferredSize(new Dimension(600, 500));
frame.getContentPane().add(scroller, BorderLayout.CENTER); frame.getContentPane().add(scroller, BorderLayout.CENTER);
frame.pack(); frame.pack();
frame.setVisible(true); frame.setVisible(true);
@@ -108,8 +115,8 @@ public class HtmlDemo {
public void hyperlinkUpdate(HyperlinkEvent e) { public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
if (e instanceof HTMLFrameHyperlinkEvent) { if (e instanceof HTMLFrameHyperlinkEvent) {
((HTMLDocument)m_html.getDocument()).processHTMLFrameHyperlinkEvent( ((HTMLDocument) m_html.getDocument()).processHTMLFrameHyperlinkEvent(
(HTMLFrameHyperlinkEvent)e); (HTMLFrameHyperlinkEvent) e);
} else { } else {
try { try {
m_html.setPage(e.getURL()); m_html.setPage(e.getURL());
@@ -120,5 +127,5 @@ public class HtmlDemo {
} }
} }
}; };
} }
} }

View File

@@ -12,28 +12,37 @@ import eva2.optimization.mocco.paretofrontviewer.InterfaceRefSolutionListener;
*/ */
public interface InterfaceSelectablePointIcon { public interface InterfaceSelectablePointIcon {
/** This method allows to add a selection listner to the PointIcon /**
* This method allows to add a selection listner to the PointIcon
* it should need more than one listener to this abstruse event * it should need more than one listener to this abstruse event
*
* @param a The selection listener * @param a The selection listener
*/ */
public void addSelectionListener(InterfaceRefSolutionListener a); public void addSelectionListener(InterfaceRefSolutionListener a);
/** This method allows to remove the selection listner to the PointIcon /**
* This method allows to remove the selection listner to the PointIcon
*/ */
public void removeSelectionListeners(); public void removeSelectionListeners();
/** This method returns the selection listner to the PointIcon /**
* This method returns the selection listner to the PointIcon
*
* @return InterfacePointIconSelectionListener * @return InterfacePointIconSelectionListener
*/ */
public InterfaceRefSolutionListener getSelectionListener(); public InterfaceRefSolutionListener getSelectionListener();
/** Of course the PointIcon needs a reference to the individual /**
* Of course the PointIcon needs a reference to the individual
* otherwise it can't tell the listener what has been selected. * otherwise it can't tell the listener what has been selected.
*
* @param indy * @param indy
*/ */
public void setEAIndividual(AbstractEAIndividual indy); public void setEAIndividual(AbstractEAIndividual indy);
/** This method allows you to get the EAIndividual the icon stands for /**
* This method allows you to get the EAIndividual the icon stands for
*
* @return AbstractEAIndividual * @return AbstractEAIndividual
*/ */
public AbstractEAIndividual getEAIndividual(); public AbstractEAIndividual getEAIndividual();

View File

@@ -9,89 +9,102 @@ package eva2.gui;
* $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $ * $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $
* $Author: streiche $ * $Author: streiche $
*/ */
import java.io.File; import java.io.File;
import javax.swing.JInternalFrame; import javax.swing.JInternalFrame;
import javax.swing.JMenu; import javax.swing.JMenu;
import javax.swing.JToolBar; import javax.swing.JToolBar;
/** /**
* *
*/ */
public abstract class JDocFrame extends JInternalFrame{ public abstract class JDocFrame extends JInternalFrame {
private File m_file; private File m_file;
private String titleStr; private String titleStr;
protected boolean changed = false; protected boolean changed = false;
/** /**
* *
*/ */
public JDocFrame(String title){ public JDocFrame(String title) {
super(title, true, true /* not closable*/, true, true); super(title, true, true /* not closable*/, true, true);
titleStr = title; titleStr = title;
} }
/** /**
* *
*/ */
public JDocFrame(File file){ public JDocFrame(File file) {
this(file.getName()); this(file.getName());
m_file = file; m_file = file;
} }
/** /**
* *
*/ */
public File getFile(){ public File getFile() {
return m_file; return m_file;
} }
/** /**
* *
*/ */
public String getFileTitle(){ public String getFileTitle() {
return titleStr; return titleStr;
} }
/** /**
* *
*/ */
public void save(){ public void save() {
if(m_file != null) { if (m_file != null) {
save(m_file); save(m_file);
} }
} }
/** /**
* *
*/ */
public void save(File f){ public void save(File f) {
if(!f.equals(m_file)){ if (!f.equals(m_file)) {
m_file = f; m_file = f;
titleStr = f.getName(); titleStr = f.getName();
} }
setChangedImpl(false); setChangedImpl(false);
} }
/** /**
* *
*/ */
private void setChangedImpl(boolean value){ private void setChangedImpl(boolean value) {
changed = value; changed = value;
if(changed) { if (changed) {
setTitle(titleStr + " *"); setTitle(titleStr + " *");
} } else {
else {
setTitle(titleStr); setTitle(titleStr);
} }
} }
/** /**
* *
*/ */
protected void setChanged(boolean value){ protected void setChanged(boolean value) {
if(changed != value) { if (changed != value) {
setChangedImpl(value); setChangedImpl(value);
} }
} }
/** /**
* *
*/ */
public boolean isChanged(){ public boolean isChanged() {
return changed; return changed;
} }
public abstract String[] getActionGroups(); public abstract String[] getActionGroups();
public abstract JMenu getMenu(String group); public abstract JMenu getMenu(String group);
public abstract JToolBar getToolBar(String group); public abstract JToolBar getToolBar(String group);
} }

View File

@@ -104,7 +104,7 @@ public class JEFrame extends JInternalFrame {
} }
); );
this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
KeyStroke.getKeyStroke(KeyEvent.VK_LESS , Event.CTRL_MASK), KeyStroke.getKeyStroke(KeyEvent.VK_LESS, Event.CTRL_MASK),
"ctrlSmallerpressed" "ctrlSmallerpressed"
); );
final JEFrame self = this; final JEFrame self = this;

View File

@@ -1,4 +1,5 @@
package eva2.gui; package eva2.gui;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.swing.JDesktopPane; import javax.swing.JDesktopPane;

View File

@@ -90,9 +90,9 @@ public class JExtDesktopPane extends JDesktopPane {
/** /**
* Method to access the window actions. * Method to access the window actions.
* *
* @deprecated
* @param action The desired action (use JExtDesktopPane constants). Default is null * @param action The desired action (use JExtDesktopPane constants). Default is null
* @return The ExtAction * @return The ExtAction
* @deprecated
*/ */
public ExtAction getWindowAction(int action) { public ExtAction getWindowAction(int action) {
switch (action) { switch (action) {

View File

@@ -1,6 +1,7 @@
package eva2.gui; package eva2.gui;
import eva2.tools.ToolBoxGui; import eva2.tools.ToolBoxGui;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import javax.swing.JButton; import javax.swing.JButton;
@@ -8,7 +9,6 @@ import javax.swing.JToolBar;
import javax.swing.SwingConstants; import javax.swing.SwingConstants;
/** /**
*
* @author becker * @author becker
*/ */
public class JExtDesktopPaneToolBar extends JToolBar { public class JExtDesktopPaneToolBar extends JToolBar {

View File

@@ -12,26 +12,27 @@ package eva2.gui;
/*==========================================================================* /*==========================================================================*
* IMPORTS * IMPORTS
*==========================================================================*/ *==========================================================================*/
import java.io.File; import java.io.File;
import javax.swing.*; import javax.swing.*;
public class JExtFileChooser extends JFileChooser{ public class JExtFileChooser extends JFileChooser {
private boolean overwriteWarning = true; private boolean overwriteWarning = true;
public void setOverwriteWarning(boolean value){ public void setOverwriteWarning(boolean value) {
overwriteWarning = value; overwriteWarning = value;
} }
public boolean getOverwriteWarning(){ public boolean getOverwriteWarning() {
return overwriteWarning; return overwriteWarning;
} }
@Override @Override
public void approveSelection(){ public void approveSelection() {
if(getDialogType() == JFileChooser.SAVE_DIALOG && overwriteWarning){ if (getDialogType() == JFileChooser.SAVE_DIALOG && overwriteWarning) {
File f = getSelectedFile(); File f = getSelectedFile();
if(f != null && f.exists()) { if (f != null && f.exists()) {
if (JOptionPane.showConfirmDialog(this, "Die Datei " + f.getPath() + " existiert bereits.\nSoll sie <20>berschrieben werden?", "Achtung", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.NO_OPTION) { if (JOptionPane.showConfirmDialog(this, "Die Datei " + f.getPath() + " existiert bereits.\nSoll sie <20>berschrieben werden?", "Achtung", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.NO_OPTION) {
return; return;
} }

View File

@@ -9,42 +9,44 @@ package eva2.gui;
* $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $ * $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $
* $Author: streiche $ * $Author: streiche $
*/ */
import java.awt.Insets; import java.awt.Insets;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import javax.swing.*; import javax.swing.*;
/** /**
* *
*/ */
public class JExtToolBar extends JToolBar{ public class JExtToolBar extends JToolBar {
@Override @Override
public JButton add(Action a){ public JButton add(Action a) {
JButton button = super.add(a); JButton button = super.add(a);
button.setText(null); button.setText(null);
button.setMargin(new Insets(0, 0, 0, 0)); button.setMargin(new Insets(0, 0, 0, 0));
Object o; Object o;
o = a.getValue(ExtAction.TOOLTIP); o = a.getValue(ExtAction.TOOLTIP);
String toolTip = o != null ? (String)o : ""; String toolTip = o != null ? (String) o : "";
o = a.getValue(ExtAction.KEYSTROKE); o = a.getValue(ExtAction.KEYSTROKE);
button.setToolTipText(toolTip + getKeyText((KeyStroke)o)); button.setToolTipText(toolTip + getKeyText((KeyStroke) o));
return button; return button;
} }
private String getKeyText(KeyStroke k){ private String getKeyText(KeyStroke k) {
StringBuffer result = new StringBuffer(); StringBuffer result = new StringBuffer();
if(k != null){ if (k != null) {
int modifiers = k.getModifiers(); int modifiers = k.getModifiers();
if(modifiers > 0) { if (modifiers > 0) {
result.append(KeyEvent.getKeyModifiersText(modifiers) + "+"); result.append(KeyEvent.getKeyModifiersText(modifiers) + "+");
} }
result.append(KeyEvent.getKeyText(k.getKeyCode())); result.append(KeyEvent.getKeyText(k.getKeyCode()));
} }
if(result.length() > 0){ if (result.length() > 0) {
result.insert(0, " ["); result.insert(0, " [");
result.append("]"); result.append("]");
} }
@@ -53,32 +55,29 @@ public class JExtToolBar extends JToolBar{
} }
@Override @Override
protected PropertyChangeListener createActionChangeListener(JButton b){ protected PropertyChangeListener createActionChangeListener(JButton b) {
return new ExtActionChangedListener(b){ return new ExtActionChangedListener(b) {
@Override @Override
public void propertyChange(PropertyChangeEvent e){ public void propertyChange(PropertyChangeEvent e) {
JButton button = (JButton)component; JButton button = (JButton) component;
String propertyName = e.getPropertyName(); String propertyName = e.getPropertyName();
if(propertyName.equals(Action.NAME)){ if (propertyName.equals(Action.NAME)) {
/* Nichts tun! */ /* Nichts tun! */
} } else if (propertyName.equals("enabled")) {
else if(propertyName.equals("enabled")){ button.setEnabled(((Boolean) e.getNewValue()).booleanValue());
button.setEnabled(((Boolean)e.getNewValue()).booleanValue());
button.repaint(); button.repaint();
} } else if (e.getPropertyName().equals(Action.SMALL_ICON)) {
else if(e.getPropertyName().equals(Action.SMALL_ICON)){ button.setIcon((Icon) e.getNewValue());
button.setIcon((Icon)e.getNewValue());
button.invalidate(); button.invalidate();
button.repaint(); button.repaint();
} } else if (propertyName.equals(ExtAction.TOOLTIP) || propertyName.equals(ExtAction.KEYSTROKE)) {
else if(propertyName.equals(ExtAction.TOOLTIP) || propertyName.equals(ExtAction.KEYSTROKE)){ Action source = (Action) e.getSource();
Action source = (Action)e.getSource();
Object o = source.getValue(ExtAction.TOOLTIP); Object o = source.getValue(ExtAction.TOOLTIP);
String toolTip = o != null ? (String)o : ""; String toolTip = o != null ? (String) o : "";
o = source.getValue(ExtAction.KEYSTROKE); o = source.getValue(ExtAction.KEYSTROKE);
button.setToolTipText(toolTip + getKeyText((KeyStroke)o)); button.setToolTipText(toolTip + getKeyText((KeyStroke) o));
} }
} }
}; };

View File

@@ -68,7 +68,9 @@ public class JParaPanel implements Serializable, PanelMaker {
return propertyEditor; return propertyEditor;
} }
/** This method will allow you to add a new Editor to a given class /**
* This method will allow you to add a new Editor to a given class
*
* @param object * @param object
* @param editor * @param editor
* @return False if failed true else. * @return False if failed true else.

View File

@@ -12,6 +12,7 @@ package eva2.gui;
/*==========================================================================* /*==========================================================================*
* IMPORTS * IMPORTS
*==========================================================================*/ *==========================================================================*/
import java.awt.Event; import java.awt.Event;
import java.awt.event.*; import java.awt.event.*;
import java.io.*; import java.io.*;
@@ -22,66 +23,66 @@ import javax.swing.text.*;
import javax.swing.undo.*; import javax.swing.undo.*;
public class JTextEditorInternalFrame extends JDocFrame{ public class JTextEditorInternalFrame extends JDocFrame {
public final static String GROUP_EDIT = "Edit"; public final static String GROUP_EDIT = "Edit";
private JTextArea textArea; private JTextArea textArea;
private final String[] actionGroups = {GROUP_EDIT}; private final String[] actionGroups = {GROUP_EDIT};
protected UndoManager undo = new UndoManager(); protected UndoManager undo = new UndoManager();
private class UndoAction extends ExtAction{
public UndoAction(){ private class UndoAction extends ExtAction {
public UndoAction() {
super("R<EFBFBD>ckg<EFBFBD>ngig", new ImageIcon("images/EditUndo.gif"), "Macht die letzte Aktion r<>ckg<6B>ngig", super("R<EFBFBD>ckg<EFBFBD>ngig", new ImageIcon("images/EditUndo.gif"), "Macht die letzte Aktion r<>ckg<6B>ngig",
KeyStroke.getKeyStroke(KeyEvent.VK_Z, Event.CTRL_MASK)); KeyStroke.getKeyStroke(KeyEvent.VK_Z, Event.CTRL_MASK));
setEnabled(false); setEnabled(false);
} }
@Override @Override
public void actionPerformed(ActionEvent e){ public void actionPerformed(ActionEvent e) {
try{ try {
undo.undo(); undo.undo();
} catch (CannotUndoException exc) {
} }
catch(CannotUndoException exc){}
update(); update();
actRedo.update(); actRedo.update();
} }
private void update() { private void update() {
if(undo.canUndo()){ if (undo.canUndo()) {
setEnabled(true); setEnabled(true);
putValue(Action.NAME, undo.getUndoPresentationName()); putValue(Action.NAME, undo.getUndoPresentationName());
} } else {
else{
setEnabled(false); setEnabled(false);
putValue(Action.NAME, "R<EFBFBD>ckg<EFBFBD>ngig"); putValue(Action.NAME, "R<EFBFBD>ckg<EFBFBD>ngig");
} }
} }
} // end of inner class UndoAction } // end of inner class UndoAction
/////////////////////////////////////////// ///////////////////////////////////////////
// //
/////////////////////////////////////////// ///////////////////////////////////////////
private class RedoAction extends ExtAction{ private class RedoAction extends ExtAction {
public RedoAction(){ public RedoAction() {
super("Wiederholen", "Wiederholt die letzte Aktion", KeyStroke.getKeyStroke(KeyEvent.VK_Z, Event.CTRL_MASK|Event.SHIFT_MASK)); super("Wiederholen", "Wiederholt die letzte Aktion", KeyStroke.getKeyStroke(KeyEvent.VK_Z, Event.CTRL_MASK | Event.SHIFT_MASK));
setEnabled(false); setEnabled(false);
} }
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
try{ try {
undo.redo(); undo.redo();
} catch (CannotRedoException exc) {
} }
catch(CannotRedoException exc){}
update(); update();
actUndo.update(); actUndo.update();
} }
private void update() { private void update() {
if(undo.canRedo()){ if (undo.canRedo()) {
setEnabled(true); setEnabled(true);
putValue(Action.NAME, undo.getRedoPresentationName()); putValue(Action.NAME, undo.getRedoPresentationName());
} } else {
else{
setEnabled(false); setEnabled(false);
putValue(Action.NAME, "Wiederholen"); putValue(Action.NAME, "Wiederholen");
} }
@@ -92,28 +93,30 @@ public class JTextEditorInternalFrame extends JDocFrame{
private RedoAction actRedo; private RedoAction actRedo;
public final static String undoAction = "undo"; public final static String undoAction = "undo";
public final static String redoAction = "redo"; public final static String redoAction = "redo";
/////////////////////////////////////////// ///////////////////////////////////////////
// //
///////////////////////////////////////// /////////////////////////////////////////
@Override @Override
public String[] getActionGroups(){ public String[] getActionGroups() {
return actionGroups; return actionGroups;
} }
private JMenu mnuEdit; private JMenu mnuEdit;
private JToolBar barEdit; private JToolBar barEdit;
@Override @Override
public JMenu getMenu(String group){ public JMenu getMenu(String group) {
if(GROUP_EDIT.equals(group)) { if (GROUP_EDIT.equals(group)) {
return mnuEdit; return mnuEdit;
} } else {
else {
return null; return null;
} }
} }
@Override @Override
public JToolBar getToolBar(String group){ public JToolBar getToolBar(String group) {
if(GROUP_EDIT.equals(group)) { if (GROUP_EDIT.equals(group)) {
return barEdit; return barEdit;
} }
return null; return null;
@@ -121,31 +124,32 @@ public class JTextEditorInternalFrame extends JDocFrame{
private Hashtable hashActions = new Hashtable(); private Hashtable hashActions = new Hashtable();
private Action cloneAction(Action a){ private Action cloneAction(Action a) {
Action result = null; Action result = null;
try{ try {
ByteArrayOutputStream bOut = new ByteArrayOutputStream(); ByteArrayOutputStream bOut = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(bOut); ObjectOutputStream out = new ObjectOutputStream(bOut);
out.writeObject(a); out.writeObject(a);
ByteArrayInputStream bIn = new ByteArrayInputStream(bOut.toByteArray()); ByteArrayInputStream bIn = new ByteArrayInputStream(bOut.toByteArray());
ObjectInputStream in = new ObjectInputStream(bIn); ObjectInputStream in = new ObjectInputStream(bIn);
result = (Action)in.readObject(); result = (Action) in.readObject();
} catch (Exception exc) {
} }
catch(Exception exc){}
return result; return result;
} }
/////////////////////////////////////////////// ///////////////////////////////////////////////
// //
////////////////////////////////////////////// //////////////////////////////////////////////
private void createActions(){ private void createActions() {
hashActions.put(undoAction, actUndo = new UndoAction()); hashActions.put(undoAction, actUndo = new UndoAction());
hashActions.put(redoAction, actRedo = new RedoAction()); hashActions.put(redoAction, actRedo = new RedoAction());
Action[] actions = textArea.getActions(); Action[] actions = textArea.getActions();
for(int i = 0; i < actions.length; i++) { for (int i = 0; i < actions.length; i++) {
hashActions.put((String)actions[i].getValue(Action.NAME), actions[i]); hashActions.put((String) actions[i].getValue(Action.NAME), actions[i]);
} }
mnuEdit = new JExtMenu("&Bearbeiten"); mnuEdit = new JExtMenu("&Bearbeiten");
@@ -160,9 +164,9 @@ public class JTextEditorInternalFrame extends JDocFrame{
mnuEdit.add(actRedo); mnuEdit.add(actRedo);
mnuEdit.addSeparator(); mnuEdit.addSeparator();
a = (Action)hashActions.get(DefaultEditorKit.cutAction); a = (Action) hashActions.get(DefaultEditorKit.cutAction);
keyActions = keys.getKeyStrokesForAction(a); keyActions = keys.getKeyStrokesForAction(a);
if(keyActions != null && keyActions.length > 0) { if (keyActions != null && keyActions.length > 0) {
a.putValue(ExtAction.KEYSTROKE, keyActions[0]); a.putValue(ExtAction.KEYSTROKE, keyActions[0]);
} }
a.putValue(Action.SMALL_ICON, new ImageIcon("images/EditCut.gif")); a.putValue(Action.SMALL_ICON, new ImageIcon("images/EditCut.gif"));
@@ -172,9 +176,9 @@ public class JTextEditorInternalFrame extends JDocFrame{
mnuEdit.add(a); mnuEdit.add(a);
barEdit.add(a); barEdit.add(a);
a = (Action)hashActions.get(DefaultEditorKit.copyAction); a = (Action) hashActions.get(DefaultEditorKit.copyAction);
keyActions = keys.getKeyStrokesForAction(a); keyActions = keys.getKeyStrokesForAction(a);
if(keyActions != null && keyActions.length > 0) { if (keyActions != null && keyActions.length > 0) {
a.putValue(ExtAction.KEYSTROKE, keyActions[0]); a.putValue(ExtAction.KEYSTROKE, keyActions[0]);
} }
a.putValue(Action.SMALL_ICON, new ImageIcon("images/EditCopy.gif")); a.putValue(Action.SMALL_ICON, new ImageIcon("images/EditCopy.gif"));
@@ -184,9 +188,9 @@ public class JTextEditorInternalFrame extends JDocFrame{
mnuEdit.add(a); mnuEdit.add(a);
barEdit.add(a); barEdit.add(a);
a = (Action)hashActions.get(DefaultEditorKit.pasteAction); a = (Action) hashActions.get(DefaultEditorKit.pasteAction);
keyActions = keys.getKeyStrokesForAction(a); keyActions = keys.getKeyStrokesForAction(a);
if(keyActions != null && keyActions.length > 0) { if (keyActions != null && keyActions.length > 0) {
a.putValue(ExtAction.KEYSTROKE, keyActions[0]); a.putValue(ExtAction.KEYSTROKE, keyActions[0]);
} }
a.putValue(Action.SMALL_ICON, new ImageIcon("images/EditPaste.gif")); a.putValue(Action.SMALL_ICON, new ImageIcon("images/EditPaste.gif"));
@@ -198,9 +202,9 @@ public class JTextEditorInternalFrame extends JDocFrame{
mnuEdit.addSeparator(); mnuEdit.addSeparator();
a = (Action)hashActions.get(DefaultEditorKit.selectAllAction); a = (Action) hashActions.get(DefaultEditorKit.selectAllAction);
keyActions = keys.getKeyStrokesForAction(a); keyActions = keys.getKeyStrokesForAction(a);
if(keyActions != null && keyActions.length > 0) { if (keyActions != null && keyActions.length > 0) {
a.putValue(ExtAction.KEYSTROKE, keyActions[0]); a.putValue(ExtAction.KEYSTROKE, keyActions[0]);
} }
a.putValue(ExtAction.CAPTION, "Alles markieren"); a.putValue(ExtAction.CAPTION, "Alles markieren");
@@ -208,76 +212,79 @@ public class JTextEditorInternalFrame extends JDocFrame{
a.putValue(ExtAction.TOOLTIP, "Markiert das ganze Dokument"); a.putValue(ExtAction.TOOLTIP, "Markiert das ganze Dokument");
mnuEdit.add(a); mnuEdit.add(a);
} }
////////////////////////////////////////// //////////////////////////////////////////
// //
///////////////////////////////////////// /////////////////////////////////////////
private void createTextArea(){ private void createTextArea() {
textArea = new JTextArea(); textArea = new JTextArea();
getContentPane().add(new JScrollPane(textArea)); getContentPane().add(new JScrollPane(textArea));
} }
///////////////////////////////////// /////////////////////////////////////
// //
///////////////////////////////////// /////////////////////////////////////
private void createListeners(){ private void createListeners() {
textArea.getDocument().addDocumentListener(new DocumentListener(){ textArea.getDocument().addDocumentListener(new DocumentListener() {
private void changed(){ private void changed() {
setChanged(true); setChanged(true);
} }
@Override @Override
public void changedUpdate(DocumentEvent e){ public void changedUpdate(DocumentEvent e) {
changed(); changed();
} }
@Override @Override
public void insertUpdate(DocumentEvent e){ public void insertUpdate(DocumentEvent e) {
changed(); changed();
} }
@Override @Override
public void removeUpdate(DocumentEvent e){ public void removeUpdate(DocumentEvent e) {
changed(); changed();
} }
}); });
textArea.getDocument().addUndoableEditListener(new UndoableEditListener(){ textArea.getDocument().addUndoableEditListener(new UndoableEditListener() {
@Override @Override
public void undoableEditHappened(UndoableEditEvent e){ public void undoableEditHappened(UndoableEditEvent e) {
undo.addEdit(e.getEdit()); undo.addEdit(e.getEdit());
actUndo.update(); actUndo.update();
actRedo.update(); actRedo.update();
} }
}); });
} }
//////////////////////////////////////////////////// ////////////////////////////////////////////////////
// //
/////////////////////////////////////////////////// ///////////////////////////////////////////////////
public JTextEditorInternalFrame(String title){ public JTextEditorInternalFrame(String title) {
super(title); super(title);
createTextArea(); createTextArea();
createListeners(); createListeners();
createActions(); createActions();
} }
////////////////////////////////////////////////// //////////////////////////////////////////////////
// //
///////////////////////////////////////////////// /////////////////////////////////////////////////
public JTextEditorInternalFrame(File file){ public JTextEditorInternalFrame(File file) {
super(file); super(file);
createTextArea(); createTextArea();
if(file.exists()){ if (file.exists()) {
FileReader in = null; FileReader in = null;
try{ try {
in = new FileReader(file); in = new FileReader(file);
textArea.read(in, null); textArea.read(in, null);
} } catch (IOException exc) {
catch(IOException exc){} } finally {
finally{ if (in != null) {
if(in != null) { try {
try{
in.close(); in.close();
} } catch (IOException exc) {
catch(IOException exc){} }
} }
} }
} }
@@ -287,19 +294,18 @@ catch(IOException exc){}
} }
@Override @Override
public void save(File f){ public void save(File f) {
FileWriter out = null; FileWriter out = null;
try{ try {
out = new FileWriter(f); out = new FileWriter(f);
textArea.write(out); textArea.write(out);
} catch (IOException exc) {
} finally {
if (out != null) {
try {
out.close();
} catch (IOException exc) {
} }
catch(IOException exc){}
finally{
if(out != null) {
try{
out.close();
}
catch(IOException exc){}
} }
} }
@@ -307,10 +313,10 @@ catch(IOException exc){}
} }
@Override @Override
public void setSelected(boolean value) throws java.beans.PropertyVetoException{ public void setSelected(boolean value) throws java.beans.PropertyVetoException {
super.setSelected(value); super.setSelected(value);
if(value) { if (value) {
textArea.requestFocus(); textArea.requestFocus();
} }
} }

View File

@@ -8,6 +8,7 @@ package eva2.gui;
import eva2.EvAInfo; import eva2.EvAInfo;
import eva2.optimization.tools.FileTools; import eva2.optimization.tools.FileTools;
import eva2.tools.BasicResourceLoader; import eva2.tools.BasicResourceLoader;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Point; import java.awt.Point;
import java.awt.event.*; import java.awt.event.*;

View File

@@ -9,6 +9,7 @@ package eva2.gui;
* $Date: 2007-10-23 12:56:51 +0200 (Tue, 23 Oct 2007) $ * $Date: 2007-10-23 12:56:51 +0200 (Tue, 23 Oct 2007) $
* $Author: mkron $ * $Author: mkron $
*/ */
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Point; import java.awt.Point;
@@ -27,10 +28,11 @@ import javax.swing.event.ChangeListener;
*/ */
public class LoggingPanel extends JPanel { public class LoggingPanel extends JPanel {
protected static Logger logger; protected static Logger logger;
protected JTextArea loggingTextArea = new JTextArea(10,20); protected JTextArea loggingTextArea = new JTextArea(10, 20);
protected boolean firstMessage = true; protected boolean firstMessage = true;
protected Handler loggingHandler; protected Handler loggingHandler;
protected JPopupMenu loggingLevelMenu; protected JPopupMenu loggingLevelMenu;
/** /**
* *
*/ */
@@ -53,10 +55,11 @@ public class LoggingPanel extends JPanel {
add(scrollpane, BorderLayout.CENTER); add(scrollpane, BorderLayout.CENTER);
scrollpane.getViewport().addChangeListener(new ChangeListener() { scrollpane.getViewport().addChangeListener(new ChangeListener() {
private int lastHeight; private int lastHeight;
// //
@Override @Override
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
JViewport viewport = (JViewport)e.getSource(); JViewport viewport = (JViewport) e.getSource();
int height = viewport.getViewSize().height; int height = viewport.getViewSize().height;
if (height != lastHeight) { if (height != lastHeight) {
lastHeight = height; lastHeight = height;
@@ -66,12 +69,14 @@ public class LoggingPanel extends JPanel {
} }
}); });
} }
/** /**
* *
*/ */
protected static String getTimestamp() { protected static String getTimestamp() {
return (new SimpleDateFormat("HH:mm:ss:")).format(new Date()); return (new SimpleDateFormat("HH:mm:ss:")).format(new Date());
} }
/** /**
* *
*/ */

View File

@@ -114,7 +114,6 @@ public class Main extends JFrame implements OptimizationStateListener {
* Constructor of GUI of EvA2. Works as client for the EvA2 server. Note * Constructor of GUI of EvA2. Works as client for the EvA2 server. Note
* that the Main initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()} * that the Main initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()}
* to await full initialization if necessary. * to await full initialization if necessary.
*
*/ */
public Main(final String hostName) { public Main(final String hostName) {
this(hostName, null, false, false); this(hostName, null, false, false);
@@ -126,11 +125,11 @@ public class Main extends JFrame implements OptimizationStateListener {
* efficiency. Use {@link #awaitGuiInitialized()} to await full * efficiency. Use {@link #awaitGuiInitialized()} to await full
* initialization if necessary. * initialization if necessary.
* *
* @see #EvAClient(String, java.awt.Window, String, boolean, boolean, boolean)
* @param hostName * @param hostName
* @param paramsFile * @param paramsFile
* @param autorun * @param autorun
* @param nosplash * @param nosplash
* @see #EvAClient(String, java.awt.Window, String, boolean, boolean, boolean)
*/ */
public Main(final String hostName, final String paramsFile, boolean autorun, boolean nosplash) { public Main(final String hostName, final String paramsFile, boolean autorun, boolean nosplash) {
this(hostName, null, paramsFile, null, autorun, nosplash, false, false); this(hostName, null, paramsFile, null, autorun, nosplash, false, false);
@@ -141,11 +140,10 @@ public class Main extends JFrame implements OptimizationStateListener {
* initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()} * initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()}
* to await full initialization if necessary. * to await full initialization if necessary.
* *
* @see #Main(String, String, boolean, boolean)
*
* @param hostName * @param hostName
* @param autorun * @param autorun
* @param nosplash * @param nosplash
* @see #Main(String, String, boolean, boolean)
*/ */
public Main(final String hostName, boolean autorun, boolean nosplash) { public Main(final String hostName, boolean autorun, boolean nosplash) {
this(hostName, null, autorun, nosplash); this(hostName, null, autorun, nosplash);
@@ -156,12 +154,12 @@ public class Main extends JFrame implements OptimizationStateListener {
* initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()} * initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()}
* to await full initialization if necessary. * to await full initialization if necessary.
* *
* @see #Main(String, String, boolean, boolean)
* @param hostName * @param hostName
* @param paramsFile * @param paramsFile
* @param autorun * @param autorun
* @param noSplash * @param noSplash
* @param noGui * @param noGui
* @see #Main(String, String, boolean, boolean)
*/ */
public Main(final String hostName, String paramsFile, boolean autorun, boolean noSplash, boolean noGui, boolean withTreeView) { public Main(final String hostName, String paramsFile, boolean autorun, boolean noSplash, boolean noGui, boolean withTreeView) {
this(hostName, null, paramsFile, null, autorun, noSplash, noGui, withTreeView); this(hostName, null, paramsFile, null, autorun, noSplash, noGui, withTreeView);
@@ -172,13 +170,12 @@ public class Main extends JFrame implements OptimizationStateListener {
* initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()} * initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()}
* to await full initialization if necessary. * to await full initialization if necessary.
* *
* @see #Main(String, String, boolean, boolean)
*
* @param hostName * @param hostName
* @param paramsFile * @param paramsFile
* @param autorun * @param autorun
* @param noSplash * @param noSplash
* @param noGui * @param noGui
* @see #Main(String, String, boolean, boolean)
*/ */
public Main(final String hostName, InterfaceOptimizationParameters goParams, boolean autorun, boolean noSplash, boolean noGui) { public Main(final String hostName, InterfaceOptimizationParameters goParams, boolean autorun, boolean noSplash, boolean noGui) {
this(hostName, null, null, goParams, autorun, noSplash, noGui, false); this(hostName, null, null, goParams, autorun, noSplash, noGui, false);
@@ -401,7 +398,7 @@ public class Main extends JFrame implements OptimizationStateListener {
} }
logPanel = new LoggingPanel(LOGGER); logPanel = new LoggingPanel(LOGGER);
logPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); logPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
if (EvAInfo.propShowModules() != null) { if (EvAInfo.propShowModules() != null) {
@@ -551,7 +548,6 @@ public class Main extends JFrame implements OptimizationStateListener {
/** /**
* Refresh the parameter panels (if settings have been changed outside of * Refresh the parameter panels (if settings have been changed outside of
* the GUI which should be updated in the GUI. * the GUI which should be updated in the GUI.
*
*/ */
public void refreshMainPanels() { public void refreshMainPanels() {
frameMaker.refreshPanels(); frameMaker.refreshPanels();
@@ -931,10 +927,10 @@ public class Main extends JFrame implements OptimizationStateListener {
* Create a tree view of an object based on EvATreeNode. It is encapsulated * Create a tree view of an object based on EvATreeNode. It is encapsulated
* in a JScrollPane. * in a JScrollPane.
* *
* @see eva2.gui.EvATreeNode
* @param title * @param title
* @param object * @param object
* @return * @return
* @see eva2.gui.EvATreeNode
*/ */
public JComponent getEvATreeView(JParaPanel goPanel, String title, Object object) { public JComponent getEvATreeView(JParaPanel goPanel, String title, Object object) {
EvATreeNode root = new EvATreeNode(title, object); // the root of the tree EvATreeNode root = new EvATreeNode(title, object); // the root of the tree

View File

@@ -7,6 +7,7 @@ package eva2.gui;
* Time: 18:30:44 * Time: 18:30:44
* To change this template use Options | File Templates. * To change this template use Options | File Templates.
*/ */
/** /**
* *
*/ */

View File

@@ -15,9 +15,11 @@ public class MultiLineString {
public static void main(String[] args) { public static void main(String[] args) {
MultiLineString multiLineString1 = new MultiLineString(); MultiLineString multiLineString1 = new MultiLineString();
} }
public String getString() { public String getString() {
return string; return string;
} }
public void setString(String string) { public void setString(String string) {
this.string = string; this.string = string;
} }

View File

@@ -4,8 +4,8 @@ import javax.swing.JComponent;
/** /**
* Simple helper interface. * Simple helper interface.
* @author mkron
* *
* @author mkron
*/ */
public interface PanelMaker { public interface PanelMaker {
public JComponent makePanel(); public JComponent makePanel();

View File

@@ -8,6 +8,7 @@ package eva2.gui;
import eva2.EvAInfo; import eva2.EvAInfo;
import eva2.tools.BasicResourceLoader; import eva2.tools.BasicResourceLoader;
import eva2.tools.EVAHELP; import eva2.tools.EVAHELP;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component; import java.awt.Component;
import java.beans.PropertyEditor; import java.beans.PropertyEditor;

View File

@@ -24,25 +24,25 @@ public class PropertyDoubleArray implements java.io.Serializable {
/** /**
* Constructor that creates a double matrix with given dimensions and fills * Constructor that creates a double matrix with given dimensions and fills
* it cyclically with values given. * it cyclically with values given.
*
* @param rows * @param rows
* @param cols * @param cols
* @param d * @param d
*/ */
public PropertyDoubleArray(int rows, int cols, double ... d) { public PropertyDoubleArray(int rows, int cols, double... d) {
if (rows>0 && cols>0) { if (rows > 0 && cols > 0) {
this.m_DoubleArray = new double[rows][cols]; this.m_DoubleArray = new double[rows][cols];
} else {
this.m_DoubleArray = null;
} }
else { this.m_numCols = cols;
this.m_DoubleArray=null; int index = 0;
} for (int i = 0; i < rows; i++) {
this.m_numCols=cols; for (int j = 0; j < cols; j++) {
int index=0; m_DoubleArray[i][j] = d[index];
for (int i=0; i<rows; i++) {
for (int j=0; j<cols; j++) {
m_DoubleArray[i][j]=d[index];
index++; index++;
if (index>=d.length) { if (index >= d.length) {
index=0; index = 0;
} }
} }
} }
@@ -53,27 +53,30 @@ public class PropertyDoubleArray implements java.io.Serializable {
return (Object) new PropertyDoubleArray(this); return (Object) new PropertyDoubleArray(this);
} }
/** This method will allow you to set the value of the double array /**
* This method will allow you to set the value of the double array
*
* @param d The double[] * @param d The double[]
*/ */
public void setDoubleArray(double[] d) { public void setDoubleArray(double[] d) {
this.m_DoubleArray = new double[d.length][1]; this.m_DoubleArray = new double[d.length][1];
for (int i=0; i<d.length; i++) { for (int i = 0; i < d.length; i++) {
m_DoubleArray[i][0] = d[i]; m_DoubleArray[i][0] = d[i];
} }
m_numCols=1; m_numCols = 1;
} }
/** This method will allow you to set the value of the double array /**
* This method will allow you to set the value of the double array
*
* @param d The double[] * @param d The double[]
*/ */
public void setDoubleArray(double[][] d) { public void setDoubleArray(double[][] d) {
this.m_DoubleArray = d; this.m_DoubleArray = d;
if (d.length>0) { if (d.length > 0) {
m_numCols=d[0].length; m_numCols = d[0].length;
} } else {
else { m_numCols = 1;
m_numCols=1;
} }
} }
@@ -86,15 +89,16 @@ public class PropertyDoubleArray implements java.io.Serializable {
/** /**
* Return a column as a vector (in copy) * Return a column as a vector (in copy)
*
* @return a column as a vector (in copy) * @return a column as a vector (in copy)
*/ */
public double[] getDoubleColumnAsVector(int col) { public double[] getDoubleColumnAsVector(int col) {
if (col>=m_numCols) { if (col >= m_numCols) {
throw new IllegalArgumentException("Error, invalid column selected, " + col + " of " + m_numCols); throw new IllegalArgumentException("Error, invalid column selected, " + col + " of " + m_numCols);
} }
double[] ret = new double[m_DoubleArray.length]; double[] ret = new double[m_DoubleArray.length];
for (int i=0; i<ret.length; i++) { for (int i = 0; i < ret.length; i++) {
ret[i]=m_DoubleArray[i][col]; ret[i] = m_DoubleArray[i][col];
} }
return ret; return ret;
} }
@@ -108,22 +112,21 @@ public class PropertyDoubleArray implements java.io.Serializable {
} }
public double getValue(int i, int j) { public double getValue(int i, int j) {
if (i<0 || j<0 || (i>=getNumRows()) || (j>=getNumCols())) { if (i < 0 || j < 0 || (i >= getNumRows()) || (j >= getNumCols())) {
throw new IllegalArgumentException("Error, invalid access to double array: " + i + "," + j + " within " + getNumRows() + ","+getNumCols()); throw new IllegalArgumentException("Error, invalid access to double array: " + i + "," + j + " within " + getNumRows() + "," + getNumCols());
} }
return m_DoubleArray[i][j]; return m_DoubleArray[i][j];
} }
public void adaptRowCount(int k) { public void adaptRowCount(int k) {
if (k!=m_DoubleArray.length) { if (k != m_DoubleArray.length) {
double[][] newDD = new double[k][m_numCols]; double[][] newDD = new double[k][m_numCols];
for (int i=0; i<k; i++) { for (int i = 0; i < k; i++) {
for (int j=0; j<m_numCols; j++) { for (int j = 0; j < m_numCols; j++) {
if (i<m_DoubleArray.length) { if (i < m_DoubleArray.length) {
newDD[i][j]=m_DoubleArray[i][j]; newDD[i][j] = m_DoubleArray[i][j];
} } else {
else { newDD[i][j] = m_DoubleArray[m_DoubleArray.length - 1][j];
newDD[i][j]=m_DoubleArray[m_DoubleArray.length-1][j];
} }
} }
} }
@@ -132,17 +135,17 @@ public class PropertyDoubleArray implements java.io.Serializable {
} }
public void deleteRow(int k) { public void deleteRow(int k) {
if (k<0 || k>=getNumRows()) { if (k < 0 || k >= getNumRows()) {
throw new IllegalArgumentException("Invalid index to deleteRow: " + k + " is not a valid row."); throw new IllegalArgumentException("Invalid index to deleteRow: " + k + " is not a valid row.");
} }
double[][] newDD = new double[getNumRows()-1][getNumCols()]; double[][] newDD = new double[getNumRows() - 1][getNumCols()];
int inc=0; int inc = 0;
for (int i = 0; i < newDD.length; i++) { for (int i = 0; i < newDD.length; i++) {
if (i==k) { if (i == k) {
inc=1; inc = 1;
} }
for (int j=0; j<getNumCols(); j++) { for (int j = 0; j < getNumCols(); j++) {
newDD[i][j] = m_DoubleArray[i+inc][j]; newDD[i][j] = m_DoubleArray[i + inc][j];
} }
} }
setDoubleArray(newDD); setDoubleArray(newDD);
@@ -155,24 +158,25 @@ public class PropertyDoubleArray implements java.io.Serializable {
* @param k * @param k
*/ */
public void addRowCopy(int k) { public void addRowCopy(int k) {
if (k<0 || k>= getNumRows()) { if (k < 0 || k >= getNumRows()) {
k=getNumRows()-1; k = getNumRows() - 1;
} }
double[][] newDD = new double[getNumRows()+1][getNumCols()]; double[][] newDD = new double[getNumRows() + 1][getNumCols()];
for (int i = 0; i < getNumRows(); i++) { for (int i = 0; i < getNumRows(); i++) {
for (int j = 0; j<getNumCols(); j++) { for (int j = 0; j < getNumCols(); j++) {
newDD[i][j] = m_DoubleArray[i][j]; newDD[i][j] = m_DoubleArray[i][j];
} }
} }
if (k>=0) { if (k >= 0) {
for (int j=0; j<getNumCols(); j++) { for (int j = 0; j < getNumCols(); j++) {
newDD[newDD.length-1][j] = newDD[k][j]; newDD[newDD.length - 1][j] = newDD[k][j];
} } }
else { } else {
for (int j=0; j<getNumCols(); j++) { for (int j = 0; j < getNumCols(); j++) {
newDD[newDD.length-1][j] = 1.; newDD[newDD.length - 1][j] = 1.;
} } // if the array was empty }
} // if the array was empty
setDoubleArray(newDD); setDoubleArray(newDD);
} }
@@ -180,26 +184,28 @@ public class PropertyDoubleArray implements java.io.Serializable {
* Normalize all columns of the array by dividing through the sum. * Normalize all columns of the array by dividing through the sum.
*/ */
public void normalizeColumns() { public void normalizeColumns() {
double colSum=0; double colSum = 0;
for (int j=0; j<getNumCols(); j++) { for (int j = 0; j < getNumCols(); j++) {
colSum=0; colSum = 0;
for (int i = 0; i < getNumRows(); i++) { for (int i = 0; i < getNumRows(); i++) {
colSum += m_DoubleArray[i][j]; colSum += m_DoubleArray[i][j];
} }
if (colSum!=0) { if (colSum != 0) {
for (int i = 0; i < getNumRows(); i++) { for (int i = 0; i < getNumRows(); i++) {
m_DoubleArray[i][j]/=colSum; m_DoubleArray[i][j] /= colSum;
} } }
}
} }
} }
/** /**
* Check if k is a valid row index (within 0 and numRows-1). * Check if k is a valid row index (within 0 and numRows-1).
*
* @param k * @param k
* @return * @return
*/ */
public boolean isValidRow(int k) { public boolean isValidRow(int k) {
return (k>=0) && (k<getNumRows()); return (k >= 0) && (k < getNumRows());
} }
@Override @Override

View File

@@ -50,8 +50,7 @@ public class PropertyFilePath implements java.io.Serializable {
String fName = ReflectPackage.getResourcePathFromCP(relPath); String fName = ReflectPackage.getResourcePathFromCP(relPath);
if (fName == null) { if (fName == null) {
return null; return null;
} } else {
else {
return new PropertyFilePath(fName); return new PropertyFilePath(fName);
} }
} }
@@ -61,8 +60,10 @@ public class PropertyFilePath implements java.io.Serializable {
return (Object) new PropertyFilePath(this); return (Object) new PropertyFilePath(this);
} }
/** This method will allow you to set a complete string /**
* This method will allow you to set a complete string
* which will be separated into Path, Name and extension * which will be separated into Path, Name and extension
*
* @param s The complete filepath and filename * @param s The complete filepath and filename
*/ */
public void setCompleteFilePath(String s) { public void setCompleteFilePath(String s) {
@@ -72,18 +73,18 @@ public class PropertyFilePath implements java.io.Serializable {
String old = this.getCompleteFilePath(); String old = this.getCompleteFilePath();
try { try {
if (trace) { if (trace) {
System.out.println("Complete Filename: " +s); System.out.println("Complete Filename: " + s);
} }
filesep = System.getProperty("file.separator"); filesep = System.getProperty("file.separator");
if (trace) { if (trace) {
System.out.println("File.Separator: " +filesep); System.out.println("File.Separator: " + filesep);
} }
this.FileName = s.substring(s.lastIndexOf(filesep)+1); this.FileName = s.substring(s.lastIndexOf(filesep) + 1);
this.FileExtension = this.FileName.substring(this.FileName.lastIndexOf(".")); this.FileExtension = this.FileName.substring(this.FileName.lastIndexOf("."));
this.FilePath = s.substring(0, s.lastIndexOf(filesep)+1); this.FilePath = s.substring(0, s.lastIndexOf(filesep) + 1);
if (trace) { if (trace) {
System.out.println("FilePath: " +this.FilePath); System.out.println("FilePath: " + this.FilePath);
} }
if (trace) { if (trace) {
System.out.println("Filename: " + this.FileName); System.out.println("Filename: " + this.FileName);
@@ -96,8 +97,10 @@ public class PropertyFilePath implements java.io.Serializable {
} }
} }
/** This method will return the complete name of the file /**
* This method will return the complete name of the file
* which filepath * which filepath
*
* @return The complete filename with path. * @return The complete filename with path.
*/ */
public String getCompleteFilePath() { public String getCompleteFilePath() {

View File

@@ -24,14 +24,18 @@ public class PropertyIntArray implements java.io.Serializable {
return (Object) new PropertyIntArray(this); return (Object) new PropertyIntArray(this);
} }
/** This method will allow you to set the value of the double array /**
* This method will allow you to set the value of the double array
*
* @param d The int[] * @param d The int[]
*/ */
public void setIntArray(int[] d) { public void setIntArray(int[] d) {
this.m_IntArray = d; this.m_IntArray = d;
} }
/** This method will return the int array /**
* This method will return the int array
*
* @return The int array * @return The int array
*/ */
public int[] getIntArray() { public int[] getIntArray() {

View File

@@ -17,14 +17,15 @@ public class PropertyOptimizationObjectives implements java.io.Serializable {
this.m_AvailableObjectives = d; this.m_AvailableObjectives = d;
this.m_SelectedObjectives = null; this.m_SelectedObjectives = null;
} }
public PropertyOptimizationObjectives(PropertyOptimizationObjectives d) { public PropertyOptimizationObjectives(PropertyOptimizationObjectives d) {
this.m_AvailableObjectives = new InterfaceOptimizationObjective[d.m_AvailableObjectives.length]; this.m_AvailableObjectives = new InterfaceOptimizationObjective[d.m_AvailableObjectives.length];
for (int i = 0; i < this.m_AvailableObjectives.length; i++) { for (int i = 0; i < this.m_AvailableObjectives.length; i++) {
this.m_AvailableObjectives[i] = (InterfaceOptimizationObjective)d.m_AvailableObjectives[i].clone(); this.m_AvailableObjectives[i] = (InterfaceOptimizationObjective) d.m_AvailableObjectives[i].clone();
} }
this.m_SelectedObjectives = new InterfaceOptimizationObjective[d.m_SelectedObjectives.length]; this.m_SelectedObjectives = new InterfaceOptimizationObjective[d.m_SelectedObjectives.length];
for (int i = 0; i < this.m_SelectedObjectives.length; i++) { for (int i = 0; i < this.m_SelectedObjectives.length; i++) {
this.m_SelectedObjectives[i] = (InterfaceOptimizationObjective)d.m_SelectedObjectives[i].clone(); this.m_SelectedObjectives[i] = (InterfaceOptimizationObjective) d.m_SelectedObjectives[i].clone();
} }
} }
@@ -33,28 +34,36 @@ public class PropertyOptimizationObjectives implements java.io.Serializable {
return (Object) new PropertyOptimizationObjectives(this); return (Object) new PropertyOptimizationObjectives(this);
} }
/** This method will allow you to set the value of the InterfaceOptimizationTarget array /**
* This method will allow you to set the value of the InterfaceOptimizationTarget array
*
* @param d The InterfaceOptimizationTarget[] * @param d The InterfaceOptimizationTarget[]
*/ */
public void setSelectedTargets(InterfaceOptimizationObjective[] d) { public void setSelectedTargets(InterfaceOptimizationObjective[] d) {
this.m_SelectedObjectives = d; this.m_SelectedObjectives = d;
} }
/** This method will return the InterfaceOptimizationTarget array /**
* This method will return the InterfaceOptimizationTarget array
*
* @return The InterfaceOptimizationTarget[]. * @return The InterfaceOptimizationTarget[].
*/ */
public InterfaceOptimizationObjective[] getSelectedTargets() { public InterfaceOptimizationObjective[] getSelectedTargets() {
return this.m_SelectedObjectives; return this.m_SelectedObjectives;
} }
/** This method will return the InterfaceOptimizationTarget array /**
* This method will return the InterfaceOptimizationTarget array
*
* @return The InterfaceOptimizationTarget[]. * @return The InterfaceOptimizationTarget[].
*/ */
public InterfaceOptimizationObjective[] getAvailableTargets() { public InterfaceOptimizationObjective[] getAvailableTargets() {
return this.m_AvailableObjectives; return this.m_AvailableObjectives;
} }
/** This method allows you to remove a Target from the list /**
* This method allows you to remove a Target from the list
*
* @param index The index of the target to be removed. * @param index The index of the target to be removed.
*/ */
public void removeTarget(int index) { public void removeTarget(int index) {
@@ -62,7 +71,7 @@ public class PropertyOptimizationObjectives implements java.io.Serializable {
return; return;
} }
InterfaceOptimizationObjective[] newList = new InterfaceOptimizationObjective[this.m_SelectedObjectives.length-1]; InterfaceOptimizationObjective[] newList = new InterfaceOptimizationObjective[this.m_SelectedObjectives.length - 1];
int j = 0; int j = 0;
for (int i = 0; i < this.m_SelectedObjectives.length; i++) { for (int i = 0; i < this.m_SelectedObjectives.length; i++) {
if (index != i) { if (index != i) {
@@ -73,11 +82,13 @@ public class PropertyOptimizationObjectives implements java.io.Serializable {
this.m_SelectedObjectives = newList; this.m_SelectedObjectives = newList;
} }
/** This method allows you to add a new target to the list /**
* This method allows you to add a new target to the list
*
* @param optTarget * @param optTarget
*/ */
public void addTarget(InterfaceOptimizationObjective optTarget) { public void addTarget(InterfaceOptimizationObjective optTarget) {
InterfaceOptimizationObjective[] newList = new InterfaceOptimizationObjective[this.m_SelectedObjectives.length+1]; InterfaceOptimizationObjective[] newList = new InterfaceOptimizationObjective[this.m_SelectedObjectives.length + 1];
for (int i = 0; i < this.m_SelectedObjectives.length; i++) { for (int i = 0; i < this.m_SelectedObjectives.length; i++) {
newList[i] = this.m_SelectedObjectives[i]; newList[i] = this.m_SelectedObjectives[i];
} }

View File

@@ -22,17 +22,18 @@ public class PropertyOptimizationObjectivesWithParam implements java.io.Serializ
this.m_AvailableObjectives = d; this.m_AvailableObjectives = d;
this.m_SelectedObjectives = null; this.m_SelectedObjectives = null;
} }
public PropertyOptimizationObjectivesWithParam(PropertyOptimizationObjectivesWithParam d) { public PropertyOptimizationObjectivesWithParam(PropertyOptimizationObjectivesWithParam d) {
this.m_DescriptiveString = d.m_DescriptiveString; this.m_DescriptiveString = d.m_DescriptiveString;
this.m_WeightsLabel = d.m_WeightsLabel; this.m_WeightsLabel = d.m_WeightsLabel;
this.m_NormalizationEnabled = d.m_NormalizationEnabled; this.m_NormalizationEnabled = d.m_NormalizationEnabled;
this.m_AvailableObjectives = new InterfaceOptimizationObjective[d.m_AvailableObjectives.length]; this.m_AvailableObjectives = new InterfaceOptimizationObjective[d.m_AvailableObjectives.length];
for (int i = 0; i < this.m_AvailableObjectives.length; i++) { for (int i = 0; i < this.m_AvailableObjectives.length; i++) {
this.m_AvailableObjectives[i] = (InterfaceOptimizationObjective)d.m_AvailableObjectives[i].clone(); this.m_AvailableObjectives[i] = (InterfaceOptimizationObjective) d.m_AvailableObjectives[i].clone();
} }
this.m_SelectedObjectives = new InterfaceOptimizationObjective[d.m_SelectedObjectives.length]; this.m_SelectedObjectives = new InterfaceOptimizationObjective[d.m_SelectedObjectives.length];
for (int i = 0; i < this.m_SelectedObjectives.length; i++) { for (int i = 0; i < this.m_SelectedObjectives.length; i++) {
this.m_SelectedObjectives[i] = (InterfaceOptimizationObjective)d.m_SelectedObjectives[i].clone(); this.m_SelectedObjectives[i] = (InterfaceOptimizationObjective) d.m_SelectedObjectives[i].clone();
} }
if (d.m_Weights != null) { if (d.m_Weights != null) {
this.m_Weights = new double[d.m_Weights.length]; this.m_Weights = new double[d.m_Weights.length];
@@ -45,7 +46,9 @@ public class PropertyOptimizationObjectivesWithParam implements java.io.Serializ
return (Object) new PropertyOptimizationObjectivesWithParam(this); return (Object) new PropertyOptimizationObjectivesWithParam(this);
} }
/** This method will allow you to set the value of the InterfaceOptimizationTarget array /**
* This method will allow you to set the value of the InterfaceOptimizationTarget array
*
* @param d The InterfaceOptimizationTarget[] * @param d The InterfaceOptimizationTarget[]
*/ */
public void setSelectedTargets(InterfaceOptimizationObjective[] d) { public void setSelectedTargets(InterfaceOptimizationObjective[] d) {
@@ -78,61 +81,79 @@ public class PropertyOptimizationObjectivesWithParam implements java.io.Serializ
} }
} }
/** This method will return the InterfaceOptimizationTarget array /**
* This method will return the InterfaceOptimizationTarget array
*
* @return The InterfaceOptimizationTarget[]. * @return The InterfaceOptimizationTarget[].
*/ */
public InterfaceOptimizationObjective[] getSelectedTargets() { public InterfaceOptimizationObjective[] getSelectedTargets() {
return this.m_SelectedObjectives; return this.m_SelectedObjectives;
} }
/** This method will return the InterfaceOptimizationTarget array /**
* This method will return the InterfaceOptimizationTarget array
*
* @return The InterfaceOptimizationTarget[]. * @return The InterfaceOptimizationTarget[].
*/ */
public InterfaceOptimizationObjective[] getAvailableTargets() { public InterfaceOptimizationObjective[] getAvailableTargets() {
return this.m_AvailableObjectives; return this.m_AvailableObjectives;
} }
/** This method allows you to read the weights /**
* This method allows you to read the weights
*
* @return the weights * @return the weights
*/ */
public double[] getWeights() { public double[] getWeights() {
return this.m_Weights; return this.m_Weights;
} }
public void setWeights(double[] d) { public void setWeights(double[] d) {
this.m_Weights = d; this.m_Weights = d;
} }
/** This method allows you to set/get the descriptive string /**
* This method allows you to set/get the descriptive string
*
* @return the string * @return the string
*/ */
public String getDescriptiveString() { public String getDescriptiveString() {
return this.m_DescriptiveString; return this.m_DescriptiveString;
} }
public void setDescriptiveString(String d) { public void setDescriptiveString(String d) {
this.m_DescriptiveString = d; this.m_DescriptiveString = d;
} }
/** This method allows you to set/get the weights label /**
* This method allows you to set/get the weights label
*
* @return the string * @return the string
*/ */
public String getWeigthsLabel() { public String getWeigthsLabel() {
return this.m_WeightsLabel; return this.m_WeightsLabel;
} }
public void setWeightsLabel(String d) { public void setWeightsLabel(String d) {
this.m_WeightsLabel = d; this.m_WeightsLabel = d;
} }
/** This method allows you to set/get the weights label /**
* This method allows you to set/get the weights label
*
* @return the string * @return the string
*/ */
public boolean isNormalizationEnabled() { public boolean isNormalizationEnabled() {
return this.m_NormalizationEnabled; return this.m_NormalizationEnabled;
} }
public void enableNormalization(boolean d) { public void enableNormalization(boolean d) {
this.m_NormalizationEnabled = d; this.m_NormalizationEnabled = d;
} }
/** This method allows you to remove a Target from the list /**
* This method allows you to remove a Target from the list
*
* @param index The index of the target to be removed. * @param index The index of the target to be removed.
*/ */
public void removeTarget(int index) { public void removeTarget(int index) {
@@ -140,7 +161,7 @@ public class PropertyOptimizationObjectivesWithParam implements java.io.Serializ
return; return;
} }
InterfaceOptimizationObjective[] newList = new InterfaceOptimizationObjective[this.m_SelectedObjectives.length-1]; InterfaceOptimizationObjective[] newList = new InterfaceOptimizationObjective[this.m_SelectedObjectives.length - 1];
double[] newWeights = new double[this.m_Weights.length - 1]; double[] newWeights = new double[this.m_Weights.length - 1];
int j = 0; int j = 0;
for (int i = 0; i < this.m_SelectedObjectives.length; i++) { for (int i = 0; i < this.m_SelectedObjectives.length; i++) {
@@ -154,11 +175,13 @@ public class PropertyOptimizationObjectivesWithParam implements java.io.Serializ
this.m_Weights = newWeights; this.m_Weights = newWeights;
} }
/** This method allows you to add a new target to the list /**
* This method allows you to add a new target to the list
*
* @param optTarget * @param optTarget
*/ */
public void addTarget(InterfaceOptimizationObjective optTarget) { public void addTarget(InterfaceOptimizationObjective optTarget) {
InterfaceOptimizationObjective[] newList = new InterfaceOptimizationObjective[this.m_SelectedObjectives.length+1]; InterfaceOptimizationObjective[] newList = new InterfaceOptimizationObjective[this.m_SelectedObjectives.length + 1];
double[] newWeights = new double[this.m_Weights.length + 1]; double[] newWeights = new double[this.m_Weights.length + 1];
for (int i = 0; i < this.m_SelectedObjectives.length; i++) { for (int i = 0; i < this.m_SelectedObjectives.length; i++) {
newList[i] = this.m_SelectedObjectives[i]; newList[i] = this.m_SelectedObjectives[i];

View File

@@ -9,7 +9,9 @@ package eva2.gui;
* $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $ * $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $
* $Author: streiche $ * $Author: streiche $
*/ */
import eva2.tools.EVAHELP; import eva2.tools.EVAHELP;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
@@ -18,6 +20,7 @@ import javax.swing.BorderFactory;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
/** /**
* *
*/ */
@@ -26,6 +29,7 @@ public class PropertyPanel extends JPanel {
private PropertyDialog propertyDialog; private PropertyDialog propertyDialog;
private JLabel textLabel; private JLabel textLabel;
/** /**
* *
*/ */
@@ -50,12 +54,11 @@ public class PropertyPanel extends JPanel {
public void showDialog(int initX, int initY) { public void showDialog(int initX, int initY) {
if (propertyDialog == null) { if (propertyDialog == null) {
propertyDialog = new PropertyDialog(propertyEditor, EVAHELP.cutClassName(propertyEditor.getClass().getName()) , initX, initY); propertyDialog = new PropertyDialog(propertyEditor, EVAHELP.cutClassName(propertyEditor.getClass().getName()), initX, initY);
propertyDialog.setPreferredSize(new Dimension(500,300)); propertyDialog.setPreferredSize(new Dimension(500, 300));
propertyDialog.setModal(true); propertyDialog.setModal(true);
propertyDialog.setVisible(true); propertyDialog.setVisible(true);
} } else {
else {
propertyDialog.updateFrameTitle(propertyEditor); propertyDialog.updateFrameTitle(propertyEditor);
propertyDialog.setVisible(false); propertyDialog.setVisible(false);
propertyDialog.requestFocus(); propertyDialog.requestFocus();
@@ -79,7 +82,7 @@ public class PropertyPanel extends JPanel {
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
Insets i = textLabel.getInsets(); Insets i = textLabel.getInsets();
Rectangle box = new Rectangle(i.left, i.top, Rectangle box = new Rectangle(i.left, i.top,
getSize().width - i.left - i.right , getSize().width - i.left - i.right,
getSize().height - i.top - i.bottom); getSize().height - i.top - i.bottom);
g.clearRect(i.left, i.top, g.clearRect(i.left, i.top,
getSize().width - i.right - i.left, getSize().width - i.right - i.left,

View File

@@ -16,7 +16,7 @@ public class PropertySelectableList<T> implements java.io.Serializable {
protected boolean[] m_Selection; protected boolean[] m_Selection;
private transient PropertyChangeSupport m_Support = new PropertyChangeSupport(this); private transient PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
// public PropertySelectableList() { // public PropertySelectableList() {
// } // }
// //
public PropertySelectableList(T[] initial) { public PropertySelectableList(T[] initial) {
@@ -60,13 +60,14 @@ public class PropertySelectableList<T> implements java.io.Serializable {
/** /**
* Returns the elements represented by this list where only the selected elements are non-null. * Returns the elements represented by this list where only the selected elements are non-null.
*
* @return * @return
*/ */
public T[] getSelectedObjects() { public T[] getSelectedObjects() {
T[] selObjects = getObjects().clone(); T[] selObjects = getObjects().clone();
for (int i=0; i<selObjects.length; i++) { for (int i = 0; i < selObjects.length; i++) {
if (!m_Selection[i]) { if (!m_Selection[i]) {
selObjects[i]=null; selObjects[i] = null;
} }
} }
return selObjects; return selObjects;
@@ -79,8 +80,8 @@ public class PropertySelectableList<T> implements java.io.Serializable {
*/ */
public void setSelectionByIndices(int[] selection) { public void setSelectionByIndices(int[] selection) {
m_Selection = new boolean[getObjects().length]; m_Selection = new boolean[getObjects().length];
for (int i=0; i<selection.length; i++) { for (int i = 0; i < selection.length; i++) {
m_Selection[selection[i]]=true; m_Selection[selection[i]] = true;
} }
m_Support.firePropertyChange("PropertySelectableList", null, this); m_Support.firePropertyChange("PropertySelectableList", null, this);
} }
@@ -95,7 +96,7 @@ public class PropertySelectableList<T> implements java.io.Serializable {
} }
public void setSelectionForElement(int index, boolean b) { public void setSelectionForElement(int index, boolean b) {
if (m_Selection[index]!=b) { if (m_Selection[index] != b) {
this.m_Selection[index] = b; this.m_Selection[index] = b;
m_Support.firePropertyChange("PropertySelectableList", null, this); m_Support.firePropertyChange("PropertySelectableList", null, this);
} }
@@ -104,8 +105,7 @@ public class PropertySelectableList<T> implements java.io.Serializable {
public int size() { public int size() {
if (m_Objects == null) { if (m_Objects == null) {
return 0; return 0;
} } else {
else {
return m_Objects.length; return m_Objects.length;
} }
} }
@@ -119,8 +119,8 @@ public class PropertySelectableList<T> implements java.io.Serializable {
} }
public void clear() { public void clear() {
m_Objects=null; m_Objects = null;
m_Selection=null; m_Selection = null;
m_Support.firePropertyChange("PropertySelectableList", null, this); m_Support.firePropertyChange("PropertySelectableList", null, this);
} }

View File

@@ -9,8 +9,10 @@ package eva2.gui;
* $Date: 2007-12-05 11:29:32 +0100 (Wed, 05 Dec 2007) $ * $Date: 2007-12-05 11:29:32 +0100 (Wed, 05 Dec 2007) $
* $Author: mkron $ * $Author: mkron $
*/ */
import eva2.gui.editor.GenericObjectEditor; import eva2.gui.editor.GenericObjectEditor;
import eva2.tools.EVAHELP; import eva2.tools.EVAHELP;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
@@ -25,6 +27,7 @@ import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellEditor; import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer; import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableModel; import javax.swing.table.TableModel;
/** /**
* There are some trick methods interpreted here. Check EvA2Notes.txt. * There are some trick methods interpreted here. Check EvA2Notes.txt.
*/ */
@@ -1145,5 +1148,4 @@ class PropertyCellEditor extends AbstractCellEditor implements TableCellEditor {
} }
} }

View File

@@ -12,6 +12,7 @@ package eva2.gui;
/*==========================================================================* /*==========================================================================*
* IMPORTS * IMPORTS
*==========================================================================*/ *==========================================================================*/
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.GridBagConstraints; import java.awt.GridBagConstraints;
import java.awt.GridBagLayout; import java.awt.GridBagLayout;
@@ -24,6 +25,7 @@ import javax.swing.JCheckBox;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.SwingConstants; import javax.swing.SwingConstants;
/** /**
* *
*/ */
@@ -42,6 +44,7 @@ public class PropertySheetPanelStat extends JPanel implements Serializable {
// setBorder(BorderFactory.createLineBorder(Color.red)); // setBorder(BorderFactory.createLineBorder(Color.red));
setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
} }
/** /**
* A support object for handling property change listeners * A support object for handling property change listeners
*/ */

View File

@@ -4,6 +4,7 @@ package eva2.gui;
* Architecture @author Holger Ulmer, Felix Streichert, Hannes Planatscher @version: $Revision: 10 $ * Architecture @author Holger Ulmer, Felix Streichert, Hannes Planatscher @version: $Revision: 10 $
* $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $ $Author: streiche $ * $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $ $Author: streiche $
*/ */
import java.awt.event.FocusAdapter; import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent; import java.awt.event.FocusEvent;
import java.awt.event.KeyAdapter; import java.awt.event.KeyAdapter;

View File

@@ -11,7 +11,6 @@ import javax.swing.JTextField;
/** /**
* A text property editor view. Updates the editor on key release and lost focus * A text property editor view. Updates the editor on key release and lost focus
* events. * events.
*
*/ */
public class PropertyText extends JTextField { public class PropertyText extends JTextField {

View File

@@ -11,6 +11,7 @@ package eva2.gui;
* @version: $Revision: 322 $ $Date: 2007-12-11 17:24:07 +0100 (Tue, 11 Dec 2007)$ * @version: $Revision: 322 $ $Date: 2007-12-11 17:24:07 +0100 (Tue, 11 Dec 2007)$
* $Author: mkron $ * $Author: mkron $
*/ */
import eva2.tools.BasicResourceLoader; import eva2.tools.BasicResourceLoader;
import java.awt.*; import java.awt.*;
@@ -28,7 +29,7 @@ class SplashScreen extends Frame {
/** /**
* Show the splash screen to the end user. * Show the splash screen to the end user.
* * <p/>
* <P>Once this method returns, the splash screen is realized, which means * <P>Once this method returns, the splash screen is realized, which means
* that almost all work on the splash screen should proceed through the * that almost all work on the splash screen should proceed through the
* event dispatch thread. In particular, any call to * event dispatch thread. In particular, any call to

View File

@@ -28,12 +28,18 @@ import javax.swing.SwingConstants;
*/ */
public abstract class AbstractListSelectionEditor extends JPanel implements PropertyEditor, PropertyChangeListener { public abstract class AbstractListSelectionEditor extends JPanel implements PropertyEditor, PropertyChangeListener {
/** Handles property change notification */ /**
* Handles property change notification
*/
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this); private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
/** The label for when we can't edit that type */ /**
* The label for when we can't edit that type
*/
protected JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER); protected JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER);
/** The graphics stuff */ /**
* The graphics stuff
*/
private JPanel m_CustomEditor, m_NodePanel; private JPanel m_CustomEditor, m_NodePanel;
protected JCheckBox[] m_BlackCheck; protected JCheckBox[] m_BlackCheck;
@@ -41,7 +47,8 @@ public abstract class AbstractListSelectionEditor extends JPanel implements Prop
public AbstractListSelectionEditor() { public AbstractListSelectionEditor() {
} }
/** This method will init the CustomEditor Panel /**
* This method will init the CustomEditor Panel
*/ */
private void initCustomEditor() { private void initCustomEditor() {
this.m_CustomEditor = new JPanel(); this.m_CustomEditor = new JPanel();
@@ -54,6 +61,7 @@ public abstract class AbstractListSelectionEditor extends JPanel implements Prop
/** /**
* Return the number of elements in the list. * Return the number of elements in the list.
*
* @return * @return
*/ */
protected abstract int getElementCount(); protected abstract int getElementCount();
@@ -122,7 +130,9 @@ public abstract class AbstractListSelectionEditor extends JPanel implements Prop
*/ */
protected abstract boolean setObject(Object o); protected abstract boolean setObject(Object o);
/** This method will set the value of object that is to be edited. /**
* This method will set the value of object that is to be edited.
*
* @param o an object that must be an array. * @param o an object that must be an array.
*/ */
@Override @Override
@@ -134,6 +144,7 @@ public abstract class AbstractListSelectionEditor extends JPanel implements Prop
/** /**
* Returns the current object. * Returns the current object.
*
* @return the current object * @return the current object
*/ */
@Override @Override
@@ -175,13 +186,16 @@ public abstract class AbstractListSelectionEditor extends JPanel implements Prop
m_Support.removePropertyChangeListener(l); m_Support.removePropertyChangeListener(l);
} }
/** Returns true since the Object can be shown /**
* Returns true since the Object can be shown
*
* @return true * @return true
*/ */
@Override @Override
public boolean isPaintable() { public boolean isPaintable() {
return true; return true;
} }
/** /**
* Paints a representation of the current classifier. * Paints a representation of the current classifier.
* *
@@ -193,11 +207,12 @@ public abstract class AbstractListSelectionEditor extends JPanel implements Prop
FontMetrics fm = gfx.getFontMetrics(); FontMetrics fm = gfx.getFontMetrics();
int vpad = (box.height - fm.getAscent()) / 2; int vpad = (box.height - fm.getAscent()) / 2;
String rep = "Select from list"; String rep = "Select from list";
gfx.drawString(rep, 2, fm.getHeight() + vpad - 3 ); gfx.drawString(rep, 2, fm.getHeight() + vpad - 3);
} }
/** /**
* Returns true because we do support a custom editor. * Returns true because we do support a custom editor.
*
* @return true * @return true
*/ */
@Override @Override
@@ -205,7 +220,9 @@ public abstract class AbstractListSelectionEditor extends JPanel implements Prop
return true; return true;
} }
/** Returns the array editing component. /**
* Returns the array editing component.
*
* @return a value of type 'java.awt.Component' * @return a value of type 'java.awt.Component'
*/ */
@Override @Override

View File

@@ -12,6 +12,7 @@ package eva2.gui.editor;
/*==========================================================================* /*==========================================================================*
* IMPORTS * IMPORTS
*==========================================================================*/ *==========================================================================*/
import eva2.gui.PropertyDialog; import eva2.gui.PropertyDialog;
import java.awt.*; import java.awt.*;
@@ -28,19 +29,20 @@ public class BigStringEditor implements PropertyEditor {
private JTextArea m_TextArea; private JTextArea m_TextArea;
private JScrollPane m_ScrollPane; private JScrollPane m_ScrollPane;
private JPanel m_Panel; private JPanel m_Panel;
// private Source m_Source; // private Source m_Source;
private JButton m_SetButton; private JButton m_SetButton;
static private boolean m_finished = false; static private boolean m_finished = false;
/** /**
* *
*/ */
public static void editSource (String file) { public static void editSource(String file) {
try { try {
m_finished=false; m_finished = false;
BigStringEditor editor = new BigStringEditor(); BigStringEditor editor = new BigStringEditor();
PropertyDialog dialog = new PropertyDialog(editor,file, 50, 50); PropertyDialog dialog = new PropertyDialog(editor, file, 50, 50);
//frame.setSize(200, 200); //frame.setSize(200, 200);
dialog.addWindowListener(new WindowListener() { dialog.addWindowListener(new WindowListener() {
@@ -80,10 +82,11 @@ public class BigStringEditor implements PropertyEditor {
} }
} }
); );
while (m_finished==false) { while (m_finished == false) {
try {Thread.sleep(1000);} try {
catch (Exception e) { Thread.sleep(1000);
System.out.println("e+"+e.getMessage()); } catch (Exception e) {
System.out.println("e+" + e.getMessage());
} }
} }
@@ -93,16 +96,17 @@ public class BigStringEditor implements PropertyEditor {
System.out.println(e.getMessage()); System.out.println(e.getMessage());
} }
} }
/** /**
* *
*/ */
public BigStringEditor () { public BigStringEditor() {
super(); super();
// m_TextArea = new JEditTextArea(); // m_TextArea = new JEditTextArea();
// m_TextArea.setTokenMarker(new JavaTokenMarker()); // m_TextArea.setTokenMarker(new JavaTokenMarker());
m_TextArea = new JTextArea(60,60); m_TextArea = new JTextArea(60, 60);
m_TextArea.setEditable(true); m_TextArea.setEditable(true);
m_TextArea.setBorder(BorderFactory.createEmptyBorder(4,4,4,4)); m_TextArea.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
m_ScrollPane = new JScrollPane(m_TextArea); m_ScrollPane = new JScrollPane(m_TextArea);
m_Panel = new JPanel(); m_Panel = new JPanel();
m_Panel.setBorder(BorderFactory.createTitledBorder("Sourcecode")); m_Panel.setBorder(BorderFactory.createTitledBorder("Sourcecode"));
@@ -117,15 +121,16 @@ public class BigStringEditor implements PropertyEditor {
m_Panel.add(m_ScrollPane, BorderLayout.CENTER); m_Panel.add(m_ScrollPane, BorderLayout.CENTER);
m_Panel.add(m_SetButton, BorderLayout.SOUTH); m_Panel.add(m_SetButton, BorderLayout.SOUTH);
} }
/** /**
* *
*/ */
@Override @Override
public void setValue (Object value) { public void setValue(Object value) {
m_ElementEditor = null; m_ElementEditor = null;
if (value instanceof String) { if (value instanceof String) {
// m_Source.setString((String)value); // m_Source.setString((String)value);
m_TextArea.setText((String)value); m_TextArea.setText((String) value);
} }
/* if (value instanceof Source) { /* if (value instanceof Source) {
@@ -134,19 +139,21 @@ public class BigStringEditor implements PropertyEditor {
}*/ }*/
m_Support.firePropertyChange("", null, null); m_Support.firePropertyChange("", null, null);
} }
/** /**
* *
*/ */
@Override @Override
public Object getValue () { public Object getValue() {
// m_Source.setString(m_TextArea.getText()); // m_Source.setString(m_TextArea.getText());
return null; return null;
} }
/** /**
* *
*/ */
@Override @Override
public String getJavaInitializationString () { public String getJavaInitializationString() {
return "null"; return "null";
} }
@@ -157,7 +164,7 @@ public class BigStringEditor implements PropertyEditor {
* @return true * @return true
*/ */
@Override @Override
public boolean isPaintable () { public boolean isPaintable() {
return true; return true;
} }
@@ -168,9 +175,9 @@ public class BigStringEditor implements PropertyEditor {
* @param box the area we are allowed to paint into * @param box the area we are allowed to paint into
*/ */
@Override @Override
public void paintValue (Graphics gfx, Rectangle box) { public void paintValue(Graphics gfx, Rectangle box) {
FontMetrics fm = gfx.getFontMetrics(); FontMetrics fm = gfx.getFontMetrics();
int vpad = (box.height - fm.getAscent())/2; int vpad = (box.height - fm.getAscent()) / 2;
//String rep = EVAHELP.cutClassName(m_ElementClass.getName()); //String rep = EVAHELP.cutClassName(m_ElementClass.getName());
gfx.drawString("BigStringEditor", 2, fm.getHeight() + vpad - 3); gfx.drawString("BigStringEditor", 2, fm.getHeight() + vpad - 3);
} }
@@ -179,7 +186,7 @@ public class BigStringEditor implements PropertyEditor {
* *
*/ */
@Override @Override
public String getAsText () { public String getAsText() {
return null; return null;
} }
@@ -187,7 +194,7 @@ public class BigStringEditor implements PropertyEditor {
* *
*/ */
@Override @Override
public void setAsText (String text) throws IllegalArgumentException { public void setAsText(String text) throws IllegalArgumentException {
throw new IllegalArgumentException(text); throw new IllegalArgumentException(text);
} }
@@ -195,7 +202,7 @@ public class BigStringEditor implements PropertyEditor {
* *
*/ */
@Override @Override
public String[] getTags () { public String[] getTags() {
return null; return null;
} }
@@ -203,14 +210,15 @@ public class BigStringEditor implements PropertyEditor {
* *
*/ */
@Override @Override
public boolean supportsCustomEditor () { public boolean supportsCustomEditor() {
return true; return true;
} }
/** /**
* *
*/ */
@Override @Override
public Component getCustomEditor () { public Component getCustomEditor() {
return m_Panel; return m_Panel;
} }

View File

@@ -1,4 +1,5 @@
package eva2.gui.editor; package eva2.gui.editor;
/* /*
* Title: EvA2 * Title: EvA2
* Description: * Description:

View File

@@ -16,7 +16,9 @@ import javax.swing.JFrame;
* To change this template use Options | File Templates. * To change this template use Options | File Templates.
*/ */
public class EnumEditor extends PropertyEditorSupport { public class EnumEditor extends PropertyEditorSupport {
/** The Enum values that may be chosen */ /**
* The Enum values that may be chosen
*/
private Enum[] enumConstants; private Enum[] enumConstants;
@Override @Override
@@ -27,22 +29,22 @@ public class EnumEditor extends PropertyEditorSupport {
@Override @Override
public void setValue(Object value) { public void setValue(Object value) {
if (value instanceof Enum) { if (value instanceof Enum) {
enumConstants = ((Enum)value).getClass().getEnumConstants(); enumConstants = ((Enum) value).getClass().getEnumConstants();
// enumType = ((Enum)value); // enumType = ((Enum)value);
super.setValue(value); super.setValue(value);
} else if (value.getClass().isArray() && value.getClass().getComponentType().isEnum() ) { } else if (value.getClass().isArray() && value.getClass().getComponentType().isEnum()) {
// values = value.getClass().getComponentType().getEnumConstants(); // values = value.getClass().getComponentType().getEnumConstants();
Enum<?>[] e = (Enum[])(value); Enum<?>[] e = (Enum[]) (value);
enumConstants =(Enum[]) e.getClass().getComponentType().getEnumConstants(); enumConstants = (Enum[]) e.getClass().getComponentType().getEnumConstants();
super.setValue(value); super.setValue(value);
} }
} }
@Override @Override
public void setAsText(String text) throws IllegalArgumentException { public void setAsText(String text) throws IllegalArgumentException {
for (int i=0; i<enumConstants.length; i++) { for (int i = 0; i < enumConstants.length; i++) {
if (text.equals(enumConstants[i].toString())) { if (text.equals(enumConstants[i].toString())) {
setValue((Enum)enumConstants[i]); setValue((Enum) enumConstants[i]);
return; return;
} }
} }
@@ -51,12 +53,12 @@ public class EnumEditor extends PropertyEditorSupport {
@Override @Override
public String[] getTags() { public String[] getTags() {
if (getValue()==null) { if (getValue() == null) {
return null; return null;
} }
String[] tags = new String[enumConstants.length]; String[] tags = new String[enumConstants.length];
for (int i=0; i<tags.length; i++) { for (int i = 0; i < tags.length; i++) {
tags[i]=enumConstants[i].toString(); tags[i] = enumConstants[i].toString();
} }
return tags; return tags;
} }
@@ -66,7 +68,7 @@ public class EnumEditor extends PropertyEditorSupport {
* *
* @param args ignored * @param args ignored
*/ */
public static void main(String [] args) { public static void main(String[] args) {
try { try {
Enum<?> initial = TestEnum.asdf; Enum<?> initial = TestEnum.asdf;
EnumEditor ed = new EnumEditor(); EnumEditor ed = new EnumEditor();
@@ -90,4 +92,4 @@ public class EnumEditor extends PropertyEditorSupport {
} }
} }
enum TestEnum { asdf, sdf, asdfa}; enum TestEnum {asdf, sdf, asdfa};

View File

@@ -11,7 +11,9 @@ import eva2.optimization.individuals.codings.gp.GPArea;
* To change this template use Options | File Templates. * To change this template use Options | File Templates.
*/ */
public class GenericAreaEditor extends AbstractListSelectionEditor { public class GenericAreaEditor extends AbstractListSelectionEditor {
/** The GPArea that is to be edited*/ /**
* The GPArea that is to be edited
*/
private GPArea m_AreaObject; private GPArea m_AreaObject;
public GenericAreaEditor() { public GenericAreaEditor() {
@@ -25,13 +27,13 @@ public class GenericAreaEditor extends AbstractListSelectionEditor {
@Override @Override
protected String getElementName(int i) { protected String getElementName(int i) {
AbstractGPNode an = (AbstractGPNode)m_AreaObject.getCompleteList().get(i); AbstractGPNode an = (AbstractGPNode) m_AreaObject.getCompleteList().get(i);
return an.getName(); return an.getName();
} }
@Override @Override
protected boolean isElementSelected(int i) { protected boolean isElementSelected(int i) {
return ((Boolean)m_AreaObject.getBlackList().get(i)).booleanValue(); return ((Boolean) m_AreaObject.getBlackList().get(i)).booleanValue();
} }
@Override @Override

View File

@@ -3,6 +3,7 @@ package eva2.gui.editor;
import eva2.gui.*; import eva2.gui.*;
import eva2.tools.EVAHELP; import eva2.tools.EVAHELP;
import eva2.tools.SerializedObject; import eva2.tools.SerializedObject;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;

View File

@@ -28,7 +28,6 @@ import javax.swing.SwingConstants;
* A simple focus listener with an object ID and callback. * A simple focus listener with an object ID and callback.
* *
* @author mkron * @author mkron
*
*/ */
class MyFocusListener implements FocusListener { class MyFocusListener implements FocusListener {
private int myID = -1; private int myID = -1;
@@ -44,14 +43,19 @@ class MyFocusListener implements FocusListener {
* @see java.awt.event.FocusListener#focusLost(java.awt.event.FocusEvent) * @see java.awt.event.FocusListener#focusLost(java.awt.event.FocusEvent)
*/ */
@Override @Override
public void focusLost(FocusEvent e) { } public void focusLost(FocusEvent e) {
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see java.awt.event.FocusListener#focusGained(java.awt.event.FocusEvent) * @see java.awt.event.FocusListener#focusGained(java.awt.event.FocusEvent)
*/ */
@Override @Override
public void focusGained(FocusEvent e) { arrEditor.notifyFocusID(myID);}; public void focusGained(FocusEvent e) {
arrEditor.notifyFocusID(myID);
}
;
}; };
@@ -61,25 +65,37 @@ class MyFocusListener implements FocusListener {
public class GenericDoubleArrayEditor extends JPanel implements PropertyEditor { public class GenericDoubleArrayEditor extends JPanel implements PropertyEditor {
private static final long serialVersionUID = 7749892624600018812L; private static final long serialVersionUID = 7749892624600018812L;
/** Handles property change notification */ /**
* Handles property change notification
*/
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this); private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
/** The label for when we can't edit that type */ /**
* The label for when we can't edit that type
*/
private JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER); private JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER);
/** The FilePath that is to be edited*/ /**
* The FilePath that is to be edited
*/
private PropertyDoubleArray m_DoubleArray; private PropertyDoubleArray m_DoubleArray;
/** The gaphix stuff */ /**
* The gaphix stuff
*/
private JPanel m_CustomEditor, m_DataPanel, m_ButtonPanel; private JPanel m_CustomEditor, m_DataPanel, m_ButtonPanel;
private JTextField[][] m_InputTextFields; private JTextField[][] m_InputTextFields;
private JButton m_OKButton, m_AddButton, m_DeleteButton, m_NormalizeButton; private JButton m_OKButton, m_AddButton, m_DeleteButton, m_NormalizeButton;
/** Which columns has the focus? **/ /**
* Which columns has the focus? *
*/
private int lastFocussedRow = -1; private int lastFocussedRow = -1;
public GenericDoubleArrayEditor() { public GenericDoubleArrayEditor() {
// compiled code // compiled code
} }
/** This method will init the CustomEditor Panel /**
* This method will init the CustomEditor Panel
*/ */
private void initCustomEditor() { private void initCustomEditor() {
this.m_CustomEditor = new JPanel(); this.m_CustomEditor = new JPanel();
@@ -120,7 +136,8 @@ public class GenericDoubleArrayEditor extends JPanel implements PropertyEditor {
this.updateEditor(); this.updateEditor();
} }
/** This action listener adds an element to DoubleArray /**
* This action listener adds an element to DoubleArray
*/ */
ActionListener addAction = new ActionListener() { ActionListener addAction = new ActionListener() {
@Override @Override
@@ -130,13 +147,14 @@ public class GenericDoubleArrayEditor extends JPanel implements PropertyEditor {
} }
}; };
/** This action listener removes an element from the DoubleArray. /**
* This action listener removes an element from the DoubleArray.
*/ */
ActionListener deleteAction = new ActionListener() { ActionListener deleteAction = new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
if (!m_DoubleArray.isValidRow(lastFocussedRow)) { if (!m_DoubleArray.isValidRow(lastFocussedRow)) {
m_DoubleArray.deleteRow(m_DoubleArray.getNumRows()-1); m_DoubleArray.deleteRow(m_DoubleArray.getNumRows() - 1);
} else { } else {
m_DoubleArray.deleteRow(lastFocussedRow); m_DoubleArray.deleteRow(lastFocussedRow);
} }
@@ -155,12 +173,14 @@ public class GenericDoubleArrayEditor extends JPanel implements PropertyEditor {
} }
}; };
/** This action listener reads all values /**
* This action listener reads all values
*/ */
KeyListener readDoubleArrayAction = new KeyListener() { KeyListener readDoubleArrayAction = new KeyListener() {
@Override @Override
public void keyPressed(KeyEvent event) { public void keyPressed(KeyEvent event) {
} }
@Override @Override
public void keyTyped(KeyEvent event) { public void keyTyped(KeyEvent event) {
} }
@@ -170,7 +190,7 @@ public class GenericDoubleArrayEditor extends JPanel implements PropertyEditor {
double[][] tmpDD = new double[m_InputTextFields.length][m_InputTextFields[0].length]; double[][] tmpDD = new double[m_InputTextFields.length][m_InputTextFields[0].length];
for (int i = 0; i < tmpDD.length; i++) { for (int i = 0; i < tmpDD.length; i++) {
for (int j=0; j< tmpDD[0].length; j++) { for (int j = 0; j < tmpDD[0].length; j++) {
try { try {
double d = 0; double d = 0;
d = new Double(m_InputTextFields[i][j].getText()).doubleValue(); d = new Double(m_InputTextFields[i][j].getText()).doubleValue();
@@ -187,7 +207,8 @@ public class GenericDoubleArrayEditor extends JPanel implements PropertyEditor {
}; };
/** The object may have changed update the editor. /**
* The object may have changed update the editor.
*/ */
private void updateEditor() { private void updateEditor() {
if (this.m_CustomEditor != null) { if (this.m_CustomEditor != null) {
@@ -215,20 +236,21 @@ public class GenericDoubleArrayEditor extends JPanel implements PropertyEditor {
// } // }
// } // }
/** This method updates the data panel /**
* This method updates the data panel
*/ */
private void updateDataPanel() { private void updateDataPanel() {
int numRows = m_DoubleArray.getNumRows(); int numRows = m_DoubleArray.getNumRows();
int numCols = m_DoubleArray.getNumCols(); int numCols = m_DoubleArray.getNumCols();
this.m_DataPanel.removeAll(); this.m_DataPanel.removeAll();
this.m_DataPanel.setLayout(new GridLayout(numRows, numCols+1)); this.m_DataPanel.setLayout(new GridLayout(numRows, numCols + 1));
this.m_InputTextFields = new JTextField[numRows][numCols]; this.m_InputTextFields = new JTextField[numRows][numCols];
for (int i = 0; i < numRows; i++) { for (int i = 0; i < numRows; i++) {
JLabel label = new JLabel("Value X"+i+": "); JLabel label = new JLabel("Value X" + i + ": ");
this.m_DataPanel.add(label); this.m_DataPanel.add(label);
for (int j=0; j<numCols; j++) { for (int j = 0; j < numCols; j++) {
this.m_InputTextFields[i][j] = new JTextField(); this.m_InputTextFields[i][j] = new JTextField();
this.m_InputTextFields[i][j].setText(""+m_DoubleArray.getValue(i,j)); this.m_InputTextFields[i][j].setText("" + m_DoubleArray.getValue(i, j));
this.m_InputTextFields[i][j].addKeyListener(this.readDoubleArrayAction); this.m_InputTextFields[i][j].addKeyListener(this.readDoubleArrayAction);
this.m_InputTextFields[i][j].addFocusListener(new MyFocusListener(i, this)); this.m_InputTextFields[i][j].addFocusListener(new MyFocusListener(i, this));
this.m_DataPanel.add(this.m_InputTextFields[i][j]); this.m_DataPanel.add(this.m_InputTextFields[i][j]);
@@ -238,11 +260,13 @@ public class GenericDoubleArrayEditor extends JPanel implements PropertyEditor {
public void notifyFocusID(int id) { public void notifyFocusID(int id) {
// notification of which column has the focus // notification of which column has the focus
lastFocussedRow =id; lastFocussedRow = id;
// System.out.println("Focus now on " + id); // System.out.println("Focus now on " + id);
} }
/** This method will set the value of object that is to be edited. /**
* This method will set the value of object that is to be edited.
*
* @param o an object that must be an array. * @param o an object that must be an array.
*/ */
@Override @Override
@@ -253,7 +277,9 @@ public class GenericDoubleArrayEditor extends JPanel implements PropertyEditor {
} }
} }
/** Returns the current object. /**
* Returns the current object.
*
* @return the current object * @return the current object
*/ */
@Override @Override
@@ -306,21 +332,27 @@ public class GenericDoubleArrayEditor extends JPanel implements PropertyEditor {
m_Support.removePropertyChangeListener(l); m_Support.removePropertyChangeListener(l);
} }
/** This is used to hook an action listener to the ok button /**
* This is used to hook an action listener to the ok button
*
* @param a The action listener. * @param a The action listener.
*/ */
public void addOkListener(ActionListener a) { public void addOkListener(ActionListener a) {
m_OKButton.addActionListener(a); m_OKButton.addActionListener(a);
} }
/** This is used to remove an action listener from the ok button /**
* This is used to remove an action listener from the ok button
*
* @param a The action listener * @param a The action listener
*/ */
public void removeOkListener(ActionListener a) { public void removeOkListener(ActionListener a) {
m_OKButton.removeActionListener(a); m_OKButton.removeActionListener(a);
} }
/** Returns true since the Object can be shown /**
* Returns true since the Object can be shown
*
* @return true * @return true
*/ */
@Override @Override
@@ -328,7 +360,8 @@ public class GenericDoubleArrayEditor extends JPanel implements PropertyEditor {
return true; return true;
} }
/** Paints a representation of the current classifier. /**
* Paints a representation of the current classifier.
* *
* @param gfx the graphics context to use * @param gfx the graphics context to use
* @param box the area we are allowed to paint into * @param box the area we are allowed to paint into
@@ -338,10 +371,12 @@ public class GenericDoubleArrayEditor extends JPanel implements PropertyEditor {
FontMetrics fm = gfx.getFontMetrics(); FontMetrics fm = gfx.getFontMetrics();
int vpad = (box.height - fm.getAscent()) / 2; int vpad = (box.height - fm.getAscent()) / 2;
String rep = "Edit double array..."; String rep = "Edit double array...";
gfx.drawString(rep, 2, fm.getHeight() + vpad - 3 ); gfx.drawString(rep, 2, fm.getHeight() + vpad - 3);
} }
/** Returns true because we do support a custom editor. /**
* Returns true because we do support a custom editor.
*
* @return true * @return true
*/ */
@Override @Override
@@ -349,7 +384,9 @@ public class GenericDoubleArrayEditor extends JPanel implements PropertyEditor {
return true; return true;
} }
/** Returns the array editing component. /**
* Returns the array editing component.
*
* @return a value of type 'java.awt.Component' * @return a value of type 'java.awt.Component'
*/ */
@Override @Override

View File

@@ -18,14 +18,22 @@ import javax.swing.*;
*/ */
public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEditor { public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEditor {
/** Handles property change notification */ /**
* Handles property change notification
*/
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this); private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
/** The label for when we can't edit that type */ /**
* The label for when we can't edit that type
*/
private JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER); private JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER);
/** The FilePath that is to be edited*/ /**
* The FilePath that is to be edited
*/
private PropertyEpsilonConstraint m_EpsilonConstraint; private PropertyEpsilonConstraint m_EpsilonConstraint;
/** The gaphix stuff */ /**
* The gaphix stuff
*/
private JPanel m_CustomEditor, m_DataPanel, m_ButtonPanel, m_TargetPanel; private JPanel m_CustomEditor, m_DataPanel, m_ButtonPanel, m_TargetPanel;
private JTextField[] m_TargetTextField; private JTextField[] m_TargetTextField;
private JComboBox m_Objective; private JComboBox m_Objective;
@@ -35,7 +43,8 @@ public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEd
// compiled code // compiled code
} }
/** This method will init the CustomEditor Panel /**
* This method will init the CustomEditor Panel
*/ */
private void initCustomEditor() { private void initCustomEditor() {
this.m_CustomEditor = new JPanel(); this.m_CustomEditor = new JPanel();
@@ -47,7 +56,7 @@ public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEd
this.m_TargetPanel.add(new JLabel("Optimize:")); this.m_TargetPanel.add(new JLabel("Optimize:"));
this.m_Objective = new JComboBox(); this.m_Objective = new JComboBox();
for (int i = 0; i < this.m_EpsilonConstraint.m_TargetValue.length; i++) { for (int i = 0; i < this.m_EpsilonConstraint.m_TargetValue.length; i++) {
this.m_Objective.addItem("Objective "+i); this.m_Objective.addItem("Objective " + i);
} }
this.m_TargetPanel.add(this.m_Objective); this.m_TargetPanel.add(this.m_Objective);
this.m_Objective.addItemListener(this.objectiveAction); this.m_Objective.addItemListener(this.objectiveAction);
@@ -77,7 +86,8 @@ public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEd
this.updateEditor(); this.updateEditor();
} }
/** This action listener adds an element to DoubleArray /**
* This action listener adds an element to DoubleArray
*/ */
ItemListener objectiveAction = new ItemListener() { ItemListener objectiveAction = new ItemListener() {
@Override @Override
@@ -87,12 +97,14 @@ public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEd
} }
}; };
/** This action listener reads all values /**
* This action listener reads all values
*/ */
KeyListener readDoubleArrayAction = new KeyListener() { KeyListener readDoubleArrayAction = new KeyListener() {
@Override @Override
public void keyPressed(KeyEvent event) { public void keyPressed(KeyEvent event) {
} }
@Override @Override
public void keyTyped(KeyEvent event) { public void keyTyped(KeyEvent event) {
} }
@@ -116,7 +128,8 @@ public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEd
} }
}; };
/** The object may have changed update the editor. /**
* The object may have changed update the editor.
*/ */
private void updateEditor() { private void updateEditor() {
if (this.m_CustomEditor != null) { if (this.m_CustomEditor != null) {
@@ -126,22 +139,23 @@ public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEd
} }
} }
/** This method updates the data panel /**
* This method updates the data panel
*/ */
private void updateDataPanel() { private void updateDataPanel() {
double[] tmpT = this.m_EpsilonConstraint.m_TargetValue; double[] tmpT = this.m_EpsilonConstraint.m_TargetValue;
int obj = this.m_EpsilonConstraint.m_OptimizeObjective; int obj = this.m_EpsilonConstraint.m_OptimizeObjective;
this.m_DataPanel.removeAll(); this.m_DataPanel.removeAll();
this.m_DataPanel.setLayout(new GridLayout(tmpT.length+1, 2)); this.m_DataPanel.setLayout(new GridLayout(tmpT.length + 1, 2));
this.m_DataPanel.add(new JLabel()); this.m_DataPanel.add(new JLabel());
this.m_DataPanel.add(new JLabel("Target Value")); this.m_DataPanel.add(new JLabel("Target Value"));
this.m_TargetTextField = new JTextField[tmpT.length]; this.m_TargetTextField = new JTextField[tmpT.length];
for (int i = 0; i < tmpT.length; i++) { for (int i = 0; i < tmpT.length; i++) {
JLabel label = new JLabel("Objective "+i+": "); JLabel label = new JLabel("Objective " + i + ": ");
this.m_DataPanel.add(label); this.m_DataPanel.add(label);
this.m_TargetTextField[i] = new JTextField(); this.m_TargetTextField[i] = new JTextField();
this.m_TargetTextField[i].setText(""+tmpT[i]); this.m_TargetTextField[i].setText("" + tmpT[i]);
this.m_TargetTextField[i].addKeyListener(this.readDoubleArrayAction); this.m_TargetTextField[i].addKeyListener(this.readDoubleArrayAction);
this.m_DataPanel.add(this.m_TargetTextField[i]); this.m_DataPanel.add(this.m_TargetTextField[i]);
} }
@@ -149,7 +163,9 @@ public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEd
} }
/** This method will set the value of object that is to be edited. /**
* This method will set the value of object that is to be edited.
*
* @param o an object that must be an array. * @param o an object that must be an array.
*/ */
@Override @Override
@@ -160,7 +176,9 @@ public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEd
} }
} }
/** Returns the current object. /**
* Returns the current object.
*
* @return the current object * @return the current object
*/ */
@Override @Override
@@ -213,21 +231,27 @@ public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEd
m_Support.removePropertyChangeListener(l); m_Support.removePropertyChangeListener(l);
} }
/** This is used to hook an action listener to the ok button /**
* This is used to hook an action listener to the ok button
*
* @param a The action listener. * @param a The action listener.
*/ */
public void addOkListener(ActionListener a) { public void addOkListener(ActionListener a) {
m_OKButton.addActionListener(a); m_OKButton.addActionListener(a);
} }
/** This is used to remove an action listener from the ok button /**
* This is used to remove an action listener from the ok button
*
* @param a The action listener * @param a The action listener
*/ */
public void removeOkListener(ActionListener a) { public void removeOkListener(ActionListener a) {
m_OKButton.removeActionListener(a); m_OKButton.removeActionListener(a);
} }
/** Returns true since the Object can be shown /**
* Returns true since the Object can be shown
*
* @return true * @return true
*/ */
@Override @Override
@@ -235,7 +259,8 @@ public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEd
return true; return true;
} }
/** Paints a representation of the current classifier. /**
* Paints a representation of the current classifier.
* *
* @param gfx the graphics context to use * @param gfx the graphics context to use
* @param box the area we are allowed to paint into * @param box the area we are allowed to paint into
@@ -245,10 +270,12 @@ public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEd
FontMetrics fm = gfx.getFontMetrics(); FontMetrics fm = gfx.getFontMetrics();
int vpad = (box.height - fm.getAscent()) / 2; int vpad = (box.height - fm.getAscent()) / 2;
String rep = "Edit Epsilon Constraint"; String rep = "Edit Epsilon Constraint";
gfx.drawString(rep, 2, fm.getHeight() + vpad - 3 ); gfx.drawString(rep, 2, fm.getHeight() + vpad - 3);
} }
/** Returns true because we do support a custom editor. /**
* Returns true because we do support a custom editor.
*
* @return true * @return true
*/ */
@Override @Override
@@ -256,7 +283,9 @@ public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEd
return true; return true;
} }
/** Returns the array editing component. /**
* Returns the array editing component.
*
* @return a value of type 'java.awt.Component' * @return a value of type 'java.awt.Component'
*/ */
@Override @Override

View File

@@ -18,14 +18,22 @@ import javax.swing.*;
*/ */
public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEditor { public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEditor {
/** Handles property change notification */ /**
* Handles property change notification
*/
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this); private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
/** The label for when we can't edit that type */ /**
* The label for when we can't edit that type
*/
private JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER); private JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER);
/** The FilePath that is to be edited*/ /**
* The FilePath that is to be edited
*/
private PropertyEpsilonThreshold m_EpsilonThreshhold; private PropertyEpsilonThreshold m_EpsilonThreshhold;
/** The gaphix stuff */ /**
* The gaphix stuff
*/
private JPanel m_CustomEditor, m_DataPanel, m_ButtonPanel, m_TargetPanel; private JPanel m_CustomEditor, m_DataPanel, m_ButtonPanel, m_TargetPanel;
private JTextField[] m_TargetTextField, m_PunishTextField; private JTextField[] m_TargetTextField, m_PunishTextField;
private JComboBox m_Objective; private JComboBox m_Objective;
@@ -35,7 +43,8 @@ public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEdi
// compiled code // compiled code
} }
/** This method will init the CustomEditor Panel /**
* This method will init the CustomEditor Panel
*/ */
private void initCustomEditor() { private void initCustomEditor() {
this.m_CustomEditor = new JPanel(); this.m_CustomEditor = new JPanel();
@@ -47,7 +56,7 @@ public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEdi
this.m_TargetPanel.add(new JLabel("Optimize:")); this.m_TargetPanel.add(new JLabel("Optimize:"));
this.m_Objective = new JComboBox(); this.m_Objective = new JComboBox();
for (int i = 0; i < this.m_EpsilonThreshhold.m_TargetValue.length; i++) { for (int i = 0; i < this.m_EpsilonThreshhold.m_TargetValue.length; i++) {
this.m_Objective.addItem("Objective "+i); this.m_Objective.addItem("Objective " + i);
} }
this.m_TargetPanel.add(this.m_Objective); this.m_TargetPanel.add(this.m_Objective);
this.m_Objective.addItemListener(this.objectiveAction); this.m_Objective.addItemListener(this.objectiveAction);
@@ -77,7 +86,8 @@ public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEdi
this.updateEditor(); this.updateEditor();
} }
/** This action listener adds an element to DoubleArray /**
* This action listener adds an element to DoubleArray
*/ */
ItemListener objectiveAction = new ItemListener() { ItemListener objectiveAction = new ItemListener() {
@Override @Override
@@ -87,12 +97,14 @@ public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEdi
} }
}; };
/** This action listener reads all values /**
* This action listener reads all values
*/ */
KeyListener readDoubleArrayAction = new KeyListener() { KeyListener readDoubleArrayAction = new KeyListener() {
@Override @Override
public void keyPressed(KeyEvent event) { public void keyPressed(KeyEvent event) {
} }
@Override @Override
public void keyTyped(KeyEvent event) { public void keyTyped(KeyEvent event) {
} }
@@ -125,7 +137,8 @@ public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEdi
} }
}; };
/** The object may have changed update the editor. /**
* The object may have changed update the editor.
*/ */
private void updateEditor() { private void updateEditor() {
if (this.m_CustomEditor != null) { if (this.m_CustomEditor != null) {
@@ -135,7 +148,8 @@ public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEdi
} }
} }
/** This method updates the data panel /**
* This method updates the data panel
*/ */
private void updateDataPanel() { private void updateDataPanel() {
double[] tmpT = this.m_EpsilonThreshhold.m_TargetValue; double[] tmpT = this.m_EpsilonThreshhold.m_TargetValue;
@@ -143,21 +157,21 @@ public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEdi
int obj = this.m_EpsilonThreshhold.m_OptimizeObjective; int obj = this.m_EpsilonThreshhold.m_OptimizeObjective;
this.m_DataPanel.removeAll(); this.m_DataPanel.removeAll();
this.m_DataPanel.setLayout(new GridLayout(tmpT.length+1, 3)); this.m_DataPanel.setLayout(new GridLayout(tmpT.length + 1, 3));
this.m_DataPanel.add(new JLabel()); this.m_DataPanel.add(new JLabel());
this.m_DataPanel.add(new JLabel("Target Value")); this.m_DataPanel.add(new JLabel("Target Value"));
this.m_DataPanel.add(new JLabel("Punishment")); this.m_DataPanel.add(new JLabel("Punishment"));
this.m_TargetTextField = new JTextField[tmpT.length]; this.m_TargetTextField = new JTextField[tmpT.length];
this.m_PunishTextField = new JTextField[tmpT.length]; this.m_PunishTextField = new JTextField[tmpT.length];
for (int i = 0; i < tmpT.length; i++) { for (int i = 0; i < tmpT.length; i++) {
JLabel label = new JLabel("Objective "+i+": "); JLabel label = new JLabel("Objective " + i + ": ");
this.m_DataPanel.add(label); this.m_DataPanel.add(label);
this.m_TargetTextField[i] = new JTextField(); this.m_TargetTextField[i] = new JTextField();
this.m_TargetTextField[i].setText(""+tmpT[i]); this.m_TargetTextField[i].setText("" + tmpT[i]);
this.m_TargetTextField[i].addKeyListener(this.readDoubleArrayAction); this.m_TargetTextField[i].addKeyListener(this.readDoubleArrayAction);
this.m_DataPanel.add(this.m_TargetTextField[i]); this.m_DataPanel.add(this.m_TargetTextField[i]);
this.m_PunishTextField[i] = new JTextField(); this.m_PunishTextField[i] = new JTextField();
this.m_PunishTextField[i].setText(""+tmpP[i]); this.m_PunishTextField[i].setText("" + tmpP[i]);
this.m_PunishTextField[i].addKeyListener(this.readDoubleArrayAction); this.m_PunishTextField[i].addKeyListener(this.readDoubleArrayAction);
this.m_DataPanel.add(this.m_PunishTextField[i]); this.m_DataPanel.add(this.m_PunishTextField[i]);
} }
@@ -166,7 +180,9 @@ public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEdi
} }
/** This method will set the value of object that is to be edited. /**
* This method will set the value of object that is to be edited.
*
* @param o an object that must be an array. * @param o an object that must be an array.
*/ */
@Override @Override
@@ -177,7 +193,9 @@ public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEdi
} }
} }
/** Returns the current object. /**
* Returns the current object.
*
* @return the current object * @return the current object
*/ */
@Override @Override
@@ -230,21 +248,27 @@ public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEdi
m_Support.removePropertyChangeListener(l); m_Support.removePropertyChangeListener(l);
} }
/** This is used to hook an action listener to the ok button /**
* This is used to hook an action listener to the ok button
*
* @param a The action listener. * @param a The action listener.
*/ */
public void addOkListener(ActionListener a) { public void addOkListener(ActionListener a) {
m_OKButton.addActionListener(a); m_OKButton.addActionListener(a);
} }
/** This is used to remove an action listener from the ok button /**
* This is used to remove an action listener from the ok button
*
* @param a The action listener * @param a The action listener
*/ */
public void removeOkListener(ActionListener a) { public void removeOkListener(ActionListener a) {
m_OKButton.removeActionListener(a); m_OKButton.removeActionListener(a);
} }
/** Returns true since the Object can be shown /**
* Returns true since the Object can be shown
*
* @return true * @return true
*/ */
@Override @Override
@@ -252,7 +276,8 @@ public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEdi
return true; return true;
} }
/** Paints a representation of the current classifier. /**
* Paints a representation of the current classifier.
* *
* @param gfx the graphics context to use * @param gfx the graphics context to use
* @param box the area we are allowed to paint into * @param box the area we are allowed to paint into
@@ -262,10 +287,12 @@ public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEdi
FontMetrics fm = gfx.getFontMetrics(); FontMetrics fm = gfx.getFontMetrics();
int vpad = (box.height - fm.getAscent()) / 2; int vpad = (box.height - fm.getAscent()) / 2;
String rep = "Edit Epsilon Threshhold"; String rep = "Edit Epsilon Threshhold";
gfx.drawString(rep, 2, fm.getHeight() + vpad - 3 ); gfx.drawString(rep, 2, fm.getHeight() + vpad - 3);
} }
/** Returns true because we do support a custom editor. /**
* Returns true because we do support a custom editor.
*
* @return true * @return true
*/ */
@Override @Override
@@ -273,7 +300,9 @@ public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEdi
return true; return true;
} }
/** Returns the array editing component. /**
* Returns the array editing component.
*
* @return a value of type 'java.awt.Component' * @return a value of type 'java.awt.Component'
*/ */
@Override @Override

View File

@@ -23,14 +23,22 @@ import javax.swing.SwingConstants;
*/ */
public class GenericFilePathEditor extends JPanel implements PropertyEditor { public class GenericFilePathEditor extends JPanel implements PropertyEditor {
/** Handles property change notification */ /**
* Handles property change notification
*/
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this); private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
/** The label for when we can't edit that type */ /**
* The label for when we can't edit that type
*/
private JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER); private JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER);
/** The FilePath that is to be edited*/ /**
* The FilePath that is to be edited
*/
private PropertyFilePath m_FilePath; private PropertyFilePath m_FilePath;
/** The gaphix stuff */ /**
* The gaphix stuff
*/
private JFileChooser m_FileChooser; private JFileChooser m_FileChooser;
private JPanel m_Panel; private JPanel m_Panel;
@@ -38,7 +46,9 @@ public class GenericFilePathEditor extends JPanel implements PropertyEditor {
// compiled code // compiled code
} }
/** This method will set the value of object that is to be edited. /**
* This method will set the value of object that is to be edited.
*
* @param o an object that must be an array. * @param o an object that must be an array.
*/ */
@Override @Override
@@ -48,7 +58,9 @@ public class GenericFilePathEditor extends JPanel implements PropertyEditor {
} }
} }
/** Returns the current object. /**
* Returns the current object.
*
* @return the current object * @return the current object
*/ */
@Override @Override
@@ -101,7 +113,9 @@ public class GenericFilePathEditor extends JPanel implements PropertyEditor {
m_Support.removePropertyChangeListener(l); m_Support.removePropertyChangeListener(l);
} }
/** Returns true since the Object can be shown /**
* Returns true since the Object can be shown
*
* @return true * @return true
*/ */
@Override @Override
@@ -109,7 +123,8 @@ public class GenericFilePathEditor extends JPanel implements PropertyEditor {
return true; return true;
} }
/** Paints a representation of the current classifier. /**
* Paints a representation of the current classifier.
* *
* @param gfx the graphics context to use * @param gfx the graphics context to use
* @param box the area we are allowed to paint into * @param box the area we are allowed to paint into
@@ -119,10 +134,12 @@ public class GenericFilePathEditor extends JPanel implements PropertyEditor {
FontMetrics fm = gfx.getFontMetrics(); FontMetrics fm = gfx.getFontMetrics();
int vpad = (box.height - fm.getAscent()) / 2; int vpad = (box.height - fm.getAscent()) / 2;
String rep = this.m_FilePath.FileName; String rep = this.m_FilePath.FileName;
gfx.drawString(rep, 2, fm.getHeight() + vpad - 3 ); gfx.drawString(rep, 2, fm.getHeight() + vpad - 3);
} }
/** Returns true because we do support a custom editor. /**
* Returns true because we do support a custom editor.
*
* @return true * @return true
*/ */
@Override @Override
@@ -130,7 +147,9 @@ public class GenericFilePathEditor extends JPanel implements PropertyEditor {
return true; return true;
} }
/** Returns the array editing component. /**
* Returns the array editing component.
*
* @return a value of type 'java.awt.Component' * @return a value of type 'java.awt.Component'
*/ */
@Override @Override
@@ -145,7 +164,8 @@ public class GenericFilePathEditor extends JPanel implements PropertyEditor {
return this.m_Panel; return this.m_Panel;
} }
/** This action listener, called by the "train" button, causes /**
* This action listener, called by the "train" button, causes
* the SOM to recalculate the mapping. * the SOM to recalculate the mapping.
*/ */
ActionListener fileChooserAction = new ActionListener() { ActionListener fileChooserAction = new ActionListener() {

View File

@@ -21,14 +21,22 @@ import javax.swing.*;
*/ */
public class GenericIntArrayEditor extends JPanel implements PropertyEditor { public class GenericIntArrayEditor extends JPanel implements PropertyEditor {
/** Handles property change notification */ /**
* Handles property change notification
*/
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this); private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
/** The label for when we can't edit that type */ /**
* The label for when we can't edit that type
*/
private JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER); private JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER);
/** The FilePath that is to be edited*/ /**
* The FilePath that is to be edited
*/
private PropertyIntArray m_IntArray; private PropertyIntArray m_IntArray;
/** The gaphix stuff */ /**
* The gaphix stuff
*/
private JPanel m_CustomEditor, m_DataPanel, m_ButtonPanel; private JPanel m_CustomEditor, m_DataPanel, m_ButtonPanel;
private JTextField[] m_InputTextField; private JTextField[] m_InputTextField;
private JButton m_OKButton; private JButton m_OKButton;
@@ -37,7 +45,8 @@ public class GenericIntArrayEditor extends JPanel implements PropertyEditor {
// compiled code // compiled code
} }
/** This method will init the CustomEditor Panel /**
* This method will init the CustomEditor Panel
*/ */
private void initCustomEditor() { private void initCustomEditor() {
this.m_CustomEditor = new JPanel(); this.m_CustomEditor = new JPanel();
@@ -69,12 +78,14 @@ public class GenericIntArrayEditor extends JPanel implements PropertyEditor {
this.updateEditor(); this.updateEditor();
} }
/** This action listener reads all values /**
* This action listener reads all values
*/ */
KeyListener readIntArrayAction = new KeyListener() { KeyListener readIntArrayAction = new KeyListener() {
@Override @Override
public void keyPressed(KeyEvent event) { public void keyPressed(KeyEvent event) {
} }
@Override @Override
public void keyTyped(KeyEvent event) { public void keyTyped(KeyEvent event) {
} }
@@ -96,7 +107,8 @@ public class GenericIntArrayEditor extends JPanel implements PropertyEditor {
} }
}; };
/** The object may have changed update the editor. /**
* The object may have changed update the editor.
*/ */
private void updateEditor() { private void updateEditor() {
if (this.m_CustomEditor != null) { if (this.m_CustomEditor != null) {
@@ -106,7 +118,8 @@ public class GenericIntArrayEditor extends JPanel implements PropertyEditor {
} }
} }
/** This method updates the data panel /**
* This method updates the data panel
*/ */
private void updateDataPanel() { private void updateDataPanel() {
int[] tmpD = this.m_IntArray.getIntArray(); int[] tmpD = this.m_IntArray.getIntArray();
@@ -115,17 +128,19 @@ public class GenericIntArrayEditor extends JPanel implements PropertyEditor {
this.m_DataPanel.setLayout(new GridLayout(tmpD.length, 2)); this.m_DataPanel.setLayout(new GridLayout(tmpD.length, 2));
this.m_InputTextField = new JTextField[tmpD.length]; this.m_InputTextField = new JTextField[tmpD.length];
for (int i = 0; i < tmpD.length; i++) { for (int i = 0; i < tmpD.length; i++) {
JLabel label = new JLabel("Value X"+i+": "); JLabel label = new JLabel("Value X" + i + ": ");
this.m_DataPanel.add(label); this.m_DataPanel.add(label);
this.m_InputTextField[i] = new JTextField(); this.m_InputTextField[i] = new JTextField();
this.m_InputTextField[i].setText(""+tmpD[i]); this.m_InputTextField[i].setText("" + tmpD[i]);
this.m_InputTextField[i].addKeyListener(this.readIntArrayAction); this.m_InputTextField[i].addKeyListener(this.readIntArrayAction);
this.m_DataPanel.add(this.m_InputTextField[i]); this.m_DataPanel.add(this.m_InputTextField[i]);
} }
} }
/** This method will set the value of object that is to be edited. /**
* This method will set the value of object that is to be edited.
*
* @param o an object that must be an array. * @param o an object that must be an array.
*/ */
@Override @Override
@@ -136,7 +151,9 @@ public class GenericIntArrayEditor extends JPanel implements PropertyEditor {
} }
} }
/** Returns the current object. /**
* Returns the current object.
*
* @return the current object * @return the current object
*/ */
@Override @Override
@@ -189,21 +206,27 @@ public class GenericIntArrayEditor extends JPanel implements PropertyEditor {
m_Support.removePropertyChangeListener(l); m_Support.removePropertyChangeListener(l);
} }
/** This is used to hook an action listener to the ok button /**
* This is used to hook an action listener to the ok button
*
* @param a The action listener. * @param a The action listener.
*/ */
public void addOkListener(ActionListener a) { public void addOkListener(ActionListener a) {
m_OKButton.addActionListener(a); m_OKButton.addActionListener(a);
} }
/** This is used to remove an action listener from the ok button /**
* This is used to remove an action listener from the ok button
*
* @param a The action listener * @param a The action listener
*/ */
public void removeOkListener(ActionListener a) { public void removeOkListener(ActionListener a) {
m_OKButton.removeActionListener(a); m_OKButton.removeActionListener(a);
} }
/** Returns true since the Object can be shown /**
* Returns true since the Object can be shown
*
* @return true * @return true
*/ */
@Override @Override
@@ -211,7 +234,8 @@ public class GenericIntArrayEditor extends JPanel implements PropertyEditor {
return true; return true;
} }
/** Paints a representation of the current classifier. /**
* Paints a representation of the current classifier.
* *
* @param gfx the graphics context to use * @param gfx the graphics context to use
* @param box the area we are allowed to paint into * @param box the area we are allowed to paint into
@@ -221,10 +245,12 @@ public class GenericIntArrayEditor extends JPanel implements PropertyEditor {
FontMetrics fm = gfx.getFontMetrics(); FontMetrics fm = gfx.getFontMetrics();
int vpad = (box.height - fm.getAscent()) / 2; int vpad = (box.height - fm.getAscent()) / 2;
String rep = "Edit int[]"; String rep = "Edit int[]";
gfx.drawString(rep, 2, fm.getHeight() + vpad - 3 ); gfx.drawString(rep, 2, fm.getHeight() + vpad - 3);
} }
/** Returns true because we do support a custom editor. /**
* Returns true because we do support a custom editor.
*
* @return true * @return true
*/ */
@Override @Override
@@ -232,7 +258,9 @@ public class GenericIntArrayEditor extends JPanel implements PropertyEditor {
return true; return true;
} }
/** Returns the array editing component. /**
* Returns the array editing component.
*
* @return a value of type 'java.awt.Component' * @return a value of type 'java.awt.Component'
*/ */
@Override @Override

View File

@@ -8,6 +8,7 @@ package eva2.gui.editor;
import eva2.EvAInfo; import eva2.EvAInfo;
import eva2.gui.GOEPanel; import eva2.gui.GOEPanel;
import eva2.tools.ReflectPackage; import eva2.tools.ReflectPackage;
import java.awt.Component; import java.awt.Component;
import java.awt.FontMetrics; import java.awt.FontMetrics;
import java.awt.Graphics; import java.awt.Graphics;
@@ -76,9 +77,9 @@ public class GenericObjectEditor implements PropertyEditor {
* "hideFromGOE" this method will skip it. Abstract classes and interfaces will be skipped as * "hideFromGOE" this method will skip it. Abstract classes and interfaces will be skipped as
* well. * well.
* *
* @see ReflectPackage.getAssignableClassesInPackage
* @param className * @param className
* @return * @return
* @see ReflectPackage.getAssignableClassesInPackage
*/ */
public static ArrayList<String> getClassesFromClassPath(String className, ArrayList<Class<?>> instances) { public static ArrayList<String> getClassesFromClassPath(String className, ArrayList<Class<?>> instances) {
ArrayList<String> classes = new ArrayList<String>(); ArrayList<String> classes = new ArrayList<String>();
@@ -439,7 +440,7 @@ public class GenericObjectEditor implements PropertyEditor {
* Returns null as we don't support getting/setting values as text. * Returns null as we don't support getting/setting values as text.
* *
* @param text the text value * @param text the text value
* @exception IllegalArgumentException as we don't support getting/setting values as text. * @throws IllegalArgumentException as we don't support getting/setting values as text.
*/ */
@Override @Override
public void setAsText(String text) throws IllegalArgumentException { public void setAsText(String text) throws IllegalArgumentException {

View File

@@ -4,12 +4,12 @@ import eva2.gui.PropertySelectableList;
/** /**
* An editor for a selectable List. * An editor for a selectable List.
*
*/ */
public class GenericObjectListSelectionEditor extends AbstractListSelectionEditor { public class GenericObjectListSelectionEditor extends AbstractListSelectionEditor {
private PropertySelectableList objList; private PropertySelectableList objList;
public GenericObjectListSelectionEditor() {} public GenericObjectListSelectionEditor() {
}
@Override @Override
protected int getElementCount() { protected int getElementCount() {
@@ -28,11 +28,11 @@ public class GenericObjectListSelectionEditor extends AbstractListSelectionEdito
@Override @Override
protected boolean actionOnSelect() { protected boolean actionOnSelect() {
boolean changed=false; boolean changed = false;
for (int i = 0; i < this.m_BlackCheck.length; i++) { for (int i = 0; i < this.m_BlackCheck.length; i++) {
if (objList.isSelected(i)!=this.m_BlackCheck[i].isSelected()) { if (objList.isSelected(i) != this.m_BlackCheck[i].isSelected()) {
objList.setSelectionForElement(i, this.m_BlackCheck[i].isSelected()); objList.setSelectionForElement(i, this.m_BlackCheck[i].isSelected());
changed=true; changed = true;
} }
} }
return changed; return changed;
@@ -49,7 +49,9 @@ public class GenericObjectListSelectionEditor extends AbstractListSelectionEdito
} }
} }
/** Retruns the current object. /**
* Retruns the current object.
*
* @return the current object * @return the current object
*/ */
@Override @Override

View File

@@ -8,6 +8,7 @@ import eva2.optimization.problems.InterfaceOptimizationTarget;
import eva2.optimization.tools.AbstractObjectEditor; import eva2.optimization.tools.AbstractObjectEditor;
import eva2.optimization.tools.GeneralGOEProperty; import eva2.optimization.tools.GeneralGOEProperty;
import eva2.tools.BasicResourceLoader; import eva2.tools.BasicResourceLoader;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
@@ -44,14 +45,22 @@ import javax.swing.SwingConstants;
*/ */
public class GenericOptimizationObjectivesEditor extends JPanel implements PropertyEditor, java.beans.PropertyChangeListener { public class GenericOptimizationObjectivesEditor extends JPanel implements PropertyEditor, java.beans.PropertyChangeListener {
/** Handles property change notification */ /**
* Handles property change notification
*/
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this); private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
/** The label for when we can't edit that type */ /**
* The label for when we can't edit that type
*/
private JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER); private JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER);
/** The FilePath that is to be edited*/ /**
* The FilePath that is to be edited
*/
private PropertyOptimizationObjectives m_OptimizationObjectives; private PropertyOptimizationObjectives m_OptimizationObjectives;
/** The gaphix stuff */ /**
* The gaphix stuff
*/
private JComponent m_Editor; private JComponent m_Editor;
private JPanel m_TargetList; private JPanel m_TargetList;
private JComponent[] m_Targets; private JComponent[] m_Targets;
@@ -65,7 +74,8 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
} }
/** This method will init the CustomEditor Panel /**
* This method will init the CustomEditor Panel
*/ */
private void initCustomEditor() { private void initCustomEditor() {
m_self = this; m_self = this;
@@ -112,7 +122,7 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
// Some description would be nice // Some description would be nice
JTextArea jt = new JTextArea(); JTextArea jt = new JTextArea();
jt.setFont(new Font("SansSerif", Font.PLAIN,12)); jt.setFont(new Font("SansSerif", Font.PLAIN, 12));
jt.setEditable(false); jt.setEditable(false);
jt.setLineWrap(true); jt.setLineWrap(true);
jt.setWrapStyleWord(true); jt.setWrapStyleWord(true);
@@ -137,8 +147,8 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
this.updateEditor(); this.updateEditor();
} }
/** This method updates the server list /**
* * This method updates the server list
*/ */
private void updateTargetList() { private void updateTargetList() {
BasicResourceLoader loader = BasicResourceLoader.instance(); BasicResourceLoader loader = BasicResourceLoader.instance();
@@ -152,7 +162,7 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
this.m_Delete = new JButton[list.length]; this.m_Delete = new JButton[list.length];
String[] cups = new String[8]; String[] cups = new String[8];
for (int i = 0; i < cups.length; i++) { for (int i = 0; i < cups.length; i++) {
cups[i] = ""+(i+1); cups[i] = "" + (i + 1);
} }
// The head title // The head title
gbc.anchor = GridBagConstraints.WEST; gbc.anchor = GridBagConstraints.WEST;
@@ -197,7 +207,8 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
} }
} }
/** This action listener,... /**
* This action listener,...
*/ */
ActionListener updateTargets = new ActionListener() { ActionListener updateTargets = new ActionListener() {
@Override @Override
@@ -206,12 +217,13 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
} }
}; };
/** This action listener,... /**
* This action listener,...
*/ */
ActionListener addTarget = new ActionListener() { ActionListener addTarget = new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
m_OptimizationObjectives.addTarget((InterfaceOptimizationObjective)m_OptimizationObjectives.getAvailableTargets()[0].clone()); m_OptimizationObjectives.addTarget((InterfaceOptimizationObjective) m_OptimizationObjectives.getAvailableTargets()[0].clone());
int l = m_OptimizationObjectives.getSelectedTargets().length; int l = m_OptimizationObjectives.getSelectedTargets().length;
GeneralGOEProperty[] newEdit = new GeneralGOEProperty[l]; GeneralGOEProperty[] newEdit = new GeneralGOEProperty[l];
for (int i = 0; i < m_Editors.length; i++) { for (int i = 0; i < m_Editors.length; i++) {
@@ -244,18 +256,18 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
} }
}; };
/** This action listener,... /**
* This action listener,...
*/ */
ActionListener deleteTarget = new ActionListener() { ActionListener deleteTarget = new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
int l = m_OptimizationObjectives.getSelectedTargets().length, j = 0; int l = m_OptimizationObjectives.getSelectedTargets().length, j = 0;
GeneralGOEProperty[] newEdit = new GeneralGOEProperty[l-1]; GeneralGOEProperty[] newEdit = new GeneralGOEProperty[l - 1];
for (int i = 0; i < m_Delete.length; i++) { for (int i = 0; i < m_Delete.length; i++) {
if (event.getSource().equals(m_Delete[i])) { if (event.getSource().equals(m_Delete[i])) {
m_OptimizationObjectives.removeTarget(i); m_OptimizationObjectives.removeTarget(i);
} } else {
else {
newEdit[j] = m_Editors[i]; newEdit[j] = m_Editors[i];
j++; j++;
} }
@@ -265,7 +277,8 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
} }
}; };
/** The object may have changed update the editor. /**
* The object may have changed update the editor.
*/ */
private void updateEditor() { private void updateEditor() {
if (this.m_Editor != null) { if (this.m_Editor != null) {
@@ -279,18 +292,22 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
} }
/** This method will set the value of object that is to be edited. /**
* This method will set the value of object that is to be edited.
*
* @param o an object that must be an array. * @param o an object that must be an array.
*/ */
@Override @Override
public void setValue(Object o) { public void setValue(Object o) {
if (o instanceof PropertyOptimizationObjectives) { if (o instanceof PropertyOptimizationObjectives) {
this.m_OptimizationObjectives= (PropertyOptimizationObjectives) o; this.m_OptimizationObjectives = (PropertyOptimizationObjectives) o;
this.updateEditor(); this.updateEditor();
} }
} }
/** Returns the current object. /**
* Returns the current object.
*
* @return the current object * @return the current object
*/ */
@Override @Override
@@ -327,21 +344,27 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
return null; return null;
} }
/** This is used to hook an action listener to the ok button /**
* This is used to hook an action listener to the ok button
*
* @param a The action listener. * @param a The action listener.
*/ */
public void addOkListener(ActionListener a) { public void addOkListener(ActionListener a) {
//m_OKButton.addActionListener(a); //m_OKButton.addActionListener(a);
} }
/** This is used to remove an action listener from the ok button /**
* This is used to remove an action listener from the ok button
*
* @param a The action listener * @param a The action listener
*/ */
public void removeOkListener(ActionListener a) { public void removeOkListener(ActionListener a) {
//m_OKButton.removeActionListener(a); //m_OKButton.removeActionListener(a);
} }
/** Returns true since the Object can be shown /**
* Returns true since the Object can be shown
*
* @return true * @return true
*/ */
@Override @Override
@@ -349,7 +372,8 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
return true; return true;
} }
/** Paints a representation of the current classifier. /**
* Paints a representation of the current classifier.
* *
* @param gfx the graphics context to use * @param gfx the graphics context to use
* @param box the area we are allowed to paint into * @param box the area we are allowed to paint into
@@ -359,10 +383,12 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
FontMetrics fm = gfx.getFontMetrics(); FontMetrics fm = gfx.getFontMetrics();
int vpad = (box.height - fm.getAscent()) / 2; int vpad = (box.height - fm.getAscent()) / 2;
String rep = "Optimization Targets"; String rep = "Optimization Targets";
gfx.drawString(rep, 2, fm.getHeight() + vpad - 3 ); gfx.drawString(rep, 2, fm.getHeight() + vpad - 3);
} }
/** Returns true because we do support a custom editor. /**
* Returns true because we do support a custom editor.
*
* @return true * @return true
*/ */
@Override @Override
@@ -370,7 +396,9 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
return true; return true;
} }
/** Returns the array editing component. /**
* Returns the array editing component.
*
* @return a value of type 'java.awt.Component' * @return a value of type 'java.awt.Component'
*/ */
@Override @Override
@@ -381,7 +409,8 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
return m_Editor; return m_Editor;
} }
/** This method will udate the status of the object taking the values from all /**
* This method will udate the status of the object taking the values from all
* supsequent editors and setting them to my object. * supsequent editors and setting them to my object.
*/ */
public void updateCenterComponent(PropertyChangeEvent evt) { public void updateCenterComponent(PropertyChangeEvent evt) {
@@ -389,7 +418,9 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
this.updateEditor(); this.updateEditor();
} }
/********************************* java.beans.PropertyChangeListener *************************/ /**
* ****************************** java.beans.PropertyChangeListener ************************
*/
@Override @Override
public void addPropertyChangeListener(PropertyChangeListener l) { public void addPropertyChangeListener(PropertyChangeListener l) {
@@ -406,8 +437,11 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
} }
m_Support.removePropertyChangeListener(l); m_Support.removePropertyChangeListener(l);
} }
/** This will wait for the GenericObjectEditor to finish
/**
* This will wait for the GenericObjectEditor to finish
* editing an object. * editing an object.
*
* @param evt * @param evt
*/ */
@Override @Override
@@ -417,7 +451,7 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
InterfaceOptimizationObjective[] list = this.m_OptimizationObjectives.getSelectedTargets(); InterfaceOptimizationObjective[] list = this.m_OptimizationObjectives.getSelectedTargets();
for (int i = 0; i < list.length; i++) { for (int i = 0; i < list.length; i++) {
if (oldVal.equals(list[i])) { if (oldVal.equals(list[i])) {
list[i] = (InterfaceOptimizationObjective)newVal; list[i] = (InterfaceOptimizationObjective) newVal;
this.m_Editors[i].m_Name = list[i].getName(); this.m_Editors[i].m_Name = list[i].getName();
try { try {
this.m_Editors[i].m_Value = list[i]; this.m_Editors[i].m_Value = list[i];

View File

@@ -7,6 +7,7 @@ import eva2.optimization.problems.InterfaceOptimizationObjective;
import eva2.optimization.tools.AbstractObjectEditor; import eva2.optimization.tools.AbstractObjectEditor;
import eva2.optimization.tools.GeneralGOEProperty; import eva2.optimization.tools.GeneralGOEProperty;
import eva2.tools.BasicResourceLoader; import eva2.tools.BasicResourceLoader;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
@@ -47,14 +48,22 @@ import javax.swing.SwingConstants;
*/ */
public class GenericOptimizationObjectivesWithParamEditor extends JPanel implements PropertyEditor, java.beans.PropertyChangeListener { public class GenericOptimizationObjectivesWithParamEditor extends JPanel implements PropertyEditor, java.beans.PropertyChangeListener {
/** Handles property change notification */ /**
* Handles property change notification
*/
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this); private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
/** The label for when we can't edit that type */ /**
* The label for when we can't edit that type
*/
private JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER); private JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER);
/** The FilePath that is to be edited*/ /**
* The FilePath that is to be edited
*/
private PropertyOptimizationObjectivesWithParam m_OptimizationObjectivesWithWeights; private PropertyOptimizationObjectivesWithParam m_OptimizationObjectivesWithWeights;
/** The gaphix stuff */ /**
* The gaphix stuff
*/
private JComponent m_Editor; private JComponent m_Editor;
private JPanel m_TargetList; private JPanel m_TargetList;
private JTextField[] m_Weights; private JTextField[] m_Weights;
@@ -68,7 +77,8 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
m_self = this; m_self = this;
} }
/** This method will init the CustomEditor Panel /**
* This method will init the CustomEditor Panel
*/ */
private void initCustomEditor() { private void initCustomEditor() {
m_self = this; m_self = this;
@@ -110,7 +120,7 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
// The Button Panel // The Button Panel
JPanel buttonPanel = new JPanel(); JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new GridLayout(1,2)); buttonPanel.setLayout(new GridLayout(1, 2));
JButton addButton = new JButton("Add Opt. Target"); JButton addButton = new JButton("Add Opt. Target");
JButton normButton = new JButton("Normalize Weights"); JButton normButton = new JButton("Normalize Weights");
normButton.setEnabled(this.m_OptimizationObjectivesWithWeights.isNormalizationEnabled()); normButton.setEnabled(this.m_OptimizationObjectivesWithWeights.isNormalizationEnabled());
@@ -123,7 +133,7 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
// Some description would be nice // Some description would be nice
JTextArea jt = new JTextArea(); JTextArea jt = new JTextArea();
jt.setFont(new Font("SansSerif", Font.PLAIN,12)); jt.setFont(new Font("SansSerif", Font.PLAIN, 12));
jt.setEditable(false); jt.setEditable(false);
jt.setLineWrap(true); jt.setLineWrap(true);
jt.setWrapStyleWord(true); jt.setWrapStyleWord(true);
@@ -149,8 +159,8 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
this.updateEditor(); this.updateEditor();
} }
/** This method updates the server list /**
* * This method updates the server list
*/ */
private void updateTargetList() { private void updateTargetList() {
BasicResourceLoader loader = BasicResourceLoader.instance(); BasicResourceLoader loader = BasicResourceLoader.instance();
@@ -166,7 +176,7 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
this.m_Delete = new JButton[list.length]; this.m_Delete = new JButton[list.length];
String[] cups = new String[8]; String[] cups = new String[8];
for (int i = 0; i < cups.length; i++) { for (int i = 0; i < cups.length; i++) {
cups[i] = ""+(i+1); cups[i] = "" + (i + 1);
} }
// The head title // The head title
gbc.anchor = GridBagConstraints.WEST; gbc.anchor = GridBagConstraints.WEST;
@@ -190,7 +200,7 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
gbc.fill = GridBagConstraints.BOTH; gbc.fill = GridBagConstraints.BOTH;
gbc.gridx = 0; gbc.gridx = 0;
gbc.weightx = 2; gbc.weightx = 2;
this.m_Weights[i] = new JTextField(""+weights[i]); this.m_Weights[i] = new JTextField("" + weights[i]);
this.m_Weights[i].addKeyListener(this.readDoubleArrayAction); this.m_Weights[i].addKeyListener(this.readDoubleArrayAction);
this.m_TargetList.add(this.m_Weights[i], gbc); this.m_TargetList.add(this.m_Weights[i], gbc);
// the status indicator // the status indicator
@@ -222,7 +232,8 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
} }
} }
/** This action listener,... /**
* This action listener,...
*/ */
ActionListener updateTargets = new ActionListener() { ActionListener updateTargets = new ActionListener() {
@Override @Override
@@ -231,12 +242,13 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
} }
}; };
/** This action listener,... /**
* This action listener,...
*/ */
ActionListener addTarget = new ActionListener() { ActionListener addTarget = new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
m_OptimizationObjectivesWithWeights.addTarget((InterfaceOptimizationObjective)m_OptimizationObjectivesWithWeights.getAvailableTargets()[0].clone()); m_OptimizationObjectivesWithWeights.addTarget((InterfaceOptimizationObjective) m_OptimizationObjectivesWithWeights.getAvailableTargets()[0].clone());
int l = m_OptimizationObjectivesWithWeights.getSelectedTargets().length; int l = m_OptimizationObjectivesWithWeights.getSelectedTargets().length;
GeneralGOEProperty[] newEdit = new GeneralGOEProperty[l]; GeneralGOEProperty[] newEdit = new GeneralGOEProperty[l];
for (int i = 0; i < m_Editors.length; i++) { for (int i = 0; i < m_Editors.length; i++) {
@@ -269,18 +281,18 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
} }
}; };
/** This action listener,... /**
* This action listener,...
*/ */
ActionListener deleteTarget = new ActionListener() { ActionListener deleteTarget = new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
int l = m_OptimizationObjectivesWithWeights.getSelectedTargets().length, j = 0; int l = m_OptimizationObjectivesWithWeights.getSelectedTargets().length, j = 0;
GeneralGOEProperty[] newEdit = new GeneralGOEProperty[l-1]; GeneralGOEProperty[] newEdit = new GeneralGOEProperty[l - 1];
for (int i = 0; i < m_Delete.length; i++) { for (int i = 0; i < m_Delete.length; i++) {
if (event.getSource().equals(m_Delete[i])) { if (event.getSource().equals(m_Delete[i])) {
m_OptimizationObjectivesWithWeights.removeTarget(i); m_OptimizationObjectivesWithWeights.removeTarget(i);
} } else {
else {
newEdit[j] = m_Editors[i]; newEdit[j] = m_Editors[i];
j++; j++;
} }
@@ -290,7 +302,8 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
} }
}; };
/** This action listener,... /**
* This action listener,...
*/ */
ActionListener normalizeWeights = new ActionListener() { ActionListener normalizeWeights = new ActionListener() {
@Override @Override
@@ -310,12 +323,14 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
} }
}; };
/** This action listener reads all values /**
* This action listener reads all values
*/ */
KeyListener readDoubleArrayAction = new KeyListener() { KeyListener readDoubleArrayAction = new KeyListener() {
@Override @Override
public void keyPressed(KeyEvent event) { public void keyPressed(KeyEvent event) {
} }
@Override @Override
public void keyTyped(KeyEvent event) { public void keyTyped(KeyEvent event) {
} }
@@ -337,7 +352,8 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
} }
}; };
/** The object may have changed update the editor. /**
* The object may have changed update the editor.
*/ */
private void updateEditor() { private void updateEditor() {
if (this.m_Editor != null) { if (this.m_Editor != null) {
@@ -350,18 +366,22 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
} }
} }
/** This method will set the value of object that is to be edited. /**
* This method will set the value of object that is to be edited.
*
* @param o an object that must be an array. * @param o an object that must be an array.
*/ */
@Override @Override
public void setValue(Object o) { public void setValue(Object o) {
if (o instanceof PropertyOptimizationObjectivesWithParam) { if (o instanceof PropertyOptimizationObjectivesWithParam) {
this.m_OptimizationObjectivesWithWeights= (PropertyOptimizationObjectivesWithParam) o; this.m_OptimizationObjectivesWithWeights = (PropertyOptimizationObjectivesWithParam) o;
this.updateEditor(); this.updateEditor();
} }
} }
/** Returns the current object. /**
* Returns the current object.
*
* @return the current object * @return the current object
*/ */
@Override @Override
@@ -398,21 +418,27 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
return null; return null;
} }
/** This is used to hook an action listener to the ok button /**
* This is used to hook an action listener to the ok button
*
* @param a The action listener. * @param a The action listener.
*/ */
public void addOkListener(ActionListener a) { public void addOkListener(ActionListener a) {
//m_OKButton.addActionListener(a); //m_OKButton.addActionListener(a);
} }
/** This is used to remove an action listener from the ok button /**
* This is used to remove an action listener from the ok button
*
* @param a The action listener * @param a The action listener
*/ */
public void removeOkListener(ActionListener a) { public void removeOkListener(ActionListener a) {
//m_OKButton.removeActionListener(a); //m_OKButton.removeActionListener(a);
} }
/** Returns true since the Object can be shown /**
* Returns true since the Object can be shown
*
* @return true * @return true
*/ */
@Override @Override
@@ -420,7 +446,8 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
return true; return true;
} }
/** Paints a representation of the current classifier. /**
* Paints a representation of the current classifier.
* *
* @param gfx the graphics context to use * @param gfx the graphics context to use
* @param box the area we are allowed to paint into * @param box the area we are allowed to paint into
@@ -430,10 +457,12 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
FontMetrics fm = gfx.getFontMetrics(); FontMetrics fm = gfx.getFontMetrics();
int vpad = (box.height - fm.getAscent()) / 2; int vpad = (box.height - fm.getAscent()) / 2;
String rep = "Optimization Targets With Weights"; String rep = "Optimization Targets With Weights";
gfx.drawString(rep, 2, fm.getHeight() + vpad - 3 ); gfx.drawString(rep, 2, fm.getHeight() + vpad - 3);
} }
/** Returns true because we do support a custom editor. /**
* Returns true because we do support a custom editor.
*
* @return true * @return true
*/ */
@Override @Override
@@ -441,7 +470,9 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
return true; return true;
} }
/** Returns the array editing component. /**
* Returns the array editing component.
*
* @return a value of type 'java.awt.Component' * @return a value of type 'java.awt.Component'
*/ */
@Override @Override
@@ -452,7 +483,8 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
return m_Editor; return m_Editor;
} }
/** This method will udate the status of the object taking the values from all /**
* This method will udate the status of the object taking the values from all
* supsequent editors and setting them to my object. * supsequent editors and setting them to my object.
*/ */
public void updateCenterComponent(PropertyChangeEvent evt) { public void updateCenterComponent(PropertyChangeEvent evt) {
@@ -460,7 +492,9 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
this.updateEditor(); this.updateEditor();
} }
/********************************* java.beans.PropertyChangeListener *************************/ /**
* ****************************** java.beans.PropertyChangeListener ************************
*/
@Override @Override
public void addPropertyChangeListener(PropertyChangeListener l) { public void addPropertyChangeListener(PropertyChangeListener l) {
@@ -477,8 +511,11 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
} }
m_Support.removePropertyChangeListener(l); m_Support.removePropertyChangeListener(l);
} }
/** This will wait for the GenericObjectEditor to finish
/**
* This will wait for the GenericObjectEditor to finish
* editing an object. * editing an object.
*
* @param evt * @param evt
*/ */
@Override @Override
@@ -488,7 +525,7 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
InterfaceOptimizationObjective[] list = this.m_OptimizationObjectivesWithWeights.getSelectedTargets(); InterfaceOptimizationObjective[] list = this.m_OptimizationObjectivesWithWeights.getSelectedTargets();
for (int i = 0; i < list.length; i++) { for (int i = 0; i < list.length; i++) {
if (oldVal.equals(list[i])) { if (oldVal.equals(list[i])) {
list[i] = (InterfaceOptimizationObjective)newVal; list[i] = (InterfaceOptimizationObjective) newVal;
this.m_Editors[i].m_Name = list[i].getName(); this.m_Editors[i].m_Name = list[i].getName();
try { try {
this.m_Editors[i].m_Value = list[i]; this.m_Editors[i].m_Value = list[i];

View File

@@ -18,14 +18,22 @@ import javax.swing.*;
*/ */
public class GenericWeigthedLPTchebycheffEditor extends JPanel implements PropertyEditor { public class GenericWeigthedLPTchebycheffEditor extends JPanel implements PropertyEditor {
/** Handles property change notification */ /**
* Handles property change notification
*/
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this); private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
/** The label for when we can't edit that type */ /**
* The label for when we can't edit that type
*/
private JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER); private JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER);
/** The FilePath that is to be edited*/ /**
* The FilePath that is to be edited
*/
private PropertyWeightedLPTchebycheff m_WLPT; private PropertyWeightedLPTchebycheff m_WLPT;
/** The gaphix stuff */ /**
* The gaphix stuff
*/
private JPanel m_CustomEditor, m_DataPanel, m_ButtonPanel, m_TargetPanel; private JPanel m_CustomEditor, m_DataPanel, m_ButtonPanel, m_TargetPanel;
private JTextField[] m_IdealTextField, m_WeightTextField; private JTextField[] m_IdealTextField, m_WeightTextField;
private JTextField m_PValue; private JTextField m_PValue;
@@ -35,7 +43,8 @@ public class GenericWeigthedLPTchebycheffEditor extends JPanel implements Proper
// compiled code // compiled code
} }
/** This method will init the CustomEditor Panel /**
* This method will init the CustomEditor Panel
*/ */
private void initCustomEditor() { private void initCustomEditor() {
this.m_CustomEditor = new JPanel(); this.m_CustomEditor = new JPanel();
@@ -45,7 +54,7 @@ public class GenericWeigthedLPTchebycheffEditor extends JPanel implements Proper
this.m_TargetPanel = new JPanel(); this.m_TargetPanel = new JPanel();
this.m_TargetPanel.setLayout(new GridLayout(1, 2)); this.m_TargetPanel.setLayout(new GridLayout(1, 2));
this.m_TargetPanel.add(new JLabel("Choose P:")); this.m_TargetPanel.add(new JLabel("Choose P:"));
this.m_PValue = new JTextField(""+this.m_WLPT.m_P); this.m_PValue = new JTextField("" + this.m_WLPT.m_P);
this.m_TargetPanel.add(this.m_PValue); this.m_TargetPanel.add(this.m_PValue);
this.m_PValue.addKeyListener(this.readDoubleAction); this.m_PValue.addKeyListener(this.readDoubleAction);
this.m_CustomEditor.add(this.m_TargetPanel, BorderLayout.NORTH); this.m_CustomEditor.add(this.m_TargetPanel, BorderLayout.NORTH);
@@ -74,12 +83,14 @@ public class GenericWeigthedLPTchebycheffEditor extends JPanel implements Proper
this.updateEditor(); this.updateEditor();
} }
/** This action listener reads all values /**
* This action listener reads all values
*/ */
KeyListener readDoubleAction = new KeyListener() { KeyListener readDoubleAction = new KeyListener() {
@Override @Override
public void keyPressed(KeyEvent event) { public void keyPressed(KeyEvent event) {
} }
@Override @Override
public void keyTyped(KeyEvent event) { public void keyTyped(KeyEvent event) {
} }
@@ -95,12 +106,14 @@ public class GenericWeigthedLPTchebycheffEditor extends JPanel implements Proper
} }
}; };
/** This action listener reads all values /**
* This action listener reads all values
*/ */
KeyListener readDoubleArrayAction = new KeyListener() { KeyListener readDoubleArrayAction = new KeyListener() {
@Override @Override
public void keyPressed(KeyEvent event) { public void keyPressed(KeyEvent event) {
} }
@Override @Override
public void keyTyped(KeyEvent event) { public void keyTyped(KeyEvent event) {
} }
@@ -133,7 +146,8 @@ public class GenericWeigthedLPTchebycheffEditor extends JPanel implements Proper
} }
}; };
/** The object may have changed update the editor. /**
* The object may have changed update the editor.
*/ */
private void updateEditor() { private void updateEditor() {
if (this.m_CustomEditor != null) { if (this.m_CustomEditor != null) {
@@ -143,37 +157,40 @@ public class GenericWeigthedLPTchebycheffEditor extends JPanel implements Proper
} }
} }
/** This method updates the data panel /**
* This method updates the data panel
*/ */
private void updateDataPanel() { private void updateDataPanel() {
double[] tmpT = this.m_WLPT.m_IdealValue; double[] tmpT = this.m_WLPT.m_IdealValue;
double[] tmpP = this.m_WLPT.m_Weights; double[] tmpP = this.m_WLPT.m_Weights;
int obj = this.m_WLPT.m_P; int obj = this.m_WLPT.m_P;
this.m_PValue.setText(""+obj); this.m_PValue.setText("" + obj);
this.m_DataPanel.removeAll(); this.m_DataPanel.removeAll();
this.m_DataPanel.setLayout(new GridLayout(tmpT.length+1, 3)); this.m_DataPanel.setLayout(new GridLayout(tmpT.length + 1, 3));
this.m_DataPanel.add(new JLabel()); this.m_DataPanel.add(new JLabel());
this.m_DataPanel.add(new JLabel("Ideal Value")); this.m_DataPanel.add(new JLabel("Ideal Value"));
this.m_DataPanel.add(new JLabel("Weights")); this.m_DataPanel.add(new JLabel("Weights"));
this.m_IdealTextField = new JTextField[tmpT.length]; this.m_IdealTextField = new JTextField[tmpT.length];
this.m_WeightTextField = new JTextField[tmpT.length]; this.m_WeightTextField = new JTextField[tmpT.length];
for (int i = 0; i < tmpT.length; i++) { for (int i = 0; i < tmpT.length; i++) {
JLabel label = new JLabel("Objective "+i+": "); JLabel label = new JLabel("Objective " + i + ": ");
this.m_DataPanel.add(label); this.m_DataPanel.add(label);
this.m_IdealTextField[i] = new JTextField(); this.m_IdealTextField[i] = new JTextField();
this.m_IdealTextField[i].setText(""+tmpT[i]); this.m_IdealTextField[i].setText("" + tmpT[i]);
this.m_IdealTextField[i].addKeyListener(this.readDoubleArrayAction); this.m_IdealTextField[i].addKeyListener(this.readDoubleArrayAction);
this.m_DataPanel.add(this.m_IdealTextField[i]); this.m_DataPanel.add(this.m_IdealTextField[i]);
this.m_WeightTextField[i] = new JTextField(); this.m_WeightTextField[i] = new JTextField();
this.m_WeightTextField[i].setText(""+tmpP[i]); this.m_WeightTextField[i].setText("" + tmpP[i]);
this.m_WeightTextField[i].addKeyListener(this.readDoubleArrayAction); this.m_WeightTextField[i].addKeyListener(this.readDoubleArrayAction);
this.m_DataPanel.add(this.m_WeightTextField[i]); this.m_DataPanel.add(this.m_WeightTextField[i]);
} }
} }
/** This method will set the value of object that is to be edited. /**
* This method will set the value of object that is to be edited.
*
* @param o an object that must be an array. * @param o an object that must be an array.
*/ */
@Override @Override
@@ -184,7 +201,9 @@ public class GenericWeigthedLPTchebycheffEditor extends JPanel implements Proper
} }
} }
/** Returns the current object. /**
* Returns the current object.
*
* @return the current object * @return the current object
*/ */
@Override @Override
@@ -237,21 +256,27 @@ public class GenericWeigthedLPTchebycheffEditor extends JPanel implements Proper
m_Support.removePropertyChangeListener(l); m_Support.removePropertyChangeListener(l);
} }
/** This is used to hook an action listener to the ok button /**
* This is used to hook an action listener to the ok button
*
* @param a The action listener. * @param a The action listener.
*/ */
public void addOkListener(ActionListener a) { public void addOkListener(ActionListener a) {
m_OKButton.addActionListener(a); m_OKButton.addActionListener(a);
} }
/** This is used to remove an action listener from the ok button /**
* This is used to remove an action listener from the ok button
*
* @param a The action listener * @param a The action listener
*/ */
public void removeOkListener(ActionListener a) { public void removeOkListener(ActionListener a) {
m_OKButton.removeActionListener(a); m_OKButton.removeActionListener(a);
} }
/** Returns true since the Object can be shown /**
* Returns true since the Object can be shown
*
* @return true * @return true
*/ */
@Override @Override
@@ -259,7 +284,8 @@ public class GenericWeigthedLPTchebycheffEditor extends JPanel implements Proper
return true; return true;
} }
/** Paints a representation of the current classifier. /**
* Paints a representation of the current classifier.
* *
* @param gfx the graphics context to use * @param gfx the graphics context to use
* @param box the area we are allowed to paint into * @param box the area we are allowed to paint into
@@ -269,10 +295,12 @@ public class GenericWeigthedLPTchebycheffEditor extends JPanel implements Proper
FontMetrics fm = gfx.getFontMetrics(); FontMetrics fm = gfx.getFontMetrics();
int vpad = (box.height - fm.getAscent()) / 2; int vpad = (box.height - fm.getAscent()) / 2;
String rep = "Edit the ideal vector, p and ev. the weights."; String rep = "Edit the ideal vector, p and ev. the weights.";
gfx.drawString(rep, 2, fm.getHeight() + vpad - 3 ); gfx.drawString(rep, 2, fm.getHeight() + vpad - 3);
} }
/** Returns true because we do support a custom editor. /**
* Returns true because we do support a custom editor.
*
* @return true * @return true
*/ */
@Override @Override
@@ -280,7 +308,9 @@ public class GenericWeigthedLPTchebycheffEditor extends JPanel implements Proper
return true; return true;
} }
/** Returns the array editing component. /**
* Returns the array editing component.
*
* @return a value of type 'java.awt.Component' * @return a value of type 'java.awt.Component'
*/ */
@Override @Override

View File

@@ -12,6 +12,7 @@ import java.beans.*;
* <p>Description: </p> * <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p> * <p>Copyright: Copyright (c) 2003</p>
* <p>Company: </p> * <p>Company: </p>
*
* @author not attributable * @author not attributable
* @version 1.0 * @version 1.0
*/ */
@@ -20,19 +21,35 @@ public class MultiLineStringEditor implements PropertyEditor {
protected MultiLineString value; // The value we will be editing. protected MultiLineString value; // The value we will be editing.
@Override @Override
public void setValue(Object o) { value=(MultiLineString) o;} public void setValue(Object o) {
value = (MultiLineString) o;
}
@Override @Override
public Object getValue() { return value; } public Object getValue() {
return value;
}
@Override @Override
public void setAsText(String s) { value.setString(s); } public void setAsText(String s) {
value.setString(s);
}
@Override @Override
public String getAsText() { return value.getString(); } public String getAsText() {
return value.getString();
}
@Override @Override
public String[] getTags() { return null; } // not enumerated; no tags public String[] getTags() {
return null;
} // not enumerated; no tags
// Say that we allow custom editing. // Say that we allow custom editing.
@Override @Override
public boolean supportsCustomEditor() { return true; } public boolean supportsCustomEditor() {
return true;
}
// Return the custom editor. This just creates and returns a TextArea // Return the custom editor. This just creates and returns a TextArea
// to edit the multi-line text. But it also registers a listener on the // to edit the multi-line text. But it also registers a listener on the
@@ -56,18 +73,22 @@ public class MultiLineStringEditor implements PropertyEditor {
// Just print some instructions and hope they fit in the in the box. // Just print some instructions and hope they fit in the in the box.
// This could be more sophisticated. // This could be more sophisticated.
@Override @Override
public boolean isPaintable() { return true; } public boolean isPaintable() {
return true;
}
@Override @Override
public void paintValue(Graphics g, Rectangle r) { public void paintValue(Graphics g, Rectangle r) {
g.setClip(r); g.setClip(r);
g.drawString("Click to edit...", r.x+5, r.y+15); g.drawString("Click to edit...", r.x + 5, r.y + 15);
} }
// Important method for code generators. Note that it // Important method for code generators. Note that it
// ought to add any necessary escape sequences. // ought to add any necessary escape sequences.
@Override @Override
public String getJavaInitializationString() { return "\"" + value + "\""; } public String getJavaInitializationString() {
return "\"" + value + "\"";
}
// This code uses the PropertyChangeSupport class to maintain a list of // This code uses the PropertyChangeSupport class to maintain a list of
// listeners interested in the edits we make to the value. // listeners interested in the edits we make to the value.

View File

@@ -9,8 +9,10 @@ package eva2.gui.editor;
* $Date: 2007-10-23 13:43:24 +0200 (Tue, 23 Oct 2007) $ * $Date: 2007-10-23 13:43:24 +0200 (Tue, 23 Oct 2007) $
* $Author: mkron $ * $Author: mkron $
*/ */
import eva2.gui.PropertySheetPanelStat; import eva2.gui.PropertySheetPanelStat;
import eva2.optimization.stat.GenericStatistics; import eva2.optimization.stat.GenericStatistics;
import java.awt.*; import java.awt.*;
import java.beans.*; import java.beans.*;
import javax.swing.*; import javax.swing.*;

View File

@@ -62,13 +62,13 @@ public class StringSelectionEditor extends AbstractListSelectionEditor {
public String getAsText() { public String getAsText() {
StringBuffer sbuf = new StringBuffer("{"); StringBuffer sbuf = new StringBuffer("{");
boolean first = true; boolean first = true;
for (int i=0; i<getElementCount(); i++) { for (int i = 0; i < getElementCount(); i++) {
if (isElementSelected(i)) { if (isElementSelected(i)) {
if (!first) { if (!first) {
sbuf.append(", "); sbuf.append(", ");
} }
sbuf.append(getElementName(i)); sbuf.append(getElementName(i));
first=false; first = false;
} }
} }
sbuf.append("}"); sbuf.append("}");
@@ -77,7 +77,7 @@ public class StringSelectionEditor extends AbstractListSelectionEditor {
@Override @Override
public void setAsText(String text) throws IllegalArgumentException { public void setAsText(String text) throws IllegalArgumentException {
for (int i=0; i<getElementCount(); i++) { for (int i = 0; i < getElementCount(); i++) {
strs.setSelected(i, text.contains(getElementName(i))); strs.setSelected(i, text.contains(getElementName(i)));
} }
} }

View File

@@ -15,6 +15,7 @@ import eva2.gui.PropertyValueSelector;
import eva2.tools.BasicResourceLoader; import eva2.tools.BasicResourceLoader;
import eva2.tools.SelectedTag; import eva2.tools.SelectedTag;
import eva2.tools.Tag; import eva2.tools.Tag;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Toolkit; import java.awt.Toolkit;
import java.awt.event.WindowAdapter; import java.awt.event.WindowAdapter;
@@ -22,6 +23,7 @@ import java.awt.event.WindowEvent;
import java.beans.PropertyEditorManager; import java.beans.PropertyEditorManager;
import java.beans.PropertyEditorSupport; import java.beans.PropertyEditorSupport;
import javax.swing.JFrame; import javax.swing.JFrame;
/** /**
* *
*/ */
@@ -34,8 +36,8 @@ public class TagEditor extends PropertyEditorSupport {
@Override @Override
public String getJavaInitializationString() { public String getJavaInitializationString() {
SelectedTag s = (SelectedTag)getValue(); SelectedTag s = (SelectedTag) getValue();
Tag [] tags = s.getTags(); Tag[] tags = s.getTags();
String result = "new SelectedTag(" String result = "new SelectedTag("
+ s.getSelectedTag().getID() + s.getSelectedTag().getID()
+ ", {\n"; + ", {\n";
@@ -58,7 +60,7 @@ public class TagEditor extends PropertyEditorSupport {
*/ */
@Override @Override
public String getAsText() { public String getAsText() {
SelectedTag s = (SelectedTag)getValue(); SelectedTag s = (SelectedTag) getValue();
return s.getSelectedTag().getString(); return s.getSelectedTag().getString();
} }
@@ -66,12 +68,13 @@ public class TagEditor extends PropertyEditorSupport {
* Sets the current property value as text. * Sets the current property value as text.
* *
* @param text the text of the selected tag. * @param text the text of the selected tag.
* @exception java.lang.IllegalArgumentException if an error occurs * @throws java.lang.IllegalArgumentException
* if an error occurs
*/ */
@Override @Override
public void setAsText(String text) throws java.lang.IllegalArgumentException { public void setAsText(String text) throws java.lang.IllegalArgumentException {
SelectedTag s = (SelectedTag)getValue(); SelectedTag s = (SelectedTag) getValue();
Tag [] tags = s.getTags(); Tag[] tags = s.getTags();
try { try {
for (int i = 0; i < tags.length; i++) { for (int i = 0; i < tags.length; i++) {
if (text.equals(tags[i].getString())) { if (text.equals(tags[i].getString())) {
@@ -92,9 +95,9 @@ public class TagEditor extends PropertyEditorSupport {
@Override @Override
public String[] getTags() { public String[] getTags() {
SelectedTag s = (SelectedTag)getValue(); SelectedTag s = (SelectedTag) getValue();
Tag [] tags = s.getTags(); Tag[] tags = s.getTags();
String [] result = new String [tags.length]; String[] result = new String[tags.length];
for (int i = 0; i < tags.length; i++) { for (int i = 0; i < tags.length; i++) {
result[i] = tags[i].getString result[i] = tags[i].getString
(); ();
@@ -107,10 +110,10 @@ public class TagEditor extends PropertyEditorSupport {
* *
* @param args ignored * @param args ignored
*/ */
public static void main(String [] args) { public static void main(String[] args) {
try { try {
PropertyEditorManager.registerEditor(SelectedTag.class,TagEditor.class); PropertyEditorManager.registerEditor(SelectedTag.class, TagEditor.class);
Tag [] tags = { Tag[] tags = {
new Tag(0, "First option"), new Tag(0, "First option"),
new Tag(1, "Second option"), new Tag(1, "Second option"),
new Tag(2, "Third option"), new Tag(2, "Third option"),

View File

@@ -1,7 +1,6 @@
package eva2.gui.plot; package eva2.gui.plot;
import eva2.tools.chart2d.DArray; import eva2.tools.chart2d.DArray;
import eva2.tools.chart2d.DBorder; import eva2.tools.chart2d.DBorder;
import eva2.tools.chart2d.DComponent; import eva2.tools.chart2d.DComponent;
@@ -11,6 +10,7 @@ import eva2.tools.chart2d.DPoint;
import eva2.tools.chart2d.DPointIcon; import eva2.tools.chart2d.DPointIcon;
import eva2.tools.chart2d.DPointSet; import eva2.tools.chart2d.DPointSet;
import eva2.tools.chart2d.DRectangle; import eva2.tools.chart2d.DRectangle;
import java.awt.BasicStroke; import java.awt.BasicStroke;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Point; import java.awt.Point;
@@ -25,74 +25,61 @@ import java.util.ArrayList;
* Time: 16:17:35 * Time: 16:17:35
* To change this template use File | Settings | File Templates. * To change this template use File | Settings | File Templates.
*/ */
public class DPointSetMultiIcon extends DComponent public class DPointSetMultiIcon extends DComponent {
{
//~ Instance fields //////////////////////////////////////////////////////// //~ Instance fields ////////////////////////////////////////////////////////
/** /**
* this class stores the jump positions (see this.jump) * this class stores the jump positions (see this.jump)
*/ */
class JumpManager class JumpManager {
{
protected int index = -1; protected int index = -1;
protected ArrayList<Integer> jumps = new ArrayList<Integer>(); protected ArrayList<Integer> jumps = new ArrayList<Integer>();
public void addJump() public void addJump() {
{
jumps.add(getSize()); jumps.add(getSize());
} }
public boolean hasMoreIntervals() public boolean hasMoreIntervals() {
{
return index < jumps.size(); return index < jumps.size();
} }
public int[] nextInterval() public int[] nextInterval() {
{
int no_jumps = jumps.size(); int no_jumps = jumps.size();
if (index >= no_jumps) if (index >= no_jumps) {
{
throw new ArrayIndexOutOfBoundsException( throw new ArrayIndexOutOfBoundsException(
"No more intervals in JumpManager"); "No more intervals in JumpManager");
} }
int[] inter = new int[2]; int[] inter = new int[2];
if (index == -1) if (index == -1) {
{
inter[0] = 0; inter[0] = 0;
} } else {
else
{
inter[0] = jumps.get(index); inter[0] = jumps.get(index);
} }
index++; index++;
if (index < no_jumps) if (index < no_jumps) {
{
inter[1] = jumps.get(index); inter[1] = jumps.get(index);
} } else {
else
{
inter[1] = getSize(); inter[1] = getSize();
} }
return inter; return inter;
} }
public void reset() public void reset() {
{
index = -1; index = -1;
jumps.clear(); jumps.clear();
} }
public void restore() public void restore() {
{
index = -1; index = -1;
} }
} }
protected boolean connectedMI; protected boolean connectedMI;
protected DPointIcon iconMI = null; protected DPointIcon iconMI = null;
protected DPointSetMultiIcon.JumpManager jumperMI = new DPointSetMultiIcon.JumpManager(); protected DPointSetMultiIcon.JumpManager jumperMI = new DPointSetMultiIcon.JumpManager();
@@ -104,15 +91,12 @@ public class DPointSetMultiIcon extends DComponent
protected DIntDoubleMap yMI; protected DIntDoubleMap yMI;
public DPointSetMultiIcon() public DPointSetMultiIcon() {
{
this(10, 2); this(10, 2);
} }
public DPointSetMultiIcon(DIntDoubleMap x_values, DIntDoubleMap y_values) public DPointSetMultiIcon(DIntDoubleMap x_values, DIntDoubleMap y_values) {
{ if (x_values.getSize() != y_values.getSize()) {
if (x_values.getSize() != y_values.getSize())
{
throw new IllegalArgumentException( throw new IllegalArgumentException(
"The number of x-values has to be the same than the number of y-values"); "The number of x-values has to be the same than the number of y-values");
} }
@@ -123,26 +107,22 @@ public class DPointSetMultiIcon extends DComponent
setDBorder(new DBorder(1, 1, 1, 1)); setDBorder(new DBorder(1, 1, 1, 1));
} }
public DPointSetMultiIcon(int initial_capacity) public DPointSetMultiIcon(int initial_capacity) {
{
this(initial_capacity, 2); this(initial_capacity, 2);
} }
//~ Methods //////////////////////////////////////////////////////////////// //~ Methods ////////////////////////////////////////////////////////////////
public DPointSetMultiIcon(int initial_capacity, int length_multiplier) public DPointSetMultiIcon(int initial_capacity, int length_multiplier) {
{
this(new DArray(initial_capacity, length_multiplier), this(new DArray(initial_capacity, length_multiplier),
new DArray(initial_capacity, length_multiplier)); new DArray(initial_capacity, length_multiplier));
} }
public void addDPoint(double x, double y) public void addDPoint(double x, double y) {
{
addDPoint(new DPoint(x, y)); addDPoint(new DPoint(x, y));
} }
public void addDPoint(DPoint p) public void addDPoint(DPoint p) {
{
xMI.addImage(p.x); xMI.addImage(p.x);
yMI.addImage(p.y); yMI.addImage(p.y);
m_IconsMI.add(p.getIcon()); m_IconsMI.add(p.getIcon());
@@ -156,10 +136,8 @@ public class DPointSetMultiIcon extends DComponent
* @param index the index of the DPoint * @param index the index of the DPoint
* @return the DPoint at the given index * @return the DPoint at the given index
*/ */
public DPoint getDPoint(int index) public DPoint getDPoint(int index) {
{ if (index >= xMI.getSize()) {
if (index >= xMI.getSize())
{
throw new ArrayIndexOutOfBoundsException(index); throw new ArrayIndexOutOfBoundsException(index);
} }
@@ -170,8 +148,7 @@ public class DPointSetMultiIcon extends DComponent
return p; return p;
} }
public DPointSet getDPointSet() public DPointSet getDPointSet() {
{
return new DPointSet(xMI, yMI); return new DPointSet(xMI, yMI);
} }
@@ -180,8 +157,7 @@ public class DPointSetMultiIcon extends DComponent
* *
* @return the DPointIcon * @return the DPointIcon
*/ */
public DPointIcon getIcon() public DPointIcon getIcon() {
{
return iconMI; return iconMI;
} }
@@ -194,16 +170,12 @@ public class DPointSetMultiIcon extends DComponent
* *
* @return the nearest <code>DPoint</code> * @return the nearest <code>DPoint</code>
*/ */
public DPoint getNearestDPoint(DPoint point) public DPoint getNearestDPoint(DPoint point) {
{
int minIndex = getNearestDPointIndex(point); int minIndex = getNearestDPointIndex(point);
if (minIndex == -1) if (minIndex == -1) {
{
return null; return null;
} } else {
else
{
DPoint result = new DPoint(xMI.getImage(minIndex), DPoint result = new DPoint(xMI.getImage(minIndex),
yMI.getImage(minIndex)); yMI.getImage(minIndex));
result.setIcon((DPointIcon) this.m_IconsMI.get(minIndex)); result.setIcon((DPointIcon) this.m_IconsMI.get(minIndex));
@@ -212,22 +184,21 @@ public class DPointSetMultiIcon extends DComponent
} }
} }
/** method returns the index to the nearest <code>DPoint</code> in this <code>DPointSet</code>. /**
* method returns the index to the nearest <code>DPoint</code> in this <code>DPointSet</code>.
*
* @return the index to the nearest <code>DPoint</code>. -1 if no nearest <code>DPoint</code> was found. * @return the index to the nearest <code>DPoint</code>. -1 if no nearest <code>DPoint</code> was found.
*/ */
public int getNearestDPointIndex(DPoint point) public int getNearestDPointIndex(DPoint point) {
{
double minValue = Double.MAX_VALUE; double minValue = Double.MAX_VALUE;
int minIndex = -1; int minIndex = -1;
for (int i = 0; i < xMI.getSize(); i++) for (int i = 0; i < xMI.getSize(); i++) {
{
double dx = point.x - xMI.getImage(i); double dx = point.x - xMI.getImage(i);
double dy = point.y - yMI.getImage(i); double dy = point.y - yMI.getImage(i);
double dummy = (dx * dx) + (dy * dy); double dummy = (dx * dx) + (dy * dy);
if (dummy < minValue) if (dummy < minValue) {
{
minValue = dummy; minValue = dummy;
minIndex = i; minIndex = i;
} }
@@ -236,8 +207,7 @@ public class DPointSetMultiIcon extends DComponent
return minIndex; return minIndex;
} }
public int getSize() public int getSize() {
{
int size = Math.min(xMI.getSize(), yMI.getSize()); int size = Math.min(xMI.getSize(), yMI.getSize());
// int size = x.getSize(); // int size = x.getSize();
@@ -254,8 +224,7 @@ public class DPointSetMultiIcon extends DComponent
* *
* @return the stroke * @return the stroke
*/ */
public Stroke getStroke() public Stroke getStroke() {
{
return strokeMI; return strokeMI;
} }
@@ -263,58 +232,46 @@ public class DPointSetMultiIcon extends DComponent
* This method causes the DPointSet to interupt the connected painting at the * This method causes the DPointSet to interupt the connected painting at the
* current position. * current position.
*/ */
public void jump() public void jump() {
{
jumperMI.addJump(); jumperMI.addJump();
} }
@Override @Override
public void paint(DMeasures m) public void paint(DMeasures m) {
{ try {
try
{
Graphics2D g = (Graphics2D) m.getGraphics(); Graphics2D g = (Graphics2D) m.getGraphics();
g.setStroke(strokeMI); g.setStroke(strokeMI);
if (color != null) if (color != null) {
{
g.setColor(color); g.setColor(color);
} }
int size = getSize(); int size = getSize();
if (connectedMI && (size > 1)) if (connectedMI && (size > 1)) {
{
jumperMI.restore(); jumperMI.restore();
while (jumperMI.hasMoreIntervals()) while (jumperMI.hasMoreIntervals()) {
{
int[] interval = jumperMI.nextInterval(); int[] interval = jumperMI.nextInterval();
Point p1 = null; Point p1 = null;
Point p2; Point p2;
for (int i = interval[0]; i < interval[1]; i++) for (int i = interval[0]; i < interval[1]; i++) {
{
p2 = m.getPoint(xMI.getImage(i), yMI.getImage(i)); p2 = m.getPoint(xMI.getImage(i), yMI.getImage(i));
if (p1 != null) if (p1 != null) {
{ if (p2 != null) {
if (p2!=null) {
g.drawLine(p1.x, p1.y, p2.x, p2.y); g.drawLine(p1.x, p1.y, p2.x, p2.y);
} }
} }
if ((i < this.m_IconsMI.size()) && (this.m_IconsMI.get(i) != null)) if ((i < this.m_IconsMI.size()) && (this.m_IconsMI.get(i) != null)) {
{
g.setStroke(new BasicStroke()); g.setStroke(new BasicStroke());
g.translate(p2.x, p2.y); g.translate(p2.x, p2.y);
((DPointIcon) this.m_IconsMI.get(i)).paint(g); ((DPointIcon) this.m_IconsMI.get(i)).paint(g);
g.translate(-p2.x, -p2.y); g.translate(-p2.x, -p2.y);
g.setStroke(strokeMI); g.setStroke(strokeMI);
} } else {
else if (iconMI != null) {
{
if (iconMI != null)
{
g.setStroke(new BasicStroke()); g.setStroke(new BasicStroke());
g.translate(p2.x, p2.y); g.translate(p2.x, p2.y);
iconMI.paint(g); iconMI.paint(g);
@@ -326,48 +283,36 @@ public class DPointSetMultiIcon extends DComponent
p1 = p2; p1 = p2;
} }
} }
} } else {
else
{
Point p; Point p;
//for (int i = 0; i < size; i++) //for (int i = 0; i < size; i++)
// @todo Streiche: Mal wieder eine index out of bounds exception, dass ist einfach mist... // @todo Streiche: Mal wieder eine index out of bounds exception, dass ist einfach mist...
for (int i = 0; i < this.m_IconsMI.size(); i++) for (int i = 0; i < this.m_IconsMI.size(); i++) {
{ try {
try
{
p = m.getPoint(xMI.getImage(i), yMI.getImage(i)); p = m.getPoint(xMI.getImage(i), yMI.getImage(i));
if (p==null) { if (p == null) {
continue; continue;
} }
if (this.m_IconsMI.get(i) != null) if (this.m_IconsMI.get(i) != null) {
{
g.setStroke(new BasicStroke()); g.setStroke(new BasicStroke());
g.translate(p.x, p.y); g.translate(p.x, p.y);
((DPointIcon) this.m_IconsMI.get(i)).paint(g); ((DPointIcon) this.m_IconsMI.get(i)).paint(g);
g.translate(-p.x, -p.y); g.translate(-p.x, -p.y);
g.setStroke(strokeMI); g.setStroke(strokeMI);
} } else {
else if (iconMI == null) {
{
if (iconMI == null)
{
g.drawLine(p.x - 1, p.y - 1, p.x + 1, p.y + 1); g.drawLine(p.x - 1, p.y - 1, p.x + 1, p.y + 1);
g.drawLine(p.x + 1, p.y - 1, p.x - 1, p.y + 1); g.drawLine(p.x + 1, p.y - 1, p.x - 1, p.y + 1);
} } else {
else
{
g.setStroke(new BasicStroke()); g.setStroke(new BasicStroke());
g.translate(p.x, p.y); g.translate(p.x, p.y);
iconMI.paint(g); iconMI.paint(g);
g.translate(-p.x, -p.y); g.translate(-p.x, -p.y);
} }
} }
} } catch (java.lang.IllegalArgumentException e) {
catch (java.lang.IllegalArgumentException e)
{
System.out.println( System.out.println(
"The rectangle lies not in the currently painted rectangle."); "The rectangle lies not in the currently painted rectangle.");
} }
@@ -375,17 +320,13 @@ public class DPointSetMultiIcon extends DComponent
} }
g.setStroke(new BasicStroke()); g.setStroke(new BasicStroke());
} } catch (java.lang.ArrayIndexOutOfBoundsException e) {
catch (java.lang.ArrayIndexOutOfBoundsException e)
{
// *pff* // *pff*
} }
} }
public void removeAllPoints() public void removeAllPoints() {
{ if (xMI.getSize() == 0) {
if (xMI.getSize() == 0)
{
return; return;
} }
@@ -401,15 +342,12 @@ public class DPointSetMultiIcon extends DComponent
* if the DPointSet is connected, all points will be painted connected to * if the DPointSet is connected, all points will be painted connected to
* their following point * their following point
*/ */
public void removeJumps() public void removeJumps() {
{
jumperMI.reset(); jumperMI.reset();
} }
protected void restore() protected void restore() {
{ if (getSize() == 0) {
if (getSize() == 0)
{
rectangle = DRectangle.getEmpty(); rectangle = DRectangle.getEmpty();
return; return;
@@ -422,13 +360,11 @@ public class DPointSetMultiIcon extends DComponent
rectangle = new DRectangle(min_x, min_y, max_x - min_x, max_y - min_y); rectangle = new DRectangle(min_x, min_y, max_x - min_x, max_y - min_y);
} }
public void setConnected(boolean aFlag) public void setConnected(boolean aFlag) {
{
boolean changed = !(aFlag == connectedMI); boolean changed = !(aFlag == connectedMI);
connectedMI = aFlag; connectedMI = aFlag;
if (changed) if (changed) {
{
repaint(); repaint();
} }
} }
@@ -439,10 +375,8 @@ public class DPointSetMultiIcon extends DComponent
* @param index the index of the point * @param index the index of the point
* @param p the point to insert * @param p the point to insert
*/ */
public void setDPoint(int index, DPoint p) public void setDPoint(int index, DPoint p) {
{ if (index >= xMI.getSize()) {
if (index >= xMI.getSize())
{
throw new ArrayIndexOutOfBoundsException(index); throw new ArrayIndexOutOfBoundsException(index);
} }
@@ -459,16 +393,12 @@ public class DPointSetMultiIcon extends DComponent
* *
* @param icon the DPointIcon * @param icon the DPointIcon
*/ */
public void setIcon(DPointIcon icon) public void setIcon(DPointIcon icon) {
{
this.iconMI = icon; this.iconMI = icon;
if (icon == null) if (icon == null) {
{
setDBorder(new DBorder(1, 1, 1, 1)); setDBorder(new DBorder(1, 1, 1, 1));
} } else {
else
{
setDBorder(icon.getDBorder()); setDBorder(icon.getDBorder());
} }
} }
@@ -479,10 +409,8 @@ public class DPointSetMultiIcon extends DComponent
* *
* @param s the new stroke * @param s the new stroke
*/ */
public void setStroke(Stroke s) public void setStroke(Stroke s) {
{ if (s == null) {
if (s == null)
{
s = new BasicStroke(); s = new BasicStroke();
} }
@@ -493,12 +421,10 @@ public class DPointSetMultiIcon extends DComponent
//~ Inner Classes ////////////////////////////////////////////////////////// //~ Inner Classes //////////////////////////////////////////////////////////
@Override @Override
public String toString() public String toString() {
{
String text = "eva2.tools.chart2d.DPointSet[size:" + getSize(); String text = "eva2.tools.chart2d.DPointSet[size:" + getSize();
for (int i = 0; i < xMI.getSize(); i++) for (int i = 0; i < xMI.getSize(); i++) {
{
text += (",(" + xMI.getImage(i) + "," + yMI.getImage(i) + ")"); text += (",(" + xMI.getImage(i) + "," + yMI.getImage(i) + ")");
} }

View File

@@ -89,7 +89,8 @@ class ViewContainer extends ArrayList {
/** /**
* *
*/ */
public ViewContainer() { } public ViewContainer() {
}
/** /**
* *

View File

@@ -17,5 +17,6 @@ import eva2.gui.plot.Graph;
*==========================================================================*/ *==========================================================================*/
public interface DataViewerInterface { public interface DataViewerInterface {
public Graph getNewGraph(String InfoString); public Graph getNewGraph(String InfoString);
public void init(); public void init();
} }

View File

@@ -11,6 +11,7 @@ package eva2.gui.plot;
* IMPORTS * IMPORTS
*========================================================================== *==========================================================================
*/ */
import eva2.gui.*; import eva2.gui.*;
import eva2.optimization.individuals.AbstractEAIndividual; import eva2.optimization.individuals.AbstractEAIndividual;
import eva2.optimization.mocco.paretofrontviewer.InterfaceRefPointListener; import eva2.optimization.mocco.paretofrontviewer.InterfaceRefPointListener;
@@ -27,6 +28,7 @@ import eva2.tools.chart2d.DPoint;
import eva2.tools.chart2d.DPointIcon; import eva2.tools.chart2d.DPointIcon;
import eva2.tools.chart2d.DPointSet; import eva2.tools.chart2d.DPointSet;
import eva2.tools.chart2d.ScaledBorder; import eva2.tools.chart2d.ScaledBorder;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics; import java.awt.Graphics;
@@ -431,7 +433,6 @@ public class FunctionArea extends DArea implements Serializable {
/** /**
* Re-color all graphs which are nonempty by their index. * Re-color all graphs which are nonempty by their index.
*
*/ */
public void recolorAllGraphsByIndex() { public void recolorAllGraphsByIndex() {
int index = 0; int index = 0;
@@ -446,7 +447,6 @@ public class FunctionArea extends DArea implements Serializable {
} }
/** /**
*
* @return * @return
*/ */
public boolean checkLoggable() { public boolean checkLoggable() {
@@ -656,7 +656,6 @@ public class FunctionArea extends DArea implements Serializable {
/** /**
* Export contained data to standard output. * Export contained data to standard output.
*
*/ */
public void exportToAscii() { public void exportToAscii() {
exportToAscii((File) null); exportToAscii((File) null);
@@ -758,7 +757,6 @@ public class FunctionArea extends DArea implements Serializable {
} }
/** /**
*
* @param x * @param x
* @param y * @param y
* @return * @return
@@ -798,7 +796,6 @@ public class FunctionArea extends DArea implements Serializable {
} }
/** /**
*
* @param GraphLabel * @param GraphLabel
* @return * @return
*/ */
@@ -857,7 +854,6 @@ public class FunctionArea extends DArea implements Serializable {
} }
/** /**
*
* @param x * @param x
* @param y * @param y
* @return * @return
@@ -941,7 +937,6 @@ public class FunctionArea extends DArea implements Serializable {
} }
/** /**
*
* @return * @return
*/ */
public DPointSet[] printPoints() { public DPointSet[] printPoints() {
@@ -957,7 +952,6 @@ public class FunctionArea extends DArea implements Serializable {
} }
/** /**
*
* @param i * @param i
* @return * @return
*/ */
@@ -971,7 +965,6 @@ public class FunctionArea extends DArea implements Serializable {
} }
/** /**
*
* @param x * @param x
* @param y * @param y
*/ */
@@ -1004,7 +997,6 @@ public class FunctionArea extends DArea implements Serializable {
} }
/** /**
*
* @param p * @param p
* @param graphLabel * @param graphLabel
*/ */
@@ -1013,7 +1005,6 @@ public class FunctionArea extends DArea implements Serializable {
} }
/** /**
*
* @param GraphLabel * @param GraphLabel
* @param color * @param color
*/ */
@@ -1022,7 +1013,6 @@ public class FunctionArea extends DArea implements Serializable {
} }
/** /**
*
* @param GraphLabel * @param GraphLabel
* @param colorindex * @param colorindex
*/ */
@@ -1031,7 +1021,6 @@ public class FunctionArea extends DArea implements Serializable {
} }
/** /**
*
* @param GraphLabel * @param GraphLabel
* @param Info * @param Info
* @param stroke * @param stroke
@@ -1054,7 +1043,6 @@ public class FunctionArea extends DArea implements Serializable {
} }
/** /**
*
* @param x * @param x
* @param y * @param y
* @param GraphLabel * @param GraphLabel
@@ -1073,7 +1061,6 @@ public class FunctionArea extends DArea implements Serializable {
} }
/** /**
*
* @param p * @param p
* @param GraphLabel * @param GraphLabel
*/ */
@@ -1201,7 +1188,6 @@ public class FunctionArea extends DArea implements Serializable {
/** /**
* Recreate the legend object with the current point sets. * Recreate the legend object with the current point sets.
*
*/ */
public void updateLegend() { public void updateLegend() {
GraphPointSetLegend lb = new GraphPointSetLegend(pointSetContainer, GraphPointSetLegend lb = new GraphPointSetLegend(pointSetContainer,

View File

@@ -32,7 +32,6 @@ public class Graph implements Serializable {
} }
/** /**
*
* @param Info * @param Info
* @param stroke * @param stroke
*/ */

View File

@@ -20,6 +20,7 @@ import eva2.tools.chart2d.DPoint;
import eva2.tools.chart2d.DPointIcon; import eva2.tools.chart2d.DPointIcon;
import eva2.tools.chart2d.DPointSet; import eva2.tools.chart2d.DPointSet;
import eva2.tools.math.Mathematics; import eva2.tools.math.Mathematics;
import java.awt.BasicStroke; import java.awt.BasicStroke;
import java.awt.Color; import java.awt.Color;
import java.io.Serializable; import java.io.Serializable;
@@ -28,6 +29,7 @@ import java.util.ArrayList;
/*==========================================================================* /*==========================================================================*
* CLASS DECLARATION * CLASS DECLARATION
*==========================================================================*/ *==========================================================================*/
/** /**
* *
*/ */
@@ -38,10 +40,10 @@ public class GraphPointSet {
Color.black, Color.red, Color.blue, Color.pink, Color.green, Color.black, Color.red, Color.blue, Color.pink, Color.green,
Color.gray, Color.magenta, Color.cyan, Color.orange, Color.gray, Color.magenta, Color.cyan, Color.orange,
new Color(148, 0, 211), // dark violet, new Color(148, 0, 211), // dark violet,
new Color(72 , 209 , 204), // turquoise new Color(72, 209, 204), // turquoise
new Color(128 ,128 ,0), // olive new Color(128, 128, 0), // olive
new Color(34 ,139 ,34), // forest green new Color(34, 139, 34), // forest green
new Color(100 ,149 ,237 ) // cornflower new Color(100, 149, 237) // cornflower
}; };
/** /**
@@ -57,7 +59,6 @@ public class GraphPointSet {
private double[] m_Y; private double[] m_Y;
/** /**
*
* @param pointset * @param pointset
*/ */
public PointSet(DPointSet pointset) { public PointSet(DPointSet pointset) {
@@ -72,7 +73,6 @@ public class GraphPointSet {
} }
/** /**
*
* @return * @return
*/ */
public DPointSet getDPointSet() { public DPointSet getDPointSet() {
@@ -85,7 +85,6 @@ public class GraphPointSet {
} }
/** /**
*
* @return * @return
*/ */
public int getSize() { public int getSize() {
@@ -163,7 +162,6 @@ public class GraphPointSet {
} }
/** /**
*
* @param size * @param size
* @param GraphLabel * @param GraphLabel
*/ */
@@ -205,7 +203,6 @@ public class GraphPointSet {
} }
/** /**
*
* @param x * @param x
* @param y * @param y
*/ */
@@ -225,7 +222,6 @@ public class GraphPointSet {
} }
/** /**
*
* @param p * @param p
*/ */
public void addDPoint(DPoint p) { public void addDPoint(DPoint p) {
@@ -238,8 +234,7 @@ public class GraphPointSet {
* *
* @param set * @param set
* @param measures * @param measures
* @param useForce * @param useForce forces the add even if point counts mismatch, maybe losing
* forces the add even if point counts mismatch, maybe losing
* some data points * some data points
*/ */
public void addGraph(GraphPointSet set, DMeasures measures, boolean useForce) { public void addGraph(GraphPointSet set, DMeasures measures, boolean useForce) {
@@ -335,7 +330,6 @@ public class GraphPointSet {
} }
/** /**
*
* @return * @return
*/ */
public Color getColor() { public Color getColor() {
@@ -343,7 +337,6 @@ public class GraphPointSet {
} }
/** /**
*
* @return * @return
*/ */
public DPointSet getConnectedPointSet() { public DPointSet getConnectedPointSet() {
@@ -351,7 +344,6 @@ public class GraphPointSet {
} }
/** /**
*
* @return * @return
*/ */
public int getGraphLabel() { public int getGraphLabel() {
@@ -364,6 +356,7 @@ public class GraphPointSet {
// public void setUnconnectedPoint (double x, double y) { // public void setUnconnectedPoint (double x, double y) {
// m_PointSet_1.addDPoint(x,y); // m_PointSet_1.addDPoint(x,y);
// } // }
/** /**
* *
*/ */
@@ -372,7 +365,6 @@ public class GraphPointSet {
} }
/** /**
*
* @param p * @param p
* @return * @return
*/ */
@@ -381,7 +373,6 @@ public class GraphPointSet {
} }
/** /**
*
* @return * @return
*/ */
public int getPointCount() { public int getPointCount() {
@@ -389,7 +380,6 @@ public class GraphPointSet {
} }
/** /**
*
* @return * @return
*/ */
public PointSet getPointSet() { public PointSet getPointSet() {
@@ -397,7 +387,6 @@ public class GraphPointSet {
} }
/** /**
*
* @return * @return
*/ */
public DPointSetMultiIcon getReference2ConnectedPointSet() { public DPointSetMultiIcon getReference2ConnectedPointSet() {
@@ -413,7 +402,6 @@ public class GraphPointSet {
} }
/** /**
*
* @param index * @param index
* @return * @return
*/ */
@@ -423,7 +411,6 @@ public class GraphPointSet {
} }
/** /**
*
* @param Area * @param Area
*/ */
public void initGraph(DArea Area) { public void initGraph(DArea Area) {
@@ -450,7 +437,6 @@ public class GraphPointSet {
} }
/** /**
*
* @return * @return
*/ */
public boolean isStatisticsGraph() { public boolean isStatisticsGraph() {
@@ -466,7 +452,6 @@ public class GraphPointSet {
} }
/** /**
*
* @return * @return
*/ */
public DPointSet printPoints() { public DPointSet printPoints() {
@@ -490,7 +475,6 @@ public class GraphPointSet {
} }
/** /**
*
* @param x * @param x
*/ */
public void removePoint(DPoint x) { public void removePoint(DPoint x) {
@@ -503,8 +487,7 @@ public class GraphPointSet {
for (int i = 0; i < buf.length; i++) { for (int i = 0; i < buf.length; i++) {
if (buf[i].x == x.x && buf[i].y == x.y) { if (buf[i].x == x.x && buf[i].y == x.y) {
System.out.println("point found"); System.out.println("point found");
} } else {
else {
m_ConnectedPointSet.addDPoint(buf[i]); m_ConnectedPointSet.addDPoint(buf[i]);
} }
@@ -512,7 +495,6 @@ public class GraphPointSet {
} }
/** /**
*
* @param c * @param c
*/ */
public void setColor(Color c) { public void setColor(Color c) {
@@ -525,7 +507,6 @@ public class GraphPointSet {
} }
/** /**
*
* @param p * @param p
*/ */
public void setConnectedMode(boolean p) { public void setConnectedMode(boolean p) {
@@ -533,7 +514,6 @@ public class GraphPointSet {
} }
/** /**
*
* @param p * @param p
*/ */
public void setIcon(DPointIcon p) { public void setIcon(DPointIcon p) {
@@ -542,7 +522,6 @@ public class GraphPointSet {
} }
/** /**
*
* @param x * @param x
* @param stroke * @param stroke
*/ */
@@ -567,10 +546,10 @@ public class GraphPointSet {
* @return the median point of this point set or null if it is empty * @return the median point of this point set or null if it is empty
*/ */
public DPoint getMedPoint() { public DPoint getMedPoint() {
if (m_ConnectedPointSet==null) { if (m_ConnectedPointSet == null) {
return null; return null;
} }
int medX = m_ConnectedPointSet.getSize()/2; int medX = m_ConnectedPointSet.getSize() / 2;
return m_ConnectedPointSet.getDPoint(medX); return m_ConnectedPointSet.getDPoint(medX);
} }
} }

View File

@@ -3,6 +3,7 @@ package eva2.gui.plot;
import eva2.tools.Pair; import eva2.tools.Pair;
import eva2.tools.StringTools; import eva2.tools.StringTools;
import eva2.tools.chart2d.SlimRect; import eva2.tools.chart2d.SlimRect;
import java.awt.Color; import java.awt.Color;
import java.awt.FontMetrics; import java.awt.FontMetrics;
import java.awt.Graphics; import java.awt.Graphics;
@@ -24,15 +25,12 @@ import javax.swing.JPanel;
* an alternative, an own frame could be created. * an alternative, an own frame could be created.
* *
* @author mkron, draeger * @author mkron, draeger
*
*/ */
public class GraphPointSetLegend { public class GraphPointSetLegend {
SortedSet<Pair<String, Color>> legendEntries; SortedSet<Pair<String, Color>> legendEntries;
/** /**
*
* @author draeger * @author draeger
*
*/ */
private static class PairComp implements Comparator<Pair<String, Color>> { private static class PairComp implements Comparator<Pair<String, Color>> {
@@ -63,15 +61,14 @@ public class GraphPointSetLegend {
legendEntries = new TreeSet<Pair<String, Color>>(comparator); legendEntries = new TreeSet<Pair<String, Color>>(comparator);
for (int i = 0; i < pointSetContainer.size(); i++) { for (int i = 0; i < pointSetContainer.size(); i++) {
GraphPointSet pointset = pointSetContainer.get(i); GraphPointSet pointset = pointSetContainer.get(i);
if (pointset.getPointSet().getSize()>0) { if (pointset.getPointSet().getSize() > 0) {
String entryStr; String entryStr;
if (appendIndex) { if (appendIndex) {
entryStr = StringTools.expandPrefixZeros(i, pointSetContainer.size()-1) + ": " + pointset.getInfoString(); entryStr = StringTools.expandPrefixZeros(i, pointSetContainer.size() - 1) + ": " + pointset.getInfoString();
} } else {
else {
entryStr = pointset.getInfoString(); entryStr = pointset.getInfoString();
} }
legendEntries.add(new Pair<String, Color>(entryStr,pointset.getColor())); legendEntries.add(new Pair<String, Color>(entryStr, pointset.getColor()));
} }
} }
} }
@@ -99,7 +96,6 @@ public class GraphPointSetLegend {
} }
/** /**
*
* @param bgCol * @param bgCol
* @param pointSetContainer * @param pointSetContainer
* @return * @return
@@ -115,7 +111,6 @@ public class GraphPointSetLegend {
} }
/** /**
*
* @param bgCol * @param bgCol
* @param pointSetContainer * @param pointSetContainer
* @return * @return
@@ -131,7 +126,6 @@ public class GraphPointSetLegend {
} }
/** /**
*
* @param component * @param component
*/ */
public void paintIn(JComponent component) { public void paintIn(JComponent component) {
@@ -172,7 +166,6 @@ public class GraphPointSetLegend {
} }
/** /**
*
* @param g * @param g
* @param x * @param x
* @param y * @param y

View File

@@ -12,15 +12,20 @@ import eva2.optimization.problems.InterfaceOptimizationProblem;
*/ */
public interface InterfaceDPointWithContent { public interface InterfaceDPointWithContent {
public void setEAIndividual(AbstractEAIndividual indy); public void setEAIndividual(AbstractEAIndividual indy);
public AbstractEAIndividual getEAIndividual(); public AbstractEAIndividual getEAIndividual();
/** This method allows you to set the according optimization problem /**
* This method allows you to set the according optimization problem
*
* @param problem InterfaceOptimizationProblem * @param problem InterfaceOptimizationProblem
*/ */
public void setProblem(InterfaceOptimizationProblem problem); public void setProblem(InterfaceOptimizationProblem problem);
public InterfaceOptimizationProblem getProblem(); public InterfaceOptimizationProblem getProblem();
/** This method allows you to draw additional data of the individual /**
* This method allows you to draw additional data of the individual
*/ */
public void showIndividual(); public void showIndividual();
} }

View File

@@ -6,12 +6,14 @@ package eva2.gui.plot;
* Hannes Planatscher @version: $Revision: 322 $ $Date: 2007-12-11 17:24:07 * Hannes Planatscher @version: $Revision: 322 $ $Date: 2007-12-11 17:24:07
* +0100 (Tue, 11 Dec 2007) $ $Author: mkron $ * +0100 (Tue, 11 Dec 2007) $ $Author: mkron $
*/ */
import eva2.EvAInfo; import eva2.EvAInfo;
import eva2.gui.JEFrame; import eva2.gui.JEFrame;
import eva2.optimization.individuals.AbstractEAIndividual; import eva2.optimization.individuals.AbstractEAIndividual;
import eva2.optimization.population.Population; import eva2.optimization.population.Population;
import eva2.tools.BasicResourceLoader; import eva2.tools.BasicResourceLoader;
import eva2.tools.chart2d.DPointSet; import eva2.tools.chart2d.DPointSet;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;

View File

@@ -1,4 +1,5 @@
package eva2.gui.plot; package eva2.gui.plot;
/* /*
* Title: EvA2 * Title: EvA2
* Description: * Description:
@@ -13,7 +14,7 @@ package eva2.gui.plot;
* IMPORTS * IMPORTS
*==========================================================================*/ *==========================================================================*/
public interface PlotInterface { public interface PlotInterface {
public void setConnectedPoint (double x,double y,int GraphLabel); public void setConnectedPoint(double x, double y, int GraphLabel);
/** /**
* Add two graphs to form an average graph * Add two graphs to form an average graph
@@ -22,16 +23,25 @@ public interface PlotInterface {
* @param g2 graph object two * @param g2 graph object two
* @param forceAdd if the graph mismatch in point counts, try to add them anyway in a useful manner. * @param forceAdd if the graph mismatch in point counts, try to add them anyway in a useful manner.
*/ */
public void addGraph (int g1,int g2, boolean forceAdd); public void addGraph(int g1, int g2, boolean forceAdd);
public void setUnconnectedPoint (double x, double y,int GraphLabel);
public void clearAll (); public void setUnconnectedPoint(double x, double y, int GraphLabel);
public void clearGraph (int GraphNumber);
public void setInfoString (int GraphLabel, String Info, float stroke); public void clearAll();
public void jump ();
public void clearGraph(int GraphNumber);
public void setInfoString(int GraphLabel, String Info, float stroke);
public void jump();
public String getName(); public String getName();
public int getPointCount(int graphLabel); public int getPointCount(int graphLabel);
// public FunctionArea getFunctionArea(); // this is bad for RMI
// public FunctionArea getFunctionArea(); // this is bad for RMI
public boolean isValid(); public boolean isValid();
public void init(); public void init();
} }

View File

@@ -12,11 +12,13 @@ package eva2.gui.plot;
/*==========================================================================* /*==========================================================================*
* IMPORTS * IMPORTS
*==========================================================================*/ *==========================================================================*/
import eva2.optimization.problems.Interface2DBorderProblem; import eva2.optimization.problems.Interface2DBorderProblem;
import eva2.optimization.problems.InterfaceFirstOrderDerivableProblem; import eva2.optimization.problems.InterfaceFirstOrderDerivableProblem;
import eva2.tools.chart2d.DRectangle; import eva2.tools.chart2d.DRectangle;
import eva2.tools.diagram.ColorBarCalculator; import eva2.tools.diagram.ColorBarCalculator;
import eva2.tools.math.Mathematics; import eva2.tools.math.Mathematics;
import java.awt.Color; import java.awt.Color;
import javax.swing.JPanel; import javax.swing.JPanel;
@@ -24,13 +26,14 @@ import javax.swing.JPanel;
/*==========================================================================* /*==========================================================================*
* CLASS DECLARATION * CLASS DECLARATION
*==========================================================================*/ *==========================================================================*/
/** /**
* *
*/ */
public class TopoPlot extends Plot { public class TopoPlot extends Plot {
Interface2DBorderProblem prob=null; Interface2DBorderProblem prob = null;
double[][] range=null; double[][] range = null;
boolean withGrads=false; boolean withGrads = false;
private int gridx = 50; private int gridx = 50;
private int gridy = 50; private int gridy = 50;
int colorScale = ColorBarCalculator.BLUE_TO_RED; int colorScale = ColorBarCalculator.BLUE_TO_RED;
@@ -38,25 +41,28 @@ public class TopoPlot extends Plot {
/** /**
* *
*/ */
public TopoPlot(String PlotName,String xname,String yname) { public TopoPlot(String PlotName, String xname, String yname) {
super(PlotName, xname, yname, true); super(PlotName, xname, yname, true);
//if (TRACE) System.out.println("Constructor TopoPlot "+PlotName); //if (TRACE) System.out.println("Constructor TopoPlot "+PlotName);
} }
public TopoPlot(String PlotName,String xname,String yname,double[] a, double[] b) {
public TopoPlot(String PlotName, String xname, String yname, double[] a, double[] b) {
super(PlotName, xname, yname, a, b); super(PlotName, xname, yname, a, b);
//if (TRACE) System.out.println("Constructor TopoPlot "+PlotName); //if (TRACE) System.out.println("Constructor TopoPlot "+PlotName);
} }
/** /**
* Defines parameters used for drawing the topology. * Defines parameters used for drawing the topology.
*
* @param gridX the x-resolution of the topology, higher value means higher resolution * @param gridX the x-resolution of the topology, higher value means higher resolution
* @param gridY the y-resolution of the topology, higher value means higher resolution * @param gridY the y-resolution of the topology, higher value means higher resolution
* @param color_scale the topologies color coding. Values (0-3) are valid. @See ColorBarCalculator. * @param color_scale the topologies color coding. Values (0-3) are valid. @See ColorBarCalculator.
*/ */
public void setParams(int gridX, int gridY, int color_scale) { public void setParams(int gridX, int gridY, int color_scale) {
if (gridX>m_Frame.getWidth()) { if (gridX > m_Frame.getWidth()) {
gridX = m_Frame.getWidth(); gridX = m_Frame.getWidth();
} }
if (gridY>m_Frame.getHeight()) { if (gridY > m_Frame.getHeight()) {
gridY = m_Frame.getHeight(); gridY = m_Frame.getHeight();
} }
gridx = gridX; gridx = gridX;
@@ -65,7 +71,6 @@ public class TopoPlot extends Plot {
} }
@Override @Override
protected void installButtons(JPanel buttonPan) { protected void installButtons(JPanel buttonPan) {
super.installButtons(buttonPan); super.installButtons(buttonPan);
@@ -81,8 +86,10 @@ public class TopoPlot extends Plot {
// }); // });
// buttonPan.add(refineButton); // buttonPan.add(refineButton);
} }
/**
/**
* Defines parameters used for drawing the topology. * Defines parameters used for drawing the topology.
*
* @param gridX the x-resolution of the topology, higher value means higher resolution * @param gridX the x-resolution of the topology, higher value means higher resolution
* @param gridY the y-resolution of the topology, higher value means higher resolution * @param gridY the y-resolution of the topology, higher value means higher resolution
*/ */
@@ -96,26 +103,27 @@ public class TopoPlot extends Plot {
public void setTopology(Interface2DBorderProblem problem) { public void setTopology(Interface2DBorderProblem problem) {
setTopology(problem, problem.get2DBorder(), false); setTopology(problem, problem.get2DBorder(), false);
} }
/** /**
* Defines the topology (by setting a specific problem) and draws the topology * Defines the topology (by setting a specific problem) and draws the topology
*/ */
public void setTopology(Interface2DBorderProblem problem, double[][] border, boolean withGradientsIfAvailable) { public void setTopology(Interface2DBorderProblem problem, double[][] border, boolean withGradientsIfAvailable) {
prob=problem; prob = problem;
range=border; range = border;
withGrads=withGradientsIfAvailable; withGrads = withGradientsIfAvailable;
double[] sizeXY=Mathematics.getAbsRange(border); double[] sizeXY = Mathematics.getAbsRange(border);
double deltaX = sizeXY[0]/gridx; double deltaX = sizeXY[0] / gridx;
double deltaY = sizeXY[1]/gridy; double deltaY = sizeXY[1] / gridy;
double maxDeriv=0; double maxDeriv = 0;
double[] pos = new double[2]; double[] pos = new double[2];
boolean TRACEMETH=false; boolean TRACEMETH = false;
//double fitRange = java.lang.Math.abs(problem.getMinFitness()-problem.getMaxFitness() ); //double fitRange = java.lang.Math.abs(problem.getMinFitness()-problem.getMaxFitness() );
double fitRange = 0, max = -Double.MAX_VALUE, min = Double.MAX_VALUE, tmp; double fitRange = 0, max = -Double.MAX_VALUE, min = Double.MAX_VALUE, tmp;
for (int x=0; x<gridx; x++) { for (int x = 0; x < gridx; x++) {
for (int y=0; y<gridy; y++) { for (int y = 0; y < gridy; y++) {
pos[0] = border[0][0]+x*deltaX; pos[0] = border[0][0] + x * deltaX;
pos[1] = border[1][0]+y*deltaY; pos[1] = border[1][0] + y * deltaY;
tmp = (float)(problem.functionValue(pos)); tmp = (float) (problem.functionValue(pos));
if (TRACEMETH) { if (TRACEMETH) {
System.out.println(pos[0] + " " + pos[1] + " " + tmp); System.out.println(pos[0] + " " + pos[1] + " " + tmp);
} }
@@ -126,9 +134,9 @@ public class TopoPlot extends Plot {
max = tmp; max = tmp;
} }
if (withGradientsIfAvailable && (problem instanceof InterfaceFirstOrderDerivableProblem)) { if (withGradientsIfAvailable && (problem instanceof InterfaceFirstOrderDerivableProblem)) {
double[] deriv = ((InterfaceFirstOrderDerivableProblem)problem).getFirstOrderGradients(problem.project2DPoint(pos)); double[] deriv = ((InterfaceFirstOrderDerivableProblem) problem).getFirstOrderGradients(problem.project2DPoint(pos));
for (int i=0; i<2;i++) { for (int i = 0; i < 2; i++) {
maxDeriv=Math.max(maxDeriv, Math.abs(deriv[i])); maxDeriv = Math.max(maxDeriv, Math.abs(deriv[i]));
} // maximum deriv of first 2 dims } // maximum deriv of first 2 dims
} }
@@ -138,12 +146,12 @@ public class TopoPlot extends Plot {
ColorBarCalculator colorBar = new ColorBarCalculator(colorScale); ColorBarCalculator colorBar = new ColorBarCalculator(colorScale);
m_Frame.setVisible(false); m_Frame.setVisible(false);
for (int x=0; x<gridx; x++) { for (int x = 0; x < gridx; x++) {
for (int y=0; y<gridy; y++) { for (int y = 0; y < gridy; y++) {
pos[0] = border[0][0]+x*deltaX; pos[0] = border[0][0] + x * deltaX;
pos[1] = border[1][0]+y*deltaY; pos[1] = border[1][0] + y * deltaY;
DRectangle rect = new DRectangle(pos[0]-(deltaX/2),pos[1]-(deltaY/2),deltaX,deltaY); DRectangle rect = new DRectangle(pos[0] - (deltaX / 2), pos[1] - (deltaY / 2), deltaX, deltaY);
Color color = new Color(colorBar.getRGB((float)((problem.functionValue(pos)-min)/fitRange))); Color color = new Color(colorBar.getRGB((float) ((problem.functionValue(pos) - min) / fitRange)));
// Color color = new Color(255,(int)(problem.doEvaluation(pos)[0]/fitRange*255),(int)(problem.doEvaluation(pos)[0]/fitRange*255)); // Color color = new Color(255,(int)(problem.doEvaluation(pos)[0]/fitRange*255),(int)(problem.doEvaluation(pos)[0]/fitRange*255));
// Color color = new Color(colorBar.getRGB((float)(problem.functionValue(pos)/fitRange))); // Color color = new Color(255,(int)(problem.doEvaluation(pos)[0]/fitRange*255),(int)(problem.doEvaluation(pos)[0]/fitRange*255)); // Color color = new Color(colorBar.getRGB((float)(problem.functionValue(pos)/fitRange))); // Color color = new Color(255,(int)(problem.doEvaluation(pos)[0]/fitRange*255),(int)(problem.doEvaluation(pos)[0]/fitRange*255));
rect.setColor(color); rect.setColor(color);
@@ -152,12 +160,12 @@ public class TopoPlot extends Plot {
} // for y } // for y
} // for x } // for x
if (withGradientsIfAvailable && (problem instanceof InterfaceFirstOrderDerivableProblem)) { if (withGradientsIfAvailable && (problem instanceof InterfaceFirstOrderDerivableProblem)) {
for (int x=0; x<gridx; x++) { for (int x = 0; x < gridx; x++) {
for (int y=0; y<gridy; y++) { for (int y = 0; y < gridy; y++) {
pos[0] = border[0][0]+x*deltaX; pos[0] = border[0][0] + x * deltaX;
pos[1] = border[1][0]+y*deltaY; pos[1] = border[1][0] + y * deltaY;
double[] derivPos = ((InterfaceFirstOrderDerivableProblem)problem).getFirstOrderGradients(problem.project2DPoint(pos)); double[] derivPos = ((InterfaceFirstOrderDerivableProblem) problem).getFirstOrderGradients(problem.project2DPoint(pos));
Mathematics.svDiv(1.1*(2*maxDeriv/Math.max(deltaX, deltaY)), derivPos, derivPos); Mathematics.svDiv(1.1 * (2 * maxDeriv / Math.max(deltaX, deltaY)), derivPos, derivPos);
Mathematics.vvAdd(pos, derivPos, derivPos); Mathematics.vvAdd(pos, derivPos, derivPos);
getFunctionArea().drawLine(pos, derivPos); getFunctionArea().drawLine(pos, derivPos);
getFunctionArea().drawIcon(1, "", derivPos, 0); getFunctionArea().drawIcon(1, "", derivPos, 0);

View File

@@ -19,7 +19,7 @@ public class VerticalButtonUI extends BasicButtonUI {
@Override @Override
public Dimension getPreferredSize(JComponent c) { public Dimension getPreferredSize(JComponent c) {
Dimension dim = super.getPreferredSize(c); Dimension dim = super.getPreferredSize(c);
return new Dimension( dim.height, dim.width ); return new Dimension(dim.height, dim.width);
} }
private static Rectangle paintIconR = new Rectangle(); private static Rectangle paintIconR = new Rectangle();
@@ -29,7 +29,7 @@ public class VerticalButtonUI extends BasicButtonUI {
@Override @Override
public void paint(Graphics g, JComponent c) { public void paint(Graphics g, JComponent c) {
JButton button = (JButton)c; JButton button = (JButton) c;
String text = button.getText(); String text = button.getText();
Icon icon = (button.isEnabled()) ? button.getIcon() : button.getDisabledIcon(); Icon icon = (button.isEnabled()) ? button.getIcon() : button.getDisabledIcon();
@@ -54,16 +54,15 @@ public class VerticalButtonUI extends BasicButtonUI {
AffineTransform tr = g2.getTransform(); AffineTransform tr = g2.getTransform();
if (angle == 90) { if (angle == 90) {
g2.rotate( Math.PI / 2 ); g2.rotate(Math.PI / 2);
g2.translate( 0, - c.getWidth() ); g2.translate(0, -c.getWidth());
paintViewR.x = c.getHeight()/2 - (int)fm.getStringBounds(text, g).getWidth()/2; paintViewR.x = c.getHeight() / 2 - (int) fm.getStringBounds(text, g).getWidth() / 2;
paintViewR.y = c.getWidth()/2 - (int)fm.getStringBounds(text, g).getHeight()/2; paintViewR.y = c.getWidth() / 2 - (int) fm.getStringBounds(text, g).getHeight() / 2;
} } else if (angle == 270 || angle == -90) {
else if (angle == 270 || angle == -90) { g2.rotate(-Math.PI / 2);
g2.rotate( - Math.PI / 2 ); g2.translate(-c.getHeight(), 0);
g2.translate( - c.getHeight(), 0 ); paintViewR.x = c.getHeight() / 2 - (int) fm.getStringBounds(text, g).getWidth() / 2;
paintViewR.x = c.getHeight()/2 - (int)fm.getStringBounds(text, g).getWidth()/2; paintViewR.y = c.getWidth() / 2 - (int) fm.getStringBounds(text, g).getHeight() / 2;
paintViewR.y = c.getWidth()/2 - (int)fm.getStringBounds(text, g).getHeight()/2;
} }
if (icon != null) { if (icon != null) {
@@ -75,12 +74,12 @@ public class VerticalButtonUI extends BasicButtonUI {
int textY = paintTextR.y + fm.getAscent(); int textY = paintTextR.y + fm.getAscent();
if (button.isEnabled()) { if (button.isEnabled()) {
paintText(g,c,new Rectangle(paintViewR.x,paintViewR.y,textX,textY),text); paintText(g, c, new Rectangle(paintViewR.x, paintViewR.y, textX, textY), text);
} else { } else {
paintText(g,c,new Rectangle(paintViewR.x,paintViewR.y,textX,textY),text); paintText(g, c, new Rectangle(paintViewR.x, paintViewR.y, textX, textY), text);
} }
} }
g2.setTransform( tr ); g2.setTransform(tr);
} }
} }

View File

@@ -8,8 +8,10 @@ package eva2.optimization;
* $Date: 2007-11-16 17:25:09 +0100 (Fri, 16 Nov 2007) $ * $Date: 2007-11-16 17:25:09 +0100 (Fri, 16 Nov 2007) $
* $Author: mkron $ * $Author: mkron $
*/ */
import eva2.optimization.go.InterfaceOptimizationParameters; import eva2.optimization.go.InterfaceOptimizationParameters;
import eva2.optimization.modules.ModuleAdapter; import eva2.optimization.modules.ModuleAdapter;
/** /**
* *
*/ */

View File

@@ -9,9 +9,11 @@ package eva2.optimization;
* $Date: 2007-12-04 15:23:57 +0100 (Tue, 04 Dec 2007) $ * $Date: 2007-12-04 15:23:57 +0100 (Tue, 04 Dec 2007) $
* $Author: mkron $ * $Author: mkron $
*/ */
import eva2.EvAInfo; import eva2.EvAInfo;
import eva2.optimization.go.InterfaceOptimizationParameters; import eva2.optimization.go.InterfaceOptimizationParameters;
import eva2.optimization.modules.ModuleAdapter; import eva2.optimization.modules.ModuleAdapter;
/** /**
* *
*/ */

View File

@@ -10,11 +10,13 @@ package eva2.optimization;
* $Date: 2007-12-06 16:05:11 +0100 (Thu, 06 Dec 2007) $ * $Date: 2007-12-06 16:05:11 +0100 (Thu, 06 Dec 2007) $
* $Author: mkron $ * $Author: mkron $
*/ */
import eva2.optimization.go.InterfaceOptimizationParameters; import eva2.optimization.go.InterfaceOptimizationParameters;
import eva2.optimization.modules.GOModuleAdapter; import eva2.optimization.modules.GOModuleAdapter;
import eva2.optimization.modules.ModuleAdapter; import eva2.optimization.modules.ModuleAdapter;
import eva2.tools.EVAERROR; import eva2.tools.EVAERROR;
import eva2.tools.ReflectPackage; import eva2.tools.ReflectPackage;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;

View File

@@ -5,12 +5,14 @@
package eva2.optimization; package eva2.optimization;
/** /**
*
* @author becker * @author becker
*/ */
public interface OptimizationStateListener { public interface OptimizationStateListener {
void performedStop(); void performedStop();
void performedStart(String infoString); void performedStart(String infoString);
void performedRestart(String infoString); void performedRestart(String infoString);
void updateProgress(final int percent, String msg); void updateProgress(final int percent, String msg);
} }

View File

@@ -3,7 +3,7 @@ package eva2.optimization.enums;
public enum BOAScoringMethods { public enum BOAScoringMethods {
BDM, K2, BIC; BDM, K2, BIC;
public static String[] getInfoStrings(){ public static String[] getInfoStrings() {
return new String[] {"The Bayesian Dirichlet Metric", "The K2 Metric", "The Bayesian Information Criterion"}; return new String[]{"The Bayesian Dirichlet Metric", "The K2 Metric", "The Bayesian Information Criterion"};
} }
} }

View File

@@ -1,6 +1,6 @@
package eva2.optimization.enums; package eva2.optimization.enums;
public enum DETypeEnum { public enum DETypeEnum {
DE1_Rand_1, DE2_CurrentToBest, DE_Best_2, TrigonometricDE,DE_CurrentToRand; DE1_Rand_1, DE2_CurrentToBest, DE_Best_2, TrigonometricDE, DE_CurrentToRand;
//", "DE2 - DE/current-to-best/1", "DE/best/2", "Trigonometric DE"}; //", "DE2 - DE/current-to-best/1", "DE/best/2", "Trigonometric DE"};
} }

View File

@@ -33,20 +33,30 @@ public enum PSOTopologyEnum {
/** /**
* A method to translate the "old" integer tags into the enum type. * A method to translate the "old" integer tags into the enum type.
*
* @param oldID * @param oldID
* @return * @return
*/ */
public static PSOTopologyEnum translateOldID(int oldID) { public static PSOTopologyEnum translateOldID(int oldID) {
switch (oldID) { switch (oldID) {
case 0: return linear; case 0:
case 1: return grid; return linear;
case 2: return star; case 1:
case 3: return multiSwarm; return grid;
case 4: return tree; case 2:
case 5: return hpso; return star;
case 6: return random; case 3:
case 7: return dms; return multiSwarm;
default: System.err.println("Error: invalid old topology ID in PSOTopologyEnum translateOldID! Returning grid."); case 4:
return tree;
case 5:
return hpso;
case 6:
return random;
case 7:
return dms;
default:
System.err.println("Error: invalid old topology ID in PSOTopologyEnum translateOldID! Returning grid.");
return grid; return grid;
} }
} }

View File

@@ -20,6 +20,7 @@ import eva2.optimization.strategies.EvolutionStrategies;
import eva2.optimization.strategies.GeneticAlgorithm; import eva2.optimization.strategies.GeneticAlgorithm;
import eva2.optimization.strategies.InterfaceOptimizer; import eva2.optimization.strategies.InterfaceOptimizer;
import eva2.tools.math.RNG; import eva2.tools.math.RNG;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.List; import java.awt.List;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
@@ -54,7 +55,7 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
transient private JProgressBar m_ProgressBar; transient private JProgressBar m_ProgressBar;
transient private SwingWorker worker; transient private SwingWorker worker;
transient private boolean show = false; transient private boolean show = false;
// transient private InterfaceTest test = new Test1(); // transient private InterfaceTest test = new Test1();
// Opt. Algorithms and Parameters // Opt. Algorithms and Parameters
//transient private InterfaceOptimizer optimizer = new EvolutionaryMultiObjectiveOptimization(); //transient private InterfaceOptimizer optimizer = new EvolutionaryMultiObjectiveOptimization();
//transient private InterfaceOptimizationProblem problem = new TF1Problem(); //transient private InterfaceOptimizationProblem problem = new TF1Problem();
@@ -68,7 +69,7 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
transient private String m_ExperimentName; transient private String m_ExperimentName;
transient private String m_OutputPath = ""; transient private String m_OutputPath = "";
transient private String m_OutputFileName = "none"; transient private String m_OutputFileName = "none";
// transient private GOStandaloneVersion m_yself; // transient private GOStandaloneVersion m_yself;
// these parameters are for the continue option // these parameters are for the continue option
transient private Population m_Backup; transient private Population m_Backup;
transient private boolean m_ContinueFlag; transient private boolean m_ContinueFlag;
@@ -97,7 +98,6 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
/** /**
* This method allows you to get the current GO parameters * This method allows you to get the current GO parameters
*
*/ */
public OptimizationParameters getGOParameters() { public OptimizationParameters getGOParameters() {
return this.m_GO; return this.m_GO;
@@ -192,6 +192,7 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
this.m_Frame.validate(); this.m_Frame.validate();
this.m_Frame.setVisible(true); this.m_Frame.setVisible(true);
} }
/** /**
* This action listener, called by the "Run/Restart" button, will init the * This action listener, called by the "Run/Restart" button, will init the
* problem and start the computation. * problem and start the computation.
@@ -695,6 +696,7 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
// public String seedTipText() { // public String seedTipText() {
// return "Choose the seed for the random number generator."; // return "Choose the seed for the random number generator.";
// } // }
/** /**
* This method sets the name of the current experiment as it will occur in * This method sets the name of the current experiment as it will occur in
* the plot legend. * the plot legend.

View File

@@ -36,7 +36,7 @@ public interface IndividualInterface {
* *
* @param fit new fitness of the individual * @param fit new fitness of the individual
*/ */
void setFitness (double[] fit); void setFitness(double[] fit);
/** /**
* Check whether the instance is dominating the given other individual and return * Check whether the instance is dominating the given other individual and return

View File

@@ -9,5 +9,6 @@ package eva2.optimization.go;
*/ */
public interface InterfaceGOStandalone { public interface InterfaceGOStandalone {
void startExperiment(); void startExperiment();
void setShow(boolean t); void setShow(boolean t);
} }

View File

@@ -1,6 +1,7 @@
package eva2.optimization.go; package eva2.optimization.go;
import eva2.optimization.problems.InterfaceAdditionalPopulationInformer; import eva2.optimization.problems.InterfaceAdditionalPopulationInformer;
import java.util.List; import java.util.List;
public interface InterfaceNotifyOnInformers { public interface InterfaceNotifyOnInformers {

View File

@@ -19,63 +19,85 @@ public interface InterfaceOptimizationParameters {
*/ */
// public String globalInfo(); // public String globalInfo();
/** This method allows you to serialize the current parameters into a *.ser file /**
* This method allows you to serialize the current parameters into a *.ser file
*/ */
public void saveInstance(); public void saveInstance();
/** This method returns the name /**
* This method returns the name
*
* @return string * @return string
*/ */
public String getName(); public String getName();
/** This methods allow you to set and get the Seed for the Random Number Generator. /**
* This methods allow you to set and get the Seed for the Random Number Generator.
*
* @param x Long seed. * @param x Long seed.
*/ */
public void setSeed(long x); public void setSeed(long x);
public long getSeed(); public long getSeed();
public String seedTipText(); public String seedTipText();
/** This method allows you to choose a termination criteria for the /**
* This method allows you to choose a termination criteria for the
* evolutionary algorithm. * evolutionary algorithm.
*
* @param term The new terminator * @param term The new terminator
*/ */
public void setTerminator(InterfaceTerminator term); public void setTerminator(InterfaceTerminator term);
public InterfaceTerminator getTerminator(); public InterfaceTerminator getTerminator();
public String terminatorTipText(); public String terminatorTipText();
/** This method allows you to set the current optimizing algorithm /**
* This method allows you to set the current optimizing algorithm
*
* @param optimizer The new optimizing algorithm * @param optimizer The new optimizing algorithm
*/ */
public void setOptimizer(InterfaceOptimizer optimizer); public void setOptimizer(InterfaceOptimizer optimizer);
public InterfaceOptimizer getOptimizer(); public InterfaceOptimizer getOptimizer();
// public String optimizerTipText(); // public String optimizerTipText();
/** This method will set the problem that is to be optimized /**
* This method will set the problem that is to be optimized
*
* @param problem * @param problem
*/ */
public void setProblem (InterfaceOptimizationProblem problem); public void setProblem(InterfaceOptimizationProblem problem);
public InterfaceOptimizationProblem getProblem ();
public InterfaceOptimizationProblem getProblem();
public String problemTipText(); public String problemTipText();
/** This method will set the output filename /**
* @param name * This method will set the output filename
* TODO invalidate these! *
* @param name TODO invalidate these!
*/ */
// public void setOutputFileName (String name); // public void setOutputFileName (String name);
// public String getOutputFileName (); // public String getOutputFileName ();
// public String outputFileNameTipText(); // public String outputFileNameTipText();
public InterfacePostProcessParams getPostProcessParams(); public InterfacePostProcessParams getPostProcessParams();
public void setPostProcessParams(InterfacePostProcessParams ppp); public void setPostProcessParams(InterfacePostProcessParams ppp);
public String postProcessParamsTipText(); public String postProcessParamsTipText();
public void setDoPostProcessing(boolean doPP); public void setDoPostProcessing(boolean doPP);
/** /**
* Give an instance which should be informed about elements which are additional informers. * Give an instance which should be informed about elements which are additional informers.
* *
* @see InterfaceAdditionalPopulationInformer
* @param o * @param o
* @see InterfaceAdditionalPopulationInformer
*/ */
public void addInformableInstance(InterfaceNotifyOnInformers o); public void addInformableInstance(InterfaceNotifyOnInformers o);
public boolean removeInformableInstance(InterfaceNotifyOnInformers o); public boolean removeInformableInstance(InterfaceNotifyOnInformers o);
} }

View File

@@ -10,7 +10,9 @@ package eva2.optimization.go;
*/ */
public interface InterfacePopulationChangedEventListener { public interface InterfacePopulationChangedEventListener {
/** This method allows an optimizer to register a change in the optimizer. /**
* This method allows an optimizer to register a change in the optimizer.
*
* @param source The source of the event. * @param source The source of the event.
* @param name Could be used to indicate the nature of the event. * @param name Could be used to indicate the nature of the event.
*/ */

View File

@@ -32,6 +32,7 @@ public interface InterfaceProcessor {
/** /**
* Get Info String about the Optimization. * Get Info String about the Optimization.
*
* @return The info String * @return The info String
*/ */
String getInfoString(); String getInfoString();

View File

@@ -8,7 +8,6 @@ import eva2.optimization.problems.InterfaceOptimizationProblem;
* Interface for a termination criterion. * Interface for a termination criterion.
* *
* @author mkron, streiche * @author mkron, streiche
*
*/ */
public interface InterfaceTerminator { public interface InterfaceTerminator {
/** /**
@@ -18,10 +17,13 @@ public interface InterfaceTerminator {
* @return true if the population fulfills the termination criterion, else false * @return true if the population fulfills the termination criterion, else false
*/ */
public boolean isTerminated(PopulationInterface pop); public boolean isTerminated(PopulationInterface pop);
public boolean isTerminated(InterfaceSolutionSet pop); public boolean isTerminated(InterfaceSolutionSet pop);
@Override @Override
public String toString(); public String toString();
public String lastTerminationMessage(); public String lastTerminationMessage();
public void init(InterfaceOptimizationProblem prob); public void init(InterfaceOptimizationProblem prob);
} }

View File

@@ -29,6 +29,7 @@ import eva2.optimization.operator.terminators.EvaluationTerminator;
import eva2.optimization.population.Population; import eva2.optimization.population.Population;
import eva2.optimization.strategies.InterfaceOptimizer; import eva2.optimization.strategies.InterfaceOptimizer;
import eva2.optimization.strategies.IslandModelEA; import eva2.optimization.strategies.IslandModelEA;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.GridLayout; import java.awt.GridLayout;
@@ -62,7 +63,8 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
this.m_State = new MOCCOState(); this.m_State = new MOCCOState();
} }
/** This method will init the main MOCCO GUI /**
* This method will init the main MOCCO GUI
* frame * frame
*/ */
public void initMOCCOFrame() { public void initMOCCOFrame() {
@@ -93,14 +95,14 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
this.m_JPanelButtom = new JPanel(); this.m_JPanelButtom = new JPanel();
this.m_JPanelButtom.setLayout(new BorderLayout()); this.m_JPanelButtom.setLayout(new BorderLayout());
JPanel tmpP = new JPanel(); JPanel tmpP = new JPanel();
tmpP.setLayout(new GridLayout(2,1)); tmpP.setLayout(new GridLayout(2, 1));
this.m_CurrentState = new JLabel("Problem Initialization"); this.m_CurrentState = new JLabel("Problem Initialization");
tmpP.add(this.m_CurrentState); tmpP.add(this.m_CurrentState);
this.m_ProgressBar = new JProgressBar(); this.m_ProgressBar = new JProgressBar();
tmpP.add(this.m_ProgressBar); tmpP.add(this.m_ProgressBar);
this.m_JPanelButtom.add(tmpP, BorderLayout.CENTER); this.m_JPanelButtom.add(tmpP, BorderLayout.CENTER);
this.m_JPanelControl.setMinimumSize(new Dimension(400,0)); this.m_JPanelControl.setMinimumSize(new Dimension(400, 0));
this.m_JPanelControl.setPreferredSize(new Dimension(400,0)); this.m_JPanelControl.setPreferredSize(new Dimension(400, 0));
this.m_JPanelButtom.add(this.m_JPanelControl, BorderLayout.EAST); this.m_JPanelButtom.add(this.m_JPanelControl, BorderLayout.EAST);
this.m_JPanelMain.add(this.m_JPanelButtom, BorderLayout.SOUTH); this.m_JPanelMain.add(this.m_JPanelButtom, BorderLayout.SOUTH);
this.m_JFrame.validate(); this.m_JFrame.validate();
@@ -113,18 +115,33 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
InterfaceProcessElement tmpP; InterfaceProcessElement tmpP;
while (cont) { while (cont) {
this.m_Iteration++; this.m_Iteration++;
while (m_StillWorking) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { } } while (m_StillWorking) {
try {
Thread.sleep(1000);
} catch (java.lang.InterruptedException e) {
}
}
if (this.m_State.m_OriginalProblem == null) { if (this.m_State.m_OriginalProblem == null) {
this.m_State.m_OriginalProblem = new TF1Problem(); this.m_State.m_OriginalProblem = new TF1Problem();
tmpP = new MOCCOProblemInitialization(this); tmpP = new MOCCOProblemInitialization(this);
tmpP.initProcessElementParametrization(); tmpP.initProcessElementParametrization();
while (!tmpP.isFinished()) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { }} while (!tmpP.isFinished()) {
this.m_State.m_CurrentProblem = (InterfaceOptimizationProblem)this.m_State.m_OriginalProblem.clone(); try {
Thread.sleep(1000);
} catch (java.lang.InterruptedException e) {
}
}
this.m_State.m_CurrentProblem = (InterfaceOptimizationProblem) this.m_State.m_OriginalProblem.clone();
this.m_View.problemChanged(true); this.m_View.problemChanged(true);
this.m_JPanelParameters.removeAll(); this.m_JPanelParameters.removeAll();
tmpP = new MOCCOInitialPopulationSize(this); tmpP = new MOCCOInitialPopulationSize(this);
tmpP.initProcessElementParametrization(); tmpP.initProcessElementParametrization();
while (!tmpP.isFinished()) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { }} while (!tmpP.isFinished()) {
try {
Thread.sleep(1000);
} catch (java.lang.InterruptedException e) {
}
}
this.m_State.m_InitialPopulationSize = Math.max(1, this.m_State.m_InitialPopulationSize); this.m_State.m_InitialPopulationSize = Math.max(1, this.m_State.m_InitialPopulationSize);
Population pop = new Population(); Population pop = new Population();
pop.setTargetSize(this.m_State.m_InitialPopulationSize); pop.setTargetSize(this.m_State.m_InitialPopulationSize);
@@ -134,11 +151,16 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
this.m_State.addPopulation2History(pop); this.m_State.addPopulation2History(pop);
this.m_View.problemChanged(true); this.m_View.problemChanged(true);
} }
((InterfaceMultiObjectiveDeNovoProblem)this.m_State.m_CurrentProblem).deactivateRepresentationEdit(); ((InterfaceMultiObjectiveDeNovoProblem) this.m_State.m_CurrentProblem).deactivateRepresentationEdit();
this.updateStatus("Analysis/Redefinition", 33); this.updateStatus("Analysis/Redefinition", 33);
tmpP = new MOCCOProblemRedefinition(this); tmpP = new MOCCOProblemRedefinition(this);
tmpP.initProcessElementParametrization(); tmpP.initProcessElementParametrization();
while (!tmpP.isFinished()) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { } } while (!tmpP.isFinished()) {
try {
Thread.sleep(1000);
} catch (java.lang.InterruptedException e) {
}
}
this.m_State.makeFitnessCache(true); this.m_State.makeFitnessCache(true);
this.m_State.m_CurrentProblem.initializeProblem(); this.m_State.m_CurrentProblem.initializeProblem();
this.m_State.makeBackup(); this.m_State.makeBackup();
@@ -147,70 +169,125 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
this.updateStatus("MO Strategy Selection", 50); this.updateStatus("MO Strategy Selection", 50);
tmpP = new MOCCOChooseMOStrategy(this); tmpP = new MOCCOChooseMOStrategy(this);
tmpP.initProcessElementParametrization(); tmpP.initProcessElementParametrization();
while (!tmpP.isFinished()) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { } } while (!tmpP.isFinished()) {
switch (((MOCCOChooseMOStrategy)tmpP).getMOStrategy()) { try {
case MOCCOChooseMOStrategy.STRATEGY_MOEA : { Thread.sleep(1000);
} catch (java.lang.InterruptedException e) {
}
}
switch (((MOCCOChooseMOStrategy) tmpP).getMOStrategy()) {
case MOCCOChooseMOStrategy.STRATEGY_MOEA: {
this.updateStatus("MOEA Parameterization", 75); this.updateStatus("MOEA Parameterization", 75);
tmpP = new MOCCOParameterizeMO(this); tmpP = new MOCCOParameterizeMO(this);
tmpP.initProcessElementParametrization(); tmpP.initProcessElementParametrization();
while (!tmpP.isFinished()) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { } } while (!tmpP.isFinished()) {
try {
Thread.sleep(1000);
} catch (java.lang.InterruptedException e) {
}
}
break; break;
} }
case MOCCOChooseMOStrategy.STRATEGY_STEP : { case MOCCOChooseMOStrategy.STRATEGY_STEP: {
this.updateStatus("Reference Solution...", 75); this.updateStatus("Reference Solution...", 75);
tmpP = new MOCCOChooseReferenceSolution(this); tmpP = new MOCCOChooseReferenceSolution(this);
tmpP.initProcessElementParametrization(); tmpP.initProcessElementParametrization();
while (!tmpP.isFinished()) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { } } while (!tmpP.isFinished()) {
AbstractEAIndividual reference = ((MOCCOChooseReferenceSolution)tmpP).getReferenceSolution(); try {
Thread.sleep(1000);
} catch (java.lang.InterruptedException e) {
}
}
AbstractEAIndividual reference = ((MOCCOChooseReferenceSolution) tmpP).getReferenceSolution();
this.updateStatus("STEP Parameterization...", 90); this.updateStatus("STEP Parameterization...", 90);
tmpP = new MOCCOParameterizeSTEP(this); tmpP = new MOCCOParameterizeSTEP(this);
((MOCCOParameterizeSTEP)tmpP).setReferenceSolution(reference); ((MOCCOParameterizeSTEP) tmpP).setReferenceSolution(reference);
tmpP.initProcessElementParametrization(); tmpP.initProcessElementParametrization();
while (!tmpP.isFinished()) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { } } while (!tmpP.isFinished()) {
try {
Thread.sleep(1000);
} catch (java.lang.InterruptedException e) {
}
}
break; break;
} }
case MOCCOChooseMOStrategy.STRATEGY_REFP : { case MOCCOChooseMOStrategy.STRATEGY_REFP: {
this.updateStatus("Reference Point...", 75); this.updateStatus("Reference Point...", 75);
tmpP = new MOCCOChooseReferencePoint(this); tmpP = new MOCCOChooseReferencePoint(this);
tmpP.initProcessElementParametrization(); tmpP.initProcessElementParametrization();
while (!tmpP.isFinished()) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { } } while (!tmpP.isFinished()) {
double[] reference = ((MOCCOChooseReferencePoint)tmpP).getReferencePoint(); try {
Thread.sleep(1000);
} catch (java.lang.InterruptedException e) {
}
}
double[] reference = ((MOCCOChooseReferencePoint) tmpP).getReferencePoint();
this.updateStatus("Reference Point Parameterization...", 90); this.updateStatus("Reference Point Parameterization...", 90);
tmpP = new MOCCOParameterizeRefPoint(this); tmpP = new MOCCOParameterizeRefPoint(this);
((MOCCOParameterizeRefPoint)tmpP).setReferencePoint(reference); ((MOCCOParameterizeRefPoint) tmpP).setReferencePoint(reference);
tmpP.initProcessElementParametrization(); tmpP.initProcessElementParametrization();
while (!tmpP.isFinished()) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { } } while (!tmpP.isFinished()) {
try {
Thread.sleep(1000);
} catch (java.lang.InterruptedException e) {
}
}
break; break;
} }
case MOCCOChooseMOStrategy.STRATEGY_TBCH : { case MOCCOChooseMOStrategy.STRATEGY_TBCH: {
this.updateStatus("Reference Point...", 75); this.updateStatus("Reference Point...", 75);
tmpP = new MOCCOChooseReferencePoint(this); tmpP = new MOCCOChooseReferencePoint(this);
tmpP.initProcessElementParametrization(); tmpP.initProcessElementParametrization();
while (!tmpP.isFinished()) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { } } while (!tmpP.isFinished()) {
double[] reference = ((MOCCOChooseReferencePoint)tmpP).getReferencePoint(); try {
Thread.sleep(1000);
} catch (java.lang.InterruptedException e) {
}
}
double[] reference = ((MOCCOChooseReferencePoint) tmpP).getReferencePoint();
this.updateStatus("Tchebycheff Method Parameterization...", 90); this.updateStatus("Tchebycheff Method Parameterization...", 90);
tmpP = new MOCCOParameterizeTchebycheff(this); tmpP = new MOCCOParameterizeTchebycheff(this);
((MOCCOParameterizeTchebycheff)tmpP).setReferencePoint(reference); ((MOCCOParameterizeTchebycheff) tmpP).setReferencePoint(reference);
tmpP.initProcessElementParametrization(); tmpP.initProcessElementParametrization();
while (!tmpP.isFinished()) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { } } while (!tmpP.isFinished()) {
try {
Thread.sleep(1000);
} catch (java.lang.InterruptedException e) {
}
}
break; break;
} }
case MOCCOChooseMOStrategy.STRATEGY_GDF : { case MOCCOChooseMOStrategy.STRATEGY_GDF: {
this.updateStatus("Reference Solution...", 75); this.updateStatus("Reference Solution...", 75);
tmpP = new MOCCOChooseReferenceSolution(this); tmpP = new MOCCOChooseReferenceSolution(this);
tmpP.initProcessElementParametrization(); tmpP.initProcessElementParametrization();
while (!tmpP.isFinished()) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { } } while (!tmpP.isFinished()) {
AbstractEAIndividual reference = ((MOCCOChooseReferenceSolution)tmpP).getReferenceSolution(); try {
Thread.sleep(1000);
} catch (java.lang.InterruptedException e) {
}
}
AbstractEAIndividual reference = ((MOCCOChooseReferenceSolution) tmpP).getReferenceSolution();
this.updateStatus("Geoffrion-Dyer-Feinberg Method Parameterization...", 90); this.updateStatus("Geoffrion-Dyer-Feinberg Method Parameterization...", 90);
tmpP = new MOCCOParameterizeGDF(this); tmpP = new MOCCOParameterizeGDF(this);
((MOCCOParameterizeGDF)tmpP).setReferenceSolution(reference); ((MOCCOParameterizeGDF) tmpP).setReferenceSolution(reference);
tmpP.initProcessElementParametrization(); tmpP.initProcessElementParametrization();
while (!tmpP.isFinished()) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { } } while (!tmpP.isFinished()) {
try {
Thread.sleep(1000);
} catch (java.lang.InterruptedException e) {
}
}
break; break;
} }
default : { default: {
tmpP = new MOCCOParameterizeMO(this); tmpP = new MOCCOParameterizeMO(this);
while (!tmpP.isFinished()) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { } } while (!tmpP.isFinished()) {
try {
Thread.sleep(1000);
} catch (java.lang.InterruptedException e) {
}
}
break; break;
} }
} }
@@ -218,7 +295,12 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
this.updateStatus("SO-Optimizer Parameterization", 66); this.updateStatus("SO-Optimizer Parameterization", 66);
tmpP = new MOCCOParameterizeSO(this); tmpP = new MOCCOParameterizeSO(this);
tmpP.initProcessElementParametrization(); tmpP.initProcessElementParametrization();
while (!tmpP.isFinished()) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { } } while (!tmpP.isFinished()) {
try {
Thread.sleep(1000);
} catch (java.lang.InterruptedException e) {
}
}
} }
// now optimize // now optimize
this.updateStatus("Optimizing...", 0); this.updateStatus("Optimizing...", 0);
@@ -227,27 +309,24 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
} }
private void checkForObjectives(String w) { private void checkForObjectives(String w) {
System.out.println("I'm currently "+w); System.out.println("I'm currently " + w);
System.out.print("Original Problem is "); System.out.print("Original Problem is ");
if (this.m_State.m_OriginalProblem.isMultiObjective()) { if (this.m_State.m_OriginalProblem.isMultiObjective()) {
System.out.println("multi-objective."); System.out.println("multi-objective.");
} } else {
else {
System.out.println("single-objective."); System.out.println("single-objective.");
} }
System.out.print("Current Problem is "); System.out.print("Current Problem is ");
if (this.m_State.m_CurrentProblem.isMultiObjective()) { if (this.m_State.m_CurrentProblem.isMultiObjective()) {
System.out.println("multi-objective."); System.out.println("multi-objective.");
} } else {
else {
System.out.println("single-objective."); System.out.println("single-objective.");
} }
if (this.m_State.m_BackupProblem != null) { if (this.m_State.m_BackupProblem != null) {
System.out.print("Backup Problem is "); System.out.print("Backup Problem is ");
if (this.m_State.m_BackupProblem.isMultiObjective()) { if (this.m_State.m_BackupProblem.isMultiObjective()) {
System.out.println("multi-objective."); System.out.println("multi-objective.");
} } else {
else {
System.out.println("single-objective."); System.out.println("single-objective.");
} }
} else { } else {
@@ -257,30 +336,30 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
private void checktForMOSO(String w) { private void checktForMOSO(String w) {
String s; String s;
System.out.println("I'm currently at "+w); System.out.println("I'm currently at " + w);
InterfaceMOSOConverter moso = ((AbstractMultiObjectiveOptimizationProblem)this.m_State.m_CurrentProblem).getMOSOConverter(); InterfaceMOSOConverter moso = ((AbstractMultiObjectiveOptimizationProblem) this.m_State.m_CurrentProblem).getMOSOConverter();
System.out.println("MOSO selected: "+moso.getName()); System.out.println("MOSO selected: " + moso.getName());
InterfaceOptimizationObjective[] obj = ((InterfaceMultiObjectiveDeNovoProblem)this.m_State.m_CurrentProblem).getProblemObjectives(); InterfaceOptimizationObjective[] obj = ((InterfaceMultiObjectiveDeNovoProblem) this.m_State.m_CurrentProblem).getProblemObjectives();
s = "Objectives: {"; s = "Objectives: {";
for (int i = 0; i < obj.length; i++) { for (int i = 0; i < obj.length; i++) {
s += obj[i].getIdentName(); s += obj[i].getIdentName();
if (i < (obj.length-1)) { if (i < (obj.length - 1)) {
s += "; "; s += "; ";
} }
} }
s += "}"; s += "}";
System.out.println(""+s); System.out.println("" + s);
if (moso instanceof MOSOWeightedFitness) { if (moso instanceof MOSOWeightedFitness) {
PropertyDoubleArray prop = ((MOSOWeightedFitness)moso).getWeights(); PropertyDoubleArray prop = ((MOSOWeightedFitness) moso).getWeights();
s = "Weights : {"; s = "Weights : {";
for (int i = 0; i < prop.getNumRows(); i++) { for (int i = 0; i < prop.getNumRows(); i++) {
s += prop.getValue(i,0); s += prop.getValue(i, 0);
if (i < (prop.getNumRows()-1)) { if (i < (prop.getNumRows() - 1)) {
s += "; "; s += "; ";
} }
} }
s += "}"; s += "}";
System.out.println(""+s); System.out.println("" + s);
} }
} }
@@ -318,7 +397,8 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
} }
}*/ }*/
/** This is the main method /**
* This is the main method
* *
* @param args * @param args
*/ */
@@ -337,8 +417,8 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
if (go.m_State.m_Optimizer.getPopulation().getFunctionCalls() == 0) { if (go.m_State.m_Optimizer.getPopulation().getFunctionCalls() == 0) {
// start to optimize // start to optimize
go.startExperiment(); go.startExperiment();
file = file.replaceAll(".ser",""); file = file.replaceAll(".ser", "");
go.saveObject(file+"_Finished.ser"); go.saveObject(file + "_Finished.ser");
} else { } else {
// start GUI // start GUI
go.initMOCCOFrame(); go.initMOCCOFrame();
@@ -347,7 +427,9 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
} }
} }
/** This methods loads the current state of MOCO from a serialized file /**
* This methods loads the current state of MOCO from a serialized file
*
* @param loadFrom The name of the serialized file * @param loadFrom The name of the serialized file
* @return The new state of MOCO * @return The new state of MOCO
*/ */
@@ -359,19 +441,21 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
oi.close(); oi.close();
if (!(obj instanceof MOCCOState)) { if (!(obj instanceof MOCCOState)) {
throw new Exception("Object not of type MOCCOState"); throw new Exception("Object not of type MOCCOState");
} return obj; }
return obj;
} catch (Exception ex) { } catch (Exception ex) {
if (this.m_JFrame != null) { if (this.m_JFrame != null) {
JOptionPane.showMessageDialog(this.m_JFrame, "Couldn't read object: " + selected.getName() + "\n" + ex.getMessage(), "Open object file", JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(this.m_JFrame, "Couldn't read object: " + selected.getName() + "\n" + ex.getMessage(), "Open object file", JOptionPane.ERROR_MESSAGE);
} } else {
else {
System.out.println("Couldn't read object: " + selected.getName() + "\n" + ex.getMessage()); System.out.println("Couldn't read object: " + selected.getName() + "\n" + ex.getMessage());
} }
} }
return null; return null;
} }
/** This method saves the current MOCOData into a serialized file /**
* This method saves the current MOCOData into a serialized file
*
* @param saveAs The name of the outputfile * @param saveAs The name of the outputfile
*/ */
public void saveObject(String saveAs) { public void saveObject(String saveAs) {
@@ -383,8 +467,7 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
} catch (Exception ex) { } catch (Exception ex) {
if (this.m_JFrame != null) { if (this.m_JFrame != null) {
JOptionPane.showMessageDialog(this.m_JFrame, "Couldn't write to file: " + sFile.getName() + "\n" + ex.getMessage(), "Save object", JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(this.m_JFrame, "Couldn't write to file: " + sFile.getName() + "\n" + ex.getMessage(), "Save object", JOptionPane.ERROR_MESSAGE);
} } else {
else {
System.out.println("Couldn't write to file: " + sFile.getName() + "\n" + ex.getMessage()); System.out.println("Couldn't write to file: " + sFile.getName() + "\n" + ex.getMessage());
} }
} }
@@ -394,7 +477,8 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
* InterfaceGOStandalone * InterfaceGOStandalone
*/ */
/** This method starts the actual optimization procedure /**
* This method starts the actual optimization procedure
*/ */
@Override @Override
public void startExperiment() { public void startExperiment() {
@@ -403,7 +487,7 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
this.m_StillWorking = true; this.m_StillWorking = true;
this.m_State.m_Optimizer.setProblem(this.m_State.m_CurrentProblem); this.m_State.m_Optimizer.setProblem(this.m_State.m_CurrentProblem);
if (this.m_Debug) { if (this.m_Debug) {
System.out.println(""+this.m_State.m_Optimizer.getStringRepresentation()); System.out.println("" + this.m_State.m_Optimizer.getStringRepresentation());
} }
this.m_State.m_CurrentProblem.evaluate(this.m_State.m_Optimizer.getPopulation()); this.m_State.m_CurrentProblem.evaluate(this.m_State.m_Optimizer.getPopulation());
this.m_State.m_Optimizer.getPopulation().SetFunctionCalls(0); this.m_State.m_Optimizer.getPopulation().SetFunctionCalls(0);
@@ -416,11 +500,12 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
public Object construct() { public Object construct() {
return doWork(); return doWork();
} }
@Override @Override
public void finished() { public void finished() {
Population[] pop = null; Population[] pop = null;
if (m_State.m_Optimizer instanceof IslandModelEA) { if (m_State.m_Optimizer instanceof IslandModelEA) {
InterfaceOptimizer[] opt = ((IslandModelEA)m_State.m_Optimizer).getOptimizers(); InterfaceOptimizer[] opt = ((IslandModelEA) m_State.m_Optimizer).getOptimizers();
pop = new Population[opt.length]; pop = new Population[opt.length];
for (int i = 0; i < opt.length; i++) { for (int i = 0; i < opt.length; i++) {
pop[i] = opt[i].getPopulation(); pop[i] = opt[i].getPopulation();
@@ -444,7 +529,8 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
worker.start(); worker.start();
} }
/** When the worker needs to update the GUI we do so by queuing /**
* When the worker needs to update the GUI we do so by queuing
* a Runnable for the event dispatching thread with * a Runnable for the event dispatching thread with
* SwingUtilities.invokeLater(). In this case we're just * SwingUtilities.invokeLater(). In this case we're just
* changing the progress bars value. * changing the progress bars value.
@@ -462,7 +548,8 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
this.m_CurrentState.setText(t); this.m_CurrentState.setText(t);
} }
/** This method represents the application code that we'd like to /**
* This method represents the application code that we'd like to
* run on a separate thread. It simulates slowly computing * run on a separate thread. It simulates slowly computing
* a value, in this case just a string 'All Done'. It updates the * a value, in this case just a string 'All Done'. It updates the
* progress bar every half second to remind the user that * progress bar every half second to remind the user that
@@ -480,8 +567,7 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
this.m_State.m_Optimizer.optimize(); this.m_State.m_Optimizer.optimize();
} }
System.gc(); System.gc();
} } catch (InterruptedException e) {
catch (InterruptedException e) {
updateStatus("Interrupted", 0); updateStatus("Interrupted", 0);
return "Interrupted"; return "Interrupted";
} }
@@ -497,7 +583,9 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
/*********************************************************************************************** /***********************************************************************************************
* InterfacePopulationChangedEventListener * InterfacePopulationChangedEventListener
*/ */
/** This method allows an optimizer to register a change in the optimizer. /**
* This method allows an optimizer to register a change in the optimizer.
*
* @param source The source of the event. * @param source The source of the event.
* @param name Could be used to indicate the nature of the event. * @param name Could be used to indicate the nature of the event.
*/ */
@@ -506,15 +594,15 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
int currentProgress; int currentProgress;
if (name.equals(Population.nextGenerationPerformed)) { if (name.equals(Population.nextGenerationPerformed)) {
if (this.m_State.isVisible) { if (this.m_State.isVisible) {
Population population = ((InterfaceOptimizer)source).getPopulation(); Population population = ((InterfaceOptimizer) source).getPopulation();
double x = 100; double x = 100;
if (this.m_State.m_Terminator instanceof EvaluationTerminator) { if (this.m_State.m_Terminator instanceof EvaluationTerminator) {
double y = x/(double)((EvaluationTerminator)this.m_State.m_Terminator).getFitnessCalls(); double y = x / (double) ((EvaluationTerminator) this.m_State.m_Terminator).getFitnessCalls();
currentProgress = (int)(population.getFunctionCalls()*y); currentProgress = (int) (population.getFunctionCalls() * y);
} else { } else {
currentProgress = (int)(0); currentProgress = (int) (0);
} }
updateStatus("Optimizing...",currentProgress); updateStatus("Optimizing...", currentProgress);
} else { } else {
// perhaps i could write it to file!? // perhaps i could write it to file!?
} }

View File

@@ -1,4 +1,5 @@
package eva2.optimization.go; package eva2.optimization.go;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
/** /**
@@ -6,11 +7,11 @@ import javax.swing.SwingUtilities;
* SwingWorker 3), an abstract class that you subclass to * SwingWorker 3), an abstract class that you subclass to
* perform GUI-related work in a dedicated thread. For * perform GUI-related work in a dedicated thread. For
* instructions on using this class, see: * instructions on using this class, see:
* * <p/>
* http://java.sun.com/products/jfc/tsc/articles/threads/threads2.html * http://java.sun.com/products/jfc/tsc/articles/threads/threads2.html
* or * or
* http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html * http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html
* * <p/>
* Note that the API changed slightly in the 3rd version: * Note that the API changed slightly in the 3rd version:
* You must now invoke start() on the SwingWorker after * You must now invoke start() on the SwingWorker after
* creating it. * creating it.
@@ -26,9 +27,18 @@ public abstract class SwingWorker {
*/ */
private static class ThreadVar { private static class ThreadVar {
private Thread thread; private Thread thread;
ThreadVar(Thread t) { thread = t; }
synchronized Thread get() { return thread; } ThreadVar(Thread t) {
synchronized void clear() { thread = null; } thread = t;
}
synchronized Thread get() {
return thread;
}
synchronized void clear() {
thread = null;
}
} }
private ThreadVar threadVar; private ThreadVar threadVar;
@@ -75,8 +85,7 @@ public abstract class SwingWorker {
} }
try { try {
t.join(); t.join();
} } catch (InterruptedException e) {
catch (InterruptedException e) {
Thread.currentThread().interrupt(); // propagate Thread.currentThread().interrupt(); // propagate
return null; return null;
} }
@@ -90,7 +99,9 @@ public abstract class SwingWorker {
public SwingWorker() { public SwingWorker() {
final Runnable doFinished = new Runnable() { final Runnable doFinished = new Runnable() {
@Override @Override
public void run() { finished(); } public void run() {
finished();
}
}; };
Runnable doConstruct = new Runnable() { Runnable doConstruct = new Runnable() {
@@ -98,8 +109,7 @@ public abstract class SwingWorker {
public void run() { public void run() {
try { try {
setValue(construct()); setValue(construct());
} } finally {
finally {
threadVar.clear(); threadVar.clear();
} }

View File

@@ -14,9 +14,11 @@ import eva2.optimization.population.Population;
import eva2.optimization.problems.InterfaceOptimizationProblem; import eva2.optimization.problems.InterfaceOptimizationProblem;
import eva2.tools.EVAERROR; import eva2.tools.EVAERROR;
import eva2.tools.math.RNG; import eva2.tools.math.RNG;
import java.util.*; import java.util.*;
/** This is the abstract EA individual implementing the most important methods giving /**
* This is the abstract EA individual implementing the most important methods giving
* access to mutation and crossover rates and operators, fitness values and selection * access to mutation and crossover rates and operators, fitness values and selection
* probabilities. All EA individuals should typically extend this abstract EA individual. * probabilities. All EA individuals should typically extend this abstract EA individual.
* In that case the EA individuals only implement the genotype and phenotype interfaces. * In that case the EA individuals only implement the genotype and phenotype interfaces.
@@ -249,6 +251,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
// public String getIndividualName() { // public String getIndividualName() {
// return this.m_Name; // return this.m_Name;
// } // }
/** /**
* This method is used when a new offspring is created the increment the * This method is used when a new offspring is created the increment the
* name. * name.
@@ -307,6 +310,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
// return false; // return false;
// } // }
// } // }
/** /**
* This method will allow a default initialisation of the individual * This method will allow a default initialisation of the individual
* *
@@ -385,6 +389,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
// public void setLogHeritagetLen(int logLen) { // public void setLogHeritagetLen(int logLen) {
// logParentLen = logLen; // logParentLen = logLen;
// } // }
/** /**
* Add an ancestor generation with multiple parents. * Add an ancestor generation with multiple parents.
* *
@@ -446,6 +451,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
// heritage.add(parentIDs); // heritage.add(parentIDs);
//// if (heritage.size() > logParentLen) heritage.remove(0); //// if (heritage.size() > logParentLen) heritage.remove(0);
// } // }
/** /**
* Add an ancestor generation with only one parent. * Add an ancestor generation with only one parent.
* *
@@ -468,6 +474,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
// if (heritage != null) return heritage.getLast(); // if (heritage != null) return heritage.getLast();
// else return null; // else return null;
// } // }
/** /**
* This method will allow you to get the current age of an individual Zero * This method will allow you to get the current age of an individual Zero
* means it has not even been evaluated. * means it has not even been evaluated.
@@ -1286,7 +1293,6 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
/** /**
* @return true if parent history logging is activated * @return true if parent history logging is activated
*
*/ */
protected boolean isLogParents() { protected boolean isLogParents() {
return logParents; return logParents;
@@ -1309,7 +1315,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
return (IndividualInterface) this.clone(); return (IndividualInterface) this.clone();
} }
// /** This method is used to get the basic data type of an individual double[]. // /** This method is used to get the basic data type of an individual double[].
// * @deprecated Since not all EAIndividuals provide double as basic data type // * @deprecated Since not all EAIndividuals provide double as basic data type
// * the fitness can be is returned as default value. // * the fitness can be is returned as default value.
// * @see #getFitness() // * @see #getFitness()

View File

@@ -16,9 +16,8 @@ import java.util.Comparator;
* the comparison is based on those. This may be used to access alternative (e.g. older or * the comparison is based on those. This may be used to access alternative (e.g. older or
* best-so-far fitness values) for individual comparison. * best-so-far fitness values) for individual comparison.
* *
* @see #AbstractEAIndividual().isDominatingFitness(double[], double[])
* @author mkron * @author mkron
* * @see #AbstractEAIndividual().isDominatingFitness(double[], double[])
*/ */
public class AbstractEAIndividualComparator implements Comparator<Object>, Serializable { public class AbstractEAIndividualComparator implements Comparator<Object>, Serializable {
// flag whether a data field should be used. // flag whether a data field should be used.
@@ -30,7 +29,6 @@ public class AbstractEAIndividualComparator implements Comparator<Object>, Seria
* Comparator implementation which compares two individuals based on their fitness. * Comparator implementation which compares two individuals based on their fitness.
* The default version calls compares based on dominance with priority of feasibility if there are constraints. * The default version calls compares based on dominance with priority of feasibility if there are constraints.
* It assigns -1 if first is better, 1 if second is better, 0 if the two ind.s are not comparable. * It assigns -1 if first is better, 1 if second is better, 0 if the two ind.s are not comparable.
*
*/ */
public AbstractEAIndividualComparator() { public AbstractEAIndividualComparator() {
this("", -1, true); this("", -1, true);
@@ -74,8 +72,8 @@ public class AbstractEAIndividualComparator implements Comparator<Object>, Seria
@Override @Override
public boolean equals(Object other) { public boolean equals(Object other) {
if (other instanceof AbstractEAIndividualComparator) { if (other instanceof AbstractEAIndividualComparator) {
AbstractEAIndividualComparator o = (AbstractEAIndividualComparator)other; AbstractEAIndividualComparator o = (AbstractEAIndividualComparator) other;
if ((indyDataKey==o.indyDataKey) || (indyDataKey!=null && (indyDataKey.equals(o.indyDataKey)))) { if ((indyDataKey == o.indyDataKey) || (indyDataKey != null && (indyDataKey.equals(o.indyDataKey)))) {
if ((fitCriterion == o.fitCriterion) && (preferFeasible == o.preferFeasible)) { if ((fitCriterion == o.fitCriterion) && (preferFeasible == o.preferFeasible)) {
return true; return true;
} }
@@ -86,17 +84,17 @@ public class AbstractEAIndividualComparator implements Comparator<Object>, Seria
@Override @Override
public int hashCode() { public int hashCode() {
return indyDataKey.hashCode()+100+fitCriterion+(preferFeasible ? 7 : 13); return indyDataKey.hashCode() + 100 + fitCriterion + (preferFeasible ? 7 : 13);
} }
/** /**
* Generic constructor. * Generic constructor.
* *
* @see #AbstractEAIndividualComparator(int)
* @see #AbstractEAIndividualComparator(String)
* @param indyDataKey * @param indyDataKey
* @param fitnessCriterion * @param fitnessCriterion
* @param priorizeConstraints * @param priorizeConstraints
* @see #AbstractEAIndividualComparator(int)
* @see #AbstractEAIndividualComparator(String)
*/ */
public AbstractEAIndividualComparator(String indDataKey, int fitnessCriterion, boolean preferFeasible) { public AbstractEAIndividualComparator(String indDataKey, int fitnessCriterion, boolean preferFeasible) {
this.indyDataKey = indDataKey; this.indyDataKey = indDataKey;
@@ -129,19 +127,18 @@ public class AbstractEAIndividualComparator implements Comparator<Object>, Seria
if (preferFeasible) { // check constraint violation first? if (preferFeasible) { // check constraint violation first?
int constrViolComp = ((AbstractEAIndividual) o1).compareConstraintViolation((AbstractEAIndividual) o2); int constrViolComp = ((AbstractEAIndividual) o1).compareConstraintViolation((AbstractEAIndividual) o2);
if (constrViolComp>0) { if (constrViolComp > 0) {
return -1; return -1;
} } else if (constrViolComp < 0) {
else if (constrViolComp < 0) {
return 1; return 1;
} }
// otherwise both do not violate, so regard fitness // otherwise both do not violate, so regard fitness
} }
if (indyDataKey != null && (indyDataKey.length()>0)) { // check specific key if (indyDataKey != null && (indyDataKey.length() > 0)) { // check specific key
double[] fit1 = (double[])((AbstractEAIndividual)o1).getData(indyDataKey); double[] fit1 = (double[]) ((AbstractEAIndividual) o1).getData(indyDataKey);
double[] fit2 = (double[])((AbstractEAIndividual)o2).getData(indyDataKey); double[] fit2 = (double[]) ((AbstractEAIndividual) o2).getData(indyDataKey);
if ((fit1==null) || (fit2==null)) { if ((fit1 == null) || (fit2 == null)) {
throw new RuntimeException("Unknown individual data key " + indyDataKey + ", unable to compare individuals ("+this.getClass().getSimpleName()+")"); throw new RuntimeException("Unknown individual data key " + indyDataKey + ", unable to compare individuals (" + this.getClass().getSimpleName() + ")");
} }
if (fitCriterion < 0) { if (fitCriterion < 0) {
o1domO2 = AbstractEAIndividual.isDominatingFitness(fit1, fit2); o1domO2 = AbstractEAIndividual.isDominatingFitness(fit1, fit2);
@@ -149,8 +146,7 @@ public class AbstractEAIndividualComparator implements Comparator<Object>, Seria
} else { } else {
if (fit1[fitCriterion] == fit2[fitCriterion]) { if (fit1[fitCriterion] == fit2[fitCriterion]) {
return 0; return 0;
} } else {
else {
return (fit1[fitCriterion] < fit2[fitCriterion]) ? -1 : 1; return (fit1[fitCriterion] < fit2[fitCriterion]) ? -1 : 1;
} }
} }
@@ -176,9 +172,11 @@ public class AbstractEAIndividualComparator implements Comparator<Object>, Seria
public String getIndyDataKey() { public String getIndyDataKey() {
return indyDataKey; return indyDataKey;
} }
public void setIndyDataKey(String indyDataKey) { public void setIndyDataKey(String indyDataKey) {
this.indyDataKey = indyDataKey; this.indyDataKey = indyDataKey;
} }
public String indyDataKeyTipText() { public String indyDataKeyTipText() {
return "A String can be given which retrievies individual properties based on which the comparison is performed."; return "A String can be given which retrievies individual properties based on which the comparison is performed.";
} }
@@ -186,9 +184,11 @@ public class AbstractEAIndividualComparator implements Comparator<Object>, Seria
public int getFitCriterion() { public int getFitCriterion() {
return fitCriterion; return fitCriterion;
} }
public void setFitCriterion(int fitCriterion) { public void setFitCriterion(int fitCriterion) {
this.fitCriterion = fitCriterion; this.fitCriterion = fitCriterion;
} }
public String fitCriterionTipText() { public String fitCriterionTipText() {
return "If -1, dominance is used, otherwise the indexed fitness criterion (for multiobjective problems)"; return "If -1, dominance is used, otherwise the indexed fitness criterion (for multiobjective problems)";
} }
@@ -196,9 +196,11 @@ public class AbstractEAIndividualComparator implements Comparator<Object>, Seria
public boolean isPreferFeasible() { public boolean isPreferFeasible() {
return preferFeasible; return preferFeasible;
} }
public void setPreferFeasible(boolean priorConst) { public void setPreferFeasible(boolean priorConst) {
preferFeasible = priorConst; preferFeasible = priorConst;
} }
public String preferFeasibleTipText() { public String preferFeasibleTipText() {
return "Activate preference of feasible individuals in any comparison acc. to Deb's rules."; return "Activate preference of feasible individuals in any comparison acc. to Deb's rules.";
} }
@@ -206,6 +208,7 @@ public class AbstractEAIndividualComparator implements Comparator<Object>, Seria
public static String globalInfo() { public static String globalInfo() {
return "A comparator class for general EA individuals. Compares individuals based on their fitness in context of minimization."; return "A comparator class for general EA individuals. Compares individuals based on their fitness in context of minimization.";
} }
public String getName() { public String getName() {
return "IndividualComparator"; return "IndividualComparator";
} }

View File

@@ -6,10 +6,12 @@ import eva2.optimization.operator.mutation.MutateESGlobal;
import eva2.optimization.problems.InterfaceHasInitRange; import eva2.optimization.problems.InterfaceHasInitRange;
import eva2.optimization.problems.InterfaceOptimizationProblem; import eva2.optimization.problems.InterfaceOptimizationProblem;
import eva2.tools.math.RNG; import eva2.tools.math.RNG;
import java.util.BitSet; import java.util.BitSet;
/** This individual uses a real-valued genotype to code for binary values, either /**
* This individual uses a real-valued genotype to code for binary values, either
* by using a threshold value of by interpreting the double value as probability. * by using a threshold value of by interpreting the double value as probability.
* Created by IntelliJ IDEA. * Created by IntelliJ IDEA.
* User: streiche * User: streiche
@@ -52,7 +54,7 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
this.age = individual.age; this.age = individual.age;
this.crossoverOperator = individual.crossoverOperator; this.crossoverOperator = individual.crossoverOperator;
this.crossoverProbability = individual.crossoverProbability; this.crossoverProbability = individual.crossoverProbability;
this.mutationOperator = (InterfaceMutation)individual.mutationOperator.clone(); this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone();
this.mutationProbability = individual.mutationProbability; this.mutationProbability = individual.mutationProbability;
this.selectionProbability = new double[individual.selectionProbability.length]; this.selectionProbability = new double[individual.selectionProbability.length];
for (int i = 0; i < this.selectionProbability.length; i++) { for (int i = 0; i < this.selectionProbability.length; i++) {
@@ -70,7 +72,9 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
return (Object) new ESIndividualBinaryData(this); return (Object) new ESIndividualBinaryData(this);
} }
/** This method checks on equality regarding genotypic equality /**
* This method checks on equality regarding genotypic equality
*
* @param individual The individual to compare to. * @param individual The individual to compare to.
* @return boolean if equal true else false. * @return boolean if equal true else false.
*/ */
@@ -104,7 +108,9 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
/************************************************************************************ /************************************************************************************
* InterfaceDataTypeBinary methods * InterfaceDataTypeBinary methods
*/ */
/** This method allows you to request a certain amount of binary data /**
* This method allows you to request a certain amount of binary data
*
* @param length The lenght of the BitSet that is to be optimized * @param length The lenght of the BitSet that is to be optimized
*/ */
@Override @Override
@@ -117,7 +123,9 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
} }
} }
/** This method returns the length of the binary data set /**
* This method returns the length of the binary data set
*
* @return The number of bits stored * @return The number of bits stored
*/ */
@Override @Override
@@ -125,7 +133,9 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
return this.m_Genotype.length; return this.m_Genotype.length;
} }
/** This method allows you to read the binary data /**
* This method allows you to read the binary data
*
* @return BitSet representing the binary data. * @return BitSet representing the binary data.
*/ */
@Override @Override
@@ -152,8 +162,10 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
return this.m_Phenotype; return this.m_Phenotype;
} }
/** This method allows you to read the binary data without /**
* This method allows you to read the binary data without
* an update from the genotype * an update from the genotype
*
* @return BitSet representing the binary data. * @return BitSet representing the binary data.
*/ */
@Override @Override
@@ -161,15 +173,20 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
return this.m_Phenotype; return this.m_Phenotype;
} }
/** This method allows you to set the binary data. /**
* This method allows you to set the binary data.
*
* @param binaryData The new binary data. * @param binaryData The new binary data.
*/ */
@Override @Override
public void SetBinaryPhenotype(BitSet binaryData) { public void SetBinaryPhenotype(BitSet binaryData) {
this.m_Phenotype = binaryData; this.m_Phenotype = binaryData;
} }
/** This method allows you to set the binary data, this can be used for
/**
* This method allows you to set the binary data, this can be used for
* memetic algorithms. * memetic algorithms.
*
* @param binaryData The new binary data. * @param binaryData The new binary data.
*/ */
@Override @Override
@@ -178,16 +195,14 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
for (int i = 0; i < this.m_Genotype.length; i++) { for (int i = 0; i < this.m_Genotype.length; i++) {
if (this.m_UseHardSwitch) { if (this.m_UseHardSwitch) {
if (binaryData.get(i)) { if (binaryData.get(i)) {
this.m_Genotype[i] = RNG.randomDouble(0.55,1.0); this.m_Genotype[i] = RNG.randomDouble(0.55, 1.0);
} } else {
else { this.m_Genotype[i] = RNG.randomDouble(0.0, 0.45);
this.m_Genotype[i] = RNG.randomDouble(0.0,0.45);
} }
} else { } else {
if (binaryData.get(i)) { if (binaryData.get(i)) {
this.m_Genotype[i] = 0.9; this.m_Genotype[i] = 0.9;
} } else {
else {
this.m_Genotype[i] = 0.1; this.m_Genotype[i] = 0.1;
} }
} }
@@ -197,8 +212,10 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
/************************************************************************************ /************************************************************************************
* AbstractEAIndividual methods * AbstractEAIndividual methods
*/ */
/** This method will init the individual with a given value for the /**
* This method will init the individual with a given value for the
* phenotype. * phenotype.
*
* @param obj The initial value for the phenotype * @param obj The initial value for the phenotype
* @param opt The optimization problem that is to be solved. * @param opt The optimization problem that is to be solved.
*/ */
@@ -215,8 +232,10 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
this.crossoverOperator.init(this, opt); this.crossoverOperator.init(this, opt);
} }
/** This method will return a string description of the GAIndividal /**
* This method will return a string description of the GAIndividal
* noteably the Genotype. * noteably the Genotype.
*
* @return A descriptive string * @return A descriptive string
*/ */
@Override @Override
@@ -244,7 +263,9 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
* InterfaceESIndividual methods * InterfaceESIndividual methods
*/ */
/** This method will allow the user to read the ES 'genotype' /**
* This method will allow the user to read the ES 'genotype'
*
* @return BitSet * @return BitSet
*/ */
@Override @Override
@@ -252,7 +273,9 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
return this.m_Genotype; return this.m_Genotype;
} }
/** This method will allow the user to set the current ES 'genotype'. /**
* This method will allow the user to set the current ES 'genotype'.
*
* @param b The new genotype of the Individual * @param b The new genotype of the Individual
*/ */
@Override @Override
@@ -277,7 +300,9 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
// this.m_Range = range; // this.m_Range = range;
// } // }
/** This method will return the range for all double attributes. /**
* This method will return the range for all double attributes.
*
* @return The range array. * @return The range array.
*/ */
@Override @Override
@@ -285,7 +310,8 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
return this.m_Range; return this.m_Range;
} }
/** This method performs a simple one element mutation on the double vector /**
* This method performs a simple one element mutation on the double vector
*/ */
@Override @Override
public void defaultMutate() { public void defaultMutate() {
@@ -294,18 +320,19 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
@Override @Override
public void defaultInit(InterfaceOptimizationProblem prob) { public void defaultInit(InterfaceOptimizationProblem prob) {
if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange)prob).getInitRange()!=null)) { if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange) prob).getInitRange() != null)) {
ESIndividualDoubleData.defaultInit(m_Genotype, (double[][])((InterfaceHasInitRange)prob).getInitRange()); ESIndividualDoubleData.defaultInit(m_Genotype, (double[][]) ((InterfaceHasInitRange) prob).getInitRange());
} } else {
else {
ESIndividualDoubleData.defaultInit(m_Genotype, m_Range); ESIndividualDoubleData.defaultInit(m_Genotype, m_Range);
} }
} }
/********************************************************************************************************************** /**********************************************************************************************************************
* These are for GUI * These are for GUI
*/ */
/** This method allows the CommonJavaObjectEditorPanel to read the /**
* This method allows the CommonJavaObjectEditorPanel to read the
* name to the current object. * name to the current object.
*
* @return The name. * @return The name.
*/ */
@Override @Override
@@ -313,23 +340,29 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
return "ES individual"; return "ES individual";
} }
/** This method returns a global info string /**
* This method returns a global info string
*
* @return description * @return description
*/ */
public static String globalInfo() { public static String globalInfo() {
return "This is an ES individual adopted to optimize binary values."; return "This is an ES individual adopted to optimize binary values.";
} }
/** This method will toggle between genotype interpretation as bit probability and /**
* This method will toggle between genotype interpretation as bit probability and
* fixed switch. * fixed switch.
*
* @param b the Switch. * @param b the Switch.
*/ */
public void setToggleInterpretation(boolean b) { public void setToggleInterpretation(boolean b) {
this.m_UseHardSwitch = b; this.m_UseHardSwitch = b;
} }
public boolean getToggleInterpretation() { public boolean getToggleInterpretation() {
return this.m_UseHardSwitch; return this.m_UseHardSwitch;
} }
public String toggleInterpretationTipText() { public String toggleInterpretationTipText() {
return "Toggle between interpretation as probability or if(>0.5)."; return "Toggle between interpretation as probability or if(>0.5).";
} }

View File

@@ -11,7 +11,8 @@ import eva2.tools.EVAERROR;
import eva2.tools.math.Mathematics; import eva2.tools.math.Mathematics;
import eva2.tools.math.RNG; import eva2.tools.math.RNG;
/** This individual uses a real-valued genotype to code for double values. /**
* This individual uses a real-valued genotype to code for double values.
* Created by IntelliJ IDEA. * Created by IntelliJ IDEA.
* User: streiche * User: streiche
* Date: 24.03.2003 * Date: 24.03.2003
@@ -53,7 +54,7 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
this.age = individual.age; this.age = individual.age;
this.crossoverOperator = individual.crossoverOperator; this.crossoverOperator = individual.crossoverOperator;
this.crossoverProbability = individual.crossoverProbability; this.crossoverProbability = individual.crossoverProbability;
this.mutationOperator = (InterfaceMutation)individual.mutationOperator.clone(); this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone();
this.mutationProbability = individual.mutationProbability; this.mutationProbability = individual.mutationProbability;
this.selectionProbability = new double[individual.selectionProbability.length]; this.selectionProbability = new double[individual.selectionProbability.length];
for (int i = 0; i < this.selectionProbability.length; i++) { for (int i = 0; i < this.selectionProbability.length; i++) {
@@ -71,7 +72,9 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
return (Object) new ESIndividualDoubleData(this); return (Object) new ESIndividualDoubleData(this);
} }
/** This method checks on equality regarding genotypic equality /**
* This method checks on equality regarding genotypic equality
*
* @param individual The individual to compare to. * @param individual The individual to compare to.
* @return boolean if equal true else false. * @return boolean if equal true else false.
*/ */
@@ -111,11 +114,13 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
/************************************************************************************ /************************************************************************************
* InterfaceDataTypeDouble methods * InterfaceDataTypeDouble methods
*/ */
/** This method allows you to request a certain amount of double data /**
* This method allows you to request a certain amount of double data
*
* @param length The lenght of the double[] that is to be optimized * @param length The lenght of the double[] that is to be optimized
*/ */
@Override @Override
public void setDoubleDataLength (int length) { public void setDoubleDataLength(int length) {
double[] newDesPa = new double[length]; double[] newDesPa = new double[length];
double[][] newRange = new double[length][2]; double[][] newRange = new double[length][2];
@@ -128,9 +133,9 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
// if the new length is bigger than the last value fills the extra elements // if the new length is bigger than the last value fills the extra elements
for (int i = this.m_Genotype.length; (i < newDesPa.length); i++) { for (int i = this.m_Genotype.length; (i < newDesPa.length); i++) {
newDesPa[i] = this.m_Genotype[this.m_Genotype.length-1]; newDesPa[i] = this.m_Genotype[this.m_Genotype.length - 1];
newRange[i][0] = this.m_Range[this.m_Genotype.length-1][0]; newRange[i][0] = this.m_Range[this.m_Genotype.length - 1][0];
newRange[i][1] = this.m_Range[this.m_Genotype.length-1][1]; newRange[i][1] = this.m_Range[this.m_Genotype.length - 1][1];
} }
this.m_Genotype = newDesPa; this.m_Genotype = newDesPa;
this.m_Range = newRange; this.m_Range = newRange;
@@ -145,7 +150,9 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
// } // }
} }
/** This method returns the length of the double data set /**
* This method returns the length of the double data set
*
* @return The number of bits stored * @return The number of bits stored
*/ */
@Override @Override
@@ -153,9 +160,11 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
return this.m_Genotype.length; return this.m_Genotype.length;
} }
/** This method will set the range of the double attributes. If range.length /**
* This method will set the range of the double attributes. If range.length
* does not equal doubledata.length only range[i] will be used to set all * does not equal doubledata.length only range[i] will be used to set all
* ranges. * ranges.
*
* @param range The new range for the double data. * @param range The new range for the double data.
*/ */
@Override @Override
@@ -170,7 +179,9 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
} }
} }
/** This method will return the range for all double attributes. /**
* This method will return the range for all double attributes.
*
* @return The range array. * @return The range array.
*/ */
@Override @Override
@@ -178,18 +189,19 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
return this.m_Range; return this.m_Range;
} }
/** This method allows you to read the double data. A new phenotype array is allocated /**
* This method allows you to read the double data. A new phenotype array is allocated
* and the genotype copied. * and the genotype copied.
*
* @return BitSet representing the double data. * @return BitSet representing the double data.
*/ */
@Override @Override
public double[] getDoubleData() { public double[] getDoubleData() {
// since the phenotype is set to null if the genotype is changed, // since the phenotype is set to null if the genotype is changed,
// it should now be save to only perform the copy if the phenotype is null // it should now be save to only perform the copy if the phenotype is null
if (this.m_Phenotype!=null) { if (this.m_Phenotype != null) {
return m_Phenotype; return m_Phenotype;
} } else {
else {
this.m_Phenotype = new double[this.m_Genotype.length]; this.m_Phenotype = new double[this.m_Genotype.length];
System.arraycopy(this.m_Genotype, 0, this.m_Phenotype, 0, this.m_Genotype.length); System.arraycopy(this.m_Genotype, 0, this.m_Phenotype, 0, this.m_Genotype.length);
return this.m_Phenotype; return this.m_Phenotype;
@@ -199,20 +211,22 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
/** /**
* This method allows you to read the double data without * This method allows you to read the double data without
* an update from the genotype. * an update from the genotype.
*
* @return double[] representing the double data. * @return double[] representing the double data.
*/ */
@Override @Override
public double[] getDoubleDataWithoutUpdate() { public double[] getDoubleDataWithoutUpdate() {
if (m_Phenotype==null) { if (m_Phenotype == null) {
return getDoubleData(); return getDoubleData();
} } else {
else {
return this.m_Phenotype; return this.m_Phenotype;
} }
} }
/** This method allows you to set the phenotype double data. To change the genotype, /**
* This method allows you to set the phenotype double data. To change the genotype,
* use SetDoubleDataLamarckian(). * use SetDoubleDataLamarckian().
*
* @param doubleData The new double data. * @param doubleData The new double data.
*/ */
@Override @Override
@@ -220,8 +234,10 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
this.m_Phenotype = doubleData; this.m_Phenotype = doubleData;
} }
/** This method allows you to set the genotype data, this can be used for /**
* This method allows you to set the genotype data, this can be used for
* memetic algorithms. * memetic algorithms.
*
* @param doubleData The new double data. * @param doubleData The new double data.
*/ */
@Override @Override
@@ -235,7 +251,9 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
/************************************************************************************ /************************************************************************************
* AbstractEAIndividual methods * AbstractEAIndividual methods
*/ */
/** This method will allow a default initialisation of the individual /**
* This method will allow a default initialisation of the individual
*
* @param opt The optimization problem that is to be solved. * @param opt The optimization problem that is to be solved.
*/ */
@Override @Override
@@ -247,8 +265,10 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
} }
} }
/** This method will init the individual with a given value for the /**
* This method will init the individual with a given value for the
* phenotype. * phenotype.
*
* @param obj The initial value for the phenotype * @param obj The initial value for the phenotype
* @param opt The optimization problem that is to be solved. * @param opt The optimization problem that is to be solved.
*/ */
@@ -268,8 +288,10 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
this.crossoverOperator.init(this, opt); this.crossoverOperator.init(this, opt);
} }
/** This method will return a string description of the GAIndividal /**
* This method will return a string description of the GAIndividal
* noteably the Genotype. * noteably the Genotype.
*
* @return A descriptive string * @return A descriptive string
*/ */
@Override @Override
@@ -298,7 +320,9 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
/************************************************************************************ /************************************************************************************
* InterfaceESIndividual methods * InterfaceESIndividual methods
*/ */
/** This method will allow the user to read the ES 'genotype' /**
* This method will allow the user to read the ES 'genotype'
*
* @return BitSet * @return BitSet
*/ */
@Override @Override
@@ -306,13 +330,15 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
return this.m_Genotype; return this.m_Genotype;
} }
/** This method will allow the user to set the current ES 'genotype'. /**
* This method will allow the user to set the current ES 'genotype'.
*
* @param b The new genotype of the Individual * @param b The new genotype of the Individual
*/ */
@Override @Override
public void SetDGenotype(double[] b) { public void SetDGenotype(double[] b) {
this.m_Genotype = b; this.m_Genotype = b;
this.m_Phenotype=null; // mark it as invalid this.m_Phenotype = null; // mark it as invalid
for (int i = 0; i < this.m_Genotype.length; i++) { for (int i = 0; i < this.m_Genotype.length; i++) {
if (this.m_Genotype[i] < this.m_Range[i][0]) { if (this.m_Genotype[i] < this.m_Range[i][0]) {
this.m_Genotype[i] = this.m_Range[i][0]; this.m_Genotype[i] = this.m_Range[i][0];
@@ -323,7 +349,9 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
} }
} }
/** This method will allow the user to set the current ES 'genotype'. /**
* This method will allow the user to set the current ES 'genotype'.
*
* @param b The new genotype of the Individual * @param b The new genotype of the Individual
*/ */
public void SetDGenotypeNocheck(double[] b) { public void SetDGenotypeNocheck(double[] b) {
@@ -331,12 +359,13 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
this.m_Genotype = b; this.m_Genotype = b;
} }
/** This method performs a simple one element mutation on the double vector /**
* This method performs a simple one element mutation on the double vector
*/ */
@Override @Override
public void defaultMutate() { public void defaultMutate() {
ESIndividualDoubleData.defaultMutate(this.m_Genotype, this.m_Range); ESIndividualDoubleData.defaultMutate(this.m_Genotype, this.m_Range);
m_Phenotype=null; // mark it as invalid m_Phenotype = null; // mark it as invalid
} }
/** /**
@@ -348,8 +377,8 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
* @param range * @param range
*/ */
public static void defaultMutate(double[] genotype, double[][] range) { public static void defaultMutate(double[] genotype, double[][] range) {
int mutationIndex = RNG.randomInt(0, genotype.length-1); int mutationIndex = RNG.randomInt(0, genotype.length - 1);
genotype[mutationIndex] += ((range[mutationIndex][1] - range[mutationIndex][0])/2)*RNG.gaussianDouble(0.05f); genotype[mutationIndex] += ((range[mutationIndex][1] - range[mutationIndex][0]) / 2) * RNG.gaussianDouble(0.05f);
if (genotype[mutationIndex] < range[mutationIndex][0]) { if (genotype[mutationIndex] < range[mutationIndex][0]) {
genotype[mutationIndex] = range[mutationIndex][0]; genotype[mutationIndex] = range[mutationIndex][0];
} }
@@ -360,10 +389,9 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
@Override @Override
public void defaultInit(InterfaceOptimizationProblem prob) { public void defaultInit(InterfaceOptimizationProblem prob) {
if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange)prob).getInitRange()!=null)) { if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange) prob).getInitRange() != null)) {
ESIndividualDoubleData.defaultInit(m_Genotype, (double[][])((InterfaceHasInitRange)prob).getInitRange()); ESIndividualDoubleData.defaultInit(m_Genotype, (double[][]) ((InterfaceHasInitRange) prob).getInitRange());
} } else {
else {
ESIndividualDoubleData.defaultInit(m_Genotype, m_Range); ESIndividualDoubleData.defaultInit(m_Genotype, m_Range);
} }
m_Phenotype = null; // mark as invalid m_Phenotype = null; // mark as invalid
@@ -385,8 +413,10 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
/********************************************************************************************************************** /**********************************************************************************************************************
* These are for GUI * These are for GUI
*/ */
/** This method allows the CommonJavaObjectEditorPanel to read the /**
* This method allows the CommonJavaObjectEditorPanel to read the
* name to the current object. * name to the current object.
*
* @return The name. * @return The name.
*/ */
@Override @Override
@@ -394,7 +424,9 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
return "ES individual"; return "ES individual";
} }
/** This method returns a global info string /**
* This method returns a global info string
*
* @return description * @return description
*/ */
public static String globalInfo() { public static String globalInfo() {

View File

@@ -7,7 +7,8 @@ import eva2.optimization.problems.InterfaceHasInitRange;
import eva2.optimization.problems.InterfaceOptimizationProblem; import eva2.optimization.problems.InterfaceOptimizationProblem;
import eva2.tools.math.RNG; import eva2.tools.math.RNG;
/** This individual uses a real-valued genotype to code for integer values. /**
* This individual uses a real-valued genotype to code for integer values.
* Created by IntelliJ IDEA. * Created by IntelliJ IDEA.
* User: streiche * User: streiche
* Date: 15.04.2004 * Date: 15.04.2004
@@ -48,7 +49,7 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
this.age = individual.age; this.age = individual.age;
this.crossoverOperator = individual.crossoverOperator; this.crossoverOperator = individual.crossoverOperator;
this.crossoverProbability = individual.crossoverProbability; this.crossoverProbability = individual.crossoverProbability;
this.mutationOperator = (InterfaceMutation)individual.mutationOperator.clone(); this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone();
this.mutationProbability = individual.mutationProbability; this.mutationProbability = individual.mutationProbability;
this.selectionProbability = new double[individual.selectionProbability.length]; this.selectionProbability = new double[individual.selectionProbability.length];
for (int i = 0; i < this.selectionProbability.length; i++) { for (int i = 0; i < this.selectionProbability.length; i++) {
@@ -66,7 +67,9 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
return (Object) new ESIndividualIntegerData(this); return (Object) new ESIndividualIntegerData(this);
} }
/** This method checks on equality regarding genotypic equality /**
* This method checks on equality regarding genotypic equality
*
* @param individual The individual to compare to. * @param individual The individual to compare to.
* @return boolean if equal true else false. * @return boolean if equal true else false.
*/ */
@@ -100,11 +103,13 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
/************************************************************************************ /************************************************************************************
* InterfaceDataTypeInteger methods * InterfaceDataTypeInteger methods
*/ */
/** This method allows you to request a certain amount of int data /**
* This method allows you to request a certain amount of int data
*
* @param length The lenght of the int[] that is to be optimized * @param length The lenght of the int[] that is to be optimized
*/ */
@Override @Override
public void setIntegerDataLength (int length) { public void setIntegerDataLength(int length) {
double[] newDesPa = new double[length]; double[] newDesPa = new double[length];
int[][] newRange = new int[length][2]; int[][] newRange = new int[length][2];
@@ -117,15 +122,17 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
// if the new length is bigger than the last value fills the extra elements // if the new length is bigger than the last value fills the extra elements
for (int i = this.m_Genotype.length; (i < newDesPa.length); i++) { for (int i = this.m_Genotype.length; (i < newDesPa.length); i++) {
newDesPa[i] = this.m_Genotype[this.m_Genotype.length-1]; newDesPa[i] = this.m_Genotype[this.m_Genotype.length - 1];
newRange[i][0] = this.m_Range[this.m_Genotype.length-1][0]; newRange[i][0] = this.m_Range[this.m_Genotype.length - 1][0];
newRange[i][1] = this.m_Range[this.m_Genotype.length-1][1]; newRange[i][1] = this.m_Range[this.m_Genotype.length - 1][1];
} }
this.m_Genotype = newDesPa; this.m_Genotype = newDesPa;
this.m_Range = newRange; this.m_Range = newRange;
} }
/** This method returns the length of the int data set /**
* This method returns the length of the int data set
*
* @return The number of ints stored * @return The number of ints stored
*/ */
@Override @Override
@@ -133,9 +140,11 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
return this.m_Genotype.length; return this.m_Genotype.length;
} }
/** This method will set the range of the int attributes. If range.length /**
* This method will set the range of the int attributes. If range.length
* does not equal intdata.length only range[i] will be used to set all * does not equal intdata.length only range[i] will be used to set all
* ranges. * ranges.
*
* @param range The new range for the int data. * @param range The new range for the int data.
*/ */
@Override @Override
@@ -150,7 +159,9 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
} }
} }
/** This method will return the range for all int attributes. /**
* This method will return the range for all int attributes.
*
* @return The range array. * @return The range array.
*/ */
@Override @Override
@@ -158,7 +169,9 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
return this.m_Range; return this.m_Range;
} }
/** This method allows you to read the int data /**
* This method allows you to read the int data
*
* @return int[] representing the int data. * @return int[] representing the int data.
*/ */
@Override @Override
@@ -176,8 +189,10 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
return this.m_Phenotype; return this.m_Phenotype;
} }
/** This method allows you to read the int data without /**
* This method allows you to read the int data without
* an update from the genotype * an update from the genotype
*
* @return int[] representing the int data. * @return int[] representing the int data.
*/ */
@Override @Override
@@ -185,7 +200,9 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
return this.m_Phenotype; return this.m_Phenotype;
} }
/** This method allows you to set the int data. /**
* This method allows you to set the int data.
*
* @param intData The new int data. * @param intData The new int data.
*/ */
@Override @Override
@@ -193,14 +210,16 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
this.m_Phenotype = intData; this.m_Phenotype = intData;
} }
/** This method allows you to set the int data, this can be used for /**
* This method allows you to set the int data, this can be used for
* memetic algorithms. * memetic algorithms.
*
* @param intData The new int data. * @param intData The new int data.
*/ */
@Override @Override
public void SetIntGenotype(int[] intData) { public void SetIntGenotype(int[] intData) {
for (int i = 0; i < this.m_Genotype.length; i++) { for (int i = 0; i < this.m_Genotype.length; i++) {
m_Genotype[i]=(double)intData[i]; m_Genotype[i] = (double) intData[i];
} }
getIntegerData(); getIntegerData();
} }
@@ -209,8 +228,10 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
* AbstractEAIndividual methods * AbstractEAIndividual methods
*/ */
/** This method will init the individual with a given value for the /**
* This method will init the individual with a given value for the
* phenotype. * phenotype.
*
* @param obj The initial value for the phenotype * @param obj The initial value for the phenotype
* @param opt The optimization problem that is to be solved. * @param opt The optimization problem that is to be solved.
*/ */
@@ -230,8 +251,10 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
this.crossoverOperator.init(this, opt); this.crossoverOperator.init(this, opt);
} }
/** This method will return a string description of the GAIndividal /**
* This method will return a string description of the GAIndividal
* noteably the Genotype. * noteably the Genotype.
*
* @return A descriptive string * @return A descriptive string
*/ */
@Override @Override
@@ -258,7 +281,9 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
/************************************************************************************ /************************************************************************************
* InterfaceESIndividual methods * InterfaceESIndividual methods
*/ */
/** This method will allow the user to read the ES 'genotype' /**
* This method will allow the user to read the ES 'genotype'
*
* @return BitSet * @return BitSet
*/ */
@Override @Override
@@ -266,7 +291,9 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
return this.m_Genotype; return this.m_Genotype;
} }
/** This method will allow the user to set the current ES 'genotype'. /**
* This method will allow the user to set the current ES 'genotype'.
*
* @param b The new genotype of the Individual * @param b The new genotype of the Individual
*/ */
@Override @Override
@@ -282,12 +309,13 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
} }
} }
/** This method performs a simple one element mutation on the double vector /**
* This method performs a simple one element mutation on the double vector
*/ */
@Override @Override
public void defaultMutate() { public void defaultMutate() {
int mutationIndex = RNG.randomInt(0, this.m_Genotype.length-1); int mutationIndex = RNG.randomInt(0, this.m_Genotype.length - 1);
this.m_Genotype[mutationIndex] += ((this.m_Range[mutationIndex][1] - this.m_Range[mutationIndex][0])/2)*RNG.gaussianDouble(0.05f); this.m_Genotype[mutationIndex] += ((this.m_Range[mutationIndex][1] - this.m_Range[mutationIndex][0]) / 2) * RNG.gaussianDouble(0.05f);
if (this.m_Genotype[mutationIndex] < this.m_Range[mutationIndex][0]) { if (this.m_Genotype[mutationIndex] < this.m_Range[mutationIndex][0]) {
this.m_Genotype[mutationIndex] = this.m_Range[mutationIndex][0]; this.m_Genotype[mutationIndex] = this.m_Range[mutationIndex][0];
} }
@@ -296,7 +324,9 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
} }
} }
/** This method will return the range for all double attributes. /**
* This method will return the range for all double attributes.
*
* @return The range array. * @return The range array.
*/ */
@Override @Override
@@ -312,8 +342,8 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
@Override @Override
public void defaultInit(InterfaceOptimizationProblem prob) { public void defaultInit(InterfaceOptimizationProblem prob) {
int[][] range = m_Range; int[][] range = m_Range;
if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange)prob).getInitRange()!=null)) { if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange) prob).getInitRange() != null)) {
range = (int[][])((InterfaceHasInitRange)prob).getInitRange(); range = (int[][]) ((InterfaceHasInitRange) prob).getInitRange();
} }
for (int i = 0; i < this.m_Genotype.length; i++) { for (int i = 0; i < this.m_Genotype.length; i++) {
this.m_Genotype[i] = RNG.randomInt(range[i][0], range[i][1]); this.m_Genotype[i] = RNG.randomInt(range[i][0], range[i][1]);
@@ -322,8 +352,10 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
/********************************************************************************************************************** /**********************************************************************************************************************
* These are for GUI * These are for GUI
*/ */
/** This method allows the CommonJavaObjectEditorPanel to read the /**
* This method allows the CommonJavaObjectEditorPanel to read the
* name to the current object. * name to the current object.
*
* @return The name. * @return The name.
*/ */
@Override @Override
@@ -331,7 +363,9 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
return "ES individual"; return "ES individual";
} }
/** This method returns a global info string /**
* This method returns a global info string
*
* @return description * @return description
*/ */
public static String globalInfo() { public static String globalInfo() {

View File

@@ -40,7 +40,7 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
if (individual.m_Phenotype != null) { if (individual.m_Phenotype != null) {
this.m_Phenotype = new int[individual.m_Phenotype.length][]; this.m_Phenotype = new int[individual.m_Phenotype.length][];
for (int i = 0; i < m_Phenotype.length; i++) { for (int i = 0; i < m_Phenotype.length; i++) {
this.m_Phenotype[i] =new int[ individual.m_Phenotype[i].length]; this.m_Phenotype[i] = new int[individual.m_Phenotype[i].length];
System.arraycopy(individual.m_Phenotype[i], 0, this.m_Phenotype[i], 0, this.m_Phenotype[i].length); System.arraycopy(individual.m_Phenotype[i], 0, this.m_Phenotype[i], 0, this.m_Phenotype[i].length);
} }
} }
@@ -65,7 +65,7 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
this.age = individual.age; this.age = individual.age;
this.crossoverOperator = individual.crossoverOperator; this.crossoverOperator = individual.crossoverOperator;
this.crossoverProbability = individual.crossoverProbability; this.crossoverProbability = individual.crossoverProbability;
this.mutationOperator = (InterfaceMutation)individual.mutationOperator.clone(); this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone();
this.mutationProbability = individual.mutationProbability; this.mutationProbability = individual.mutationProbability;
this.selectionProbability = new double[individual.selectionProbability.length]; this.selectionProbability = new double[individual.selectionProbability.length];
for (int i = 0; i < this.selectionProbability.length; i++) { for (int i = 0; i < this.selectionProbability.length; i++) {
@@ -84,7 +84,9 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
return (Object) new ESIndividualPermutationData(this); return (Object) new ESIndividualPermutationData(this);
} }
/** This method checks on equality regarding genotypic equality /**
* This method checks on equality regarding genotypic equality
*
* @param individual The individual to compare to. * @param individual The individual to compare to.
* @return boolean if equal true else false. * @return boolean if equal true else false.
*/ */
@@ -118,12 +120,13 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
} }
} }
/************************************************************************************ /**
* *********************************************************************************
* InterfaceDataTypePermutation methods * InterfaceDataTypePermutation methods
*/ */
@Override @Override
public void setPermutationDataLength(int[] length){ public void setPermutationDataLength(int[] length) {
this.m_Genotype = new double[length.length][]; this.m_Genotype = new double[length.length][];
this.m_Range = new double[length.length][][]; this.m_Range = new double[length.length][][];
@@ -151,7 +154,7 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
} }
@Override @Override
public void SetPermutationPhenotype(int[][] perm){ public void SetPermutationPhenotype(int[][] perm) {
this.m_Phenotype = perm; this.m_Phenotype = perm;
this.m_Range = new double[perm.length][][]; this.m_Range = new double[perm.length][][];
for (int i = 0; i < perm.length; i++) { for (int i = 0; i < perm.length; i++) {
@@ -165,7 +168,7 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
} }
@Override @Override
public void SetPermutationGenotype(int[][] perm){ public void SetPermutationGenotype(int[][] perm) {
this.SetPermutationPhenotype(perm); this.SetPermutationPhenotype(perm);
this.m_Genotype = new double[perm.length][]; this.m_Genotype = new double[perm.length][];
@@ -185,7 +188,7 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
this.m_Range[p][i][1] = 1; this.m_Range[p][i][1] = 1;
} }
for (int i = 0; i < this.m_Genotype[p].length; i++) { for (int i = 0; i < this.m_Genotype[p].length; i++) {
this.m_Genotype[p][i] = (perm[p][i] - smallest)/(double)biggest; this.m_Genotype[p][i] = (perm[p][i] - smallest) / (double) biggest;
} }
} }
@@ -221,8 +224,10 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
return this.m_Phenotype; return this.m_Phenotype;
} }
/** This method allows you to read the permutation data without /**
* This method allows you to read the permutation data without
* an update from the genotype * an update from the genotype
*
* @return int[] representing the permutation. * @return int[] representing the permutation.
*/ */
@Override @Override
@@ -233,6 +238,7 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
public int[] getFirstindex() { public int[] getFirstindex() {
return firstindex; return firstindex;
} }
@Override @Override
public void setFirstindex(int[] firstindex) { public void setFirstindex(int[] firstindex) {
this.firstindex = firstindex; this.firstindex = firstindex;
@@ -242,8 +248,10 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
* AbstractEAIndividual methods * AbstractEAIndividual methods
*/ */
/** This method will init the individual with a given value for the /**
* This method will init the individual with a given value for the
* phenotype. * phenotype.
*
* @param obj The initial value for the phenotype * @param obj The initial value for the phenotype
* @param opt The optimization problem that is to be solved. * @param opt The optimization problem that is to be solved.
*/ */
@@ -263,8 +271,10 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
this.crossoverOperator.init(this, opt); this.crossoverOperator.init(this, opt);
} }
/** This method will return a string description of the GAIndividal /**
* This method will return a string description of the GAIndividal
* noteably the Genotype. * noteably the Genotype.
*
* @return A descriptive string * @return A descriptive string
*/ */
@Override @Override
@@ -291,7 +301,9 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
/************************************************************************************ /************************************************************************************
* InterfaceESIndividual methods * InterfaceESIndividual methods
*/ */
/** This method will allow the user to read the ES 'genotype' /**
* This method will allow the user to read the ES 'genotype'
*
* @return BitSet * @return BitSet
*/ */
@Override @Override
@@ -330,7 +342,9 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
return matrix; return matrix;
} }
/** This method will allow the user to set the current ES 'genotype'. /**
* This method will allow the user to set the current ES 'genotype'.
*
* @param b The new genotype of the Individual * @param b The new genotype of the Individual
*/ */
@Override @Override
@@ -350,7 +364,8 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
} }
/** This method performs a one element mutation on every permutation coded by a double vector. /**
* This method performs a one element mutation on every permutation coded by a double vector.
*/ */
@Override @Override
public void defaultMutate() { public void defaultMutate() {
@@ -362,8 +377,8 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
@Override @Override
public void defaultInit(InterfaceOptimizationProblem prob) { public void defaultInit(InterfaceOptimizationProblem prob) {
double[][][] range = m_Range; double[][][] range = m_Range;
if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange)prob).getInitRange()!=null)) { if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange) prob).getInitRange() != null)) {
range = (double[][][])((InterfaceHasInitRange)prob).getInitRange(); range = (double[][][]) ((InterfaceHasInitRange) prob).getInitRange();
} }
for (int i = 0; i < this.m_Genotype.length; i++) { for (int i = 0; i < this.m_Genotype.length; i++) {
@@ -371,7 +386,9 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
} }
} }
/** This method will return the range for all double attributes. /**
* This method will return the range for all double attributes.
*
* @return The range array. * @return The range array.
*/ */
@Override @Override
@@ -395,8 +412,10 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
/********************************************************************************************************************** /**********************************************************************************************************************
* These are for GUI * These are for GUI
*/ */
/** This method allows the CommonJavaObjectEditorPanel to read the /**
* This method allows the CommonJavaObjectEditorPanel to read the
* name to the current object. * name to the current object.
*
* @return The name. * @return The name.
*/ */
@Override @Override
@@ -404,7 +423,9 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
return "ES individual"; return "ES individual";
} }
/** This method returns a global info string /**
* This method returns a global info string
*
* @return description * @return description
*/ */
public static String globalInfo() { public static String globalInfo() {

View File

@@ -5,9 +5,11 @@ import eva2.optimization.operator.mutation.InterfaceMutation;
import eva2.optimization.population.Population; import eva2.optimization.population.Population;
import eva2.optimization.problems.InterfaceOptimizationProblem; import eva2.optimization.problems.InterfaceOptimizationProblem;
import eva2.tools.math.RNG; import eva2.tools.math.RNG;
import java.util.BitSet; import java.util.BitSet;
/** This individual combines a binary and a real-valued phenotype. /**
* This individual combines a binary and a real-valued phenotype.
* Created by IntelliJ IDEA. * Created by IntelliJ IDEA.
* User: streiche * User: streiche
* Date: 13.05.2003 * Date: 13.05.2003
@@ -27,14 +29,14 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
} }
public GAESIndividualBinaryDoubleData(GAESIndividualBinaryDoubleData individual) { public GAESIndividualBinaryDoubleData(GAESIndividualBinaryDoubleData individual) {
this.m_Numbers = (InterfaceDataTypeDouble)((AbstractEAIndividual)individual.getNumbers()).clone(); this.m_Numbers = (InterfaceDataTypeDouble) ((AbstractEAIndividual) individual.getNumbers()).clone();
this.m_BitSet = (InterfaceDataTypeBinary)((AbstractEAIndividual)individual.getBitSet()).clone(); this.m_BitSet = (InterfaceDataTypeBinary) ((AbstractEAIndividual) individual.getBitSet()).clone();
// cloning the members of AbstractEAIndividual // cloning the members of AbstractEAIndividual
this.age = individual.age; this.age = individual.age;
this.crossoverOperator = individual.crossoverOperator; this.crossoverOperator = individual.crossoverOperator;
this.crossoverProbability = individual.crossoverProbability; this.crossoverProbability = individual.crossoverProbability;
this.mutationOperator = (InterfaceMutation)individual.mutationOperator.clone(); this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone();
this.mutationProbability = individual.mutationProbability; this.mutationProbability = individual.mutationProbability;
this.selectionProbability = new double[individual.selectionProbability.length]; this.selectionProbability = new double[individual.selectionProbability.length];
for (int i = 0; i < this.selectionProbability.length; i++) { for (int i = 0; i < this.selectionProbability.length; i++) {
@@ -52,18 +54,20 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
return (Object) new GAESIndividualBinaryDoubleData(this); return (Object) new GAESIndividualBinaryDoubleData(this);
} }
/** This method checks on equality regarding genotypic equality /**
* This method checks on equality regarding genotypic equality
*
* @param individual The individual to compare to. * @param individual The individual to compare to.
* @return boolean if equal true else false. * @return boolean if equal true else false.
*/ */
@Override @Override
public boolean equalGenotypes(AbstractEAIndividual individual) { public boolean equalGenotypes(AbstractEAIndividual individual) {
if (individual instanceof GAESIndividualBinaryDoubleData) { if (individual instanceof GAESIndividualBinaryDoubleData) {
GAESIndividualBinaryDoubleData indy = (GAESIndividualBinaryDoubleData)individual; GAESIndividualBinaryDoubleData indy = (GAESIndividualBinaryDoubleData) individual;
if (!((AbstractEAIndividual)this.m_Numbers).equalGenotypes((AbstractEAIndividual)indy.m_Numbers)) { if (!((AbstractEAIndividual) this.m_Numbers).equalGenotypes((AbstractEAIndividual) indy.m_Numbers)) {
return false; return false;
} }
if (!((AbstractEAIndividual)this.m_BitSet).equalGenotypes((AbstractEAIndividual)indy.m_BitSet)) { if (!((AbstractEAIndividual) this.m_BitSet).equalGenotypes((AbstractEAIndividual) indy.m_BitSet)) {
return false; return false;
} }
return true; return true;
@@ -72,63 +76,70 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
} }
} }
/** This method will allow a default initialisation of the individual /**
* This method will allow a default initialisation of the individual
*
* @param opt The optimization problem that is to be solved. * @param opt The optimization problem that is to be solved.
*/ */
@Override @Override
public void init(InterfaceOptimizationProblem opt) { public void init(InterfaceOptimizationProblem opt) {
((AbstractEAIndividual)this.m_Numbers).init(opt); ((AbstractEAIndividual) this.m_Numbers).init(opt);
((AbstractEAIndividual)this.m_BitSet).init(opt); ((AbstractEAIndividual) this.m_BitSet).init(opt);
} }
@Override @Override
public void defaultInit(InterfaceOptimizationProblem prob) { public void defaultInit(InterfaceOptimizationProblem prob) {
((AbstractEAIndividual)this.m_Numbers).defaultInit(prob); ((AbstractEAIndividual) this.m_Numbers).defaultInit(prob);
((AbstractEAIndividual)this.m_BitSet).defaultInit(prob); ((AbstractEAIndividual) this.m_BitSet).defaultInit(prob);
} }
/** This method will init the individual with a given value for the /**
* This method will init the individual with a given value for the
* phenotype. * phenotype.
*
* @param obj The initial value for the phenotype * @param obj The initial value for the phenotype
* @param opt The optimization problem that is to be solved. * @param opt The optimization problem that is to be solved.
*/ */
@Override @Override
public void initByValue(Object obj, InterfaceOptimizationProblem opt) { public void initByValue(Object obj, InterfaceOptimizationProblem opt) {
if (obj instanceof Object[]) { if (obj instanceof Object[]) {
if (((Object[])obj)[0] instanceof double[]) { if (((Object[]) obj)[0] instanceof double[]) {
((AbstractEAIndividual)this.m_Numbers).initByValue(((Object[])obj)[0], opt); ((AbstractEAIndividual) this.m_Numbers).initByValue(((Object[]) obj)[0], opt);
((AbstractEAIndividual)this.m_BitSet).initByValue(((Object[])obj)[1], opt); ((AbstractEAIndividual) this.m_BitSet).initByValue(((Object[]) obj)[1], opt);
} else { } else {
((AbstractEAIndividual)this.m_Numbers).initByValue(((Object[])obj)[1], opt); ((AbstractEAIndividual) this.m_Numbers).initByValue(((Object[]) obj)[1], opt);
((AbstractEAIndividual)this.m_BitSet).initByValue(((Object[])obj)[0], opt); ((AbstractEAIndividual) this.m_BitSet).initByValue(((Object[]) obj)[0], opt);
} }
} else { } else {
((AbstractEAIndividual)this.m_Numbers).init(opt); ((AbstractEAIndividual) this.m_Numbers).init(opt);
((AbstractEAIndividual)this.m_BitSet).init(opt); ((AbstractEAIndividual) this.m_BitSet).init(opt);
System.out.println("Initial value for GAESIndividualDoubleData is not suitable!"); System.out.println("Initial value for GAESIndividualDoubleData is not suitable!");
} }
} }
/** This method will mutate the individual randomly /**
* This method will mutate the individual randomly
*/ */
@Override @Override
public void mutate() { public void mutate() {
if (RNG.flipCoin(this.mutationProbability)) { if (RNG.flipCoin(this.mutationProbability)) {
((AbstractEAIndividual)this.m_Numbers).mutate(); ((AbstractEAIndividual) this.m_Numbers).mutate();
} }
if (RNG.flipCoin(this.mutationProbability)) { if (RNG.flipCoin(this.mutationProbability)) {
((AbstractEAIndividual)this.m_BitSet).mutate(); ((AbstractEAIndividual) this.m_BitSet).mutate();
} }
} }
@Override @Override
public void defaultMutate() { public void defaultMutate() {
((AbstractEAIndividual)this.m_Numbers).defaultMutate(); ((AbstractEAIndividual) this.m_Numbers).defaultMutate();
((AbstractEAIndividual)this.m_BitSet).defaultMutate(); ((AbstractEAIndividual) this.m_BitSet).defaultMutate();
} }
/** This method will mate the Individual with given other individuals /**
* This method will mate the Individual with given other individuals
* of the same type. * of the same type.
*
* @param partners The possible partners * @param partners The possible partners
* @return offsprings * @return offsprings
*/ */
@@ -144,25 +155,25 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
// out += this.getSolutionRepresentationFor() + "\n" + partners.getSolutionRepresentationFor(); // out += this.getSolutionRepresentationFor() + "\n" + partners.getSolutionRepresentationFor();
// System.out.println(out); // System.out.println(out);
numTmp = (AbstractEAIndividual)this.getNumbers(); numTmp = (AbstractEAIndividual) this.getNumbers();
numPop = new Population(); numPop = new Population();
for (int i = 0; i < partners.size(); i++) { for (int i = 0; i < partners.size(); i++) {
numPop.add(((GAESIndividualBinaryDoubleData)partners.get(i)).getNumbers()); numPop.add(((GAESIndividualBinaryDoubleData) partners.get(i)).getNumbers());
} }
resNum = numTmp.mateWith(numPop); resNum = numTmp.mateWith(numPop);
binTmp = (AbstractEAIndividual)this.getBitSet(); binTmp = (AbstractEAIndividual) this.getBitSet();
binPop = new Population(); binPop = new Population();
for (int i = 0; i < partners.size(); i++) { for (int i = 0; i < partners.size(); i++) {
binPop.add(((GAESIndividualBinaryDoubleData)partners.get(i)).getBitSet()); binPop.add(((GAESIndividualBinaryDoubleData) partners.get(i)).getBitSet());
} }
resBin = binTmp.mateWith(binPop); resBin = binTmp.mateWith(binPop);
result = new GAESIndividualBinaryDoubleData[resNum.length]; result = new GAESIndividualBinaryDoubleData[resNum.length];
for (int i = 0; i < result.length; i++) { for (int i = 0; i < result.length; i++) {
result[i] = new GAESIndividualBinaryDoubleData(this); result[i] = new GAESIndividualBinaryDoubleData(this);
((GAESIndividualBinaryDoubleData)result[i]).setNumbers((InterfaceDataTypeDouble)resNum[i]); ((GAESIndividualBinaryDoubleData) result[i]).setNumbers((InterfaceDataTypeDouble) resNum[i]);
((GAESIndividualBinaryDoubleData)result[i]).setBitSet((InterfaceDataTypeBinary)resBin[i]); ((GAESIndividualBinaryDoubleData) result[i]).setBitSet((InterfaceDataTypeBinary) resBin[i]);
} }
// result = ((AbstractEAIndividual)this.m_Numbers).mateWith(partners); // result = ((AbstractEAIndividual)this.m_Numbers).mateWith(partners);
@@ -177,10 +188,10 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
} else { } else {
// simply return a number of perfect clones // simply return a number of perfect clones
result = new AbstractEAIndividual[partners.size() +1]; result = new AbstractEAIndividual[partners.size() + 1];
result[0] = (AbstractEAIndividual)this.clone(); result[0] = (AbstractEAIndividual) this.clone();
for (int i = 0; i < partners.size(); i++) { for (int i = 0; i < partners.size(); i++) {
result[i+1] = (AbstractEAIndividual) ((AbstractEAIndividual)partners.get(i)).clone(); result[i + 1] = (AbstractEAIndividual) ((AbstractEAIndividual) partners.get(i)).clone();
} }
} }
for (int i = 0; i < result.length; i++) { for (int i = 0; i < result.length; i++) {
@@ -189,31 +200,37 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
return result; return result;
} }
/** This method will return a string description of the GAIndividal /**
* This method will return a string description of the GAIndividal
* noteably the Genotype. * noteably the Genotype.
*
* @return A descriptive string * @return A descriptive string
*/ */
@Override @Override
public String getStringRepresentation() { public String getStringRepresentation() {
String result = "This is a hybrid Individual:\n"; String result = "This is a hybrid Individual:\n";
result += "The Numbers Part:\n"+((AbstractEAIndividual)this.m_Numbers).getStringRepresentation(); result += "The Numbers Part:\n" + ((AbstractEAIndividual) this.m_Numbers).getStringRepresentation();
result += "\nThe Binarys Part:\n"+((AbstractEAIndividual)this.m_BitSet).getStringRepresentation(); result += "\nThe Binarys Part:\n" + ((AbstractEAIndividual) this.m_BitSet).getStringRepresentation();
return result; return result;
} }
/********************************************************************************************************************** /**
* *******************************************************************************************************************
* These are for InterfaceDataTypeDouble * These are for InterfaceDataTypeDouble
* <p/>
/** This method allows you to request a certain amount of double data * /** This method allows you to request a certain amount of double data
*
* @param length The lenght of the double[] that is to be optimized * @param length The lenght of the double[] that is to be optimized
*/ */
@Override @Override
public void setDoubleDataLength (int length) { public void setDoubleDataLength(int length) {
this.m_Numbers.setDoubleDataLength(length); this.m_Numbers.setDoubleDataLength(length);
this.m_BitSet.setBinaryDataLength(length); this.m_BitSet.setBinaryDataLength(length);
} }
/** This method returns the length of the double data set /**
* This method returns the length of the double data set
*
* @return The number of bits stored * @return The number of bits stored
*/ */
@Override @Override
@@ -221,9 +238,11 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
return this.m_Numbers.size(); return this.m_Numbers.size();
} }
/** This method will set the range of the double attributes. /**
* This method will set the range of the double attributes.
* Note: range[d][0] gives the lower bound and range[d] gives the upper bound * Note: range[d][0] gives the lower bound and range[d] gives the upper bound
* for dimension d. * for dimension d.
*
* @param range The new range for the double data. * @param range The new range for the double data.
*/ */
@Override @Override
@@ -231,7 +250,9 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
this.m_Numbers.SetDoubleRange(range); this.m_Numbers.SetDoubleRange(range);
} }
/** This method will return the range for all double attributes. /**
* This method will return the range for all double attributes.
*
* @return The range array. * @return The range array.
*/ */
@Override @Override
@@ -239,7 +260,9 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
return this.m_Numbers.getDoubleRange(); return this.m_Numbers.getDoubleRange();
} }
/** This method allows you to read the double data /**
* This method allows you to read the double data
*
* @return BitSet representing the double data. * @return BitSet representing the double data.
*/ */
@Override @Override
@@ -247,8 +270,10 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
return this.m_Numbers.getDoubleData(); return this.m_Numbers.getDoubleData();
} }
/** This method allows you to read the double data without /**
* This method allows you to read the double data without
* an update from the genotype * an update from the genotype
*
* @return double[] representing the double data. * @return double[] representing the double data.
*/ */
@Override @Override
@@ -256,7 +281,9 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
return this.m_Numbers.getDoubleDataWithoutUpdate(); return this.m_Numbers.getDoubleDataWithoutUpdate();
} }
/** This method allows you to set the double data. /**
* This method allows you to set the double data.
*
* @param doubleData The new double data. * @param doubleData The new double data.
* @see InterfaceDataTypeDouble.SetDoubleData() * @see InterfaceDataTypeDouble.SetDoubleData()
*/ */
@@ -265,8 +292,10 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
this.m_Numbers.SetDoublePhenotype(doubleData); this.m_Numbers.SetDoublePhenotype(doubleData);
} }
/** This method allows you to set the double data, this can be used for /**
* This method allows you to set the double data, this can be used for
* memetic algorithms. * memetic algorithms.
*
* @param doubleData The new double data. * @param doubleData The new double data.
* @see InterfaceDataTypeDouble.SetDoubleDataLamarckian() * @see InterfaceDataTypeDouble.SetDoubleDataLamarckian()
*/ */
@@ -275,26 +304,32 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
this.m_Numbers.SetDoubleGenotype(doubleData); this.m_Numbers.SetDoubleGenotype(doubleData);
} }
/********************************************************************************************************************** /**
* *******************************************************************************************************************
* These are for InterfaceDataTypeBinary * These are for InterfaceDataTypeBinary
* <p/>
/** This method allows you to request a certain amount of binary data * /** This method allows you to request a certain amount of binary data
*
* @param length The lenght of the BitSet that is to be optimized * @param length The lenght of the BitSet that is to be optimized
*/ */
@Override @Override
public void setBinaryDataLength (int length) { public void setBinaryDataLength(int length) {
this.m_Numbers.setDoubleDataLength(length); this.m_Numbers.setDoubleDataLength(length);
this.m_BitSet.setBinaryDataLength(length); this.m_BitSet.setBinaryDataLength(length);
} }
/** This method returns the length of the binary data set /**
* This method returns the length of the binary data set
*
* @return The number of bits stored * @return The number of bits stored
*/ */
public int GetBinaryDataLength() { public int GetBinaryDataLength() {
return this.m_BitSet.size(); return this.m_BitSet.size();
} }
/** This method allows you to read the binary data /**
* This method allows you to read the binary data
*
* @return BitSet representing the binary data. * @return BitSet representing the binary data.
*/ */
@Override @Override
@@ -302,8 +337,10 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
return this.m_BitSet.getBinaryData(); return this.m_BitSet.getBinaryData();
} }
/** This method allows you to read the binary data without /**
* This method allows you to read the binary data without
* an update from the genotype * an update from the genotype
*
* @return BitSet representing the binary data. * @return BitSet representing the binary data.
*/ */
@Override @Override
@@ -311,7 +348,9 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
return this.m_BitSet.getBinaryDataWithoutUpdate(); return this.m_BitSet.getBinaryDataWithoutUpdate();
} }
/** This method allows you to set the binary data. /**
* This method allows you to set the binary data.
*
* @param binaryData The new binary data. * @param binaryData The new binary data.
* @see InterfaceDataTypeBinary.SetBinaryData() * @see InterfaceDataTypeBinary.SetBinaryData()
*/ */
@@ -320,8 +359,10 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
this.m_BitSet.SetBinaryPhenotype(binaryData); this.m_BitSet.SetBinaryPhenotype(binaryData);
} }
/** This method allows you to set the binary data, this can be used for /**
* This method allows you to set the binary data, this can be used for
* memetic algorithms. * memetic algorithms.
*
* @param binaryData The new binary data. * @param binaryData The new binary data.
* @see InterfaceBinaryData.SetBinaryDataLamarckian() * @see InterfaceBinaryData.SetBinaryDataLamarckian()
*/ */
@@ -333,8 +374,10 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
/********************************************************************************************************************** /**********************************************************************************************************************
* These are for GUI * These are for GUI
*/ */
/** This method allows the CommonJavaObjectEditorPanel to read the /**
* This method allows the CommonJavaObjectEditorPanel to read the
* name to the current object. * name to the current object.
*
* @return The name. * @return The name.
*/ */
@Override @Override
@@ -342,34 +385,45 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
return "GA/ES individual"; return "GA/ES individual";
} }
/** This method returns a global info string /**
* This method returns a global info string
*
* @return description * @return description
*/ */
public static String globalInfo() { public static String globalInfo() {
return "This is a mixed data type combining a BitSet and a real-valued vector."; return "This is a mixed data type combining a BitSet and a real-valued vector.";
} }
/** This method will allow you to set the inner constants /**
* This method will allow you to set the inner constants
*
* @param Numbers The new representation for the inner constants. * @param Numbers The new representation for the inner constants.
*/ */
public void setNumbers(InterfaceDataTypeDouble Numbers) { public void setNumbers(InterfaceDataTypeDouble Numbers) {
this.m_Numbers = Numbers; this.m_Numbers = Numbers;
} }
public InterfaceDataTypeDouble getNumbers() { public InterfaceDataTypeDouble getNumbers() {
return this.m_Numbers; return this.m_Numbers;
} }
public String numbersTipText() { public String numbersTipText() {
return "Choose the type of inner binary representation to use."; return "Choose the type of inner binary representation to use.";
} }
/** This method will allow you to set the inner constants
/**
* This method will allow you to set the inner constants
*
* @param BitSet The new representation for the inner constants. * @param BitSet The new representation for the inner constants.
*/ */
public void setBitSet(InterfaceDataTypeBinary BitSet) { public void setBitSet(InterfaceDataTypeBinary BitSet) {
this.m_BitSet = BitSet; this.m_BitSet = BitSet;
} }
public InterfaceDataTypeBinary getBitSet() { public InterfaceDataTypeBinary getBitSet() {
return this.m_BitSet; return this.m_BitSet;
} }
public String bitSetTipText() { public String bitSetTipText() {
return "Choose the type of inner real-valued representation to use."; return "Choose the type of inner real-valued representation to use.";
} }

View File

@@ -7,9 +7,11 @@ import eva2.optimization.operator.mutation.InterfaceMutation;
import eva2.optimization.operator.mutation.MutateGANBit; import eva2.optimization.operator.mutation.MutateGANBit;
import eva2.optimization.problems.InterfaceOptimizationProblem; import eva2.optimization.problems.InterfaceOptimizationProblem;
import eva2.tools.math.RNG; import eva2.tools.math.RNG;
import java.util.BitSet; import java.util.BitSet;
/** This individual uses a binary genotype to code for binary values. /**
* This individual uses a binary genotype to code for binary values.
* Created by IntelliJ IDEA. * Created by IntelliJ IDEA.
* User: streiche * User: streiche
* Date: 24.03.2003 * Date: 24.03.2003
@@ -42,14 +44,14 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
} }
this.m_GenotypeLength = individual.m_GenotypeLength; this.m_GenotypeLength = individual.m_GenotypeLength;
if (individual.m_Genotype != null) { if (individual.m_Genotype != null) {
this.m_Genotype = (BitSet)individual.m_Genotype.clone(); this.m_Genotype = (BitSet) individual.m_Genotype.clone();
} }
// cloning the members of AbstractEAIndividual // cloning the members of AbstractEAIndividual
this.age = individual.age; this.age = individual.age;
this.crossoverOperator = (InterfaceCrossover)individual.crossoverOperator.clone(); this.crossoverOperator = (InterfaceCrossover) individual.crossoverOperator.clone();
this.crossoverProbability = individual.crossoverProbability; this.crossoverProbability = individual.crossoverProbability;
this.mutationOperator = (InterfaceMutation)individual.mutationOperator.clone(); this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone();
this.mutationProbability = individual.mutationProbability; this.mutationProbability = individual.mutationProbability;
this.selectionProbability = new double[individual.selectionProbability.length]; this.selectionProbability = new double[individual.selectionProbability.length];
for (int i = 0; i < this.selectionProbability.length; i++) { for (int i = 0; i < this.selectionProbability.length; i++) {
@@ -67,7 +69,9 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
return (Object) new GAIndividualBinaryData(this); return (Object) new GAIndividualBinaryData(this);
} }
/** This method checks on equality regarding genotypic equality /**
* This method checks on equality regarding genotypic equality
*
* @param individual The individual to compare to. * @param individual The individual to compare to.
* @return boolean if equal true else false. * @return boolean if equal true else false.
*/ */
@@ -90,8 +94,10 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
} }
} }
/** This method evaluates the GAIndividual as simple minimize number /**
* This method evaluates the GAIndividual as simple minimize number
* of bits problem. * of bits problem.
*
* @return The number of true bits * @return The number of true bits
*/ */
public double defaultEvaulateAsMiniBits() { public double defaultEvaulateAsMiniBits() {
@@ -107,8 +113,10 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
/************************************************************************************ /************************************************************************************
* AbstractEAIndividual methods * AbstractEAIndividual methods
*/ */
/** This method will init the individual with a given value for the /**
* This method will init the individual with a given value for the
* phenotype. * phenotype.
*
* @param obj The initial value for the phenotype * @param obj The initial value for the phenotype
* @param opt The optimization problem that is to be solved. * @param opt The optimization problem that is to be solved.
*/ */
@@ -125,9 +133,11 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
this.crossoverOperator.init(this, opt); this.crossoverOperator.init(this, opt);
} }
/** This method can be used to read the current fitness of the individual. /**
* This method can be used to read the current fitness of the individual.
* Please note that the fitness can be based on multiple criteria therefore * Please note that the fitness can be based on multiple criteria therefore
* double[] is used instead of a single double. * double[] is used instead of a single double.
*
* @return The complete fitness array * @return The complete fitness array
*/ */
@Override @Override
@@ -156,22 +166,23 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
result += "})\n Value: "; result += "})\n Value: ";
result += "{"; result += "{";
for (int i = 0; i < this.m_GenotypeLength; i++) { for (int i = 0; i < this.m_GenotypeLength; i++) {
if (i%8==0) { if (i % 8 == 0) {
result+="|"; result += "|";
} }
if (this.m_Genotype.get(i)) { if (this.m_Genotype.get(i)) {
result += "1"; result += "1";
} } else {
else {
result += "0"; result += "0";
} }
} }
result += "}"; result += "}";
result += "\n Mutation ("+this.mutationProbability +"):" + this.mutationOperator.getStringRepresentation(); result += "\n Mutation (" + this.mutationProbability + "):" + this.mutationOperator.getStringRepresentation();
return result; return result;
} }
/** This method allows you to read the binary data /**
* This method allows you to read the binary data
*
* @return BitSet representing the binary data. * @return BitSet representing the binary data.
*/ */
@Override @Override
@@ -190,9 +201,11 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
this.m_Genotype = binaryData; this.m_Genotype = binaryData;
} }
/** This method allows the user to read the length of the genotype. /**
* This method allows the user to read the length of the genotype.
* This may be necessary since BitSet.length only returns the index * This may be necessary since BitSet.length only returns the index
* of the last significant bit. * of the last significant bit.
*
* @return The length of the genotype. * @return The length of the genotype.
*/ */
@Override @Override
@@ -205,14 +218,14 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
for (int i = 0; i < this.m_GenotypeLength; i++) { for (int i = 0; i < this.m_GenotypeLength; i++) {
if (RNG.flipCoin(0.5)) { if (RNG.flipCoin(0.5)) {
this.m_Genotype.set(i); this.m_Genotype.set(i);
} } else {
else {
this.m_Genotype.clear(i); this.m_Genotype.clear(i);
} }
} }
} }
/** This method performs a simple one point mutation in the genotype /**
* This method performs a simple one point mutation in the genotype
*/ */
@Override @Override
public void defaultMutate() { public void defaultMutate() {
@@ -220,8 +233,7 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
//if (mutationIndex > 28) System.out.println("Mutate: " + this.getSolutionRepresentationFor()); //if (mutationIndex > 28) System.out.println("Mutate: " + this.getSolutionRepresentationFor());
if (this.m_Genotype.get(mutationIndex)) { if (this.m_Genotype.get(mutationIndex)) {
this.m_Genotype.clear(mutationIndex); this.m_Genotype.clear(mutationIndex);
} } else {
else {
this.m_Genotype.set(mutationIndex); this.m_Genotype.set(mutationIndex);
} }
//if (mutationIndex > 28) System.out.println(this.getSolutionRepresentationFor()); //if (mutationIndex > 28) System.out.println(this.getSolutionRepresentationFor());
@@ -230,7 +242,9 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
/************************************************************************************ /************************************************************************************
* InterfaceDataTypeBinary methods * InterfaceDataTypeBinary methods
*/ */
/** This method allows you to request a certain amount of binary data /**
* This method allows you to request a certain amount of binary data
*
* @param length The lenght of the BitSet that is to be optimized * @param length The lenght of the BitSet that is to be optimized
*/ */
@Override @Override
@@ -238,7 +252,9 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
this.m_GenotypeLength = length; this.m_GenotypeLength = length;
} }
/** This method returns the length of the binary data set /**
* This method returns the length of the binary data set
*
* @return The number of bits stored * @return The number of bits stored
*/ */
@Override @Override
@@ -246,17 +262,21 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
return this.m_GenotypeLength; return this.m_GenotypeLength;
} }
/** This method allows you to read the binary data /**
* This method allows you to read the binary data
*
* @return BitSet representing the binary data. * @return BitSet representing the binary data.
*/ */
@Override @Override
public BitSet getBinaryData() { public BitSet getBinaryData() {
this.m_Phenotype = (BitSet)this.m_Genotype.clone(); this.m_Phenotype = (BitSet) this.m_Genotype.clone();
return this.m_Phenotype; return this.m_Phenotype;
} }
/** This method allows you to read the binary data without /**
* This method allows you to read the binary data without
* an update from the genotype * an update from the genotype
*
* @return BitSet representing the binary data. * @return BitSet representing the binary data.
*/ */
@Override @Override
@@ -264,7 +284,9 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
return this.m_Phenotype; return this.m_Phenotype;
} }
/** This method allows you to set the binary data. /**
* This method allows you to set the binary data.
*
* @param binaryData The new binary data. * @param binaryData The new binary data.
*/ */
@Override @Override
@@ -272,21 +294,25 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
this.m_Phenotype = binaryData; this.m_Phenotype = binaryData;
} }
/** This method allows you to set the binary data, this can be used for /**
* This method allows you to set the binary data, this can be used for
* memetic algorithms. * memetic algorithms.
*
* @param binaryData The new binary data. * @param binaryData The new binary data.
*/ */
@Override @Override
public void SetBinaryGenotype(BitSet binaryData) { public void SetBinaryGenotype(BitSet binaryData) {
this.SetBinaryPhenotype(binaryData); this.SetBinaryPhenotype(binaryData);
this.m_Genotype =(BitSet)binaryData.clone(); this.m_Genotype = (BitSet) binaryData.clone();
} }
/********************************************************************************************************************** /**********************************************************************************************************************
* These are for GUI * These are for GUI
*/ */
/** This method allows the CommonJavaObjectEditorPanel to read the /**
* This method allows the CommonJavaObjectEditorPanel to read the
* name to the current object. * name to the current object.
*
* @return The name. * @return The name.
*/ */
@Override @Override
@@ -294,7 +320,9 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
return "GA binary individual"; return "GA binary individual";
} }
/** This method returns a global info string /**
* This method returns a global info string
*
* @return description * @return description
*/ */
public static String globalInfo() { public static String globalInfo() {

View File

@@ -9,9 +9,11 @@ import eva2.optimization.operator.mutation.InterfaceMutation;
import eva2.optimization.operator.mutation.MutateGAUniform; import eva2.optimization.operator.mutation.MutateGAUniform;
import eva2.optimization.problems.InterfaceOptimizationProblem; import eva2.optimization.problems.InterfaceOptimizationProblem;
import eva2.tools.math.RNG; import eva2.tools.math.RNG;
import java.util.BitSet; import java.util.BitSet;
/** This individual uses a binary genotype to code for double values /**
* This individual uses a binary genotype to code for double values
* using two alternative encodings. * using two alternative encodings.
* Created by IntelliJ IDEA. * Created by IntelliJ IDEA.
* User: streiche * User: streiche
@@ -55,9 +57,9 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
// cloning the members of AbstractEAIndividual // cloning the members of AbstractEAIndividual
this.age = individual.age; this.age = individual.age;
this.crossoverOperator = (InterfaceCrossover)individual.crossoverOperator.clone(); this.crossoverOperator = (InterfaceCrossover) individual.crossoverOperator.clone();
this.crossoverProbability = individual.crossoverProbability; this.crossoverProbability = individual.crossoverProbability;
this.mutationOperator = (InterfaceMutation)individual.mutationOperator.clone(); this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone();
this.mutationProbability = individual.mutationProbability; this.mutationProbability = individual.mutationProbability;
this.selectionProbability = new double[individual.selectionProbability.length]; this.selectionProbability = new double[individual.selectionProbability.length];
for (int i = 0; i < this.selectionProbability.length; i++) { for (int i = 0; i < this.selectionProbability.length; i++) {
@@ -77,7 +79,9 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
return (Object) new GAIndividualDoubleData(this); return (Object) new GAIndividualDoubleData(this);
} }
/** This method checks on equality regarding genotypic equality /**
* This method checks on equality regarding genotypic equality
*
* @param individual The individual to compare to. * @param individual The individual to compare to.
* @return boolean if equal true else false. * @return boolean if equal true else false.
*/ */
@@ -112,11 +116,13 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
/************************************************************************************ /************************************************************************************
* InterfaceDataTypeDouble methods * InterfaceDataTypeDouble methods
*/ */
/** This method allows you to request a certain amount of double data /**
* This method allows you to request a certain amount of double data
*
* @param length The lenght of the double[] that is to be optimized * @param length The lenght of the double[] that is to be optimized
*/ */
@Override @Override
public void setDoubleDataLength (int length) { public void setDoubleDataLength(int length) {
double[] newDesPa = new double[length]; double[] newDesPa = new double[length];
double[][] newRange = new double[length][2]; double[][] newRange = new double[length][2];
@@ -128,8 +134,8 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
// if the new length is bigger than the last value fills the extra elements // if the new length is bigger than the last value fills the extra elements
for (int i = this.m_Range.length; (i < newDesPa.length); i++) { for (int i = this.m_Range.length; (i < newDesPa.length); i++) {
newRange[i][0] = this.m_Range[this.m_Range.length-1][0]; newRange[i][0] = this.m_Range[this.m_Range.length - 1][0];
newRange[i][1] = this.m_Range[this.m_Range.length-1][1]; newRange[i][1] = this.m_Range[this.m_Range.length - 1][1];
} }
this.m_Range = newRange; this.m_Range = newRange;
this.m_GenotypeLength = length * this.m_Precision; this.m_GenotypeLength = length * this.m_Precision;
@@ -143,7 +149,9 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
// } // }
} }
/** This method returns the length of the double data set /**
* This method returns the length of the double data set
*
* @return The number of bits stored * @return The number of bits stored
*/ */
@Override @Override
@@ -151,9 +159,11 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
return this.m_Range.length; return this.m_Range.length;
} }
/** This method will set the range of the double attributes. If range.length /**
* This method will set the range of the double attributes. If range.length
* does not equal doubledata.length only range[i] will be used to set all * does not equal doubledata.length only range[i] will be used to set all
* ranges. * ranges.
*
* @param range The new range for the double data. * @param range The new range for the double data.
*/ */
@Override @Override
@@ -168,7 +178,9 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
} }
} }
/** This method will return the range for all double attributes. /**
* This method will return the range for all double attributes.
*
* @return The range array. * @return The range array.
*/ */
@Override @Override
@@ -176,7 +188,9 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
return this.m_Range; return this.m_Range;
} }
/** This method allows you to read the double data /**
* This method allows you to read the double data
*
* @return BitSet representing the double data. * @return BitSet representing the double data.
*/ */
@Override @Override
@@ -191,8 +205,10 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
return this.m_Phenotype; return this.m_Phenotype;
} }
/** This method allows you to read the double data without /**
* This method allows you to read the double data without
* an update from the genotype * an update from the genotype
*
* @return double[] representing the double data. * @return double[] representing the double data.
*/ */
@Override @Override
@@ -200,8 +216,10 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
return this.m_Phenotype; return this.m_Phenotype;
} }
/** This method allows you to set the phenotype data. To change the genotype data, /**
* This method allows you to set the phenotype data. To change the genotype data,
* use SetDoubleDataLamarckian. * use SetDoubleDataLamarckian.
*
* @param doubleData The new double data. * @param doubleData The new double data.
*/ */
@Override @Override
@@ -209,8 +227,10 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
this.m_Phenotype = doubleData; this.m_Phenotype = doubleData;
} }
/** This method allows you to set the double data, this can be used for /**
* This method allows you to set the double data, this can be used for
* memetic algorithms. * memetic algorithms.
*
* @param doubleData The new double data. * @param doubleData The new double data.
*/ */
@Override @Override
@@ -228,8 +248,10 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
* AbstractEAIndividual methods * AbstractEAIndividual methods
*/ */
/** This method will init the individual with a given value for the /**
* This method will init the individual with a given value for the
* phenotype. * phenotype.
*
* @param obj The initial value for the phenotype * @param obj The initial value for the phenotype
* @param opt The optimization problem that is to be solved. * @param opt The optimization problem that is to be solved.
*/ */
@@ -249,8 +271,10 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
this.crossoverOperator.init(this, opt); this.crossoverOperator.init(this, opt);
} }
/** This method will return a string description of the GAIndividal /**
* This method will return a string description of the GAIndividal
* noteably the Genotype. * noteably the Genotype.
*
* @return A descriptive string * @return A descriptive string
*/ */
@Override @Override
@@ -276,8 +300,7 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
for (int i = 0; i < this.m_GenotypeLength; i++) { for (int i = 0; i < this.m_GenotypeLength; i++) {
if (this.m_Genotype.get(i)) { if (this.m_Genotype.get(i)) {
result += "1"; result += "1";
} } else {
else {
result += "0"; result += "0";
} }
} }
@@ -289,7 +312,9 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
* InterfaceGAIndividual methods * InterfaceGAIndividual methods
*/ */
/** This method allows you to read the binary data /**
* This method allows you to read the binary data
*
* @return BitSet representing the binary data. * @return BitSet representing the binary data.
*/ */
@Override @Override
@@ -297,8 +322,10 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
return this.m_Genotype; return this.m_Genotype;
} }
/** This method allows you to set the binary data, this can be used for /**
* This method allows you to set the binary data, this can be used for
* memetic algorithms. * memetic algorithms.
*
* @param binaryData The new binary data. * @param binaryData The new binary data.
*/ */
@Override @Override
@@ -306,9 +333,11 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
this.m_Genotype = binaryData; this.m_Genotype = binaryData;
} }
/** This method allows the user to read the length of the genotype. /**
* This method allows the user to read the length of the genotype.
* This may be necessary since BitSet.lenght only returns the index * This may be necessary since BitSet.lenght only returns the index
* of the last significat bit. * of the last significat bit.
*
* @return The length of the genotype. * @return The length of the genotype.
*/ */
@Override @Override
@@ -321,30 +350,31 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
for (int i = 0; i < this.m_GenotypeLength; i++) { for (int i = 0; i < this.m_GenotypeLength; i++) {
if (RNG.flipCoin(0.5)) { if (RNG.flipCoin(0.5)) {
this.m_Genotype.set(i); this.m_Genotype.set(i);
} } else {
else {
this.m_Genotype.clear(i); this.m_Genotype.clear(i);
} }
} }
} }
/** This method performs a simple one point mutation in the genotype /**
* This method performs a simple one point mutation in the genotype
*/ */
@Override @Override
public void defaultMutate() { public void defaultMutate() {
int mutationIndex = RNG.randomInt(0, this.m_GenotypeLength); int mutationIndex = RNG.randomInt(0, this.m_GenotypeLength);
if (this.m_Genotype.get(mutationIndex)) { if (this.m_Genotype.get(mutationIndex)) {
this.m_Genotype.clear(mutationIndex); this.m_Genotype.clear(mutationIndex);
} } else {
else {
this.m_Genotype.set(mutationIndex); this.m_Genotype.set(mutationIndex);
} }
} }
/********************************************************************************************************************** /**********************************************************************************************************************
* These are for GUI * These are for GUI
*/ */
/** This method allows the CommonJavaObjectEditorPanel to read the /**
* This method allows the CommonJavaObjectEditorPanel to read the
* name to the current object. * name to the current object.
*
* @return The name. * @return The name.
*/ */
@Override @Override
@@ -352,37 +382,47 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
return "GA individual"; return "GA individual";
} }
/** This method returns a global info string /**
* This method returns a global info string
*
* @return description * @return description
*/ */
public static String globalInfo() { public static String globalInfo() {
return "This is a GA individual suited to optimize double values."; return "This is a GA individual suited to optimize double values.";
} }
/** This method allows you to set the Coding that is to be used, currently either standard binary /**
* This method allows you to set the Coding that is to be used, currently either standard binary
* coding or Gray coding. * coding or Gray coding.
*
* @param coding The used genotype coding method * @param coding The used genotype coding method
*/ */
public void setGACoding(InterfaceGADoubleCoding coding) { public void setGACoding(InterfaceGADoubleCoding coding) {
this.m_DoubleCoding = coding; this.m_DoubleCoding = coding;
} }
public InterfaceGADoubleCoding getGACoding() { public InterfaceGADoubleCoding getGACoding() {
return this.m_DoubleCoding; return this.m_DoubleCoding;
} }
public String gADoubleCodingTipText() { public String gADoubleCodingTipText() {
return "Choose the coding to use."; return "Choose the coding to use.";
} }
/** This method allows you to set the number of mulitruns that are to be performed, /**
* This method allows you to set the number of mulitruns that are to be performed,
* necessary for stochastic optimizers to ensure reliable results. * necessary for stochastic optimizers to ensure reliable results.
*
* @param precision The number of multiruns that are to be performed * @param precision The number of multiruns that are to be performed
*/ */
public void setPrecision(int precision) { public void setPrecision(int precision) {
this.m_Precision = precision; this.m_Precision = precision;
} }
public int getPrecision() { public int getPrecision() {
return this.m_Precision; return this.m_Precision;
} }
public String precisionTipText() { public String precisionTipText() {
return "Gives the number of bits to be used to code a double."; return "Gives the number of bits to be used to code a double.";
} }

View File

@@ -8,9 +8,11 @@ import eva2.optimization.operator.mutation.InterfaceMutation;
import eva2.optimization.operator.mutation.MutateGANBit; import eva2.optimization.operator.mutation.MutateGANBit;
import eva2.optimization.problems.InterfaceOptimizationProblem; import eva2.optimization.problems.InterfaceOptimizationProblem;
import eva2.tools.math.RNG; import eva2.tools.math.RNG;
import java.util.BitSet; import java.util.BitSet;
/** This individual uses a binary genotype to code for binary values using /**
* This individual uses a binary genotype to code for binary values using
* two alternative encodings. * two alternative encodings.
* Created by IntelliJ IDEA. * Created by IntelliJ IDEA.
* User: streiche * User: streiche
@@ -57,7 +59,7 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
this.age = individual.age; this.age = individual.age;
this.crossoverOperator = individual.crossoverOperator; this.crossoverOperator = individual.crossoverOperator;
this.crossoverProbability = individual.crossoverProbability; this.crossoverProbability = individual.crossoverProbability;
this.mutationOperator = (InterfaceMutation)individual.mutationOperator.clone(); this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone();
this.mutationProbability = individual.mutationProbability; this.mutationProbability = individual.mutationProbability;
this.selectionProbability = new double[individual.selectionProbability.length]; this.selectionProbability = new double[individual.selectionProbability.length];
for (int i = 0; i < this.selectionProbability.length; i++) { for (int i = 0; i < this.selectionProbability.length; i++) {
@@ -77,7 +79,9 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
} }
/** This method checks on equality regarding genotypic equality /**
* This method checks on equality regarding genotypic equality
*
* @param individual The individual to compare to. * @param individual The individual to compare to.
* @return boolean if equal true else false. * @return boolean if equal true else false.
*/ */
@@ -112,11 +116,13 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
/************************************************************************************ /************************************************************************************
* InterfaceDataTypeInteger methods * InterfaceDataTypeInteger methods
*/ */
/** This method allows you to request a certain amount of double data /**
* This method allows you to request a certain amount of double data
*
* @param length The lenght of the double[] that is to be optimized * @param length The lenght of the double[] that is to be optimized
*/ */
@Override @Override
public void setIntegerDataLength (int length) { public void setIntegerDataLength(int length) {
int[] newDesPa = new int[length]; int[] newDesPa = new int[length];
int[][] newRange = new int[length][2]; int[][] newRange = new int[length][2];
@@ -128,8 +134,8 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
// if the new length is bigger than the last value fills the extra elements // if the new length is bigger than the last value fills the extra elements
for (int i = this.m_Range.length; (i < newDesPa.length); i++) { for (int i = this.m_Range.length; (i < newDesPa.length); i++) {
newRange[i][0] = this.m_Range[this.m_Range.length-1][0]; newRange[i][0] = this.m_Range[this.m_Range.length - 1][0];
newRange[i][1] = this.m_Range[this.m_Range.length-1][1]; newRange[i][1] = this.m_Range[this.m_Range.length - 1][1];
} }
this.m_Range = newRange; this.m_Range = newRange;
this.m_CodingLenghts = new int[this.m_Range.length]; this.m_CodingLenghts = new int[this.m_Range.length];
@@ -138,7 +144,9 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
} }
} }
/** This method returns the length of the double data set /**
* This method returns the length of the double data set
*
* @return The number of bits stored * @return The number of bits stored
*/ */
@Override @Override
@@ -146,9 +154,11 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
return this.m_Range.length; return this.m_Range.length;
} }
/** This method will set the range of the integer attributes. If range.length /**
* This method will set the range of the integer attributes. If range.length
* does not equal doubledata.length only range[i] will be used to set all * does not equal doubledata.length only range[i] will be used to set all
* ranges. * ranges.
*
* @param range The new range for the double data. * @param range The new range for the double data.
*/ */
@Override @Override
@@ -171,7 +181,7 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
* @param upper * @param upper
*/ */
public void SetIntRange(int lower, int upper) { public void SetIntRange(int lower, int upper) {
for (int i=0; i<m_Range.length; i++) { for (int i = 0; i < m_Range.length; i++) {
SetIntRange(i, lower, upper); SetIntRange(i, lower, upper);
m_CodingLenghts[i] = m_IntegerCoding.calculateNecessaryBits(m_Range[i]); m_CodingLenghts[i] = m_IntegerCoding.calculateNecessaryBits(m_Range[i]);
} }
@@ -190,7 +200,9 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
m_CodingLenghts[index] = m_IntegerCoding.calculateNecessaryBits(m_Range[index]); m_CodingLenghts[index] = m_IntegerCoding.calculateNecessaryBits(m_Range[index]);
} }
/** This method will return the range for all double attributes. /**
* This method will return the range for all double attributes.
*
* @return The range array. * @return The range array.
*/ */
@Override @Override
@@ -198,7 +210,9 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
return this.m_Range; return this.m_Range;
} }
/** This method allows you to read the double data /**
* This method allows you to read the double data
*
* @return BitSet representing the double data. * @return BitSet representing the double data.
*/ */
@Override @Override
@@ -215,8 +229,10 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
return this.m_Phenotype; return this.m_Phenotype;
} }
/** This method allows you to read the int data without /**
* This method allows you to read the int data without
* an update from the genotype * an update from the genotype
*
* @return int[] representing the int data. * @return int[] representing the int data.
*/ */
@Override @Override
@@ -224,7 +240,9 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
return this.m_Phenotype; return this.m_Phenotype;
} }
/** This method allows you to set the double data. /**
* This method allows you to set the double data.
*
* @param doubleData The new double data. * @param doubleData The new double data.
*/ */
@Override @Override
@@ -232,8 +250,10 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
this.m_Phenotype = doubleData; this.m_Phenotype = doubleData;
} }
/** This method allows you to set the double data, this can be used for /**
* This method allows you to set the double data, this can be used for
* memetic algorithms. * memetic algorithms.
*
* @param doubleData The new double data. * @param doubleData The new double data.
*/ */
@Override @Override
@@ -254,8 +274,10 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
/************************************************************************************ /************************************************************************************
* AbstractEAIndividual methods * AbstractEAIndividual methods
*/ */
/** This method will init the individual with a given value for the /**
* This method will init the individual with a given value for the
* phenotype. * phenotype.
*
* @param obj The initial value for the phenotype * @param obj The initial value for the phenotype
* @param opt The optimization problem that is to be solved. * @param opt The optimization problem that is to be solved.
*/ */
@@ -275,8 +297,10 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
this.crossoverOperator.init(this, opt); this.crossoverOperator.init(this, opt);
} }
/** This method will return a string description of the GAIndividal /**
* This method will return a string description of the GAIndividal
* noteably the Genotype. * noteably the Genotype.
*
* @return A descriptive string * @return A descriptive string
*/ */
@Override @Override
@@ -300,7 +324,7 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
result += "]\n"; result += "]\n";
result += "CodingRange: ["; result += "CodingRange: [";
for (int i = 0; i < this.m_Range.length; i++) { for (int i = 0; i < this.m_Range.length; i++) {
result += "("+this.m_Range[i][0]+"; "+this.m_Range[i][1]+"); "; result += "(" + this.m_Range[i][0] + "; " + this.m_Range[i][1] + "); ";
} }
result += "]\n"; result += "]\n";
result += "CodingLength: ["; result += "CodingLength: [";
@@ -316,8 +340,7 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
for (int i = 0; i < overallLength; i++) { for (int i = 0; i < overallLength; i++) {
if (this.m_Genotype.get(i)) { if (this.m_Genotype.get(i)) {
result += "1"; result += "1";
} } else {
else {
result += "0"; result += "0";
} }
} }
@@ -329,7 +352,9 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
* InterfaceGAIndividual methods * InterfaceGAIndividual methods
*/ */
/** This method allows you to read the binary data /**
* This method allows you to read the binary data
*
* @return BitSet representing the binary data. * @return BitSet representing the binary data.
*/ */
@Override @Override
@@ -337,8 +362,10 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
return this.m_Genotype; return this.m_Genotype;
} }
/** This method allows you to set the binary data, this can be used for /**
* This method allows you to set the binary data, this can be used for
* memetic algorithms. * memetic algorithms.
*
* @param binaryData The new binary data. * @param binaryData The new binary data.
*/ */
@Override @Override
@@ -346,9 +373,11 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
this.m_Genotype = binaryData; this.m_Genotype = binaryData;
} }
/** This method allows the user to read the length of the genotype. /**
* This method allows the user to read the length of the genotype.
* This may be necessary since BitSet.lenght only returns the index * This may be necessary since BitSet.lenght only returns the index
* of the last significat bit. * of the last significat bit.
*
* @return The length of the genotype. * @return The length of the genotype.
*/ */
@Override @Override
@@ -369,14 +398,14 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
for (int i = 0; i < overallLength; i++) { for (int i = 0; i < overallLength; i++) {
if (RNG.flipCoin(0.5)) { if (RNG.flipCoin(0.5)) {
this.m_Genotype.set(i); this.m_Genotype.set(i);
} } else {
else {
this.m_Genotype.clear(i); this.m_Genotype.clear(i);
} }
} }
} }
/** This method performs a simple one point mutation in the genotype /**
* This method performs a simple one point mutation in the genotype
*/ */
@Override @Override
public void defaultMutate() { public void defaultMutate() {
@@ -387,8 +416,7 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
int mutationIndex = RNG.randomInt(0, overallLength); int mutationIndex = RNG.randomInt(0, overallLength);
if (this.m_Genotype.get(mutationIndex)) { if (this.m_Genotype.get(mutationIndex)) {
this.m_Genotype.clear(mutationIndex); this.m_Genotype.clear(mutationIndex);
} } else {
else {
this.m_Genotype.set(mutationIndex); this.m_Genotype.set(mutationIndex);
} }
} }
@@ -400,39 +428,41 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
int[][] range = new int[dimension][2]; int[][] range = new int[dimension][2];
for (int i = 0; i < dimension; i++) { for (int i = 0; i < dimension; i++) {
range[i][0] = 0; range[i][0] = 0;
range[i][1] = i+1; range[i][1] = i + 1;
} }
indy.setIntegerDataLength(dimension); indy.setIntegerDataLength(dimension);
indy.SetIntRange(range); indy.SetIntRange(range);
indy.defaultInit(null); indy.defaultInit(null);
System.out.println(""+indy.getStringRepresentation()); System.out.println("" + indy.getStringRepresentation());
System.out.println("System.exit(0)"); System.out.println("System.exit(0)");
int[] data = indy.getIntegerData(); int[] data = indy.getIntegerData();
String tmp = "Before {"; String tmp = "Before {";
for (int i = 0; i < data.length; i++) { for (int i = 0; i < data.length; i++) {
tmp += data[i] +"; "; tmp += data[i] + "; ";
} }
System.out.println(tmp+"}"); System.out.println(tmp + "}");
tmp = "Setting {"; tmp = "Setting {";
for (int i = 0; i < data.length; i++) { for (int i = 0; i < data.length; i++) {
data[i] = RNG.randomInt(range[i][0], range[i][1]); data[i] = RNG.randomInt(range[i][0], range[i][1]);
tmp += data[i] + "; "; tmp += data[i] + "; ";
} }
System.out.println(tmp+"}"); System.out.println(tmp + "}");
indy.SetIntGenotype(data); indy.SetIntGenotype(data);
System.out.println(""+indy.getStringRepresentation()); System.out.println("" + indy.getStringRepresentation());
data = indy.getIntegerData(); data = indy.getIntegerData();
tmp = "After {"; tmp = "After {";
for (int i = 0; i < data.length; i++) { for (int i = 0; i < data.length; i++) {
tmp += data[i] +"; "; tmp += data[i] + "; ";
} }
System.out.println(tmp+"}"); System.out.println(tmp + "}");
} }
/********************************************************************************************************************** /**********************************************************************************************************************
* These are for GUI * These are for GUI
*/ */
/** This method allows the CommonJavaObjectEditorPanel to read the /**
* This method allows the CommonJavaObjectEditorPanel to read the
* name to the current object. * name to the current object.
*
* @return The name. * @return The name.
*/ */
@Override @Override
@@ -440,23 +470,29 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
return "GA individual"; return "GA individual";
} }
/** This method returns a global info string /**
* This method returns a global info string
*
* @return description * @return description
*/ */
public static String globalInfo() { public static String globalInfo() {
return "This is a GA individual suited to optimize int values."; return "This is a GA individual suited to optimize int values.";
} }
/** This method allows you to set the Coding that is to be used, currently either standard binary /**
* This method allows you to set the Coding that is to be used, currently either standard binary
* coding or Gray coding. * coding or Gray coding.
*
* @param coding The used genotype coding method * @param coding The used genotype coding method
*/ */
public void setGACoding(InterfaceGAIntegerCoding coding) { public void setGACoding(InterfaceGAIntegerCoding coding) {
this.m_IntegerCoding = coding; this.m_IntegerCoding = coding;
} }
public InterfaceGAIntegerCoding getGACoding() { public InterfaceGAIntegerCoding getGACoding() {
return this.m_IntegerCoding; return this.m_IntegerCoding;
} }
public String gAIntegerCodingTipText() { public String gAIntegerCodingTipText() {
return "Choose the coding to use."; return "Choose the coding to use.";
} }

Some files were not shown because too many files have changed in this diff Show More