Reformat all Code.
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
package eva2.gui;
|
||||
|
||||
import eva2.tools.BasicResourceLoader;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
@@ -13,7 +14,6 @@ import javax.swing.event.HyperlinkEvent;
|
||||
import javax.swing.event.HyperlinkListener;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author becker
|
||||
*/
|
||||
public class AboutDialog extends JDialog {
|
||||
@@ -50,9 +50,9 @@ public class AboutDialog extends JDialog {
|
||||
add(imageLabel, gbConstraints);
|
||||
|
||||
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>For more information, please visit the <a href=\"http://www.cogsys.cs.uni-tuebingen.de/software/JavaEvA/\">EvA2 Homepage</a>.</p>"
|
||||
+"</body></html>";
|
||||
+ "<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>"
|
||||
+ "</body></html>";
|
||||
|
||||
infoEditorPane = new JEditorPane("text/html", infoMessage);
|
||||
infoEditorPane.setEditable(false);
|
||||
|
@@ -6,6 +6,7 @@ import eva2.tools.Pair;
|
||||
import eva2.tools.SelectedTag;
|
||||
import eva2.tools.StringTools;
|
||||
import eva2.tools.Tag;
|
||||
|
||||
import java.beans.BeanInfo;
|
||||
import java.beans.IntrospectionException;
|
||||
import java.beans.Introspector;
|
||||
@@ -23,7 +24,6 @@ import java.util.logging.Logger;
|
||||
* generic display.
|
||||
*
|
||||
* @author mkron, Holger Ulmer, Felix Streichert, Hannes Planatscher
|
||||
*
|
||||
*/
|
||||
public class BeanInspector {
|
||||
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.
|
||||
*
|
||||
* @see #toString(Object, char, boolean, String)
|
||||
* @param obj
|
||||
* @return
|
||||
* @see #toString(Object, char, boolean, String)
|
||||
*/
|
||||
public static String toString(Object obj) {
|
||||
return toString(obj, ';', false, "", 1, false);
|
||||
@@ -574,7 +574,6 @@ public class BeanInspector {
|
||||
/**
|
||||
* For a Java primitive wrapper class return the corresponding primitive
|
||||
* class.
|
||||
*
|
||||
*/
|
||||
public static Class getUnboxedType(Class cls) {
|
||||
if (cls == Double.class) {
|
||||
|
@@ -9,10 +9,12 @@ package eva2.gui;
|
||||
* $Date: 2007-11-27 14:37:05 +0100 (Tue, 27 Nov 2007) $
|
||||
* $Author: mkron $
|
||||
*/
|
||||
|
||||
import eva2.optimization.OptimizationStateListener;
|
||||
import eva2.optimization.modules.ModuleAdapter;
|
||||
import eva2.optimization.stat.OptimizationJob;
|
||||
import eva2.tools.ToolBoxGui;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.Serializable;
|
||||
|
@@ -7,6 +7,7 @@ package eva2.gui;
|
||||
|
||||
import eva2.optimization.go.InterfaceNotifyOnInformers;
|
||||
import eva2.optimization.problems.InterfaceAdditionalPopulationInformer;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.Serializable;
|
||||
@@ -86,8 +87,8 @@ public class EvATabbedFrameMaker implements Serializable, PanelMaker, InterfaceN
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @return The toolbar with control buttons
|
||||
* @deprecated
|
||||
*/
|
||||
public JExtToolBar getToolBar() {
|
||||
return extToolBar;
|
||||
@@ -222,7 +223,7 @@ class ClosableTabComponent extends JPanel {
|
||||
final int tabPosition = i;
|
||||
|
||||
pane.remove(i);
|
||||
if(pane.getTabCount() == 0) {
|
||||
if (pane.getTabCount() == 0) {
|
||||
pane.setVisible(false);
|
||||
}
|
||||
/* Create a button to be shown in the ToolBar */
|
||||
@@ -240,15 +241,15 @@ class ClosableTabComponent extends JPanel {
|
||||
pane.setTabComponentAt(tabPosition, ClosableTabComponent.this);
|
||||
pane.setVisible(true);
|
||||
/* Remove the Button */
|
||||
toolBar.remove((Component)e.getSource());
|
||||
toolBar.remove((Component) e.getSource());
|
||||
/* If the Button was the last one, hide ToolBar again */
|
||||
if(toolBar.getComponentCount() == 0) {
|
||||
if (toolBar.getComponentCount() == 0) {
|
||||
toolBar.setVisible(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
/* Add it to the ToolBar */
|
||||
if(!toolBar.isVisible()) {
|
||||
if (!toolBar.isVisible()) {
|
||||
toolBar.setVisible(true);
|
||||
}
|
||||
toolBar.add(tabButton);
|
||||
|
@@ -9,16 +9,15 @@ import javax.swing.tree.DefaultMutableTreeNode;
|
||||
* The tree is constructed using the reflection functionality of PropertySheetPanel
|
||||
* which is also used to generate the nested panels for parameter configuration.
|
||||
*
|
||||
* @author mkron
|
||||
* @see PropertySheetPanel
|
||||
* @see GOParameters
|
||||
* @author mkron
|
||||
*
|
||||
*/
|
||||
public class EvATreeNode extends DefaultMutableTreeNode {
|
||||
private String[] childrenNames = null;
|
||||
private Object[] childrenValues = null;
|
||||
private String myName="EvATreeNode";
|
||||
private boolean doListPrimitives=false;
|
||||
private String myName = "EvATreeNode";
|
||||
private boolean doListPrimitives = false;
|
||||
|
||||
/**
|
||||
* A default constructor setting the name and target object of
|
||||
@@ -54,7 +53,7 @@ public class EvATreeNode extends DefaultMutableTreeNode {
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
myName=name;
|
||||
myName = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@@ -65,8 +64,8 @@ public class EvATreeNode extends DefaultMutableTreeNode {
|
||||
* Actually create child nodes.
|
||||
*/
|
||||
private void initChildren() {
|
||||
for (int i=0; i<childrenValues.length; i++) {
|
||||
if (childrenValues[i]!=null) {
|
||||
for (int i = 0; i < childrenValues.length; i++) {
|
||||
if (childrenValues[i] != null) {
|
||||
if (doListPrimitives || !(BeanInspector.isJavaPrimitive(childrenValues[i].getClass()))) {
|
||||
super.add(new EvATreeNode(childrenNames[i], childrenValues[i]));
|
||||
}
|
||||
@@ -76,16 +75,15 @@ public class EvATreeNode extends DefaultMutableTreeNode {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String extendedInfo=null;
|
||||
String extendedInfo = null;
|
||||
try {
|
||||
extendedInfo=(String)BeanInspector.callIfAvailable(this.getUserObject(), "getName", new Object[]{});
|
||||
extendedInfo = (String) BeanInspector.callIfAvailable(this.getUserObject(), "getName", new Object[]{});
|
||||
} catch (Exception e) {
|
||||
extendedInfo=null;
|
||||
extendedInfo = null;
|
||||
}
|
||||
if (extendedInfo != null) {
|
||||
return myName + " - "+ extendedInfo;
|
||||
}
|
||||
else {
|
||||
return myName + " - " + extendedInfo;
|
||||
} else {
|
||||
return myName;
|
||||
}
|
||||
}
|
||||
|
@@ -15,11 +15,11 @@ import javax.swing.tree.TreePath;
|
||||
* to react to selection changes in the tree view (and update the parameter panel),
|
||||
* and the property change listener to
|
||||
* react to changes in the parameters (and update the tree).
|
||||
* @author mkron
|
||||
*
|
||||
* @author mkron
|
||||
*/
|
||||
public class EvATreeSelectionListener implements TreeSelectionListener, PropertyChangeListener {
|
||||
private PropertyEditor goe=null;
|
||||
private PropertyEditor goe = null;
|
||||
private EvATreeNode root = null;
|
||||
private JTree jtree = null;
|
||||
public static final boolean TRACE = true;
|
||||
@@ -37,10 +37,10 @@ public class EvATreeSelectionListener implements TreeSelectionListener, Property
|
||||
root = rootNode;
|
||||
jtree = jt;
|
||||
|
||||
if (jtree!=null) {
|
||||
if (jtree != null) {
|
||||
jtree.addTreeSelectionListener(this);
|
||||
} // listen to tree selection changes
|
||||
if (goEditor!=null) {
|
||||
if (goEditor != null) {
|
||||
goEditor.addPropertyChangeListener(this);
|
||||
} // listen to changes to the parameters
|
||||
}
|
||||
@@ -52,15 +52,16 @@ public class EvATreeSelectionListener implements TreeSelectionListener, Property
|
||||
}
|
||||
TreePath tp = e.getPath();
|
||||
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));
|
||||
} }
|
||||
EvATreeNode leafNode = (EvATreeNode)tp.getLastPathComponent();
|
||||
}
|
||||
}
|
||||
EvATreeNode leafNode = (EvATreeNode) tp.getLastPathComponent();
|
||||
// goe.setValue(leafNode.getUserObject());
|
||||
Component editComp = goe.getCustomEditor();
|
||||
if (editComp instanceof GOEPanel) {
|
||||
// update the object in the main GOEPanel
|
||||
((GOEPanel)editComp).setTarget(leafNode.getUserObject());
|
||||
((GOEPanel) editComp).setTarget(leafNode.getUserObject());
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
root.setObject(evt.getNewValue(), true);
|
||||
if (jtree !=null) {
|
||||
if (jtree != null) {
|
||||
jtree.setModel(new DefaultTreeModel(root));
|
||||
} // TODO this should be done differently so that the tree is not collapsed on each change!
|
||||
}
|
||||
|
@@ -6,19 +6,18 @@ import eva2.tools.chart2d.DFunction;
|
||||
* Represents an exponential scaling function.
|
||||
* MK: added a guard against undefined values: the smallest positive position can
|
||||
* be stored and used instead of invalid points.
|
||||
*
|
||||
*/
|
||||
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
|
||||
|
||||
public void setMinValue(double v) {
|
||||
if (v>0) {
|
||||
if (v > 0) {
|
||||
minValue = v;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
System.err.println("Error, minimal value for Exp must be positive!");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see eva2.tools.chart2d.DFunction#isDefinedAt(double)
|
||||
@@ -62,8 +61,8 @@ public class Exp extends DFunction {
|
||||
}
|
||||
|
||||
public void updateMinValue(double y) {
|
||||
if (y<minValue && (y>0)) {
|
||||
minValue=y;
|
||||
if (y < minValue && (y > 0)) {
|
||||
minValue = y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -12,10 +12,12 @@ package eva2.gui;
|
||||
/*==========================================================================*
|
||||
* IMPORTS
|
||||
*==========================================================================*/
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.Action;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -24,46 +26,51 @@ public abstract class ExtAction extends AbstractAction {
|
||||
public final static String MNEMONIC = "Mnemonic";
|
||||
public final static String TOOLTIP = "ToolTip";
|
||||
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);
|
||||
putValue(MNEMONIC, new Character(m.getMnemonic()));
|
||||
putValue(Action.NAME, m.getText());
|
||||
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);
|
||||
if (i==null) {
|
||||
if (i == null) {
|
||||
System.out.println("Icon == null");
|
||||
}
|
||||
putValue(KEYSTROKE, key);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ExtAction(String s, Icon i, String toolTip){
|
||||
public ExtAction(String s, Icon i, String toolTip) {
|
||||
super(null, i);
|
||||
if (i==null) {
|
||||
if (i == null) {
|
||||
System.out.println("Icon == null");
|
||||
}
|
||||
setValues(s, toolTip);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ExtAction(String s, String toolTip, KeyStroke key){
|
||||
public ExtAction(String s, String toolTip, KeyStroke key) {
|
||||
this(s, toolTip);
|
||||
putValue(KEYSTROKE, key);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ExtAction(String s, String toolTip){
|
||||
public ExtAction(String s, String toolTip) {
|
||||
super();
|
||||
setValues(s, toolTip);
|
||||
}
|
||||
|
@@ -12,30 +12,35 @@ package eva2.gui;
|
||||
/*==========================================================================*
|
||||
* IMPORTS
|
||||
*==========================================================================*/
|
||||
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import javax.swing.JComponent;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public abstract class ExtActionChangedListener implements PropertyChangeListener{
|
||||
public abstract class ExtActionChangedListener implements PropertyChangeListener {
|
||||
protected JComponent component;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
ExtActionChangedListener(JComponent c){
|
||||
ExtActionChangedListener(JComponent c) {
|
||||
super();
|
||||
setTarget(c);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public abstract void propertyChange(PropertyChangeEvent e);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void setTarget(JComponent c){
|
||||
public void setTarget(JComponent c) {
|
||||
component = c;
|
||||
}
|
||||
}
|
||||
|
@@ -9,6 +9,7 @@ package eva2.gui;
|
||||
* $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $
|
||||
* $Author: streiche $
|
||||
*/
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Event;
|
||||
import java.util.logging.Level;
|
||||
|
@@ -5,6 +5,7 @@ import eva2.optimization.tools.FileTools;
|
||||
import eva2.tools.BasicResourceLoader;
|
||||
import eva2.tools.EVAHELP;
|
||||
import eva2.tools.SerializedObject;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
@@ -9,8 +9,10 @@ package eva2.gui;
|
||||
* $Date: 2007-10-23 16:58:12 +0200 (Tue, 23 Oct 2007) $
|
||||
* $Author: mkron $
|
||||
*/
|
||||
|
||||
import eva2.EvAInfo;
|
||||
import eva2.tools.BasicResourceLoader;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Toolkit;
|
||||
@@ -25,24 +27,28 @@ import javax.swing.event.HyperlinkEvent;
|
||||
import javax.swing.event.HyperlinkListener;
|
||||
import javax.swing.text.html.HTMLDocument;
|
||||
import javax.swing.text.html.HTMLFrameHyperlinkEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class HtmlDemo {
|
||||
private JEditorPane m_html;
|
||||
private String m_name;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public HtmlDemo(String name) {
|
||||
m_name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public JEditorPane getPane() {
|
||||
return m_html;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -52,21 +58,22 @@ public class HtmlDemo {
|
||||
}
|
||||
|
||||
public boolean resourceExists() {
|
||||
URL url = ClassLoader.getSystemResource("html/"+m_name);
|
||||
URL url = ClassLoader.getSystemResource("html/" + m_name);
|
||||
return (url != null);
|
||||
}
|
||||
|
||||
public static boolean resourceExists(String mname) {
|
||||
URL url = ClassLoader.getSystemResource("html/"+mname);
|
||||
URL url = ClassLoader.getSystemResource("html/" + mname);
|
||||
return (url != null);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void show() {
|
||||
try {
|
||||
URL url = null;
|
||||
url = this.getClass().getClassLoader().getSystemResource("html/"+m_name);
|
||||
url = this.getClass().getClassLoader().getSystemResource("html/" + m_name);
|
||||
|
||||
try {
|
||||
m_html = new JEditorPane(url);
|
||||
@@ -86,14 +93,14 @@ public class HtmlDemo {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
JFrame frame = new JFrame (m_name);
|
||||
JFrame frame = new JFrame(m_name);
|
||||
BasicResourceLoader loader = BasicResourceLoader.instance();
|
||||
byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation, true);
|
||||
frame.setIconImage(Toolkit.getDefaultToolkit().createImage(bytes));
|
||||
JScrollPane scroller = new JScrollPane();
|
||||
JViewport vp = scroller.getViewport();
|
||||
vp.add(m_html);
|
||||
scroller.setPreferredSize( new Dimension(600,500) );
|
||||
scroller.setPreferredSize(new Dimension(600, 500));
|
||||
frame.getContentPane().add(scroller, BorderLayout.CENTER);
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
@@ -108,8 +115,8 @@ public class HtmlDemo {
|
||||
public void hyperlinkUpdate(HyperlinkEvent e) {
|
||||
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
|
||||
if (e instanceof HTMLFrameHyperlinkEvent) {
|
||||
((HTMLDocument)m_html.getDocument()).processHTMLFrameHyperlinkEvent(
|
||||
(HTMLFrameHyperlinkEvent)e);
|
||||
((HTMLDocument) m_html.getDocument()).processHTMLFrameHyperlinkEvent(
|
||||
(HTMLFrameHyperlinkEvent) e);
|
||||
} else {
|
||||
try {
|
||||
m_html.setPage(e.getURL());
|
||||
@@ -120,5 +127,5 @@ public class HtmlDemo {
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -12,28 +12,37 @@ import eva2.optimization.mocco.paretofrontviewer.InterfaceRefSolutionListener;
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param a The selection listener
|
||||
*/
|
||||
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();
|
||||
|
||||
/** This method returns the selection listner to the PointIcon
|
||||
/**
|
||||
* This method returns the selection listner to the PointIcon
|
||||
*
|
||||
* @return InterfacePointIconSelectionListener
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @param 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
|
||||
*/
|
||||
public AbstractEAIndividual getEAIndividual();
|
||||
|
@@ -9,89 +9,102 @@ package eva2.gui;
|
||||
* $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $
|
||||
* $Author: streiche $
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import javax.swing.JInternalFrame;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JToolBar;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public abstract class JDocFrame extends JInternalFrame{
|
||||
public abstract class JDocFrame extends JInternalFrame {
|
||||
private File m_file;
|
||||
private String titleStr;
|
||||
protected boolean changed = false;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public JDocFrame(String title){
|
||||
public JDocFrame(String title) {
|
||||
super(title, true, true /* not closable*/, true, true);
|
||||
titleStr = title;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public JDocFrame(File file){
|
||||
public JDocFrame(File file) {
|
||||
this(file.getName());
|
||||
m_file = file;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public File getFile(){
|
||||
public File getFile() {
|
||||
return m_file;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public String getFileTitle(){
|
||||
public String getFileTitle() {
|
||||
return titleStr;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void save(){
|
||||
if(m_file != null) {
|
||||
public void save() {
|
||||
if (m_file != null) {
|
||||
save(m_file);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void save(File f){
|
||||
if(!f.equals(m_file)){
|
||||
public void save(File f) {
|
||||
if (!f.equals(m_file)) {
|
||||
m_file = f;
|
||||
titleStr = f.getName();
|
||||
}
|
||||
setChangedImpl(false);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void setChangedImpl(boolean value){
|
||||
private void setChangedImpl(boolean value) {
|
||||
changed = value;
|
||||
if(changed) {
|
||||
if (changed) {
|
||||
setTitle(titleStr + " *");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
setTitle(titleStr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected void setChanged(boolean value){
|
||||
if(changed != value) {
|
||||
protected void setChanged(boolean value) {
|
||||
if (changed != value) {
|
||||
setChangedImpl(value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public boolean isChanged(){
|
||||
public boolean isChanged() {
|
||||
return changed;
|
||||
}
|
||||
|
||||
public abstract String[] getActionGroups();
|
||||
|
||||
public abstract JMenu getMenu(String group);
|
||||
|
||||
public abstract JToolBar getToolBar(String group);
|
||||
}
|
||||
|
||||
|
@@ -104,7 +104,7 @@ public class JEFrame extends JInternalFrame {
|
||||
}
|
||||
);
|
||||
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"
|
||||
);
|
||||
final JEFrame self = this;
|
||||
|
@@ -1,4 +1,5 @@
|
||||
package eva2.gui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.swing.JDesktopPane;
|
||||
|
@@ -90,9 +90,9 @@ public class JExtDesktopPane extends JDesktopPane {
|
||||
/**
|
||||
* Method to access the window actions.
|
||||
*
|
||||
* @deprecated
|
||||
* @param action The desired action (use JExtDesktopPane constants). Default is null
|
||||
* @return The ExtAction
|
||||
* @deprecated
|
||||
*/
|
||||
public ExtAction getWindowAction(int action) {
|
||||
switch (action) {
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package eva2.gui;
|
||||
|
||||
import eva2.tools.ToolBoxGui;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import javax.swing.JButton;
|
||||
@@ -8,7 +9,6 @@ import javax.swing.JToolBar;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author becker
|
||||
*/
|
||||
public class JExtDesktopPaneToolBar extends JToolBar {
|
||||
|
@@ -12,26 +12,27 @@ package eva2.gui;
|
||||
/*==========================================================================*
|
||||
* IMPORTS
|
||||
*==========================================================================*/
|
||||
|
||||
import java.io.File;
|
||||
import javax.swing.*;
|
||||
|
||||
public class JExtFileChooser extends JFileChooser{
|
||||
public class JExtFileChooser extends JFileChooser {
|
||||
private boolean overwriteWarning = true;
|
||||
|
||||
public void setOverwriteWarning(boolean value){
|
||||
public void setOverwriteWarning(boolean value) {
|
||||
overwriteWarning = value;
|
||||
}
|
||||
|
||||
public boolean getOverwriteWarning(){
|
||||
public boolean getOverwriteWarning() {
|
||||
return overwriteWarning;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void approveSelection(){
|
||||
if(getDialogType() == JFileChooser.SAVE_DIALOG && overwriteWarning){
|
||||
public void approveSelection() {
|
||||
if (getDialogType() == JFileChooser.SAVE_DIALOG && overwriteWarning) {
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
|
@@ -9,42 +9,44 @@ package eva2.gui;
|
||||
* $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $
|
||||
* $Author: streiche $
|
||||
*/
|
||||
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class JExtToolBar extends JToolBar{
|
||||
public class JExtToolBar extends JToolBar {
|
||||
@Override
|
||||
public JButton add(Action a){
|
||||
public JButton add(Action a) {
|
||||
JButton button = super.add(a);
|
||||
button.setText(null);
|
||||
button.setMargin(new Insets(0, 0, 0, 0));
|
||||
|
||||
Object o;
|
||||
o = a.getValue(ExtAction.TOOLTIP);
|
||||
String toolTip = o != null ? (String)o : "";
|
||||
String toolTip = o != null ? (String) o : "";
|
||||
|
||||
o = a.getValue(ExtAction.KEYSTROKE);
|
||||
button.setToolTipText(toolTip + getKeyText((KeyStroke)o));
|
||||
button.setToolTipText(toolTip + getKeyText((KeyStroke) o));
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
private String getKeyText(KeyStroke k){
|
||||
private String getKeyText(KeyStroke k) {
|
||||
StringBuffer result = new StringBuffer();
|
||||
|
||||
if(k != null){
|
||||
if (k != null) {
|
||||
int modifiers = k.getModifiers();
|
||||
if(modifiers > 0) {
|
||||
if (modifiers > 0) {
|
||||
result.append(KeyEvent.getKeyModifiersText(modifiers) + "+");
|
||||
}
|
||||
result.append(KeyEvent.getKeyText(k.getKeyCode()));
|
||||
}
|
||||
if(result.length() > 0){
|
||||
if (result.length() > 0) {
|
||||
result.insert(0, " [");
|
||||
result.append("]");
|
||||
}
|
||||
@@ -53,32 +55,29 @@ public class JExtToolBar extends JToolBar{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PropertyChangeListener createActionChangeListener(JButton b){
|
||||
return new ExtActionChangedListener(b){
|
||||
protected PropertyChangeListener createActionChangeListener(JButton b) {
|
||||
return new ExtActionChangedListener(b) {
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent e){
|
||||
JButton button = (JButton)component;
|
||||
public void propertyChange(PropertyChangeEvent e) {
|
||||
JButton button = (JButton) component;
|
||||
|
||||
String propertyName = e.getPropertyName();
|
||||
if(propertyName.equals(Action.NAME)){
|
||||
if (propertyName.equals(Action.NAME)) {
|
||||
/* Nichts tun! */
|
||||
}
|
||||
else if(propertyName.equals("enabled")){
|
||||
button.setEnabled(((Boolean)e.getNewValue()).booleanValue());
|
||||
} else if (propertyName.equals("enabled")) {
|
||||
button.setEnabled(((Boolean) e.getNewValue()).booleanValue());
|
||||
button.repaint();
|
||||
}
|
||||
else if(e.getPropertyName().equals(Action.SMALL_ICON)){
|
||||
button.setIcon((Icon)e.getNewValue());
|
||||
} else if (e.getPropertyName().equals(Action.SMALL_ICON)) {
|
||||
button.setIcon((Icon) e.getNewValue());
|
||||
button.invalidate();
|
||||
button.repaint();
|
||||
}
|
||||
else if(propertyName.equals(ExtAction.TOOLTIP) || propertyName.equals(ExtAction.KEYSTROKE)){
|
||||
Action source = (Action)e.getSource();
|
||||
} else if (propertyName.equals(ExtAction.TOOLTIP) || propertyName.equals(ExtAction.KEYSTROKE)) {
|
||||
Action source = (Action) e.getSource();
|
||||
|
||||
Object o = source.getValue(ExtAction.TOOLTIP);
|
||||
String toolTip = o != null ? (String)o : "";
|
||||
String toolTip = o != null ? (String) o : "";
|
||||
o = source.getValue(ExtAction.KEYSTROKE);
|
||||
button.setToolTipText(toolTip + getKeyText((KeyStroke)o));
|
||||
button.setToolTipText(toolTip + getKeyText((KeyStroke) o));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@@ -68,7 +68,9 @@ public class JParaPanel implements Serializable, PanelMaker {
|
||||
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 editor
|
||||
* @return False if failed true else.
|
||||
|
@@ -12,6 +12,7 @@ package eva2.gui;
|
||||
/*==========================================================================*
|
||||
* IMPORTS
|
||||
*==========================================================================*/
|
||||
|
||||
import java.awt.Event;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
@@ -22,66 +23,66 @@ import javax.swing.text.*;
|
||||
import javax.swing.undo.*;
|
||||
|
||||
|
||||
public class JTextEditorInternalFrame extends JDocFrame{
|
||||
public class JTextEditorInternalFrame extends JDocFrame {
|
||||
public final static String GROUP_EDIT = "Edit";
|
||||
private JTextArea textArea;
|
||||
private final String[] actionGroups = {GROUP_EDIT};
|
||||
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",
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_Z, Event.CTRL_MASK));
|
||||
setEnabled(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e){
|
||||
try{
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
undo.undo();
|
||||
} catch (CannotUndoException exc) {
|
||||
}
|
||||
catch(CannotUndoException exc){}
|
||||
|
||||
update();
|
||||
actRedo.update();
|
||||
}
|
||||
|
||||
private void update() {
|
||||
if(undo.canUndo()){
|
||||
if (undo.canUndo()) {
|
||||
setEnabled(true);
|
||||
putValue(Action.NAME, undo.getUndoPresentationName());
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
setEnabled(false);
|
||||
putValue(Action.NAME, "R<EFBFBD>ckg<EFBFBD>ngig");
|
||||
}
|
||||
}
|
||||
} // end of inner class UndoAction
|
||||
|
||||
///////////////////////////////////////////
|
||||
//
|
||||
///////////////////////////////////////////
|
||||
private class RedoAction extends ExtAction{
|
||||
public RedoAction(){
|
||||
super("Wiederholen", "Wiederholt die letzte Aktion", KeyStroke.getKeyStroke(KeyEvent.VK_Z, Event.CTRL_MASK|Event.SHIFT_MASK));
|
||||
private class RedoAction extends ExtAction {
|
||||
public RedoAction() {
|
||||
super("Wiederholen", "Wiederholt die letzte Aktion", KeyStroke.getKeyStroke(KeyEvent.VK_Z, Event.CTRL_MASK | Event.SHIFT_MASK));
|
||||
setEnabled(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try{
|
||||
try {
|
||||
undo.redo();
|
||||
} catch (CannotRedoException exc) {
|
||||
}
|
||||
catch(CannotRedoException exc){}
|
||||
|
||||
update();
|
||||
actUndo.update();
|
||||
}
|
||||
|
||||
private void update() {
|
||||
if(undo.canRedo()){
|
||||
if (undo.canRedo()) {
|
||||
setEnabled(true);
|
||||
putValue(Action.NAME, undo.getRedoPresentationName());
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
setEnabled(false);
|
||||
putValue(Action.NAME, "Wiederholen");
|
||||
}
|
||||
@@ -92,28 +93,30 @@ public class JTextEditorInternalFrame extends JDocFrame{
|
||||
private RedoAction actRedo;
|
||||
public final static String undoAction = "undo";
|
||||
public final static String redoAction = "redo";
|
||||
|
||||
///////////////////////////////////////////
|
||||
//
|
||||
/////////////////////////////////////////
|
||||
@Override
|
||||
public String[] getActionGroups(){
|
||||
public String[] getActionGroups() {
|
||||
return actionGroups;
|
||||
}
|
||||
|
||||
private JMenu mnuEdit;
|
||||
private JToolBar barEdit;
|
||||
|
||||
@Override
|
||||
public JMenu getMenu(String group){
|
||||
if(GROUP_EDIT.equals(group)) {
|
||||
public JMenu getMenu(String group) {
|
||||
if (GROUP_EDIT.equals(group)) {
|
||||
return mnuEdit;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JToolBar getToolBar(String group){
|
||||
if(GROUP_EDIT.equals(group)) {
|
||||
public JToolBar getToolBar(String group) {
|
||||
if (GROUP_EDIT.equals(group)) {
|
||||
return barEdit;
|
||||
}
|
||||
return null;
|
||||
@@ -121,31 +124,32 @@ public class JTextEditorInternalFrame extends JDocFrame{
|
||||
|
||||
private Hashtable hashActions = new Hashtable();
|
||||
|
||||
private Action cloneAction(Action a){
|
||||
private Action cloneAction(Action a) {
|
||||
Action result = null;
|
||||
|
||||
try{
|
||||
try {
|
||||
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
|
||||
ObjectOutputStream out = new ObjectOutputStream(bOut);
|
||||
out.writeObject(a);
|
||||
ByteArrayInputStream bIn = new ByteArrayInputStream(bOut.toByteArray());
|
||||
ObjectInputStream in = new ObjectInputStream(bIn);
|
||||
result = (Action)in.readObject();
|
||||
result = (Action) in.readObject();
|
||||
} catch (Exception exc) {
|
||||
}
|
||||
catch(Exception exc){}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////
|
||||
//
|
||||
//////////////////////////////////////////////
|
||||
private void createActions(){
|
||||
private void createActions() {
|
||||
hashActions.put(undoAction, actUndo = new UndoAction());
|
||||
hashActions.put(redoAction, actRedo = new RedoAction());
|
||||
|
||||
Action[] actions = textArea.getActions();
|
||||
for(int i = 0; i < actions.length; i++) {
|
||||
hashActions.put((String)actions[i].getValue(Action.NAME), actions[i]);
|
||||
for (int i = 0; i < actions.length; i++) {
|
||||
hashActions.put((String) actions[i].getValue(Action.NAME), actions[i]);
|
||||
}
|
||||
|
||||
mnuEdit = new JExtMenu("&Bearbeiten");
|
||||
@@ -160,9 +164,9 @@ public class JTextEditorInternalFrame extends JDocFrame{
|
||||
mnuEdit.add(actRedo);
|
||||
mnuEdit.addSeparator();
|
||||
|
||||
a = (Action)hashActions.get(DefaultEditorKit.cutAction);
|
||||
a = (Action) hashActions.get(DefaultEditorKit.cutAction);
|
||||
keyActions = keys.getKeyStrokesForAction(a);
|
||||
if(keyActions != null && keyActions.length > 0) {
|
||||
if (keyActions != null && keyActions.length > 0) {
|
||||
a.putValue(ExtAction.KEYSTROKE, keyActions[0]);
|
||||
}
|
||||
a.putValue(Action.SMALL_ICON, new ImageIcon("images/EditCut.gif"));
|
||||
@@ -172,9 +176,9 @@ public class JTextEditorInternalFrame extends JDocFrame{
|
||||
mnuEdit.add(a);
|
||||
barEdit.add(a);
|
||||
|
||||
a = (Action)hashActions.get(DefaultEditorKit.copyAction);
|
||||
a = (Action) hashActions.get(DefaultEditorKit.copyAction);
|
||||
keyActions = keys.getKeyStrokesForAction(a);
|
||||
if(keyActions != null && keyActions.length > 0) {
|
||||
if (keyActions != null && keyActions.length > 0) {
|
||||
a.putValue(ExtAction.KEYSTROKE, keyActions[0]);
|
||||
}
|
||||
a.putValue(Action.SMALL_ICON, new ImageIcon("images/EditCopy.gif"));
|
||||
@@ -184,9 +188,9 @@ public class JTextEditorInternalFrame extends JDocFrame{
|
||||
mnuEdit.add(a);
|
||||
barEdit.add(a);
|
||||
|
||||
a = (Action)hashActions.get(DefaultEditorKit.pasteAction);
|
||||
a = (Action) hashActions.get(DefaultEditorKit.pasteAction);
|
||||
keyActions = keys.getKeyStrokesForAction(a);
|
||||
if(keyActions != null && keyActions.length > 0) {
|
||||
if (keyActions != null && keyActions.length > 0) {
|
||||
a.putValue(ExtAction.KEYSTROKE, keyActions[0]);
|
||||
}
|
||||
a.putValue(Action.SMALL_ICON, new ImageIcon("images/EditPaste.gif"));
|
||||
@@ -198,9 +202,9 @@ public class JTextEditorInternalFrame extends JDocFrame{
|
||||
|
||||
mnuEdit.addSeparator();
|
||||
|
||||
a = (Action)hashActions.get(DefaultEditorKit.selectAllAction);
|
||||
a = (Action) hashActions.get(DefaultEditorKit.selectAllAction);
|
||||
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.CAPTION, "Alles markieren");
|
||||
@@ -208,76 +212,79 @@ public class JTextEditorInternalFrame extends JDocFrame{
|
||||
a.putValue(ExtAction.TOOLTIP, "Markiert das ganze Dokument");
|
||||
mnuEdit.add(a);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
//
|
||||
/////////////////////////////////////////
|
||||
private void createTextArea(){
|
||||
private void createTextArea() {
|
||||
textArea = new JTextArea();
|
||||
getContentPane().add(new JScrollPane(textArea));
|
||||
}
|
||||
|
||||
/////////////////////////////////////
|
||||
//
|
||||
/////////////////////////////////////
|
||||
private void createListeners(){
|
||||
textArea.getDocument().addDocumentListener(new DocumentListener(){
|
||||
private void changed(){
|
||||
private void createListeners() {
|
||||
textArea.getDocument().addDocumentListener(new DocumentListener() {
|
||||
private void changed() {
|
||||
setChanged(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e){
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
changed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e){
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
changed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent e){
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
changed();
|
||||
}
|
||||
});
|
||||
|
||||
textArea.getDocument().addUndoableEditListener(new UndoableEditListener(){
|
||||
textArea.getDocument().addUndoableEditListener(new UndoableEditListener() {
|
||||
@Override
|
||||
public void undoableEditHappened(UndoableEditEvent e){
|
||||
public void undoableEditHappened(UndoableEditEvent e) {
|
||||
undo.addEdit(e.getEdit());
|
||||
actUndo.update();
|
||||
actRedo.update();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
//
|
||||
///////////////////////////////////////////////////
|
||||
public JTextEditorInternalFrame(String title){
|
||||
public JTextEditorInternalFrame(String title) {
|
||||
super(title);
|
||||
createTextArea();
|
||||
createListeners();
|
||||
createActions();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
//
|
||||
/////////////////////////////////////////////////
|
||||
public JTextEditorInternalFrame(File file){
|
||||
public JTextEditorInternalFrame(File file) {
|
||||
super(file);
|
||||
createTextArea();
|
||||
|
||||
if(file.exists()){
|
||||
if (file.exists()) {
|
||||
FileReader in = null;
|
||||
try{
|
||||
try {
|
||||
in = new FileReader(file);
|
||||
textArea.read(in, null);
|
||||
}
|
||||
catch(IOException exc){}
|
||||
finally{
|
||||
if(in != null) {
|
||||
try{
|
||||
} catch (IOException exc) {
|
||||
} finally {
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
}
|
||||
catch(IOException exc){}
|
||||
} catch (IOException exc) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -287,19 +294,18 @@ catch(IOException exc){}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(File f){
|
||||
public void save(File f) {
|
||||
FileWriter out = null;
|
||||
try{
|
||||
try {
|
||||
out = new FileWriter(f);
|
||||
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
|
||||
public void setSelected(boolean value) throws java.beans.PropertyVetoException{
|
||||
public void setSelected(boolean value) throws java.beans.PropertyVetoException {
|
||||
super.setSelected(value);
|
||||
|
||||
if(value) {
|
||||
if (value) {
|
||||
textArea.requestFocus();
|
||||
}
|
||||
}
|
||||
|
@@ -8,6 +8,7 @@ package eva2.gui;
|
||||
import eva2.EvAInfo;
|
||||
import eva2.optimization.tools.FileTools;
|
||||
import eva2.tools.BasicResourceLoader;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Point;
|
||||
import java.awt.event.*;
|
||||
|
@@ -9,6 +9,7 @@ package eva2.gui;
|
||||
* $Date: 2007-10-23 12:56:51 +0200 (Tue, 23 Oct 2007) $
|
||||
* $Author: mkron $
|
||||
*/
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Point;
|
||||
@@ -27,10 +28,11 @@ import javax.swing.event.ChangeListener;
|
||||
*/
|
||||
public class LoggingPanel extends JPanel {
|
||||
protected static Logger logger;
|
||||
protected JTextArea loggingTextArea = new JTextArea(10,20);
|
||||
protected JTextArea loggingTextArea = new JTextArea(10, 20);
|
||||
protected boolean firstMessage = true;
|
||||
protected Handler loggingHandler;
|
||||
protected JPopupMenu loggingLevelMenu;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -53,10 +55,11 @@ public class LoggingPanel extends JPanel {
|
||||
add(scrollpane, BorderLayout.CENTER);
|
||||
scrollpane.getViewport().addChangeListener(new ChangeListener() {
|
||||
private int lastHeight;
|
||||
|
||||
//
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
JViewport viewport = (JViewport)e.getSource();
|
||||
JViewport viewport = (JViewport) e.getSource();
|
||||
int height = viewport.getViewSize().height;
|
||||
if (height != lastHeight) {
|
||||
lastHeight = height;
|
||||
@@ -66,12 +69,14 @@ public class LoggingPanel extends JPanel {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected static String getTimestamp() {
|
||||
return (new SimpleDateFormat("HH:mm:ss:")).format(new Date());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@@ -114,7 +114,6 @@ public class Main extends JFrame implements OptimizationStateListener {
|
||||
* Constructor of GUI of EvA2. Works as client for the EvA2 server. Note
|
||||
* that the Main initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()}
|
||||
* to await full initialization if necessary.
|
||||
*
|
||||
*/
|
||||
public Main(final String hostName) {
|
||||
this(hostName, null, false, false);
|
||||
@@ -126,11 +125,11 @@ public class Main extends JFrame implements OptimizationStateListener {
|
||||
* efficiency. Use {@link #awaitGuiInitialized()} to await full
|
||||
* initialization if necessary.
|
||||
*
|
||||
* @see #EvAClient(String, java.awt.Window, String, boolean, boolean, boolean)
|
||||
* @param hostName
|
||||
* @param paramsFile
|
||||
* @param autorun
|
||||
* @param nosplash
|
||||
* @see #EvAClient(String, java.awt.Window, String, boolean, boolean, boolean)
|
||||
*/
|
||||
public Main(final String hostName, final String paramsFile, boolean autorun, boolean nosplash) {
|
||||
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()}
|
||||
* to await full initialization if necessary.
|
||||
*
|
||||
* @see #Main(String, String, boolean, boolean)
|
||||
*
|
||||
* @param hostName
|
||||
* @param autorun
|
||||
* @param nosplash
|
||||
* @see #Main(String, String, boolean, boolean)
|
||||
*/
|
||||
public Main(final String hostName, boolean autorun, boolean 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()}
|
||||
* to await full initialization if necessary.
|
||||
*
|
||||
* @see #Main(String, String, boolean, boolean)
|
||||
* @param hostName
|
||||
* @param paramsFile
|
||||
* @param autorun
|
||||
* @param noSplash
|
||||
* @param noGui
|
||||
* @see #Main(String, String, boolean, boolean)
|
||||
*/
|
||||
public Main(final String hostName, String paramsFile, boolean autorun, boolean noSplash, boolean noGui, boolean 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()}
|
||||
* to await full initialization if necessary.
|
||||
*
|
||||
* @see #Main(String, String, boolean, boolean)
|
||||
*
|
||||
* @param hostName
|
||||
* @param paramsFile
|
||||
* @param autorun
|
||||
* @param noSplash
|
||||
* @param noGui
|
||||
* @see #Main(String, String, boolean, boolean)
|
||||
*/
|
||||
public Main(final String hostName, InterfaceOptimizationParameters goParams, boolean autorun, boolean noSplash, boolean noGui) {
|
||||
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.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
|
||||
logPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
|
||||
|
||||
|
||||
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
|
||||
* the GUI which should be updated in the GUI.
|
||||
*
|
||||
*/
|
||||
public void refreshMainPanels() {
|
||||
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
|
||||
* in a JScrollPane.
|
||||
*
|
||||
* @see eva2.gui.EvATreeNode
|
||||
* @param title
|
||||
* @param object
|
||||
* @return
|
||||
* @see eva2.gui.EvATreeNode
|
||||
*/
|
||||
public JComponent getEvATreeView(JParaPanel goPanel, String title, Object object) {
|
||||
EvATreeNode root = new EvATreeNode(title, object); // the root of the tree
|
||||
|
@@ -7,6 +7,7 @@ package eva2.gui;
|
||||
* Time: 18:30:44
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@@ -15,9 +15,11 @@ public class MultiLineString {
|
||||
public static void main(String[] args) {
|
||||
MultiLineString multiLineString1 = new MultiLineString();
|
||||
}
|
||||
|
||||
public String getString() {
|
||||
return string;
|
||||
}
|
||||
|
||||
public void setString(String string) {
|
||||
this.string = string;
|
||||
}
|
||||
|
@@ -4,8 +4,8 @@ import javax.swing.JComponent;
|
||||
|
||||
/**
|
||||
* Simple helper interface.
|
||||
* @author mkron
|
||||
*
|
||||
* @author mkron
|
||||
*/
|
||||
public interface PanelMaker {
|
||||
public JComponent makePanel();
|
||||
|
@@ -8,6 +8,7 @@ package eva2.gui;
|
||||
import eva2.EvAInfo;
|
||||
import eva2.tools.BasicResourceLoader;
|
||||
import eva2.tools.EVAHELP;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.beans.PropertyEditor;
|
||||
|
@@ -24,25 +24,25 @@ public class PropertyDoubleArray implements java.io.Serializable {
|
||||
/**
|
||||
* Constructor that creates a double matrix with given dimensions and fills
|
||||
* it cyclically with values given.
|
||||
*
|
||||
* @param rows
|
||||
* @param cols
|
||||
* @param d
|
||||
*/
|
||||
public PropertyDoubleArray(int rows, int cols, double ... d) {
|
||||
if (rows>0 && cols>0) {
|
||||
public PropertyDoubleArray(int rows, int cols, double... d) {
|
||||
if (rows > 0 && cols > 0) {
|
||||
this.m_DoubleArray = new double[rows][cols];
|
||||
} else {
|
||||
this.m_DoubleArray = null;
|
||||
}
|
||||
else {
|
||||
this.m_DoubleArray=null;
|
||||
}
|
||||
this.m_numCols=cols;
|
||||
int index=0;
|
||||
for (int i=0; i<rows; i++) {
|
||||
for (int j=0; j<cols; j++) {
|
||||
m_DoubleArray[i][j]=d[index];
|
||||
this.m_numCols = cols;
|
||||
int index = 0;
|
||||
for (int i = 0; i < rows; i++) {
|
||||
for (int j = 0; j < cols; j++) {
|
||||
m_DoubleArray[i][j] = d[index];
|
||||
index++;
|
||||
if (index>=d.length) {
|
||||
index=0;
|
||||
if (index >= d.length) {
|
||||
index = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,27 +53,30 @@ public class PropertyDoubleArray implements java.io.Serializable {
|
||||
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[]
|
||||
*/
|
||||
public void setDoubleArray(double[] d) {
|
||||
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_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[]
|
||||
*/
|
||||
public void setDoubleArray(double[][] d) {
|
||||
this.m_DoubleArray = d;
|
||||
if (d.length>0) {
|
||||
m_numCols=d[0].length;
|
||||
}
|
||||
else {
|
||||
m_numCols=1;
|
||||
if (d.length > 0) {
|
||||
m_numCols = d[0].length;
|
||||
} else {
|
||||
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)
|
||||
*/
|
||||
public double[] getDoubleColumnAsVector(int col) {
|
||||
if (col>=m_numCols) {
|
||||
if (col >= m_numCols) {
|
||||
throw new IllegalArgumentException("Error, invalid column selected, " + col + " of " + m_numCols);
|
||||
}
|
||||
double[] ret = new double[m_DoubleArray.length];
|
||||
for (int i=0; i<ret.length; i++) {
|
||||
ret[i]=m_DoubleArray[i][col];
|
||||
for (int i = 0; i < ret.length; i++) {
|
||||
ret[i] = m_DoubleArray[i][col];
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -108,22 +112,21 @@ public class PropertyDoubleArray implements java.io.Serializable {
|
||||
}
|
||||
|
||||
public double getValue(int i, int j) {
|
||||
if (i<0 || j<0 || (i>=getNumRows()) || (j>=getNumCols())) {
|
||||
throw new IllegalArgumentException("Error, invalid access to double array: " + i + "," + j + " within " + getNumRows() + ","+getNumCols());
|
||||
if (i < 0 || j < 0 || (i >= getNumRows()) || (j >= getNumCols())) {
|
||||
throw new IllegalArgumentException("Error, invalid access to double array: " + i + "," + j + " within " + getNumRows() + "," + getNumCols());
|
||||
}
|
||||
return m_DoubleArray[i][j];
|
||||
}
|
||||
|
||||
public void adaptRowCount(int k) {
|
||||
if (k!=m_DoubleArray.length) {
|
||||
if (k != m_DoubleArray.length) {
|
||||
double[][] newDD = new double[k][m_numCols];
|
||||
for (int i=0; i<k; i++) {
|
||||
for (int j=0; j<m_numCols; j++) {
|
||||
if (i<m_DoubleArray.length) {
|
||||
newDD[i][j]=m_DoubleArray[i][j];
|
||||
}
|
||||
else {
|
||||
newDD[i][j]=m_DoubleArray[m_DoubleArray.length-1][j];
|
||||
for (int i = 0; i < k; i++) {
|
||||
for (int j = 0; j < m_numCols; j++) {
|
||||
if (i < m_DoubleArray.length) {
|
||||
newDD[i][j] = m_DoubleArray[i][j];
|
||||
} else {
|
||||
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) {
|
||||
if (k<0 || k>=getNumRows()) {
|
||||
if (k < 0 || k >= getNumRows()) {
|
||||
throw new IllegalArgumentException("Invalid index to deleteRow: " + k + " is not a valid row.");
|
||||
}
|
||||
double[][] newDD = new double[getNumRows()-1][getNumCols()];
|
||||
int inc=0;
|
||||
double[][] newDD = new double[getNumRows() - 1][getNumCols()];
|
||||
int inc = 0;
|
||||
for (int i = 0; i < newDD.length; i++) {
|
||||
if (i==k) {
|
||||
inc=1;
|
||||
if (i == k) {
|
||||
inc = 1;
|
||||
}
|
||||
for (int j=0; j<getNumCols(); j++) {
|
||||
newDD[i][j] = m_DoubleArray[i+inc][j];
|
||||
for (int j = 0; j < getNumCols(); j++) {
|
||||
newDD[i][j] = m_DoubleArray[i + inc][j];
|
||||
}
|
||||
}
|
||||
setDoubleArray(newDD);
|
||||
@@ -155,24 +158,25 @@ public class PropertyDoubleArray implements java.io.Serializable {
|
||||
* @param k
|
||||
*/
|
||||
public void addRowCopy(int k) {
|
||||
if (k<0 || k>= getNumRows()) {
|
||||
k=getNumRows()-1;
|
||||
if (k < 0 || k >= getNumRows()) {
|
||||
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 j = 0; j<getNumCols(); j++) {
|
||||
for (int j = 0; j < getNumCols(); j++) {
|
||||
newDD[i][j] = m_DoubleArray[i][j];
|
||||
}
|
||||
}
|
||||
if (k>=0) {
|
||||
for (int j=0; j<getNumCols(); j++) {
|
||||
newDD[newDD.length-1][j] = newDD[k][j];
|
||||
} }
|
||||
else {
|
||||
for (int j=0; j<getNumCols(); j++) {
|
||||
newDD[newDD.length-1][j] = 1.;
|
||||
} } // if the array was empty
|
||||
if (k >= 0) {
|
||||
for (int j = 0; j < getNumCols(); j++) {
|
||||
newDD[newDD.length - 1][j] = newDD[k][j];
|
||||
}
|
||||
} else {
|
||||
for (int j = 0; j < getNumCols(); j++) {
|
||||
newDD[newDD.length - 1][j] = 1.;
|
||||
}
|
||||
} // if the array was empty
|
||||
setDoubleArray(newDD);
|
||||
}
|
||||
|
||||
@@ -180,26 +184,28 @@ public class PropertyDoubleArray implements java.io.Serializable {
|
||||
* Normalize all columns of the array by dividing through the sum.
|
||||
*/
|
||||
public void normalizeColumns() {
|
||||
double colSum=0;
|
||||
for (int j=0; j<getNumCols(); j++) {
|
||||
colSum=0;
|
||||
double colSum = 0;
|
||||
for (int j = 0; j < getNumCols(); j++) {
|
||||
colSum = 0;
|
||||
for (int i = 0; i < getNumRows(); i++) {
|
||||
colSum += m_DoubleArray[i][j];
|
||||
}
|
||||
if (colSum!=0) {
|
||||
if (colSum != 0) {
|
||||
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).
|
||||
*
|
||||
* @param k
|
||||
* @return
|
||||
*/
|
||||
public boolean isValidRow(int k) {
|
||||
return (k>=0) && (k<getNumRows());
|
||||
return (k >= 0) && (k < getNumRows());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -50,8 +50,7 @@ public class PropertyFilePath implements java.io.Serializable {
|
||||
String fName = ReflectPackage.getResourcePathFromCP(relPath);
|
||||
if (fName == null) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return new PropertyFilePath(fName);
|
||||
}
|
||||
}
|
||||
@@ -61,8 +60,10 @@ public class PropertyFilePath implements java.io.Serializable {
|
||||
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
|
||||
*
|
||||
* @param s The complete filepath and filename
|
||||
*/
|
||||
public void setCompleteFilePath(String s) {
|
||||
@@ -72,18 +73,18 @@ public class PropertyFilePath implements java.io.Serializable {
|
||||
String old = this.getCompleteFilePath();
|
||||
try {
|
||||
if (trace) {
|
||||
System.out.println("Complete Filename: " +s);
|
||||
System.out.println("Complete Filename: " + s);
|
||||
}
|
||||
filesep = System.getProperty("file.separator");
|
||||
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.FilePath = s.substring(0, s.lastIndexOf(filesep)+1);
|
||||
this.FilePath = s.substring(0, s.lastIndexOf(filesep) + 1);
|
||||
|
||||
if (trace) {
|
||||
System.out.println("FilePath: " +this.FilePath);
|
||||
System.out.println("FilePath: " + this.FilePath);
|
||||
}
|
||||
if (trace) {
|
||||
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
|
||||
*
|
||||
* @return The complete filename with path.
|
||||
*/
|
||||
public String getCompleteFilePath() {
|
||||
|
@@ -24,14 +24,18 @@ public class PropertyIntArray implements java.io.Serializable {
|
||||
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[]
|
||||
*/
|
||||
public void setIntArray(int[] d) {
|
||||
this.m_IntArray = d;
|
||||
}
|
||||
|
||||
/** This method will return the int array
|
||||
/**
|
||||
* This method will return the int array
|
||||
*
|
||||
* @return The int array
|
||||
*/
|
||||
public int[] getIntArray() {
|
||||
|
@@ -17,14 +17,15 @@ public class PropertyOptimizationObjectives implements java.io.Serializable {
|
||||
this.m_AvailableObjectives = d;
|
||||
this.m_SelectedObjectives = null;
|
||||
}
|
||||
|
||||
public PropertyOptimizationObjectives(PropertyOptimizationObjectives d) {
|
||||
this.m_AvailableObjectives = new InterfaceOptimizationObjective[d.m_AvailableObjectives.length];
|
||||
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];
|
||||
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);
|
||||
}
|
||||
|
||||
/** 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[]
|
||||
*/
|
||||
public void setSelectedTargets(InterfaceOptimizationObjective[] d) {
|
||||
this.m_SelectedObjectives = d;
|
||||
}
|
||||
|
||||
/** This method will return the InterfaceOptimizationTarget array
|
||||
/**
|
||||
* This method will return the InterfaceOptimizationTarget array
|
||||
*
|
||||
* @return The InterfaceOptimizationTarget[].
|
||||
*/
|
||||
public InterfaceOptimizationObjective[] getSelectedTargets() {
|
||||
return this.m_SelectedObjectives;
|
||||
}
|
||||
|
||||
/** This method will return the InterfaceOptimizationTarget array
|
||||
/**
|
||||
* This method will return the InterfaceOptimizationTarget array
|
||||
*
|
||||
* @return The InterfaceOptimizationTarget[].
|
||||
*/
|
||||
public InterfaceOptimizationObjective[] getAvailableTargets() {
|
||||
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.
|
||||
*/
|
||||
public void removeTarget(int index) {
|
||||
@@ -62,7 +71,7 @@ public class PropertyOptimizationObjectives implements java.io.Serializable {
|
||||
return;
|
||||
}
|
||||
|
||||
InterfaceOptimizationObjective[] newList = new InterfaceOptimizationObjective[this.m_SelectedObjectives.length-1];
|
||||
InterfaceOptimizationObjective[] newList = new InterfaceOptimizationObjective[this.m_SelectedObjectives.length - 1];
|
||||
int j = 0;
|
||||
for (int i = 0; i < this.m_SelectedObjectives.length; i++) {
|
||||
if (index != i) {
|
||||
@@ -73,11 +82,13 @@ public class PropertyOptimizationObjectives implements java.io.Serializable {
|
||||
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
|
||||
*/
|
||||
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++) {
|
||||
newList[i] = this.m_SelectedObjectives[i];
|
||||
}
|
||||
|
@@ -22,17 +22,18 @@ public class PropertyOptimizationObjectivesWithParam implements java.io.Serializ
|
||||
this.m_AvailableObjectives = d;
|
||||
this.m_SelectedObjectives = null;
|
||||
}
|
||||
|
||||
public PropertyOptimizationObjectivesWithParam(PropertyOptimizationObjectivesWithParam d) {
|
||||
this.m_DescriptiveString = d.m_DescriptiveString;
|
||||
this.m_WeightsLabel = d.m_WeightsLabel;
|
||||
this.m_NormalizationEnabled = d.m_NormalizationEnabled;
|
||||
this.m_AvailableObjectives = new InterfaceOptimizationObjective[d.m_AvailableObjectives.length];
|
||||
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];
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
|
||||
/** 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[]
|
||||
*/
|
||||
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[].
|
||||
*/
|
||||
public InterfaceOptimizationObjective[] getSelectedTargets() {
|
||||
return this.m_SelectedObjectives;
|
||||
}
|
||||
|
||||
/** This method will return the InterfaceOptimizationTarget array
|
||||
/**
|
||||
* This method will return the InterfaceOptimizationTarget array
|
||||
*
|
||||
* @return The InterfaceOptimizationTarget[].
|
||||
*/
|
||||
public InterfaceOptimizationObjective[] getAvailableTargets() {
|
||||
return this.m_AvailableObjectives;
|
||||
}
|
||||
|
||||
/** This method allows you to read the weights
|
||||
/**
|
||||
* This method allows you to read the weights
|
||||
*
|
||||
* @return the weights
|
||||
*/
|
||||
public double[] getWeights() {
|
||||
return this.m_Weights;
|
||||
}
|
||||
|
||||
public void setWeights(double[] 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
|
||||
*/
|
||||
public String getDescriptiveString() {
|
||||
return this.m_DescriptiveString;
|
||||
}
|
||||
|
||||
public void setDescriptiveString(String 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
|
||||
*/
|
||||
public String getWeigthsLabel() {
|
||||
return this.m_WeightsLabel;
|
||||
}
|
||||
|
||||
public void setWeightsLabel(String 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
|
||||
*/
|
||||
public boolean isNormalizationEnabled() {
|
||||
return this.m_NormalizationEnabled;
|
||||
}
|
||||
|
||||
public void enableNormalization(boolean 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.
|
||||
*/
|
||||
public void removeTarget(int index) {
|
||||
@@ -140,7 +161,7 @@ public class PropertyOptimizationObjectivesWithParam implements java.io.Serializ
|
||||
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];
|
||||
int j = 0;
|
||||
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 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
|
||||
*/
|
||||
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];
|
||||
for (int i = 0; i < this.m_SelectedObjectives.length; i++) {
|
||||
newList[i] = this.m_SelectedObjectives[i];
|
||||
|
@@ -9,7 +9,9 @@ package eva2.gui;
|
||||
* $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $
|
||||
* $Author: streiche $
|
||||
*/
|
||||
|
||||
import eva2.tools.EVAHELP;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
@@ -18,6 +20,7 @@ import javax.swing.BorderFactory;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -26,6 +29,7 @@ public class PropertyPanel extends JPanel {
|
||||
private PropertyDialog propertyDialog;
|
||||
|
||||
private JLabel textLabel;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -50,12 +54,11 @@ public class PropertyPanel extends JPanel {
|
||||
|
||||
public void showDialog(int initX, int initY) {
|
||||
if (propertyDialog == null) {
|
||||
propertyDialog = new PropertyDialog(propertyEditor, EVAHELP.cutClassName(propertyEditor.getClass().getName()) , initX, initY);
|
||||
propertyDialog.setPreferredSize(new Dimension(500,300));
|
||||
propertyDialog = new PropertyDialog(propertyEditor, EVAHELP.cutClassName(propertyEditor.getClass().getName()), initX, initY);
|
||||
propertyDialog.setPreferredSize(new Dimension(500, 300));
|
||||
propertyDialog.setModal(true);
|
||||
propertyDialog.setVisible(true);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
propertyDialog.updateFrameTitle(propertyEditor);
|
||||
propertyDialog.setVisible(false);
|
||||
propertyDialog.requestFocus();
|
||||
@@ -79,7 +82,7 @@ public class PropertyPanel extends JPanel {
|
||||
public void paintComponent(Graphics g) {
|
||||
Insets i = textLabel.getInsets();
|
||||
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);
|
||||
g.clearRect(i.left, i.top,
|
||||
getSize().width - i.right - i.left,
|
||||
|
@@ -16,7 +16,7 @@ public class PropertySelectableList<T> implements java.io.Serializable {
|
||||
protected boolean[] m_Selection;
|
||||
private transient PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||
|
||||
// public PropertySelectableList() {
|
||||
// public PropertySelectableList() {
|
||||
// }
|
||||
//
|
||||
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.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public T[] getSelectedObjects() {
|
||||
T[] selObjects = getObjects().clone();
|
||||
for (int i=0; i<selObjects.length; i++) {
|
||||
for (int i = 0; i < selObjects.length; i++) {
|
||||
if (!m_Selection[i]) {
|
||||
selObjects[i]=null;
|
||||
selObjects[i] = null;
|
||||
}
|
||||
}
|
||||
return selObjects;
|
||||
@@ -79,8 +80,8 @@ public class PropertySelectableList<T> implements java.io.Serializable {
|
||||
*/
|
||||
public void setSelectionByIndices(int[] selection) {
|
||||
m_Selection = new boolean[getObjects().length];
|
||||
for (int i=0; i<selection.length; i++) {
|
||||
m_Selection[selection[i]]=true;
|
||||
for (int i = 0; i < selection.length; i++) {
|
||||
m_Selection[selection[i]] = true;
|
||||
}
|
||||
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) {
|
||||
if (m_Selection[index]!=b) {
|
||||
if (m_Selection[index] != b) {
|
||||
this.m_Selection[index] = b;
|
||||
m_Support.firePropertyChange("PropertySelectableList", null, this);
|
||||
}
|
||||
@@ -104,8 +105,7 @@ public class PropertySelectableList<T> implements java.io.Serializable {
|
||||
public int size() {
|
||||
if (m_Objects == null) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return m_Objects.length;
|
||||
}
|
||||
}
|
||||
@@ -119,8 +119,8 @@ public class PropertySelectableList<T> implements java.io.Serializable {
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
m_Objects=null;
|
||||
m_Selection=null;
|
||||
m_Objects = null;
|
||||
m_Selection = null;
|
||||
m_Support.firePropertyChange("PropertySelectableList", null, this);
|
||||
}
|
||||
|
||||
|
@@ -9,8 +9,10 @@ package eva2.gui;
|
||||
* $Date: 2007-12-05 11:29:32 +0100 (Wed, 05 Dec 2007) $
|
||||
* $Author: mkron $
|
||||
*/
|
||||
|
||||
import eva2.gui.editor.GenericObjectEditor;
|
||||
import eva2.tools.EVAHELP;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
@@ -25,6 +27,7 @@ import javax.swing.table.DefaultTableModel;
|
||||
import javax.swing.table.TableCellEditor;
|
||||
import javax.swing.table.TableCellRenderer;
|
||||
import javax.swing.table.TableModel;
|
||||
|
||||
/**
|
||||
* There are some trick methods interpreted here. Check EvA2Notes.txt.
|
||||
*/
|
||||
@@ -1145,5 +1148,4 @@ class PropertyCellEditor extends AbstractCellEditor implements TableCellEditor {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@@ -12,6 +12,7 @@ package eva2.gui;
|
||||
/*==========================================================================*
|
||||
* IMPORTS
|
||||
*==========================================================================*/
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
@@ -24,6 +25,7 @@ import javax.swing.JCheckBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -42,6 +44,7 @@ public class PropertySheetPanelStat extends JPanel implements Serializable {
|
||||
// setBorder(BorderFactory.createLineBorder(Color.red));
|
||||
setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* A support object for handling property change listeners
|
||||
*/
|
||||
|
@@ -4,6 +4,7 @@ package eva2.gui;
|
||||
* 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 $
|
||||
*/
|
||||
|
||||
import java.awt.event.FocusAdapter;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.KeyAdapter;
|
||||
|
@@ -11,7 +11,6 @@ import javax.swing.JTextField;
|
||||
/**
|
||||
* A text property editor view. Updates the editor on key release and lost focus
|
||||
* events.
|
||||
*
|
||||
*/
|
||||
public class PropertyText extends JTextField {
|
||||
|
||||
|
@@ -11,6 +11,7 @@ package eva2.gui;
|
||||
* @version: $Revision: 322 $ $Date: 2007-12-11 17:24:07 +0100 (Tue, 11 Dec 2007)$
|
||||
* $Author: mkron $
|
||||
*/
|
||||
|
||||
import eva2.tools.BasicResourceLoader;
|
||||
|
||||
import java.awt.*;
|
||||
@@ -28,7 +29,7 @@ class SplashScreen extends Frame {
|
||||
|
||||
/**
|
||||
* Show the splash screen to the end user.
|
||||
*
|
||||
* <p/>
|
||||
* <P>Once this method returns, the splash screen is realized, which means
|
||||
* that almost all work on the splash screen should proceed through the
|
||||
* event dispatch thread. In particular, any call to
|
||||
|
@@ -28,12 +28,18 @@ import javax.swing.SwingConstants;
|
||||
*/
|
||||
public abstract class AbstractListSelectionEditor extends JPanel implements PropertyEditor, PropertyChangeListener {
|
||||
|
||||
/** Handles property change notification */
|
||||
/**
|
||||
* Handles property change notification
|
||||
*/
|
||||
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);
|
||||
|
||||
/** The graphics stuff */
|
||||
/**
|
||||
* The graphics stuff
|
||||
*/
|
||||
private JPanel m_CustomEditor, m_NodePanel;
|
||||
protected JCheckBox[] m_BlackCheck;
|
||||
|
||||
@@ -41,7 +47,8 @@ public abstract class AbstractListSelectionEditor extends JPanel implements Prop
|
||||
public AbstractListSelectionEditor() {
|
||||
}
|
||||
|
||||
/** This method will init the CustomEditor Panel
|
||||
/**
|
||||
* This method will init the CustomEditor Panel
|
||||
*/
|
||||
private void initCustomEditor() {
|
||||
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
|
||||
*/
|
||||
protected abstract int getElementCount();
|
||||
@@ -122,7 +130,9 @@ public abstract class AbstractListSelectionEditor extends JPanel implements Prop
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
@Override
|
||||
@@ -134,6 +144,7 @@ public abstract class AbstractListSelectionEditor extends JPanel implements Prop
|
||||
|
||||
/**
|
||||
* Returns the current object.
|
||||
*
|
||||
* @return the current object
|
||||
*/
|
||||
@Override
|
||||
@@ -175,13 +186,16 @@ public abstract class AbstractListSelectionEditor extends JPanel implements Prop
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
}
|
||||
|
||||
/** Returns true since the Object can be shown
|
||||
/**
|
||||
* Returns true since the Object can be shown
|
||||
*
|
||||
* @return true
|
||||
*/
|
||||
@Override
|
||||
public boolean isPaintable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints a representation of the current classifier.
|
||||
*
|
||||
@@ -193,11 +207,12 @@ public abstract class AbstractListSelectionEditor extends JPanel implements Prop
|
||||
FontMetrics fm = gfx.getFontMetrics();
|
||||
int vpad = (box.height - fm.getAscent()) / 2;
|
||||
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.
|
||||
*
|
||||
* @return true
|
||||
*/
|
||||
@Override
|
||||
@@ -205,7 +220,9 @@ public abstract class AbstractListSelectionEditor extends JPanel implements Prop
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Returns the array editing component.
|
||||
/**
|
||||
* Returns the array editing component.
|
||||
*
|
||||
* @return a value of type 'java.awt.Component'
|
||||
*/
|
||||
@Override
|
||||
|
@@ -12,6 +12,7 @@ package eva2.gui.editor;
|
||||
/*==========================================================================*
|
||||
* IMPORTS
|
||||
*==========================================================================*/
|
||||
|
||||
import eva2.gui.PropertyDialog;
|
||||
|
||||
import java.awt.*;
|
||||
@@ -28,19 +29,20 @@ public class BigStringEditor implements PropertyEditor {
|
||||
private JTextArea m_TextArea;
|
||||
private JScrollPane m_ScrollPane;
|
||||
private JPanel m_Panel;
|
||||
// private Source m_Source;
|
||||
// private Source m_Source;
|
||||
private JButton m_SetButton;
|
||||
static private boolean m_finished = false;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static void editSource (String file) {
|
||||
public static void editSource(String file) {
|
||||
|
||||
try {
|
||||
m_finished=false;
|
||||
m_finished = false;
|
||||
BigStringEditor editor = new BigStringEditor();
|
||||
|
||||
PropertyDialog dialog = new PropertyDialog(editor,file, 50, 50);
|
||||
PropertyDialog dialog = new PropertyDialog(editor, file, 50, 50);
|
||||
//frame.setSize(200, 200);
|
||||
dialog.addWindowListener(new WindowListener() {
|
||||
|
||||
@@ -80,10 +82,11 @@ public class BigStringEditor implements PropertyEditor {
|
||||
}
|
||||
}
|
||||
);
|
||||
while (m_finished==false) {
|
||||
try {Thread.sleep(1000);}
|
||||
catch (Exception e) {
|
||||
System.out.println("e+"+e.getMessage());
|
||||
while (m_finished == false) {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (Exception e) {
|
||||
System.out.println("e+" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,16 +96,17 @@ public class BigStringEditor implements PropertyEditor {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public BigStringEditor () {
|
||||
public BigStringEditor() {
|
||||
super();
|
||||
// m_TextArea = new JEditTextArea();
|
||||
// m_TextArea.setTokenMarker(new JavaTokenMarker());
|
||||
m_TextArea = new JTextArea(60,60);
|
||||
m_TextArea = new JTextArea(60, 60);
|
||||
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_Panel = new JPanel();
|
||||
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_SetButton, BorderLayout.SOUTH);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void setValue (Object value) {
|
||||
public void setValue(Object value) {
|
||||
m_ElementEditor = null;
|
||||
if (value instanceof String) {
|
||||
// m_Source.setString((String)value);
|
||||
m_TextArea.setText((String)value);
|
||||
m_TextArea.setText((String) value);
|
||||
|
||||
}
|
||||
/* if (value instanceof Source) {
|
||||
@@ -134,19 +139,21 @@ public class BigStringEditor implements PropertyEditor {
|
||||
}*/
|
||||
m_Support.firePropertyChange("", null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public Object getValue () {
|
||||
public Object getValue() {
|
||||
// m_Source.setString(m_TextArea.getText());
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public String getJavaInitializationString () {
|
||||
public String getJavaInitializationString() {
|
||||
return "null";
|
||||
}
|
||||
|
||||
@@ -157,7 +164,7 @@ public class BigStringEditor implements PropertyEditor {
|
||||
* @return true
|
||||
*/
|
||||
@Override
|
||||
public boolean isPaintable () {
|
||||
public boolean isPaintable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -168,9 +175,9 @@ public class BigStringEditor implements PropertyEditor {
|
||||
* @param box the area we are allowed to paint into
|
||||
*/
|
||||
@Override
|
||||
public void paintValue (Graphics gfx, Rectangle box) {
|
||||
public void paintValue(Graphics gfx, Rectangle box) {
|
||||
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());
|
||||
gfx.drawString("BigStringEditor", 2, fm.getHeight() + vpad - 3);
|
||||
}
|
||||
@@ -179,7 +186,7 @@ public class BigStringEditor implements PropertyEditor {
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public String getAsText () {
|
||||
public String getAsText() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -187,7 +194,7 @@ public class BigStringEditor implements PropertyEditor {
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void setAsText (String text) throws IllegalArgumentException {
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
throw new IllegalArgumentException(text);
|
||||
}
|
||||
|
||||
@@ -195,7 +202,7 @@ public class BigStringEditor implements PropertyEditor {
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public String[] getTags () {
|
||||
public String[] getTags() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -203,14 +210,15 @@ public class BigStringEditor implements PropertyEditor {
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public boolean supportsCustomEditor () {
|
||||
public boolean supportsCustomEditor() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public Component getCustomEditor () {
|
||||
public Component getCustomEditor() {
|
||||
return m_Panel;
|
||||
}
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
package eva2.gui.editor;
|
||||
|
||||
/*
|
||||
* Title: EvA2
|
||||
* Description:
|
||||
|
@@ -16,7 +16,9 @@ import javax.swing.JFrame;
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class EnumEditor extends PropertyEditorSupport {
|
||||
/** The Enum values that may be chosen */
|
||||
/**
|
||||
* The Enum values that may be chosen
|
||||
*/
|
||||
private Enum[] enumConstants;
|
||||
|
||||
@Override
|
||||
@@ -27,22 +29,22 @@ public class EnumEditor extends PropertyEditorSupport {
|
||||
@Override
|
||||
public void setValue(Object value) {
|
||||
if (value instanceof Enum) {
|
||||
enumConstants = ((Enum)value).getClass().getEnumConstants();
|
||||
enumConstants = ((Enum) value).getClass().getEnumConstants();
|
||||
// enumType = ((Enum)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();
|
||||
Enum<?>[] e = (Enum[])(value);
|
||||
enumConstants =(Enum[]) e.getClass().getComponentType().getEnumConstants();
|
||||
Enum<?>[] e = (Enum[]) (value);
|
||||
enumConstants = (Enum[]) e.getClass().getComponentType().getEnumConstants();
|
||||
super.setValue(value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
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())) {
|
||||
setValue((Enum)enumConstants[i]);
|
||||
setValue((Enum) enumConstants[i]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -51,12 +53,12 @@ public class EnumEditor extends PropertyEditorSupport {
|
||||
|
||||
@Override
|
||||
public String[] getTags() {
|
||||
if (getValue()==null) {
|
||||
if (getValue() == null) {
|
||||
return null;
|
||||
}
|
||||
String[] tags = new String[enumConstants.length];
|
||||
for (int i=0; i<tags.length; i++) {
|
||||
tags[i]=enumConstants[i].toString();
|
||||
for (int i = 0; i < tags.length; i++) {
|
||||
tags[i] = enumConstants[i].toString();
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
@@ -66,7 +68,7 @@ public class EnumEditor extends PropertyEditorSupport {
|
||||
*
|
||||
* @param args ignored
|
||||
*/
|
||||
public static void main(String [] args) {
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
Enum<?> initial = TestEnum.asdf;
|
||||
EnumEditor ed = new EnumEditor();
|
||||
@@ -90,4 +92,4 @@ public class EnumEditor extends PropertyEditorSupport {
|
||||
}
|
||||
}
|
||||
|
||||
enum TestEnum { asdf, sdf, asdfa};
|
||||
enum TestEnum {asdf, sdf, asdfa};
|
@@ -11,7 +11,9 @@ import eva2.optimization.individuals.codings.gp.GPArea;
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class GenericAreaEditor extends AbstractListSelectionEditor {
|
||||
/** The GPArea that is to be edited*/
|
||||
/**
|
||||
* The GPArea that is to be edited
|
||||
*/
|
||||
private GPArea m_AreaObject;
|
||||
|
||||
public GenericAreaEditor() {
|
||||
@@ -25,13 +27,13 @@ public class GenericAreaEditor extends AbstractListSelectionEditor {
|
||||
|
||||
@Override
|
||||
protected String getElementName(int i) {
|
||||
AbstractGPNode an = (AbstractGPNode)m_AreaObject.getCompleteList().get(i);
|
||||
AbstractGPNode an = (AbstractGPNode) m_AreaObject.getCompleteList().get(i);
|
||||
return an.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isElementSelected(int i) {
|
||||
return ((Boolean)m_AreaObject.getBlackList().get(i)).booleanValue();
|
||||
return ((Boolean) m_AreaObject.getBlackList().get(i)).booleanValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -3,6 +3,7 @@ package eva2.gui.editor;
|
||||
import eva2.gui.*;
|
||||
import eva2.tools.EVAHELP;
|
||||
import eva2.tools.SerializedObject;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
|
@@ -28,7 +28,6 @@ import javax.swing.SwingConstants;
|
||||
* A simple focus listener with an object ID and callback.
|
||||
*
|
||||
* @author mkron
|
||||
*
|
||||
*/
|
||||
class MyFocusListener implements FocusListener {
|
||||
private int myID = -1;
|
||||
@@ -44,14 +43,19 @@ class MyFocusListener implements FocusListener {
|
||||
* @see java.awt.event.FocusListener#focusLost(java.awt.event.FocusEvent)
|
||||
*/
|
||||
@Override
|
||||
public void focusLost(FocusEvent e) { }
|
||||
public void focusLost(FocusEvent e) {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.awt.event.FocusListener#focusGained(java.awt.event.FocusEvent)
|
||||
*/
|
||||
@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 {
|
||||
|
||||
private static final long serialVersionUID = 7749892624600018812L;
|
||||
/** Handles property change notification */
|
||||
/**
|
||||
* Handles property change notification
|
||||
*/
|
||||
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);
|
||||
/** The FilePath that is to be edited*/
|
||||
/**
|
||||
* The FilePath that is to be edited
|
||||
*/
|
||||
private PropertyDoubleArray m_DoubleArray;
|
||||
|
||||
/** The gaphix stuff */
|
||||
/**
|
||||
* The gaphix stuff
|
||||
*/
|
||||
private JPanel m_CustomEditor, m_DataPanel, m_ButtonPanel;
|
||||
private JTextField[][] m_InputTextFields;
|
||||
private JButton m_OKButton, m_AddButton, m_DeleteButton, m_NormalizeButton;
|
||||
|
||||
/** Which columns has the focus? **/
|
||||
/**
|
||||
* Which columns has the focus? *
|
||||
*/
|
||||
private int lastFocussedRow = -1;
|
||||
|
||||
public GenericDoubleArrayEditor() {
|
||||
// compiled code
|
||||
}
|
||||
|
||||
/** This method will init the CustomEditor Panel
|
||||
/**
|
||||
* This method will init the CustomEditor Panel
|
||||
*/
|
||||
private void initCustomEditor() {
|
||||
this.m_CustomEditor = new JPanel();
|
||||
@@ -120,7 +136,8 @@ public class GenericDoubleArrayEditor extends JPanel implements PropertyEditor {
|
||||
this.updateEditor();
|
||||
}
|
||||
|
||||
/** This action listener adds an element to DoubleArray
|
||||
/**
|
||||
* This action listener adds an element to DoubleArray
|
||||
*/
|
||||
ActionListener addAction = new ActionListener() {
|
||||
@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() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
if (!m_DoubleArray.isValidRow(lastFocussedRow)) {
|
||||
m_DoubleArray.deleteRow(m_DoubleArray.getNumRows()-1);
|
||||
m_DoubleArray.deleteRow(m_DoubleArray.getNumRows() - 1);
|
||||
} else {
|
||||
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() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent event) {
|
||||
}
|
||||
|
||||
@Override
|
||||
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];
|
||||
|
||||
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 {
|
||||
double d = 0;
|
||||
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() {
|
||||
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() {
|
||||
int numRows = m_DoubleArray.getNumRows();
|
||||
int numCols = m_DoubleArray.getNumCols();
|
||||
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];
|
||||
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);
|
||||
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].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].addFocusListener(new MyFocusListener(i, this));
|
||||
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) {
|
||||
// notification of which column has the focus
|
||||
lastFocussedRow =id;
|
||||
lastFocussedRow = 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.
|
||||
*/
|
||||
@Override
|
||||
@@ -253,7 +277,9 @@ public class GenericDoubleArrayEditor extends JPanel implements PropertyEditor {
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns the current object.
|
||||
/**
|
||||
* Returns the current object.
|
||||
*
|
||||
* @return the current object
|
||||
*/
|
||||
@Override
|
||||
@@ -306,21 +332,27 @@ public class GenericDoubleArrayEditor extends JPanel implements PropertyEditor {
|
||||
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.
|
||||
*/
|
||||
public void addOkListener(ActionListener 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
|
||||
*/
|
||||
public void removeOkListener(ActionListener a) {
|
||||
m_OKButton.removeActionListener(a);
|
||||
}
|
||||
|
||||
/** Returns true since the Object can be shown
|
||||
/**
|
||||
* Returns true since the Object can be shown
|
||||
*
|
||||
* @return true
|
||||
*/
|
||||
@Override
|
||||
@@ -328,7 +360,8 @@ public class GenericDoubleArrayEditor extends JPanel implements PropertyEditor {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Paints a representation of the current classifier.
|
||||
/**
|
||||
* Paints a representation of the current classifier.
|
||||
*
|
||||
* @param gfx the graphics context to use
|
||||
* @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();
|
||||
int vpad = (box.height - fm.getAscent()) / 2;
|
||||
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
|
||||
*/
|
||||
@Override
|
||||
@@ -349,7 +384,9 @@ public class GenericDoubleArrayEditor extends JPanel implements PropertyEditor {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Returns the array editing component.
|
||||
/**
|
||||
* Returns the array editing component.
|
||||
*
|
||||
* @return a value of type 'java.awt.Component'
|
||||
*/
|
||||
@Override
|
||||
|
@@ -18,14 +18,22 @@ import javax.swing.*;
|
||||
*/
|
||||
public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEditor {
|
||||
|
||||
/** Handles property change notification */
|
||||
/**
|
||||
* Handles property change notification
|
||||
*/
|
||||
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);
|
||||
/** The FilePath that is to be edited*/
|
||||
/**
|
||||
* The FilePath that is to be edited
|
||||
*/
|
||||
private PropertyEpsilonConstraint m_EpsilonConstraint;
|
||||
|
||||
/** The gaphix stuff */
|
||||
/**
|
||||
* The gaphix stuff
|
||||
*/
|
||||
private JPanel m_CustomEditor, m_DataPanel, m_ButtonPanel, m_TargetPanel;
|
||||
private JTextField[] m_TargetTextField;
|
||||
private JComboBox m_Objective;
|
||||
@@ -35,7 +43,8 @@ public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEd
|
||||
// compiled code
|
||||
}
|
||||
|
||||
/** This method will init the CustomEditor Panel
|
||||
/**
|
||||
* This method will init the CustomEditor Panel
|
||||
*/
|
||||
private void initCustomEditor() {
|
||||
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_Objective = new JComboBox();
|
||||
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_Objective.addItemListener(this.objectiveAction);
|
||||
@@ -77,7 +86,8 @@ public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEd
|
||||
this.updateEditor();
|
||||
}
|
||||
|
||||
/** This action listener adds an element to DoubleArray
|
||||
/**
|
||||
* This action listener adds an element to DoubleArray
|
||||
*/
|
||||
ItemListener objectiveAction = new ItemListener() {
|
||||
@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() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent event) {
|
||||
}
|
||||
|
||||
@Override
|
||||
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() {
|
||||
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() {
|
||||
double[] tmpT = this.m_EpsilonConstraint.m_TargetValue;
|
||||
int obj = this.m_EpsilonConstraint.m_OptimizeObjective;
|
||||
|
||||
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("Target Value"));
|
||||
this.m_TargetTextField = new JTextField[tmpT.length];
|
||||
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_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_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.
|
||||
*/
|
||||
@Override
|
||||
@@ -160,7 +176,9 @@ public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEd
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns the current object.
|
||||
/**
|
||||
* Returns the current object.
|
||||
*
|
||||
* @return the current object
|
||||
*/
|
||||
@Override
|
||||
@@ -213,21 +231,27 @@ public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEd
|
||||
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.
|
||||
*/
|
||||
public void addOkListener(ActionListener 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
|
||||
*/
|
||||
public void removeOkListener(ActionListener a) {
|
||||
m_OKButton.removeActionListener(a);
|
||||
}
|
||||
|
||||
/** Returns true since the Object can be shown
|
||||
/**
|
||||
* Returns true since the Object can be shown
|
||||
*
|
||||
* @return true
|
||||
*/
|
||||
@Override
|
||||
@@ -235,7 +259,8 @@ public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEd
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Paints a representation of the current classifier.
|
||||
/**
|
||||
* Paints a representation of the current classifier.
|
||||
*
|
||||
* @param gfx the graphics context to use
|
||||
* @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();
|
||||
int vpad = (box.height - fm.getAscent()) / 2;
|
||||
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
|
||||
*/
|
||||
@Override
|
||||
@@ -256,7 +283,9 @@ public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEd
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Returns the array editing component.
|
||||
/**
|
||||
* Returns the array editing component.
|
||||
*
|
||||
* @return a value of type 'java.awt.Component'
|
||||
*/
|
||||
@Override
|
||||
|
@@ -18,14 +18,22 @@ import javax.swing.*;
|
||||
*/
|
||||
public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEditor {
|
||||
|
||||
/** Handles property change notification */
|
||||
/**
|
||||
* Handles property change notification
|
||||
*/
|
||||
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);
|
||||
/** The FilePath that is to be edited*/
|
||||
/**
|
||||
* The FilePath that is to be edited
|
||||
*/
|
||||
private PropertyEpsilonThreshold m_EpsilonThreshhold;
|
||||
|
||||
/** The gaphix stuff */
|
||||
/**
|
||||
* The gaphix stuff
|
||||
*/
|
||||
private JPanel m_CustomEditor, m_DataPanel, m_ButtonPanel, m_TargetPanel;
|
||||
private JTextField[] m_TargetTextField, m_PunishTextField;
|
||||
private JComboBox m_Objective;
|
||||
@@ -35,7 +43,8 @@ public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEdi
|
||||
// compiled code
|
||||
}
|
||||
|
||||
/** This method will init the CustomEditor Panel
|
||||
/**
|
||||
* This method will init the CustomEditor Panel
|
||||
*/
|
||||
private void initCustomEditor() {
|
||||
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_Objective = new JComboBox();
|
||||
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_Objective.addItemListener(this.objectiveAction);
|
||||
@@ -77,7 +86,8 @@ public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEdi
|
||||
this.updateEditor();
|
||||
}
|
||||
|
||||
/** This action listener adds an element to DoubleArray
|
||||
/**
|
||||
* This action listener adds an element to DoubleArray
|
||||
*/
|
||||
ItemListener objectiveAction = new ItemListener() {
|
||||
@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() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent event) {
|
||||
}
|
||||
|
||||
@Override
|
||||
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() {
|
||||
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() {
|
||||
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;
|
||||
|
||||
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("Target Value"));
|
||||
this.m_DataPanel.add(new JLabel("Punishment"));
|
||||
this.m_TargetTextField = new JTextField[tmpT.length];
|
||||
this.m_PunishTextField = new JTextField[tmpT.length];
|
||||
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_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_DataPanel.add(this.m_TargetTextField[i]);
|
||||
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_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.
|
||||
*/
|
||||
@Override
|
||||
@@ -177,7 +193,9 @@ public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEdi
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns the current object.
|
||||
/**
|
||||
* Returns the current object.
|
||||
*
|
||||
* @return the current object
|
||||
*/
|
||||
@Override
|
||||
@@ -230,21 +248,27 @@ public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEdi
|
||||
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.
|
||||
*/
|
||||
public void addOkListener(ActionListener 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
|
||||
*/
|
||||
public void removeOkListener(ActionListener a) {
|
||||
m_OKButton.removeActionListener(a);
|
||||
}
|
||||
|
||||
/** Returns true since the Object can be shown
|
||||
/**
|
||||
* Returns true since the Object can be shown
|
||||
*
|
||||
* @return true
|
||||
*/
|
||||
@Override
|
||||
@@ -252,7 +276,8 @@ public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEdi
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Paints a representation of the current classifier.
|
||||
/**
|
||||
* Paints a representation of the current classifier.
|
||||
*
|
||||
* @param gfx the graphics context to use
|
||||
* @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();
|
||||
int vpad = (box.height - fm.getAscent()) / 2;
|
||||
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
|
||||
*/
|
||||
@Override
|
||||
@@ -273,7 +300,9 @@ public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEdi
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Returns the array editing component.
|
||||
/**
|
||||
* Returns the array editing component.
|
||||
*
|
||||
* @return a value of type 'java.awt.Component'
|
||||
*/
|
||||
@Override
|
||||
|
@@ -23,14 +23,22 @@ import javax.swing.SwingConstants;
|
||||
*/
|
||||
public class GenericFilePathEditor extends JPanel implements PropertyEditor {
|
||||
|
||||
/** Handles property change notification */
|
||||
/**
|
||||
* Handles property change notification
|
||||
*/
|
||||
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);
|
||||
/** The FilePath that is to be edited*/
|
||||
/**
|
||||
* The FilePath that is to be edited
|
||||
*/
|
||||
private PropertyFilePath m_FilePath;
|
||||
|
||||
/** The gaphix stuff */
|
||||
/**
|
||||
* The gaphix stuff
|
||||
*/
|
||||
private JFileChooser m_FileChooser;
|
||||
private JPanel m_Panel;
|
||||
|
||||
@@ -38,7 +46,9 @@ public class GenericFilePathEditor extends JPanel implements PropertyEditor {
|
||||
// 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.
|
||||
*/
|
||||
@Override
|
||||
@@ -48,7 +58,9 @@ public class GenericFilePathEditor extends JPanel implements PropertyEditor {
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns the current object.
|
||||
/**
|
||||
* Returns the current object.
|
||||
*
|
||||
* @return the current object
|
||||
*/
|
||||
@Override
|
||||
@@ -101,7 +113,9 @@ public class GenericFilePathEditor extends JPanel implements PropertyEditor {
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
}
|
||||
|
||||
/** Returns true since the Object can be shown
|
||||
/**
|
||||
* Returns true since the Object can be shown
|
||||
*
|
||||
* @return true
|
||||
*/
|
||||
@Override
|
||||
@@ -109,7 +123,8 @@ public class GenericFilePathEditor extends JPanel implements PropertyEditor {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Paints a representation of the current classifier.
|
||||
/**
|
||||
* Paints a representation of the current classifier.
|
||||
*
|
||||
* @param gfx the graphics context to use
|
||||
* @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();
|
||||
int vpad = (box.height - fm.getAscent()) / 2;
|
||||
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
|
||||
*/
|
||||
@Override
|
||||
@@ -130,7 +147,9 @@ public class GenericFilePathEditor extends JPanel implements PropertyEditor {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Returns the array editing component.
|
||||
/**
|
||||
* Returns the array editing component.
|
||||
*
|
||||
* @return a value of type 'java.awt.Component'
|
||||
*/
|
||||
@Override
|
||||
@@ -145,7 +164,8 @@ public class GenericFilePathEditor extends JPanel implements PropertyEditor {
|
||||
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.
|
||||
*/
|
||||
ActionListener fileChooserAction = new ActionListener() {
|
||||
|
@@ -21,14 +21,22 @@ import javax.swing.*;
|
||||
*/
|
||||
public class GenericIntArrayEditor extends JPanel implements PropertyEditor {
|
||||
|
||||
/** Handles property change notification */
|
||||
/**
|
||||
* Handles property change notification
|
||||
*/
|
||||
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);
|
||||
/** The FilePath that is to be edited*/
|
||||
/**
|
||||
* The FilePath that is to be edited
|
||||
*/
|
||||
private PropertyIntArray m_IntArray;
|
||||
|
||||
/** The gaphix stuff */
|
||||
/**
|
||||
* The gaphix stuff
|
||||
*/
|
||||
private JPanel m_CustomEditor, m_DataPanel, m_ButtonPanel;
|
||||
private JTextField[] m_InputTextField;
|
||||
private JButton m_OKButton;
|
||||
@@ -37,7 +45,8 @@ public class GenericIntArrayEditor extends JPanel implements PropertyEditor {
|
||||
// compiled code
|
||||
}
|
||||
|
||||
/** This method will init the CustomEditor Panel
|
||||
/**
|
||||
* This method will init the CustomEditor Panel
|
||||
*/
|
||||
private void initCustomEditor() {
|
||||
this.m_CustomEditor = new JPanel();
|
||||
@@ -69,12 +78,14 @@ public class GenericIntArrayEditor extends JPanel implements PropertyEditor {
|
||||
this.updateEditor();
|
||||
}
|
||||
|
||||
/** This action listener reads all values
|
||||
/**
|
||||
* This action listener reads all values
|
||||
*/
|
||||
KeyListener readIntArrayAction = new KeyListener() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent event) {
|
||||
}
|
||||
|
||||
@Override
|
||||
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() {
|
||||
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() {
|
||||
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_InputTextField = new JTextField[tmpD.length];
|
||||
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_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_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.
|
||||
*/
|
||||
@Override
|
||||
@@ -136,7 +151,9 @@ public class GenericIntArrayEditor extends JPanel implements PropertyEditor {
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns the current object.
|
||||
/**
|
||||
* Returns the current object.
|
||||
*
|
||||
* @return the current object
|
||||
*/
|
||||
@Override
|
||||
@@ -189,21 +206,27 @@ public class GenericIntArrayEditor extends JPanel implements PropertyEditor {
|
||||
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.
|
||||
*/
|
||||
public void addOkListener(ActionListener 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
|
||||
*/
|
||||
public void removeOkListener(ActionListener a) {
|
||||
m_OKButton.removeActionListener(a);
|
||||
}
|
||||
|
||||
/** Returns true since the Object can be shown
|
||||
/**
|
||||
* Returns true since the Object can be shown
|
||||
*
|
||||
* @return true
|
||||
*/
|
||||
@Override
|
||||
@@ -211,7 +234,8 @@ public class GenericIntArrayEditor extends JPanel implements PropertyEditor {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Paints a representation of the current classifier.
|
||||
/**
|
||||
* Paints a representation of the current classifier.
|
||||
*
|
||||
* @param gfx the graphics context to use
|
||||
* @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();
|
||||
int vpad = (box.height - fm.getAscent()) / 2;
|
||||
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
|
||||
*/
|
||||
@Override
|
||||
@@ -232,7 +258,9 @@ public class GenericIntArrayEditor extends JPanel implements PropertyEditor {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Returns the array editing component.
|
||||
/**
|
||||
* Returns the array editing component.
|
||||
*
|
||||
* @return a value of type 'java.awt.Component'
|
||||
*/
|
||||
@Override
|
||||
|
@@ -8,6 +8,7 @@ package eva2.gui.editor;
|
||||
import eva2.EvAInfo;
|
||||
import eva2.gui.GOEPanel;
|
||||
import eva2.tools.ReflectPackage;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.FontMetrics;
|
||||
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
|
||||
* well.
|
||||
*
|
||||
* @see ReflectPackage.getAssignableClassesInPackage
|
||||
* @param className
|
||||
* @return
|
||||
* @see ReflectPackage.getAssignableClassesInPackage
|
||||
*/
|
||||
public static ArrayList<String> getClassesFromClassPath(String className, ArrayList<Class<?>> instances) {
|
||||
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.
|
||||
*
|
||||
* @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
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
|
@@ -4,12 +4,12 @@ import eva2.gui.PropertySelectableList;
|
||||
|
||||
/**
|
||||
* An editor for a selectable List.
|
||||
*
|
||||
*/
|
||||
public class GenericObjectListSelectionEditor extends AbstractListSelectionEditor {
|
||||
private PropertySelectableList objList;
|
||||
|
||||
public GenericObjectListSelectionEditor() {}
|
||||
public GenericObjectListSelectionEditor() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getElementCount() {
|
||||
@@ -28,11 +28,11 @@ public class GenericObjectListSelectionEditor extends AbstractListSelectionEdito
|
||||
|
||||
@Override
|
||||
protected boolean actionOnSelect() {
|
||||
boolean changed=false;
|
||||
boolean changed = false;
|
||||
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());
|
||||
changed=true;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
@@ -49,7 +49,9 @@ public class GenericObjectListSelectionEditor extends AbstractListSelectionEdito
|
||||
}
|
||||
}
|
||||
|
||||
/** Retruns the current object.
|
||||
/**
|
||||
* Retruns the current object.
|
||||
*
|
||||
* @return the current object
|
||||
*/
|
||||
@Override
|
||||
|
@@ -8,6 +8,7 @@ import eva2.optimization.problems.InterfaceOptimizationTarget;
|
||||
import eva2.optimization.tools.AbstractObjectEditor;
|
||||
import eva2.optimization.tools.GeneralGOEProperty;
|
||||
import eva2.tools.BasicResourceLoader;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
@@ -44,14 +45,22 @@ import javax.swing.SwingConstants;
|
||||
*/
|
||||
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);
|
||||
/** 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);
|
||||
/** The FilePath that is to be edited*/
|
||||
/**
|
||||
* The FilePath that is to be edited
|
||||
*/
|
||||
private PropertyOptimizationObjectives m_OptimizationObjectives;
|
||||
|
||||
/** The gaphix stuff */
|
||||
/**
|
||||
* The gaphix stuff
|
||||
*/
|
||||
private JComponent m_Editor;
|
||||
private JPanel m_TargetList;
|
||||
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() {
|
||||
m_self = this;
|
||||
@@ -112,7 +122,7 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
|
||||
|
||||
// Some description would be nice
|
||||
JTextArea jt = new JTextArea();
|
||||
jt.setFont(new Font("SansSerif", Font.PLAIN,12));
|
||||
jt.setFont(new Font("SansSerif", Font.PLAIN, 12));
|
||||
jt.setEditable(false);
|
||||
jt.setLineWrap(true);
|
||||
jt.setWrapStyleWord(true);
|
||||
@@ -137,8 +147,8 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
|
||||
this.updateEditor();
|
||||
}
|
||||
|
||||
/** This method updates the server list
|
||||
*
|
||||
/**
|
||||
* This method updates the server list
|
||||
*/
|
||||
private void updateTargetList() {
|
||||
BasicResourceLoader loader = BasicResourceLoader.instance();
|
||||
@@ -152,7 +162,7 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
|
||||
this.m_Delete = new JButton[list.length];
|
||||
String[] cups = new String[8];
|
||||
for (int i = 0; i < cups.length; i++) {
|
||||
cups[i] = ""+(i+1);
|
||||
cups[i] = "" + (i + 1);
|
||||
}
|
||||
// The head title
|
||||
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() {
|
||||
@Override
|
||||
@@ -206,12 +217,13 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
|
||||
}
|
||||
};
|
||||
|
||||
/** This action listener,...
|
||||
/**
|
||||
* This action listener,...
|
||||
*/
|
||||
ActionListener addTarget = new ActionListener() {
|
||||
@Override
|
||||
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;
|
||||
GeneralGOEProperty[] newEdit = new GeneralGOEProperty[l];
|
||||
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() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
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++) {
|
||||
if (event.getSource().equals(m_Delete[i])) {
|
||||
m_OptimizationObjectives.removeTarget(i);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
newEdit[j] = m_Editors[i];
|
||||
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() {
|
||||
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.
|
||||
*/
|
||||
@Override
|
||||
public void setValue(Object o) {
|
||||
if (o instanceof PropertyOptimizationObjectives) {
|
||||
this.m_OptimizationObjectives= (PropertyOptimizationObjectives) o;
|
||||
this.m_OptimizationObjectives = (PropertyOptimizationObjectives) o;
|
||||
this.updateEditor();
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns the current object.
|
||||
/**
|
||||
* Returns the current object.
|
||||
*
|
||||
* @return the current object
|
||||
*/
|
||||
@Override
|
||||
@@ -327,21 +344,27 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
|
||||
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.
|
||||
*/
|
||||
public void addOkListener(ActionListener 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
|
||||
*/
|
||||
public void removeOkListener(ActionListener a) {
|
||||
//m_OKButton.removeActionListener(a);
|
||||
}
|
||||
|
||||
/** Returns true since the Object can be shown
|
||||
/**
|
||||
* Returns true since the Object can be shown
|
||||
*
|
||||
* @return true
|
||||
*/
|
||||
@Override
|
||||
@@ -349,7 +372,8 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Paints a representation of the current classifier.
|
||||
/**
|
||||
* Paints a representation of the current classifier.
|
||||
*
|
||||
* @param gfx the graphics context to use
|
||||
* @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();
|
||||
int vpad = (box.height - fm.getAscent()) / 2;
|
||||
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
|
||||
*/
|
||||
@Override
|
||||
@@ -370,7 +396,9 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Returns the array editing component.
|
||||
/**
|
||||
* Returns the array editing component.
|
||||
*
|
||||
* @return a value of type 'java.awt.Component'
|
||||
*/
|
||||
@Override
|
||||
@@ -381,7 +409,8 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
|
||||
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.
|
||||
*/
|
||||
public void updateCenterComponent(PropertyChangeEvent evt) {
|
||||
@@ -389,7 +418,9 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
|
||||
this.updateEditor();
|
||||
}
|
||||
|
||||
/********************************* java.beans.PropertyChangeListener *************************/
|
||||
/**
|
||||
* ****************************** java.beans.PropertyChangeListener ************************
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
@@ -406,8 +437,11 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
|
||||
}
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
}
|
||||
/** This will wait for the GenericObjectEditor to finish
|
||||
|
||||
/**
|
||||
* This will wait for the GenericObjectEditor to finish
|
||||
* editing an object.
|
||||
*
|
||||
* @param evt
|
||||
*/
|
||||
@Override
|
||||
@@ -417,7 +451,7 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
|
||||
InterfaceOptimizationObjective[] list = this.m_OptimizationObjectives.getSelectedTargets();
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
if (oldVal.equals(list[i])) {
|
||||
list[i] = (InterfaceOptimizationObjective)newVal;
|
||||
list[i] = (InterfaceOptimizationObjective) newVal;
|
||||
this.m_Editors[i].m_Name = list[i].getName();
|
||||
try {
|
||||
this.m_Editors[i].m_Value = list[i];
|
||||
|
@@ -7,6 +7,7 @@ import eva2.optimization.problems.InterfaceOptimizationObjective;
|
||||
import eva2.optimization.tools.AbstractObjectEditor;
|
||||
import eva2.optimization.tools.GeneralGOEProperty;
|
||||
import eva2.tools.BasicResourceLoader;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
@@ -47,14 +48,22 @@ import javax.swing.SwingConstants;
|
||||
*/
|
||||
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);
|
||||
/** 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);
|
||||
/** The FilePath that is to be edited*/
|
||||
/**
|
||||
* The FilePath that is to be edited
|
||||
*/
|
||||
private PropertyOptimizationObjectivesWithParam m_OptimizationObjectivesWithWeights;
|
||||
|
||||
/** The gaphix stuff */
|
||||
/**
|
||||
* The gaphix stuff
|
||||
*/
|
||||
private JComponent m_Editor;
|
||||
private JPanel m_TargetList;
|
||||
private JTextField[] m_Weights;
|
||||
@@ -68,7 +77,8 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
||||
m_self = this;
|
||||
}
|
||||
|
||||
/** This method will init the CustomEditor Panel
|
||||
/**
|
||||
* This method will init the CustomEditor Panel
|
||||
*/
|
||||
private void initCustomEditor() {
|
||||
m_self = this;
|
||||
@@ -110,7 +120,7 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
||||
|
||||
// The Button Panel
|
||||
JPanel buttonPanel = new JPanel();
|
||||
buttonPanel.setLayout(new GridLayout(1,2));
|
||||
buttonPanel.setLayout(new GridLayout(1, 2));
|
||||
JButton addButton = new JButton("Add Opt. Target");
|
||||
JButton normButton = new JButton("Normalize Weights");
|
||||
normButton.setEnabled(this.m_OptimizationObjectivesWithWeights.isNormalizationEnabled());
|
||||
@@ -123,7 +133,7 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
||||
|
||||
// Some description would be nice
|
||||
JTextArea jt = new JTextArea();
|
||||
jt.setFont(new Font("SansSerif", Font.PLAIN,12));
|
||||
jt.setFont(new Font("SansSerif", Font.PLAIN, 12));
|
||||
jt.setEditable(false);
|
||||
jt.setLineWrap(true);
|
||||
jt.setWrapStyleWord(true);
|
||||
@@ -149,8 +159,8 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
||||
this.updateEditor();
|
||||
}
|
||||
|
||||
/** This method updates the server list
|
||||
*
|
||||
/**
|
||||
* This method updates the server list
|
||||
*/
|
||||
private void updateTargetList() {
|
||||
BasicResourceLoader loader = BasicResourceLoader.instance();
|
||||
@@ -166,7 +176,7 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
||||
this.m_Delete = new JButton[list.length];
|
||||
String[] cups = new String[8];
|
||||
for (int i = 0; i < cups.length; i++) {
|
||||
cups[i] = ""+(i+1);
|
||||
cups[i] = "" + (i + 1);
|
||||
}
|
||||
// The head title
|
||||
gbc.anchor = GridBagConstraints.WEST;
|
||||
@@ -190,7 +200,7 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
||||
gbc.fill = GridBagConstraints.BOTH;
|
||||
gbc.gridx = 0;
|
||||
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_TargetList.add(this.m_Weights[i], gbc);
|
||||
// the status indicator
|
||||
@@ -222,7 +232,8 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
||||
}
|
||||
}
|
||||
|
||||
/** This action listener,...
|
||||
/**
|
||||
* This action listener,...
|
||||
*/
|
||||
ActionListener updateTargets = new ActionListener() {
|
||||
@Override
|
||||
@@ -231,12 +242,13 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
||||
}
|
||||
};
|
||||
|
||||
/** This action listener,...
|
||||
/**
|
||||
* This action listener,...
|
||||
*/
|
||||
ActionListener addTarget = new ActionListener() {
|
||||
@Override
|
||||
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;
|
||||
GeneralGOEProperty[] newEdit = new GeneralGOEProperty[l];
|
||||
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() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
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++) {
|
||||
if (event.getSource().equals(m_Delete[i])) {
|
||||
m_OptimizationObjectivesWithWeights.removeTarget(i);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
newEdit[j] = m_Editors[i];
|
||||
j++;
|
||||
}
|
||||
@@ -290,7 +302,8 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
||||
}
|
||||
};
|
||||
|
||||
/** This action listener,...
|
||||
/**
|
||||
* This action listener,...
|
||||
*/
|
||||
ActionListener normalizeWeights = new ActionListener() {
|
||||
@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() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent event) {
|
||||
}
|
||||
|
||||
@Override
|
||||
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() {
|
||||
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.
|
||||
*/
|
||||
@Override
|
||||
public void setValue(Object o) {
|
||||
if (o instanceof PropertyOptimizationObjectivesWithParam) {
|
||||
this.m_OptimizationObjectivesWithWeights= (PropertyOptimizationObjectivesWithParam) o;
|
||||
this.m_OptimizationObjectivesWithWeights = (PropertyOptimizationObjectivesWithParam) o;
|
||||
this.updateEditor();
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns the current object.
|
||||
/**
|
||||
* Returns the current object.
|
||||
*
|
||||
* @return the current object
|
||||
*/
|
||||
@Override
|
||||
@@ -398,21 +418,27 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
||||
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.
|
||||
*/
|
||||
public void addOkListener(ActionListener 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
|
||||
*/
|
||||
public void removeOkListener(ActionListener a) {
|
||||
//m_OKButton.removeActionListener(a);
|
||||
}
|
||||
|
||||
/** Returns true since the Object can be shown
|
||||
/**
|
||||
* Returns true since the Object can be shown
|
||||
*
|
||||
* @return true
|
||||
*/
|
||||
@Override
|
||||
@@ -420,7 +446,8 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Paints a representation of the current classifier.
|
||||
/**
|
||||
* Paints a representation of the current classifier.
|
||||
*
|
||||
* @param gfx the graphics context to use
|
||||
* @param box the area we are allowed to paint into
|
||||
@@ -430,10 +457,12 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
||||
FontMetrics fm = gfx.getFontMetrics();
|
||||
int vpad = (box.height - fm.getAscent()) / 2;
|
||||
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
|
||||
*/
|
||||
@Override
|
||||
@@ -441,7 +470,9 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Returns the array editing component.
|
||||
/**
|
||||
* Returns the array editing component.
|
||||
*
|
||||
* @return a value of type 'java.awt.Component'
|
||||
*/
|
||||
@Override
|
||||
@@ -452,7 +483,8 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
||||
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.
|
||||
*/
|
||||
public void updateCenterComponent(PropertyChangeEvent evt) {
|
||||
@@ -460,7 +492,9 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
||||
this.updateEditor();
|
||||
}
|
||||
|
||||
/********************************* java.beans.PropertyChangeListener *************************/
|
||||
/**
|
||||
* ****************************** java.beans.PropertyChangeListener ************************
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
@@ -477,8 +511,11 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
||||
}
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
}
|
||||
/** This will wait for the GenericObjectEditor to finish
|
||||
|
||||
/**
|
||||
* This will wait for the GenericObjectEditor to finish
|
||||
* editing an object.
|
||||
*
|
||||
* @param evt
|
||||
*/
|
||||
@Override
|
||||
@@ -488,7 +525,7 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
||||
InterfaceOptimizationObjective[] list = this.m_OptimizationObjectivesWithWeights.getSelectedTargets();
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
if (oldVal.equals(list[i])) {
|
||||
list[i] = (InterfaceOptimizationObjective)newVal;
|
||||
list[i] = (InterfaceOptimizationObjective) newVal;
|
||||
this.m_Editors[i].m_Name = list[i].getName();
|
||||
try {
|
||||
this.m_Editors[i].m_Value = list[i];
|
||||
|
@@ -18,14 +18,22 @@ import javax.swing.*;
|
||||
*/
|
||||
public class GenericWeigthedLPTchebycheffEditor extends JPanel implements PropertyEditor {
|
||||
|
||||
/** Handles property change notification */
|
||||
/**
|
||||
* Handles property change notification
|
||||
*/
|
||||
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);
|
||||
/** The FilePath that is to be edited*/
|
||||
/**
|
||||
* The FilePath that is to be edited
|
||||
*/
|
||||
private PropertyWeightedLPTchebycheff m_WLPT;
|
||||
|
||||
/** The gaphix stuff */
|
||||
/**
|
||||
* The gaphix stuff
|
||||
*/
|
||||
private JPanel m_CustomEditor, m_DataPanel, m_ButtonPanel, m_TargetPanel;
|
||||
private JTextField[] m_IdealTextField, m_WeightTextField;
|
||||
private JTextField m_PValue;
|
||||
@@ -35,7 +43,8 @@ public class GenericWeigthedLPTchebycheffEditor extends JPanel implements Proper
|
||||
// compiled code
|
||||
}
|
||||
|
||||
/** This method will init the CustomEditor Panel
|
||||
/**
|
||||
* This method will init the CustomEditor Panel
|
||||
*/
|
||||
private void initCustomEditor() {
|
||||
this.m_CustomEditor = new JPanel();
|
||||
@@ -45,7 +54,7 @@ public class GenericWeigthedLPTchebycheffEditor extends JPanel implements Proper
|
||||
this.m_TargetPanel = new JPanel();
|
||||
this.m_TargetPanel.setLayout(new GridLayout(1, 2));
|
||||
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_PValue.addKeyListener(this.readDoubleAction);
|
||||
this.m_CustomEditor.add(this.m_TargetPanel, BorderLayout.NORTH);
|
||||
@@ -74,12 +83,14 @@ public class GenericWeigthedLPTchebycheffEditor extends JPanel implements Proper
|
||||
this.updateEditor();
|
||||
}
|
||||
|
||||
/** This action listener reads all values
|
||||
/**
|
||||
* This action listener reads all values
|
||||
*/
|
||||
KeyListener readDoubleAction = new KeyListener() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent event) {
|
||||
}
|
||||
|
||||
@Override
|
||||
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() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent event) {
|
||||
}
|
||||
|
||||
@Override
|
||||
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() {
|
||||
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() {
|
||||
double[] tmpT = this.m_WLPT.m_IdealValue;
|
||||
double[] tmpP = this.m_WLPT.m_Weights;
|
||||
int obj = this.m_WLPT.m_P;
|
||||
|
||||
this.m_PValue.setText(""+obj);
|
||||
this.m_PValue.setText("" + obj);
|
||||
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("Ideal Value"));
|
||||
this.m_DataPanel.add(new JLabel("Weights"));
|
||||
this.m_IdealTextField = new JTextField[tmpT.length];
|
||||
this.m_WeightTextField = new JTextField[tmpT.length];
|
||||
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_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_DataPanel.add(this.m_IdealTextField[i]);
|
||||
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_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.
|
||||
*/
|
||||
@Override
|
||||
@@ -184,7 +201,9 @@ public class GenericWeigthedLPTchebycheffEditor extends JPanel implements Proper
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns the current object.
|
||||
/**
|
||||
* Returns the current object.
|
||||
*
|
||||
* @return the current object
|
||||
*/
|
||||
@Override
|
||||
@@ -237,21 +256,27 @@ public class GenericWeigthedLPTchebycheffEditor extends JPanel implements Proper
|
||||
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.
|
||||
*/
|
||||
public void addOkListener(ActionListener 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
|
||||
*/
|
||||
public void removeOkListener(ActionListener a) {
|
||||
m_OKButton.removeActionListener(a);
|
||||
}
|
||||
|
||||
/** Returns true since the Object can be shown
|
||||
/**
|
||||
* Returns true since the Object can be shown
|
||||
*
|
||||
* @return true
|
||||
*/
|
||||
@Override
|
||||
@@ -259,7 +284,8 @@ public class GenericWeigthedLPTchebycheffEditor extends JPanel implements Proper
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Paints a representation of the current classifier.
|
||||
/**
|
||||
* Paints a representation of the current classifier.
|
||||
*
|
||||
* @param gfx the graphics context to use
|
||||
* @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();
|
||||
int vpad = (box.height - fm.getAscent()) / 2;
|
||||
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
|
||||
*/
|
||||
@Override
|
||||
@@ -280,7 +308,9 @@ public class GenericWeigthedLPTchebycheffEditor extends JPanel implements Proper
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Returns the array editing component.
|
||||
/**
|
||||
* Returns the array editing component.
|
||||
*
|
||||
* @return a value of type 'java.awt.Component'
|
||||
*/
|
||||
@Override
|
||||
|
@@ -12,6 +12,7 @@ import java.beans.*;
|
||||
* <p>Description: </p>
|
||||
* <p>Copyright: Copyright (c) 2003</p>
|
||||
* <p>Company: </p>
|
||||
*
|
||||
* @author not attributable
|
||||
* @version 1.0
|
||||
*/
|
||||
@@ -20,19 +21,35 @@ public class MultiLineStringEditor implements PropertyEditor {
|
||||
protected MultiLineString value; // The value we will be editing.
|
||||
|
||||
@Override
|
||||
public void setValue(Object o) { value=(MultiLineString) o;}
|
||||
public void setValue(Object o) {
|
||||
value = (MultiLineString) o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() { return value; }
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAsText(String s) { value.setString(s); }
|
||||
public void setAsText(String s) {
|
||||
value.setString(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAsText() { return value.getString(); }
|
||||
public String getAsText() {
|
||||
return value.getString();
|
||||
}
|
||||
|
||||
@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.
|
||||
@Override
|
||||
public boolean supportsCustomEditor() { return true; }
|
||||
public boolean supportsCustomEditor() {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 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
|
||||
@@ -56,18 +73,22 @@ public class MultiLineStringEditor implements PropertyEditor {
|
||||
// Just print some instructions and hope they fit in the in the box.
|
||||
// This could be more sophisticated.
|
||||
@Override
|
||||
public boolean isPaintable() { return true; }
|
||||
public boolean isPaintable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintValue(Graphics g, Rectangle 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
|
||||
// ought to add any necessary escape sequences.
|
||||
@Override
|
||||
public String getJavaInitializationString() { return "\"" + value + "\""; }
|
||||
public String getJavaInitializationString() {
|
||||
return "\"" + value + "\"";
|
||||
}
|
||||
|
||||
// This code uses the PropertyChangeSupport class to maintain a list of
|
||||
// listeners interested in the edits we make to the value.
|
||||
|
@@ -9,8 +9,10 @@ package eva2.gui.editor;
|
||||
* $Date: 2007-10-23 13:43:24 +0200 (Tue, 23 Oct 2007) $
|
||||
* $Author: mkron $
|
||||
*/
|
||||
|
||||
import eva2.gui.PropertySheetPanelStat;
|
||||
import eva2.optimization.stat.GenericStatistics;
|
||||
|
||||
import java.awt.*;
|
||||
import java.beans.*;
|
||||
import javax.swing.*;
|
||||
|
@@ -62,13 +62,13 @@ public class StringSelectionEditor extends AbstractListSelectionEditor {
|
||||
public String getAsText() {
|
||||
StringBuffer sbuf = new StringBuffer("{");
|
||||
boolean first = true;
|
||||
for (int i=0; i<getElementCount(); i++) {
|
||||
for (int i = 0; i < getElementCount(); i++) {
|
||||
if (isElementSelected(i)) {
|
||||
if (!first) {
|
||||
sbuf.append(", ");
|
||||
}
|
||||
sbuf.append(getElementName(i));
|
||||
first=false;
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
sbuf.append("}");
|
||||
@@ -77,7 +77,7 @@ public class StringSelectionEditor extends AbstractListSelectionEditor {
|
||||
|
||||
@Override
|
||||
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)));
|
||||
}
|
||||
}
|
||||
|
@@ -15,6 +15,7 @@ import eva2.gui.PropertyValueSelector;
|
||||
import eva2.tools.BasicResourceLoader;
|
||||
import eva2.tools.SelectedTag;
|
||||
import eva2.tools.Tag;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.WindowAdapter;
|
||||
@@ -22,6 +23,7 @@ import java.awt.event.WindowEvent;
|
||||
import java.beans.PropertyEditorManager;
|
||||
import java.beans.PropertyEditorSupport;
|
||||
import javax.swing.JFrame;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -34,8 +36,8 @@ public class TagEditor extends PropertyEditorSupport {
|
||||
@Override
|
||||
public String getJavaInitializationString() {
|
||||
|
||||
SelectedTag s = (SelectedTag)getValue();
|
||||
Tag [] tags = s.getTags();
|
||||
SelectedTag s = (SelectedTag) getValue();
|
||||
Tag[] tags = s.getTags();
|
||||
String result = "new SelectedTag("
|
||||
+ s.getSelectedTag().getID()
|
||||
+ ", {\n";
|
||||
@@ -58,7 +60,7 @@ public class TagEditor extends PropertyEditorSupport {
|
||||
*/
|
||||
@Override
|
||||
public String getAsText() {
|
||||
SelectedTag s = (SelectedTag)getValue();
|
||||
SelectedTag s = (SelectedTag) getValue();
|
||||
return s.getSelectedTag().getString();
|
||||
}
|
||||
|
||||
@@ -66,12 +68,13 @@ public class TagEditor extends PropertyEditorSupport {
|
||||
* Sets the current property value as text.
|
||||
*
|
||||
* @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
|
||||
public void setAsText(String text) throws java.lang.IllegalArgumentException {
|
||||
SelectedTag s = (SelectedTag)getValue();
|
||||
Tag [] tags = s.getTags();
|
||||
SelectedTag s = (SelectedTag) getValue();
|
||||
Tag[] tags = s.getTags();
|
||||
try {
|
||||
for (int i = 0; i < tags.length; i++) {
|
||||
if (text.equals(tags[i].getString())) {
|
||||
@@ -92,9 +95,9 @@ public class TagEditor extends PropertyEditorSupport {
|
||||
@Override
|
||||
public String[] getTags() {
|
||||
|
||||
SelectedTag s = (SelectedTag)getValue();
|
||||
Tag [] tags = s.getTags();
|
||||
String [] result = new String [tags.length];
|
||||
SelectedTag s = (SelectedTag) getValue();
|
||||
Tag[] tags = s.getTags();
|
||||
String[] result = new String[tags.length];
|
||||
for (int i = 0; i < tags.length; i++) {
|
||||
result[i] = tags[i].getString
|
||||
();
|
||||
@@ -107,10 +110,10 @@ public class TagEditor extends PropertyEditorSupport {
|
||||
*
|
||||
* @param args ignored
|
||||
*/
|
||||
public static void main(String [] args) {
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
PropertyEditorManager.registerEditor(SelectedTag.class,TagEditor.class);
|
||||
Tag [] tags = {
|
||||
PropertyEditorManager.registerEditor(SelectedTag.class, TagEditor.class);
|
||||
Tag[] tags = {
|
||||
new Tag(0, "First option"),
|
||||
new Tag(1, "Second option"),
|
||||
new Tag(2, "Third option"),
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package eva2.gui.plot;
|
||||
|
||||
|
||||
|
||||
import eva2.tools.chart2d.DArray;
|
||||
import eva2.tools.chart2d.DBorder;
|
||||
import eva2.tools.chart2d.DComponent;
|
||||
@@ -11,6 +10,7 @@ import eva2.tools.chart2d.DPoint;
|
||||
import eva2.tools.chart2d.DPointIcon;
|
||||
import eva2.tools.chart2d.DPointSet;
|
||||
import eva2.tools.chart2d.DRectangle;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
@@ -25,74 +25,61 @@ import java.util.ArrayList;
|
||||
* Time: 16:17:35
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class DPointSetMultiIcon extends DComponent
|
||||
{
|
||||
public class DPointSetMultiIcon extends DComponent {
|
||||
//~ Instance fields ////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* this class stores the jump positions (see this.jump)
|
||||
*/
|
||||
class JumpManager
|
||||
{
|
||||
class JumpManager {
|
||||
protected int index = -1;
|
||||
protected ArrayList<Integer> jumps = new ArrayList<Integer>();
|
||||
|
||||
public void addJump()
|
||||
{
|
||||
public void addJump() {
|
||||
jumps.add(getSize());
|
||||
}
|
||||
|
||||
public boolean hasMoreIntervals()
|
||||
{
|
||||
public boolean hasMoreIntervals() {
|
||||
return index < jumps.size();
|
||||
}
|
||||
|
||||
public int[] nextInterval()
|
||||
{
|
||||
public int[] nextInterval() {
|
||||
int no_jumps = jumps.size();
|
||||
|
||||
if (index >= no_jumps)
|
||||
{
|
||||
if (index >= no_jumps) {
|
||||
throw new ArrayIndexOutOfBoundsException(
|
||||
"No more intervals in JumpManager");
|
||||
}
|
||||
|
||||
int[] inter = new int[2];
|
||||
|
||||
if (index == -1)
|
||||
{
|
||||
if (index == -1) {
|
||||
inter[0] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
inter[0] = jumps.get(index);
|
||||
}
|
||||
|
||||
index++;
|
||||
|
||||
if (index < no_jumps)
|
||||
{
|
||||
if (index < no_jumps) {
|
||||
inter[1] = jumps.get(index);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
inter[1] = getSize();
|
||||
}
|
||||
|
||||
return inter;
|
||||
}
|
||||
|
||||
public void reset()
|
||||
{
|
||||
public void reset() {
|
||||
index = -1;
|
||||
jumps.clear();
|
||||
}
|
||||
|
||||
public void restore()
|
||||
{
|
||||
public void restore() {
|
||||
index = -1;
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean connectedMI;
|
||||
protected DPointIcon iconMI = null;
|
||||
protected DPointSetMultiIcon.JumpManager jumperMI = new DPointSetMultiIcon.JumpManager();
|
||||
@@ -104,15 +91,12 @@ public class DPointSetMultiIcon extends DComponent
|
||||
|
||||
protected DIntDoubleMap yMI;
|
||||
|
||||
public DPointSetMultiIcon()
|
||||
{
|
||||
public DPointSetMultiIcon() {
|
||||
this(10, 2);
|
||||
}
|
||||
|
||||
public DPointSetMultiIcon(DIntDoubleMap x_values, DIntDoubleMap y_values)
|
||||
{
|
||||
if (x_values.getSize() != y_values.getSize())
|
||||
{
|
||||
public DPointSetMultiIcon(DIntDoubleMap x_values, DIntDoubleMap y_values) {
|
||||
if (x_values.getSize() != y_values.getSize()) {
|
||||
throw new IllegalArgumentException(
|
||||
"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));
|
||||
}
|
||||
|
||||
public DPointSetMultiIcon(int initial_capacity)
|
||||
{
|
||||
public DPointSetMultiIcon(int initial_capacity) {
|
||||
this(initial_capacity, 2);
|
||||
}
|
||||
|
||||
//~ Methods ////////////////////////////////////////////////////////////////
|
||||
|
||||
public DPointSetMultiIcon(int initial_capacity, int length_multiplier)
|
||||
{
|
||||
public DPointSetMultiIcon(int initial_capacity, int length_multiplier) {
|
||||
this(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));
|
||||
}
|
||||
|
||||
public void addDPoint(DPoint p)
|
||||
{
|
||||
public void addDPoint(DPoint p) {
|
||||
xMI.addImage(p.x);
|
||||
yMI.addImage(p.y);
|
||||
m_IconsMI.add(p.getIcon());
|
||||
@@ -156,10 +136,8 @@ public class DPointSetMultiIcon extends DComponent
|
||||
* @param index the index of the DPoint
|
||||
* @return the DPoint at the given index
|
||||
*/
|
||||
public DPoint getDPoint(int index)
|
||||
{
|
||||
if (index >= xMI.getSize())
|
||||
{
|
||||
public DPoint getDPoint(int index) {
|
||||
if (index >= xMI.getSize()) {
|
||||
throw new ArrayIndexOutOfBoundsException(index);
|
||||
}
|
||||
|
||||
@@ -170,8 +148,7 @@ public class DPointSetMultiIcon extends DComponent
|
||||
return p;
|
||||
}
|
||||
|
||||
public DPointSet getDPointSet()
|
||||
{
|
||||
public DPointSet getDPointSet() {
|
||||
return new DPointSet(xMI, yMI);
|
||||
}
|
||||
|
||||
@@ -180,8 +157,7 @@ public class DPointSetMultiIcon extends DComponent
|
||||
*
|
||||
* @return the DPointIcon
|
||||
*/
|
||||
public DPointIcon getIcon()
|
||||
{
|
||||
public DPointIcon getIcon() {
|
||||
return iconMI;
|
||||
}
|
||||
|
||||
@@ -194,16 +170,12 @@ public class DPointSetMultiIcon extends DComponent
|
||||
*
|
||||
* @return the nearest <code>DPoint</code>
|
||||
*/
|
||||
public DPoint getNearestDPoint(DPoint point)
|
||||
{
|
||||
public DPoint getNearestDPoint(DPoint point) {
|
||||
int minIndex = getNearestDPointIndex(point);
|
||||
|
||||
if (minIndex == -1)
|
||||
{
|
||||
if (minIndex == -1) {
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
DPoint result = new DPoint(xMI.getImage(minIndex),
|
||||
yMI.getImage(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.
|
||||
*/
|
||||
public int getNearestDPointIndex(DPoint point)
|
||||
{
|
||||
public int getNearestDPointIndex(DPoint point) {
|
||||
double minValue = Double.MAX_VALUE;
|
||||
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 dy = point.y - yMI.getImage(i);
|
||||
double dummy = (dx * dx) + (dy * dy);
|
||||
|
||||
if (dummy < minValue)
|
||||
{
|
||||
if (dummy < minValue) {
|
||||
minValue = dummy;
|
||||
minIndex = i;
|
||||
}
|
||||
@@ -236,8 +207,7 @@ public class DPointSetMultiIcon extends DComponent
|
||||
return minIndex;
|
||||
}
|
||||
|
||||
public int getSize()
|
||||
{
|
||||
public int getSize() {
|
||||
int size = Math.min(xMI.getSize(), yMI.getSize());
|
||||
|
||||
// int size = x.getSize();
|
||||
@@ -254,8 +224,7 @@ public class DPointSetMultiIcon extends DComponent
|
||||
*
|
||||
* @return the stroke
|
||||
*/
|
||||
public Stroke getStroke()
|
||||
{
|
||||
public Stroke getStroke() {
|
||||
return strokeMI;
|
||||
}
|
||||
|
||||
@@ -263,58 +232,46 @@ public class DPointSetMultiIcon extends DComponent
|
||||
* This method causes the DPointSet to interupt the connected painting at the
|
||||
* current position.
|
||||
*/
|
||||
public void jump()
|
||||
{
|
||||
public void jump() {
|
||||
jumperMI.addJump();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(DMeasures m)
|
||||
{
|
||||
try
|
||||
{
|
||||
public void paint(DMeasures m) {
|
||||
try {
|
||||
Graphics2D g = (Graphics2D) m.getGraphics();
|
||||
g.setStroke(strokeMI);
|
||||
|
||||
if (color != null)
|
||||
{
|
||||
if (color != null) {
|
||||
g.setColor(color);
|
||||
}
|
||||
|
||||
int size = getSize();
|
||||
|
||||
if (connectedMI && (size > 1))
|
||||
{
|
||||
if (connectedMI && (size > 1)) {
|
||||
jumperMI.restore();
|
||||
|
||||
while (jumperMI.hasMoreIntervals())
|
||||
{
|
||||
while (jumperMI.hasMoreIntervals()) {
|
||||
int[] interval = jumperMI.nextInterval();
|
||||
Point p1 = null;
|
||||
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));
|
||||
if (p1 != null)
|
||||
{
|
||||
if (p2!=null) {
|
||||
if (p1 != null) {
|
||||
if (p2 != null) {
|
||||
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.translate(p2.x, p2.y);
|
||||
((DPointIcon) this.m_IconsMI.get(i)).paint(g);
|
||||
g.translate(-p2.x, -p2.y);
|
||||
g.setStroke(strokeMI);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (iconMI != null)
|
||||
{
|
||||
} else {
|
||||
if (iconMI != null) {
|
||||
g.setStroke(new BasicStroke());
|
||||
g.translate(p2.x, p2.y);
|
||||
iconMI.paint(g);
|
||||
@@ -326,48 +283,36 @@ public class DPointSetMultiIcon extends DComponent
|
||||
p1 = p2;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
Point p;
|
||||
|
||||
//for (int i = 0; i < size; i++)
|
||||
// @todo Streiche: Mal wieder eine index out of bounds exception, dass ist einfach mist...
|
||||
for (int i = 0; i < this.m_IconsMI.size(); i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < this.m_IconsMI.size(); i++) {
|
||||
try {
|
||||
p = m.getPoint(xMI.getImage(i), yMI.getImage(i));
|
||||
|
||||
if (p==null) {
|
||||
if (p == null) {
|
||||
continue;
|
||||
}
|
||||
if (this.m_IconsMI.get(i) != null)
|
||||
{
|
||||
if (this.m_IconsMI.get(i) != null) {
|
||||
g.setStroke(new BasicStroke());
|
||||
g.translate(p.x, p.y);
|
||||
((DPointIcon) this.m_IconsMI.get(i)).paint(g);
|
||||
g.translate(-p.x, -p.y);
|
||||
g.setStroke(strokeMI);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (iconMI == null)
|
||||
{
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
g.setStroke(new BasicStroke());
|
||||
g.translate(p.x, p.y);
|
||||
iconMI.paint(g);
|
||||
g.translate(-p.x, -p.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (java.lang.IllegalArgumentException e)
|
||||
{
|
||||
} catch (java.lang.IllegalArgumentException e) {
|
||||
System.out.println(
|
||||
"The rectangle lies not in the currently painted rectangle.");
|
||||
}
|
||||
@@ -375,17 +320,13 @@ public class DPointSetMultiIcon extends DComponent
|
||||
}
|
||||
|
||||
g.setStroke(new BasicStroke());
|
||||
}
|
||||
catch (java.lang.ArrayIndexOutOfBoundsException e)
|
||||
{
|
||||
} catch (java.lang.ArrayIndexOutOfBoundsException e) {
|
||||
// *pff*
|
||||
}
|
||||
}
|
||||
|
||||
public void removeAllPoints()
|
||||
{
|
||||
if (xMI.getSize() == 0)
|
||||
{
|
||||
public void removeAllPoints() {
|
||||
if (xMI.getSize() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -401,15 +342,12 @@ public class DPointSetMultiIcon extends DComponent
|
||||
* if the DPointSet is connected, all points will be painted connected to
|
||||
* their following point
|
||||
*/
|
||||
public void removeJumps()
|
||||
{
|
||||
public void removeJumps() {
|
||||
jumperMI.reset();
|
||||
}
|
||||
|
||||
protected void restore()
|
||||
{
|
||||
if (getSize() == 0)
|
||||
{
|
||||
protected void restore() {
|
||||
if (getSize() == 0) {
|
||||
rectangle = DRectangle.getEmpty();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public void setConnected(boolean aFlag)
|
||||
{
|
||||
public void setConnected(boolean aFlag) {
|
||||
boolean changed = !(aFlag == connectedMI);
|
||||
connectedMI = aFlag;
|
||||
|
||||
if (changed)
|
||||
{
|
||||
if (changed) {
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
@@ -439,10 +375,8 @@ public class DPointSetMultiIcon extends DComponent
|
||||
* @param index the index of the point
|
||||
* @param p the point to insert
|
||||
*/
|
||||
public void setDPoint(int index, DPoint p)
|
||||
{
|
||||
if (index >= xMI.getSize())
|
||||
{
|
||||
public void setDPoint(int index, DPoint p) {
|
||||
if (index >= xMI.getSize()) {
|
||||
throw new ArrayIndexOutOfBoundsException(index);
|
||||
}
|
||||
|
||||
@@ -459,16 +393,12 @@ public class DPointSetMultiIcon extends DComponent
|
||||
*
|
||||
* @param icon the DPointIcon
|
||||
*/
|
||||
public void setIcon(DPointIcon icon)
|
||||
{
|
||||
public void setIcon(DPointIcon icon) {
|
||||
this.iconMI = icon;
|
||||
|
||||
if (icon == null)
|
||||
{
|
||||
if (icon == null) {
|
||||
setDBorder(new DBorder(1, 1, 1, 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
setDBorder(icon.getDBorder());
|
||||
}
|
||||
}
|
||||
@@ -479,10 +409,8 @@ public class DPointSetMultiIcon extends DComponent
|
||||
*
|
||||
* @param s the new stroke
|
||||
*/
|
||||
public void setStroke(Stroke s)
|
||||
{
|
||||
if (s == null)
|
||||
{
|
||||
public void setStroke(Stroke s) {
|
||||
if (s == null) {
|
||||
s = new BasicStroke();
|
||||
}
|
||||
|
||||
@@ -493,12 +421,10 @@ public class DPointSetMultiIcon extends DComponent
|
||||
//~ Inner Classes //////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
public String toString() {
|
||||
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) + ")");
|
||||
}
|
||||
|
||||
|
@@ -89,7 +89,8 @@ class ViewContainer extends ArrayList {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ViewContainer() { }
|
||||
public ViewContainer() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
|
@@ -17,5 +17,6 @@ import eva2.gui.plot.Graph;
|
||||
*==========================================================================*/
|
||||
public interface DataViewerInterface {
|
||||
public Graph getNewGraph(String InfoString);
|
||||
|
||||
public void init();
|
||||
}
|
@@ -11,6 +11,7 @@ package eva2.gui.plot;
|
||||
* IMPORTS
|
||||
*==========================================================================
|
||||
*/
|
||||
|
||||
import eva2.gui.*;
|
||||
import eva2.optimization.individuals.AbstractEAIndividual;
|
||||
import eva2.optimization.mocco.paretofrontviewer.InterfaceRefPointListener;
|
||||
@@ -27,6 +28,7 @@ import eva2.tools.chart2d.DPoint;
|
||||
import eva2.tools.chart2d.DPointIcon;
|
||||
import eva2.tools.chart2d.DPointSet;
|
||||
import eva2.tools.chart2d.ScaledBorder;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
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.
|
||||
*
|
||||
*/
|
||||
public void recolorAllGraphsByIndex() {
|
||||
int index = 0;
|
||||
@@ -446,7 +447,6 @@ public class FunctionArea extends DArea implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean checkLoggable() {
|
||||
@@ -656,7 +656,6 @@ public class FunctionArea extends DArea implements Serializable {
|
||||
|
||||
/**
|
||||
* Export contained data to standard output.
|
||||
*
|
||||
*/
|
||||
public void exportToAscii() {
|
||||
exportToAscii((File) null);
|
||||
@@ -758,7 +757,6 @@ public class FunctionArea extends DArea implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param x
|
||||
* @param y
|
||||
* @return
|
||||
@@ -798,7 +796,6 @@ public class FunctionArea extends DArea implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param GraphLabel
|
||||
* @return
|
||||
*/
|
||||
@@ -857,7 +854,6 @@ public class FunctionArea extends DArea implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param x
|
||||
* @param y
|
||||
* @return
|
||||
@@ -941,7 +937,6 @@ public class FunctionArea extends DArea implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public DPointSet[] printPoints() {
|
||||
@@ -957,7 +952,6 @@ public class FunctionArea extends DArea implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param i
|
||||
* @return
|
||||
*/
|
||||
@@ -971,7 +965,6 @@ public class FunctionArea extends DArea implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param x
|
||||
* @param y
|
||||
*/
|
||||
@@ -1004,7 +997,6 @@ public class FunctionArea extends DArea implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param p
|
||||
* @param graphLabel
|
||||
*/
|
||||
@@ -1013,7 +1005,6 @@ public class FunctionArea extends DArea implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param GraphLabel
|
||||
* @param color
|
||||
*/
|
||||
@@ -1022,7 +1013,6 @@ public class FunctionArea extends DArea implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param GraphLabel
|
||||
* @param colorindex
|
||||
*/
|
||||
@@ -1031,7 +1021,6 @@ public class FunctionArea extends DArea implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param GraphLabel
|
||||
* @param Info
|
||||
* @param stroke
|
||||
@@ -1054,7 +1043,6 @@ public class FunctionArea extends DArea implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param x
|
||||
* @param y
|
||||
* @param GraphLabel
|
||||
@@ -1073,7 +1061,6 @@ public class FunctionArea extends DArea implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param p
|
||||
* @param GraphLabel
|
||||
*/
|
||||
@@ -1201,7 +1188,6 @@ public class FunctionArea extends DArea implements Serializable {
|
||||
|
||||
/**
|
||||
* Recreate the legend object with the current point sets.
|
||||
*
|
||||
*/
|
||||
public void updateLegend() {
|
||||
GraphPointSetLegend lb = new GraphPointSetLegend(pointSetContainer,
|
||||
|
@@ -32,7 +32,6 @@ public class Graph implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param Info
|
||||
* @param stroke
|
||||
*/
|
||||
|
@@ -20,6 +20,7 @@ import eva2.tools.chart2d.DPoint;
|
||||
import eva2.tools.chart2d.DPointIcon;
|
||||
import eva2.tools.chart2d.DPointSet;
|
||||
import eva2.tools.math.Mathematics;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.io.Serializable;
|
||||
@@ -28,6 +29,7 @@ import java.util.ArrayList;
|
||||
/*==========================================================================*
|
||||
* CLASS DECLARATION
|
||||
*==========================================================================*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -38,10 +40,10 @@ public class GraphPointSet {
|
||||
Color.black, Color.red, Color.blue, Color.pink, Color.green,
|
||||
Color.gray, Color.magenta, Color.cyan, Color.orange,
|
||||
new Color(148, 0, 211), // dark violet,
|
||||
new Color(72 , 209 , 204), // turquoise
|
||||
new Color(128 ,128 ,0), // olive
|
||||
new Color(34 ,139 ,34), // forest green
|
||||
new Color(100 ,149 ,237 ) // cornflower
|
||||
new Color(72, 209, 204), // turquoise
|
||||
new Color(128, 128, 0), // olive
|
||||
new Color(34, 139, 34), // forest green
|
||||
new Color(100, 149, 237) // cornflower
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -57,7 +59,6 @@ public class GraphPointSet {
|
||||
private double[] m_Y;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param pointset
|
||||
*/
|
||||
public PointSet(DPointSet pointset) {
|
||||
@@ -72,7 +73,6 @@ public class GraphPointSet {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public DPointSet getDPointSet() {
|
||||
@@ -85,7 +85,6 @@ public class GraphPointSet {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getSize() {
|
||||
@@ -163,7 +162,6 @@ public class GraphPointSet {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param size
|
||||
* @param GraphLabel
|
||||
*/
|
||||
@@ -205,7 +203,6 @@ public class GraphPointSet {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param x
|
||||
* @param y
|
||||
*/
|
||||
@@ -225,7 +222,6 @@ public class GraphPointSet {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param p
|
||||
*/
|
||||
public void addDPoint(DPoint p) {
|
||||
@@ -238,8 +234,7 @@ public class GraphPointSet {
|
||||
*
|
||||
* @param set
|
||||
* @param measures
|
||||
* @param useForce
|
||||
* forces the add even if point counts mismatch, maybe losing
|
||||
* @param useForce forces the add even if point counts mismatch, maybe losing
|
||||
* some data points
|
||||
*/
|
||||
public void addGraph(GraphPointSet set, DMeasures measures, boolean useForce) {
|
||||
@@ -335,7 +330,6 @@ public class GraphPointSet {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Color getColor() {
|
||||
@@ -343,7 +337,6 @@ public class GraphPointSet {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public DPointSet getConnectedPointSet() {
|
||||
@@ -351,7 +344,6 @@ public class GraphPointSet {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getGraphLabel() {
|
||||
@@ -364,6 +356,7 @@ public class GraphPointSet {
|
||||
// public void setUnconnectedPoint (double x, double y) {
|
||||
// m_PointSet_1.addDPoint(x,y);
|
||||
// }
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -372,7 +365,6 @@ public class GraphPointSet {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param p
|
||||
* @return
|
||||
*/
|
||||
@@ -381,7 +373,6 @@ public class GraphPointSet {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getPointCount() {
|
||||
@@ -389,7 +380,6 @@ public class GraphPointSet {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public PointSet getPointSet() {
|
||||
@@ -397,7 +387,6 @@ public class GraphPointSet {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public DPointSetMultiIcon getReference2ConnectedPointSet() {
|
||||
@@ -413,7 +402,6 @@ public class GraphPointSet {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param index
|
||||
* @return
|
||||
*/
|
||||
@@ -423,7 +411,6 @@ public class GraphPointSet {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param Area
|
||||
*/
|
||||
public void initGraph(DArea Area) {
|
||||
@@ -450,7 +437,6 @@ public class GraphPointSet {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isStatisticsGraph() {
|
||||
@@ -466,7 +452,6 @@ public class GraphPointSet {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public DPointSet printPoints() {
|
||||
@@ -490,7 +475,6 @@ public class GraphPointSet {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param x
|
||||
*/
|
||||
public void removePoint(DPoint x) {
|
||||
@@ -503,8 +487,7 @@ public class GraphPointSet {
|
||||
for (int i = 0; i < buf.length; i++) {
|
||||
if (buf[i].x == x.x && buf[i].y == x.y) {
|
||||
System.out.println("point found");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
m_ConnectedPointSet.addDPoint(buf[i]);
|
||||
}
|
||||
|
||||
@@ -512,7 +495,6 @@ public class GraphPointSet {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param c
|
||||
*/
|
||||
public void setColor(Color c) {
|
||||
@@ -525,7 +507,6 @@ public class GraphPointSet {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param p
|
||||
*/
|
||||
public void setConnectedMode(boolean p) {
|
||||
@@ -533,7 +514,6 @@ public class GraphPointSet {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param p
|
||||
*/
|
||||
public void setIcon(DPointIcon p) {
|
||||
@@ -542,7 +522,6 @@ public class GraphPointSet {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param x
|
||||
* @param stroke
|
||||
*/
|
||||
@@ -567,10 +546,10 @@ public class GraphPointSet {
|
||||
* @return the median point of this point set or null if it is empty
|
||||
*/
|
||||
public DPoint getMedPoint() {
|
||||
if (m_ConnectedPointSet==null) {
|
||||
if (m_ConnectedPointSet == null) {
|
||||
return null;
|
||||
}
|
||||
int medX = m_ConnectedPointSet.getSize()/2;
|
||||
int medX = m_ConnectedPointSet.getSize() / 2;
|
||||
return m_ConnectedPointSet.getDPoint(medX);
|
||||
}
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@ package eva2.gui.plot;
|
||||
import eva2.tools.Pair;
|
||||
import eva2.tools.StringTools;
|
||||
import eva2.tools.chart2d.SlimRect;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics;
|
||||
@@ -24,15 +25,12 @@ import javax.swing.JPanel;
|
||||
* an alternative, an own frame could be created.
|
||||
*
|
||||
* @author mkron, draeger
|
||||
*
|
||||
*/
|
||||
public class GraphPointSetLegend {
|
||||
SortedSet<Pair<String, Color>> legendEntries;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author draeger
|
||||
*
|
||||
*/
|
||||
private static class PairComp implements Comparator<Pair<String, Color>> {
|
||||
|
||||
@@ -63,15 +61,14 @@ public class GraphPointSetLegend {
|
||||
legendEntries = new TreeSet<Pair<String, Color>>(comparator);
|
||||
for (int i = 0; i < pointSetContainer.size(); i++) {
|
||||
GraphPointSet pointset = pointSetContainer.get(i);
|
||||
if (pointset.getPointSet().getSize()>0) {
|
||||
if (pointset.getPointSet().getSize() > 0) {
|
||||
String entryStr;
|
||||
if (appendIndex) {
|
||||
entryStr = StringTools.expandPrefixZeros(i, pointSetContainer.size()-1) + ": " + pointset.getInfoString();
|
||||
}
|
||||
else {
|
||||
entryStr = StringTools.expandPrefixZeros(i, pointSetContainer.size() - 1) + ": " + pointset.getInfoString();
|
||||
} else {
|
||||
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 pointSetContainer
|
||||
* @return
|
||||
@@ -115,7 +111,6 @@ public class GraphPointSetLegend {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param bgCol
|
||||
* @param pointSetContainer
|
||||
* @return
|
||||
@@ -131,7 +126,6 @@ public class GraphPointSetLegend {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
public void paintIn(JComponent component) {
|
||||
@@ -172,7 +166,6 @@ public class GraphPointSetLegend {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param g
|
||||
* @param x
|
||||
* @param y
|
||||
|
@@ -12,15 +12,20 @@ import eva2.optimization.problems.InterfaceOptimizationProblem;
|
||||
*/
|
||||
public interface InterfaceDPointWithContent {
|
||||
public void setEAIndividual(AbstractEAIndividual indy);
|
||||
|
||||
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
|
||||
*/
|
||||
public void setProblem(InterfaceOptimizationProblem problem);
|
||||
|
||||
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();
|
||||
}
|
||||
|
@@ -6,12 +6,14 @@ package eva2.gui.plot;
|
||||
* Hannes Planatscher @version: $Revision: 322 $ $Date: 2007-12-11 17:24:07
|
||||
* +0100 (Tue, 11 Dec 2007) $ $Author: mkron $
|
||||
*/
|
||||
|
||||
import eva2.EvAInfo;
|
||||
import eva2.gui.JEFrame;
|
||||
import eva2.optimization.individuals.AbstractEAIndividual;
|
||||
import eva2.optimization.population.Population;
|
||||
import eva2.tools.BasicResourceLoader;
|
||||
import eva2.tools.chart2d.DPointSet;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
@@ -1,4 +1,5 @@
|
||||
package eva2.gui.plot;
|
||||
|
||||
/*
|
||||
* Title: EvA2
|
||||
* Description:
|
||||
@@ -13,7 +14,7 @@ package eva2.gui.plot;
|
||||
* IMPORTS
|
||||
*==========================================================================*/
|
||||
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
|
||||
@@ -22,16 +23,25 @@ public interface PlotInterface {
|
||||
* @param g2 graph object two
|
||||
* @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 setUnconnectedPoint (double x, double y,int GraphLabel);
|
||||
public void clearAll ();
|
||||
public void clearGraph (int GraphNumber);
|
||||
public void setInfoString (int GraphLabel, String Info, float stroke);
|
||||
public void jump ();
|
||||
public void addGraph(int g1, int g2, boolean forceAdd);
|
||||
|
||||
public void setUnconnectedPoint(double x, double y, int GraphLabel);
|
||||
|
||||
public void clearAll();
|
||||
|
||||
public void clearGraph(int GraphNumber);
|
||||
|
||||
public void setInfoString(int GraphLabel, String Info, float stroke);
|
||||
|
||||
public void jump();
|
||||
|
||||
public String getName();
|
||||
|
||||
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 void init();
|
||||
}
|
||||
|
||||
|
@@ -12,11 +12,13 @@ package eva2.gui.plot;
|
||||
/*==========================================================================*
|
||||
* IMPORTS
|
||||
*==========================================================================*/
|
||||
|
||||
import eva2.optimization.problems.Interface2DBorderProblem;
|
||||
import eva2.optimization.problems.InterfaceFirstOrderDerivableProblem;
|
||||
import eva2.tools.chart2d.DRectangle;
|
||||
import eva2.tools.diagram.ColorBarCalculator;
|
||||
import eva2.tools.math.Mathematics;
|
||||
|
||||
import java.awt.Color;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
@@ -24,13 +26,14 @@ import javax.swing.JPanel;
|
||||
/*==========================================================================*
|
||||
* CLASS DECLARATION
|
||||
*==========================================================================*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class TopoPlot extends Plot {
|
||||
Interface2DBorderProblem prob=null;
|
||||
double[][] range=null;
|
||||
boolean withGrads=false;
|
||||
Interface2DBorderProblem prob = null;
|
||||
double[][] range = null;
|
||||
boolean withGrads = false;
|
||||
private int gridx = 50;
|
||||
private int gridy = 50;
|
||||
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);
|
||||
//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);
|
||||
//if (TRACE) System.out.println("Constructor TopoPlot "+PlotName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines parameters used for drawing the topology.
|
||||
*
|
||||
* @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 color_scale the topologies color coding. Values (0-3) are valid. @See ColorBarCalculator.
|
||||
*/
|
||||
public void setParams(int gridX, int gridY, int color_scale) {
|
||||
if (gridX>m_Frame.getWidth()) {
|
||||
if (gridX > m_Frame.getWidth()) {
|
||||
gridX = m_Frame.getWidth();
|
||||
}
|
||||
if (gridY>m_Frame.getHeight()) {
|
||||
if (gridY > m_Frame.getHeight()) {
|
||||
gridY = m_Frame.getHeight();
|
||||
}
|
||||
gridx = gridX;
|
||||
@@ -65,7 +71,6 @@ public class TopoPlot extends Plot {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void installButtons(JPanel buttonPan) {
|
||||
super.installButtons(buttonPan);
|
||||
@@ -81,8 +86,10 @@ public class TopoPlot extends Plot {
|
||||
// });
|
||||
// buttonPan.add(refineButton);
|
||||
}
|
||||
/**
|
||||
|
||||
/**
|
||||
* Defines parameters used for drawing the topology.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
@@ -96,26 +103,27 @@ public class TopoPlot extends Plot {
|
||||
public void setTopology(Interface2DBorderProblem problem) {
|
||||
setTopology(problem, problem.get2DBorder(), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the topology (by setting a specific problem) and draws the topology
|
||||
*/
|
||||
public void setTopology(Interface2DBorderProblem problem, double[][] border, boolean withGradientsIfAvailable) {
|
||||
prob=problem;
|
||||
range=border;
|
||||
withGrads=withGradientsIfAvailable;
|
||||
double[] sizeXY=Mathematics.getAbsRange(border);
|
||||
double deltaX = sizeXY[0]/gridx;
|
||||
double deltaY = sizeXY[1]/gridy;
|
||||
double maxDeriv=0;
|
||||
prob = problem;
|
||||
range = border;
|
||||
withGrads = withGradientsIfAvailable;
|
||||
double[] sizeXY = Mathematics.getAbsRange(border);
|
||||
double deltaX = sizeXY[0] / gridx;
|
||||
double deltaY = sizeXY[1] / gridy;
|
||||
double maxDeriv = 0;
|
||||
double[] pos = new double[2];
|
||||
boolean TRACEMETH=false;
|
||||
boolean TRACEMETH = false;
|
||||
//double fitRange = java.lang.Math.abs(problem.getMinFitness()-problem.getMaxFitness() );
|
||||
double fitRange = 0, max = -Double.MAX_VALUE, min = Double.MAX_VALUE, tmp;
|
||||
for (int x=0; x<gridx; x++) {
|
||||
for (int y=0; y<gridy; y++) {
|
||||
pos[0] = border[0][0]+x*deltaX;
|
||||
pos[1] = border[1][0]+y*deltaY;
|
||||
tmp = (float)(problem.functionValue(pos));
|
||||
for (int x = 0; x < gridx; x++) {
|
||||
for (int y = 0; y < gridy; y++) {
|
||||
pos[0] = border[0][0] + x * deltaX;
|
||||
pos[1] = border[1][0] + y * deltaY;
|
||||
tmp = (float) (problem.functionValue(pos));
|
||||
if (TRACEMETH) {
|
||||
System.out.println(pos[0] + " " + pos[1] + " " + tmp);
|
||||
}
|
||||
@@ -126,9 +134,9 @@ public class TopoPlot extends Plot {
|
||||
max = tmp;
|
||||
}
|
||||
if (withGradientsIfAvailable && (problem instanceof InterfaceFirstOrderDerivableProblem)) {
|
||||
double[] deriv = ((InterfaceFirstOrderDerivableProblem)problem).getFirstOrderGradients(problem.project2DPoint(pos));
|
||||
for (int i=0; i<2;i++) {
|
||||
maxDeriv=Math.max(maxDeriv, Math.abs(deriv[i]));
|
||||
double[] deriv = ((InterfaceFirstOrderDerivableProblem) problem).getFirstOrderGradients(problem.project2DPoint(pos));
|
||||
for (int i = 0; i < 2; i++) {
|
||||
maxDeriv = Math.max(maxDeriv, Math.abs(deriv[i]));
|
||||
} // maximum deriv of first 2 dims
|
||||
}
|
||||
|
||||
@@ -138,12 +146,12 @@ public class TopoPlot extends Plot {
|
||||
ColorBarCalculator colorBar = new ColorBarCalculator(colorScale);
|
||||
|
||||
m_Frame.setVisible(false);
|
||||
for (int x=0; x<gridx; x++) {
|
||||
for (int y=0; y<gridy; y++) {
|
||||
pos[0] = border[0][0]+x*deltaX;
|
||||
pos[1] = border[1][0]+y*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)));
|
||||
for (int x = 0; x < gridx; x++) {
|
||||
for (int y = 0; y < gridy; y++) {
|
||||
pos[0] = border[0][0] + x * deltaX;
|
||||
pos[1] = border[1][0] + y * 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(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);
|
||||
@@ -152,12 +160,12 @@ public class TopoPlot extends Plot {
|
||||
} // for y
|
||||
} // for x
|
||||
if (withGradientsIfAvailable && (problem instanceof InterfaceFirstOrderDerivableProblem)) {
|
||||
for (int x=0; x<gridx; x++) {
|
||||
for (int y=0; y<gridy; y++) {
|
||||
pos[0] = border[0][0]+x*deltaX;
|
||||
pos[1] = border[1][0]+y*deltaY;
|
||||
double[] derivPos = ((InterfaceFirstOrderDerivableProblem)problem).getFirstOrderGradients(problem.project2DPoint(pos));
|
||||
Mathematics.svDiv(1.1*(2*maxDeriv/Math.max(deltaX, deltaY)), derivPos, derivPos);
|
||||
for (int x = 0; x < gridx; x++) {
|
||||
for (int y = 0; y < gridy; y++) {
|
||||
pos[0] = border[0][0] + x * deltaX;
|
||||
pos[1] = border[1][0] + y * deltaY;
|
||||
double[] derivPos = ((InterfaceFirstOrderDerivableProblem) problem).getFirstOrderGradients(problem.project2DPoint(pos));
|
||||
Mathematics.svDiv(1.1 * (2 * maxDeriv / Math.max(deltaX, deltaY)), derivPos, derivPos);
|
||||
Mathematics.vvAdd(pos, derivPos, derivPos);
|
||||
getFunctionArea().drawLine(pos, derivPos);
|
||||
getFunctionArea().drawIcon(1, "", derivPos, 0);
|
||||
|
@@ -19,7 +19,7 @@ public class VerticalButtonUI extends BasicButtonUI {
|
||||
@Override
|
||||
public Dimension getPreferredSize(JComponent 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();
|
||||
@@ -29,7 +29,7 @@ public class VerticalButtonUI extends BasicButtonUI {
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g, JComponent c) {
|
||||
JButton button = (JButton)c;
|
||||
JButton button = (JButton) c;
|
||||
String text = button.getText();
|
||||
Icon icon = (button.isEnabled()) ? button.getIcon() : button.getDisabledIcon();
|
||||
|
||||
@@ -54,16 +54,15 @@ public class VerticalButtonUI extends BasicButtonUI {
|
||||
AffineTransform tr = g2.getTransform();
|
||||
|
||||
if (angle == 90) {
|
||||
g2.rotate( Math.PI / 2 );
|
||||
g2.translate( 0, - c.getWidth() );
|
||||
paintViewR.x = c.getHeight()/2 - (int)fm.getStringBounds(text, g).getWidth()/2;
|
||||
paintViewR.y = c.getWidth()/2 - (int)fm.getStringBounds(text, g).getHeight()/2;
|
||||
}
|
||||
else if (angle == 270 || angle == -90) {
|
||||
g2.rotate( - Math.PI / 2 );
|
||||
g2.translate( - c.getHeight(), 0 );
|
||||
paintViewR.x = c.getHeight()/2 - (int)fm.getStringBounds(text, g).getWidth()/2;
|
||||
paintViewR.y = c.getWidth()/2 - (int)fm.getStringBounds(text, g).getHeight()/2;
|
||||
g2.rotate(Math.PI / 2);
|
||||
g2.translate(0, -c.getWidth());
|
||||
paintViewR.x = c.getHeight() / 2 - (int) fm.getStringBounds(text, g).getWidth() / 2;
|
||||
paintViewR.y = c.getWidth() / 2 - (int) fm.getStringBounds(text, g).getHeight() / 2;
|
||||
} else if (angle == 270 || angle == -90) {
|
||||
g2.rotate(-Math.PI / 2);
|
||||
g2.translate(-c.getHeight(), 0);
|
||||
paintViewR.x = c.getHeight() / 2 - (int) fm.getStringBounds(text, g).getWidth() / 2;
|
||||
paintViewR.y = c.getWidth() / 2 - (int) fm.getStringBounds(text, g).getHeight() / 2;
|
||||
}
|
||||
|
||||
if (icon != null) {
|
||||
@@ -75,12 +74,12 @@ public class VerticalButtonUI extends BasicButtonUI {
|
||||
int textY = paintTextR.y + fm.getAscent();
|
||||
|
||||
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 {
|
||||
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);
|
||||
}
|
||||
}
|
@@ -8,8 +8,10 @@ package eva2.optimization;
|
||||
* $Date: 2007-11-16 17:25:09 +0100 (Fri, 16 Nov 2007) $
|
||||
* $Author: mkron $
|
||||
*/
|
||||
|
||||
import eva2.optimization.go.InterfaceOptimizationParameters;
|
||||
import eva2.optimization.modules.ModuleAdapter;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@@ -9,9 +9,11 @@ package eva2.optimization;
|
||||
* $Date: 2007-12-04 15:23:57 +0100 (Tue, 04 Dec 2007) $
|
||||
* $Author: mkron $
|
||||
*/
|
||||
|
||||
import eva2.EvAInfo;
|
||||
import eva2.optimization.go.InterfaceOptimizationParameters;
|
||||
import eva2.optimization.modules.ModuleAdapter;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@@ -10,11 +10,13 @@ package eva2.optimization;
|
||||
* $Date: 2007-12-06 16:05:11 +0100 (Thu, 06 Dec 2007) $
|
||||
* $Author: mkron $
|
||||
*/
|
||||
|
||||
import eva2.optimization.go.InterfaceOptimizationParameters;
|
||||
import eva2.optimization.modules.GOModuleAdapter;
|
||||
import eva2.optimization.modules.ModuleAdapter;
|
||||
import eva2.tools.EVAERROR;
|
||||
import eva2.tools.ReflectPackage;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
|
@@ -5,12 +5,14 @@
|
||||
package eva2.optimization;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author becker
|
||||
*/
|
||||
public interface OptimizationStateListener {
|
||||
void performedStop();
|
||||
|
||||
void performedStart(String infoString);
|
||||
|
||||
void performedRestart(String infoString);
|
||||
|
||||
void updateProgress(final int percent, String msg);
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@ package eva2.optimization.enums;
|
||||
public enum BOAScoringMethods {
|
||||
BDM, K2, BIC;
|
||||
|
||||
public static String[] getInfoStrings(){
|
||||
return new String[] {"The Bayesian Dirichlet Metric", "The K2 Metric", "The Bayesian Information Criterion"};
|
||||
public static String[] getInfoStrings() {
|
||||
return new String[]{"The Bayesian Dirichlet Metric", "The K2 Metric", "The Bayesian Information Criterion"};
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
package eva2.optimization.enums;
|
||||
|
||||
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"};
|
||||
}
|
||||
|
@@ -33,20 +33,30 @@ public enum PSOTopologyEnum {
|
||||
|
||||
/**
|
||||
* A method to translate the "old" integer tags into the enum type.
|
||||
*
|
||||
* @param oldID
|
||||
* @return
|
||||
*/
|
||||
public static PSOTopologyEnum translateOldID(int oldID) {
|
||||
switch (oldID) {
|
||||
case 0: return linear;
|
||||
case 1: return grid;
|
||||
case 2: return star;
|
||||
case 3: return multiSwarm;
|
||||
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.");
|
||||
case 0:
|
||||
return linear;
|
||||
case 1:
|
||||
return grid;
|
||||
case 2:
|
||||
return star;
|
||||
case 3:
|
||||
return multiSwarm;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@@ -20,6 +20,7 @@ import eva2.optimization.strategies.EvolutionStrategies;
|
||||
import eva2.optimization.strategies.GeneticAlgorithm;
|
||||
import eva2.optimization.strategies.InterfaceOptimizer;
|
||||
import eva2.tools.math.RNG;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.List;
|
||||
import java.awt.event.ActionEvent;
|
||||
@@ -54,7 +55,7 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
transient private JProgressBar m_ProgressBar;
|
||||
transient private SwingWorker worker;
|
||||
transient private boolean show = false;
|
||||
// transient private InterfaceTest test = new Test1();
|
||||
// transient private InterfaceTest test = new Test1();
|
||||
// Opt. Algorithms and Parameters
|
||||
//transient private InterfaceOptimizer optimizer = new EvolutionaryMultiObjectiveOptimization();
|
||||
//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_OutputPath = "";
|
||||
transient private String m_OutputFileName = "none";
|
||||
// transient private GOStandaloneVersion m_yself;
|
||||
// transient private GOStandaloneVersion m_yself;
|
||||
// these parameters are for the continue option
|
||||
transient private Population m_Backup;
|
||||
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
|
||||
*
|
||||
*/
|
||||
public OptimizationParameters getGOParameters() {
|
||||
return this.m_GO;
|
||||
@@ -192,6 +192,7 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
this.m_Frame.validate();
|
||||
this.m_Frame.setVisible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* This action listener, called by the "Run/Restart" button, will init the
|
||||
* problem and start the computation.
|
||||
@@ -695,6 +696,7 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
// public String seedTipText() {
|
||||
// return "Choose the seed for the random number generator.";
|
||||
// }
|
||||
|
||||
/**
|
||||
* This method sets the name of the current experiment as it will occur in
|
||||
* the plot legend.
|
||||
|
@@ -36,7 +36,7 @@ public interface IndividualInterface {
|
||||
*
|
||||
* @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
|
||||
|
@@ -9,5 +9,6 @@ package eva2.optimization.go;
|
||||
*/
|
||||
public interface InterfaceGOStandalone {
|
||||
void startExperiment();
|
||||
|
||||
void setShow(boolean t);
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package eva2.optimization.go;
|
||||
|
||||
import eva2.optimization.problems.InterfaceAdditionalPopulationInformer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface InterfaceNotifyOnInformers {
|
||||
|
@@ -19,63 +19,85 @@ public interface InterfaceOptimizationParameters {
|
||||
*/
|
||||
// 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();
|
||||
|
||||
/** This method returns the name
|
||||
/**
|
||||
* This method returns the name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
public void setSeed(long x);
|
||||
|
||||
public long getSeed();
|
||||
|
||||
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.
|
||||
*
|
||||
* @param term The new terminator
|
||||
*/
|
||||
public void setTerminator(InterfaceTerminator term);
|
||||
|
||||
public InterfaceTerminator getTerminator();
|
||||
|
||||
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
|
||||
*/
|
||||
public void setOptimizer(InterfaceOptimizer optimizer);
|
||||
|
||||
public InterfaceOptimizer getOptimizer();
|
||||
// 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
|
||||
*/
|
||||
public void setProblem (InterfaceOptimizationProblem problem);
|
||||
public InterfaceOptimizationProblem getProblem ();
|
||||
public void setProblem(InterfaceOptimizationProblem problem);
|
||||
|
||||
public InterfaceOptimizationProblem getProblem();
|
||||
|
||||
public String problemTipText();
|
||||
|
||||
/** This method will set the output filename
|
||||
* @param name
|
||||
* TODO invalidate these!
|
||||
/**
|
||||
* This method will set the output filename
|
||||
*
|
||||
* @param name TODO invalidate these!
|
||||
*/
|
||||
// public void setOutputFileName (String name);
|
||||
// public String getOutputFileName ();
|
||||
// public String outputFileNameTipText();
|
||||
|
||||
public InterfacePostProcessParams getPostProcessParams();
|
||||
|
||||
public void setPostProcessParams(InterfacePostProcessParams ppp);
|
||||
|
||||
public String postProcessParamsTipText();
|
||||
|
||||
public void setDoPostProcessing(boolean doPP);
|
||||
|
||||
/**
|
||||
* Give an instance which should be informed about elements which are additional informers.
|
||||
*
|
||||
* @see InterfaceAdditionalPopulationInformer
|
||||
* @param o
|
||||
* @see InterfaceAdditionalPopulationInformer
|
||||
*/
|
||||
public void addInformableInstance(InterfaceNotifyOnInformers o);
|
||||
|
||||
public boolean removeInformableInstance(InterfaceNotifyOnInformers o);
|
||||
}
|
||||
|
@@ -10,7 +10,9 @@ package eva2.optimization.go;
|
||||
*/
|
||||
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 name Could be used to indicate the nature of the event.
|
||||
*/
|
||||
|
@@ -32,6 +32,7 @@ public interface InterfaceProcessor {
|
||||
|
||||
/**
|
||||
* Get Info String about the Optimization.
|
||||
*
|
||||
* @return The info String
|
||||
*/
|
||||
String getInfoString();
|
||||
|
@@ -8,7 +8,6 @@ import eva2.optimization.problems.InterfaceOptimizationProblem;
|
||||
* Interface for a termination criterion.
|
||||
*
|
||||
* @author mkron, streiche
|
||||
*
|
||||
*/
|
||||
public interface InterfaceTerminator {
|
||||
/**
|
||||
@@ -18,10 +17,13 @@ public interface InterfaceTerminator {
|
||||
* @return true if the population fulfills the termination criterion, else false
|
||||
*/
|
||||
public boolean isTerminated(PopulationInterface pop);
|
||||
|
||||
public boolean isTerminated(InterfaceSolutionSet pop);
|
||||
|
||||
@Override
|
||||
public String toString();
|
||||
|
||||
public String lastTerminationMessage();
|
||||
|
||||
public void init(InterfaceOptimizationProblem prob);
|
||||
}
|
@@ -29,6 +29,7 @@ import eva2.optimization.operator.terminators.EvaluationTerminator;
|
||||
import eva2.optimization.population.Population;
|
||||
import eva2.optimization.strategies.InterfaceOptimizer;
|
||||
import eva2.optimization.strategies.IslandModelEA;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.GridLayout;
|
||||
@@ -62,7 +63,8 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
||||
this.m_State = new MOCCOState();
|
||||
}
|
||||
|
||||
/** This method will init the main MOCCO GUI
|
||||
/**
|
||||
* This method will init the main MOCCO GUI
|
||||
* frame
|
||||
*/
|
||||
public void initMOCCOFrame() {
|
||||
@@ -93,14 +95,14 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
||||
this.m_JPanelButtom = new JPanel();
|
||||
this.m_JPanelButtom.setLayout(new BorderLayout());
|
||||
JPanel tmpP = new JPanel();
|
||||
tmpP.setLayout(new GridLayout(2,1));
|
||||
tmpP.setLayout(new GridLayout(2, 1));
|
||||
this.m_CurrentState = new JLabel("Problem Initialization");
|
||||
tmpP.add(this.m_CurrentState);
|
||||
this.m_ProgressBar = new JProgressBar();
|
||||
tmpP.add(this.m_ProgressBar);
|
||||
this.m_JPanelButtom.add(tmpP, BorderLayout.CENTER);
|
||||
this.m_JPanelControl.setMinimumSize(new Dimension(400,0));
|
||||
this.m_JPanelControl.setPreferredSize(new Dimension(400,0));
|
||||
this.m_JPanelControl.setMinimumSize(new Dimension(400, 0));
|
||||
this.m_JPanelControl.setPreferredSize(new Dimension(400, 0));
|
||||
this.m_JPanelButtom.add(this.m_JPanelControl, BorderLayout.EAST);
|
||||
this.m_JPanelMain.add(this.m_JPanelButtom, BorderLayout.SOUTH);
|
||||
this.m_JFrame.validate();
|
||||
@@ -113,18 +115,33 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
||||
InterfaceProcessElement tmpP;
|
||||
while (cont) {
|
||||
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) {
|
||||
this.m_State.m_OriginalProblem = new TF1Problem();
|
||||
tmpP = new MOCCOProblemInitialization(this);
|
||||
tmpP.initProcessElementParametrization();
|
||||
while (!tmpP.isFinished()) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { }}
|
||||
this.m_State.m_CurrentProblem = (InterfaceOptimizationProblem)this.m_State.m_OriginalProblem.clone();
|
||||
while (!tmpP.isFinished()) {
|
||||
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_JPanelParameters.removeAll();
|
||||
tmpP = new MOCCOInitialPopulationSize(this);
|
||||
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);
|
||||
Population pop = new Population();
|
||||
pop.setTargetSize(this.m_State.m_InitialPopulationSize);
|
||||
@@ -134,11 +151,16 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
||||
this.m_State.addPopulation2History(pop);
|
||||
this.m_View.problemChanged(true);
|
||||
}
|
||||
((InterfaceMultiObjectiveDeNovoProblem)this.m_State.m_CurrentProblem).deactivateRepresentationEdit();
|
||||
((InterfaceMultiObjectiveDeNovoProblem) this.m_State.m_CurrentProblem).deactivateRepresentationEdit();
|
||||
this.updateStatus("Analysis/Redefinition", 33);
|
||||
tmpP = new MOCCOProblemRedefinition(this);
|
||||
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.m_CurrentProblem.initializeProblem();
|
||||
this.m_State.makeBackup();
|
||||
@@ -147,70 +169,125 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
||||
this.updateStatus("MO Strategy Selection", 50);
|
||||
tmpP = new MOCCOChooseMOStrategy(this);
|
||||
tmpP.initProcessElementParametrization();
|
||||
while (!tmpP.isFinished()) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { } }
|
||||
switch (((MOCCOChooseMOStrategy)tmpP).getMOStrategy()) {
|
||||
case MOCCOChooseMOStrategy.STRATEGY_MOEA : {
|
||||
while (!tmpP.isFinished()) {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (java.lang.InterruptedException e) {
|
||||
}
|
||||
}
|
||||
switch (((MOCCOChooseMOStrategy) tmpP).getMOStrategy()) {
|
||||
case MOCCOChooseMOStrategy.STRATEGY_MOEA: {
|
||||
this.updateStatus("MOEA Parameterization", 75);
|
||||
tmpP = new MOCCOParameterizeMO(this);
|
||||
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;
|
||||
}
|
||||
case MOCCOChooseMOStrategy.STRATEGY_STEP : {
|
||||
case MOCCOChooseMOStrategy.STRATEGY_STEP: {
|
||||
this.updateStatus("Reference Solution...", 75);
|
||||
tmpP = new MOCCOChooseReferenceSolution(this);
|
||||
tmpP.initProcessElementParametrization();
|
||||
while (!tmpP.isFinished()) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { } }
|
||||
AbstractEAIndividual reference = ((MOCCOChooseReferenceSolution)tmpP).getReferenceSolution();
|
||||
while (!tmpP.isFinished()) {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (java.lang.InterruptedException e) {
|
||||
}
|
||||
}
|
||||
AbstractEAIndividual reference = ((MOCCOChooseReferenceSolution) tmpP).getReferenceSolution();
|
||||
this.updateStatus("STEP Parameterization...", 90);
|
||||
tmpP = new MOCCOParameterizeSTEP(this);
|
||||
((MOCCOParameterizeSTEP)tmpP).setReferenceSolution(reference);
|
||||
((MOCCOParameterizeSTEP) tmpP).setReferenceSolution(reference);
|
||||
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;
|
||||
}
|
||||
case MOCCOChooseMOStrategy.STRATEGY_REFP : {
|
||||
case MOCCOChooseMOStrategy.STRATEGY_REFP: {
|
||||
this.updateStatus("Reference Point...", 75);
|
||||
tmpP = new MOCCOChooseReferencePoint(this);
|
||||
tmpP.initProcessElementParametrization();
|
||||
while (!tmpP.isFinished()) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { } }
|
||||
double[] reference = ((MOCCOChooseReferencePoint)tmpP).getReferencePoint();
|
||||
while (!tmpP.isFinished()) {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (java.lang.InterruptedException e) {
|
||||
}
|
||||
}
|
||||
double[] reference = ((MOCCOChooseReferencePoint) tmpP).getReferencePoint();
|
||||
this.updateStatus("Reference Point Parameterization...", 90);
|
||||
tmpP = new MOCCOParameterizeRefPoint(this);
|
||||
((MOCCOParameterizeRefPoint)tmpP).setReferencePoint(reference);
|
||||
((MOCCOParameterizeRefPoint) tmpP).setReferencePoint(reference);
|
||||
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;
|
||||
}
|
||||
case MOCCOChooseMOStrategy.STRATEGY_TBCH : {
|
||||
case MOCCOChooseMOStrategy.STRATEGY_TBCH: {
|
||||
this.updateStatus("Reference Point...", 75);
|
||||
tmpP = new MOCCOChooseReferencePoint(this);
|
||||
tmpP.initProcessElementParametrization();
|
||||
while (!tmpP.isFinished()) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { } }
|
||||
double[] reference = ((MOCCOChooseReferencePoint)tmpP).getReferencePoint();
|
||||
while (!tmpP.isFinished()) {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (java.lang.InterruptedException e) {
|
||||
}
|
||||
}
|
||||
double[] reference = ((MOCCOChooseReferencePoint) tmpP).getReferencePoint();
|
||||
this.updateStatus("Tchebycheff Method Parameterization...", 90);
|
||||
tmpP = new MOCCOParameterizeTchebycheff(this);
|
||||
((MOCCOParameterizeTchebycheff)tmpP).setReferencePoint(reference);
|
||||
((MOCCOParameterizeTchebycheff) tmpP).setReferencePoint(reference);
|
||||
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;
|
||||
}
|
||||
case MOCCOChooseMOStrategy.STRATEGY_GDF : {
|
||||
case MOCCOChooseMOStrategy.STRATEGY_GDF: {
|
||||
this.updateStatus("Reference Solution...", 75);
|
||||
tmpP = new MOCCOChooseReferenceSolution(this);
|
||||
tmpP.initProcessElementParametrization();
|
||||
while (!tmpP.isFinished()) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { } }
|
||||
AbstractEAIndividual reference = ((MOCCOChooseReferenceSolution)tmpP).getReferenceSolution();
|
||||
while (!tmpP.isFinished()) {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (java.lang.InterruptedException e) {
|
||||
}
|
||||
}
|
||||
AbstractEAIndividual reference = ((MOCCOChooseReferenceSolution) tmpP).getReferenceSolution();
|
||||
this.updateStatus("Geoffrion-Dyer-Feinberg Method Parameterization...", 90);
|
||||
tmpP = new MOCCOParameterizeGDF(this);
|
||||
((MOCCOParameterizeGDF)tmpP).setReferenceSolution(reference);
|
||||
((MOCCOParameterizeGDF) tmpP).setReferenceSolution(reference);
|
||||
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;
|
||||
}
|
||||
default : {
|
||||
default: {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -218,7 +295,12 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
||||
this.updateStatus("SO-Optimizer Parameterization", 66);
|
||||
tmpP = new MOCCOParameterizeSO(this);
|
||||
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
|
||||
this.updateStatus("Optimizing...", 0);
|
||||
@@ -227,27 +309,24 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
||||
}
|
||||
|
||||
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 ");
|
||||
if (this.m_State.m_OriginalProblem.isMultiObjective()) {
|
||||
System.out.println("multi-objective.");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
System.out.println("single-objective.");
|
||||
}
|
||||
System.out.print("Current Problem is ");
|
||||
if (this.m_State.m_CurrentProblem.isMultiObjective()) {
|
||||
System.out.println("multi-objective.");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
System.out.println("single-objective.");
|
||||
}
|
||||
if (this.m_State.m_BackupProblem != null) {
|
||||
System.out.print("Backup Problem is ");
|
||||
if (this.m_State.m_BackupProblem.isMultiObjective()) {
|
||||
System.out.println("multi-objective.");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
System.out.println("single-objective.");
|
||||
}
|
||||
} else {
|
||||
@@ -257,30 +336,30 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
||||
|
||||
private void checktForMOSO(String w) {
|
||||
String s;
|
||||
System.out.println("I'm currently at "+w);
|
||||
InterfaceMOSOConverter moso = ((AbstractMultiObjectiveOptimizationProblem)this.m_State.m_CurrentProblem).getMOSOConverter();
|
||||
System.out.println("MOSO selected: "+moso.getName());
|
||||
InterfaceOptimizationObjective[] obj = ((InterfaceMultiObjectiveDeNovoProblem)this.m_State.m_CurrentProblem).getProblemObjectives();
|
||||
System.out.println("I'm currently at " + w);
|
||||
InterfaceMOSOConverter moso = ((AbstractMultiObjectiveOptimizationProblem) this.m_State.m_CurrentProblem).getMOSOConverter();
|
||||
System.out.println("MOSO selected: " + moso.getName());
|
||||
InterfaceOptimizationObjective[] obj = ((InterfaceMultiObjectiveDeNovoProblem) this.m_State.m_CurrentProblem).getProblemObjectives();
|
||||
s = "Objectives: {";
|
||||
for (int i = 0; i < obj.length; i++) {
|
||||
s += obj[i].getIdentName();
|
||||
if (i < (obj.length-1)) {
|
||||
if (i < (obj.length - 1)) {
|
||||
s += "; ";
|
||||
}
|
||||
}
|
||||
s += "}";
|
||||
System.out.println(""+s);
|
||||
System.out.println("" + s);
|
||||
if (moso instanceof MOSOWeightedFitness) {
|
||||
PropertyDoubleArray prop = ((MOSOWeightedFitness)moso).getWeights();
|
||||
PropertyDoubleArray prop = ((MOSOWeightedFitness) moso).getWeights();
|
||||
s = "Weights : {";
|
||||
for (int i = 0; i < prop.getNumRows(); i++) {
|
||||
s += prop.getValue(i,0);
|
||||
if (i < (prop.getNumRows()-1)) {
|
||||
s += prop.getValue(i, 0);
|
||||
if (i < (prop.getNumRows() - 1)) {
|
||||
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
|
||||
*/
|
||||
@@ -337,8 +417,8 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
||||
if (go.m_State.m_Optimizer.getPopulation().getFunctionCalls() == 0) {
|
||||
// start to optimize
|
||||
go.startExperiment();
|
||||
file = file.replaceAll(".ser","");
|
||||
go.saveObject(file+"_Finished.ser");
|
||||
file = file.replaceAll(".ser", "");
|
||||
go.saveObject(file + "_Finished.ser");
|
||||
} else {
|
||||
// start GUI
|
||||
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
|
||||
* @return The new state of MOCO
|
||||
*/
|
||||
@@ -359,19 +441,21 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
||||
oi.close();
|
||||
if (!(obj instanceof MOCCOState)) {
|
||||
throw new Exception("Object not of type MOCCOState");
|
||||
} return obj;
|
||||
}
|
||||
return obj;
|
||||
} catch (Exception ex) {
|
||||
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);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
System.out.println("Couldn't read object: " + selected.getName() + "\n" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
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
|
||||
*/
|
||||
public void saveObject(String saveAs) {
|
||||
@@ -383,8 +467,7 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
||||
} catch (Exception ex) {
|
||||
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);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
System.out.println("Couldn't write to file: " + sFile.getName() + "\n" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -394,7 +477,8 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
||||
* InterfaceGOStandalone
|
||||
*/
|
||||
|
||||
/** This method starts the actual optimization procedure
|
||||
/**
|
||||
* This method starts the actual optimization procedure
|
||||
*/
|
||||
@Override
|
||||
public void startExperiment() {
|
||||
@@ -403,7 +487,7 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
||||
this.m_StillWorking = true;
|
||||
this.m_State.m_Optimizer.setProblem(this.m_State.m_CurrentProblem);
|
||||
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_Optimizer.getPopulation().SetFunctionCalls(0);
|
||||
@@ -416,11 +500,12 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
||||
public Object construct() {
|
||||
return doWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finished() {
|
||||
Population[] pop = null;
|
||||
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];
|
||||
for (int i = 0; i < opt.length; i++) {
|
||||
pop[i] = opt[i].getPopulation();
|
||||
@@ -444,7 +529,8 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
||||
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
|
||||
* SwingUtilities.invokeLater(). In this case we're just
|
||||
* changing the progress bars value.
|
||||
@@ -462,7 +548,8 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
||||
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
|
||||
* a value, in this case just a string 'All Done'. It updates the
|
||||
* 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();
|
||||
}
|
||||
System.gc();
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
} catch (InterruptedException e) {
|
||||
updateStatus("Interrupted", 0);
|
||||
return "Interrupted";
|
||||
}
|
||||
@@ -497,7 +583,9 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
||||
/***********************************************************************************************
|
||||
* 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 name Could be used to indicate the nature of the event.
|
||||
*/
|
||||
@@ -506,15 +594,15 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
||||
int currentProgress;
|
||||
if (name.equals(Population.nextGenerationPerformed)) {
|
||||
if (this.m_State.isVisible) {
|
||||
Population population = ((InterfaceOptimizer)source).getPopulation();
|
||||
Population population = ((InterfaceOptimizer) source).getPopulation();
|
||||
double x = 100;
|
||||
if (this.m_State.m_Terminator instanceof EvaluationTerminator) {
|
||||
double y = x/(double)((EvaluationTerminator)this.m_State.m_Terminator).getFitnessCalls();
|
||||
currentProgress = (int)(population.getFunctionCalls()*y);
|
||||
double y = x / (double) ((EvaluationTerminator) this.m_State.m_Terminator).getFitnessCalls();
|
||||
currentProgress = (int) (population.getFunctionCalls() * y);
|
||||
} else {
|
||||
currentProgress = (int)(0);
|
||||
currentProgress = (int) (0);
|
||||
}
|
||||
updateStatus("Optimizing...",currentProgress);
|
||||
updateStatus("Optimizing...", currentProgress);
|
||||
} else {
|
||||
// perhaps i could write it to file!?
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
package eva2.optimization.go;
|
||||
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
/**
|
||||
@@ -6,11 +7,11 @@ import javax.swing.SwingUtilities;
|
||||
* SwingWorker 3), an abstract class that you subclass to
|
||||
* perform GUI-related work in a dedicated thread. For
|
||||
* instructions on using this class, see:
|
||||
*
|
||||
* <p/>
|
||||
* http://java.sun.com/products/jfc/tsc/articles/threads/threads2.html
|
||||
* or
|
||||
* http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html
|
||||
*
|
||||
* <p/>
|
||||
* Note that the API changed slightly in the 3rd version:
|
||||
* You must now invoke start() on the SwingWorker after
|
||||
* creating it.
|
||||
@@ -26,9 +27,18 @@ public abstract class SwingWorker {
|
||||
*/
|
||||
private static class ThreadVar {
|
||||
private Thread thread;
|
||||
ThreadVar(Thread t) { thread = t; }
|
||||
synchronized Thread get() { return thread; }
|
||||
synchronized void clear() { thread = null; }
|
||||
|
||||
ThreadVar(Thread t) {
|
||||
thread = t;
|
||||
}
|
||||
|
||||
synchronized Thread get() {
|
||||
return thread;
|
||||
}
|
||||
|
||||
synchronized void clear() {
|
||||
thread = null;
|
||||
}
|
||||
}
|
||||
|
||||
private ThreadVar threadVar;
|
||||
@@ -75,8 +85,7 @@ public abstract class SwingWorker {
|
||||
}
|
||||
try {
|
||||
t.join();
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt(); // propagate
|
||||
return null;
|
||||
}
|
||||
@@ -90,7 +99,9 @@ public abstract class SwingWorker {
|
||||
public SwingWorker() {
|
||||
final Runnable doFinished = new Runnable() {
|
||||
@Override
|
||||
public void run() { finished(); }
|
||||
public void run() {
|
||||
finished();
|
||||
}
|
||||
};
|
||||
|
||||
Runnable doConstruct = new Runnable() {
|
||||
@@ -98,8 +109,7 @@ public abstract class SwingWorker {
|
||||
public void run() {
|
||||
try {
|
||||
setValue(construct());
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
threadVar.clear();
|
||||
}
|
||||
|
||||
|
@@ -14,9 +14,11 @@ import eva2.optimization.population.Population;
|
||||
import eva2.optimization.problems.InterfaceOptimizationProblem;
|
||||
import eva2.tools.EVAERROR;
|
||||
import eva2.tools.math.RNG;
|
||||
|
||||
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
|
||||
* probabilities. All EA individuals should typically extend this abstract EA individual.
|
||||
* 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() {
|
||||
// return this.m_Name;
|
||||
// }
|
||||
|
||||
/**
|
||||
* This method is used when a new offspring is created the increment the
|
||||
* name.
|
||||
@@ -307,6 +310,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
// logParentLen = logLen;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Add an ancestor generation with multiple parents.
|
||||
*
|
||||
@@ -446,6 +451,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
||||
// heritage.add(parentIDs);
|
||||
//// if (heritage.size() > logParentLen) heritage.remove(0);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 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();
|
||||
// else return null;
|
||||
// }
|
||||
|
||||
/**
|
||||
* This method will allow you to get the current age of an individual Zero
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
protected boolean isLogParents() {
|
||||
return logParents;
|
||||
@@ -1309,7 +1315,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
||||
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
|
||||
// * the fitness can be is returned as default value.
|
||||
// * @see #getFitness()
|
||||
|
@@ -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
|
||||
* best-so-far fitness values) for individual comparison.
|
||||
*
|
||||
* @see #AbstractEAIndividual().isDominatingFitness(double[], double[])
|
||||
* @author mkron
|
||||
*
|
||||
* @see #AbstractEAIndividual().isDominatingFitness(double[], double[])
|
||||
*/
|
||||
public class AbstractEAIndividualComparator implements Comparator<Object>, Serializable {
|
||||
// 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.
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
public AbstractEAIndividualComparator() {
|
||||
this("", -1, true);
|
||||
@@ -74,8 +72,8 @@ public class AbstractEAIndividualComparator implements Comparator<Object>, Seria
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (other instanceof AbstractEAIndividualComparator) {
|
||||
AbstractEAIndividualComparator o = (AbstractEAIndividualComparator)other;
|
||||
if ((indyDataKey==o.indyDataKey) || (indyDataKey!=null && (indyDataKey.equals(o.indyDataKey)))) {
|
||||
AbstractEAIndividualComparator o = (AbstractEAIndividualComparator) other;
|
||||
if ((indyDataKey == o.indyDataKey) || (indyDataKey != null && (indyDataKey.equals(o.indyDataKey)))) {
|
||||
if ((fitCriterion == o.fitCriterion) && (preferFeasible == o.preferFeasible)) {
|
||||
return true;
|
||||
}
|
||||
@@ -86,17 +84,17 @@ public class AbstractEAIndividualComparator implements Comparator<Object>, Seria
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return indyDataKey.hashCode()+100+fitCriterion+(preferFeasible ? 7 : 13);
|
||||
return indyDataKey.hashCode() + 100 + fitCriterion + (preferFeasible ? 7 : 13);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic constructor.
|
||||
*
|
||||
* @see #AbstractEAIndividualComparator(int)
|
||||
* @see #AbstractEAIndividualComparator(String)
|
||||
* @param indyDataKey
|
||||
* @param fitnessCriterion
|
||||
* @param priorizeConstraints
|
||||
* @see #AbstractEAIndividualComparator(int)
|
||||
* @see #AbstractEAIndividualComparator(String)
|
||||
*/
|
||||
public AbstractEAIndividualComparator(String indDataKey, int fitnessCriterion, boolean preferFeasible) {
|
||||
this.indyDataKey = indDataKey;
|
||||
@@ -129,19 +127,18 @@ public class AbstractEAIndividualComparator implements Comparator<Object>, Seria
|
||||
|
||||
if (preferFeasible) { // check constraint violation first?
|
||||
int constrViolComp = ((AbstractEAIndividual) o1).compareConstraintViolation((AbstractEAIndividual) o2);
|
||||
if (constrViolComp>0) {
|
||||
if (constrViolComp > 0) {
|
||||
return -1;
|
||||
}
|
||||
else if (constrViolComp < 0) {
|
||||
} else if (constrViolComp < 0) {
|
||||
return 1;
|
||||
}
|
||||
// otherwise both do not violate, so regard fitness
|
||||
}
|
||||
if (indyDataKey != null && (indyDataKey.length()>0)) { // check specific key
|
||||
double[] fit1 = (double[])((AbstractEAIndividual)o1).getData(indyDataKey);
|
||||
double[] fit2 = (double[])((AbstractEAIndividual)o2).getData(indyDataKey);
|
||||
if ((fit1==null) || (fit2==null)) {
|
||||
throw new RuntimeException("Unknown individual data key " + indyDataKey + ", unable to compare individuals ("+this.getClass().getSimpleName()+")");
|
||||
if (indyDataKey != null && (indyDataKey.length() > 0)) { // check specific key
|
||||
double[] fit1 = (double[]) ((AbstractEAIndividual) o1).getData(indyDataKey);
|
||||
double[] fit2 = (double[]) ((AbstractEAIndividual) o2).getData(indyDataKey);
|
||||
if ((fit1 == null) || (fit2 == null)) {
|
||||
throw new RuntimeException("Unknown individual data key " + indyDataKey + ", unable to compare individuals (" + this.getClass().getSimpleName() + ")");
|
||||
}
|
||||
if (fitCriterion < 0) {
|
||||
o1domO2 = AbstractEAIndividual.isDominatingFitness(fit1, fit2);
|
||||
@@ -149,8 +146,7 @@ public class AbstractEAIndividualComparator implements Comparator<Object>, Seria
|
||||
} else {
|
||||
if (fit1[fitCriterion] == fit2[fitCriterion]) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return (fit1[fitCriterion] < fit2[fitCriterion]) ? -1 : 1;
|
||||
}
|
||||
}
|
||||
@@ -176,9 +172,11 @@ public class AbstractEAIndividualComparator implements Comparator<Object>, Seria
|
||||
public String getIndyDataKey() {
|
||||
return indyDataKey;
|
||||
}
|
||||
|
||||
public void setIndyDataKey(String indyDataKey) {
|
||||
this.indyDataKey = indyDataKey;
|
||||
}
|
||||
|
||||
public String indyDataKeyTipText() {
|
||||
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() {
|
||||
return fitCriterion;
|
||||
}
|
||||
|
||||
public void setFitCriterion(int fitCriterion) {
|
||||
this.fitCriterion = fitCriterion;
|
||||
}
|
||||
|
||||
public String fitCriterionTipText() {
|
||||
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() {
|
||||
return preferFeasible;
|
||||
}
|
||||
|
||||
public void setPreferFeasible(boolean priorConst) {
|
||||
preferFeasible = priorConst;
|
||||
}
|
||||
|
||||
public String preferFeasibleTipText() {
|
||||
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() {
|
||||
return "A comparator class for general EA individuals. Compares individuals based on their fitness in context of minimization.";
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "IndividualComparator";
|
||||
}
|
||||
|
@@ -6,10 +6,12 @@ import eva2.optimization.operator.mutation.MutateESGlobal;
|
||||
import eva2.optimization.problems.InterfaceHasInitRange;
|
||||
import eva2.optimization.problems.InterfaceOptimizationProblem;
|
||||
import eva2.tools.math.RNG;
|
||||
|
||||
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.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
@@ -52,7 +54,7 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
this.age = individual.age;
|
||||
this.crossoverOperator = individual.crossoverOperator;
|
||||
this.crossoverProbability = individual.crossoverProbability;
|
||||
this.mutationOperator = (InterfaceMutation)individual.mutationOperator.clone();
|
||||
this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone();
|
||||
this.mutationProbability = individual.mutationProbability;
|
||||
this.selectionProbability = new double[individual.selectionProbability.length];
|
||||
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);
|
||||
}
|
||||
|
||||
/** This method checks on equality regarding genotypic equality
|
||||
/**
|
||||
* This method checks on equality regarding genotypic equality
|
||||
*
|
||||
* @param individual The individual to compare to.
|
||||
* @return boolean if equal true else false.
|
||||
*/
|
||||
@@ -104,7 +108,9 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
/************************************************************************************
|
||||
* 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
|
||||
*/
|
||||
@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
|
||||
*/
|
||||
@Override
|
||||
@@ -125,7 +133,9 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
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.
|
||||
*/
|
||||
@Override
|
||||
@@ -152,8 +162,10 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
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
|
||||
*
|
||||
* @return BitSet representing the binary data.
|
||||
*/
|
||||
@Override
|
||||
@@ -161,15 +173,20 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
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.
|
||||
*/
|
||||
@Override
|
||||
public void SetBinaryPhenotype(BitSet 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.
|
||||
*
|
||||
* @param binaryData The new binary data.
|
||||
*/
|
||||
@Override
|
||||
@@ -178,16 +195,14 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
for (int i = 0; i < this.m_Genotype.length; i++) {
|
||||
if (this.m_UseHardSwitch) {
|
||||
if (binaryData.get(i)) {
|
||||
this.m_Genotype[i] = RNG.randomDouble(0.55,1.0);
|
||||
}
|
||||
else {
|
||||
this.m_Genotype[i] = RNG.randomDouble(0.0,0.45);
|
||||
this.m_Genotype[i] = RNG.randomDouble(0.55, 1.0);
|
||||
} else {
|
||||
this.m_Genotype[i] = RNG.randomDouble(0.0, 0.45);
|
||||
}
|
||||
} else {
|
||||
if (binaryData.get(i)) {
|
||||
this.m_Genotype[i] = 0.9;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.m_Genotype[i] = 0.1;
|
||||
}
|
||||
}
|
||||
@@ -197,8 +212,10 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
/************************************************************************************
|
||||
* 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.
|
||||
*
|
||||
* @param obj The initial value for the phenotype
|
||||
* @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 method will return a string description of the GAIndividal
|
||||
/**
|
||||
* This method will return a string description of the GAIndividal
|
||||
* noteably the Genotype.
|
||||
*
|
||||
* @return A descriptive string
|
||||
*/
|
||||
@Override
|
||||
@@ -244,7 +263,9 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
* 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
|
||||
*/
|
||||
@Override
|
||||
@@ -252,7 +273,9 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
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
|
||||
*/
|
||||
@Override
|
||||
@@ -277,7 +300,9 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
// 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.
|
||||
*/
|
||||
@Override
|
||||
@@ -285,7 +310,8 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
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
|
||||
public void defaultMutate() {
|
||||
@@ -294,18 +320,19 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
|
||||
@Override
|
||||
public void defaultInit(InterfaceOptimizationProblem prob) {
|
||||
if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange)prob).getInitRange()!=null)) {
|
||||
ESIndividualDoubleData.defaultInit(m_Genotype, (double[][])((InterfaceHasInitRange)prob).getInitRange());
|
||||
}
|
||||
else {
|
||||
if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange) prob).getInitRange() != null)) {
|
||||
ESIndividualDoubleData.defaultInit(m_Genotype, (double[][]) ((InterfaceHasInitRange) prob).getInitRange());
|
||||
} else {
|
||||
ESIndividualDoubleData.defaultInit(m_Genotype, m_Range);
|
||||
}
|
||||
}
|
||||
/**********************************************************************************************************************
|
||||
* 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.
|
||||
*
|
||||
* @return The name.
|
||||
*/
|
||||
@Override
|
||||
@@ -313,23 +340,29 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
return "ES individual";
|
||||
}
|
||||
|
||||
/** This method returns a global info string
|
||||
/**
|
||||
* This method returns a global info string
|
||||
*
|
||||
* @return description
|
||||
*/
|
||||
public static String globalInfo() {
|
||||
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.
|
||||
*
|
||||
* @param b the Switch.
|
||||
*/
|
||||
public void setToggleInterpretation(boolean b) {
|
||||
this.m_UseHardSwitch = b;
|
||||
}
|
||||
|
||||
public boolean getToggleInterpretation() {
|
||||
return this.m_UseHardSwitch;
|
||||
}
|
||||
|
||||
public String toggleInterpretationTipText() {
|
||||
return "Toggle between interpretation as probability or if(>0.5).";
|
||||
}
|
||||
|
@@ -11,7 +11,8 @@ import eva2.tools.EVAERROR;
|
||||
import eva2.tools.math.Mathematics;
|
||||
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.
|
||||
* User: streiche
|
||||
* Date: 24.03.2003
|
||||
@@ -53,7 +54,7 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
this.age = individual.age;
|
||||
this.crossoverOperator = individual.crossoverOperator;
|
||||
this.crossoverProbability = individual.crossoverProbability;
|
||||
this.mutationOperator = (InterfaceMutation)individual.mutationOperator.clone();
|
||||
this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone();
|
||||
this.mutationProbability = individual.mutationProbability;
|
||||
this.selectionProbability = new double[individual.selectionProbability.length];
|
||||
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);
|
||||
}
|
||||
|
||||
/** This method checks on equality regarding genotypic equality
|
||||
/**
|
||||
* This method checks on equality regarding genotypic equality
|
||||
*
|
||||
* @param individual The individual to compare to.
|
||||
* @return boolean if equal true else false.
|
||||
*/
|
||||
@@ -111,11 +114,13 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
/************************************************************************************
|
||||
* 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
|
||||
*/
|
||||
@Override
|
||||
public void setDoubleDataLength (int length) {
|
||||
public void setDoubleDataLength(int length) {
|
||||
double[] newDesPa = new double[length];
|
||||
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
|
||||
for (int i = this.m_Genotype.length; (i < newDesPa.length); i++) {
|
||||
newDesPa[i] = this.m_Genotype[this.m_Genotype.length-1];
|
||||
newRange[i][0] = this.m_Range[this.m_Genotype.length-1][0];
|
||||
newRange[i][1] = this.m_Range[this.m_Genotype.length-1][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][1] = this.m_Range[this.m_Genotype.length - 1][1];
|
||||
}
|
||||
this.m_Genotype = newDesPa;
|
||||
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
|
||||
*/
|
||||
@Override
|
||||
@@ -153,9 +160,11 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
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
|
||||
* ranges.
|
||||
*
|
||||
* @param range The new range for the double data.
|
||||
*/
|
||||
@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.
|
||||
*/
|
||||
@Override
|
||||
@@ -178,18 +189,19 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
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.
|
||||
*
|
||||
* @return BitSet representing the double data.
|
||||
*/
|
||||
@Override
|
||||
public double[] getDoubleData() {
|
||||
// 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
|
||||
if (this.m_Phenotype!=null) {
|
||||
if (this.m_Phenotype != null) {
|
||||
return m_Phenotype;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.m_Phenotype = new double[this.m_Genotype.length];
|
||||
System.arraycopy(this.m_Genotype, 0, this.m_Phenotype, 0, this.m_Genotype.length);
|
||||
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
|
||||
* an update from the genotype.
|
||||
*
|
||||
* @return double[] representing the double data.
|
||||
*/
|
||||
@Override
|
||||
public double[] getDoubleDataWithoutUpdate() {
|
||||
if (m_Phenotype==null) {
|
||||
if (m_Phenotype == null) {
|
||||
return getDoubleData();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
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().
|
||||
*
|
||||
* @param doubleData The new double data.
|
||||
*/
|
||||
@Override
|
||||
@@ -220,8 +234,10 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
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.
|
||||
*
|
||||
* @param doubleData The new double data.
|
||||
*/
|
||||
@Override
|
||||
@@ -235,7 +251,9 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
/************************************************************************************
|
||||
* 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.
|
||||
*/
|
||||
@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.
|
||||
*
|
||||
* @param obj The initial value for the phenotype
|
||||
* @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 method will return a string description of the GAIndividal
|
||||
/**
|
||||
* This method will return a string description of the GAIndividal
|
||||
* noteably the Genotype.
|
||||
*
|
||||
* @return A descriptive string
|
||||
*/
|
||||
@Override
|
||||
@@ -298,7 +320,9 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
/************************************************************************************
|
||||
* 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
|
||||
*/
|
||||
@Override
|
||||
@@ -306,13 +330,15 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
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
|
||||
*/
|
||||
@Override
|
||||
public void SetDGenotype(double[] 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++) {
|
||||
if (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
|
||||
*/
|
||||
public void SetDGenotypeNocheck(double[] b) {
|
||||
@@ -331,12 +359,13 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
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
|
||||
public void defaultMutate() {
|
||||
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
|
||||
*/
|
||||
public static void defaultMutate(double[] genotype, double[][] range) {
|
||||
int mutationIndex = RNG.randomInt(0, genotype.length-1);
|
||||
genotype[mutationIndex] += ((range[mutationIndex][1] - range[mutationIndex][0])/2)*RNG.gaussianDouble(0.05f);
|
||||
int mutationIndex = RNG.randomInt(0, genotype.length - 1);
|
||||
genotype[mutationIndex] += ((range[mutationIndex][1] - range[mutationIndex][0]) / 2) * RNG.gaussianDouble(0.05f);
|
||||
if (genotype[mutationIndex] < range[mutationIndex][0]) {
|
||||
genotype[mutationIndex] = range[mutationIndex][0];
|
||||
}
|
||||
@@ -360,10 +389,9 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
|
||||
@Override
|
||||
public void defaultInit(InterfaceOptimizationProblem prob) {
|
||||
if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange)prob).getInitRange()!=null)) {
|
||||
ESIndividualDoubleData.defaultInit(m_Genotype, (double[][])((InterfaceHasInitRange)prob).getInitRange());
|
||||
}
|
||||
else {
|
||||
if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange) prob).getInitRange() != null)) {
|
||||
ESIndividualDoubleData.defaultInit(m_Genotype, (double[][]) ((InterfaceHasInitRange) prob).getInitRange());
|
||||
} else {
|
||||
ESIndividualDoubleData.defaultInit(m_Genotype, m_Range);
|
||||
}
|
||||
m_Phenotype = null; // mark as invalid
|
||||
@@ -385,8 +413,10 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
/**********************************************************************************************************************
|
||||
* 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.
|
||||
*
|
||||
* @return The name.
|
||||
*/
|
||||
@Override
|
||||
@@ -394,7 +424,9 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
return "ES individual";
|
||||
}
|
||||
|
||||
/** This method returns a global info string
|
||||
/**
|
||||
* This method returns a global info string
|
||||
*
|
||||
* @return description
|
||||
*/
|
||||
public static String globalInfo() {
|
||||
|
@@ -7,7 +7,8 @@ import eva2.optimization.problems.InterfaceHasInitRange;
|
||||
import eva2.optimization.problems.InterfaceOptimizationProblem;
|
||||
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.
|
||||
* User: streiche
|
||||
* Date: 15.04.2004
|
||||
@@ -48,7 +49,7 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
this.age = individual.age;
|
||||
this.crossoverOperator = individual.crossoverOperator;
|
||||
this.crossoverProbability = individual.crossoverProbability;
|
||||
this.mutationOperator = (InterfaceMutation)individual.mutationOperator.clone();
|
||||
this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone();
|
||||
this.mutationProbability = individual.mutationProbability;
|
||||
this.selectionProbability = new double[individual.selectionProbability.length];
|
||||
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);
|
||||
}
|
||||
|
||||
/** This method checks on equality regarding genotypic equality
|
||||
/**
|
||||
* This method checks on equality regarding genotypic equality
|
||||
*
|
||||
* @param individual The individual to compare to.
|
||||
* @return boolean if equal true else false.
|
||||
*/
|
||||
@@ -100,11 +103,13 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
/************************************************************************************
|
||||
* 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
|
||||
*/
|
||||
@Override
|
||||
public void setIntegerDataLength (int length) {
|
||||
public void setIntegerDataLength(int length) {
|
||||
double[] newDesPa = new double[length];
|
||||
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
|
||||
for (int i = this.m_Genotype.length; (i < newDesPa.length); i++) {
|
||||
newDesPa[i] = this.m_Genotype[this.m_Genotype.length-1];
|
||||
newRange[i][0] = this.m_Range[this.m_Genotype.length-1][0];
|
||||
newRange[i][1] = this.m_Range[this.m_Genotype.length-1][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][1] = this.m_Range[this.m_Genotype.length - 1][1];
|
||||
}
|
||||
this.m_Genotype = newDesPa;
|
||||
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
|
||||
*/
|
||||
@Override
|
||||
@@ -133,9 +140,11 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
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
|
||||
* ranges.
|
||||
*
|
||||
* @param range The new range for the int data.
|
||||
*/
|
||||
@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.
|
||||
*/
|
||||
@Override
|
||||
@@ -158,7 +169,9 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
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.
|
||||
*/
|
||||
@Override
|
||||
@@ -176,8 +189,10 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
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
|
||||
*
|
||||
* @return int[] representing the int data.
|
||||
*/
|
||||
@Override
|
||||
@@ -185,7 +200,9 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
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.
|
||||
*/
|
||||
@Override
|
||||
@@ -193,14 +210,16 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
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.
|
||||
*
|
||||
* @param intData The new int data.
|
||||
*/
|
||||
@Override
|
||||
public void SetIntGenotype(int[] intData) {
|
||||
for (int i = 0; i < this.m_Genotype.length; i++) {
|
||||
m_Genotype[i]=(double)intData[i];
|
||||
m_Genotype[i] = (double) intData[i];
|
||||
}
|
||||
getIntegerData();
|
||||
}
|
||||
@@ -209,8 +228,10 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
* 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.
|
||||
*
|
||||
* @param obj The initial value for the phenotype
|
||||
* @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 method will return a string description of the GAIndividal
|
||||
/**
|
||||
* This method will return a string description of the GAIndividal
|
||||
* noteably the Genotype.
|
||||
*
|
||||
* @return A descriptive string
|
||||
*/
|
||||
@Override
|
||||
@@ -258,7 +281,9 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
/************************************************************************************
|
||||
* 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
|
||||
*/
|
||||
@Override
|
||||
@@ -266,7 +291,9 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
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
|
||||
*/
|
||||
@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
|
||||
public void defaultMutate() {
|
||||
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);
|
||||
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);
|
||||
if (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.
|
||||
*/
|
||||
@Override
|
||||
@@ -312,8 +342,8 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
@Override
|
||||
public void defaultInit(InterfaceOptimizationProblem prob) {
|
||||
int[][] range = m_Range;
|
||||
if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange)prob).getInitRange()!=null)) {
|
||||
range = (int[][])((InterfaceHasInitRange)prob).getInitRange();
|
||||
if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange) prob).getInitRange() != null)) {
|
||||
range = (int[][]) ((InterfaceHasInitRange) prob).getInitRange();
|
||||
}
|
||||
for (int i = 0; i < this.m_Genotype.length; i++) {
|
||||
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
|
||||
*/
|
||||
/** This method allows the CommonJavaObjectEditorPanel to read the
|
||||
/**
|
||||
* This method allows the CommonJavaObjectEditorPanel to read the
|
||||
* name to the current object.
|
||||
*
|
||||
* @return The name.
|
||||
*/
|
||||
@Override
|
||||
@@ -331,7 +363,9 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
return "ES individual";
|
||||
}
|
||||
|
||||
/** This method returns a global info string
|
||||
/**
|
||||
* This method returns a global info string
|
||||
*
|
||||
* @return description
|
||||
*/
|
||||
public static String globalInfo() {
|
||||
|
@@ -40,7 +40,7 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
|
||||
if (individual.m_Phenotype != null) {
|
||||
this.m_Phenotype = new int[individual.m_Phenotype.length][];
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -65,7 +65,7 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
|
||||
this.age = individual.age;
|
||||
this.crossoverOperator = individual.crossoverOperator;
|
||||
this.crossoverProbability = individual.crossoverProbability;
|
||||
this.mutationOperator = (InterfaceMutation)individual.mutationOperator.clone();
|
||||
this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone();
|
||||
this.mutationProbability = individual.mutationProbability;
|
||||
this.selectionProbability = new double[individual.selectionProbability.length];
|
||||
for (int i = 0; i < this.selectionProbability.length; i++) {
|
||||
@@ -84,7 +84,9 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
|
||||
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.
|
||||
* @return boolean if equal true else false.
|
||||
*/
|
||||
@@ -118,12 +120,13 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
/**
|
||||
* *********************************************************************************
|
||||
* InterfaceDataTypePermutation methods
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void setPermutationDataLength(int[] length){
|
||||
public void setPermutationDataLength(int[] length) {
|
||||
|
||||
this.m_Genotype = new double[length.length][];
|
||||
this.m_Range = new double[length.length][][];
|
||||
@@ -151,7 +154,7 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetPermutationPhenotype(int[][] perm){
|
||||
public void SetPermutationPhenotype(int[][] perm) {
|
||||
this.m_Phenotype = perm;
|
||||
this.m_Range = new double[perm.length][][];
|
||||
for (int i = 0; i < perm.length; i++) {
|
||||
@@ -165,7 +168,7 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetPermutationGenotype(int[][] perm){
|
||||
public void SetPermutationGenotype(int[][] perm) {
|
||||
this.SetPermutationPhenotype(perm);
|
||||
|
||||
this.m_Genotype = new double[perm.length][];
|
||||
@@ -185,7 +188,7 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
|
||||
this.m_Range[p][i][1] = 1;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
/** 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
|
||||
*
|
||||
* @return int[] representing the permutation.
|
||||
*/
|
||||
@Override
|
||||
@@ -233,6 +238,7 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
|
||||
public int[] getFirstindex() {
|
||||
return firstindex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFirstindex(int[] firstindex) {
|
||||
this.firstindex = firstindex;
|
||||
@@ -242,8 +248,10 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
|
||||
* 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.
|
||||
*
|
||||
* @param obj The initial value for the phenotype
|
||||
* @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 method will return a string description of the GAIndividal
|
||||
/**
|
||||
* This method will return a string description of the GAIndividal
|
||||
* noteably the Genotype.
|
||||
*
|
||||
* @return A descriptive string
|
||||
*/
|
||||
@Override
|
||||
@@ -291,7 +301,9 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
|
||||
/************************************************************************************
|
||||
* 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
|
||||
*/
|
||||
@Override
|
||||
@@ -330,7 +342,9 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
|
||||
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
|
||||
*/
|
||||
@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
|
||||
public void defaultMutate() {
|
||||
@@ -362,8 +377,8 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
|
||||
@Override
|
||||
public void defaultInit(InterfaceOptimizationProblem prob) {
|
||||
double[][][] range = m_Range;
|
||||
if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange)prob).getInitRange()!=null)) {
|
||||
range = (double[][][])((InterfaceHasInitRange)prob).getInitRange();
|
||||
if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange) prob).getInitRange() != null)) {
|
||||
range = (double[][][]) ((InterfaceHasInitRange) prob).getInitRange();
|
||||
}
|
||||
|
||||
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.
|
||||
*/
|
||||
@Override
|
||||
@@ -395,8 +412,10 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
|
||||
/**********************************************************************************************************************
|
||||
* 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.
|
||||
*
|
||||
* @return The name.
|
||||
*/
|
||||
@Override
|
||||
@@ -404,7 +423,9 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
|
||||
return "ES individual";
|
||||
}
|
||||
|
||||
/** This method returns a global info string
|
||||
/**
|
||||
* This method returns a global info string
|
||||
*
|
||||
* @return description
|
||||
*/
|
||||
public static String globalInfo() {
|
||||
|
@@ -5,9 +5,11 @@ import eva2.optimization.operator.mutation.InterfaceMutation;
|
||||
import eva2.optimization.population.Population;
|
||||
import eva2.optimization.problems.InterfaceOptimizationProblem;
|
||||
import eva2.tools.math.RNG;
|
||||
|
||||
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.
|
||||
* User: streiche
|
||||
* Date: 13.05.2003
|
||||
@@ -27,14 +29,14 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
|
||||
}
|
||||
|
||||
public GAESIndividualBinaryDoubleData(GAESIndividualBinaryDoubleData individual) {
|
||||
this.m_Numbers = (InterfaceDataTypeDouble)((AbstractEAIndividual)individual.getNumbers()).clone();
|
||||
this.m_BitSet = (InterfaceDataTypeBinary)((AbstractEAIndividual)individual.getBitSet()).clone();
|
||||
this.m_Numbers = (InterfaceDataTypeDouble) ((AbstractEAIndividual) individual.getNumbers()).clone();
|
||||
this.m_BitSet = (InterfaceDataTypeBinary) ((AbstractEAIndividual) individual.getBitSet()).clone();
|
||||
|
||||
// cloning the members of AbstractEAIndividual
|
||||
this.age = individual.age;
|
||||
this.crossoverOperator = individual.crossoverOperator;
|
||||
this.crossoverProbability = individual.crossoverProbability;
|
||||
this.mutationOperator = (InterfaceMutation)individual.mutationOperator.clone();
|
||||
this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone();
|
||||
this.mutationProbability = individual.mutationProbability;
|
||||
this.selectionProbability = new double[individual.selectionProbability.length];
|
||||
for (int i = 0; i < this.selectionProbability.length; i++) {
|
||||
@@ -52,18 +54,20 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
|
||||
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.
|
||||
* @return boolean if equal true else false.
|
||||
*/
|
||||
@Override
|
||||
public boolean equalGenotypes(AbstractEAIndividual individual) {
|
||||
if (individual instanceof GAESIndividualBinaryDoubleData) {
|
||||
GAESIndividualBinaryDoubleData indy = (GAESIndividualBinaryDoubleData)individual;
|
||||
if (!((AbstractEAIndividual)this.m_Numbers).equalGenotypes((AbstractEAIndividual)indy.m_Numbers)) {
|
||||
GAESIndividualBinaryDoubleData indy = (GAESIndividualBinaryDoubleData) individual;
|
||||
if (!((AbstractEAIndividual) this.m_Numbers).equalGenotypes((AbstractEAIndividual) indy.m_Numbers)) {
|
||||
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 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.
|
||||
*/
|
||||
@Override
|
||||
public void init(InterfaceOptimizationProblem opt) {
|
||||
((AbstractEAIndividual)this.m_Numbers).init(opt);
|
||||
((AbstractEAIndividual)this.m_BitSet).init(opt);
|
||||
((AbstractEAIndividual) this.m_Numbers).init(opt);
|
||||
((AbstractEAIndividual) this.m_BitSet).init(opt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void defaultInit(InterfaceOptimizationProblem prob) {
|
||||
((AbstractEAIndividual)this.m_Numbers).defaultInit(prob);
|
||||
((AbstractEAIndividual)this.m_BitSet).defaultInit(prob);
|
||||
((AbstractEAIndividual) this.m_Numbers).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.
|
||||
*
|
||||
* @param obj The initial value for the phenotype
|
||||
* @param opt The optimization problem that is to be solved.
|
||||
*/
|
||||
@Override
|
||||
public void initByValue(Object obj, InterfaceOptimizationProblem opt) {
|
||||
if (obj instanceof Object[]) {
|
||||
if (((Object[])obj)[0] instanceof double[]) {
|
||||
((AbstractEAIndividual)this.m_Numbers).initByValue(((Object[])obj)[0], opt);
|
||||
((AbstractEAIndividual)this.m_BitSet).initByValue(((Object[])obj)[1], opt);
|
||||
if (((Object[]) obj)[0] instanceof double[]) {
|
||||
((AbstractEAIndividual) this.m_Numbers).initByValue(((Object[]) obj)[0], opt);
|
||||
((AbstractEAIndividual) this.m_BitSet).initByValue(((Object[]) obj)[1], opt);
|
||||
} else {
|
||||
((AbstractEAIndividual)this.m_Numbers).initByValue(((Object[])obj)[1], opt);
|
||||
((AbstractEAIndividual)this.m_BitSet).initByValue(((Object[])obj)[0], opt);
|
||||
((AbstractEAIndividual) this.m_Numbers).initByValue(((Object[]) obj)[1], opt);
|
||||
((AbstractEAIndividual) this.m_BitSet).initByValue(((Object[]) obj)[0], opt);
|
||||
}
|
||||
} else {
|
||||
((AbstractEAIndividual)this.m_Numbers).init(opt);
|
||||
((AbstractEAIndividual)this.m_BitSet).init(opt);
|
||||
((AbstractEAIndividual) this.m_Numbers).init(opt);
|
||||
((AbstractEAIndividual) this.m_BitSet).init(opt);
|
||||
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
|
||||
public void mutate() {
|
||||
if (RNG.flipCoin(this.mutationProbability)) {
|
||||
((AbstractEAIndividual)this.m_Numbers).mutate();
|
||||
((AbstractEAIndividual) this.m_Numbers).mutate();
|
||||
}
|
||||
if (RNG.flipCoin(this.mutationProbability)) {
|
||||
((AbstractEAIndividual)this.m_BitSet).mutate();
|
||||
((AbstractEAIndividual) this.m_BitSet).mutate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void defaultMutate() {
|
||||
((AbstractEAIndividual)this.m_Numbers).defaultMutate();
|
||||
((AbstractEAIndividual)this.m_BitSet).defaultMutate();
|
||||
((AbstractEAIndividual) this.m_Numbers).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.
|
||||
*
|
||||
* @param partners The possible partners
|
||||
* @return offsprings
|
||||
*/
|
||||
@@ -144,25 +155,25 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
|
||||
// out += this.getSolutionRepresentationFor() + "\n" + partners.getSolutionRepresentationFor();
|
||||
// System.out.println(out);
|
||||
|
||||
numTmp = (AbstractEAIndividual)this.getNumbers();
|
||||
numTmp = (AbstractEAIndividual) this.getNumbers();
|
||||
numPop = new Population();
|
||||
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);
|
||||
|
||||
binTmp = (AbstractEAIndividual)this.getBitSet();
|
||||
binTmp = (AbstractEAIndividual) this.getBitSet();
|
||||
binPop = new Population();
|
||||
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);
|
||||
|
||||
result = new GAESIndividualBinaryDoubleData[resNum.length];
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
result[i] = new GAESIndividualBinaryDoubleData(this);
|
||||
((GAESIndividualBinaryDoubleData)result[i]).setNumbers((InterfaceDataTypeDouble)resNum[i]);
|
||||
((GAESIndividualBinaryDoubleData)result[i]).setBitSet((InterfaceDataTypeBinary)resBin[i]);
|
||||
((GAESIndividualBinaryDoubleData) result[i]).setNumbers((InterfaceDataTypeDouble) resNum[i]);
|
||||
((GAESIndividualBinaryDoubleData) result[i]).setBitSet((InterfaceDataTypeBinary) resBin[i]);
|
||||
}
|
||||
|
||||
// result = ((AbstractEAIndividual)this.m_Numbers).mateWith(partners);
|
||||
@@ -177,10 +188,10 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
|
||||
|
||||
} else {
|
||||
// simply return a number of perfect clones
|
||||
result = new AbstractEAIndividual[partners.size() +1];
|
||||
result[0] = (AbstractEAIndividual)this.clone();
|
||||
result = new AbstractEAIndividual[partners.size() + 1];
|
||||
result[0] = (AbstractEAIndividual) this.clone();
|
||||
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++) {
|
||||
@@ -189,31 +200,37 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
|
||||
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.
|
||||
*
|
||||
* @return A descriptive string
|
||||
*/
|
||||
@Override
|
||||
public String getStringRepresentation() {
|
||||
String result = "This is a hybrid Individual:\n";
|
||||
result += "The Numbers Part:\n"+((AbstractEAIndividual)this.m_Numbers).getStringRepresentation();
|
||||
result += "\nThe Binarys Part:\n"+((AbstractEAIndividual)this.m_BitSet).getStringRepresentation();
|
||||
result += "The Numbers Part:\n" + ((AbstractEAIndividual) this.m_Numbers).getStringRepresentation();
|
||||
result += "\nThe Binarys Part:\n" + ((AbstractEAIndividual) this.m_BitSet).getStringRepresentation();
|
||||
return result;
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************
|
||||
/**
|
||||
* *******************************************************************************************************************
|
||||
* These are for InterfaceDataTypeDouble
|
||||
|
||||
/** This method allows you to request a certain amount of double data
|
||||
* <p/>
|
||||
* /** This method allows you to request a certain amount of double data
|
||||
*
|
||||
* @param length The lenght of the double[] that is to be optimized
|
||||
*/
|
||||
@Override
|
||||
public void setDoubleDataLength (int length) {
|
||||
public void setDoubleDataLength(int length) {
|
||||
this.m_Numbers.setDoubleDataLength(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
|
||||
*/
|
||||
@Override
|
||||
@@ -221,9 +238,11 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
|
||||
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
|
||||
* for dimension d.
|
||||
*
|
||||
* @param range The new range for the double data.
|
||||
*/
|
||||
@Override
|
||||
@@ -231,7 +250,9 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
|
||||
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.
|
||||
*/
|
||||
@Override
|
||||
@@ -239,7 +260,9 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
|
||||
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.
|
||||
*/
|
||||
@Override
|
||||
@@ -247,8 +270,10 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
|
||||
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
|
||||
*
|
||||
* @return double[] representing the double data.
|
||||
*/
|
||||
@Override
|
||||
@@ -256,7 +281,9 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
|
||||
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.
|
||||
* @see InterfaceDataTypeDouble.SetDoubleData()
|
||||
*/
|
||||
@@ -265,8 +292,10 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
|
||||
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.
|
||||
*
|
||||
* @param doubleData The new double data.
|
||||
* @see InterfaceDataTypeDouble.SetDoubleDataLamarckian()
|
||||
*/
|
||||
@@ -275,26 +304,32 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
|
||||
this.m_Numbers.SetDoubleGenotype(doubleData);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************
|
||||
/**
|
||||
* *******************************************************************************************************************
|
||||
* These are for InterfaceDataTypeBinary
|
||||
|
||||
/** This method allows you to request a certain amount of binary data
|
||||
* <p/>
|
||||
* /** This method allows you to request a certain amount of binary data
|
||||
*
|
||||
* @param length The lenght of the BitSet that is to be optimized
|
||||
*/
|
||||
@Override
|
||||
public void setBinaryDataLength (int length) {
|
||||
public void setBinaryDataLength(int length) {
|
||||
this.m_Numbers.setDoubleDataLength(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
|
||||
*/
|
||||
public int GetBinaryDataLength() {
|
||||
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.
|
||||
*/
|
||||
@Override
|
||||
@@ -302,8 +337,10 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
|
||||
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
|
||||
*
|
||||
* @return BitSet representing the binary data.
|
||||
*/
|
||||
@Override
|
||||
@@ -311,7 +348,9 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
|
||||
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.
|
||||
* @see InterfaceDataTypeBinary.SetBinaryData()
|
||||
*/
|
||||
@@ -320,8 +359,10 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
|
||||
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.
|
||||
*
|
||||
* @param binaryData The new binary data.
|
||||
* @see InterfaceBinaryData.SetBinaryDataLamarckian()
|
||||
*/
|
||||
@@ -333,8 +374,10 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
|
||||
/**********************************************************************************************************************
|
||||
* 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.
|
||||
*
|
||||
* @return The name.
|
||||
*/
|
||||
@Override
|
||||
@@ -342,34 +385,45 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
|
||||
return "GA/ES individual";
|
||||
}
|
||||
|
||||
/** This method returns a global info string
|
||||
/**
|
||||
* This method returns a global info string
|
||||
*
|
||||
* @return description
|
||||
*/
|
||||
public static String globalInfo() {
|
||||
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.
|
||||
*/
|
||||
public void setNumbers(InterfaceDataTypeDouble Numbers) {
|
||||
this.m_Numbers = Numbers;
|
||||
}
|
||||
|
||||
public InterfaceDataTypeDouble getNumbers() {
|
||||
return this.m_Numbers;
|
||||
}
|
||||
|
||||
public String numbersTipText() {
|
||||
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.
|
||||
*/
|
||||
public void setBitSet(InterfaceDataTypeBinary BitSet) {
|
||||
this.m_BitSet = BitSet;
|
||||
}
|
||||
|
||||
public InterfaceDataTypeBinary getBitSet() {
|
||||
return this.m_BitSet;
|
||||
}
|
||||
|
||||
public String bitSetTipText() {
|
||||
return "Choose the type of inner real-valued representation to use.";
|
||||
}
|
||||
|
@@ -7,9 +7,11 @@ import eva2.optimization.operator.mutation.InterfaceMutation;
|
||||
import eva2.optimization.operator.mutation.MutateGANBit;
|
||||
import eva2.optimization.problems.InterfaceOptimizationProblem;
|
||||
import eva2.tools.math.RNG;
|
||||
|
||||
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.
|
||||
* User: streiche
|
||||
* Date: 24.03.2003
|
||||
@@ -42,14 +44,14 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
}
|
||||
this.m_GenotypeLength = individual.m_GenotypeLength;
|
||||
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
|
||||
this.age = individual.age;
|
||||
this.crossoverOperator = (InterfaceCrossover)individual.crossoverOperator.clone();
|
||||
this.crossoverOperator = (InterfaceCrossover) individual.crossoverOperator.clone();
|
||||
this.crossoverProbability = individual.crossoverProbability;
|
||||
this.mutationOperator = (InterfaceMutation)individual.mutationOperator.clone();
|
||||
this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone();
|
||||
this.mutationProbability = individual.mutationProbability;
|
||||
this.selectionProbability = new double[individual.selectionProbability.length];
|
||||
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);
|
||||
}
|
||||
|
||||
/** This method checks on equality regarding genotypic equality
|
||||
/**
|
||||
* This method checks on equality regarding genotypic equality
|
||||
*
|
||||
* @param individual The individual to compare to.
|
||||
* @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.
|
||||
*
|
||||
* @return The number of true bits
|
||||
*/
|
||||
public double defaultEvaulateAsMiniBits() {
|
||||
@@ -107,8 +113,10 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
/************************************************************************************
|
||||
* 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.
|
||||
*
|
||||
* @param obj The initial value for the phenotype
|
||||
* @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 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
|
||||
* double[] is used instead of a single double.
|
||||
*
|
||||
* @return The complete fitness array
|
||||
*/
|
||||
@Override
|
||||
@@ -156,22 +166,23 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
result += "})\n Value: ";
|
||||
result += "{";
|
||||
for (int i = 0; i < this.m_GenotypeLength; i++) {
|
||||
if (i%8==0) {
|
||||
result+="|";
|
||||
if (i % 8 == 0) {
|
||||
result += "|";
|
||||
}
|
||||
if (this.m_Genotype.get(i)) {
|
||||
result += "1";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
result += "0";
|
||||
}
|
||||
}
|
||||
result += "}";
|
||||
result += "\n Mutation ("+this.mutationProbability +"):" + this.mutationOperator.getStringRepresentation();
|
||||
result += "\n Mutation (" + this.mutationProbability + "):" + this.mutationOperator.getStringRepresentation();
|
||||
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.
|
||||
*/
|
||||
@Override
|
||||
@@ -190,9 +201,11 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
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
|
||||
* of the last significant bit.
|
||||
*
|
||||
* @return The length of the genotype.
|
||||
*/
|
||||
@Override
|
||||
@@ -205,14 +218,14 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
for (int i = 0; i < this.m_GenotypeLength; i++) {
|
||||
if (RNG.flipCoin(0.5)) {
|
||||
this.m_Genotype.set(i);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
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
|
||||
public void defaultMutate() {
|
||||
@@ -220,8 +233,7 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
//if (mutationIndex > 28) System.out.println("Mutate: " + this.getSolutionRepresentationFor());
|
||||
if (this.m_Genotype.get(mutationIndex)) {
|
||||
this.m_Genotype.clear(mutationIndex);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.m_Genotype.set(mutationIndex);
|
||||
}
|
||||
//if (mutationIndex > 28) System.out.println(this.getSolutionRepresentationFor());
|
||||
@@ -230,7 +242,9 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
/************************************************************************************
|
||||
* 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
|
||||
*/
|
||||
@Override
|
||||
@@ -238,7 +252,9 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
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
|
||||
*/
|
||||
@Override
|
||||
@@ -246,17 +262,21 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
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.
|
||||
*/
|
||||
@Override
|
||||
public BitSet getBinaryData() {
|
||||
this.m_Phenotype = (BitSet)this.m_Genotype.clone();
|
||||
this.m_Phenotype = (BitSet) this.m_Genotype.clone();
|
||||
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
|
||||
*
|
||||
* @return BitSet representing the binary data.
|
||||
*/
|
||||
@Override
|
||||
@@ -264,7 +284,9 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
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.
|
||||
*/
|
||||
@Override
|
||||
@@ -272,21 +294,25 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
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.
|
||||
*
|
||||
* @param binaryData The new binary data.
|
||||
*/
|
||||
@Override
|
||||
public void SetBinaryGenotype(BitSet binaryData) {
|
||||
this.SetBinaryPhenotype(binaryData);
|
||||
this.m_Genotype =(BitSet)binaryData.clone();
|
||||
this.m_Genotype = (BitSet) binaryData.clone();
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************
|
||||
* 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.
|
||||
*
|
||||
* @return The name.
|
||||
*/
|
||||
@Override
|
||||
@@ -294,7 +320,9 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
return "GA binary individual";
|
||||
}
|
||||
|
||||
/** This method returns a global info string
|
||||
/**
|
||||
* This method returns a global info string
|
||||
*
|
||||
* @return description
|
||||
*/
|
||||
public static String globalInfo() {
|
||||
|
@@ -9,9 +9,11 @@ import eva2.optimization.operator.mutation.InterfaceMutation;
|
||||
import eva2.optimization.operator.mutation.MutateGAUniform;
|
||||
import eva2.optimization.problems.InterfaceOptimizationProblem;
|
||||
import eva2.tools.math.RNG;
|
||||
|
||||
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.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
@@ -55,9 +57,9 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
|
||||
// cloning the members of AbstractEAIndividual
|
||||
this.age = individual.age;
|
||||
this.crossoverOperator = (InterfaceCrossover)individual.crossoverOperator.clone();
|
||||
this.crossoverOperator = (InterfaceCrossover) individual.crossoverOperator.clone();
|
||||
this.crossoverProbability = individual.crossoverProbability;
|
||||
this.mutationOperator = (InterfaceMutation)individual.mutationOperator.clone();
|
||||
this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone();
|
||||
this.mutationProbability = individual.mutationProbability;
|
||||
this.selectionProbability = new double[individual.selectionProbability.length];
|
||||
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);
|
||||
}
|
||||
|
||||
/** This method checks on equality regarding genotypic equality
|
||||
/**
|
||||
* This method checks on equality regarding genotypic equality
|
||||
*
|
||||
* @param individual The individual to compare to.
|
||||
* @return boolean if equal true else false.
|
||||
*/
|
||||
@@ -112,11 +116,13 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
/************************************************************************************
|
||||
* 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
|
||||
*/
|
||||
@Override
|
||||
public void setDoubleDataLength (int length) {
|
||||
public void setDoubleDataLength(int length) {
|
||||
double[] newDesPa = new double[length];
|
||||
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
|
||||
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][1] = this.m_Range[this.m_Range.length-1][1];
|
||||
newRange[i][0] = this.m_Range[this.m_Range.length - 1][0];
|
||||
newRange[i][1] = this.m_Range[this.m_Range.length - 1][1];
|
||||
}
|
||||
this.m_Range = newRange;
|
||||
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
|
||||
*/
|
||||
@Override
|
||||
@@ -151,9 +159,11 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
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
|
||||
* ranges.
|
||||
*
|
||||
* @param range The new range for the double data.
|
||||
*/
|
||||
@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.
|
||||
*/
|
||||
@Override
|
||||
@@ -176,7 +188,9 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
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.
|
||||
*/
|
||||
@Override
|
||||
@@ -191,8 +205,10 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
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
|
||||
*
|
||||
* @return double[] representing the double data.
|
||||
*/
|
||||
@Override
|
||||
@@ -200,8 +216,10 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
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.
|
||||
*
|
||||
* @param doubleData The new double data.
|
||||
*/
|
||||
@Override
|
||||
@@ -209,8 +227,10 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
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.
|
||||
*
|
||||
* @param doubleData The new double data.
|
||||
*/
|
||||
@Override
|
||||
@@ -228,8 +248,10 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
* 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.
|
||||
*
|
||||
* @param obj The initial value for the phenotype
|
||||
* @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 method will return a string description of the GAIndividal
|
||||
/**
|
||||
* This method will return a string description of the GAIndividal
|
||||
* noteably the Genotype.
|
||||
*
|
||||
* @return A descriptive string
|
||||
*/
|
||||
@Override
|
||||
@@ -276,8 +300,7 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
for (int i = 0; i < this.m_GenotypeLength; i++) {
|
||||
if (this.m_Genotype.get(i)) {
|
||||
result += "1";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
result += "0";
|
||||
}
|
||||
}
|
||||
@@ -289,7 +312,9 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
* 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.
|
||||
*/
|
||||
@Override
|
||||
@@ -297,8 +322,10 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
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.
|
||||
*
|
||||
* @param binaryData The new binary data.
|
||||
*/
|
||||
@Override
|
||||
@@ -306,9 +333,11 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
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
|
||||
* of the last significat bit.
|
||||
*
|
||||
* @return The length of the genotype.
|
||||
*/
|
||||
@Override
|
||||
@@ -321,30 +350,31 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
for (int i = 0; i < this.m_GenotypeLength; i++) {
|
||||
if (RNG.flipCoin(0.5)) {
|
||||
this.m_Genotype.set(i);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
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
|
||||
public void defaultMutate() {
|
||||
int mutationIndex = RNG.randomInt(0, this.m_GenotypeLength);
|
||||
if (this.m_Genotype.get(mutationIndex)) {
|
||||
this.m_Genotype.clear(mutationIndex);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.m_Genotype.set(mutationIndex);
|
||||
}
|
||||
}
|
||||
/**********************************************************************************************************************
|
||||
* 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.
|
||||
*
|
||||
* @return The name.
|
||||
*/
|
||||
@Override
|
||||
@@ -352,37 +382,47 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
return "GA individual";
|
||||
}
|
||||
|
||||
/** This method returns a global info string
|
||||
/**
|
||||
* This method returns a global info string
|
||||
*
|
||||
* @return description
|
||||
*/
|
||||
public static String globalInfo() {
|
||||
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.
|
||||
*
|
||||
* @param coding The used genotype coding method
|
||||
*/
|
||||
public void setGACoding(InterfaceGADoubleCoding coding) {
|
||||
this.m_DoubleCoding = coding;
|
||||
}
|
||||
|
||||
public InterfaceGADoubleCoding getGACoding() {
|
||||
return this.m_DoubleCoding;
|
||||
}
|
||||
|
||||
public String gADoubleCodingTipText() {
|
||||
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.
|
||||
*
|
||||
* @param precision The number of multiruns that are to be performed
|
||||
*/
|
||||
public void setPrecision(int precision) {
|
||||
this.m_Precision = precision;
|
||||
}
|
||||
|
||||
public int getPrecision() {
|
||||
return this.m_Precision;
|
||||
}
|
||||
|
||||
public String precisionTipText() {
|
||||
return "Gives the number of bits to be used to code a double.";
|
||||
}
|
||||
|
@@ -8,9 +8,11 @@ import eva2.optimization.operator.mutation.InterfaceMutation;
|
||||
import eva2.optimization.operator.mutation.MutateGANBit;
|
||||
import eva2.optimization.problems.InterfaceOptimizationProblem;
|
||||
import eva2.tools.math.RNG;
|
||||
|
||||
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.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
@@ -57,7 +59,7 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
this.age = individual.age;
|
||||
this.crossoverOperator = individual.crossoverOperator;
|
||||
this.crossoverProbability = individual.crossoverProbability;
|
||||
this.mutationOperator = (InterfaceMutation)individual.mutationOperator.clone();
|
||||
this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone();
|
||||
this.mutationProbability = individual.mutationProbability;
|
||||
this.selectionProbability = new double[individual.selectionProbability.length];
|
||||
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.
|
||||
* @return boolean if equal true else false.
|
||||
*/
|
||||
@@ -112,11 +116,13 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
/************************************************************************************
|
||||
* 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
|
||||
*/
|
||||
@Override
|
||||
public void setIntegerDataLength (int length) {
|
||||
public void setIntegerDataLength(int length) {
|
||||
int[] newDesPa = new int[length];
|
||||
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
|
||||
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][1] = this.m_Range[this.m_Range.length-1][1];
|
||||
newRange[i][0] = this.m_Range[this.m_Range.length - 1][0];
|
||||
newRange[i][1] = this.m_Range[this.m_Range.length - 1][1];
|
||||
}
|
||||
this.m_Range = newRange;
|
||||
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
|
||||
*/
|
||||
@Override
|
||||
@@ -146,9 +154,11 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
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
|
||||
* ranges.
|
||||
*
|
||||
* @param range The new range for the double data.
|
||||
*/
|
||||
@Override
|
||||
@@ -171,7 +181,7 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
* @param 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);
|
||||
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]);
|
||||
}
|
||||
|
||||
/** This method will return the range for all double attributes.
|
||||
/**
|
||||
* This method will return the range for all double attributes.
|
||||
*
|
||||
* @return The range array.
|
||||
*/
|
||||
@Override
|
||||
@@ -198,7 +210,9 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
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.
|
||||
*/
|
||||
@Override
|
||||
@@ -215,8 +229,10 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
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
|
||||
*
|
||||
* @return int[] representing the int data.
|
||||
*/
|
||||
@Override
|
||||
@@ -224,7 +240,9 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
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.
|
||||
*/
|
||||
@Override
|
||||
@@ -232,8 +250,10 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
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.
|
||||
*
|
||||
* @param doubleData The new double data.
|
||||
*/
|
||||
@Override
|
||||
@@ -254,8 +274,10 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
/************************************************************************************
|
||||
* 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.
|
||||
*
|
||||
* @param obj The initial value for the phenotype
|
||||
* @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 method will return a string description of the GAIndividal
|
||||
/**
|
||||
* This method will return a string description of the GAIndividal
|
||||
* noteably the Genotype.
|
||||
*
|
||||
* @return A descriptive string
|
||||
*/
|
||||
@Override
|
||||
@@ -300,7 +324,7 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
result += "]\n";
|
||||
result += "CodingRange: [";
|
||||
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 += "CodingLength: [";
|
||||
@@ -316,8 +340,7 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
for (int i = 0; i < overallLength; i++) {
|
||||
if (this.m_Genotype.get(i)) {
|
||||
result += "1";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
result += "0";
|
||||
}
|
||||
}
|
||||
@@ -329,7 +352,9 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
* 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.
|
||||
*/
|
||||
@Override
|
||||
@@ -337,8 +362,10 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
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.
|
||||
*
|
||||
* @param binaryData The new binary data.
|
||||
*/
|
||||
@Override
|
||||
@@ -346,9 +373,11 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
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
|
||||
* of the last significat bit.
|
||||
*
|
||||
* @return The length of the genotype.
|
||||
*/
|
||||
@Override
|
||||
@@ -369,14 +398,14 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
for (int i = 0; i < overallLength; i++) {
|
||||
if (RNG.flipCoin(0.5)) {
|
||||
this.m_Genotype.set(i);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
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
|
||||
public void defaultMutate() {
|
||||
@@ -387,8 +416,7 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
int mutationIndex = RNG.randomInt(0, overallLength);
|
||||
if (this.m_Genotype.get(mutationIndex)) {
|
||||
this.m_Genotype.clear(mutationIndex);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.m_Genotype.set(mutationIndex);
|
||||
}
|
||||
}
|
||||
@@ -400,39 +428,41 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
int[][] range = new int[dimension][2];
|
||||
for (int i = 0; i < dimension; i++) {
|
||||
range[i][0] = 0;
|
||||
range[i][1] = i+1;
|
||||
range[i][1] = i + 1;
|
||||
}
|
||||
indy.setIntegerDataLength(dimension);
|
||||
indy.SetIntRange(range);
|
||||
indy.defaultInit(null);
|
||||
System.out.println(""+indy.getStringRepresentation());
|
||||
System.out.println("" + indy.getStringRepresentation());
|
||||
System.out.println("System.exit(0)");
|
||||
int[] data = indy.getIntegerData();
|
||||
String tmp = "Before {";
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
tmp += data[i] +"; ";
|
||||
tmp += data[i] + "; ";
|
||||
}
|
||||
System.out.println(tmp+"}");
|
||||
System.out.println(tmp + "}");
|
||||
tmp = "Setting {";
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
data[i] = RNG.randomInt(range[i][0], range[i][1]);
|
||||
tmp += data[i] + "; ";
|
||||
}
|
||||
System.out.println(tmp+"}");
|
||||
System.out.println(tmp + "}");
|
||||
indy.SetIntGenotype(data);
|
||||
System.out.println(""+indy.getStringRepresentation());
|
||||
System.out.println("" + indy.getStringRepresentation());
|
||||
data = indy.getIntegerData();
|
||||
tmp = "After {";
|
||||
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
|
||||
*/
|
||||
/** This method allows the CommonJavaObjectEditorPanel to read the
|
||||
/**
|
||||
* This method allows the CommonJavaObjectEditorPanel to read the
|
||||
* name to the current object.
|
||||
*
|
||||
* @return The name.
|
||||
*/
|
||||
@Override
|
||||
@@ -440,23 +470,29 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
return "GA individual";
|
||||
}
|
||||
|
||||
/** This method returns a global info string
|
||||
/**
|
||||
* This method returns a global info string
|
||||
*
|
||||
* @return description
|
||||
*/
|
||||
public static String globalInfo() {
|
||||
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.
|
||||
*
|
||||
* @param coding The used genotype coding method
|
||||
*/
|
||||
public void setGACoding(InterfaceGAIntegerCoding coding) {
|
||||
this.m_IntegerCoding = coding;
|
||||
}
|
||||
|
||||
public InterfaceGAIntegerCoding getGACoding() {
|
||||
return this.m_IntegerCoding;
|
||||
}
|
||||
|
||||
public String gAIntegerCodingTipText() {
|
||||
return "Choose the coding to use.";
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user