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,24 +14,23 @@ import javax.swing.event.HyperlinkEvent;
|
||||
import javax.swing.event.HyperlinkListener;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author becker
|
||||
*/
|
||||
public class AboutDialog extends JDialog {
|
||||
private JLabel imageLabel;
|
||||
private JEditorPane infoEditorPane;
|
||||
private JTextArea aboutTextArea;
|
||||
|
||||
|
||||
public AboutDialog(Frame parent) {
|
||||
super(parent);
|
||||
initComponents();
|
||||
}
|
||||
|
||||
|
||||
private void initComponents() {
|
||||
setTitle("About");
|
||||
setLayout(new GridBagLayout());
|
||||
GridBagConstraints gbConstraints = new GridBagConstraints();
|
||||
|
||||
|
||||
setSize(new Dimension(470, 600));
|
||||
setResizable(false);
|
||||
|
||||
@@ -41,19 +41,19 @@ public class AboutDialog extends JDialog {
|
||||
|
||||
/* Create a new JLabel with the image */
|
||||
imageLabel = new JLabel(imageIcon);
|
||||
|
||||
|
||||
gbConstraints.gridx = 0;
|
||||
gbConstraints.gridy = 0;
|
||||
gbConstraints.ipady = 10;
|
||||
gbConstraints.insets = new Insets(10, 10, 0, 10);
|
||||
gbConstraints.anchor = GridBagConstraints.PAGE_START;
|
||||
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);
|
||||
infoEditorPane.setOpaque(false);
|
||||
@@ -74,10 +74,10 @@ public class AboutDialog extends JDialog {
|
||||
gbConstraints.gridy++;
|
||||
gbConstraints.anchor = GridBagConstraints.CENTER;
|
||||
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
|
||||
gbConstraints.weightx = 1.0;
|
||||
gbConstraints.weightx = 1.0;
|
||||
add(infoEditorPane, gbConstraints);
|
||||
|
||||
aboutTextArea = new JTextArea();
|
||||
|
||||
aboutTextArea = new JTextArea();
|
||||
aboutTextArea.setEditable(false);
|
||||
aboutTextArea.setRows(8);
|
||||
|
||||
@@ -93,7 +93,7 @@ public class AboutDialog extends JDialog {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
AboutDialog.this.dispose();
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
gbConstraints.gridy++;
|
||||
gbConstraints.fill = GridBagConstraints.NONE;
|
||||
|
||||
@@ -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);
|
||||
@@ -475,7 +475,7 @@ public class BeanInspector {
|
||||
*
|
||||
* @param obj
|
||||
* @param mName the method name
|
||||
* @param args the arguments, null allowed if the method takes no parameters
|
||||
* @param args the arguments, null allowed if the method takes no parameters
|
||||
* @return the method or null if it isn't found
|
||||
*/
|
||||
public static Method hasMethod(Object obj, String mName, Object[] args) {
|
||||
@@ -487,9 +487,9 @@ public class BeanInspector {
|
||||
* parameter signature. Return it if found, or null if not.
|
||||
*
|
||||
* @param obj
|
||||
* @param mName the method name
|
||||
* @param mName the method name
|
||||
* @param paramTypes the parameter types, null allowed if no parameters are
|
||||
* expected
|
||||
* expected
|
||||
* @return the method or null if it isn't found
|
||||
*/
|
||||
public static Method hasMethod(Object obj, String mName, Class[] paramTypes) {
|
||||
@@ -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) {
|
||||
@@ -604,8 +603,8 @@ public class BeanInspector {
|
||||
* Just concatenates getClassDescription(obj) and getMemberDescriptions(obj,
|
||||
* withValues).
|
||||
*
|
||||
* @param obj target object
|
||||
* @param withValues if true, member values are displayed as well
|
||||
* @param obj target object
|
||||
* @param withValues if true, member values are displayed as well
|
||||
* @return an info string about class and members of the given object
|
||||
*/
|
||||
public static String getDescription(Object obj, boolean withValues) {
|
||||
@@ -651,8 +650,8 @@ public class BeanInspector {
|
||||
* member property is normal or hidden, meaning it may have effect depending
|
||||
* on settings of other members only, for instance.
|
||||
*
|
||||
* @param obj target object
|
||||
* @param withValues if true, member values are displayed as well
|
||||
* @param obj target object
|
||||
* @param withValues if true, member values are displayed as well
|
||||
* @return an info string about class and members of the given object
|
||||
*/
|
||||
public static String[] getMemberDescriptions(Object obj, boolean withValues) {
|
||||
@@ -741,7 +740,7 @@ public class BeanInspector {
|
||||
System.err.println("Skipping property " + name + " ; exception: " + ex.getMessage());
|
||||
ex.printStackTrace();
|
||||
} // end try
|
||||
} // end for
|
||||
} // end for
|
||||
return memberInfoList.toArray(new String[1]);
|
||||
}
|
||||
|
||||
@@ -1018,9 +1017,9 @@ public class BeanInspector {
|
||||
/**
|
||||
* This method simply looks for an appropriate tiptext
|
||||
*
|
||||
* @param name The name of the property
|
||||
* @param name The name of the property
|
||||
* @param methods A list of methods to search.
|
||||
* @param target The target object
|
||||
* @param target The target object
|
||||
* @return String for the ToolTip.
|
||||
*/
|
||||
public static String getToolTipText(String name, MethodDescriptor[] methods, Object target, boolean stripToolTipToFirstPoint, int toHTMLLen) {
|
||||
@@ -1057,9 +1056,9 @@ public class BeanInspector {
|
||||
/**
|
||||
* This method simply looks for an appropriate tool tip text
|
||||
*
|
||||
* @param name The name of the property
|
||||
* @param name The name of the property
|
||||
* @param methods A list of methods to search.
|
||||
* @param target The target object
|
||||
* @param target The target object
|
||||
* @return String for the ToolTip.
|
||||
*/
|
||||
public static String getToolTipText(String name, MethodDescriptor[] methods, Object target) {
|
||||
|
||||
@@ -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;
|
||||
@@ -53,9 +55,9 @@ public class EvAModuleButtonPanelMaker implements OptimizationStateListener, Ser
|
||||
public JToolBar makePanel() {
|
||||
toolBar = new JToolBar();
|
||||
toolBar.setFloatable(false);
|
||||
|
||||
|
||||
moduleAdapter.addOptimizationStateListener((OptimizationStateListener) (this));
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
runButton = ToolBoxGui.createIconifiedButton("images/Play24.gif", "Start", true);
|
||||
@@ -111,7 +113,7 @@ public class EvAModuleButtonPanelMaker implements OptimizationStateListener, Ser
|
||||
});
|
||||
postProcessButton.setEnabled(runningState && moduleAdapter.hasPostProcessing());
|
||||
toolBar.add(postProcessButton);
|
||||
|
||||
|
||||
scheduleButton = ToolBoxGui.createIconifiedButton("images/Server24.gif", "Schedule", true);
|
||||
scheduleButton.setToolTipText("Schedule the currently configured optimization as a job.");
|
||||
//scheduleButton.setBorderPainted(false);
|
||||
@@ -139,7 +141,7 @@ public class EvAModuleButtonPanelMaker implements OptimizationStateListener, Ser
|
||||
stopButton.setEnabled(true);
|
||||
runButton.setEnabled(false);
|
||||
postProcessButton.setEnabled(false);
|
||||
} catch (Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
System.err.print("Error in run: " + ex + " : " + ex.getMessage());
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -71,7 +72,7 @@ public class EvATabbedFrameMaker implements Serializable, PanelMaker, InterfaceN
|
||||
tabbedPane.addTab(((JParaPanel) element).getName(), panel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < tabbedPane.getTabCount(); i++) {
|
||||
tabbedPane.setTabComponentAt(i, new ClosableTabComponent(tabbedPane, tabToolBar));
|
||||
}
|
||||
@@ -86,8 +87,8 @@ public class EvATabbedFrameMaker implements Serializable, PanelMaker, InterfaceN
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @return The toolbar with control buttons
|
||||
* @deprecated
|
||||
*/
|
||||
public JExtToolBar getToolBar() {
|
||||
return extToolBar;
|
||||
@@ -151,16 +152,16 @@ public class EvATabbedFrameMaker implements Serializable, PanelMaker, InterfaceN
|
||||
|
||||
/**
|
||||
* Component to be used as tabComponent;
|
||||
* Contains a JLabel to show the text and
|
||||
* a JButton to close the tab it belongs to
|
||||
* Contains a JLabel to show the text and
|
||||
* a JButton to close the tab it belongs to
|
||||
*/
|
||||
class ClosableTabComponent extends JPanel {
|
||||
private final JTabbedPane pane;
|
||||
private final JToolBar toolBar;
|
||||
|
||||
|
||||
public ClosableTabComponent(final JTabbedPane pane, final JToolBar toolBar) {
|
||||
super(new FlowLayout(FlowLayout.LEADING, 0, 0));
|
||||
|
||||
|
||||
if (pane == null) {
|
||||
throw new NullPointerException("TabbedPane is null");
|
||||
}
|
||||
@@ -168,7 +169,7 @@ class ClosableTabComponent extends JPanel {
|
||||
this.toolBar = toolBar;
|
||||
this.toolBar.setVisible(false);
|
||||
setOpaque(false);
|
||||
|
||||
|
||||
//make JLabel read titles from JTabbedPane
|
||||
JLabel label = new JLabel() {
|
||||
@Override
|
||||
@@ -180,18 +181,18 @@ class ClosableTabComponent extends JPanel {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
add(label);
|
||||
//add more space between the label and the button
|
||||
label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
|
||||
//tab button
|
||||
JButton button = new TabButton();
|
||||
|
||||
|
||||
add(button);
|
||||
//add more space to the top of the component
|
||||
setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0));
|
||||
}
|
||||
|
||||
|
||||
private class TabButton extends JButton implements ActionListener {
|
||||
public TabButton() {
|
||||
int size = 17;
|
||||
@@ -212,7 +213,7 @@ class ClosableTabComponent extends JPanel {
|
||||
//Close the proper tab by clicking the button
|
||||
addActionListener(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
int i = pane.indexOfTabComponent(ClosableTabComponent.this);
|
||||
@@ -220,9 +221,9 @@ class ClosableTabComponent extends JPanel {
|
||||
final String tabTitle = pane.getTitleAt(i);
|
||||
final Component tabPane = pane.getComponentAt(i);
|
||||
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 */
|
||||
@@ -233,33 +234,33 @@ class ClosableTabComponent extends JPanel {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
/* Add the Tab Panel again */
|
||||
/* Add the Tab Panel again */
|
||||
// ToDo: Fix indexing problem
|
||||
pane.insertTab(tabTitle, null, tabPane, "", tabPosition);
|
||||
/* Set the tab component (closable) */
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//we don't want to update UI for this button
|
||||
@Override
|
||||
public void updateUI() {
|
||||
}
|
||||
|
||||
|
||||
//paint the cross
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
@@ -277,7 +278,7 @@ class ClosableTabComponent extends JPanel {
|
||||
g2.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private final static MouseListener buttonMouseListener = new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
@@ -287,7 +288,7 @@ class ClosableTabComponent extends JPanel {
|
||||
button.setBorderPainted(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
Component component = e.getComponent();
|
||||
|
||||
@@ -8,85 +8,83 @@ import javax.swing.tree.DefaultMutableTreeNode;
|
||||
* OptimizationParameters object, however this is not necessary.
|
||||
* 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;
|
||||
public class EvATreeNode extends DefaultMutableTreeNode {
|
||||
private String[] childrenNames = null;
|
||||
private Object[] childrenValues = null;
|
||||
private String myName = "EvATreeNode";
|
||||
private boolean doListPrimitives = false;
|
||||
|
||||
/**
|
||||
* A default constructor setting the name and target object of
|
||||
* the tree. The children are generated immediately.
|
||||
* The node label is constructed from the name String and the
|
||||
* information retrieved from the target object if it implements the getName method.
|
||||
*
|
||||
* @param name title of the node
|
||||
* @param target
|
||||
*/
|
||||
public EvATreeNode(String name, Object target) {
|
||||
super(target);
|
||||
myName = name;
|
||||
setObject(target, true);
|
||||
}
|
||||
/**
|
||||
* A default constructor setting the name and target object of
|
||||
* the tree. The children are generated immediately.
|
||||
* The node label is constructed from the name String and the
|
||||
* information retrieved from the target object if it implements the getName method.
|
||||
*
|
||||
* @param name title of the node
|
||||
* @param target
|
||||
*/
|
||||
public EvATreeNode(String name, Object target) {
|
||||
super(target);
|
||||
myName = name;
|
||||
setObject(target, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the target object of the tree. Note that the name is not automatically
|
||||
* updated and may be out of date if the new target object is incompatible to the
|
||||
* old name.
|
||||
*
|
||||
* @param target the new target object
|
||||
* @param expand should be true to generate child nodes immediately
|
||||
*/
|
||||
public void setObject(Object target, boolean expand) {
|
||||
super.setUserObject(target);
|
||||
childrenNames = PropertySheetPanel.getPropertyNames(target);
|
||||
childrenValues = PropertySheetPanel.getPropertyValues(target, true, true, true);
|
||||
super.removeAllChildren();
|
||||
if (expand) {
|
||||
initChildren();
|
||||
/**
|
||||
* Set the target object of the tree. Note that the name is not automatically
|
||||
* updated and may be out of date if the new target object is incompatible to the
|
||||
* old name.
|
||||
*
|
||||
* @param target the new target object
|
||||
* @param expand should be true to generate child nodes immediately
|
||||
*/
|
||||
public void setObject(Object target, boolean expand) {
|
||||
super.setUserObject(target);
|
||||
childrenNames = PropertySheetPanel.getPropertyNames(target);
|
||||
childrenValues = PropertySheetPanel.getPropertyValues(target, true, true, true);
|
||||
super.removeAllChildren();
|
||||
if (expand) {
|
||||
initChildren();
|
||||
}
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
myName = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return myName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Actually create child nodes.
|
||||
*/
|
||||
private void initChildren() {
|
||||
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]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
myName=name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return myName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Actually create child nodes.
|
||||
*/
|
||||
private void initChildren() {
|
||||
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]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String extendedInfo=null;
|
||||
try {
|
||||
extendedInfo=(String)BeanInspector.callIfAvailable(this.getUserObject(), "getName", new Object[]{});
|
||||
} catch (Exception e) {
|
||||
extendedInfo=null;
|
||||
}
|
||||
if (extendedInfo != null) {
|
||||
return myName + " - "+ extendedInfo;
|
||||
}
|
||||
else {
|
||||
return myName;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
String extendedInfo = null;
|
||||
try {
|
||||
extendedInfo = (String) BeanInspector.callIfAvailable(this.getUserObject(), "getName", new Object[]{});
|
||||
} catch (Exception e) {
|
||||
extendedInfo = null;
|
||||
}
|
||||
if (extendedInfo != null) {
|
||||
return myName + " - " + extendedInfo;
|
||||
} else {
|
||||
return myName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,68 +12,69 @@ import javax.swing.tree.TreePath;
|
||||
|
||||
/**
|
||||
* Listener for use with the EvATreeNode class. It implements both the tree selection listener
|
||||
* to react to selection changes in the tree view (and update the parameter panel),
|
||||
* to react to selection changes in the tree view (and update the parameter panel),
|
||||
* and the property change listener to
|
||||
* 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 EvATreeNode root = null;
|
||||
private JTree jtree = null;
|
||||
public static final boolean TRACE = true;
|
||||
private PropertyEditor goe = null;
|
||||
private EvATreeNode root = null;
|
||||
private JTree jtree = null;
|
||||
public static final boolean TRACE = true;
|
||||
|
||||
/**
|
||||
* Create a tree listener and hook it up in the editor to listen to parameter changes
|
||||
* and in the JTree to update it.
|
||||
*
|
||||
* @param rootNode the root node of the tree
|
||||
* @param goEditor the editor containing the parameter panel
|
||||
* @param jt the GUI view of the tree
|
||||
*/
|
||||
public EvATreeSelectionListener(EvATreeNode rootNode, PropertyEditor goEditor, JTree jt) {
|
||||
goe = goEditor;
|
||||
root = rootNode;
|
||||
jtree = jt;
|
||||
|
||||
if (jtree!=null) {
|
||||
jtree.addTreeSelectionListener(this);
|
||||
} // listen to tree selection changes
|
||||
if (goEditor!=null) {
|
||||
goEditor.addPropertyChangeListener(this);
|
||||
} // listen to changes to the parameters
|
||||
}
|
||||
/**
|
||||
* Create a tree listener and hook it up in the editor to listen to parameter changes
|
||||
* and in the JTree to update it.
|
||||
*
|
||||
* @param rootNode the root node of the tree
|
||||
* @param goEditor the editor containing the parameter panel
|
||||
* @param jt the GUI view of the tree
|
||||
*/
|
||||
public EvATreeSelectionListener(EvATreeNode rootNode, PropertyEditor goEditor, JTree jt) {
|
||||
goe = goEditor;
|
||||
root = rootNode;
|
||||
jtree = jt;
|
||||
|
||||
if (jtree != null) {
|
||||
jtree.addTreeSelectionListener(this);
|
||||
} // listen to tree selection changes
|
||||
if (goEditor != null) {
|
||||
goEditor.addPropertyChangeListener(this);
|
||||
} // listen to changes to the parameters
|
||||
}
|
||||
|
||||
@Override
|
||||
public void valueChanged(TreeSelectionEvent e) {
|
||||
if (TRACE) {
|
||||
System.out.println("valueChanged to " + BeanInspector.toString(e.getPath()));
|
||||
public void valueChanged(TreeSelectionEvent e) {
|
||||
if (TRACE) {
|
||||
System.out.println("valueChanged to " + BeanInspector.toString(e.getPath()));
|
||||
}
|
||||
TreePath tp = e.getPath();
|
||||
if (TRACE) {
|
||||
for (int i = tp.getPathCount() - 1; i >= 0; i--) {
|
||||
System.out.println("* " + i + " " + tp.getPathComponent(i));
|
||||
}
|
||||
TreePath tp = e.getPath();
|
||||
if (TRACE) {
|
||||
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());
|
||||
} else {
|
||||
System.err.println("Error, unable to notify custom editor of type " + editComp.getClass() + ", expected GOEPanel (EvATreeSelectionListener)");
|
||||
}
|
||||
}
|
||||
Component editComp = goe.getCustomEditor();
|
||||
if (editComp instanceof GOEPanel) {
|
||||
// update the object in the main GOEPanel
|
||||
((GOEPanel) editComp).setTarget(leafNode.getUserObject());
|
||||
} else {
|
||||
System.err.println("Error, unable to notify custom editor of type " + editComp.getClass() + ", expected GOEPanel (EvATreeSelectionListener)");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
if (TRACE) {
|
||||
System.out.println("EvATreeNode received change event " + evt);
|
||||
}
|
||||
root.setObject(evt.getNewValue(), true);
|
||||
if (jtree !=null) {
|
||||
jtree.setModel(new DefaultTreeModel(root));
|
||||
} // TODO this should be done differently so that the tree is not collapsed on each change!
|
||||
}
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
if (TRACE) {
|
||||
System.out.println("EvATreeNode received change event " + evt);
|
||||
}
|
||||
root.setObject(evt.getNewValue(), true);
|
||||
if (jtree != null) {
|
||||
jtree.setModel(new DefaultTreeModel(root));
|
||||
} // TODO this should be done differently so that the tree is not collapsed on each change!
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,67 +3,66 @@ package eva2.gui;
|
||||
import eva2.tools.chart2d.DFunction;
|
||||
|
||||
/**
|
||||
* Represents an exponential scaling function.
|
||||
* Represents an exponential scaling function.
|
||||
* MK: added a guard against undefined values: the smallest positive position can
|
||||
* 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) {
|
||||
minValue = v;
|
||||
}
|
||||
else {
|
||||
System.err.println("Error, minimal value for Exp must be positive!");
|
||||
}
|
||||
}
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see eva2.tools.chart2d.DFunction#isDefinedAt(double)
|
||||
*/
|
||||
@Override
|
||||
public boolean isDefinedAt(double source) {
|
||||
return true;
|
||||
}
|
||||
private double minValue = 1e-10; // think of a minimal value we want to show in case invalid (<=0) values are requested
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see eva2.tools.chart2d.DFunction#isInvertibleAt(double)
|
||||
*/
|
||||
@Override
|
||||
public boolean isInvertibleAt(double image) {
|
||||
return image > 0;
|
||||
}
|
||||
public void setMinValue(double v) {
|
||||
if (v > 0) {
|
||||
minValue = v;
|
||||
} else {
|
||||
System.err.println("Error, minimal value for Exp must be positive!");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see eva2.tools.chart2d.DFunction#getImageOf(double)
|
||||
*/
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see eva2.tools.chart2d.DFunction#isDefinedAt(double)
|
||||
*/
|
||||
@Override
|
||||
public double getImageOf(double source) {
|
||||
return Math.exp(source);
|
||||
}
|
||||
public boolean isDefinedAt(double source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see eva2.tools.chart2d.DFunction#getSourceOf(double)
|
||||
*/
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see eva2.tools.chart2d.DFunction#isInvertibleAt(double)
|
||||
*/
|
||||
@Override
|
||||
public double getSourceOf(double target) {
|
||||
if (target <= 0) {
|
||||
return Math.log(minValue); // think of a minimal value we want to show in case invalid values are requested
|
||||
public boolean isInvertibleAt(double image) {
|
||||
return image > 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see eva2.tools.chart2d.DFunction#getImageOf(double)
|
||||
*/
|
||||
@Override
|
||||
public double getImageOf(double source) {
|
||||
return Math.exp(source);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see eva2.tools.chart2d.DFunction#getSourceOf(double)
|
||||
*/
|
||||
@Override
|
||||
public double getSourceOf(double target) {
|
||||
if (target <= 0) {
|
||||
return Math.log(minValue); // think of a minimal value we want to show in case invalid values are requested
|
||||
// throw new IllegalArgumentException(
|
||||
// "Can not calculate log on values smaller than or equal 0 --> target = "
|
||||
// + target);
|
||||
}
|
||||
return Math.log(target);
|
||||
}
|
||||
|
||||
public void updateMinValue(double y) {
|
||||
if (y<minValue && (y>0)) {
|
||||
minValue=y;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Math.log(target);
|
||||
}
|
||||
|
||||
public void updateMinValue(double y) {
|
||||
if (y < minValue && (y > 0)) {
|
||||
minValue = y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,60 +12,67 @@ package eva2.gui;
|
||||
/*==========================================================================*
|
||||
* IMPORTS
|
||||
*==========================================================================*/
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.Action;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public abstract class ExtAction extends AbstractAction {
|
||||
public final static String CAPTION = "Caption";
|
||||
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){
|
||||
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){
|
||||
this(s, i, toolTip);
|
||||
if (i==null) {
|
||||
System.out.println("Icon == null");
|
||||
}
|
||||
putValue(KEYSTROKE, key);
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ExtAction(String s, Icon i, String toolTip){
|
||||
super(null, i);
|
||||
if (i==null) {
|
||||
System.out.println("Icon == null");
|
||||
}
|
||||
setValues(s, toolTip);
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ExtAction(String s, String toolTip, KeyStroke key){
|
||||
this(s, toolTip);
|
||||
putValue(KEYSTROKE, key);
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ExtAction(String s, String toolTip){
|
||||
super();
|
||||
setValues(s, toolTip);
|
||||
}
|
||||
public final static String CAPTION = "Caption";
|
||||
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) {
|
||||
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) {
|
||||
this(s, i, toolTip);
|
||||
if (i == null) {
|
||||
System.out.println("Icon == null");
|
||||
}
|
||||
putValue(KEYSTROKE, key);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ExtAction(String s, Icon i, String toolTip) {
|
||||
super(null, i);
|
||||
if (i == null) {
|
||||
System.out.println("Icon == null");
|
||||
}
|
||||
setValues(s, toolTip);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ExtAction(String s, String toolTip, KeyStroke key) {
|
||||
this(s, toolTip);
|
||||
putValue(KEYSTROKE, key);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
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{
|
||||
protected JComponent component;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
ExtActionChangedListener(JComponent c){
|
||||
super();
|
||||
setTarget(c);
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public abstract class ExtActionChangedListener implements PropertyChangeListener {
|
||||
protected JComponent component;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
ExtActionChangedListener(JComponent c) {
|
||||
super();
|
||||
setTarget(c);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public abstract void propertyChange(PropertyChangeEvent e);
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void setTarget(JComponent c){
|
||||
component = c;
|
||||
}
|
||||
public abstract void propertyChange(PropertyChangeEvent e);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
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;
|
||||
@@ -22,7 +23,7 @@ import javax.swing.KeyStroke;
|
||||
*
|
||||
*/
|
||||
public class ExtDesktopManager extends DefaultDesktopManager {
|
||||
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(ExtDesktopManager.class.getName());
|
||||
|
||||
int WINDOW_LIST_START;
|
||||
|
||||
@@ -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;
|
||||
@@ -29,7 +30,7 @@ import javax.swing.plaf.basic.BasicComboBoxRenderer;
|
||||
public class GOEPanel extends JPanel implements ItemListener {
|
||||
|
||||
private Object backupObject;
|
||||
private PropertyChangeSupport propChangeSupport;
|
||||
private PropertyChangeSupport propChangeSupport;
|
||||
/**
|
||||
* The chooser component
|
||||
*/
|
||||
@@ -97,11 +98,11 @@ public class GOEPanel extends JPanel implements ItemListener {
|
||||
propertySheetPanel = new PropertySheetPanel();
|
||||
propertySheetPanel.addPropertyChangeListener(
|
||||
new PropertyChangeListener() {
|
||||
@Override
|
||||
public void propertyChange(final PropertyChangeEvent event) {
|
||||
propChangeSupport.firePropertyChange("", backupObject, genericObjectEditor.getValue());
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void propertyChange(final PropertyChangeEvent event) {
|
||||
propChangeSupport.firePropertyChange("", backupObject, genericObjectEditor.getValue());
|
||||
}
|
||||
});
|
||||
openButton = makeIconButton("images/Open16.gif", "Open");
|
||||
openButton.setToolTipText("Load a configured object");
|
||||
openButton.setEnabled(true);
|
||||
@@ -409,8 +410,8 @@ public class GOEPanel extends JPanel implements ItemListener {
|
||||
objectChooser.setSelectedIndex(0);
|
||||
JOptionPane.showMessageDialog(this,
|
||||
"Could not create an example of\n"
|
||||
+ className + "\n"
|
||||
+ "from the current classpath. Is the resource folder at the right place?\nIs the class abstract or the default constructor missing?",
|
||||
+ className + "\n"
|
||||
+ "from the current classpath. Is the resource folder at the right place?\nIs the class abstract or the default constructor missing?",
|
||||
"GenericObjectEditor",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
EVAHELP.getSystemPropertyString();
|
||||
@@ -431,7 +432,7 @@ class ToolTipComboBoxRenderer extends BasicComboBoxRenderer {
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList list, Object value,
|
||||
int index, boolean isSelected, boolean cellHasFocus) {
|
||||
int index, boolean isSelected, boolean cellHasFocus) {
|
||||
if (isSelected) {
|
||||
setBackground(list.getSelectionBackground());
|
||||
setForeground(list.getSelectionForeground());
|
||||
|
||||
@@ -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,48 +27,53 @@ 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;
|
||||
}
|
||||
private JEditorPane m_html;
|
||||
private String m_name;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
*
|
||||
*/
|
||||
public HtmlDemo(String name) {
|
||||
m_name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public JEditorPane getPane() {
|
||||
return m_html;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
HtmlDemo demo = new HtmlDemo("ES.html");
|
||||
demo.show();
|
||||
}
|
||||
|
||||
|
||||
public boolean resourceExists() {
|
||||
URL url = ClassLoader.getSystemResource("html/"+m_name);
|
||||
return (url != null);
|
||||
URL url = ClassLoader.getSystemResource("html/" + m_name);
|
||||
return (url != null);
|
||||
}
|
||||
|
||||
|
||||
public static boolean resourceExists(String mname) {
|
||||
URL url = ClassLoader.getSystemResource("html/"+mname);
|
||||
return (url != null);
|
||||
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,39 +93,39 @@ public class HtmlDemo {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
JFrame frame = new JFrame (m_name);
|
||||
BasicResourceLoader loader = BasicResourceLoader.instance();
|
||||
byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation, true);
|
||||
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();
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public HyperlinkListener createHyperLinkListener() {
|
||||
return new HyperlinkListener() {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public HyperlinkListener createHyperLinkListener() {
|
||||
return new HyperlinkListener() {
|
||||
@Override
|
||||
public void hyperlinkUpdate(HyperlinkEvent e) {
|
||||
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
|
||||
if (e instanceof HTMLFrameHyperlinkEvent) {
|
||||
((HTMLDocument)m_html.getDocument()).processHTMLFrameHyperlinkEvent(
|
||||
(HTMLFrameHyperlinkEvent)e);
|
||||
} else {
|
||||
try {
|
||||
m_html.setPage(e.getURL());
|
||||
} catch (IOException ioe) {
|
||||
System.out.println("IOE: " + ioe);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
public void hyperlinkUpdate(HyperlinkEvent e) {
|
||||
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
|
||||
if (e instanceof HTMLFrameHyperlinkEvent) {
|
||||
((HTMLDocument) m_html.getDocument()).processHTMLFrameHyperlinkEvent(
|
||||
(HTMLFrameHyperlinkEvent) e);
|
||||
} else {
|
||||
try {
|
||||
m_html.setPage(e.getURL());
|
||||
} catch (IOException ioe) {
|
||||
System.out.println("IOE: " + ioe);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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{
|
||||
private File m_file;
|
||||
private String titleStr;
|
||||
protected boolean changed = false;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public JDocFrame(String title){
|
||||
super(title, true, true /* not closable*/, true, true);
|
||||
titleStr = title;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public JDocFrame(File file){
|
||||
this(file.getName());
|
||||
m_file = file;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public File getFile(){
|
||||
return m_file;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public String getFileTitle(){
|
||||
return titleStr;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void save(){
|
||||
if(m_file != null) {
|
||||
save(m_file);
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void save(File f){
|
||||
if(!f.equals(m_file)){
|
||||
m_file = f;
|
||||
titleStr = f.getName();
|
||||
public abstract class JDocFrame extends JInternalFrame {
|
||||
private File m_file;
|
||||
private String titleStr;
|
||||
protected boolean changed = false;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public JDocFrame(String title) {
|
||||
super(title, true, true /* not closable*/, true, true);
|
||||
titleStr = title;
|
||||
}
|
||||
setChangedImpl(false);
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void setChangedImpl(boolean value){
|
||||
changed = value;
|
||||
if(changed) {
|
||||
setTitle(titleStr + " *");
|
||||
}
|
||||
else {
|
||||
setTitle(titleStr);
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected void setChanged(boolean value){
|
||||
if(changed != value) {
|
||||
setChangedImpl(value);
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public boolean isChanged(){
|
||||
return changed;
|
||||
}
|
||||
public abstract String[] getActionGroups();
|
||||
public abstract JMenu getMenu(String group);
|
||||
public abstract JToolBar getToolBar(String group);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public JDocFrame(File file) {
|
||||
this(file.getName());
|
||||
m_file = file;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public File getFile() {
|
||||
return m_file;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public String getFileTitle() {
|
||||
return titleStr;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void save() {
|
||||
if (m_file != null) {
|
||||
save(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) {
|
||||
changed = value;
|
||||
if (changed) {
|
||||
setTitle(titleStr + " *");
|
||||
} else {
|
||||
setTitle(titleStr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected void setChanged(boolean value) {
|
||||
if (changed != value) {
|
||||
setChangedImpl(value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public boolean isChanged() {
|
||||
return changed;
|
||||
}
|
||||
|
||||
public abstract String[] getActionGroups();
|
||||
|
||||
public abstract JMenu getMenu(String group);
|
||||
|
||||
public abstract JToolBar getToolBar(String group);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,42 +22,42 @@ import javax.swing.event.InternalFrameEvent;
|
||||
import javax.swing.event.InternalFrameListener;
|
||||
|
||||
public class JEFrame extends JInternalFrame {
|
||||
private boolean closeAllOnClose = false;
|
||||
|
||||
public JEFrame() {
|
||||
super();
|
||||
init();
|
||||
}
|
||||
private boolean closeAllOnClose = false;
|
||||
|
||||
public JEFrame(String name) {
|
||||
super(name);
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set to true if all registered JEFrames should be closed if this frame is closed.
|
||||
*
|
||||
* @param c
|
||||
*/
|
||||
public void setCloseAllOnClosed(boolean c) {
|
||||
closeAllOnClose = c;
|
||||
}
|
||||
public JEFrame() {
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInternalFrameListener(InternalFrameListener l) {
|
||||
super.addInternalFrameListener(l);
|
||||
}
|
||||
public JEFrame(String name) {
|
||||
super(name);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||
|
||||
this.addInternalFrameListener(new InternalFrameAdapter() {
|
||||
/**
|
||||
* Set to true if all registered JEFrames should be closed if this frame is closed.
|
||||
*
|
||||
* @param c
|
||||
*/
|
||||
public void setCloseAllOnClosed(boolean c) {
|
||||
closeAllOnClose = c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInternalFrameListener(InternalFrameListener l) {
|
||||
super.addInternalFrameListener(l);
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||
|
||||
this.addInternalFrameListener(new InternalFrameAdapter() {
|
||||
|
||||
@Override
|
||||
public void internalFrameClosed(InternalFrameEvent e) {
|
||||
super.internalFrameClosed(e);
|
||||
JEFrameRegister.getInstance().unregister((JEFrame) e.getInternalFrame());
|
||||
if (closeAllOnClose) {
|
||||
JEFrameRegister.getInstance().unregister((JEFrame) e.getInternalFrame());
|
||||
if (closeAllOnClose) {
|
||||
JEFrameRegister.getInstance().closeAll();
|
||||
}
|
||||
}
|
||||
@@ -70,59 +70,59 @@ public class JEFrame extends JInternalFrame {
|
||||
|
||||
@Override
|
||||
public void internalFrameActivated(InternalFrameEvent e) {
|
||||
JEFrameRegister.getInstance().register((JEFrame) e.getInternalFrame());
|
||||
super.internalFrameActivated(e);
|
||||
JEFrameRegister.getInstance().register((JEFrame) e.getInternalFrame());
|
||||
super.internalFrameActivated(e);
|
||||
}
|
||||
});
|
||||
this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_F, Event.CTRL_MASK),
|
||||
"ctrlFpressed"
|
||||
);
|
||||
this.getRootPane().getActionMap().put(
|
||||
"ctrlFpressed",
|
||||
new AbstractAction("ctrlFpressed") {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
});
|
||||
this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_F, Event.CTRL_MASK),
|
||||
"ctrlFpressed"
|
||||
);
|
||||
this.getRootPane().getActionMap().put(
|
||||
"ctrlFpressed",
|
||||
new AbstractAction("ctrlFpressed") {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
JEFrameRegister.getInstance().getFrameList().get(0).toFront();
|
||||
}
|
||||
}
|
||||
);
|
||||
this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_O, Event.CTRL_MASK),
|
||||
"ctrlOpressed"
|
||||
);
|
||||
this.getRootPane().getActionMap().put(
|
||||
"ctrlOpressed",
|
||||
new AbstractAction("ctrlOpressed") {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
java.util.List<JEFrame> frameList = JEFrameRegister.getInstance().getFrameList();
|
||||
for (JEFrame frame : frameList) {
|
||||
}
|
||||
}
|
||||
);
|
||||
this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_O, Event.CTRL_MASK),
|
||||
"ctrlOpressed"
|
||||
);
|
||||
this.getRootPane().getActionMap().put(
|
||||
"ctrlOpressed",
|
||||
new AbstractAction("ctrlOpressed") {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
java.util.List<JEFrame> frameList = JEFrameRegister.getInstance().getFrameList();
|
||||
for (JEFrame frame : frameList) {
|
||||
frame.toFront();
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_LESS , Event.CTRL_MASK),
|
||||
"ctrlSmallerpressed"
|
||||
);
|
||||
final JEFrame self = this;
|
||||
this.getRootPane().getActionMap().put(
|
||||
"ctrlSmallerpressed",
|
||||
new AbstractAction("ctrlSmallerpressed") {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
JEFrameRegister.getInstance().setFocusToNext(self);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
);
|
||||
this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_LESS, Event.CTRL_MASK),
|
||||
"ctrlSmallerpressed"
|
||||
);
|
||||
final JEFrame self = this;
|
||||
this.getRootPane().getActionMap().put(
|
||||
"ctrlSmallerpressed",
|
||||
new AbstractAction("ctrlSmallerpressed") {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
JEFrameRegister.getInstance().setFocusToNext(self);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
this.setMaximizable(true);
|
||||
this.setResizable(true);
|
||||
this.setIconifiable(true);
|
||||
this.setClosable(true);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package eva2.gui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.swing.JDesktopPane;
|
||||
|
||||
@@ -39,7 +39,7 @@ public class JExtDesktopPane extends JDesktopPane {
|
||||
*/
|
||||
public JExtDesktopPane() {
|
||||
super();
|
||||
|
||||
|
||||
windowMenu = new JExtMenu("&Windows");
|
||||
desktopManager = new ExtDesktopManager(this);
|
||||
setDesktopManager(desktopManager);
|
||||
@@ -65,7 +65,7 @@ public class JExtDesktopPane extends JDesktopPane {
|
||||
}
|
||||
});
|
||||
|
||||
windowMenu.add(actWindowTileHorz = new ExtAction("Tile &Horizontally", "Tiles all windows horizontically",
|
||||
windowMenu.add(actWindowTileHorz = new ExtAction("Tile &Horizontally", "Tiles all windows horizontically",
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_PERIOD, Event.CTRL_MASK)) {
|
||||
|
||||
@Override
|
||||
@@ -89,10 +89,10 @@ 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,19 +9,18 @@ import javax.swing.JToolBar;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author becker
|
||||
*/
|
||||
public class JExtDesktopPaneToolBar extends JToolBar {
|
||||
|
||||
|
||||
private JExtDesktopPane desktopPane;
|
||||
|
||||
|
||||
public JExtDesktopPaneToolBar(JExtDesktopPane desktopPane) {
|
||||
this.desktopPane = desktopPane;
|
||||
|
||||
|
||||
initComponents();
|
||||
}
|
||||
|
||||
|
||||
private void initComponents() {
|
||||
/* We don't want the ToolBar to be draggable */
|
||||
setFloatable(false);
|
||||
@@ -33,10 +33,10 @@ public class JExtDesktopPaneToolBar extends JToolBar {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
desktopPane.tileWindows(SwingConstants.VERTICAL);
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
add(verticalButton);
|
||||
|
||||
add(verticalButton);
|
||||
|
||||
JButton horizontalButton = ToolBoxGui.createIconifiedButton("images/TileHorizontal16.png", "Tile horizontally", false);
|
||||
horizontalButton.addActionListener(new ActionListener() {
|
||||
|
||||
@@ -44,10 +44,10 @@ public class JExtDesktopPaneToolBar extends JToolBar {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
desktopPane.tileWindows(SwingConstants.HORIZONTAL);
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
add(horizontalButton);
|
||||
|
||||
|
||||
JButton cascadeButton = ToolBoxGui.createIconifiedButton("images/Cascade16.png", "Cascade windows", false);
|
||||
cascadeButton.addActionListener(new ActionListener() {
|
||||
|
||||
@@ -55,7 +55,7 @@ public class JExtDesktopPaneToolBar extends JToolBar {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
desktopPane.overlapWindows();
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
add(cascadeButton);
|
||||
}
|
||||
|
||||
@@ -12,32 +12,33 @@ package eva2.gui;
|
||||
/*==========================================================================*
|
||||
* IMPORTS
|
||||
*==========================================================================*/
|
||||
|
||||
import java.io.File;
|
||||
import javax.swing.*;
|
||||
|
||||
public class JExtFileChooser extends JFileChooser{
|
||||
private boolean overwriteWarning = true;
|
||||
public class JExtFileChooser extends JFileChooser {
|
||||
private boolean overwriteWarning = true;
|
||||
|
||||
public void setOverwriteWarning(boolean value){
|
||||
overwriteWarning = value;
|
||||
}
|
||||
|
||||
public boolean getOverwriteWarning(){
|
||||
return overwriteWarning;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void approveSelection(){
|
||||
if(getDialogType() == JFileChooser.SAVE_DIALOG && overwriteWarning){
|
||||
File f = getSelectedFile();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
public void setOverwriteWarning(boolean value) {
|
||||
overwriteWarning = value;
|
||||
}
|
||||
|
||||
super.approveSelection();
|
||||
}
|
||||
public boolean getOverwriteWarning() {
|
||||
return overwriteWarning;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void approveSelection() {
|
||||
if (getDialogType() == JFileChooser.SAVE_DIALOG && overwriteWarning) {
|
||||
File f = getSelectedFile();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.approveSelection();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,78 +9,77 @@ 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){
|
||||
JButton button = super.add(a);
|
||||
button.setText(null);
|
||||
button.setMargin(new Insets(0, 0, 0, 0));
|
||||
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 : "";
|
||||
Object o;
|
||||
o = a.getValue(ExtAction.TOOLTIP);
|
||||
String toolTip = o != null ? (String) o : "";
|
||||
|
||||
o = a.getValue(ExtAction.KEYSTROKE);
|
||||
button.setToolTipText(toolTip + getKeyText((KeyStroke)o));
|
||||
o = a.getValue(ExtAction.KEYSTROKE);
|
||||
button.setToolTipText(toolTip + getKeyText((KeyStroke) o));
|
||||
|
||||
return button;
|
||||
}
|
||||
return button;
|
||||
}
|
||||
|
||||
private String getKeyText(KeyStroke k){
|
||||
StringBuffer result = new StringBuffer();
|
||||
private String getKeyText(KeyStroke k) {
|
||||
StringBuffer result = new StringBuffer();
|
||||
|
||||
if(k != null){
|
||||
int modifiers = k.getModifiers();
|
||||
if(modifiers > 0) {
|
||||
result.append(KeyEvent.getKeyModifiersText(modifiers) + "+");
|
||||
if (k != null) {
|
||||
int modifiers = k.getModifiers();
|
||||
if (modifiers > 0) {
|
||||
result.append(KeyEvent.getKeyModifiersText(modifiers) + "+");
|
||||
}
|
||||
result.append(KeyEvent.getKeyText(k.getKeyCode()));
|
||||
}
|
||||
if (result.length() > 0) {
|
||||
result.insert(0, " [");
|
||||
result.append("]");
|
||||
}
|
||||
result.append(KeyEvent.getKeyText(k.getKeyCode()));
|
||||
}
|
||||
if(result.length() > 0){
|
||||
result.insert(0, " [");
|
||||
result.append("]");
|
||||
}
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
@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)){
|
||||
String propertyName = e.getPropertyName();
|
||||
if (propertyName.equals(Action.NAME)) {
|
||||
/* Nichts tun! */
|
||||
}
|
||||
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());
|
||||
button.invalidate();
|
||||
button.repaint();
|
||||
}
|
||||
else if(propertyName.equals(ExtAction.TOOLTIP) || propertyName.equals(ExtAction.KEYSTROKE)){
|
||||
Action source = (Action)e.getSource();
|
||||
} 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());
|
||||
button.invalidate();
|
||||
button.repaint();
|
||||
} 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 : "";
|
||||
o = source.getValue(ExtAction.KEYSTROKE);
|
||||
button.setToolTipText(toolTip + getKeyText((KeyStroke)o));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
Object o = source.getValue(ExtAction.TOOLTIP);
|
||||
String toolTip = o != null ? (String) o : "";
|
||||
o = source.getValue(ExtAction.KEYSTROKE);
|
||||
button.setToolTipText(toolTip + getKeyText((KeyStroke) o));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class JParaPanel implements Serializable, PanelMaker {
|
||||
protected Object localParameter;
|
||||
protected Object proxyParameter;
|
||||
protected PropertyEditor propertyEditor;
|
||||
|
||||
|
||||
/**
|
||||
* ToDo: Should be removed in future.
|
||||
*/
|
||||
@@ -49,12 +49,12 @@ public class JParaPanel implements Serializable, PanelMaker {
|
||||
/* ToDo: First parameter is useless and should be removed */
|
||||
propertyEditor = OptimizationJobList.makeEditor(tempPanel, (OptimizationJobList) localParameter);
|
||||
} else {
|
||||
propertyEditor = new GenericObjectEditor();
|
||||
((GenericObjectEditor) (propertyEditor)).setClassType(localParameter.getClass());
|
||||
((GenericObjectEditor) (propertyEditor)).setValue(localParameter);
|
||||
((GenericObjectEditor) (propertyEditor)).disableOKCancel();
|
||||
propertyEditor = new GenericObjectEditor();
|
||||
((GenericObjectEditor) (propertyEditor)).setClassType(localParameter.getClass());
|
||||
((GenericObjectEditor) (propertyEditor)).setValue(localParameter);
|
||||
((GenericObjectEditor) (propertyEditor)).disableOKCancel();
|
||||
}
|
||||
|
||||
|
||||
return (JComponent) propertyEditor.getCustomEditor();
|
||||
}
|
||||
|
||||
@@ -65,10 +65,12 @@ public class JParaPanel implements Serializable, PanelMaker {
|
||||
}
|
||||
|
||||
public PropertyEditor getEditor() {
|
||||
return propertyEditor;
|
||||
return propertyEditor;
|
||||
}
|
||||
|
||||
/** This method will allow you to add a new Editor to a given class
|
||||
|
||||
/**
|
||||
* This method will allow you to add a new Editor to a given class
|
||||
*
|
||||
* @param object
|
||||
* @param 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,296 +23,301 @@ import javax.swing.text.*;
|
||||
import javax.swing.undo.*;
|
||||
|
||||
|
||||
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(){
|
||||
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);
|
||||
}
|
||||
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();
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e){
|
||||
try{
|
||||
undo.undo();
|
||||
}
|
||||
catch(CannotUndoException exc){}
|
||||
|
||||
update();
|
||||
actRedo.update();
|
||||
}
|
||||
|
||||
private void update() {
|
||||
if(undo.canUndo()){
|
||||
setEnabled(true);
|
||||
putValue(Action.NAME, undo.getUndoPresentationName());
|
||||
}
|
||||
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));
|
||||
setEnabled(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try{
|
||||
undo.redo();
|
||||
}
|
||||
catch(CannotRedoException exc){}
|
||||
|
||||
update();
|
||||
actUndo.update();
|
||||
}
|
||||
|
||||
private void update() {
|
||||
if(undo.canRedo()){
|
||||
setEnabled(true);
|
||||
putValue(Action.NAME, undo.getRedoPresentationName());
|
||||
}
|
||||
else{
|
||||
setEnabled(false);
|
||||
putValue(Action.NAME, "Wiederholen");
|
||||
}
|
||||
}
|
||||
} // end of inner class RedoAction
|
||||
|
||||
private UndoAction actUndo;
|
||||
private RedoAction actRedo;
|
||||
public final static String undoAction = "undo";
|
||||
public final static String redoAction = "redo";
|
||||
///////////////////////////////////////////
|
||||
//
|
||||
/////////////////////////////////////////
|
||||
@Override
|
||||
public String[] getActionGroups(){
|
||||
return actionGroups;
|
||||
}
|
||||
|
||||
private JMenu mnuEdit;
|
||||
private JToolBar barEdit;
|
||||
@Override
|
||||
public JMenu getMenu(String group){
|
||||
if(GROUP_EDIT.equals(group)) {
|
||||
return mnuEdit;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public JToolBar getToolBar(String group){
|
||||
if(GROUP_EDIT.equals(group)) {
|
||||
return barEdit;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Hashtable hashActions = new Hashtable();
|
||||
|
||||
private Action cloneAction(Action a){
|
||||
Action result = null;
|
||||
|
||||
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();
|
||||
}
|
||||
catch(Exception exc){}
|
||||
|
||||
return result;
|
||||
}
|
||||
///////////////////////////////////////////////
|
||||
//
|
||||
//////////////////////////////////////////////
|
||||
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]);
|
||||
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);
|
||||
}
|
||||
|
||||
mnuEdit = new JExtMenu("&Bearbeiten");
|
||||
barEdit = new JExtToolBar();
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
undo.undo();
|
||||
} catch (CannotUndoException exc) {
|
||||
}
|
||||
|
||||
Action a;
|
||||
Keymap keys = textArea.getKeymap();
|
||||
KeyStroke[] keyActions;
|
||||
update();
|
||||
actRedo.update();
|
||||
}
|
||||
|
||||
mnuEdit.add(actUndo);
|
||||
barEdit.add(actUndo);
|
||||
mnuEdit.add(actRedo);
|
||||
mnuEdit.addSeparator();
|
||||
private void update() {
|
||||
if (undo.canUndo()) {
|
||||
setEnabled(true);
|
||||
putValue(Action.NAME, undo.getUndoPresentationName());
|
||||
} else {
|
||||
setEnabled(false);
|
||||
putValue(Action.NAME, "R<EFBFBD>ckg<EFBFBD>ngig");
|
||||
}
|
||||
}
|
||||
} // end of inner class UndoAction
|
||||
|
||||
a = (Action)hashActions.get(DefaultEditorKit.cutAction);
|
||||
keyActions = keys.getKeyStrokesForAction(a);
|
||||
if(keyActions != null && keyActions.length > 0) {
|
||||
a.putValue(ExtAction.KEYSTROKE, keyActions[0]);
|
||||
}
|
||||
a.putValue(Action.SMALL_ICON, new ImageIcon("images/EditCut.gif"));
|
||||
a.putValue(ExtAction.CAPTION, "Ausschneiden");
|
||||
a.putValue(ExtAction.MNEMONIC, new Character('a'));
|
||||
a.putValue(ExtAction.TOOLTIP, "Schneidet den markierten Text aus und setzt ihn in die Zwischenablage");
|
||||
mnuEdit.add(a);
|
||||
barEdit.add(a);
|
||||
///////////////////////////////////////////
|
||||
//
|
||||
///////////////////////////////////////////
|
||||
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);
|
||||
}
|
||||
|
||||
a = (Action)hashActions.get(DefaultEditorKit.copyAction);
|
||||
keyActions = keys.getKeyStrokesForAction(a);
|
||||
if(keyActions != null && keyActions.length > 0) {
|
||||
a.putValue(ExtAction.KEYSTROKE, keyActions[0]);
|
||||
}
|
||||
a.putValue(Action.SMALL_ICON, new ImageIcon("images/EditCopy.gif"));
|
||||
a.putValue(ExtAction.CAPTION, "Kopieren");
|
||||
a.putValue(ExtAction.MNEMONIC, new Character('k'));
|
||||
a.putValue(ExtAction.TOOLTIP, "Kopiert den markierten Text in die Zwischenablage");
|
||||
mnuEdit.add(a);
|
||||
barEdit.add(a);
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
undo.redo();
|
||||
} catch (CannotRedoException exc) {
|
||||
}
|
||||
|
||||
a = (Action)hashActions.get(DefaultEditorKit.pasteAction);
|
||||
keyActions = keys.getKeyStrokesForAction(a);
|
||||
if(keyActions != null && keyActions.length > 0) {
|
||||
a.putValue(ExtAction.KEYSTROKE, keyActions[0]);
|
||||
}
|
||||
a.putValue(Action.SMALL_ICON, new ImageIcon("images/EditPaste.gif"));
|
||||
a.putValue(ExtAction.CAPTION, "Einf<EFBFBD>gen");
|
||||
a.putValue(ExtAction.MNEMONIC, new Character('e'));
|
||||
a.putValue(ExtAction.TOOLTIP, "F<EFBFBD>gt Text aus der Zwischenablage ein");
|
||||
mnuEdit.add(a);
|
||||
barEdit.add(a);
|
||||
update();
|
||||
actUndo.update();
|
||||
}
|
||||
|
||||
mnuEdit.addSeparator();
|
||||
private void update() {
|
||||
if (undo.canRedo()) {
|
||||
setEnabled(true);
|
||||
putValue(Action.NAME, undo.getRedoPresentationName());
|
||||
} else {
|
||||
setEnabled(false);
|
||||
putValue(Action.NAME, "Wiederholen");
|
||||
}
|
||||
}
|
||||
} // end of inner class RedoAction
|
||||
|
||||
a = (Action)hashActions.get(DefaultEditorKit.selectAllAction);
|
||||
keyActions = keys.getKeyStrokesForAction(a);
|
||||
if(keyActions != null && keyActions.length > 0) {
|
||||
a.putValue(ExtAction.KEYSTROKE, keyActions[0]);
|
||||
}
|
||||
a.putValue(ExtAction.CAPTION, "Alles markieren");
|
||||
a.putValue(ExtAction.MNEMONIC, new Character('m'));
|
||||
a.putValue(ExtAction.TOOLTIP, "Markiert das ganze Dokument");
|
||||
mnuEdit.add(a);
|
||||
}
|
||||
//////////////////////////////////////////
|
||||
//
|
||||
/////////////////////////////////////////
|
||||
private void createTextArea(){
|
||||
textArea = new JTextArea();
|
||||
getContentPane().add(new JScrollPane(textArea));
|
||||
}
|
||||
/////////////////////////////////////
|
||||
//
|
||||
/////////////////////////////////////
|
||||
private void createListeners(){
|
||||
textArea.getDocument().addDocumentListener(new DocumentListener(){
|
||||
private void changed(){
|
||||
setChanged(true);
|
||||
}
|
||||
private UndoAction actUndo;
|
||||
private RedoAction actRedo;
|
||||
public final static String undoAction = "undo";
|
||||
public final static String redoAction = "redo";
|
||||
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e){
|
||||
changed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e){
|
||||
changed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent e){
|
||||
changed();
|
||||
}
|
||||
});
|
||||
|
||||
textArea.getDocument().addUndoableEditListener(new UndoableEditListener(){
|
||||
@Override
|
||||
public void undoableEditHappened(UndoableEditEvent e){
|
||||
undo.addEdit(e.getEdit());
|
||||
actUndo.update();
|
||||
actRedo.update();
|
||||
}
|
||||
});
|
||||
}
|
||||
////////////////////////////////////////////////////
|
||||
//
|
||||
///////////////////////////////////////////////////
|
||||
public JTextEditorInternalFrame(String title){
|
||||
super(title);
|
||||
createTextArea();
|
||||
createListeners();
|
||||
createActions();
|
||||
}
|
||||
//////////////////////////////////////////////////
|
||||
//
|
||||
/////////////////////////////////////////////////
|
||||
public JTextEditorInternalFrame(File file){
|
||||
super(file);
|
||||
createTextArea();
|
||||
|
||||
if(file.exists()){
|
||||
FileReader in = null;
|
||||
try{
|
||||
in = new FileReader(file);
|
||||
textArea.read(in, null);
|
||||
}
|
||||
catch(IOException exc){}
|
||||
finally{
|
||||
if(in != null) {
|
||||
try{
|
||||
in.close();
|
||||
}
|
||||
catch(IOException exc){}
|
||||
}
|
||||
}
|
||||
///////////////////////////////////////////
|
||||
//
|
||||
/////////////////////////////////////////
|
||||
@Override
|
||||
public String[] getActionGroups() {
|
||||
return actionGroups;
|
||||
}
|
||||
|
||||
createListeners();
|
||||
createActions();
|
||||
}
|
||||
private JMenu mnuEdit;
|
||||
private JToolBar barEdit;
|
||||
|
||||
@Override
|
||||
public void save(File f){
|
||||
FileWriter out = null;
|
||||
try{
|
||||
out = new FileWriter(f);
|
||||
textArea.write(out);
|
||||
}
|
||||
catch(IOException exc){}
|
||||
finally{
|
||||
if(out != null) {
|
||||
try{
|
||||
out.close();
|
||||
}
|
||||
catch(IOException exc){}
|
||||
public JMenu getMenu(String group) {
|
||||
if (GROUP_EDIT.equals(group)) {
|
||||
return mnuEdit;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
super.save(f);
|
||||
}
|
||||
@Override
|
||||
public JToolBar getToolBar(String group) {
|
||||
if (GROUP_EDIT.equals(group)) {
|
||||
return barEdit;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Hashtable hashActions = new Hashtable();
|
||||
|
||||
private Action cloneAction(Action a) {
|
||||
Action result = null;
|
||||
|
||||
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();
|
||||
} catch (Exception exc) {
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////
|
||||
//
|
||||
//////////////////////////////////////////////
|
||||
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]);
|
||||
}
|
||||
|
||||
mnuEdit = new JExtMenu("&Bearbeiten");
|
||||
barEdit = new JExtToolBar();
|
||||
|
||||
Action a;
|
||||
Keymap keys = textArea.getKeymap();
|
||||
KeyStroke[] keyActions;
|
||||
|
||||
mnuEdit.add(actUndo);
|
||||
barEdit.add(actUndo);
|
||||
mnuEdit.add(actRedo);
|
||||
mnuEdit.addSeparator();
|
||||
|
||||
a = (Action) hashActions.get(DefaultEditorKit.cutAction);
|
||||
keyActions = keys.getKeyStrokesForAction(a);
|
||||
if (keyActions != null && keyActions.length > 0) {
|
||||
a.putValue(ExtAction.KEYSTROKE, keyActions[0]);
|
||||
}
|
||||
a.putValue(Action.SMALL_ICON, new ImageIcon("images/EditCut.gif"));
|
||||
a.putValue(ExtAction.CAPTION, "Ausschneiden");
|
||||
a.putValue(ExtAction.MNEMONIC, new Character('a'));
|
||||
a.putValue(ExtAction.TOOLTIP, "Schneidet den markierten Text aus und setzt ihn in die Zwischenablage");
|
||||
mnuEdit.add(a);
|
||||
barEdit.add(a);
|
||||
|
||||
a = (Action) hashActions.get(DefaultEditorKit.copyAction);
|
||||
keyActions = keys.getKeyStrokesForAction(a);
|
||||
if (keyActions != null && keyActions.length > 0) {
|
||||
a.putValue(ExtAction.KEYSTROKE, keyActions[0]);
|
||||
}
|
||||
a.putValue(Action.SMALL_ICON, new ImageIcon("images/EditCopy.gif"));
|
||||
a.putValue(ExtAction.CAPTION, "Kopieren");
|
||||
a.putValue(ExtAction.MNEMONIC, new Character('k'));
|
||||
a.putValue(ExtAction.TOOLTIP, "Kopiert den markierten Text in die Zwischenablage");
|
||||
mnuEdit.add(a);
|
||||
barEdit.add(a);
|
||||
|
||||
a = (Action) hashActions.get(DefaultEditorKit.pasteAction);
|
||||
keyActions = keys.getKeyStrokesForAction(a);
|
||||
if (keyActions != null && keyActions.length > 0) {
|
||||
a.putValue(ExtAction.KEYSTROKE, keyActions[0]);
|
||||
}
|
||||
a.putValue(Action.SMALL_ICON, new ImageIcon("images/EditPaste.gif"));
|
||||
a.putValue(ExtAction.CAPTION, "Einf<EFBFBD>gen");
|
||||
a.putValue(ExtAction.MNEMONIC, new Character('e'));
|
||||
a.putValue(ExtAction.TOOLTIP, "F<EFBFBD>gt Text aus der Zwischenablage ein");
|
||||
mnuEdit.add(a);
|
||||
barEdit.add(a);
|
||||
|
||||
mnuEdit.addSeparator();
|
||||
|
||||
a = (Action) hashActions.get(DefaultEditorKit.selectAllAction);
|
||||
keyActions = keys.getKeyStrokesForAction(a);
|
||||
if (keyActions != null && keyActions.length > 0) {
|
||||
a.putValue(ExtAction.KEYSTROKE, keyActions[0]);
|
||||
}
|
||||
a.putValue(ExtAction.CAPTION, "Alles markieren");
|
||||
a.putValue(ExtAction.MNEMONIC, new Character('m'));
|
||||
a.putValue(ExtAction.TOOLTIP, "Markiert das ganze Dokument");
|
||||
mnuEdit.add(a);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
//
|
||||
/////////////////////////////////////////
|
||||
private void createTextArea() {
|
||||
textArea = new JTextArea();
|
||||
getContentPane().add(new JScrollPane(textArea));
|
||||
}
|
||||
|
||||
/////////////////////////////////////
|
||||
//
|
||||
/////////////////////////////////////
|
||||
private void createListeners() {
|
||||
textArea.getDocument().addDocumentListener(new DocumentListener() {
|
||||
private void changed() {
|
||||
setChanged(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
changed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
changed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
changed();
|
||||
}
|
||||
});
|
||||
|
||||
textArea.getDocument().addUndoableEditListener(new UndoableEditListener() {
|
||||
@Override
|
||||
public void undoableEditHappened(UndoableEditEvent e) {
|
||||
undo.addEdit(e.getEdit());
|
||||
actUndo.update();
|
||||
actRedo.update();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
//
|
||||
///////////////////////////////////////////////////
|
||||
public JTextEditorInternalFrame(String title) {
|
||||
super(title);
|
||||
createTextArea();
|
||||
createListeners();
|
||||
createActions();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
//
|
||||
/////////////////////////////////////////////////
|
||||
public JTextEditorInternalFrame(File file) {
|
||||
super(file);
|
||||
createTextArea();
|
||||
|
||||
if (file.exists()) {
|
||||
FileReader in = null;
|
||||
try {
|
||||
in = new FileReader(file);
|
||||
textArea.read(in, null);
|
||||
} catch (IOException exc) {
|
||||
} finally {
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException exc) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
createListeners();
|
||||
createActions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(boolean value) throws java.beans.PropertyVetoException{
|
||||
super.setSelected(value);
|
||||
public void save(File f) {
|
||||
FileWriter out = null;
|
||||
try {
|
||||
out = new FileWriter(f);
|
||||
textArea.write(out);
|
||||
} catch (IOException exc) {
|
||||
} finally {
|
||||
if (out != null) {
|
||||
try {
|
||||
out.close();
|
||||
} catch (IOException exc) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(value) {
|
||||
textArea.requestFocus();
|
||||
}
|
||||
}
|
||||
super.save(f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(boolean value) throws java.beans.PropertyVetoException {
|
||||
super.setSelected(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.*;
|
||||
|
||||
@@ -26,7 +26,7 @@ public final class LoggingLevelLabel extends JLabel {
|
||||
private JPopupMenu menu;
|
||||
private String[] options;
|
||||
private Logger logger;
|
||||
|
||||
|
||||
public LoggingLevelLabel(final Logger logger) {
|
||||
options = new String[]{"Info", "Warning", "Severe", "Fine", "Finer", "Finest", "All"};
|
||||
|
||||
@@ -36,7 +36,7 @@ public final class LoggingLevelLabel extends JLabel {
|
||||
createPopupMenu();
|
||||
updateText();
|
||||
}
|
||||
|
||||
|
||||
private void createPopupMenu() {
|
||||
this.menu = new JPopupMenu();
|
||||
addMouseListener(new MouseListener() {
|
||||
@@ -59,7 +59,7 @@ public final class LoggingLevelLabel extends JLabel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
public void mouseExited(MouseEvent e) {
|
||||
}
|
||||
});
|
||||
|
||||
@@ -85,20 +85,20 @@ public final class LoggingLevelLabel extends JLabel {
|
||||
/* Show the updated text */
|
||||
setText("<html><b>Level</b>: " + lvl.getName());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the level of the logger to a new level.
|
||||
*
|
||||
*
|
||||
* @param level The new level for the logger
|
||||
*/
|
||||
private void setLoggerLevel(Level level) {
|
||||
private void setLoggerLevel(Level level) {
|
||||
// Recursively set logging level for all classes under eva2
|
||||
Logger.getLogger("eva2").setLevel(level);
|
||||
logger.log(Level.INFO, "Logging Level changed to {0}", level.getName());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
class MenuActionListener implements ActionListener {
|
||||
|
||||
@@ -115,6 +115,6 @@ public final class LoggingLevelLabel extends JLabel {
|
||||
}
|
||||
|
||||
LoggingLevelLabel.this.updateText();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -26,91 +27,95 @@ import javax.swing.event.ChangeListener;
|
||||
*
|
||||
*/
|
||||
public class LoggingPanel extends JPanel {
|
||||
protected static Logger logger;
|
||||
protected JTextArea loggingTextArea = new JTextArea(10,20);
|
||||
protected boolean firstMessage = true;
|
||||
protected Handler loggingHandler;
|
||||
protected JPopupMenu loggingLevelMenu;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public LoggingPanel(Logger logger) {
|
||||
this.logger = logger;
|
||||
loggingTextArea.setEditable(false);
|
||||
loggingTextArea.setLineWrap(true);
|
||||
protected static Logger logger;
|
||||
protected JTextArea loggingTextArea = new JTextArea(10, 20);
|
||||
protected boolean firstMessage = true;
|
||||
protected Handler loggingHandler;
|
||||
protected JPopupMenu loggingLevelMenu;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public LoggingPanel(Logger logger) {
|
||||
this.logger = logger;
|
||||
loggingTextArea.setEditable(false);
|
||||
loggingTextArea.setLineWrap(true);
|
||||
loggingTextArea.setBorder(BorderFactory.createEmptyBorder());
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
add(new JLabel("Info"), BorderLayout.PAGE_START);
|
||||
|
||||
this.loggingHandler = new LoggingHandler(this);
|
||||
logger.addHandler(loggingHandler);
|
||||
|
||||
final JScrollPane scrollpane = new JScrollPane(loggingTextArea);
|
||||
|
||||
this.loggingHandler = new LoggingHandler(this);
|
||||
logger.addHandler(loggingHandler);
|
||||
|
||||
final JScrollPane scrollpane = new JScrollPane(loggingTextArea);
|
||||
scrollpane.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
|
||||
// scrollpane.setAutoscrolls(false);
|
||||
add(scrollpane, BorderLayout.CENTER);
|
||||
scrollpane.getViewport().addChangeListener(new ChangeListener() {
|
||||
private int lastHeight;
|
||||
//
|
||||
add(scrollpane, BorderLayout.CENTER);
|
||||
scrollpane.getViewport().addChangeListener(new ChangeListener() {
|
||||
private int lastHeight;
|
||||
|
||||
//
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
JViewport viewport = (JViewport)e.getSource();
|
||||
int height = viewport.getViewSize().height;
|
||||
if (height != lastHeight) {
|
||||
lastHeight = height;
|
||||
int x = height - viewport.getExtentSize().height;
|
||||
viewport.setViewPosition(new Point(0, x));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected static String getTimestamp() {
|
||||
return (new SimpleDateFormat("HH:mm:ss:")).format(new Date());
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void logMessage(String message) {
|
||||
loggingTextArea.append(LoggingPanel.getTimestamp() + ' ' + message);
|
||||
loggingTextArea.append("\n");
|
||||
}
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
JViewport viewport = (JViewport) e.getSource();
|
||||
int height = viewport.getViewSize().height;
|
||||
if (height != lastHeight) {
|
||||
lastHeight = height;
|
||||
int x = height - viewport.getExtentSize().height;
|
||||
viewport.setViewPosition(new Point(0, x));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected static String getTimestamp() {
|
||||
return (new SimpleDateFormat("HH:mm:ss:")).format(new Date());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void logMessage(String message) {
|
||||
loggingTextArea.append(LoggingPanel.getTimestamp() + ' ' + message);
|
||||
loggingTextArea.append("\n");
|
||||
}
|
||||
}
|
||||
|
||||
class LoggingHandler extends Handler {
|
||||
protected LoggingPanel loggingPanel;
|
||||
|
||||
public LoggingHandler(LoggingPanel loggingPanel) {
|
||||
this.loggingPanel = loggingPanel;
|
||||
}
|
||||
protected LoggingPanel loggingPanel;
|
||||
|
||||
@Override
|
||||
public void publish(LogRecord record) {
|
||||
StringBuilder sBuilder = new StringBuilder();
|
||||
sBuilder.append("[");
|
||||
sBuilder.append(record.getLevel().toString());
|
||||
sBuilder.append("] ");
|
||||
MessageFormat messageFormat = new MessageFormat(record.getMessage());
|
||||
sBuilder.append(messageFormat.format(record.getParameters()));
|
||||
// Show message on LogPanel
|
||||
this.loggingPanel.logMessage(sBuilder.toString());
|
||||
}
|
||||
public LoggingHandler(LoggingPanel loggingPanel) {
|
||||
this.loggingPanel = loggingPanel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
/*
|
||||
* We do nothing here as we don't buffer the entries
|
||||
@Override
|
||||
public void publish(LogRecord record) {
|
||||
StringBuilder sBuilder = new StringBuilder();
|
||||
sBuilder.append("[");
|
||||
sBuilder.append(record.getLevel().toString());
|
||||
sBuilder.append("] ");
|
||||
MessageFormat messageFormat = new MessageFormat(record.getMessage());
|
||||
sBuilder.append(messageFormat.format(record.getParameters()));
|
||||
// Show message on LogPanel
|
||||
this.loggingPanel.logMessage(sBuilder.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
/*
|
||||
* We do nothing here as we don't buffer the entries
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws SecurityException {
|
||||
@Override
|
||||
public void close() throws SecurityException {
|
||||
/*
|
||||
* Nothing to close
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -77,7 +77,7 @@ public class Main extends JFrame implements OptimizationStateListener {
|
||||
private ExtAction actLicense;
|
||||
|
||||
// if not null, the module is loaded automatically and no other can be selected
|
||||
private String useDefaultModule = null; //"Genetic_Optimization";
|
||||
private String useDefaultModule = null; //"Genetic_Optimization";
|
||||
private boolean showLoadModules = false;
|
||||
private boolean localMode = false;
|
||||
|
||||
@@ -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();
|
||||
@@ -567,8 +563,8 @@ public class Main extends JFrame implements OptimizationStateListener {
|
||||
* @param args command line parameters
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
/*============================COPIED FROM SYSBIO==============================*/
|
||||
// Properties for Mac OS X support.
|
||||
/*============================COPIED FROM SYSBIO==============================*/
|
||||
// Properties for Mac OS X support.
|
||||
if ((System.getProperty("mrj.version") != null)
|
||||
|| (System.getProperty("os.name").toLowerCase().indexOf("mac") != -1)) {
|
||||
/*
|
||||
@@ -585,13 +581,13 @@ public class Main extends JFrame implements OptimizationStateListener {
|
||||
System.setProperty("com.apple.mrj.application.growbox.intrudes", "false");
|
||||
System.setProperty("com.apple.mrj.application.live-resize", "true");
|
||||
}
|
||||
/*==========================================================================*/
|
||||
/*==========================================================================*/
|
||||
|
||||
|
||||
/* Available command-line parameters */
|
||||
String[] keys = new String[]{
|
||||
"--help", "--autorun", "--nosplash", "--nogui",
|
||||
"--remotehost", "--params", "--treeView"
|
||||
"--help", "--autorun", "--nosplash", "--nogui",
|
||||
"--remotehost", "--params", "--treeView"
|
||||
};
|
||||
/* Number of arguments per parameter */
|
||||
int[] arities = new int[]{0, 0, 0, 0, 1, 1, 0};
|
||||
@@ -627,14 +623,14 @@ public class Main extends JFrame implements OptimizationStateListener {
|
||||
* Initialize the client GUI with given parameters and set listeners. This
|
||||
* will return as soon as the GUI is visible and ready.
|
||||
*
|
||||
* @param goParams optimization parameters
|
||||
* @param statisticsListener statistics listener receiving data during
|
||||
* optimization
|
||||
* @param windowListener additional window listener for client frame
|
||||
* @param goParams optimization parameters
|
||||
* @param statisticsListener statistics listener receiving data during
|
||||
* optimization
|
||||
* @param windowListener additional window listener for client frame
|
||||
*/
|
||||
public static Main initClientGUI(OptimizationParameters goParams,
|
||||
InterfaceStatisticsListener statisticsListener,
|
||||
WindowListener windowListener, final Window parent) {
|
||||
InterfaceStatisticsListener statisticsListener,
|
||||
WindowListener windowListener, final Window parent) {
|
||||
Main evaClient;
|
||||
|
||||
evaClient = new Main(null, parent, null, goParams,
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -5,21 +5,23 @@ package eva2.gui;
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class MultiLineString {
|
||||
public class MultiLineString {
|
||||
|
||||
String string = "";
|
||||
String string = "";
|
||||
|
||||
public MultiLineString() {
|
||||
}
|
||||
public MultiLineString() {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
MultiLineString multiLineString1 = new MultiLineString();
|
||||
}
|
||||
public String getString() {
|
||||
return string;
|
||||
}
|
||||
public void setString(String string) {
|
||||
this.string = string;
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
MultiLineString multiLineString1 = new MultiLineString();
|
||||
}
|
||||
|
||||
public String getString() {
|
||||
return string;
|
||||
}
|
||||
|
||||
public void setString(String string) {
|
||||
this.string = string;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ import javax.swing.JComponent;
|
||||
|
||||
/**
|
||||
* Simple helper interface.
|
||||
* @author mkron
|
||||
*
|
||||
* @author mkron
|
||||
*/
|
||||
public interface PanelMaker {
|
||||
public JComponent makePanel();
|
||||
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;
|
||||
@@ -25,7 +26,7 @@ public class PropertyDialog extends JDialog {
|
||||
*
|
||||
*/
|
||||
public PropertyDialog(PropertyEditor editor, String title, int x, int y) {
|
||||
super();
|
||||
super();
|
||||
setTitle(getFrameNameFromEditor(editor));
|
||||
//super(getFrameNameFromEditor(editor)); // that was the long class name !!
|
||||
BasicResourceLoader loader = BasicResourceLoader.instance();
|
||||
|
||||
@@ -8,13 +8,13 @@ public class PropertyDoubleArray implements java.io.Serializable {
|
||||
private int m_numCols = 1;
|
||||
|
||||
public PropertyDoubleArray(double[] d) {
|
||||
setDoubleArray(d);
|
||||
setDoubleArray(d);
|
||||
}
|
||||
|
||||
|
||||
public PropertyDoubleArray(double[][] d) {
|
||||
setDoubleArray(d);
|
||||
setDoubleArray(d);
|
||||
}
|
||||
|
||||
|
||||
public PropertyDoubleArray(PropertyDoubleArray d) {
|
||||
this.m_DoubleArray = d.m_DoubleArray.clone();
|
||||
this.m_numCols = d.m_numCols;
|
||||
@@ -24,189 +24,195 @@ 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];
|
||||
index++;
|
||||
if (index >= d.length) {
|
||||
index = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
public Object clone() {
|
||||
return (Object) new PropertyDoubleArray(this);
|
||||
}
|
||||
|
||||
/** This method will allow you to set the value of the double array
|
||||
* @param d The double[]
|
||||
/**
|
||||
* 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++) {
|
||||
this.m_DoubleArray = new double[d.length][1];
|
||||
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
|
||||
* @param d The double[]
|
||||
|
||||
/**
|
||||
* 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;
|
||||
this.m_DoubleArray = d;
|
||||
if (d.length > 0) {
|
||||
m_numCols = d[0].length;
|
||||
} else {
|
||||
m_numCols = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* @return the double array itself (no clone)
|
||||
*/
|
||||
public double[][] getDoubleArrayShallow() {
|
||||
return this.m_DoubleArray;
|
||||
return this.m_DoubleArray;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
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];
|
||||
if (col >= m_numCols) {
|
||||
throw new IllegalArgumentException("Error, invalid column selected, " + col + " of " + m_numCols);
|
||||
}
|
||||
return ret;
|
||||
double[] ret = new double[m_DoubleArray.length];
|
||||
for (int i = 0; i < ret.length; i++) {
|
||||
ret[i] = m_DoubleArray[i][col];
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
public int getNumCols() {
|
||||
return m_numCols;
|
||||
return m_numCols;
|
||||
}
|
||||
|
||||
|
||||
public int getNumRows() {
|
||||
return m_DoubleArray.length;
|
||||
return m_DoubleArray.length;
|
||||
}
|
||||
|
||||
|
||||
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());
|
||||
}
|
||||
return m_DoubleArray[i][j];
|
||||
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) {
|
||||
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];
|
||||
}
|
||||
}
|
||||
}
|
||||
setDoubleArray(newDD);
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteRow(int k) {
|
||||
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;
|
||||
for (int i = 0; i < newDD.length; i++) {
|
||||
if (i==k) {
|
||||
inc=1;
|
||||
public void adaptRowCount(int k) {
|
||||
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 j=0; j<getNumCols(); j++) {
|
||||
newDD[i][j] = m_DoubleArray[i+inc][j];
|
||||
}
|
||||
}
|
||||
setDoubleArray(newDD);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a copy of an indexed row at the end. If the given index
|
||||
* is invalid, the last row is copied.
|
||||
*
|
||||
* @param k
|
||||
*/
|
||||
public void addRowCopy(int k) {
|
||||
if (k<0 || k>= getNumRows()) {
|
||||
k=getNumRows()-1;
|
||||
}
|
||||
double[][] newDD = new double[getNumRows()+1][getNumCols()];
|
||||
|
||||
for (int i = 0; i < getNumRows(); i++) {
|
||||
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
|
||||
setDoubleArray(newDD);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
for (int i = 0; i < getNumRows(); i++) {
|
||||
colSum += m_DoubleArray[i][j];
|
||||
}
|
||||
if (colSum!=0) {
|
||||
for (int i = 0; i < getNumRows(); i++) {
|
||||
m_DoubleArray[i][j]/=colSum;
|
||||
} }
|
||||
}
|
||||
}
|
||||
setDoubleArray(newDD);
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteRow(int k) {
|
||||
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;
|
||||
for (int i = 0; i < newDD.length; i++) {
|
||||
if (i == k) {
|
||||
inc = 1;
|
||||
}
|
||||
for (int j = 0; j < getNumCols(); j++) {
|
||||
newDD[i][j] = m_DoubleArray[i + inc][j];
|
||||
}
|
||||
}
|
||||
setDoubleArray(newDD);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a copy of an indexed row at the end. If the given index
|
||||
* is invalid, the last row is copied.
|
||||
*
|
||||
* @param k
|
||||
*/
|
||||
public void addRowCopy(int k) {
|
||||
if (k < 0 || k >= getNumRows()) {
|
||||
k = getNumRows() - 1;
|
||||
}
|
||||
double[][] newDD = new double[getNumRows() + 1][getNumCols()];
|
||||
|
||||
for (int i = 0; i < getNumRows(); i++) {
|
||||
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
|
||||
setDoubleArray(newDD);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
for (int i = 0; i < getNumRows(); i++) {
|
||||
colSum += m_DoubleArray[i][j];
|
||||
}
|
||||
if (colSum != 0) {
|
||||
for (int i = 0; i < getNumRows(); i++) {
|
||||
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());
|
||||
}
|
||||
|
||||
/**
|
||||
* 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());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return BeanInspector.toString(m_DoubleArray);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return BeanInspector.toString(m_DoubleArray);
|
||||
}
|
||||
|
||||
// /** This method will allow you to set the value of the double array
|
||||
// * @param d The double[]
|
||||
// */
|
||||
|
||||
@@ -9,8 +9,8 @@ package eva2.gui;
|
||||
*/
|
||||
public class PropertyEpsilonConstraint implements java.io.Serializable {
|
||||
|
||||
public double[] m_TargetValue;
|
||||
public int m_OptimizeObjective;
|
||||
public double[] m_TargetValue;
|
||||
public int m_OptimizeObjective;
|
||||
|
||||
public PropertyEpsilonConstraint() {
|
||||
}
|
||||
|
||||
@@ -9,9 +9,9 @@ package eva2.gui;
|
||||
*/
|
||||
public class PropertyEpsilonThreshold implements java.io.Serializable {
|
||||
|
||||
public double[] m_Punishment;
|
||||
public double[] m_TargetValue;
|
||||
public int m_OptimizeObjective;
|
||||
public double[] m_Punishment;
|
||||
public double[] m_TargetValue;
|
||||
public int m_OptimizeObjective;
|
||||
|
||||
public PropertyEpsilonThreshold() {
|
||||
}
|
||||
|
||||
@@ -10,48 +10,47 @@ import eva2.tools.ReflectPackage;
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class PropertyFilePath implements java.io.Serializable {
|
||||
|
||||
|
||||
public String FileName = "";
|
||||
public String FilePath = "";
|
||||
public String FileExtension = "";
|
||||
|
||||
/**
|
||||
* Constructor setting the absolute path. F
|
||||
*
|
||||
*
|
||||
* @param s
|
||||
*/
|
||||
private PropertyFilePath(String s) {
|
||||
this.setCompleteFilePath(s);
|
||||
}
|
||||
|
||||
|
||||
public PropertyFilePath(PropertyFilePath d) {
|
||||
this.FileName = d.FileName;
|
||||
this.FilePath = d.FilePath;
|
||||
this.FileExtension = d.FileExtension;
|
||||
this.FileName = d.FileName;
|
||||
this.FilePath = d.FilePath;
|
||||
this.FileExtension = d.FileExtension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an instance by an absolute path.
|
||||
*
|
||||
*
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
public static PropertyFilePath getFilePathAbsolute(String path) {
|
||||
return new PropertyFilePath(path);
|
||||
return new PropertyFilePath(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an instance by a relative path.
|
||||
*
|
||||
*
|
||||
* @param relPath
|
||||
* @return
|
||||
*/
|
||||
public static PropertyFilePath getFilePathFromResource(String relPath) {
|
||||
String fName = ReflectPackage.getResourcePathFromCP(relPath);
|
||||
if (fName == null) {
|
||||
String fName = ReflectPackage.getResourcePathFromCP(relPath);
|
||||
if (fName == null) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return new PropertyFilePath(fName);
|
||||
}
|
||||
}
|
||||
@@ -61,29 +60,31 @@ 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
|
||||
*
|
||||
* @param s The complete filepath and filename
|
||||
*/
|
||||
public void setCompleteFilePath(String s) {
|
||||
boolean trace = false;
|
||||
String filesep;
|
||||
boolean trace = false;
|
||||
String filesep;
|
||||
|
||||
String old = this.getCompleteFilePath();
|
||||
try {
|
||||
if (trace) {
|
||||
System.out.println("Complete Filename: " +s);
|
||||
System.out.println("Complete Filename: " + s);
|
||||
}
|
||||
filesep = System.getProperty("file.separator");
|
||||
filesep = System.getProperty("file.separator");
|
||||
if (trace) {
|
||||
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
|
||||
* @param d The int[]
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
@@ -10,21 +10,22 @@ import eva2.optimization.problems.InterfaceOptimizationObjective;
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class PropertyOptimizationObjectives implements java.io.Serializable {
|
||||
public InterfaceOptimizationObjective[] m_AvailableObjectives;
|
||||
public InterfaceOptimizationObjective[] m_SelectedObjectives;
|
||||
public InterfaceOptimizationObjective[] m_AvailableObjectives;
|
||||
public InterfaceOptimizationObjective[] m_SelectedObjectives;
|
||||
|
||||
public PropertyOptimizationObjectives(InterfaceOptimizationObjective[] d) {
|
||||
this.m_AvailableObjectives = d;
|
||||
this.m_SelectedObjectives = null;
|
||||
this.m_SelectedObjectives = null;
|
||||
}
|
||||
|
||||
public PropertyOptimizationObjectives(PropertyOptimizationObjectives d) {
|
||||
this.m_AvailableObjectives = new InterfaceOptimizationObjective[d.m_AvailableObjectives.length];
|
||||
this.m_AvailableObjectives = new InterfaceOptimizationObjective[d.m_AvailableObjectives.length];
|
||||
for (int i = 0; i < this.m_AvailableObjectives.length; i++) {
|
||||
this.m_AvailableObjectives[i] = (InterfaceOptimizationObjective)d.m_AvailableObjectives[i].clone();
|
||||
this.m_AvailableObjectives[i] = (InterfaceOptimizationObjective) d.m_AvailableObjectives[i].clone();
|
||||
}
|
||||
this.m_SelectedObjectives = new InterfaceOptimizationObjective[d.m_SelectedObjectives.length];
|
||||
this.m_SelectedObjectives = new InterfaceOptimizationObjective[d.m_SelectedObjectives.length];
|
||||
for (int i = 0; i < this.m_SelectedObjectives.length; i++) {
|
||||
this.m_SelectedObjectives[i] = (InterfaceOptimizationObjective)d.m_SelectedObjectives[i].clone();
|
||||
this.m_SelectedObjectives[i] = (InterfaceOptimizationObjective) d.m_SelectedObjectives[i].clone();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,36 +34,44 @@ 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
|
||||
* @param d The InterfaceOptimizationTarget[]
|
||||
/**
|
||||
* 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
|
||||
* @param index The index of the target to be removed.
|
||||
/**
|
||||
* 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) {
|
||||
if ((index < 0) || (index >= this.m_SelectedObjectives.length)) {
|
||||
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];
|
||||
}
|
||||
|
||||
@@ -11,28 +11,29 @@ import eva2.optimization.problems.InterfaceOptimizationObjective;
|
||||
*/
|
||||
public class PropertyOptimizationObjectivesWithParam implements java.io.Serializable {
|
||||
|
||||
public InterfaceOptimizationObjective[] m_AvailableObjectives;
|
||||
public InterfaceOptimizationObjective[] m_SelectedObjectives;
|
||||
public double[] m_Weights;
|
||||
public String m_DescriptiveString = "No Description given.";
|
||||
public String m_WeightsLabel = "-";
|
||||
public boolean m_NormalizationEnabled = true;
|
||||
public InterfaceOptimizationObjective[] m_AvailableObjectives;
|
||||
public InterfaceOptimizationObjective[] m_SelectedObjectives;
|
||||
public double[] m_Weights;
|
||||
public String m_DescriptiveString = "No Description given.";
|
||||
public String m_WeightsLabel = "-";
|
||||
public boolean m_NormalizationEnabled = true;
|
||||
|
||||
public PropertyOptimizationObjectivesWithParam(InterfaceOptimizationObjective[] d) {
|
||||
this.m_AvailableObjectives = d;
|
||||
this.m_SelectedObjectives = null;
|
||||
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];
|
||||
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];
|
||||
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,8 +46,10 @@ 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
|
||||
* @param d The InterfaceOptimizationTarget[]
|
||||
/**
|
||||
* 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;
|
||||
@@ -62,7 +65,7 @@ public class PropertyOptimizationObjectivesWithParam implements java.io.Serializ
|
||||
if (d.length == this.m_Weights.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (d.length > this.m_Weights.length) {
|
||||
double[] newWeights = new double[d.length];
|
||||
for (int i = 0; i < this.m_Weights.length; i++) {
|
||||
@@ -78,70 +81,88 @@ 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
|
||||
* @param index The index of the target to be removed.
|
||||
/**
|
||||
* 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) {
|
||||
if ((index < 0) || (index >= this.m_SelectedObjectives.length)) {
|
||||
return;
|
||||
}
|
||||
|
||||
InterfaceOptimizationObjective[] newList = new InterfaceOptimizationObjective[this.m_SelectedObjectives.length-1];
|
||||
double[] newWeights = new double[this.m_Weights.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++) {
|
||||
if (index != i) {
|
||||
@@ -150,23 +171,25 @@ public class PropertyOptimizationObjectivesWithParam implements java.io.Serializ
|
||||
j++;
|
||||
}
|
||||
}
|
||||
this.m_SelectedObjectives = newList;
|
||||
this.m_Weights = newWeights;
|
||||
this.m_SelectedObjectives = newList;
|
||||
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];
|
||||
double[] newWeights = new double[this.m_Weights.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];
|
||||
newWeights[i] = this.m_Weights[i];
|
||||
}
|
||||
newList[this.m_SelectedObjectives.length] = optTarget;
|
||||
newWeights[this.m_SelectedObjectives.length] = 1.0;
|
||||
this.m_SelectedObjectives = newList;
|
||||
this.m_Weights = newWeights;
|
||||
this.m_SelectedObjectives = newList;
|
||||
this.m_Weights = newWeights;
|
||||
}
|
||||
}
|
||||
@@ -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,76 +20,77 @@ import javax.swing.BorderFactory;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class PropertyPanel extends JPanel {
|
||||
private PropertyEditor propertyEditor;
|
||||
private PropertyDialog propertyDialog;
|
||||
|
||||
private PropertyEditor propertyEditor;
|
||||
private PropertyDialog propertyDialog;
|
||||
|
||||
private JLabel textLabel;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public PropertyPanel(PropertyEditor editor) {
|
||||
setToolTipText("Click to edit properties for this object");
|
||||
setOpaque(true);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public PropertyPanel(PropertyEditor editor) {
|
||||
setToolTipText("Click to edit properties for this object");
|
||||
setOpaque(true);
|
||||
|
||||
setLayout(new GridBagLayout());
|
||||
GridBagConstraints gbConstraints = new GridBagConstraints();
|
||||
gbConstraints.gridx = 0;
|
||||
gbConstraints.gridy = 0;
|
||||
gbConstraints.weightx = 1.0;
|
||||
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
|
||||
propertyEditor = editor;
|
||||
|
||||
propertyEditor = editor;
|
||||
|
||||
textLabel = new JLabel();
|
||||
|
||||
add(textLabel, gbConstraints);
|
||||
|
||||
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
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.setModal(true);
|
||||
propertyDialog.setVisible(true);
|
||||
}
|
||||
else {
|
||||
propertyDialog.updateFrameTitle(propertyEditor);
|
||||
propertyDialog.setVisible(false);
|
||||
propertyDialog.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
} else {
|
||||
propertyDialog.updateFrameTitle(propertyEditor);
|
||||
propertyDialog.setVisible(false);
|
||||
propertyDialog.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void removeNotify() {
|
||||
if (propertyDialog != null) {
|
||||
propertyDialog = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void removeNotify() {
|
||||
if (propertyDialog != null) {
|
||||
propertyDialog = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
Insets i = textLabel.getInsets();
|
||||
Rectangle box = new Rectangle(i.left, i.top,
|
||||
getSize().width - i.left - i.right ,
|
||||
getSize().height - i.top - i.bottom);
|
||||
g.clearRect(i.left, i.top,
|
||||
getSize().width - i.right - i.left,
|
||||
getSize().height - i.bottom - i.top);
|
||||
propertyEditor.paintValue(g, box);
|
||||
}
|
||||
|
||||
public PropertyEditor getEditor() {
|
||||
return propertyEditor;
|
||||
}
|
||||
public void paintComponent(Graphics g) {
|
||||
Insets i = textLabel.getInsets();
|
||||
Rectangle box = new Rectangle(i.left, i.top,
|
||||
getSize().width - i.left - i.right,
|
||||
getSize().height - i.top - i.bottom);
|
||||
g.clearRect(i.left, i.top,
|
||||
getSize().width - i.right - i.left,
|
||||
getSize().height - i.bottom - i.top);
|
||||
propertyEditor.paintValue(g, box);
|
||||
}
|
||||
|
||||
public PropertyEditor getEditor() {
|
||||
return propertyEditor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,18 +12,18 @@ import java.beans.PropertyChangeSupport;
|
||||
*/
|
||||
public class PropertySelectableList<T> implements java.io.Serializable {
|
||||
|
||||
protected T[] m_Objects;
|
||||
protected boolean[] m_Selection;
|
||||
private transient PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||
protected T[] m_Objects;
|
||||
protected boolean[] m_Selection;
|
||||
private transient PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||
|
||||
// public PropertySelectableList() {
|
||||
// public PropertySelectableList() {
|
||||
// }
|
||||
//
|
||||
public PropertySelectableList(T[] initial) {
|
||||
m_Objects = initial;
|
||||
m_Selection = new boolean[initial.length];
|
||||
m_Objects = initial;
|
||||
m_Selection = new boolean[initial.length];
|
||||
}
|
||||
|
||||
|
||||
public PropertySelectableList(PropertySelectableList<T> b) {
|
||||
if (b.m_Objects != null) {
|
||||
this.m_Objects = b.m_Objects.clone();
|
||||
@@ -33,18 +33,18 @@ public class PropertySelectableList<T> implements java.io.Serializable {
|
||||
System.arraycopy(b.m_Selection, 0, this.m_Selection, 0, this.m_Selection.length);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
return (Object) new PropertySelectableList<T>(this);
|
||||
}
|
||||
|
||||
|
||||
public void setObjects(T[] o) {
|
||||
this.m_Objects = o;
|
||||
this.m_Selection = new boolean[o.length];
|
||||
m_Support.firePropertyChange("PropertySelectableList", null, this);
|
||||
}
|
||||
|
||||
|
||||
public void setObjects(T[] o, boolean[] selection) {
|
||||
this.m_Objects = o;
|
||||
this.m_Selection = selection;
|
||||
@@ -53,77 +53,77 @@ public class PropertySelectableList<T> implements java.io.Serializable {
|
||||
}
|
||||
m_Support.firePropertyChange("PropertySelectableList", null, this);
|
||||
}
|
||||
|
||||
|
||||
public T[] getObjects() {
|
||||
return this.m_Objects;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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++) {
|
||||
if (!m_Selection[i]) {
|
||||
selObjects[i]=null;
|
||||
T[] selObjects = getObjects().clone();
|
||||
for (int i = 0; i < selObjects.length; i++) {
|
||||
if (!m_Selection[i]) {
|
||||
selObjects[i] = null;
|
||||
}
|
||||
}
|
||||
return selObjects;
|
||||
}
|
||||
return selObjects;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the selection by giving a list of selected indices.
|
||||
*
|
||||
*
|
||||
* @param selection
|
||||
*/
|
||||
public void setSelectionByIndices(int[] selection) {
|
||||
m_Selection = new boolean[getObjects().length];
|
||||
for (int i=0; i<selection.length; i++) {
|
||||
m_Selection[selection[i]]=true;
|
||||
m_Selection = new boolean[getObjects().length];
|
||||
for (int i = 0; i < selection.length; i++) {
|
||||
m_Selection[selection[i]] = true;
|
||||
}
|
||||
m_Support.firePropertyChange("PropertySelectableList", null, this);
|
||||
m_Support.firePropertyChange("PropertySelectableList", null, this);
|
||||
}
|
||||
|
||||
|
||||
public void setSelection(boolean[] selection) {
|
||||
this.m_Selection = selection;
|
||||
m_Support.firePropertyChange("PropertySelectableList", null, this);
|
||||
m_Support.firePropertyChange("PropertySelectableList", null, this);
|
||||
}
|
||||
|
||||
|
||||
public boolean[] getSelection() {
|
||||
return this.m_Selection;
|
||||
}
|
||||
|
||||
public void setSelectionForElement(int index, boolean b) {
|
||||
if (m_Selection[index]!=b) {
|
||||
this.m_Selection[index] = b;
|
||||
m_Support.firePropertyChange("PropertySelectableList", null, this);
|
||||
}
|
||||
}
|
||||
|
||||
public int size() {
|
||||
if (m_Objects == null) {
|
||||
return 0;
|
||||
if (m_Selection[index] != b) {
|
||||
this.m_Selection[index] = b;
|
||||
m_Support.firePropertyChange("PropertySelectableList", null, this);
|
||||
}
|
||||
else {
|
||||
}
|
||||
|
||||
public int size() {
|
||||
if (m_Objects == null) {
|
||||
return 0;
|
||||
} else {
|
||||
return m_Objects.length;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public T get(int i) {
|
||||
return m_Objects[i];
|
||||
}
|
||||
|
||||
public boolean isSelected(int i) {
|
||||
return m_Selection[i];
|
||||
return m_Objects[i];
|
||||
}
|
||||
|
||||
public boolean isSelected(int i) {
|
||||
return m_Selection[i];
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
m_Objects = null;
|
||||
m_Selection = null;
|
||||
m_Support.firePropertyChange("PropertySelectableList", null, this);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
m_Objects=null;
|
||||
m_Selection=null;
|
||||
m_Support.firePropertyChange("PropertySelectableList", null, this);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Append an object at the end of the list and immediately select it.
|
||||
// * @param o
|
||||
@@ -144,18 +144,18 @@ public class PropertySelectableList<T> implements java.io.Serializable {
|
||||
// }
|
||||
// m_Support.firePropertyChange("PropertySelectableList", null, this);
|
||||
// }
|
||||
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
}
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
@@ -92,7 +95,7 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
||||
boolean stripToolTipToFirstPoint = false;
|
||||
private JTable propertyTable;
|
||||
private DefaultTableModel propertyTableModel;
|
||||
|
||||
|
||||
/**
|
||||
* Creates the property sheet panel.
|
||||
*/
|
||||
@@ -120,7 +123,7 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
if (propertyChangeSupport == null) {
|
||||
propertyChangeSupport = new PropertyChangeSupport(this);
|
||||
}
|
||||
}
|
||||
propertyChangeSupport.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
@@ -128,41 +131,41 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
if (propertyChangeSupport == null) {
|
||||
propertyChangeSupport = new PropertyChangeSupport(this);
|
||||
}
|
||||
}
|
||||
propertyChangeSupport.removePropertyChangeListener(l);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a fitting viewer component for an editor instance. If none can be
|
||||
* identified, null is returned.
|
||||
*
|
||||
*
|
||||
* @param editor
|
||||
* @return
|
||||
*/
|
||||
public static JComponent getView(PropertyEditor editor) {
|
||||
JComponent view = null;
|
||||
// Now figure out how to display it...
|
||||
if (editor.isPaintable() && editor.supportsCustomEditor()) {
|
||||
view = new PropertyPanel(editor);
|
||||
} else {
|
||||
String[] tags = editor.getTags();
|
||||
JComponent view = null;
|
||||
// Now figure out how to display it...
|
||||
if (editor.isPaintable() && editor.supportsCustomEditor()) {
|
||||
view = new PropertyPanel(editor);
|
||||
} else {
|
||||
String[] tags = editor.getTags();
|
||||
if (tags != null) {
|
||||
if ((tags.length == 2) && (tags[0].equals("True")) && (tags[1].equals("False"))) {
|
||||
view = new PropertyBoolSelector(editor);
|
||||
} else {
|
||||
} else {
|
||||
view = new PropertyValueSelector(editor);
|
||||
}
|
||||
} else {
|
||||
if (editor.getAsText() != null) {
|
||||
view = new PropertyText(editor);
|
||||
} else {
|
||||
if (editor.getAsText() != null) {
|
||||
view = new PropertyText(editor);
|
||||
} else {
|
||||
view = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return view;
|
||||
}
|
||||
}
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets a new target object for customisation.
|
||||
*
|
||||
@@ -171,7 +174,7 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
||||
public synchronized void setTarget(Object targ) {
|
||||
propertyTableModel = new DefaultTableModel();
|
||||
propertyTableModel.addColumn("Key");
|
||||
propertyTableModel.addColumn("Value");
|
||||
propertyTableModel.addColumn("Value");
|
||||
propertyTable = new JTable(propertyTableModel);
|
||||
propertyTable.setDefaultRenderer(Object.class, new PropertyCellRenderer());
|
||||
propertyTable.setDefaultEditor(Object.class, new PropertyCellEditor());
|
||||
@@ -194,7 +197,7 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
||||
}
|
||||
|
||||
int rowHeight = 12;
|
||||
|
||||
|
||||
GridBagConstraints gbConstraints = new GridBagConstraints();
|
||||
gbConstraints.fill = GridBagConstraints.BOTH;
|
||||
|
||||
@@ -212,7 +215,7 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
||||
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
|
||||
gbConstraints.anchor = GridBagConstraints.PAGE_START;
|
||||
add(infoPanel, gbConstraints);
|
||||
}
|
||||
}
|
||||
methsFound++;
|
||||
} // end if (name.equals("globalInfo")) {
|
||||
else if (name.equals("hideHideable")) {
|
||||
@@ -221,10 +224,10 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
||||
meth.invoke(targetObject, args);
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
methsFound++;
|
||||
methsFound++;
|
||||
} else if (name.equals("customPropertyOrder")) {
|
||||
methsFound++;
|
||||
reorderProperties(meth);
|
||||
methsFound++;
|
||||
reorderProperties(meth);
|
||||
}
|
||||
if (methsFound == 3) {
|
||||
break; // small speed-up
|
||||
@@ -232,7 +235,7 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
||||
} // end for (int i = 0; i < m_Methods.length; i++) {
|
||||
// restore hide states of all properties
|
||||
// GenericObjectEditor.setHideProperties(m_Target.getClass(), hideStateBackup);
|
||||
|
||||
|
||||
// Now lets search for the individual properties, their
|
||||
// values, views and editors...
|
||||
propertyEditors = new PropertyEditor[propertyDescriptors.length];
|
||||
@@ -243,7 +246,7 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
||||
propertyLabels = new JLabel[propertyDescriptors.length];
|
||||
toolTips = new String[propertyDescriptors.length];
|
||||
|
||||
|
||||
|
||||
for (int i = 0; i < propertyDescriptors.length; i++) {
|
||||
// For each property do this
|
||||
// Don't display hidden or expert properties.
|
||||
@@ -278,7 +281,7 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
||||
name = eva2.tools.StringTools.humaniseCamelCase(name);
|
||||
propertyTableModel.addRow(new Object[]{name, newView});
|
||||
}
|
||||
|
||||
|
||||
JScrollPane scrollableTable = new JScrollPane(propertyTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
gbConstraints.gridx = 0;
|
||||
gbConstraints.gridy = 1;
|
||||
@@ -294,38 +297,38 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
||||
|
||||
public static PropertyDescriptor[] getProperties(Object target) {
|
||||
BeanInfo bi;
|
||||
try {
|
||||
bi = Introspector.getBeanInfo(target.getClass());
|
||||
} catch (IntrospectionException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
bi = Introspector.getBeanInfo(target.getClass());
|
||||
} catch (IntrospectionException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return bi.getPropertyDescriptors();
|
||||
}
|
||||
|
||||
|
||||
public static String[] getPropertyNames(Object target) {
|
||||
return getNames(getProperties(target));
|
||||
}
|
||||
|
||||
|
||||
public static Object[] getPropertyValues(Object target, boolean omitExpert, boolean omitHidden, boolean onlySetAndGettable) {
|
||||
return getValues(target, getProperties(target), omitExpert, omitHidden, onlySetAndGettable);
|
||||
return getValues(target, getProperties(target), omitExpert, omitHidden, onlySetAndGettable);
|
||||
}
|
||||
|
||||
|
||||
public static String[] getNames(PropertyDescriptor[] props) {
|
||||
String[] names = new String[props.length];
|
||||
for (int i = 0; i < props.length; i++) {
|
||||
names[i] = props[i].getDisplayName();
|
||||
}
|
||||
return names;
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Cycle the properties and request the value of each in an array. Null
|
||||
* values may indicate missing getter/setter, expert flag or hidden flag set
|
||||
* depending on the parameters. Note that to show hidden properties
|
||||
* dynamically, views may need be constructed for them anyways, so do not
|
||||
* omit them here.
|
||||
*
|
||||
*
|
||||
* @param props
|
||||
* @param omitExpert
|
||||
* @param omitHidden
|
||||
@@ -338,7 +341,7 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
||||
// For each property do this
|
||||
// Don't display hidden or expert properties.
|
||||
// if (m_Properties[i].isHidden() || m_Properties[i].isExpert()) continue;
|
||||
// we now look at hidden properties, they can be shown or hidden dynamically (MK)
|
||||
// we now look at hidden properties, they can be shown or hidden dynamically (MK)
|
||||
String name = props[i].getDisplayName();
|
||||
if (props[i].isExpert() && omitExpert) {
|
||||
continue;
|
||||
@@ -353,49 +356,49 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
||||
continue;
|
||||
}
|
||||
Object args[] = {};
|
||||
Object value = null;
|
||||
try {
|
||||
value = getter.invoke(target, args);
|
||||
} catch (Exception ex) {
|
||||
System.out.println("Exception on getting value for property " + name + " on target " + target.toString());
|
||||
ex.printStackTrace();
|
||||
Object value = null;
|
||||
try {
|
||||
value = getter.invoke(target, args);
|
||||
} catch (Exception ex) {
|
||||
System.out.println("Exception on getting value for property " + name + " on target " + target.toString());
|
||||
ex.printStackTrace();
|
||||
values[i] = null;
|
||||
}
|
||||
}
|
||||
// PropertyEditor editor = null;
|
||||
//Class pec = m_Properties[i].getPropertyEditorClass();
|
||||
//Class pec = m_Properties[i].getPropertyEditorClass();
|
||||
values[i] = value;
|
||||
|
||||
} // end for each property
|
||||
return values;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a label to be shown if no other properties are shown.
|
||||
*
|
||||
*
|
||||
* @param componentOffset
|
||||
* @param gbLayout
|
||||
* @return
|
||||
*/
|
||||
private JLabel createDummyLabel(int componentOffset, GridBagLayout gbLayout) {
|
||||
private JLabel createDummyLabel(int componentOffset, GridBagLayout gbLayout) {
|
||||
JLabel empty = new JLabel("No editable properties", SwingConstants.CENTER);
|
||||
Dimension d = empty.getPreferredSize();
|
||||
empty.setPreferredSize(new Dimension(d.width * 2, d.height * 2));
|
||||
empty.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 10));
|
||||
GridBagConstraints gbConstraints = new GridBagConstraints();
|
||||
Dimension d = empty.getPreferredSize();
|
||||
empty.setPreferredSize(new Dimension(d.width * 2, d.height * 2));
|
||||
empty.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 10));
|
||||
GridBagConstraints gbConstraints = new GridBagConstraints();
|
||||
gbConstraints.anchor = GridBagConstraints.CENTER;
|
||||
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
|
||||
gbConstraints.gridy = componentOffset;
|
||||
gbConstraints.gridx = 0;
|
||||
gbLayout.setConstraints(empty, gbConstraints);
|
||||
return empty;
|
||||
}
|
||||
gbLayout.setConstraints(empty, gbConstraints);
|
||||
return empty;
|
||||
}
|
||||
|
||||
private PropertyEditor makeEditor(PropertyDescriptor property, String name, Object value) {
|
||||
PropertyEditor editor = PropertyEditorProvider.findEditor(property, value);
|
||||
PropertyEditor editor = PropertyEditorProvider.findEditor(property, value);
|
||||
if (editor == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// Don't try to set null values:
|
||||
if (value == null) {
|
||||
// If it's a user-defined property we give a warning.
|
||||
@@ -408,14 +411,14 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
||||
editor.setValue(value);
|
||||
|
||||
// System.out.println("PSP editor class: " + editor.getClass());
|
||||
|
||||
|
||||
editor.addPropertyChangeListener(this);
|
||||
return editor;
|
||||
}
|
||||
|
||||
private void addLabelView(int componentOffset, GridBagLayout gbLayout,
|
||||
int i, String name, JComponent newView) {
|
||||
|
||||
|
||||
private void addLabelView(int componentOffset, GridBagLayout gbLayout,
|
||||
int i, String name, JComponent newView) {
|
||||
|
||||
propertyLabels[i] = makeLabel(name);
|
||||
views[i] = newView;
|
||||
viewWrappers[i] = new JPanel();
|
||||
@@ -425,50 +428,50 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
||||
add(propertyLabels[i]);
|
||||
JPanel newPanel = makeViewPanel(toolTips[i], propertyLabels[i], views[i], viewWrappers[i]);
|
||||
gbLayout.setConstraints(newPanel, makeViewConstraints(i + componentOffset));
|
||||
add(newPanel);
|
||||
}
|
||||
add(newPanel);
|
||||
}
|
||||
|
||||
private JLabel makeLabel(String name) {
|
||||
JLabel label = new JLabel(name, SwingConstants.RIGHT);
|
||||
private JLabel makeLabel(String name) {
|
||||
JLabel label = new JLabel(name, SwingConstants.RIGHT);
|
||||
label.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 5));
|
||||
return label;
|
||||
}
|
||||
|
||||
private static JPanel makeViewPanel(String tipText, JLabel label,
|
||||
JComponent view, JComponent viewWrapper) {
|
||||
JPanel newPanel = new JPanel();
|
||||
if (tipText != null) {
|
||||
label.setToolTipText(tipText);
|
||||
view.setToolTipText(tipText);
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
private static JPanel makeViewPanel(String tipText, JLabel label,
|
||||
JComponent view, JComponent viewWrapper) {
|
||||
JPanel newPanel = new JPanel();
|
||||
if (tipText != null) {
|
||||
label.setToolTipText(tipText);
|
||||
view.setToolTipText(tipText);
|
||||
}
|
||||
newPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 10));
|
||||
newPanel.setLayout(new BorderLayout());
|
||||
// @todo: Streiche here i could add the ViewWrapper
|
||||
viewWrapper.add(view, BorderLayout.CENTER);
|
||||
newPanel.add(viewWrapper, BorderLayout.CENTER);
|
||||
return newPanel;
|
||||
}
|
||||
|
||||
private GridBagConstraints makeLabelConstraints(int componentIndex) {
|
||||
GridBagConstraints gbConstraints = new GridBagConstraints();
|
||||
newPanel.setLayout(new BorderLayout());
|
||||
// @todo: Streiche here i could add the ViewWrapper
|
||||
viewWrapper.add(view, BorderLayout.CENTER);
|
||||
newPanel.add(viewWrapper, BorderLayout.CENTER);
|
||||
return newPanel;
|
||||
}
|
||||
|
||||
private GridBagConstraints makeLabelConstraints(int componentIndex) {
|
||||
GridBagConstraints gbConstraints = new GridBagConstraints();
|
||||
gbConstraints.anchor = GridBagConstraints.EAST;
|
||||
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
|
||||
gbConstraints.gridy = componentIndex;
|
||||
gbConstraints.gridx = 0;
|
||||
return gbConstraints;
|
||||
}
|
||||
return gbConstraints;
|
||||
}
|
||||
|
||||
private GridBagConstraints makeViewConstraints(int componentIndex) {
|
||||
GridBagConstraints gbConstraints = new GridBagConstraints();
|
||||
private GridBagConstraints makeViewConstraints(int componentIndex) {
|
||||
GridBagConstraints gbConstraints = new GridBagConstraints();
|
||||
gbConstraints.anchor = GridBagConstraints.WEST;
|
||||
gbConstraints.fill = GridBagConstraints.BOTH;
|
||||
gbConstraints.gridy = componentIndex;
|
||||
gbConstraints.gridx = 1;
|
||||
gbConstraints.weightx = 100;
|
||||
return gbConstraints;
|
||||
}
|
||||
|
||||
/**
|
||||
return gbConstraints;
|
||||
}
|
||||
|
||||
/**
|
||||
* Be sure to give a clone
|
||||
*
|
||||
* @param oldProps
|
||||
@@ -479,79 +482,79 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
||||
// Mathematics.revertArray(oldProps, newProps);
|
||||
Object[] args = {};
|
||||
Object retV = null;
|
||||
PropertyDescriptor[] newProps = null;
|
||||
PropertyDescriptor[] newProps = null;
|
||||
try {
|
||||
retV = meth.invoke(targetObject, args); // should return String[] to be interpreted as a list of ordered properties
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
if (retV != null) {
|
||||
try {
|
||||
if (retV.getClass().isArray()) { // reorder the properties
|
||||
if (retV.getClass().isArray()) { // reorder the properties
|
||||
String[] swProps = (String[]) retV;
|
||||
PropertyDescriptor[] oldProps = propertyDescriptors.clone();
|
||||
newProps = new PropertyDescriptor[oldProps.length];
|
||||
//int findFirst=findFirstProp(props[0], oldProps);
|
||||
//int findFirst=findFirstProp(props[0], oldProps);
|
||||
int firstNonNull = 0;
|
||||
for (int i = 0; i < oldProps.length; i++) {
|
||||
if (i < swProps.length) {
|
||||
int pInOld = findProp(oldProps, swProps[i]);
|
||||
newProps[i] = oldProps[pInOld];
|
||||
oldProps[pInOld] = null;
|
||||
} else {
|
||||
firstNonNull = findFirstNonNullAfter(oldProps, firstNonNull);
|
||||
} else {
|
||||
firstNonNull = findFirstNonNullAfter(oldProps, firstNonNull);
|
||||
newProps[i] = oldProps[firstNonNull];
|
||||
firstNonNull++;
|
||||
}
|
||||
}
|
||||
firstNonNull++;
|
||||
}
|
||||
}
|
||||
propertyDescriptors = newProps;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.err.println("Error during reordering properties: " + e.getMessage());
|
||||
System.err.println("Error during reordering properties: " + e.getMessage());
|
||||
return propertyDescriptors;
|
||||
}
|
||||
}
|
||||
return newProps;
|
||||
}
|
||||
return newProps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the first non-null entry in an Array at or after the given index and
|
||||
* return its index. If only null entries are found, -1 is returned.
|
||||
*
|
||||
*
|
||||
* @param arr
|
||||
* @param firstLook
|
||||
* @return
|
||||
*/
|
||||
private int findFirstNonNullAfter(PropertyDescriptor[] arr,
|
||||
int firstLook) {
|
||||
int firstLook) {
|
||||
for (int i = firstLook; i < arr.length; i++) {
|
||||
if (arr[i] != null) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Find a string property in an array and return its index or -1 if not
|
||||
* found.
|
||||
*
|
||||
*
|
||||
* @param oldProps
|
||||
* @param string
|
||||
* @return
|
||||
*/
|
||||
private int findProp(PropertyDescriptor[] oldProps, String string) {
|
||||
private int findProp(PropertyDescriptor[] oldProps, String string) {
|
||||
for (int i = 0; i < oldProps.length; i++) {
|
||||
if (oldProps[i] == null) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
String name = oldProps[i].getDisplayName();
|
||||
if (name.compareTo(string) == 0) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
System.err.println("Error, property not found: " + string);
|
||||
return -1;
|
||||
}
|
||||
System.err.println("Error, property not found: " + string);
|
||||
return -1;
|
||||
}
|
||||
|
||||
private JPanel makeInfoPanel(Method meth, Object targ, int rowHeight) {
|
||||
if (meth.getReturnType().equals(String.class)) {
|
||||
@@ -583,9 +586,9 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
||||
infoPanel.setBorder(BorderFactory.createTitledBorder("Info"));
|
||||
infoPanel.setLayout(new BorderLayout());
|
||||
infoPanel.add(infoTextArea, BorderLayout.CENTER);
|
||||
|
||||
|
||||
if (HtmlDemo.resourceExists(getHelpFileName())) {
|
||||
// this means that the expected URL really exists
|
||||
// this means that the expected URL really exists
|
||||
infoPanel.add(helpButton, BorderLayout.LINE_END);
|
||||
} else {
|
||||
LOGGER.log(Level.FINE, "Not adding help button because of missing {0}", getHelpFileName());
|
||||
@@ -596,7 +599,7 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private String translateGreek(String name) {
|
||||
// Add some specific display for some greeks here
|
||||
if (name.equalsIgnoreCase("alpha")) {
|
||||
@@ -703,19 +706,19 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
||||
if (name.equalsIgnoreCase("pib")) {
|
||||
return "\u03A0";
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the html help file name.
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected String getHelpFileName() {
|
||||
return EVAHELP.cutClassName(className) + ".html";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method opens a help frame.
|
||||
*/
|
||||
@@ -732,10 +735,10 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
||||
public int editableProperties() {
|
||||
return numEditableProperties;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return true if the modification was successful.
|
||||
*
|
||||
*
|
||||
* @param i
|
||||
* @param newValue
|
||||
* @return
|
||||
@@ -761,12 +764,12 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
||||
((GenericObjectEditor) tmpEdit).setClassType(propertyDescriptors[i].getPropertyType());
|
||||
}
|
||||
propertyEditors[i].setValue(newValue);
|
||||
JComponent newView = null;
|
||||
newView = getView(tmpEdit);
|
||||
JComponent newView = null;
|
||||
newView = getView(tmpEdit);
|
||||
if (newView == null) {
|
||||
System.err.println("Warning: Property \"" + propertyDescriptors[i].getDisplayName() + "\" has non-displayable editor. Skipping.");
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
propertyEditors[i].addPropertyChangeListener(this);
|
||||
views[i] = newView;
|
||||
if (toolTips[i] != null) {
|
||||
@@ -777,7 +780,7 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
||||
viewWrappers[i].add(views[i], BorderLayout.CENTER);
|
||||
viewWrappers[i].repaint();
|
||||
}
|
||||
|
||||
|
||||
// System.out.println("Value: "+value +" / m_Values[i]: " + m_Values[i]);
|
||||
// Now try to update the target with the new value of the property
|
||||
// and allow the target to do some changes to the value, therefore
|
||||
@@ -832,12 +835,12 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
||||
PropertyEditor editor = (PropertyEditor) evt.getSource();
|
||||
for (int i = 0; i < propertyEditors.length; i++) {
|
||||
if (propertyEditors[i] == editor) {
|
||||
propIndex = i;
|
||||
propIndex = i;
|
||||
if (wasModified(i, editor.getValue(), true)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (propIndex == -1) {
|
||||
System.err.println("error: could not identify event editor! (PropertySheetPanel)");
|
||||
}
|
||||
@@ -845,7 +848,7 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
||||
System.err.println("unknown event source! (PropertySheetPanel)");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Updates the propertysheet when a value has been changed (from outside the
|
||||
* propertysheet?).
|
||||
@@ -855,24 +858,24 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
||||
synchronized boolean wasModified(int propIndex, Object value, boolean followDependencies) {
|
||||
if (!updateValue(propIndex, value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
boolean doRepaint = false;
|
||||
|
||||
for (int i = 0; i < propertyEditors.length; i++) { // check the views for out-of-date information. this is different than checking the editors
|
||||
if (i != propIndex) {
|
||||
if (i != propIndex) {
|
||||
if (updateFieldView(i)) {
|
||||
doRepaint = true;
|
||||
}
|
||||
}// end if (m_Editors[i] == editor) {
|
||||
}// end if (m_Editors[i] == editor) {
|
||||
} // end for (int i = 0 ; i < m_Editors.length; i++) {
|
||||
if (doRepaint) { // some components have been hidden or reappeared
|
||||
// MK this finally seems to work right, with a scroll pane, too.
|
||||
if (doRepaint) { // some components have been hidden or reappeared
|
||||
// MK this finally seems to work right, with a scroll pane, too.
|
||||
Container p = this;
|
||||
while (p != null && (!p.getSize().equals(p.getPreferredSize()))) {
|
||||
p.setSize(p.getPreferredSize());
|
||||
p = p.getParent();
|
||||
}
|
||||
while (p != null && (!p.getSize().equals(p.getPreferredSize()))) {
|
||||
p.setSize(p.getPreferredSize());
|
||||
p = p.getParent();
|
||||
}
|
||||
}
|
||||
|
||||
// Now re-read all the properties and update the editors
|
||||
@@ -888,44 +891,44 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
||||
Object args[] = {};
|
||||
o = getter.invoke(targetObject, args);
|
||||
} catch (Exception ex) {
|
||||
o = null;
|
||||
System.err.println(ex.getMessage());
|
||||
ex.printStackTrace();
|
||||
o = null;
|
||||
System.err.println(ex.getMessage());
|
||||
ex.printStackTrace();
|
||||
}
|
||||
if ((o != null) && o == objectValues[i] && (BeanInspector.isJavaPrimitive(o.getClass()))) {
|
||||
// The property is equal to its old value.
|
||||
continue;
|
||||
// The property is equal to its old value.
|
||||
continue;
|
||||
}
|
||||
if (o != null && o.equals(objectValues[i])) {
|
||||
// The property is equal to its old value.
|
||||
continue;
|
||||
// The property is equal to its old value.
|
||||
continue;
|
||||
}
|
||||
objectValues[i] = o;
|
||||
// Make sure we have an editor for this property...
|
||||
if (propertyEditors[i] == null) {
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
// The property has changed! Update the editor.
|
||||
propertyEditors[i].removePropertyChangeListener(this);
|
||||
propertyEditors[i].setValue(o);
|
||||
propertyEditors[i].addPropertyChangeListener(this);
|
||||
if (views[i] != null) {
|
||||
//System.out.println("Trying to repaint " + (i + 1));
|
||||
//System.out.println("Trying to repaint " + (i + 1));
|
||||
views[i].repaint();
|
||||
}
|
||||
}
|
||||
|
||||
if (followDependencies) {
|
||||
// Handle the special method getGOEPropertyUpdateLinks which returns a list of pairs
|
||||
// of strings indicating that on an update of the i-th property, the i+1-th property
|
||||
// should be updated. This is useful for changes within sub-classes of the target
|
||||
// which are not directly displayed in this panel but in sub-panels (and there have an own view etc.)
|
||||
// Handle the special method getGOEPropertyUpdateLinks which returns a list of pairs
|
||||
// of strings indicating that on an update of the i-th property, the i+1-th property
|
||||
// should be updated. This is useful for changes within sub-classes of the target
|
||||
// which are not directly displayed in this panel but in sub-panels (and there have an own view etc.)
|
||||
Object o = BeanInspector.callIfAvailable(targetObject, "getGOEPropertyUpdateLinks", null);
|
||||
if ((o != null) && (o instanceof String[])) {
|
||||
if ((o != null) && (o instanceof String[])) {
|
||||
maybeTriggerUpdates(propIndex, (String[]) o);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Make sure the target bean gets repainted.
|
||||
if (Beans.isInstanceOf(targetObject, Component.class)) {
|
||||
//System.out.println("Beans.getInstanceOf repaint ");
|
||||
@@ -942,100 +945,100 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
||||
* @return
|
||||
*/
|
||||
private boolean updateFieldView(int i) {
|
||||
// looking at another field (not changed explicitly, maybe implicitly
|
||||
boolean valChanged = false;
|
||||
boolean doRepaint = false;
|
||||
// looking at another field (not changed explicitly, maybe implicitly
|
||||
boolean valChanged = false;
|
||||
boolean doRepaint = false;
|
||||
Object args[] = {};
|
||||
Method getter = propertyDescriptors[i].getReadMethod();
|
||||
if (propertyDescriptors[i].isHidden() || propertyDescriptors[i].isExpert()) {
|
||||
if ((propertyLabels[i] != null) && (propertyLabels[i].isVisible())) {
|
||||
// something is set to hidden but was visible up to now
|
||||
// something is set to hidden but was visible up to now
|
||||
viewWrappers[i].setVisible(false);
|
||||
views[i].setVisible(false);
|
||||
propertyLabels[i].setVisible(false);
|
||||
doRepaint = true;
|
||||
}
|
||||
return doRepaint;
|
||||
} else {
|
||||
doRepaint = true;
|
||||
}
|
||||
return doRepaint;
|
||||
} else {
|
||||
if ((propertyLabels[i] != null) && !(propertyLabels[i].isVisible())) {
|
||||
// something is invisible but set to not hidden in the mean time
|
||||
// something is invisible but set to not hidden in the mean time
|
||||
viewWrappers[i].setVisible(true);
|
||||
views[i].setVisible(true);
|
||||
propertyLabels[i].setVisible(true);
|
||||
doRepaint = true;
|
||||
}
|
||||
}
|
||||
try { // check if view i is up to date and in sync with the value of the getter
|
||||
doRepaint = true;
|
||||
}
|
||||
}
|
||||
try { // check if view i is up to date and in sync with the value of the getter
|
||||
if (views[i] != null) {
|
||||
Object val = getter.invoke(targetObject, args);
|
||||
if (views[i] instanceof PropertyBoolSelector) {
|
||||
valChanged = (((PropertyBoolSelector) views[i]).isSelected() != ((Boolean) val));
|
||||
if (valChanged) {
|
||||
((PropertyBoolSelector) views[i]).setSelected(((Boolean) val));
|
||||
}
|
||||
}
|
||||
} else if (views[i] instanceof PropertyText) {
|
||||
valChanged = !(((PropertyText) views[i]).getText()).equals(val.toString());
|
||||
if (valChanged) {
|
||||
((PropertyText) views[i]).setText(val.toString());
|
||||
}
|
||||
}
|
||||
} else if (views[i] instanceof PropertyPanel) {
|
||||
valChanged = false;//!((PropertyPanel)m_Views[i]).equals(value);
|
||||
// disregard whole panels and hope for the best
|
||||
} else if (views[i] instanceof PropertyValueSelector) {
|
||||
//changed = !((SelectedTag)val).isSelectedString((String)((PropertyValueSelector)m_Views[i]).getSelectedItem());
|
||||
// interestingly there seems to be an implicit update of the ValueSelector, possible changes
|
||||
// are already applied, all we need to see it is a repaint
|
||||
//changed = !((SelectedTag)val).isSelectedString((String)((PropertyValueSelector)m_Views[i]).getSelectedItem());
|
||||
// interestingly there seems to be an implicit update of the ValueSelector, possible changes
|
||||
// are already applied, all we need to see it is a repaint
|
||||
views[i].repaint();
|
||||
} else {
|
||||
System.out.println("Warning: Property \"" + i
|
||||
+ "\" not recognized. Skipping.");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
System.out.println("Warning: Property \"" + i
|
||||
+ "\" not recognized. Skipping.");
|
||||
}
|
||||
}
|
||||
} catch (Exception exc) {
|
||||
System.err.println("Exception in PropertySheetPanel");
|
||||
}
|
||||
return doRepaint;
|
||||
}
|
||||
System.err.println("Exception in PropertySheetPanel");
|
||||
}
|
||||
return doRepaint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the given link list and trigger updates of indicated properties.
|
||||
*
|
||||
*
|
||||
* @param propIndex
|
||||
* @param links
|
||||
*/
|
||||
private void maybeTriggerUpdates(int propIndex, String[] links) {
|
||||
int max = links.length;
|
||||
if (max % 2 == 1) {
|
||||
System.err.println("Error in PropertySheetPanel:maybeTriggerUpdates: odd number of strings provided!");
|
||||
max -= 1;
|
||||
}
|
||||
private void maybeTriggerUpdates(int propIndex, String[] links) {
|
||||
int max = links.length;
|
||||
if (max % 2 == 1) {
|
||||
System.err.println("Error in PropertySheetPanel:maybeTriggerUpdates: odd number of strings provided!");
|
||||
max -= 1;
|
||||
}
|
||||
for (int i = 0; i < max; i += 2) {
|
||||
if (links[i].equals(propertyDescriptors[propIndex].getName())) {
|
||||
updateLinkedProperty(links[i + 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateLinkedProperty(String propName) {
|
||||
private void updateLinkedProperty(String propName) {
|
||||
for (int i = 0; i < propertyDescriptors.length; i++) {
|
||||
if (propertyDescriptors[i].getName().equals(propName)) {
|
||||
Method getter = propertyDescriptors[i].getReadMethod();
|
||||
Object val = null;
|
||||
try {
|
||||
Object val = null;
|
||||
try {
|
||||
val = getter.invoke(targetObject, (Object[]) null);
|
||||
} catch (Exception e) {
|
||||
val = null;
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (val != null) {
|
||||
} catch (Exception e) {
|
||||
val = null;
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (val != null) {
|
||||
propertyEditors[i].setValue(val);
|
||||
} else {
|
||||
System.err.println("Error in PropertySheetPanel:updateLinkedProperty");
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class PropertyTableModel extends DefaultTableModel implements TableModel {
|
||||
@@ -1062,11 +1065,11 @@ class PropertyCellRenderer implements TableCellRenderer {
|
||||
} else if (value instanceof PropertyValueSelector) {
|
||||
return (PropertyValueSelector) value;
|
||||
}
|
||||
|
||||
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
class PropertyCellEditor extends AbstractCellEditor implements TableCellEditor {
|
||||
@@ -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,82 +25,84 @@ import javax.swing.JCheckBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class PropertySheetPanelStat extends JPanel implements Serializable {
|
||||
|
||||
public final static boolean TRACE = false;
|
||||
private Object[] m_Values;
|
||||
private JCheckBoxFlag[] m_Views;
|
||||
private JLabel[] m_Labels;
|
||||
private boolean[] m_flag;
|
||||
public final static boolean TRACE = false;
|
||||
private Object[] m_Values;
|
||||
private JCheckBoxFlag[] m_Views;
|
||||
private JLabel[] m_Labels;
|
||||
private boolean[] m_flag;
|
||||
|
||||
/**
|
||||
* Creates the property sheet panel.
|
||||
*/
|
||||
public PropertySheetPanelStat() {
|
||||
// setBorder(BorderFactory.createLineBorder(Color.red));
|
||||
/**
|
||||
* Creates the property sheet panel.
|
||||
*/
|
||||
public PropertySheetPanelStat() {
|
||||
// setBorder(BorderFactory.createLineBorder(Color.red));
|
||||
setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A support object for handling property change listeners
|
||||
*/
|
||||
private PropertyChangeSupport m_support = new PropertyChangeSupport(this);
|
||||
private PropertyChangeSupport m_support = new PropertyChangeSupport(this);
|
||||
|
||||
public synchronized void setTarget(String[] names, boolean[] flag) {
|
||||
int componentOffset = 0;
|
||||
// Close any child windows at this point
|
||||
removeAll();
|
||||
GridBagLayout gbLayout = new GridBagLayout();
|
||||
setLayout(gbLayout);
|
||||
setVisible(false);
|
||||
public synchronized void setTarget(String[] names, boolean[] flag) {
|
||||
int componentOffset = 0;
|
||||
// Close any child windows at this point
|
||||
removeAll();
|
||||
GridBagLayout gbLayout = new GridBagLayout();
|
||||
setLayout(gbLayout);
|
||||
setVisible(false);
|
||||
|
||||
int rowHeight = 12;
|
||||
int rowHeight = 12;
|
||||
|
||||
m_Values = new Object[flag.length];
|
||||
m_Views = new JCheckBoxFlag[flag.length];
|
||||
m_Labels = new JLabel[names.length];
|
||||
m_Values = new Object[flag.length];
|
||||
m_Views = new JCheckBoxFlag[flag.length];
|
||||
m_Labels = new JLabel[names.length];
|
||||
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
m_Labels[i] = new JLabel(names[i], SwingConstants.RIGHT);
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
m_Labels[i] = new JLabel(names[i], SwingConstants.RIGHT);
|
||||
m_Labels[i].setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 5));
|
||||
m_Views[i] = new JCheckBoxFlag(flag[i]);
|
||||
GridBagConstraints gbConstraints = new GridBagConstraints();
|
||||
gbConstraints.anchor = GridBagConstraints.EAST;
|
||||
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
|
||||
m_Views[i] = new JCheckBoxFlag(flag[i]);
|
||||
GridBagConstraints gbConstraints = new GridBagConstraints();
|
||||
gbConstraints.anchor = GridBagConstraints.EAST;
|
||||
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
|
||||
gbConstraints.gridy = i + componentOffset;
|
||||
gbConstraints.gridx = 0;
|
||||
gbLayout.setConstraints(m_Labels[i], gbConstraints);
|
||||
add(m_Labels[i]);
|
||||
JPanel newPanel = new JPanel();
|
||||
gbLayout.setConstraints(m_Labels[i], gbConstraints);
|
||||
add(m_Labels[i]);
|
||||
JPanel newPanel = new JPanel();
|
||||
newPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 10));
|
||||
|
||||
newPanel.setLayout(new BorderLayout());
|
||||
newPanel.add(m_Views[i], BorderLayout.CENTER);
|
||||
gbConstraints = new GridBagConstraints();
|
||||
gbConstraints.anchor = GridBagConstraints.WEST;
|
||||
gbConstraints.fill = GridBagConstraints.BOTH;
|
||||
newPanel.setLayout(new BorderLayout());
|
||||
newPanel.add(m_Views[i], BorderLayout.CENTER);
|
||||
gbConstraints = new GridBagConstraints();
|
||||
gbConstraints.anchor = GridBagConstraints.WEST;
|
||||
gbConstraints.fill = GridBagConstraints.BOTH;
|
||||
gbConstraints.gridy = i + componentOffset;
|
||||
gbConstraints.gridx = 1;
|
||||
gbConstraints.weightx = 100;
|
||||
gbLayout.setConstraints(newPanel, gbConstraints);
|
||||
add(newPanel);
|
||||
gbConstraints.weightx = 100;
|
||||
gbLayout.setConstraints(newPanel, gbConstraints);
|
||||
add(newPanel);
|
||||
}
|
||||
validate();
|
||||
setVisible(true);
|
||||
}
|
||||
validate();
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public boolean[] getState() {
|
||||
boolean[] ret = new boolean[this.m_Views.length];
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public boolean[] getState() {
|
||||
boolean[] ret = new boolean[this.m_Views.length];
|
||||
for (int i = 0; i < ret.length; i++) {
|
||||
ret[i] = m_Views[i].isSelected();
|
||||
ret[i] = m_Views[i].isSelected();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,23 +110,23 @@ public class PropertySheetPanelStat extends JPanel implements Serializable {
|
||||
*/
|
||||
class JCheckBoxFlag extends JCheckBox {
|
||||
|
||||
private boolean m_Flag = true;
|
||||
private boolean m_Flag = true;
|
||||
|
||||
public JCheckBoxFlag(boolean flag) {
|
||||
super();
|
||||
m_Flag = flag;
|
||||
super();
|
||||
m_Flag = flag;
|
||||
addItemListener(new ItemListener() {
|
||||
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent evt) {
|
||||
if (evt.getStateChange() == evt.SELECTED) {
|
||||
m_Flag = true;
|
||||
}
|
||||
if (evt.getStateChange() == evt.DESELECTED) {
|
||||
m_Flag = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
if (evt.getStateChange() == evt.SELECTED) {
|
||||
m_Flag = true;
|
||||
}
|
||||
if (evt.getStateChange() == evt.DESELECTED) {
|
||||
m_Flag = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -9,9 +9,9 @@ package eva2.gui;
|
||||
*/
|
||||
public class PropertyWeightedLPTchebycheff implements java.io.Serializable {
|
||||
|
||||
public double[] m_IdealValue;
|
||||
public double[] m_Weights;
|
||||
public int m_P = 0;
|
||||
public double[] m_IdealValue;
|
||||
public double[] m_Weights;
|
||||
public int m_P = 0;
|
||||
|
||||
public PropertyWeightedLPTchebycheff() {
|
||||
}
|
||||
@@ -25,7 +25,7 @@ public class PropertyWeightedLPTchebycheff implements java.io.Serializable {
|
||||
this.m_Weights = new double[e.m_Weights.length];
|
||||
System.arraycopy(e.m_Weights, 0, this.m_Weights, 0, this.m_Weights.length);
|
||||
}
|
||||
this.m_P = e.m_P;
|
||||
this.m_P = e.m_P;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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
|
||||
@@ -41,11 +42,11 @@ class SplashScreen extends Frame {
|
||||
byte[] bytes = loader.getBytesFromResourceLocation(imgLocation, true);
|
||||
ImageIcon ii = new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes));
|
||||
JLabel splashLabel = new JLabel(ii);
|
||||
|
||||
|
||||
splashWindow.add(splashLabel);
|
||||
splashWindow.pack();
|
||||
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
splashWindow.setLocation(screenSize.width / 2 - splashWindow.getSize().width / 2, screenSize.height / 2 - splashWindow.getSize().height / 2);
|
||||
splashWindow.setVisible(true);
|
||||
splashWindow.setVisible(true);
|
||||
}
|
||||
}
|
||||
@@ -28,20 +28,27 @@ import javax.swing.SwingConstants;
|
||||
*/
|
||||
public abstract class AbstractListSelectionEditor extends JPanel implements PropertyEditor, PropertyChangeListener {
|
||||
|
||||
/** Handles property change notification */
|
||||
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||
/** The label for when we can't edit that type */
|
||||
protected JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER);
|
||||
|
||||
/** The graphics stuff */
|
||||
private JPanel m_CustomEditor, m_NodePanel;
|
||||
protected JCheckBox[] m_BlackCheck;
|
||||
/**
|
||||
* Handles property change notification
|
||||
*/
|
||||
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||
/**
|
||||
* The label for when we can't edit that type
|
||||
*/
|
||||
protected JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER);
|
||||
|
||||
|
||||
public AbstractListSelectionEditor() {
|
||||
}
|
||||
/**
|
||||
* The graphics stuff
|
||||
*/
|
||||
private JPanel m_CustomEditor, m_NodePanel;
|
||||
protected JCheckBox[] m_BlackCheck;
|
||||
|
||||
/** This method will init the CustomEditor Panel
|
||||
|
||||
public AbstractListSelectionEditor() {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will init the CustomEditor Panel
|
||||
*/
|
||||
private void initCustomEditor() {
|
||||
this.m_CustomEditor = new JPanel();
|
||||
@@ -54,37 +61,38 @@ public abstract class AbstractListSelectionEditor extends JPanel implements Prop
|
||||
|
||||
/**
|
||||
* Return the number of elements in the list.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract int getElementCount();
|
||||
|
||||
|
||||
/**
|
||||
* Get the display name of an element.
|
||||
*
|
||||
*
|
||||
* @param i
|
||||
* @return
|
||||
*/
|
||||
protected abstract String getElementName(int i);
|
||||
|
||||
|
||||
/**
|
||||
* Get the tool tip of an element or null if none is available.
|
||||
*
|
||||
*
|
||||
* @param i
|
||||
* @return
|
||||
*/
|
||||
protected String getElementToolTip(int i) {
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the selection state of an element.
|
||||
*
|
||||
*
|
||||
* @param i
|
||||
* @return
|
||||
*/
|
||||
protected abstract boolean isElementSelected(int i);
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* The object may have changed update the editor. This notifies change listeners automatically.
|
||||
*/
|
||||
private void updateEditor() {
|
||||
@@ -93,9 +101,9 @@ public abstract class AbstractListSelectionEditor extends JPanel implements Prop
|
||||
this.m_NodePanel.setLayout(new GridLayout(getElementCount(), 1));
|
||||
this.m_BlackCheck = new JCheckBox[getElementCount()];
|
||||
for (int i = 0; i < getElementCount(); i++) {
|
||||
this.m_BlackCheck[i] = new JCheckBox(getElementName(i), isElementSelected(i));
|
||||
this.m_BlackCheck[i].setToolTipText(getElementToolTip(i));
|
||||
this.m_BlackCheck[i].addActionListener(new ActionListener() {
|
||||
this.m_BlackCheck[i] = new JCheckBox(getElementName(i), isElementSelected(i));
|
||||
this.m_BlackCheck[i].setToolTipText(getElementToolTip(i));
|
||||
this.m_BlackCheck[i].addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent ev) {
|
||||
if (actionOnSelect()) {
|
||||
@@ -108,32 +116,35 @@ public abstract class AbstractListSelectionEditor extends JPanel implements Prop
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Perform actions when the selection state changes. Return true if there was an actual change.
|
||||
*/
|
||||
protected abstract boolean actionOnSelect();
|
||||
|
||||
/**
|
||||
* Set the base object, return true on success. Make sure that the editor instance is
|
||||
* added as a listener to the object (if supported).
|
||||
*
|
||||
* Set the base object, return true on success. Make sure that the editor instance is
|
||||
* added as a listener to the object (if supported).
|
||||
*
|
||||
* @param o
|
||||
* @return
|
||||
*/
|
||||
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
|
||||
public void setValue(Object o) {
|
||||
if (setObject(o)) {
|
||||
if (setObject(o)) {
|
||||
updateEditor();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Returns the current object.
|
||||
*
|
||||
* @return the current object
|
||||
*/
|
||||
@Override
|
||||
@@ -148,7 +159,7 @@ public abstract class AbstractListSelectionEditor extends JPanel implements Prop
|
||||
public String getAsText() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
throw new IllegalArgumentException(text);
|
||||
@@ -172,16 +183,19 @@ public abstract class AbstractListSelectionEditor extends JPanel implements Prop
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
}
|
||||
|
||||
/** Returns true since the Object can be shown
|
||||
|
||||
/**
|
||||
* Returns true since the Object can be shown
|
||||
*
|
||||
* @return true
|
||||
*/
|
||||
@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,9 +220,11 @@ public abstract class AbstractListSelectionEditor extends JPanel implements Prop
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Returns the array editing component.
|
||||
* @return a value of type 'java.awt.Component'
|
||||
*/
|
||||
/**
|
||||
* Returns the array editing component.
|
||||
*
|
||||
* @return a value of type 'java.awt.Component'
|
||||
*/
|
||||
@Override
|
||||
public Component getCustomEditor() {
|
||||
if (this.m_CustomEditor == null) {
|
||||
@@ -215,9 +232,9 @@ public abstract class AbstractListSelectionEditor extends JPanel implements Prop
|
||||
}
|
||||
return m_CustomEditor;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
m_Support.firePropertyChange("AbstractListSelectionEditor", null, this);
|
||||
m_Support.firePropertyChange("AbstractListSelectionEditor", null, this);
|
||||
}
|
||||
}
|
||||
@@ -12,9 +12,10 @@ package eva2.gui.editor;
|
||||
/*==========================================================================*
|
||||
* IMPORTS
|
||||
*==========================================================================*/
|
||||
|
||||
import eva2.gui.PropertyDialog;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.beans.*;
|
||||
import javax.swing.*;
|
||||
@@ -23,212 +24,219 @@ import javax.swing.*;
|
||||
* CLASS DECLARATION
|
||||
*==========================================================================*/
|
||||
public class BigStringEditor implements PropertyEditor {
|
||||
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||
private PropertyEditor m_ElementEditor;
|
||||
private JTextArea m_TextArea;
|
||||
private JScrollPane m_ScrollPane;
|
||||
private JPanel m_Panel;
|
||||
// private Source m_Source;
|
||||
private JButton m_SetButton;
|
||||
static private boolean m_finished = false;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static void editSource (String file) {
|
||||
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||
private PropertyEditor m_ElementEditor;
|
||||
private JTextArea m_TextArea;
|
||||
private JScrollPane m_ScrollPane;
|
||||
private JPanel m_Panel;
|
||||
// private Source m_Source;
|
||||
private JButton m_SetButton;
|
||||
static private boolean m_finished = false;
|
||||
|
||||
try {
|
||||
m_finished=false;
|
||||
BigStringEditor editor = new BigStringEditor();
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static void editSource(String file) {
|
||||
|
||||
PropertyDialog dialog = new PropertyDialog(editor,file, 50, 50);
|
||||
//frame.setSize(200, 200);
|
||||
dialog.addWindowListener(new WindowListener() {
|
||||
try {
|
||||
m_finished = false;
|
||||
BigStringEditor editor = new BigStringEditor();
|
||||
|
||||
PropertyDialog dialog = new PropertyDialog(editor, file, 50, 50);
|
||||
//frame.setSize(200, 200);
|
||||
dialog.addWindowListener(new WindowListener() {
|
||||
|
||||
@Override
|
||||
public void windowOpened(WindowEvent e) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowClosed(WindowEvent e) {
|
||||
public void windowClosed(WindowEvent e) {
|
||||
m_finished = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowIconified(WindowEvent e) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowDeiconified(WindowEvent e) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowActivated(WindowEvent e) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowDeactivated(WindowEvent e) {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
);
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public BigStringEditor () {
|
||||
super();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public BigStringEditor() {
|
||||
super();
|
||||
// m_TextArea = new JEditTextArea();
|
||||
// m_TextArea.setTokenMarker(new JavaTokenMarker());
|
||||
m_TextArea = new JTextArea(60,60);
|
||||
m_TextArea.setEditable(true);
|
||||
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"));
|
||||
m_Panel.setLayout(new BorderLayout());
|
||||
m_SetButton = new JButton("SET");
|
||||
m_SetButton.addActionListener(new ActionListener() {
|
||||
m_TextArea = new JTextArea(60, 60);
|
||||
m_TextArea.setEditable(true);
|
||||
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"));
|
||||
m_Panel.setLayout(new BorderLayout());
|
||||
m_SetButton = new JButton("SET");
|
||||
m_SetButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
setValue(m_TextArea.getText());
|
||||
}
|
||||
});
|
||||
m_Panel.add(m_ScrollPane, BorderLayout.CENTER);
|
||||
m_Panel.add(m_SetButton, BorderLayout.SOUTH);
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void setValue (Object value) {
|
||||
m_ElementEditor = null;
|
||||
if (value instanceof String) {
|
||||
// m_Source.setString((String)value);
|
||||
m_TextArea.setText((String)value);
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
setValue(m_TextArea.getText());
|
||||
}
|
||||
});
|
||||
m_Panel.add(m_ScrollPane, BorderLayout.CENTER);
|
||||
m_Panel.add(m_SetButton, BorderLayout.SOUTH);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void setValue(Object value) {
|
||||
m_ElementEditor = null;
|
||||
if (value instanceof String) {
|
||||
// m_Source.setString((String)value);
|
||||
m_TextArea.setText((String) value);
|
||||
|
||||
}
|
||||
/* if (value instanceof Source) {
|
||||
// m_Source = (Source) value;
|
||||
m_TextArea.setText(((Source)value).getString());
|
||||
}*/
|
||||
m_Support.firePropertyChange("", null, null);
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public Object getValue () {
|
||||
// m_Source.setString(m_TextArea.getText());
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public String getJavaInitializationString () {
|
||||
return "null";
|
||||
}
|
||||
m_Support.firePropertyChange("", null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true to indicate that we can paint a representation of the
|
||||
* string array
|
||||
*
|
||||
* @return true
|
||||
*/
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public boolean isPaintable () {
|
||||
return true;
|
||||
}
|
||||
public Object getValue() {
|
||||
// m_Source.setString(m_TextArea.getText());
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints a representation of the current classifier.
|
||||
*
|
||||
* @param gfx the graphics context to use
|
||||
* @param box the area we are allowed to paint into
|
||||
*/
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void paintValue (Graphics gfx, Rectangle box) {
|
||||
FontMetrics fm = gfx.getFontMetrics();
|
||||
int vpad = (box.height - fm.getAscent())/2;
|
||||
//String rep = EVAHELP.cutClassName(m_ElementClass.getName());
|
||||
gfx.drawString("BigStringEditor", 2, fm.getHeight() + vpad - 3);
|
||||
}
|
||||
public String getJavaInitializationString() {
|
||||
return "null";
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* Returns true to indicate that we can paint a representation of the
|
||||
* string array
|
||||
*
|
||||
* @return true
|
||||
*/
|
||||
@Override
|
||||
public String getAsText () {
|
||||
return null;
|
||||
}
|
||||
public boolean isPaintable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* Paints a representation of the current classifier.
|
||||
*
|
||||
* @param gfx the graphics context to use
|
||||
* @param box the area we are allowed to paint into
|
||||
*/
|
||||
@Override
|
||||
public void setAsText (String text) throws IllegalArgumentException {
|
||||
throw new IllegalArgumentException(text);
|
||||
}
|
||||
public void paintValue(Graphics gfx, Rectangle box) {
|
||||
FontMetrics fm = gfx.getFontMetrics();
|
||||
int vpad = (box.height - fm.getAscent()) / 2;
|
||||
//String rep = EVAHELP.cutClassName(m_ElementClass.getName());
|
||||
gfx.drawString("BigStringEditor", 2, fm.getHeight() + vpad - 3);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public String[] getTags () {
|
||||
return null;
|
||||
}
|
||||
public String getAsText() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public boolean supportsCustomEditor () {
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
throw new IllegalArgumentException(text);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public Component getCustomEditor () {
|
||||
return m_Panel;
|
||||
}
|
||||
public String[] getTags() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public boolean supportsCustomEditor() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public Component getCustomEditor() {
|
||||
return m_Panel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.addPropertyChangeListener(l);
|
||||
}
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
}
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package eva2.gui.editor;
|
||||
|
||||
/*
|
||||
* Title: EvA2
|
||||
* Description:
|
||||
@@ -10,5 +11,5 @@ package eva2.gui.editor;
|
||||
* $Author: streiche $
|
||||
*/
|
||||
public interface ComponentFilter {
|
||||
public boolean accept(java.awt.Component component);
|
||||
public boolean accept(java.awt.Component component);
|
||||
}
|
||||
|
||||
@@ -16,78 +16,80 @@ import javax.swing.JFrame;
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class EnumEditor extends PropertyEditorSupport {
|
||||
/** The Enum values that may be chosen */
|
||||
private Enum[] enumConstants;
|
||||
/**
|
||||
* The Enum values that may be chosen
|
||||
*/
|
||||
private Enum[] enumConstants;
|
||||
|
||||
@Override
|
||||
public String getAsText() {
|
||||
return getValue().toString();
|
||||
}
|
||||
|
||||
public String getAsText() {
|
||||
return getValue().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Object value) {
|
||||
if (value instanceof Enum) {
|
||||
enumConstants = ((Enum)value).getClass().getEnumConstants();
|
||||
public void setValue(Object value) {
|
||||
if (value instanceof Enum) {
|
||||
enumConstants = ((Enum) value).getClass().getEnumConstants();
|
||||
// enumType = ((Enum)value);
|
||||
super.setValue(value);
|
||||
} else if (value.getClass().isArray() && value.getClass().getComponentType().isEnum() ) {
|
||||
super.setValue(value);
|
||||
} else if (value.getClass().isArray() && value.getClass().getComponentType().isEnum()) {
|
||||
// values = value.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++) {
|
||||
if (text.equals(enumConstants[i].toString())) {
|
||||
setValue((Enum)enumConstants[i]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Invalid text for enum");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTags() {
|
||||
if (getValue()==null) {
|
||||
return null;
|
||||
}
|
||||
String[] tags = new String[enumConstants.length];
|
||||
for (int i=0; i<tags.length; i++) {
|
||||
tags[i]=enumConstants[i].toString();
|
||||
Enum<?>[] e = (Enum[]) (value);
|
||||
enumConstants = (Enum[]) e.getClass().getComponentType().getEnumConstants();
|
||||
super.setValue(value);
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the editor.
|
||||
*
|
||||
* @param args ignored
|
||||
*/
|
||||
public static void main(String [] args) {
|
||||
try {
|
||||
Enum<?> initial = TestEnum.asdf;
|
||||
EnumEditor ed = new EnumEditor();
|
||||
ed.setValue(initial);
|
||||
PropertyValueSelector ps = new PropertyValueSelector(ed);
|
||||
JFrame f = new JFrame();
|
||||
f.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
for (int i = 0; i < enumConstants.length; i++) {
|
||||
if (text.equals(enumConstants[i].toString())) {
|
||||
setValue((Enum) enumConstants[i]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Invalid text for enum");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTags() {
|
||||
if (getValue() == null) {
|
||||
return null;
|
||||
}
|
||||
String[] tags = new String[enumConstants.length];
|
||||
for (int i = 0; i < tags.length; i++) {
|
||||
tags[i] = enumConstants[i].toString();
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the editor.
|
||||
*
|
||||
* @param args ignored
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
Enum<?> initial = TestEnum.asdf;
|
||||
EnumEditor ed = new EnumEditor();
|
||||
ed.setValue(initial);
|
||||
PropertyValueSelector ps = new PropertyValueSelector(ed);
|
||||
JFrame f = new JFrame();
|
||||
f.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
f.getContentPane().setLayout(new BorderLayout());
|
||||
f.getContentPane().add(ps, BorderLayout.CENTER);
|
||||
f.pack();
|
||||
f.setVisible(true);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
System.err.println(ex.getMessage());
|
||||
}
|
||||
}
|
||||
public void windowClosing(WindowEvent e) {
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
f.getContentPane().setLayout(new BorderLayout());
|
||||
f.getContentPane().add(ps, BorderLayout.CENTER);
|
||||
f.pack();
|
||||
f.setVisible(true);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
System.err.println(ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum TestEnum { asdf, sdf, asdfa};
|
||||
enum TestEnum {asdf, sdf, asdfa};
|
||||
@@ -11,53 +11,55 @@ 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*/
|
||||
private GPArea m_AreaObject;
|
||||
|
||||
/**
|
||||
* The GPArea that is to be edited
|
||||
*/
|
||||
private GPArea m_AreaObject;
|
||||
|
||||
public GenericAreaEditor() {
|
||||
// compiled code
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getElementCount() {
|
||||
return m_AreaObject.getCompleteList().size();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getElementName(int i) {
|
||||
AbstractGPNode an = (AbstractGPNode)m_AreaObject.getCompleteList().get(i);
|
||||
return an.getName();
|
||||
}
|
||||
@Override
|
||||
protected int getElementCount() {
|
||||
return m_AreaObject.getCompleteList().size();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isElementSelected(int i) {
|
||||
return ((Boolean)m_AreaObject.getBlackList().get(i)).booleanValue();
|
||||
}
|
||||
@Override
|
||||
protected String getElementName(int i) {
|
||||
AbstractGPNode an = (AbstractGPNode) m_AreaObject.getCompleteList().get(i);
|
||||
return an.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean actionOnSelect() {
|
||||
/** This method checks the current BlackList and compiles it
|
||||
* to a new ReducedList.
|
||||
*/
|
||||
for (int i = 0; i < this.m_BlackCheck.length; i++) {
|
||||
this.m_AreaObject.setBlackListElement(i, this.m_BlackCheck[i].isSelected());
|
||||
}
|
||||
this.m_AreaObject.compileReducedList();
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
protected boolean isElementSelected(int i) {
|
||||
return ((Boolean) m_AreaObject.getBlackList().get(i)).booleanValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setObject(Object o) {
|
||||
@Override
|
||||
protected boolean actionOnSelect() {
|
||||
/** This method checks the current BlackList and compiles it
|
||||
* to a new ReducedList.
|
||||
*/
|
||||
for (int i = 0; i < this.m_BlackCheck.length; i++) {
|
||||
this.m_AreaObject.setBlackListElement(i, this.m_BlackCheck[i].isSelected());
|
||||
}
|
||||
this.m_AreaObject.compileReducedList();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setObject(Object o) {
|
||||
if (o instanceof GPArea) {
|
||||
this.m_AreaObject = (GPArea) o;
|
||||
m_AreaObject.addPropertyChangeListener(this);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
return this.m_AreaObject;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -165,7 +166,7 @@ public class GenericArrayEditor extends JPanel implements PropertyEditor {
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Listens to list items being selected and takes appropriate action
|
||||
*/
|
||||
@@ -173,7 +174,7 @@ public class GenericArrayEditor extends JPanel implements PropertyEditor {
|
||||
new ListSelectionListener() {
|
||||
//
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
|
||||
if (e.getSource() == elementList) {
|
||||
@@ -261,7 +262,7 @@ public class GenericArrayEditor extends JPanel implements PropertyEditor {
|
||||
* Creates the list cell renderer.
|
||||
*
|
||||
* @param editorClass The class of the property editor for array objects
|
||||
* @param valueClass The class of the array values
|
||||
* @param valueClass The class of the array values
|
||||
*/
|
||||
public EditorListCellRenderer(Class editorClass, Class valueClass) {
|
||||
this.editorClass = editorClass;
|
||||
@@ -271,24 +272,24 @@ public class GenericArrayEditor extends JPanel implements PropertyEditor {
|
||||
/**
|
||||
* Creates a cell rendering component.
|
||||
*
|
||||
* @param JList the list that will be rendered in
|
||||
* @param Object the cell value
|
||||
* @param int which element of the list to render
|
||||
* @param JList the list that will be rendered in
|
||||
* @param Object the cell value
|
||||
* @param int which element of the list to render
|
||||
* @param boolean true if the cell is selected
|
||||
* @param boolean true if the cell has the focus
|
||||
* @return the rendering component
|
||||
*/
|
||||
@Override
|
||||
public Component getListCellRendererComponent(final JList list,
|
||||
final Object value,
|
||||
final int index,
|
||||
final boolean isSelected,
|
||||
final boolean cellHasFocus) {
|
||||
final Object value,
|
||||
final int index,
|
||||
final boolean isSelected,
|
||||
final boolean cellHasFocus) {
|
||||
try {
|
||||
final PropertyEditor e = (PropertyEditor) editorClass.newInstance();
|
||||
if (e instanceof GenericObjectEditor) {
|
||||
((GenericObjectEditor) e).setClassType(valueClass);
|
||||
}
|
||||
}
|
||||
e.setValue(value);
|
||||
JPanel cellPanel = new JPanel() {
|
||||
|
||||
@@ -644,7 +645,7 @@ public class GenericArrayEditor extends JPanel implements PropertyEditor {
|
||||
* @return
|
||||
*/
|
||||
private JMenuItem createMenuItem(String title, boolean enabled,
|
||||
ActionListener aListener) {
|
||||
ActionListener aListener) {
|
||||
JMenuItem item = new JMenuItem(title);
|
||||
// if (bgColor!=null) item.setForeground(bgColor);
|
||||
item.addActionListener(aListener);
|
||||
|
||||
@@ -26,32 +26,36 @@ import javax.swing.SwingConstants;
|
||||
|
||||
/**
|
||||
* A simple focus listener with an object ID and callback.
|
||||
*
|
||||
* @author mkron
|
||||
*
|
||||
* @author mkron
|
||||
*/
|
||||
class MyFocusListener implements FocusListener {
|
||||
private int myID = -1;
|
||||
private GenericDoubleArrayEditor arrEditor = null;
|
||||
|
||||
public MyFocusListener(int id, GenericDoubleArrayEditor gdae) {
|
||||
myID = id;
|
||||
this.arrEditor = gdae;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.awt.event.FocusListener#focusLost(java.awt.event.FocusEvent)
|
||||
*/
|
||||
private int myID = -1;
|
||||
private GenericDoubleArrayEditor arrEditor = null;
|
||||
|
||||
public MyFocusListener(int id, GenericDoubleArrayEditor gdae) {
|
||||
myID = id;
|
||||
this.arrEditor = gdae;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.awt.event.FocusListener#focusLost(java.awt.event.FocusEvent)
|
||||
*/
|
||||
@Override
|
||||
public void focusLost(FocusEvent e) { }
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.awt.event.FocusListener#focusGained(java.awt.event.FocusEvent)
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
;
|
||||
};
|
||||
|
||||
|
||||
@@ -60,29 +64,41 @@ class MyFocusListener implements FocusListener {
|
||||
*/
|
||||
public class GenericDoubleArrayEditor extends JPanel implements PropertyEditor {
|
||||
|
||||
private static final long serialVersionUID = 7749892624600018812L;
|
||||
/** Handles property change notification */
|
||||
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||
/** 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*/
|
||||
private static final long serialVersionUID = 7749892624600018812L;
|
||||
/**
|
||||
* Handles property change notification
|
||||
*/
|
||||
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
private PropertyDoubleArray m_DoubleArray;
|
||||
|
||||
/** 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? **/
|
||||
private int lastFocussedRow = -1;
|
||||
/**
|
||||
* 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? *
|
||||
*/
|
||||
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();
|
||||
this.m_CustomEditor = new JPanel();
|
||||
this.m_CustomEditor.setLayout(new BorderLayout());
|
||||
|
||||
this.m_CustomEditor.add(new JLabel("Current Double Array:"), BorderLayout.NORTH);
|
||||
@@ -100,17 +116,17 @@ public class GenericDoubleArrayEditor extends JPanel implements PropertyEditor {
|
||||
this.m_DeleteButton.addActionListener(this.deleteAction);
|
||||
this.m_NormalizeButton = new JButton("Normalize");
|
||||
this.m_NormalizeButton.addActionListener(this.normalizeAction);
|
||||
this.m_OKButton = new JButton("OK");
|
||||
this.m_OKButton = new JButton("OK");
|
||||
this.m_OKButton.setEnabled(true);
|
||||
this.m_OKButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
//m_Backup = copyObject(m_Object);
|
||||
if ((m_CustomEditor.getTopLevelAncestor() != null) && (m_CustomEditor.getTopLevelAncestor() instanceof Window)) {
|
||||
Window w = (Window) m_CustomEditor.getTopLevelAncestor();
|
||||
w.dispose();
|
||||
}
|
||||
}
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
//m_Backup = copyObject(m_Object);
|
||||
if ((m_CustomEditor.getTopLevelAncestor() != null) && (m_CustomEditor.getTopLevelAncestor() instanceof Window)) {
|
||||
Window w = (Window) m_CustomEditor.getTopLevelAncestor();
|
||||
w.dispose();
|
||||
}
|
||||
}
|
||||
});
|
||||
this.m_ButtonPanel.add(this.m_AddButton);
|
||||
this.m_ButtonPanel.add(this.m_DeleteButton);
|
||||
@@ -120,74 +136,79 @@ 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
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
m_DoubleArray.addRowCopy(lastFocussedRow); // copy the last focussed row
|
||||
m_DoubleArray.addRowCopy(lastFocussedRow); // copy the last focussed row
|
||||
updateEditor();
|
||||
}
|
||||
};
|
||||
|
||||
/** 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);
|
||||
} else {
|
||||
m_DoubleArray.deleteRow(lastFocussedRow);
|
||||
}
|
||||
if (!m_DoubleArray.isValidRow(lastFocussedRow)) {
|
||||
m_DoubleArray.deleteRow(m_DoubleArray.getNumRows() - 1);
|
||||
} else {
|
||||
m_DoubleArray.deleteRow(lastFocussedRow);
|
||||
}
|
||||
updateEditor();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* This action listener nomalizes each columng of the values of the DoubleArray.
|
||||
*/
|
||||
ActionListener normalizeAction = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
m_DoubleArray.normalizeColumns();
|
||||
m_DoubleArray.normalizeColumns();
|
||||
updateEditor();
|
||||
}
|
||||
};
|
||||
|
||||
/** This action listener reads all values
|
||||
|
||||
/**
|
||||
* This action listener reads all values
|
||||
*/
|
||||
KeyListener readDoubleArrayAction = new KeyListener() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent event) {
|
||||
public void keyPressed(KeyEvent event) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent event) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent event) {
|
||||
double[][] tmpDD = new double[m_InputTextFields.length][m_InputTextFields[0].length];
|
||||
double[][] tmpDD = new double[m_InputTextFields.length][m_InputTextFields[0].length];
|
||||
|
||||
for (int i = 0; i < tmpDD.length; i++) {
|
||||
for (int j=0; j< tmpDD[0].length; j++) {
|
||||
try {
|
||||
double d = 0;
|
||||
d = new Double(m_InputTextFields[i][j].getText()).doubleValue();
|
||||
tmpDD[i][j] = d;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < tmpDD[0].length; j++) {
|
||||
try {
|
||||
double d = 0;
|
||||
d = new Double(m_InputTextFields[i][j].getText()).doubleValue();
|
||||
tmpDD[i][j] = d;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
//tmpD[i] = new Double(m_InputTextField[i].getText()).doubleValue();
|
||||
}
|
||||
|
||||
m_DoubleArray.setDoubleArray(tmpDD);
|
||||
//updateEditor();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/** 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,34 +236,37 @@ 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();
|
||||
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++) {
|
||||
this.m_InputTextFields[i][j] = new JTextField();
|
||||
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]);
|
||||
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].addKeyListener(this.readDoubleArrayAction);
|
||||
this.m_InputTextFields[i][j].addFocusListener(new MyFocusListener(i, this));
|
||||
this.m_DataPanel.add(this.m_InputTextFields[i][j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void notifyFocusID(int id) {
|
||||
// notification of which column has the focus
|
||||
lastFocussedRow =id;
|
||||
// notification of which column has the focus
|
||||
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
|
||||
@@ -292,35 +318,41 @@ public class GenericDoubleArrayEditor extends JPanel implements PropertyEditor {
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) {
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.addPropertyChangeListener(l);
|
||||
m_Support.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) {
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
}
|
||||
|
||||
/** This is used to hook an action listener to the ok button
|
||||
/**
|
||||
* This is used to hook an action listener to the ok button
|
||||
*
|
||||
* @param a The action listener.
|
||||
*/
|
||||
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,20 +371,24 @@ 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.
|
||||
* @return true
|
||||
*/
|
||||
/**
|
||||
* Returns true because we do support a custom editor.
|
||||
*
|
||||
* @return true
|
||||
*/
|
||||
@Override
|
||||
public boolean supportsCustomEditor() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Returns the array editing component.
|
||||
* @return a value of type 'java.awt.Component'
|
||||
*/
|
||||
/**
|
||||
* Returns the array editing component.
|
||||
*
|
||||
* @return a value of type 'java.awt.Component'
|
||||
*/
|
||||
@Override
|
||||
public Component getCustomEditor() {
|
||||
if (this.m_CustomEditor == null) {
|
||||
|
||||
@@ -18,27 +18,36 @@ import javax.swing.*;
|
||||
*/
|
||||
public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEditor {
|
||||
|
||||
/** Handles property change notification */
|
||||
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||
/** 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*/
|
||||
/**
|
||||
* Handles property change notification
|
||||
*/
|
||||
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
private PropertyEpsilonConstraint m_EpsilonConstraint;
|
||||
|
||||
/** The gaphix stuff */
|
||||
private JPanel m_CustomEditor, m_DataPanel, m_ButtonPanel, m_TargetPanel;
|
||||
private JTextField[] m_TargetTextField;
|
||||
private JComboBox m_Objective;
|
||||
private JButton m_OKButton;
|
||||
/**
|
||||
* The gaphix stuff
|
||||
*/
|
||||
private JPanel m_CustomEditor, m_DataPanel, m_ButtonPanel, m_TargetPanel;
|
||||
private JTextField[] m_TargetTextField;
|
||||
private JComboBox m_Objective;
|
||||
private JButton m_OKButton;
|
||||
|
||||
public GenericEpsilonConstraintEditor() {
|
||||
// compiled code
|
||||
}
|
||||
|
||||
/** This method will init the CustomEditor Panel
|
||||
/**
|
||||
* This method will init the CustomEditor Panel
|
||||
*/
|
||||
private void initCustomEditor() {
|
||||
this.m_CustomEditor = new JPanel();
|
||||
this.m_CustomEditor = new JPanel();
|
||||
this.m_CustomEditor.setLayout(new BorderLayout());
|
||||
|
||||
// target panel
|
||||
@@ -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);
|
||||
@@ -60,46 +69,49 @@ public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEd
|
||||
|
||||
// init button panel
|
||||
this.m_ButtonPanel = new JPanel();
|
||||
this.m_OKButton = new JButton("OK");
|
||||
this.m_OKButton = new JButton("OK");
|
||||
this.m_OKButton.setEnabled(true);
|
||||
this.m_OKButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
//m_Backup = copyObject(m_Object);
|
||||
if ((m_CustomEditor.getTopLevelAncestor() != null) && (m_CustomEditor.getTopLevelAncestor() instanceof Window)) {
|
||||
Window w = (Window) m_CustomEditor.getTopLevelAncestor();
|
||||
w.dispose();
|
||||
}
|
||||
}
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
//m_Backup = copyObject(m_Object);
|
||||
if ((m_CustomEditor.getTopLevelAncestor() != null) && (m_CustomEditor.getTopLevelAncestor() instanceof Window)) {
|
||||
Window w = (Window) m_CustomEditor.getTopLevelAncestor();
|
||||
w.dispose();
|
||||
}
|
||||
}
|
||||
});
|
||||
this.m_ButtonPanel.add(this.m_OKButton);
|
||||
this.m_CustomEditor.add(this.m_ButtonPanel, BorderLayout.SOUTH);
|
||||
this.updateEditor();
|
||||
}
|
||||
|
||||
/** This action listener adds an element to DoubleArray
|
||||
/**
|
||||
* This action listener adds an element to DoubleArray
|
||||
*/
|
||||
ItemListener objectiveAction = new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent event) {
|
||||
m_EpsilonConstraint.m_OptimizeObjective = m_Objective.getSelectedIndex();
|
||||
m_EpsilonConstraint.m_OptimizeObjective = m_Objective.getSelectedIndex();
|
||||
updateEditor();
|
||||
}
|
||||
};
|
||||
|
||||
/** 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) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent event) {
|
||||
double[] tmpT = m_EpsilonConstraint.m_TargetValue;
|
||||
double[] tmpT = m_EpsilonConstraint.m_TargetValue;
|
||||
|
||||
for (int i = 0; i < tmpT.length; i++) {
|
||||
|
||||
@@ -112,11 +124,12 @@ public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEd
|
||||
}
|
||||
}
|
||||
|
||||
m_EpsilonConstraint.m_TargetValue = tmpT;
|
||||
}
|
||||
m_EpsilonConstraint.m_TargetValue = tmpT;
|
||||
}
|
||||
};
|
||||
|
||||
/** 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;
|
||||
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] = new JTextField();
|
||||
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
|
||||
@@ -199,35 +217,41 @@ public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEd
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) {
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.addPropertyChangeListener(l);
|
||||
m_Support.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) {
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
}
|
||||
|
||||
/** This is used to hook an action listener to the ok button
|
||||
/**
|
||||
* This is used to hook an action listener to the ok button
|
||||
*
|
||||
* @param a The action listener.
|
||||
*/
|
||||
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,20 +270,24 @@ 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.
|
||||
* @return true
|
||||
*/
|
||||
/**
|
||||
* Returns true because we do support a custom editor.
|
||||
*
|
||||
* @return true
|
||||
*/
|
||||
@Override
|
||||
public boolean supportsCustomEditor() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Returns the array editing component.
|
||||
* @return a value of type 'java.awt.Component'
|
||||
*/
|
||||
/**
|
||||
* Returns the array editing component.
|
||||
*
|
||||
* @return a value of type 'java.awt.Component'
|
||||
*/
|
||||
@Override
|
||||
public Component getCustomEditor() {
|
||||
if (this.m_CustomEditor == null) {
|
||||
|
||||
@@ -18,27 +18,36 @@ import javax.swing.*;
|
||||
*/
|
||||
public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEditor {
|
||||
|
||||
/** Handles property change notification */
|
||||
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||
/** 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*/
|
||||
/**
|
||||
* Handles property change notification
|
||||
*/
|
||||
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
private PropertyEpsilonThreshold m_EpsilonThreshhold;
|
||||
|
||||
/** The gaphix stuff */
|
||||
private JPanel m_CustomEditor, m_DataPanel, m_ButtonPanel, m_TargetPanel;
|
||||
private JTextField[] m_TargetTextField, m_PunishTextField;
|
||||
private JComboBox m_Objective;
|
||||
private JButton m_OKButton;
|
||||
/**
|
||||
* The gaphix stuff
|
||||
*/
|
||||
private JPanel m_CustomEditor, m_DataPanel, m_ButtonPanel, m_TargetPanel;
|
||||
private JTextField[] m_TargetTextField, m_PunishTextField;
|
||||
private JComboBox m_Objective;
|
||||
private JButton m_OKButton;
|
||||
|
||||
public GenericEpsilonThresholdEditor() {
|
||||
// compiled code
|
||||
}
|
||||
|
||||
/** This method will init the CustomEditor Panel
|
||||
/**
|
||||
* This method will init the CustomEditor Panel
|
||||
*/
|
||||
private void initCustomEditor() {
|
||||
this.m_CustomEditor = new JPanel();
|
||||
this.m_CustomEditor = new JPanel();
|
||||
this.m_CustomEditor.setLayout(new BorderLayout());
|
||||
|
||||
// target panel
|
||||
@@ -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);
|
||||
@@ -60,47 +69,50 @@ public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEdi
|
||||
|
||||
// init button panel
|
||||
this.m_ButtonPanel = new JPanel();
|
||||
this.m_OKButton = new JButton("OK");
|
||||
this.m_OKButton = new JButton("OK");
|
||||
this.m_OKButton.setEnabled(true);
|
||||
this.m_OKButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
//m_Backup = copyObject(m_Object);
|
||||
if ((m_CustomEditor.getTopLevelAncestor() != null) && (m_CustomEditor.getTopLevelAncestor() instanceof Window)) {
|
||||
Window w = (Window) m_CustomEditor.getTopLevelAncestor();
|
||||
w.dispose();
|
||||
}
|
||||
}
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
//m_Backup = copyObject(m_Object);
|
||||
if ((m_CustomEditor.getTopLevelAncestor() != null) && (m_CustomEditor.getTopLevelAncestor() instanceof Window)) {
|
||||
Window w = (Window) m_CustomEditor.getTopLevelAncestor();
|
||||
w.dispose();
|
||||
}
|
||||
}
|
||||
});
|
||||
this.m_ButtonPanel.add(this.m_OKButton);
|
||||
this.m_CustomEditor.add(this.m_ButtonPanel, BorderLayout.SOUTH);
|
||||
this.updateEditor();
|
||||
}
|
||||
|
||||
/** This action listener adds an element to DoubleArray
|
||||
/**
|
||||
* This action listener adds an element to DoubleArray
|
||||
*/
|
||||
ItemListener objectiveAction = new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent event) {
|
||||
m_EpsilonThreshhold.m_OptimizeObjective = m_Objective.getSelectedIndex();
|
||||
m_EpsilonThreshhold.m_OptimizeObjective = m_Objective.getSelectedIndex();
|
||||
updateEditor();
|
||||
}
|
||||
};
|
||||
|
||||
/** 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) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent event) {
|
||||
double[] tmpT = m_EpsilonThreshhold.m_TargetValue;
|
||||
double[] tmpP = m_EpsilonThreshhold.m_Punishment;
|
||||
double[] tmpT = m_EpsilonThreshhold.m_TargetValue;
|
||||
double[] tmpP = m_EpsilonThreshhold.m_Punishment;
|
||||
|
||||
for (int i = 0; i < tmpT.length; i++) {
|
||||
|
||||
@@ -120,12 +132,13 @@ public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEdi
|
||||
}
|
||||
}
|
||||
|
||||
m_EpsilonThreshhold.m_TargetValue = tmpT;
|
||||
m_EpsilonThreshhold.m_Punishment = tmpP;
|
||||
}
|
||||
m_EpsilonThreshhold.m_TargetValue = tmpT;
|
||||
m_EpsilonThreshhold.m_Punishment = tmpP;
|
||||
}
|
||||
};
|
||||
|
||||
/** 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,29 +148,30 @@ 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;
|
||||
double[] tmpP = this.m_EpsilonThreshhold.m_Punishment;
|
||||
int obj = this.m_EpsilonThreshhold.m_OptimizeObjective;
|
||||
double[] tmpT = this.m_EpsilonThreshhold.m_TargetValue;
|
||||
double[] tmpP = this.m_EpsilonThreshhold.m_Punishment;
|
||||
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] = new JTextField();
|
||||
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] = new JTextField();
|
||||
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
|
||||
@@ -216,35 +234,41 @@ public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEdi
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) {
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.addPropertyChangeListener(l);
|
||||
m_Support.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) {
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
}
|
||||
|
||||
/** This is used to hook an action listener to the ok button
|
||||
/**
|
||||
* This is used to hook an action listener to the ok button
|
||||
*
|
||||
* @param a The action listener.
|
||||
*/
|
||||
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,20 +287,24 @@ 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.
|
||||
* @return true
|
||||
*/
|
||||
/**
|
||||
* Returns true because we do support a custom editor.
|
||||
*
|
||||
* @return true
|
||||
*/
|
||||
@Override
|
||||
public boolean supportsCustomEditor() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Returns the array editing component.
|
||||
* @return a value of type 'java.awt.Component'
|
||||
*/
|
||||
/**
|
||||
* Returns the array editing component.
|
||||
*
|
||||
* @return a value of type 'java.awt.Component'
|
||||
*/
|
||||
@Override
|
||||
public Component getCustomEditor() {
|
||||
if (this.m_CustomEditor == null) {
|
||||
|
||||
@@ -23,22 +23,32 @@ import javax.swing.SwingConstants;
|
||||
*/
|
||||
public class GenericFilePathEditor extends JPanel implements PropertyEditor {
|
||||
|
||||
/** Handles property change notification */
|
||||
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||
/** 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*/
|
||||
/**
|
||||
* Handles property change notification
|
||||
*/
|
||||
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
private PropertyFilePath m_FilePath;
|
||||
|
||||
/** The gaphix stuff */
|
||||
private JFileChooser m_FileChooser;
|
||||
private JPanel m_Panel;
|
||||
/**
|
||||
* The gaphix stuff
|
||||
*/
|
||||
private JFileChooser m_FileChooser;
|
||||
private JPanel m_Panel;
|
||||
|
||||
public GenericFilePathEditor() {
|
||||
// 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
|
||||
@@ -87,21 +99,23 @@ public class GenericFilePathEditor extends JPanel implements PropertyEditor {
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) {
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.addPropertyChangeListener(l);
|
||||
m_Support.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) {
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
}
|
||||
|
||||
/** Returns true since the Object can be shown
|
||||
/**
|
||||
* Returns true since the Object can be shown
|
||||
*
|
||||
* @return true
|
||||
*/
|
||||
@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,24 +134,28 @@ 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.
|
||||
* @return true
|
||||
*/
|
||||
/**
|
||||
* Returns true because we do support a custom editor.
|
||||
*
|
||||
* @return true
|
||||
*/
|
||||
@Override
|
||||
public boolean supportsCustomEditor() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Returns the array editing component.
|
||||
* @return a value of type 'java.awt.Component'
|
||||
*/
|
||||
/**
|
||||
* Returns the array editing component.
|
||||
*
|
||||
* @return a value of type 'java.awt.Component'
|
||||
*/
|
||||
@Override
|
||||
public Component getCustomEditor() {
|
||||
this.m_Panel = new JPanel();
|
||||
this.m_FileChooser = new JFileChooser();
|
||||
this.m_Panel = new JPanel();
|
||||
this.m_FileChooser = new JFileChooser();
|
||||
File file = new File(this.m_FilePath.getCompleteFilePath());
|
||||
this.m_FileChooser.setSelectedFile(file);
|
||||
this.m_FileChooser.setMultiSelectionEnabled(false);
|
||||
@@ -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() {
|
||||
@@ -155,7 +175,7 @@ public class GenericFilePathEditor extends JPanel implements PropertyEditor {
|
||||
m_FilePath.setCompleteFilePath(m_FileChooser.getSelectedFile().getAbsolutePath());
|
||||
m_Support.firePropertyChange("", m_FilePath, null);
|
||||
Window w = (Window) m_FileChooser.getTopLevelAncestor();
|
||||
w.dispose();
|
||||
w.dispose();
|
||||
m_Panel = null;
|
||||
}
|
||||
if (event.getActionCommand() == "CancelSelection") {
|
||||
|
||||
@@ -21,26 +21,35 @@ import javax.swing.*;
|
||||
*/
|
||||
public class GenericIntArrayEditor extends JPanel implements PropertyEditor {
|
||||
|
||||
/** Handles property change notification */
|
||||
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||
/** 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*/
|
||||
/**
|
||||
* Handles property change notification
|
||||
*/
|
||||
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
private PropertyIntArray m_IntArray;
|
||||
|
||||
/** The gaphix stuff */
|
||||
private JPanel m_CustomEditor, m_DataPanel, m_ButtonPanel;
|
||||
private JTextField[] m_InputTextField;
|
||||
private JButton m_OKButton;
|
||||
/**
|
||||
* The gaphix stuff
|
||||
*/
|
||||
private JPanel m_CustomEditor, m_DataPanel, m_ButtonPanel;
|
||||
private JTextField[] m_InputTextField;
|
||||
private JButton m_OKButton;
|
||||
|
||||
public GenericIntArrayEditor() {
|
||||
// compiled code
|
||||
}
|
||||
|
||||
/** This method will init the CustomEditor Panel
|
||||
/**
|
||||
* This method will init the CustomEditor Panel
|
||||
*/
|
||||
private void initCustomEditor() {
|
||||
this.m_CustomEditor = new JPanel();
|
||||
this.m_CustomEditor = new JPanel();
|
||||
this.m_CustomEditor.setLayout(new BorderLayout());
|
||||
|
||||
this.m_CustomEditor.add(new JLabel("Current Int Array:"), BorderLayout.NORTH);
|
||||
@@ -52,36 +61,38 @@ public class GenericIntArrayEditor extends JPanel implements PropertyEditor {
|
||||
|
||||
// init button panel
|
||||
this.m_ButtonPanel = new JPanel();
|
||||
this.m_OKButton = new JButton("OK");
|
||||
this.m_OKButton = new JButton("OK");
|
||||
this.m_OKButton.setEnabled(true);
|
||||
this.m_OKButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
//m_Backup = copyObject(m_Object);
|
||||
if ((m_CustomEditor.getTopLevelAncestor() != null) && (m_CustomEditor.getTopLevelAncestor() instanceof Window)) {
|
||||
Window w = (Window) m_CustomEditor.getTopLevelAncestor();
|
||||
w.dispose();
|
||||
}
|
||||
}
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
//m_Backup = copyObject(m_Object);
|
||||
if ((m_CustomEditor.getTopLevelAncestor() != null) && (m_CustomEditor.getTopLevelAncestor() instanceof Window)) {
|
||||
Window w = (Window) m_CustomEditor.getTopLevelAncestor();
|
||||
w.dispose();
|
||||
}
|
||||
}
|
||||
});
|
||||
this.m_ButtonPanel.add(this.m_OKButton);
|
||||
this.m_CustomEditor.add(this.m_ButtonPanel, BorderLayout.SOUTH);
|
||||
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) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent event) {
|
||||
int[] tmpD = new int[m_InputTextField.length];
|
||||
int[] tmpD = new int[m_InputTextField.length];
|
||||
|
||||
for (int i = 0; i < tmpD.length; i++) {
|
||||
try {
|
||||
@@ -93,10 +104,11 @@ public class GenericIntArrayEditor extends JPanel implements PropertyEditor {
|
||||
}
|
||||
}
|
||||
m_IntArray.setIntArray(tmpD);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/** 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] = new JTextField();
|
||||
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
|
||||
@@ -175,35 +192,41 @@ public class GenericIntArrayEditor extends JPanel implements PropertyEditor {
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) {
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.addPropertyChangeListener(l);
|
||||
m_Support.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) {
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
}
|
||||
|
||||
/** This is used to hook an action listener to the ok button
|
||||
/**
|
||||
* This is used to hook an action listener to the ok button
|
||||
*
|
||||
* @param a The action listener.
|
||||
*/
|
||||
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,20 +245,24 @@ 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.
|
||||
* @return true
|
||||
*/
|
||||
/**
|
||||
* Returns true because we do support a custom editor.
|
||||
*
|
||||
* @return true
|
||||
*/
|
||||
@Override
|
||||
public boolean supportsCustomEditor() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Returns the array editing component.
|
||||
* @return a value of type 'java.awt.Component'
|
||||
*/
|
||||
/**
|
||||
* Returns the array editing component.
|
||||
*
|
||||
* @return a value of type 'java.awt.Component'
|
||||
*/
|
||||
@Override
|
||||
public Component getCustomEditor() {
|
||||
if (this.m_CustomEditor == null) {
|
||||
|
||||
@@ -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>();
|
||||
@@ -110,7 +111,7 @@ public class GenericObjectEditor implements PropertyEditor {
|
||||
}
|
||||
|
||||
|
||||
if (!Modifier.isAbstract(m) && !clazz.isInterface()) { // dont take abstract classes or interfaces
|
||||
if (!Modifier.isAbstract(m) && !clazz.isInterface()) { // dont take abstract classes or interfaces
|
||||
try {
|
||||
Class<?>[] params = new Class[0];
|
||||
clazz.getConstructor(params);
|
||||
@@ -134,9 +135,9 @@ public class GenericObjectEditor implements PropertyEditor {
|
||||
* this only sets the hidden property of the java bean which is checked in the wasModified
|
||||
* method of PropertySheetPanel.
|
||||
*
|
||||
* @param cls class the property belongs to
|
||||
* @param property string name of the property
|
||||
* @param hide desired value to set, true for hidden, false for visible
|
||||
* @param cls class the property belongs to
|
||||
* @param property string name of the property
|
||||
* @param hide desired value to set, true for hidden, false for visible
|
||||
* @return false, if an error occurs, else true
|
||||
*/
|
||||
public static boolean setExpertProperty(Class<?> cls, String property, boolean expertValue) {
|
||||
@@ -164,9 +165,9 @@ public class GenericObjectEditor implements PropertyEditor {
|
||||
* this only sets the hidden property of the java bean which is checked in the wasModified
|
||||
* method of PropertySheetPanel.
|
||||
*
|
||||
* @param cls class the property belongs to
|
||||
* @param property string name of the property
|
||||
* @param hide desired value to set, true for hidden, false for visible
|
||||
* @param cls class the property belongs to
|
||||
* @param property string name of the property
|
||||
* @param hide desired value to set, true for hidden, false for visible
|
||||
* @return false, if an error occurs, else true
|
||||
*/
|
||||
public static boolean setHideProperty(Class<?> cls, String property, boolean hide) {
|
||||
@@ -263,7 +264,7 @@ public class GenericObjectEditor implements PropertyEditor {
|
||||
*
|
||||
* @param type a value of type 'Class'
|
||||
*/
|
||||
public void setClassType(Class<?> type) {
|
||||
public void setClassType(Class<?> type) {
|
||||
classType = type;
|
||||
if (editorComponent != null) {
|
||||
editorComponent.updateClassType();
|
||||
@@ -286,7 +287,7 @@ public class GenericObjectEditor implements PropertyEditor {
|
||||
|
||||
Vector<String> v = null;
|
||||
v = new Vector<String>(getClassesFromProperties(classType.getName(), null));
|
||||
|
||||
|
||||
try {
|
||||
if (v.size() > 0) {
|
||||
setObject((Object) Class.forName((String) v.get(0)).newInstance());
|
||||
@@ -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,52 +4,54 @@ import eva2.gui.PropertySelectableList;
|
||||
|
||||
/**
|
||||
* An editor for a selectable List.
|
||||
*
|
||||
*/
|
||||
public class GenericObjectListSelectionEditor extends AbstractListSelectionEditor {
|
||||
private PropertySelectableList objList;
|
||||
|
||||
public GenericObjectListSelectionEditor() {}
|
||||
|
||||
@Override
|
||||
protected int getElementCount() {
|
||||
return objList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getElementName(int i) {
|
||||
return objList.get(i).toString();
|
||||
}
|
||||
public GenericObjectListSelectionEditor() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isElementSelected(int i) {
|
||||
return objList.isSelected(i);
|
||||
}
|
||||
@Override
|
||||
protected int getElementCount() {
|
||||
return objList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean actionOnSelect() {
|
||||
boolean changed=false;
|
||||
for (int i = 0; i < this.m_BlackCheck.length; i++) {
|
||||
if (objList.isSelected(i)!=this.m_BlackCheck[i].isSelected()) {
|
||||
objList.setSelectionForElement(i, this.m_BlackCheck[i].isSelected());
|
||||
changed=true;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
@Override
|
||||
protected String getElementName(int i) {
|
||||
return objList.get(i).toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setObject(Object o) {
|
||||
@Override
|
||||
protected boolean isElementSelected(int i) {
|
||||
return objList.isSelected(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean actionOnSelect() {
|
||||
boolean changed = false;
|
||||
for (int i = 0; i < this.m_BlackCheck.length; i++) {
|
||||
if (objList.isSelected(i) != this.m_BlackCheck[i].isSelected()) {
|
||||
objList.setSelectionForElement(i, this.m_BlackCheck[i].isSelected());
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setObject(Object o) {
|
||||
if (o instanceof PropertySelectableList) {
|
||||
this.objList = (PropertySelectableList) o;
|
||||
objList.addPropertyChangeListener(this);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 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,28 +45,37 @@ import javax.swing.SwingConstants;
|
||||
*/
|
||||
public class GenericOptimizationObjectivesEditor extends JPanel implements PropertyEditor, java.beans.PropertyChangeListener {
|
||||
|
||||
/** Handles property change notification */
|
||||
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||
/** 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*/
|
||||
/**
|
||||
* Handles property change notification
|
||||
*/
|
||||
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
private PropertyOptimizationObjectives m_OptimizationObjectives;
|
||||
|
||||
/** The gaphix stuff */
|
||||
private JComponent m_Editor;
|
||||
private JPanel m_TargetList;
|
||||
private JComponent[] m_Targets;
|
||||
private JButton[] m_Delete;
|
||||
private JScrollPane m_ScrollTargets;
|
||||
private GeneralGOEProperty[] m_Editors;
|
||||
private PropertyChangeListener m_self;
|
||||
/**
|
||||
* The gaphix stuff
|
||||
*/
|
||||
private JComponent m_Editor;
|
||||
private JPanel m_TargetList;
|
||||
private JComponent[] m_Targets;
|
||||
private JButton[] m_Delete;
|
||||
private JScrollPane m_ScrollTargets;
|
||||
private GeneralGOEProperty[] m_Editors;
|
||||
private PropertyChangeListener m_self;
|
||||
|
||||
public GenericOptimizationObjectivesEditor() {
|
||||
m_self = this;
|
||||
|
||||
}
|
||||
|
||||
/** This method will init the CustomEditor Panel
|
||||
/**
|
||||
* This method will init the CustomEditor Panel
|
||||
*/
|
||||
private void initCustomEditor() {
|
||||
m_self = this;
|
||||
@@ -74,14 +84,14 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
|
||||
this.m_Editor.setMinimumSize(new Dimension(400, 200));
|
||||
|
||||
// init the editors
|
||||
InterfaceOptimizationObjective[] list = this.m_OptimizationObjectives.getSelectedTargets();
|
||||
InterfaceOptimizationObjective[] list = this.m_OptimizationObjectives.getSelectedTargets();
|
||||
this.m_Editors = new GeneralGOEProperty[list.length];
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
this.m_Editors[i] = new GeneralGOEProperty();
|
||||
this.m_Editors[i].m_Name = list[i].getName();
|
||||
this.m_Editors[i].m_Name = list[i].getName();
|
||||
try {
|
||||
this.m_Editors[i].m_Value = list[i];
|
||||
this.m_Editors[i].m_Editor = PropertyEditorProvider.findEditor(this.m_Editors[i].m_Value.getClass());
|
||||
this.m_Editors[i].m_Value = list[i];
|
||||
this.m_Editors[i].m_Editor = PropertyEditorProvider.findEditor(this.m_Editors[i].m_Value.getClass());
|
||||
if (this.m_Editors[i].m_Editor == null) {
|
||||
this.m_Editors[i].m_Editor = PropertyEditorProvider.findEditor(InterfaceOptimizationObjective.class);
|
||||
}
|
||||
@@ -99,87 +109,87 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
|
||||
}
|
||||
}
|
||||
this.m_TargetList = new JPanel();
|
||||
this.updateTargetList();
|
||||
this.updateTargetList();
|
||||
this.m_ScrollTargets = new JScrollPane(this.m_TargetList);
|
||||
|
||||
this.m_Editor.setLayout(new BorderLayout());
|
||||
this.m_Editor.add(this.m_ScrollTargets, BorderLayout.CENTER);
|
||||
|
||||
// the add button
|
||||
JButton addButton = new JButton("Add Opt. Target");
|
||||
JButton addButton = new JButton("Add Opt. Target");
|
||||
addButton.addActionListener(addTarget);
|
||||
this.m_Editor.add(addButton, BorderLayout.SOUTH);
|
||||
|
||||
// Some description would be nice
|
||||
JTextArea jt = new JTextArea();
|
||||
jt.setFont(new Font("SansSerif", Font.PLAIN,12));
|
||||
jt.setEditable(false);
|
||||
jt.setLineWrap(true);
|
||||
jt.setWrapStyleWord(true);
|
||||
jt.setText("Choose and parameterize optimization objectives.");
|
||||
JTextArea jt = new JTextArea();
|
||||
jt.setFont(new Font("SansSerif", Font.PLAIN, 12));
|
||||
jt.setEditable(false);
|
||||
jt.setLineWrap(true);
|
||||
jt.setWrapStyleWord(true);
|
||||
jt.setText("Choose and parameterize optimization objectives.");
|
||||
jt.setBackground(getBackground());
|
||||
JPanel jp = new JPanel();
|
||||
jp.setBorder(BorderFactory.createCompoundBorder(
|
||||
BorderFactory.createTitledBorder("Info"),
|
||||
BorderFactory.createEmptyBorder(0, 5, 5, 5)
|
||||
));
|
||||
jp.setLayout(new BorderLayout());
|
||||
jp.add(jt, BorderLayout.CENTER);
|
||||
JPanel p2 = new JPanel();
|
||||
JPanel jp = new JPanel();
|
||||
jp.setBorder(BorderFactory.createCompoundBorder(
|
||||
BorderFactory.createTitledBorder("Info"),
|
||||
BorderFactory.createEmptyBorder(0, 5, 5, 5)
|
||||
));
|
||||
jp.setLayout(new BorderLayout());
|
||||
jp.add(jt, BorderLayout.CENTER);
|
||||
JPanel p2 = new JPanel();
|
||||
p2.setLayout(new BorderLayout());
|
||||
JButton help = new JButton("Help");
|
||||
help.setEnabled(false);
|
||||
p2.add(help, BorderLayout.NORTH);
|
||||
jp.add(p2, BorderLayout.EAST);
|
||||
GridBagConstraints gbConstraints = new GridBagConstraints();
|
||||
GridBagConstraints gbConstraints = new GridBagConstraints();
|
||||
this.m_Editor.add(jp, BorderLayout.NORTH);
|
||||
|
||||
this.updateEditor();
|
||||
this.updateEditor();
|
||||
}
|
||||
|
||||
/** This method updates the server list
|
||||
*
|
||||
/**
|
||||
* This method updates the server list
|
||||
*/
|
||||
private void updateTargetList() {
|
||||
BasicResourceLoader loader = BasicResourceLoader.instance();
|
||||
byte[] bytes;
|
||||
InterfaceOptimizationObjective[] list = this.m_OptimizationObjectives.getSelectedTargets();
|
||||
BasicResourceLoader loader = BasicResourceLoader.instance();
|
||||
byte[] bytes;
|
||||
InterfaceOptimizationObjective[] list = this.m_OptimizationObjectives.getSelectedTargets();
|
||||
|
||||
this.m_TargetList.removeAll();
|
||||
this.m_TargetList.setLayout(new GridBagLayout());
|
||||
GridBagConstraints gbc = new GridBagConstraints();
|
||||
this.m_Targets = new JComponent[list.length];
|
||||
this.m_Delete = new JButton[list.length];
|
||||
String[] cups = new String[8];
|
||||
this.m_Targets = new JComponent[list.length];
|
||||
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;
|
||||
gbc.fill = GridBagConstraints.BOTH;
|
||||
gbc.gridx = 0;
|
||||
gbc.weightx = 10;
|
||||
gbc.anchor = GridBagConstraints.WEST;
|
||||
gbc.fill = GridBagConstraints.BOTH;
|
||||
gbc.gridx = 0;
|
||||
gbc.weightx = 10;
|
||||
this.m_TargetList.add(new JLabel("Target"), gbc);
|
||||
gbc.anchor = GridBagConstraints.WEST;
|
||||
gbc.fill = GridBagConstraints.REMAINDER;
|
||||
gbc.gridx = 1;
|
||||
gbc.weightx = 1;
|
||||
gbc.anchor = GridBagConstraints.WEST;
|
||||
gbc.fill = GridBagConstraints.REMAINDER;
|
||||
gbc.gridx = 1;
|
||||
gbc.weightx = 1;
|
||||
this.m_TargetList.add(new JLabel("Remove"), gbc);
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
// the status indicator
|
||||
gbc.anchor = GridBagConstraints.WEST;
|
||||
gbc.fill = GridBagConstraints.BOTH;
|
||||
gbc.gridx = 0;
|
||||
gbc.weightx = 10;
|
||||
gbc.anchor = GridBagConstraints.WEST;
|
||||
gbc.fill = GridBagConstraints.BOTH;
|
||||
gbc.gridx = 0;
|
||||
gbc.weightx = 10;
|
||||
// this.m_Targets[i] = new JButton(""+list[i].getName());
|
||||
// this.m_Targets[i].setEnabled(false);
|
||||
this.m_Targets[i] = this.m_Editors[i].m_View;
|
||||
this.m_TargetList.add(this.m_Targets[i], gbc);
|
||||
// The delete button
|
||||
gbc.anchor = GridBagConstraints.WEST;
|
||||
gbc.fill = GridBagConstraints.REMAINDER;
|
||||
gbc.gridx = 1;
|
||||
gbc.weightx = 1;
|
||||
gbc.anchor = GridBagConstraints.WEST;
|
||||
gbc.fill = GridBagConstraints.REMAINDER;
|
||||
gbc.gridx = 1;
|
||||
gbc.weightx = 1;
|
||||
bytes = loader.getBytesFromResourceLocation("images/Sub24.gif", true);
|
||||
this.m_Delete[i] = new JButton("", new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes)));
|
||||
this.m_Delete[i].addActionListener(deleteTarget);
|
||||
@@ -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++) {
|
||||
@@ -219,11 +231,11 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
|
||||
}
|
||||
InterfaceOptimizationObjective[] list = m_OptimizationObjectives.getSelectedTargets();
|
||||
l--;
|
||||
newEdit[l] = new GeneralGOEProperty();
|
||||
newEdit[l].m_Name = list[l].getName();
|
||||
newEdit[l] = new GeneralGOEProperty();
|
||||
newEdit[l].m_Name = list[l].getName();
|
||||
try {
|
||||
newEdit[l].m_Value = list[l];
|
||||
newEdit[l].m_Editor = PropertyEditorProvider.findEditor(newEdit[l].m_Value.getClass());
|
||||
newEdit[l].m_Value = list[l];
|
||||
newEdit[l].m_Editor = PropertyEditorProvider.findEditor(newEdit[l].m_Value.getClass());
|
||||
if (newEdit[l].m_Editor == null) {
|
||||
newEdit[l].m_Editor = PropertyEditorProvider.findEditor(InterfaceOptimizationObjective.class);
|
||||
}
|
||||
@@ -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,20 +383,24 @@ 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.
|
||||
* @return true
|
||||
*/
|
||||
/**
|
||||
* Returns true because we do support a custom editor.
|
||||
*
|
||||
* @return true
|
||||
*/
|
||||
@Override
|
||||
public boolean supportsCustomEditor() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Returns the array editing component.
|
||||
* @return a value of type 'java.awt.Component'
|
||||
*/
|
||||
/**
|
||||
* Returns the array editing component.
|
||||
*
|
||||
* @return a value of type 'java.awt.Component'
|
||||
*/
|
||||
@Override
|
||||
public Component getCustomEditor() {
|
||||
if (this.m_Editor == null) {
|
||||
@@ -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,39 +418,44 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
|
||||
this.updateEditor();
|
||||
}
|
||||
|
||||
/********************************* java.beans.PropertyChangeListener *************************/
|
||||
/**
|
||||
* ****************************** java.beans.PropertyChangeListener ************************
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) {
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.addPropertyChangeListener(l);
|
||||
m_Support.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) {
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
}
|
||||
/** This will wait for the GenericObjectEditor to finish
|
||||
|
||||
/**
|
||||
* This will wait for the GenericObjectEditor to finish
|
||||
* editing an object.
|
||||
*
|
||||
* @param evt
|
||||
*/
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
Object newVal = evt.getNewValue();
|
||||
Object oldVal = evt.getOldValue();
|
||||
InterfaceOptimizationObjective[] list = this.m_OptimizationObjectives.getSelectedTargets();
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
if (oldVal.equals(list[i])) {
|
||||
list[i] = (InterfaceOptimizationObjective)newVal;
|
||||
this.m_Editors[i].m_Name = list[i].getName();
|
||||
list[i] = (InterfaceOptimizationObjective) newVal;
|
||||
this.m_Editors[i].m_Name = list[i].getName();
|
||||
try {
|
||||
this.m_Editors[i].m_Value = list[i];
|
||||
this.m_Editors[i].m_Editor = PropertyEditorProvider.findEditor(this.m_Editors[i].m_Value.getClass());
|
||||
this.m_Editors[i].m_Value = list[i];
|
||||
this.m_Editors[i].m_Editor = PropertyEditorProvider.findEditor(this.m_Editors[i].m_Value.getClass());
|
||||
if (this.m_Editors[i].m_Editor == null) {
|
||||
this.m_Editors[i].m_Editor = PropertyEditorProvider.findEditor(InterfaceOptimizationObjective.class);
|
||||
}
|
||||
|
||||
@@ -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,28 +48,37 @@ import javax.swing.SwingConstants;
|
||||
*/
|
||||
public class GenericOptimizationObjectivesWithParamEditor extends JPanel implements PropertyEditor, java.beans.PropertyChangeListener {
|
||||
|
||||
/** Handles property change notification */
|
||||
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||
/** 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*/
|
||||
/**
|
||||
* Handles property change notification
|
||||
*/
|
||||
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
private PropertyOptimizationObjectivesWithParam m_OptimizationObjectivesWithWeights;
|
||||
|
||||
/** The gaphix stuff */
|
||||
private JComponent m_Editor;
|
||||
private JPanel m_TargetList;
|
||||
private JTextField[] m_Weights;
|
||||
private JComponent[] m_Targets;
|
||||
private JButton[] m_Delete;
|
||||
private JScrollPane m_ScrollTargets;
|
||||
private GeneralGOEProperty[] m_Editors;
|
||||
private PropertyChangeListener m_self;
|
||||
/**
|
||||
* The gaphix stuff
|
||||
*/
|
||||
private JComponent m_Editor;
|
||||
private JPanel m_TargetList;
|
||||
private JTextField[] m_Weights;
|
||||
private JComponent[] m_Targets;
|
||||
private JButton[] m_Delete;
|
||||
private JScrollPane m_ScrollTargets;
|
||||
private GeneralGOEProperty[] m_Editors;
|
||||
private PropertyChangeListener m_self;
|
||||
|
||||
public GenericOptimizationObjectivesWithParamEditor() {
|
||||
m_self = this;
|
||||
}
|
||||
|
||||
/** This method will init the CustomEditor Panel
|
||||
/**
|
||||
* This method will init the CustomEditor Panel
|
||||
*/
|
||||
private void initCustomEditor() {
|
||||
m_self = this;
|
||||
@@ -77,14 +87,14 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
||||
this.m_Editor.setMinimumSize(new Dimension(450, 200));
|
||||
|
||||
// init the editors
|
||||
InterfaceOptimizationObjective[] list = this.m_OptimizationObjectivesWithWeights.getSelectedTargets();
|
||||
InterfaceOptimizationObjective[] list = this.m_OptimizationObjectivesWithWeights.getSelectedTargets();
|
||||
this.m_Editors = new GeneralGOEProperty[list.length];
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
this.m_Editors[i] = new GeneralGOEProperty();
|
||||
this.m_Editors[i].m_Name = list[i].getName();
|
||||
this.m_Editors[i].m_Name = list[i].getName();
|
||||
try {
|
||||
this.m_Editors[i].m_Value = list[i];
|
||||
this.m_Editors[i].m_Editor = PropertyEditorProvider.findEditor(this.m_Editors[i].m_Value.getClass());
|
||||
this.m_Editors[i].m_Value = list[i];
|
||||
this.m_Editors[i].m_Editor = PropertyEditorProvider.findEditor(this.m_Editors[i].m_Value.getClass());
|
||||
if (this.m_Editors[i].m_Editor == null) {
|
||||
this.m_Editors[i].m_Editor = PropertyEditorProvider.findEditor(InterfaceOptimizationObjective.class);
|
||||
}
|
||||
@@ -102,17 +112,17 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
||||
}
|
||||
}
|
||||
this.m_TargetList = new JPanel();
|
||||
this.updateTargetList();
|
||||
this.updateTargetList();
|
||||
this.m_ScrollTargets = new JScrollPane(this.m_TargetList);
|
||||
|
||||
this.m_Editor.setLayout(new BorderLayout());
|
||||
this.m_Editor.add(this.m_ScrollTargets, BorderLayout.CENTER);
|
||||
|
||||
// The Button Panel
|
||||
JPanel buttonPanel = new JPanel();
|
||||
buttonPanel.setLayout(new GridLayout(1,2));
|
||||
JButton addButton = new JButton("Add Opt. Target");
|
||||
JButton normButton = new JButton("Normalize Weights");
|
||||
JPanel buttonPanel = new JPanel();
|
||||
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());
|
||||
normButton.addActionListener(normalizeWeights);
|
||||
addButton.addActionListener(addTarget);
|
||||
@@ -122,89 +132,89 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
||||
this.m_Editor.add(buttonPanel, BorderLayout.SOUTH);
|
||||
|
||||
// Some description would be nice
|
||||
JTextArea jt = new JTextArea();
|
||||
jt.setFont(new Font("SansSerif", Font.PLAIN,12));
|
||||
jt.setEditable(false);
|
||||
jt.setLineWrap(true);
|
||||
jt.setWrapStyleWord(true);
|
||||
jt.setText(this.m_OptimizationObjectivesWithWeights.getDescriptiveString());
|
||||
JTextArea jt = new JTextArea();
|
||||
jt.setFont(new Font("SansSerif", Font.PLAIN, 12));
|
||||
jt.setEditable(false);
|
||||
jt.setLineWrap(true);
|
||||
jt.setWrapStyleWord(true);
|
||||
jt.setText(this.m_OptimizationObjectivesWithWeights.getDescriptiveString());
|
||||
jt.setBackground(getBackground());
|
||||
JPanel jp = new JPanel();
|
||||
jp.setBorder(BorderFactory.createCompoundBorder(
|
||||
BorderFactory.createTitledBorder("Info"),
|
||||
BorderFactory.createEmptyBorder(0, 5, 5, 5)
|
||||
));
|
||||
jp.setLayout(new BorderLayout());
|
||||
jp.add(jt, BorderLayout.CENTER);
|
||||
JPanel p2 = new JPanel();
|
||||
JPanel jp = new JPanel();
|
||||
jp.setBorder(BorderFactory.createCompoundBorder(
|
||||
BorderFactory.createTitledBorder("Info"),
|
||||
BorderFactory.createEmptyBorder(0, 5, 5, 5)
|
||||
));
|
||||
jp.setLayout(new BorderLayout());
|
||||
jp.add(jt, BorderLayout.CENTER);
|
||||
JPanel p2 = new JPanel();
|
||||
p2.setLayout(new BorderLayout());
|
||||
JButton help = new JButton("Help");
|
||||
help.setEnabled(false);
|
||||
p2.add(help, BorderLayout.NORTH);
|
||||
jp.add(p2, BorderLayout.EAST);
|
||||
GridBagConstraints gbConstraints = new GridBagConstraints();
|
||||
GridBagConstraints gbConstraints = new GridBagConstraints();
|
||||
|
||||
this.m_Editor.add(jp, BorderLayout.NORTH);
|
||||
|
||||
this.updateEditor();
|
||||
}
|
||||
|
||||
/** This method updates the server list
|
||||
*
|
||||
/**
|
||||
* This method updates the server list
|
||||
*/
|
||||
private void updateTargetList() {
|
||||
BasicResourceLoader loader = BasicResourceLoader.instance();
|
||||
byte[] bytes;
|
||||
InterfaceOptimizationObjective[] list = this.m_OptimizationObjectivesWithWeights.getSelectedTargets();
|
||||
double[] weights = this.m_OptimizationObjectivesWithWeights.getWeights();
|
||||
BasicResourceLoader loader = BasicResourceLoader.instance();
|
||||
byte[] bytes;
|
||||
InterfaceOptimizationObjective[] list = this.m_OptimizationObjectivesWithWeights.getSelectedTargets();
|
||||
double[] weights = this.m_OptimizationObjectivesWithWeights.getWeights();
|
||||
|
||||
this.m_TargetList.removeAll();
|
||||
this.m_TargetList.setLayout(new GridBagLayout());
|
||||
GridBagConstraints gbc = new GridBagConstraints();
|
||||
this.m_Weights = new JTextField[list.length];
|
||||
this.m_Targets = new JComponent[list.length];
|
||||
this.m_Delete = new JButton[list.length];
|
||||
String[] cups = new String[8];
|
||||
this.m_Weights = new JTextField[list.length];
|
||||
this.m_Targets = new JComponent[list.length];
|
||||
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;
|
||||
gbc.fill = GridBagConstraints.BOTH;
|
||||
gbc.gridx = 0;
|
||||
gbc.weightx = 2;
|
||||
gbc.anchor = GridBagConstraints.WEST;
|
||||
gbc.fill = GridBagConstraints.BOTH;
|
||||
gbc.gridx = 0;
|
||||
gbc.weightx = 2;
|
||||
this.m_TargetList.add(new JLabel(this.m_OptimizationObjectivesWithWeights.getWeigthsLabel()), gbc);
|
||||
gbc.anchor = GridBagConstraints.WEST;
|
||||
gbc.fill = GridBagConstraints.BOTH;
|
||||
gbc.gridx = 1;
|
||||
gbc.weightx = 10;
|
||||
gbc.anchor = GridBagConstraints.WEST;
|
||||
gbc.fill = GridBagConstraints.BOTH;
|
||||
gbc.gridx = 1;
|
||||
gbc.weightx = 10;
|
||||
this.m_TargetList.add(new JLabel("Target"), gbc);
|
||||
gbc.anchor = GridBagConstraints.WEST;
|
||||
gbc.fill = GridBagConstraints.REMAINDER;
|
||||
gbc.gridx = 2;
|
||||
gbc.weightx = 1;
|
||||
gbc.anchor = GridBagConstraints.WEST;
|
||||
gbc.fill = GridBagConstraints.REMAINDER;
|
||||
gbc.gridx = 2;
|
||||
gbc.weightx = 1;
|
||||
this.m_TargetList.add(new JLabel("Remove"), gbc);
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
// the weight
|
||||
gbc.anchor = GridBagConstraints.WEST;
|
||||
gbc.fill = GridBagConstraints.BOTH;
|
||||
gbc.gridx = 0;
|
||||
gbc.weightx = 2;
|
||||
this.m_Weights[i] = new JTextField(""+weights[i]);
|
||||
gbc.anchor = GridBagConstraints.WEST;
|
||||
gbc.fill = GridBagConstraints.BOTH;
|
||||
gbc.gridx = 0;
|
||||
gbc.weightx = 2;
|
||||
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
|
||||
gbc.anchor = GridBagConstraints.WEST;
|
||||
gbc.fill = GridBagConstraints.BOTH;
|
||||
gbc.gridx = 1;
|
||||
gbc.weightx = 10;
|
||||
gbc.anchor = GridBagConstraints.WEST;
|
||||
gbc.fill = GridBagConstraints.BOTH;
|
||||
gbc.gridx = 1;
|
||||
gbc.weightx = 10;
|
||||
this.m_Targets[i] = this.m_Editors[i].m_View;
|
||||
this.m_TargetList.add(this.m_Targets[i], gbc);
|
||||
// The delete button
|
||||
gbc.anchor = GridBagConstraints.WEST;
|
||||
gbc.fill = GridBagConstraints.REMAINDER;
|
||||
gbc.gridx = 2;
|
||||
gbc.weightx = 1;
|
||||
gbc.anchor = GridBagConstraints.WEST;
|
||||
gbc.fill = GridBagConstraints.REMAINDER;
|
||||
gbc.gridx = 2;
|
||||
gbc.weightx = 1;
|
||||
bytes = loader.getBytesFromResourceLocation("images/Sub24.gif", true);
|
||||
this.m_Delete[i] = new JButton("", new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes)));
|
||||
this.m_Delete[i].addActionListener(deleteTarget);
|
||||
@@ -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++) {
|
||||
@@ -244,11 +256,11 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
||||
}
|
||||
InterfaceOptimizationObjective[] list = m_OptimizationObjectivesWithWeights.getSelectedTargets();
|
||||
l--;
|
||||
newEdit[l] = new GeneralGOEProperty();
|
||||
newEdit[l].m_Name = list[l].getName();
|
||||
newEdit[l] = new GeneralGOEProperty();
|
||||
newEdit[l].m_Name = list[l].getName();
|
||||
try {
|
||||
newEdit[l].m_Value = list[l];
|
||||
newEdit[l].m_Editor = PropertyEditorProvider.findEditor(newEdit[l].m_Value.getClass());
|
||||
newEdit[l].m_Value = list[l];
|
||||
newEdit[l].m_Editor = PropertyEditorProvider.findEditor(newEdit[l].m_Value.getClass());
|
||||
if (newEdit[l].m_Editor == null) {
|
||||
newEdit[l].m_Editor = PropertyEditorProvider.findEditor(InterfaceOptimizationObjective.class);
|
||||
}
|
||||
@@ -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,19 +323,21 @@ 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) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent event) {
|
||||
double[] newW = m_OptimizationObjectivesWithWeights.getWeights();
|
||||
double[] newW = m_OptimizationObjectivesWithWeights.getWeights();
|
||||
|
||||
for (int i = 0; i < newW.length; i++) {
|
||||
try {
|
||||
@@ -334,10 +349,11 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
||||
}
|
||||
|
||||
m_OptimizationObjectivesWithWeights.setWeights(newW);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/** 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,20 +457,24 @@ 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.
|
||||
* @return true
|
||||
*/
|
||||
/**
|
||||
* Returns true because we do support a custom editor.
|
||||
*
|
||||
* @return true
|
||||
*/
|
||||
@Override
|
||||
public boolean supportsCustomEditor() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Returns the array editing component.
|
||||
* @return a value of type 'java.awt.Component'
|
||||
*/
|
||||
/**
|
||||
* Returns the array editing component.
|
||||
*
|
||||
* @return a value of type 'java.awt.Component'
|
||||
*/
|
||||
@Override
|
||||
public Component getCustomEditor() {
|
||||
if (this.m_Editor == null) {
|
||||
@@ -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,39 +492,44 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
||||
this.updateEditor();
|
||||
}
|
||||
|
||||
/********************************* java.beans.PropertyChangeListener *************************/
|
||||
/**
|
||||
* ****************************** java.beans.PropertyChangeListener ************************
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) {
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.addPropertyChangeListener(l);
|
||||
m_Support.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) {
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
}
|
||||
/** This will wait for the GenericObjectEditor to finish
|
||||
|
||||
/**
|
||||
* This will wait for the GenericObjectEditor to finish
|
||||
* editing an object.
|
||||
*
|
||||
* @param evt
|
||||
*/
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
Object newVal = evt.getNewValue();
|
||||
Object oldVal = evt.getOldValue();
|
||||
InterfaceOptimizationObjective[] list = this.m_OptimizationObjectivesWithWeights.getSelectedTargets();
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
if (oldVal.equals(list[i])) {
|
||||
list[i] = (InterfaceOptimizationObjective)newVal;
|
||||
this.m_Editors[i].m_Name = list[i].getName();
|
||||
list[i] = (InterfaceOptimizationObjective) newVal;
|
||||
this.m_Editors[i].m_Name = list[i].getName();
|
||||
try {
|
||||
this.m_Editors[i].m_Value = list[i];
|
||||
this.m_Editors[i].m_Editor = PropertyEditorProvider.findEditor(this.m_Editors[i].m_Value.getClass());
|
||||
this.m_Editors[i].m_Value = list[i];
|
||||
this.m_Editors[i].m_Editor = PropertyEditorProvider.findEditor(this.m_Editors[i].m_Value.getClass());
|
||||
if (this.m_Editors[i].m_Editor == null) {
|
||||
this.m_Editors[i].m_Editor = PropertyEditorProvider.findEditor(InterfaceOptimizationObjective.class);
|
||||
}
|
||||
|
||||
@@ -18,34 +18,43 @@ import javax.swing.*;
|
||||
*/
|
||||
public class GenericWeigthedLPTchebycheffEditor extends JPanel implements PropertyEditor {
|
||||
|
||||
/** Handles property change notification */
|
||||
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||
/** 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*/
|
||||
/**
|
||||
* Handles property change notification
|
||||
*/
|
||||
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
private PropertyWeightedLPTchebycheff m_WLPT;
|
||||
|
||||
/** The gaphix stuff */
|
||||
private JPanel m_CustomEditor, m_DataPanel, m_ButtonPanel, m_TargetPanel;
|
||||
private JTextField[] m_IdealTextField, m_WeightTextField;
|
||||
private JTextField m_PValue;
|
||||
private JButton m_OKButton;
|
||||
/**
|
||||
* The gaphix stuff
|
||||
*/
|
||||
private JPanel m_CustomEditor, m_DataPanel, m_ButtonPanel, m_TargetPanel;
|
||||
private JTextField[] m_IdealTextField, m_WeightTextField;
|
||||
private JTextField m_PValue;
|
||||
private JButton m_OKButton;
|
||||
|
||||
public GenericWeigthedLPTchebycheffEditor() {
|
||||
// compiled code
|
||||
}
|
||||
|
||||
/** This method will init the CustomEditor Panel
|
||||
/**
|
||||
* This method will init the CustomEditor Panel
|
||||
*/
|
||||
private void initCustomEditor() {
|
||||
this.m_CustomEditor = new JPanel();
|
||||
this.m_CustomEditor = new JPanel();
|
||||
this.m_CustomEditor.setLayout(new BorderLayout());
|
||||
|
||||
// target panel
|
||||
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);
|
||||
@@ -57,58 +66,62 @@ public class GenericWeigthedLPTchebycheffEditor extends JPanel implements Proper
|
||||
|
||||
// init button panel
|
||||
this.m_ButtonPanel = new JPanel();
|
||||
this.m_OKButton = new JButton("OK");
|
||||
this.m_OKButton = new JButton("OK");
|
||||
this.m_OKButton.setEnabled(true);
|
||||
this.m_OKButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
//m_Backup = copyObject(m_Object);
|
||||
if ((m_CustomEditor.getTopLevelAncestor() != null) && (m_CustomEditor.getTopLevelAncestor() instanceof Window)) {
|
||||
Window w = (Window) m_CustomEditor.getTopLevelAncestor();
|
||||
w.dispose();
|
||||
}
|
||||
}
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
//m_Backup = copyObject(m_Object);
|
||||
if ((m_CustomEditor.getTopLevelAncestor() != null) && (m_CustomEditor.getTopLevelAncestor() instanceof Window)) {
|
||||
Window w = (Window) m_CustomEditor.getTopLevelAncestor();
|
||||
w.dispose();
|
||||
}
|
||||
}
|
||||
});
|
||||
this.m_ButtonPanel.add(this.m_OKButton);
|
||||
this.m_CustomEditor.add(this.m_ButtonPanel, BorderLayout.SOUTH);
|
||||
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) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent event) {
|
||||
try {
|
||||
try {
|
||||
int d = new Integer(m_PValue.getText()).intValue();
|
||||
m_WLPT.m_P = d;
|
||||
} catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/** 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) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent event) {
|
||||
double[] tmpT = m_WLPT.m_IdealValue;
|
||||
double[] tmpP = m_WLPT.m_Weights;
|
||||
double[] tmpT = m_WLPT.m_IdealValue;
|
||||
double[] tmpP = m_WLPT.m_Weights;
|
||||
|
||||
for (int i = 0; i < tmpT.length; i++) {
|
||||
|
||||
@@ -128,12 +141,13 @@ public class GenericWeigthedLPTchebycheffEditor extends JPanel implements Proper
|
||||
}
|
||||
}
|
||||
|
||||
m_WLPT.m_IdealValue = tmpT;
|
||||
m_WLPT.m_Weights = tmpP;
|
||||
}
|
||||
m_WLPT.m_IdealValue = tmpT;
|
||||
m_WLPT.m_Weights = tmpP;
|
||||
}
|
||||
};
|
||||
|
||||
/** 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;
|
||||
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] = new JTextField();
|
||||
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] = new JTextField();
|
||||
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
|
||||
@@ -223,35 +242,41 @@ public class GenericWeigthedLPTchebycheffEditor extends JPanel implements Proper
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) {
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.addPropertyChangeListener(l);
|
||||
m_Support.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) {
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
}
|
||||
|
||||
/** This is used to hook an action listener to the ok button
|
||||
/**
|
||||
* This is used to hook an action listener to the ok button
|
||||
*
|
||||
* @param a The action listener.
|
||||
*/
|
||||
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,20 +295,24 @@ 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.
|
||||
* @return true
|
||||
*/
|
||||
/**
|
||||
* Returns true because we do support a custom editor.
|
||||
*
|
||||
* @return true
|
||||
*/
|
||||
@Override
|
||||
public boolean supportsCustomEditor() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Returns the array editing component.
|
||||
* @return a value of type 'java.awt.Component'
|
||||
*/
|
||||
/**
|
||||
* Returns the array editing component.
|
||||
*
|
||||
* @return a value of type 'java.awt.Component'
|
||||
*/
|
||||
@Override
|
||||
public Component getCustomEditor() {
|
||||
if (this.m_CustomEditor == null) {
|
||||
|
||||
@@ -12,80 +12,101 @@ import java.beans.*;
|
||||
* <p>Description: </p>
|
||||
* <p>Copyright: Copyright (c) 2003</p>
|
||||
* <p>Company: </p>
|
||||
*
|
||||
* @author not attributable
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class MultiLineStringEditor implements PropertyEditor {
|
||||
protected MultiLineString value; // The value we will be editing.
|
||||
protected MultiLineString value; // The value we will be editing.
|
||||
|
||||
@Override
|
||||
public void setValue(Object o) { value=(MultiLineString) o;}
|
||||
@Override
|
||||
public Object getValue() { return value; }
|
||||
@Override
|
||||
public void setAsText(String s) { value.setString(s); }
|
||||
@Override
|
||||
public String getAsText() { return value.getString(); }
|
||||
@Override
|
||||
public String[] getTags() { return null; } // not enumerated; no tags
|
||||
public void setValue(Object o) {
|
||||
value = (MultiLineString) o;
|
||||
}
|
||||
|
||||
// Say that we allow custom editing.
|
||||
@Override
|
||||
public boolean supportsCustomEditor() { return true; }
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
// 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
|
||||
// text area to update the value as the user types and to fire the
|
||||
// property change events that property editors are required to fire.
|
||||
@Override
|
||||
public Component getCustomEditor() {
|
||||
final TextArea t = new TextArea(value.string);
|
||||
t.setSize(300, 150); // TextArea doesn't have a preferred size, so set one
|
||||
t.addTextListener(new TextListener() {
|
||||
public void setAsText(String s) {
|
||||
value.setString(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAsText() {
|
||||
return value.getString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTags() {
|
||||
return null;
|
||||
} // not enumerated; no tags
|
||||
|
||||
// Say that we allow custom editing.
|
||||
@Override
|
||||
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
|
||||
// text area to update the value as the user types and to fire the
|
||||
// property change events that property editors are required to fire.
|
||||
@Override
|
||||
public Component getCustomEditor() {
|
||||
final TextArea t = new TextArea(value.string);
|
||||
t.setSize(300, 150); // TextArea doesn't have a preferred size, so set one
|
||||
t.addTextListener(new TextListener() {
|
||||
@Override
|
||||
public void textValueChanged(TextEvent e) {
|
||||
value.setString(t.getText());
|
||||
listeners.firePropertyChange(null, null, null);
|
||||
}
|
||||
});
|
||||
return t;
|
||||
}
|
||||
public void textValueChanged(TextEvent e) {
|
||||
value.setString(t.getText());
|
||||
listeners.firePropertyChange(null, null, null);
|
||||
}
|
||||
});
|
||||
return t;
|
||||
}
|
||||
|
||||
// Visual display of the value, for use with the custom editor.
|
||||
// Just print some instructions and hope they fit in the in the box.
|
||||
// This could be more sophisticated.
|
||||
// Visual display of the value, for use with the custom editor.
|
||||
// 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);
|
||||
}
|
||||
public void paintValue(Graphics g, Rectangle r) {
|
||||
g.setClip(r);
|
||||
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.
|
||||
// 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.
|
||||
protected PropertyChangeSupport listeners = new PropertyChangeSupport(this);
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
if (listeners == null) {
|
||||
listeners = new PropertyChangeSupport(this);
|
||||
}
|
||||
listeners.addPropertyChangeListener(l);
|
||||
}
|
||||
// This code uses the PropertyChangeSupport class to maintain a list of
|
||||
// listeners interested in the edits we make to the value.
|
||||
protected PropertyChangeSupport listeners = new PropertyChangeSupport(this);
|
||||
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
if (listeners == null) {
|
||||
listeners = new PropertyChangeSupport(this);
|
||||
}
|
||||
listeners.removePropertyChangeListener(l);
|
||||
}
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
if (listeners == null) {
|
||||
listeners = new PropertyChangeSupport(this);
|
||||
}
|
||||
listeners.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
if (listeners == null) {
|
||||
listeners = new PropertyChangeSupport(this);
|
||||
}
|
||||
listeners.removePropertyChangeListener(l);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,144 +9,146 @@ 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.*;
|
||||
|
||||
public class StatisticsEditor implements PropertyEditor {
|
||||
|
||||
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||
private PropertySheetPanelStat m_StatPanel;
|
||||
private JScrollPane m_ScrollPane;
|
||||
private JPanel m_Panel;
|
||||
private GenericStatistics m_Value;
|
||||
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||
private PropertySheetPanelStat m_StatPanel;
|
||||
private JScrollPane m_ScrollPane;
|
||||
private JPanel m_Panel;
|
||||
private GenericStatistics m_Value;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public StatisticsEditor() {
|
||||
super();
|
||||
m_StatPanel = new PropertySheetPanelStat();
|
||||
m_StatPanel.addPropertyChangeListener(
|
||||
new PropertyChangeListener() {
|
||||
super();
|
||||
m_StatPanel = new PropertySheetPanelStat();
|
||||
m_StatPanel.addPropertyChangeListener(
|
||||
new PropertyChangeListener() {
|
||||
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
m_Support.firePropertyChange("", null, null);
|
||||
}
|
||||
});
|
||||
m_ScrollPane = new JScrollPane(m_StatPanel);
|
||||
m_Panel = new JPanel();
|
||||
m_Panel.setLayout(new BorderLayout());
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
m_Support.firePropertyChange("", null, null);
|
||||
}
|
||||
});
|
||||
m_ScrollPane = new JScrollPane(m_StatPanel);
|
||||
m_Panel = new JPanel();
|
||||
m_Panel.setLayout(new BorderLayout());
|
||||
|
||||
m_Panel.add(m_ScrollPane, BorderLayout.CENTER);
|
||||
m_Panel.add(m_ScrollPane, BorderLayout.CENTER);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void setValue(Object value) {
|
||||
if (value instanceof GenericStatistics) {
|
||||
if (value instanceof GenericStatistics) {
|
||||
m_Value = (GenericStatistics) value;
|
||||
m_StatPanel.setTarget(m_Value.getPropertyNames(), m_Value.getState());
|
||||
}
|
||||
m_Support.firePropertyChange("", null, null);
|
||||
}
|
||||
m_Support.firePropertyChange("", null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public Object getValue() {
|
||||
System.out.println("getValue !!!!!!!!!!!!");
|
||||
m_Value.setState(m_StatPanel.getState());
|
||||
return m_Value;
|
||||
}
|
||||
System.out.println("getValue !!!!!!!!!!!!");
|
||||
m_Value.setState(m_StatPanel.getState());
|
||||
return m_Value;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public String getJavaInitializationString() {
|
||||
return "null";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public boolean isPaintable() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void paintValue(Graphics gfx, Rectangle box) {
|
||||
FontMetrics fm = gfx.getFontMetrics();
|
||||
FontMetrics fm = gfx.getFontMetrics();
|
||||
int vpad = (box.height - fm.getAscent()) / 2;
|
||||
//String rep = EVAHELP.cutClassName(m_ElementClass.getName());
|
||||
gfx.drawString("StatisticeEditor", 2, fm.getHeight() + vpad - 3);
|
||||
}
|
||||
//String rep = EVAHELP.cutClassName(m_ElementClass.getName());
|
||||
gfx.drawString("StatisticeEditor", 2, fm.getHeight() + vpad - 3);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public String getAsText() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
throw new IllegalArgumentException(text);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public String[] getTags() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public boolean supportsCustomEditor() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public Component getCustomEditor() {
|
||||
return m_Panel;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.addPropertyChangeListener(l);
|
||||
}
|
||||
m_Support.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
}
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,83 +3,83 @@ package eva2.gui.editor;
|
||||
import eva2.tools.StringSelection;
|
||||
|
||||
public class StringSelectionEditor extends AbstractListSelectionEditor {
|
||||
StringSelection strs;
|
||||
|
||||
public StringSelectionEditor() {
|
||||
strs = new StringSelection(new String[]{}, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean actionOnSelect() {
|
||||
for (int i = 0; i < this.m_BlackCheck.length; i++) {
|
||||
strs.setSelected(i, this.m_BlackCheck[i].isSelected());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
StringSelection strs;
|
||||
|
||||
@Override
|
||||
protected int getElementCount() {
|
||||
return strs.getLength();
|
||||
}
|
||||
public StringSelectionEditor() {
|
||||
strs = new StringSelection(new String[]{}, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getElementName(int i) {
|
||||
return strs.getElement(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getElementToolTip(int i) {
|
||||
return strs.getElementInfo(i);
|
||||
}
|
||||
@Override
|
||||
protected boolean actionOnSelect() {
|
||||
for (int i = 0; i < this.m_BlackCheck.length; i++) {
|
||||
strs.setSelected(i, this.m_BlackCheck[i].isSelected());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
return strs;
|
||||
}
|
||||
@Override
|
||||
protected int getElementCount() {
|
||||
return strs.getLength();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isElementSelected(int i) {
|
||||
return strs.isSelected(i);
|
||||
}
|
||||
@Override
|
||||
protected String getElementName(int i) {
|
||||
return strs.getElement(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setObject(Object o) {
|
||||
@Override
|
||||
protected String getElementToolTip(int i) {
|
||||
return strs.getElementInfo(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
return strs;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isElementSelected(int i) {
|
||||
return strs.isSelected(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setObject(Object o) {
|
||||
if (o instanceof StringSelection) {
|
||||
strs = (StringSelection) o;
|
||||
// m_AreaObject.addPropertyChangeListener(this);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "StringSelection";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAsText() {
|
||||
StringBuffer sbuf = new StringBuffer("{");
|
||||
boolean first = true;
|
||||
for (int i = 0; i < getElementCount(); i++) {
|
||||
if (isElementSelected(i)) {
|
||||
if (!first) {
|
||||
sbuf.append(", ");
|
||||
}
|
||||
sbuf.append(getElementName(i));
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
sbuf.append("}");
|
||||
return sbuf.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "StringSelection";
|
||||
}
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
for (int i = 0; i < getElementCount(); i++) {
|
||||
strs.setSelected(i, text.contains(getElementName(i)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAsText() {
|
||||
StringBuffer sbuf = new StringBuffer("{");
|
||||
boolean first = true;
|
||||
for (int i=0; i<getElementCount(); i++) {
|
||||
if (isElementSelected(i)) {
|
||||
if (!first) {
|
||||
sbuf.append(", ");
|
||||
}
|
||||
sbuf.append(getElementName(i));
|
||||
first=false;
|
||||
}
|
||||
}
|
||||
sbuf.append("}");
|
||||
return sbuf.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
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,123 +23,125 @@ import java.awt.event.WindowEvent;
|
||||
import java.beans.PropertyEditorManager;
|
||||
import java.beans.PropertyEditorSupport;
|
||||
import javax.swing.JFrame;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class TagEditor extends PropertyEditorSupport {
|
||||
/**
|
||||
* Returns a description of the property value as java source.
|
||||
*
|
||||
* @return a value of type 'String'
|
||||
*/
|
||||
/**
|
||||
* Returns a description of the property value as java source.
|
||||
*
|
||||
* @return a value of type 'String'
|
||||
*/
|
||||
@Override
|
||||
public String getJavaInitializationString() {
|
||||
public String getJavaInitializationString() {
|
||||
|
||||
SelectedTag s = (SelectedTag)getValue();
|
||||
Tag [] tags = s.getTags();
|
||||
String result = "new SelectedTag("
|
||||
+ s.getSelectedTag().getID()
|
||||
+ ", {\n";
|
||||
for (int i = 0; i < tags.length; i++) {
|
||||
result += "new Tag(" + tags[i].getID()
|
||||
+ ",\"" + tags[i].getString()
|
||||
+ "\")";
|
||||
if (i < tags.length - 1) {
|
||||
result += ',';
|
||||
}
|
||||
result += '\n';
|
||||
SelectedTag s = (SelectedTag) getValue();
|
||||
Tag[] tags = s.getTags();
|
||||
String result = "new SelectedTag("
|
||||
+ s.getSelectedTag().getID()
|
||||
+ ", {\n";
|
||||
for (int i = 0; i < tags.length; i++) {
|
||||
result += "new Tag(" + tags[i].getID()
|
||||
+ ",\"" + tags[i].getString()
|
||||
+ "\")";
|
||||
if (i < tags.length - 1) {
|
||||
result += ',';
|
||||
}
|
||||
result += '\n';
|
||||
}
|
||||
return result + "})";
|
||||
}
|
||||
return result + "})";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current value as text.
|
||||
*
|
||||
* @return a value of type 'String'
|
||||
*/
|
||||
/**
|
||||
* Gets the current value as text.
|
||||
*
|
||||
* @return a value of type 'String'
|
||||
*/
|
||||
@Override
|
||||
public String getAsText() {
|
||||
SelectedTag s = (SelectedTag)getValue();
|
||||
return s.getSelectedTag().getString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current property value as text.
|
||||
*
|
||||
* @param text the text of the selected tag.
|
||||
* @exception 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();
|
||||
try {
|
||||
for (int i = 0; i < tags.length; i++) {
|
||||
if (text.equals(tags[i].getString())) {
|
||||
setValue(new SelectedTag(tags[i].getID(), tags));
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
throw new java.lang.IllegalArgumentException(text);
|
||||
public String getAsText() {
|
||||
SelectedTag s = (SelectedTag) getValue();
|
||||
return s.getSelectedTag().getString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of tags that can be selected from.
|
||||
*
|
||||
* @return an array of string tags.
|
||||
*/
|
||||
/**
|
||||
* Sets the current property value as text.
|
||||
*
|
||||
* @param text the text of the selected tag.
|
||||
* @throws java.lang.IllegalArgumentException
|
||||
* if an error occurs
|
||||
*/
|
||||
@Override
|
||||
public String[] getTags() {
|
||||
|
||||
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
|
||||
();
|
||||
public void setAsText(String text) throws java.lang.IllegalArgumentException {
|
||||
SelectedTag s = (SelectedTag) getValue();
|
||||
Tag[] tags = s.getTags();
|
||||
try {
|
||||
for (int i = 0; i < tags.length; i++) {
|
||||
if (text.equals(tags[i].getString())) {
|
||||
setValue(new SelectedTag(tags[i].getID(), tags));
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
throw new java.lang.IllegalArgumentException(text);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests out the selectedtag editor from the command line.
|
||||
*
|
||||
* @param args ignored
|
||||
*/
|
||||
public static void main(String [] args) {
|
||||
try {
|
||||
PropertyEditorManager.registerEditor(SelectedTag.class,TagEditor.class);
|
||||
Tag [] tags = {
|
||||
new Tag(0, "First option"),
|
||||
new Tag(1, "Second option"),
|
||||
new Tag(2, "Third option"),
|
||||
new Tag(3, "Fourth option"),
|
||||
new Tag(4, "Fifth option"),
|
||||
};
|
||||
SelectedTag initial = new SelectedTag(1, tags);
|
||||
TagEditor ce = new TagEditor();
|
||||
ce.setValue(initial);
|
||||
PropertyValueSelector ps = new PropertyValueSelector(ce);
|
||||
JFrame f = new JFrame();
|
||||
BasicResourceLoader loader = BasicResourceLoader.instance();
|
||||
byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation, true);
|
||||
f.setIconImage(Toolkit.getDefaultToolkit().createImage(bytes));
|
||||
f.addWindowListener(new WindowAdapter() {
|
||||
/**
|
||||
* Gets the list of tags that can be selected from.
|
||||
*
|
||||
* @return an array of string tags.
|
||||
*/
|
||||
@Override
|
||||
public String[] getTags() {
|
||||
|
||||
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
|
||||
();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests out the selectedtag editor from the command line.
|
||||
*
|
||||
* @param args ignored
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
PropertyEditorManager.registerEditor(SelectedTag.class, TagEditor.class);
|
||||
Tag[] tags = {
|
||||
new Tag(0, "First option"),
|
||||
new Tag(1, "Second option"),
|
||||
new Tag(2, "Third option"),
|
||||
new Tag(3, "Fourth option"),
|
||||
new Tag(4, "Fifth option"),
|
||||
};
|
||||
SelectedTag initial = new SelectedTag(1, tags);
|
||||
TagEditor ce = new TagEditor();
|
||||
ce.setValue(initial);
|
||||
PropertyValueSelector ps = new PropertyValueSelector(ce);
|
||||
JFrame f = new JFrame();
|
||||
BasicResourceLoader loader = BasicResourceLoader.instance();
|
||||
byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation, true);
|
||||
f.setIconImage(Toolkit.getDefaultToolkit().createImage(bytes));
|
||||
f.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
f.getContentPane().setLayout(new BorderLayout());
|
||||
f.getContentPane().add(ps, BorderLayout.CENTER);
|
||||
f.pack();
|
||||
f.setVisible(true);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
System.err.println(ex.getMessage());
|
||||
public void windowClosing(WindowEvent e) {
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
f.getContentPane().setLayout(new BorderLayout());
|
||||
f.getContentPane().add(ps, BorderLayout.CENTER);
|
||||
f.pack();
|
||||
f.setVisible(true);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
System.err.println(ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
"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,17 +91,14 @@ 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");
|
||||
"The number of x-values has to be the same than the number of y-values");
|
||||
}
|
||||
|
||||
xMI = x_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));
|
||||
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) {
|
||||
g.drawLine(p1.x, p1.y, p2.x, p2.y);
|
||||
}
|
||||
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,66 +283,50 @@ 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.");
|
||||
"The rectangle lies not in the currently painted rectangle.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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,30 +393,24 @@ 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());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* method sets the stroke of the line
|
||||
* if the points were not connected, they now will be connected
|
||||
* method sets the stroke of the line
|
||||
* if the points were not connected, they now will be connected
|
||||
*
|
||||
* @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) + ")");
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public class DataViewer implements DataViewerInterface {
|
||||
}
|
||||
DataViewerInterface ret = null;
|
||||
try {
|
||||
if (!viewContainer.containsName(graphWindowName)) {
|
||||
if (!viewContainer.containsName(graphWindowName)) {
|
||||
ret = new DataViewer(graphWindowName, true);
|
||||
viewContainer.add(ret);
|
||||
} else {
|
||||
@@ -89,7 +89,8 @@ class ViewContainer extends ArrayList {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ViewContainer() { }
|
||||
public ViewContainer() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -16,6 +16,7 @@ import eva2.gui.plot.Graph;
|
||||
* IMPORTS
|
||||
*==========================================================================*/
|
||||
public interface DataViewerInterface {
|
||||
public Graph getNewGraph(String InfoString);
|
||||
public void init();
|
||||
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;
|
||||
@@ -205,11 +207,11 @@ public class FunctionArea extends DArea implements Serializable {
|
||||
+ " graph tool tips";
|
||||
addMenuItem(graphPopupMenu, togGTTName,
|
||||
new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent ee) {
|
||||
setShowGraphToolTips(!isShowGraphToolTips());
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent ee) {
|
||||
setShowGraphToolTips(!isShowGraphToolTips());
|
||||
}
|
||||
});
|
||||
|
||||
String togLName = (isShowLegend() ? "Hide" : "Show")
|
||||
+ " legend";
|
||||
@@ -230,11 +232,11 @@ public class FunctionArea extends DArea implements Serializable {
|
||||
if (FunctionArea.this.pointSetContainer.size() > 0) {
|
||||
addMenuItem(graphPopupMenu, "Recolor all graphs",
|
||||
new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent ee) {
|
||||
recolorAllGraphsByIndex();
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent ee) {
|
||||
recolorAllGraphsByIndex();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (refPointListener != null) {
|
||||
@@ -242,16 +244,16 @@ public class FunctionArea extends DArea implements Serializable {
|
||||
addMenuItem(graphPopupMenu, "Select Reference Point:("
|
||||
+ temp.x + "/" + temp.y + ")",
|
||||
new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent ee) {
|
||||
DPoint temp = getDMeasures().getDPoint(
|
||||
xPos, yPos);
|
||||
double[] point = new double[2];
|
||||
point[0] = temp.x;
|
||||
point[1] = temp.y;
|
||||
refPointListener.refPointGiven(point);
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent ee) {
|
||||
DPoint temp = getDMeasures().getDPoint(
|
||||
xPos, yPos);
|
||||
double[] point = new double[2];
|
||||
point[0] = temp.x;
|
||||
point[1] = temp.y;
|
||||
refPointListener.refPointGiven(point);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// darn this point is an empty copy !!
|
||||
@@ -261,19 +263,19 @@ public class FunctionArea extends DArea implements Serializable {
|
||||
addMenuItem(graphPopupMenu, "Nearest point: ("
|
||||
+ point.x + "/" + point.y + ")",
|
||||
new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent ee) {
|
||||
}
|
||||
}, false);
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent ee) {
|
||||
}
|
||||
}, false);
|
||||
|
||||
addMenuItem(graphPopupMenu, " Remove point",
|
||||
new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent ee) {
|
||||
removePoint(FunctionArea.this.xPos,
|
||||
FunctionArea.this.yPos);
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent ee) {
|
||||
removePoint(FunctionArea.this.xPos,
|
||||
FunctionArea.this.yPos);
|
||||
}
|
||||
});
|
||||
|
||||
if (point.getIcon() instanceof InterfaceSelectablePointIcon) {
|
||||
currentPointIcon = point.getIcon();
|
||||
@@ -283,13 +285,13 @@ public class FunctionArea extends DArea implements Serializable {
|
||||
: " Select individual";
|
||||
addMenuItem(graphPopupMenu, selectTitle,
|
||||
new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(
|
||||
ActionEvent ee) {
|
||||
((InterfaceSelectablePointIcon) currentPointIcon).getSelectionListener().individualSelected(
|
||||
((InterfaceSelectablePointIcon) currentPointIcon).getEAIndividual());
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void actionPerformed(
|
||||
ActionEvent ee) {
|
||||
((InterfaceSelectablePointIcon) currentPointIcon).getSelectionListener().individualSelected(
|
||||
((InterfaceSelectablePointIcon) currentPointIcon).getEAIndividual());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,16 +299,16 @@ public class FunctionArea extends DArea implements Serializable {
|
||||
currentPointIcon = point.getIcon();
|
||||
addMenuItem(graphPopupMenu, " Show individual",
|
||||
new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(
|
||||
ActionEvent ee) {
|
||||
((InterfaceDPointWithContent) currentPointIcon).showIndividual();
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void actionPerformed(
|
||||
ActionEvent ee) {
|
||||
((InterfaceDPointWithContent) currentPointIcon).showIndividual();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
if (FunctionArea.this.pointSetContainer.size() > 0) {
|
||||
if (FunctionArea.this.pointSetContainer.size() > 0) {
|
||||
// there is at least one graph
|
||||
// The graph info element
|
||||
// int gIndex = getNearestGraphIndex(e.getX(),
|
||||
@@ -314,45 +316,45 @@ public class FunctionArea extends DArea implements Serializable {
|
||||
addMenuItem(graphPopupMenu, "Graph Info: "
|
||||
+ getGraphInfo(e.getX(), e.getY()),
|
||||
new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent ee) {
|
||||
DPoint temp = FunctionArea.this.getDMeasures().getDPoint(
|
||||
FunctionArea.this.xPos,
|
||||
FunctionArea.this.yPos);
|
||||
DPointIcon icon1 = new DPointIcon() {
|
||||
@Override
|
||||
public DBorder getDBorder() {
|
||||
return new DBorder(4, 4, 4, 4);
|
||||
}
|
||||
public void actionPerformed(ActionEvent ee) {
|
||||
DPoint temp = FunctionArea.this.getDMeasures().getDPoint(
|
||||
FunctionArea.this.xPos,
|
||||
FunctionArea.this.yPos);
|
||||
DPointIcon icon1 = new DPointIcon() {
|
||||
@Override
|
||||
public DBorder getDBorder() {
|
||||
return new DBorder(4, 4, 4, 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
g.drawLine(-2, 0, 2, 0);
|
||||
g.drawLine(0, 0, 0, 4);
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
g.drawLine(-2, 0, 2, 0);
|
||||
g.drawLine(0, 0, 0, 4);
|
||||
}
|
||||
};
|
||||
temp.setIcon(icon1);
|
||||
FunctionArea.this.addDElement(temp);
|
||||
}
|
||||
};
|
||||
temp.setIcon(icon1);
|
||||
FunctionArea.this.addDElement(temp);
|
||||
}
|
||||
}, false);
|
||||
}, false);
|
||||
|
||||
addMenuItem(graphPopupMenu, " Remove graph",
|
||||
new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent ee) {
|
||||
clearGraph(FunctionArea.this.xPos,
|
||||
FunctionArea.this.yPos);
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent ee) {
|
||||
clearGraph(FunctionArea.this.xPos,
|
||||
FunctionArea.this.yPos);
|
||||
}
|
||||
});
|
||||
|
||||
addMenuItem(graphPopupMenu, " Change graph color",
|
||||
new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent ee) {
|
||||
changeColorGraph(FunctionArea.this.xPos,
|
||||
FunctionArea.this.yPos);
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent ee) {
|
||||
changeColorGraph(FunctionArea.this.xPos,
|
||||
FunctionArea.this.yPos);
|
||||
}
|
||||
});
|
||||
}
|
||||
graphPopupMenu.show(FunctionArea.this, e.getX(), e.getY());
|
||||
}
|
||||
@@ -370,7 +372,7 @@ public class FunctionArea extends DArea implements Serializable {
|
||||
* @return
|
||||
*/
|
||||
private JMenuItem addMenuItem(JPopupMenu menu, String title,
|
||||
ActionListener aListener) {
|
||||
ActionListener aListener) {
|
||||
return addMenuItem(menu, title, aListener, true);
|
||||
}
|
||||
|
||||
@@ -385,7 +387,7 @@ public class FunctionArea extends DArea implements Serializable {
|
||||
* @return
|
||||
*/
|
||||
private JMenuItem addMenuItem(JPopupMenu menu, String title,
|
||||
ActionListener aListener, boolean enabled) {
|
||||
ActionListener aListener, boolean enabled) {
|
||||
JMenuItem item = new JMenuItem(title);
|
||||
// if (bgColor!=null) item.setForeground(bgColor);
|
||||
item.addActionListener(aListener);
|
||||
@@ -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() {
|
||||
@@ -602,7 +602,7 @@ public class FunctionArea extends DArea implements Serializable {
|
||||
* @param graphID
|
||||
*/
|
||||
public void drawIcon(DPointIcon theIcon, String label, double[] position,
|
||||
int graphID) {
|
||||
int graphID) {
|
||||
DPointSet popRep;
|
||||
popRep = new DPointSet();
|
||||
popRep.addDPoint(new DPoint(position[0], position[1]));
|
||||
@@ -623,7 +623,7 @@ public class FunctionArea extends DArea implements Serializable {
|
||||
* @param graphID
|
||||
*/
|
||||
public void drawIcon(int iconType, String label, double[] position,
|
||||
int graphID) {
|
||||
int graphID) {
|
||||
DPointIcon theIcon;
|
||||
switch (iconType) {
|
||||
case 0:
|
||||
@@ -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
|
||||
*/
|
||||
@@ -1191,7 +1178,7 @@ public class FunctionArea extends DArea implements Serializable {
|
||||
* Allows setting whether or not to paint the y-axis in logarithmic scale.
|
||||
*
|
||||
* @param log if true logarithmic scale is used, linear scale in case of
|
||||
* false.
|
||||
* false.
|
||||
*/
|
||||
public void toggleLog(boolean log) {
|
||||
if (log != log) {
|
||||
@@ -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
|
||||
*/
|
||||
@@ -84,7 +83,7 @@ public class Graph implements Serializable {
|
||||
* false if force was used and points possibly have been lost.
|
||||
*
|
||||
* @return true if the graph could be added directly or false if the graph was added by force
|
||||
* losing some data points
|
||||
* losing some data points
|
||||
* @see PlotInterface.addGraph
|
||||
*/
|
||||
public boolean addGraph(Graph x) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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;
|
||||
@@ -22,180 +23,172 @@ import javax.swing.JPanel;
|
||||
* A class representing the legend of a plot. It is created from a list of
|
||||
* GraphPointSets as used in FunctionArea. Painting is done in FunctionArea. As
|
||||
* an alternative, an own frame could be created.
|
||||
*
|
||||
*
|
||||
* @author mkron, draeger
|
||||
*
|
||||
*/
|
||||
public class GraphPointSetLegend {
|
||||
SortedSet<Pair<String, Color>> legendEntries;
|
||||
SortedSet<Pair<String, Color>> legendEntries;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author draeger
|
||||
*
|
||||
*/
|
||||
private static class PairComp implements Comparator<Pair<String, Color>> {
|
||||
/**
|
||||
* @author draeger
|
||||
*/
|
||||
private static class PairComp implements Comparator<Pair<String, Color>> {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public int compare(Pair<String, Color> o1, Pair<String, Color> o2) {
|
||||
int comp = o1.car().compareTo(o2.car());
|
||||
// Same text; let us see if the color is also identical.
|
||||
return comp == 0 ? comp = Integer.valueOf(o1.cdr().getRGB())
|
||||
.compareTo(Integer.valueOf(o2.cdr().getRGB())) : comp;
|
||||
}
|
||||
public int compare(Pair<String, Color> o1, Pair<String, Color> o2) {
|
||||
int comp = o1.car().compareTo(o2.car());
|
||||
// Same text; let us see if the color is also identical.
|
||||
return comp == 0 ? comp = Integer.valueOf(o1.cdr().getRGB())
|
||||
.compareTo(Integer.valueOf(o2.cdr().getRGB())) : comp;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static final PairComp comparator = new PairComp();
|
||||
private static final PairComp comparator = new PairComp();
|
||||
|
||||
/**
|
||||
* A constructor which may enumerate the point sets.
|
||||
*
|
||||
* @param pointSetContainer the set of point sets to be shown.
|
||||
* @param appendIndex if true, the string entries are enumerated according to the index
|
||||
*/
|
||||
public GraphPointSetLegend(List<GraphPointSet> pointSetContainer, boolean appendIndex) {
|
||||
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) {
|
||||
String entryStr;
|
||||
if (appendIndex) {
|
||||
entryStr = StringTools.expandPrefixZeros(i, pointSetContainer.size()-1) + ": " + pointset.getInfoString();
|
||||
}
|
||||
else {
|
||||
entryStr = pointset.getInfoString();
|
||||
}
|
||||
legendEntries.add(new Pair<String, Color>(entryStr,pointset.getColor()));
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* A constructor which may enumerate the point sets.
|
||||
*
|
||||
* @param pointSetContainer the set of point sets to be shown.
|
||||
* @param appendIndex if true, the string entries are enumerated according to the index
|
||||
*/
|
||||
public GraphPointSetLegend(List<GraphPointSet> pointSetContainer, boolean appendIndex) {
|
||||
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) {
|
||||
String entryStr;
|
||||
if (appendIndex) {
|
||||
entryStr = StringTools.expandPrefixZeros(i, pointSetContainer.size() - 1) + ": " + pointset.getInfoString();
|
||||
} else {
|
||||
entryStr = pointset.getInfoString();
|
||||
}
|
||||
legendEntries.add(new Pair<String, Color>(entryStr, pointset.getColor()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A constructor without enumeration.
|
||||
*
|
||||
* @param pointSetContainer the set of point sets to be shown.
|
||||
*/
|
||||
public GraphPointSetLegend(List<GraphPointSet> pointSetContainer) {
|
||||
this(pointSetContainer, false);
|
||||
}
|
||||
/**
|
||||
* A constructor without enumeration.
|
||||
*
|
||||
* @param pointSetContainer the set of point sets to be shown.
|
||||
*/
|
||||
public GraphPointSetLegend(List<GraphPointSet> pointSetContainer) {
|
||||
this(pointSetContainer, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the legend labels to a container.
|
||||
*
|
||||
* @param comp
|
||||
*/
|
||||
public void addToContainer(JComponent comp) {
|
||||
for (Pair<String, Color> legendEntry : legendEntries) {
|
||||
JLabel label = new JLabel(legendEntry.head);
|
||||
label.setForeground(legendEntry.tail);
|
||||
comp.add(label);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Add the legend labels to a container.
|
||||
*
|
||||
* @param comp
|
||||
*/
|
||||
public void addToContainer(JComponent comp) {
|
||||
for (Pair<String, Color> legendEntry : legendEntries) {
|
||||
JLabel label = new JLabel(legendEntry.head);
|
||||
label.setForeground(legendEntry.tail);
|
||||
comp.add(label);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param bgCol
|
||||
* @param pointSetContainer
|
||||
* @return
|
||||
*/
|
||||
public static JPanel makeLegendPanel(Color bgCol,
|
||||
ArrayList<GraphPointSet> pointSetContainer) {
|
||||
JPanel pan = new JPanel();
|
||||
pan.setBackground(bgCol);
|
||||
pan.setLayout(new BoxLayout(pan, BoxLayout.Y_AXIS));
|
||||
GraphPointSetLegend lBox = new GraphPointSetLegend(pointSetContainer);
|
||||
lBox.addToContainer(pan);
|
||||
return pan;
|
||||
}
|
||||
/**
|
||||
* @param bgCol
|
||||
* @param pointSetContainer
|
||||
* @return
|
||||
*/
|
||||
public static JPanel makeLegendPanel(Color bgCol,
|
||||
ArrayList<GraphPointSet> pointSetContainer) {
|
||||
JPanel pan = new JPanel();
|
||||
pan.setBackground(bgCol);
|
||||
pan.setLayout(new BoxLayout(pan, BoxLayout.Y_AXIS));
|
||||
GraphPointSetLegend lBox = new GraphPointSetLegend(pointSetContainer);
|
||||
lBox.addToContainer(pan);
|
||||
return pan;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param bgCol
|
||||
* @param pointSetContainer
|
||||
* @return
|
||||
*/
|
||||
public static JFrame makeLegendFrame(Color bgCol,
|
||||
ArrayList<GraphPointSet> pointSetContainer) {
|
||||
JFrame frame = new JFrame("Legend");
|
||||
// LegendBox lBox = new LegendBox(bgCol, pointSetContainer);
|
||||
frame.add(makeLegendPanel(bgCol, pointSetContainer));
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
return frame;
|
||||
}
|
||||
/**
|
||||
* @param bgCol
|
||||
* @param pointSetContainer
|
||||
* @return
|
||||
*/
|
||||
public static JFrame makeLegendFrame(Color bgCol,
|
||||
ArrayList<GraphPointSet> pointSetContainer) {
|
||||
JFrame frame = new JFrame("Legend");
|
||||
// LegendBox lBox = new LegendBox(bgCol, pointSetContainer);
|
||||
frame.add(makeLegendPanel(bgCol, pointSetContainer));
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
return frame;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
public void paintIn(JComponent component) {
|
||||
Graphics g = component.getGraphics();
|
||||
FontMetrics fm = g.getFontMetrics();
|
||||
int yOffs = 5 + fm.getHeight();
|
||||
int xOffs = 0;
|
||||
Color origCol = g.getColor();
|
||||
/**
|
||||
* @param component
|
||||
*/
|
||||
public void paintIn(JComponent component) {
|
||||
Graphics g = component.getGraphics();
|
||||
FontMetrics fm = g.getFontMetrics();
|
||||
int yOffs = 5 + fm.getHeight();
|
||||
int xOffs = 0;
|
||||
Color origCol = g.getColor();
|
||||
|
||||
for (Pair<String, Color> legendEntry : legendEntries) {
|
||||
g.setColor(legendEntry.tail);
|
||||
Rectangle2D rect = fm.getStringBounds(legendEntry.head, g);
|
||||
xOffs = (int) (component.getWidth() - rect.getWidth() - 5);
|
||||
g.drawString(legendEntry.head, xOffs, yOffs);
|
||||
yOffs += (5 + rect.getHeight());
|
||||
}
|
||||
g.setColor(origCol);
|
||||
}
|
||||
for (Pair<String, Color> legendEntry : legendEntries) {
|
||||
g.setColor(legendEntry.tail);
|
||||
Rectangle2D rect = fm.getStringBounds(legendEntry.head, g);
|
||||
xOffs = (int) (component.getWidth() - rect.getWidth() - 5);
|
||||
g.drawString(legendEntry.head, xOffs, yOffs);
|
||||
yOffs += (5 + rect.getHeight());
|
||||
}
|
||||
g.setColor(origCol);
|
||||
}
|
||||
|
||||
// public void paintIn(Graphics g, Dimension dim) {
|
||||
// paintIn(g, dim.width);
|
||||
// }
|
||||
//
|
||||
// public void paintIn(Graphics g, Rectangle rect) {
|
||||
// paintIn(g, rect.width);
|
||||
// }
|
||||
//
|
||||
// public void paintIn(Graphics g, DRectangle rect) {
|
||||
// paintIn(g, (int)rect.width);
|
||||
// }
|
||||
// public void paintIn(Graphics g, Dimension dim) {
|
||||
// paintIn(g, dim.width);
|
||||
// }
|
||||
//
|
||||
// public void paintIn(Graphics g, Rectangle rect) {
|
||||
// paintIn(g, rect.width);
|
||||
// }
|
||||
//
|
||||
// public void paintIn(Graphics g, DRectangle rect) {
|
||||
// paintIn(g, (int)rect.width);
|
||||
// }
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void paintIn(Graphics g, SlimRect rect) {
|
||||
paintIn(g, (int) rect.getX(), (int) rect.getY(), (int) rect.getX()
|
||||
+ (int) rect.getWidth());
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void paintIn(Graphics g, SlimRect rect) {
|
||||
paintIn(g, (int) rect.getX(), (int) rect.getY(), (int) rect.getX()
|
||||
+ (int) rect.getWidth());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param g
|
||||
* @param x
|
||||
* @param y
|
||||
* @param maxX
|
||||
*/
|
||||
private void paintIn(Graphics g, int x, int y, int maxX) {
|
||||
FontMetrics fm = g.getFontMetrics();
|
||||
// System.out.println("In LegendBox.paintIn!");
|
||||
int yOffs = 5 + y + fm.getHeight();
|
||||
int xOffs = x;
|
||||
Color origCol = g.getColor();
|
||||
// avoid that an entry with identical label and color occurs multiple
|
||||
// times.
|
||||
for (Pair<String, Color> legendEntry : legendEntries) {
|
||||
// System.out.println(legendEntries[i].toString() + "\tcontaines: "
|
||||
// + set.contains(legendEntries[i]));
|
||||
g.setColor(legendEntry.tail);
|
||||
Rectangle2D stringBounds = fm.getStringBounds(legendEntry.head, g);
|
||||
xOffs = (int) (maxX - stringBounds.getWidth() - 5);
|
||||
g.drawString(legendEntry.head, xOffs, yOffs);
|
||||
// g.drawString(legendEntries[i].head, 80, 80);
|
||||
yOffs += (5 + stringBounds.getHeight());
|
||||
}
|
||||
g.setColor(origCol);
|
||||
}
|
||||
/**
|
||||
* @param g
|
||||
* @param x
|
||||
* @param y
|
||||
* @param maxX
|
||||
*/
|
||||
private void paintIn(Graphics g, int x, int y, int maxX) {
|
||||
FontMetrics fm = g.getFontMetrics();
|
||||
// System.out.println("In LegendBox.paintIn!");
|
||||
int yOffs = 5 + y + fm.getHeight();
|
||||
int xOffs = x;
|
||||
Color origCol = g.getColor();
|
||||
// avoid that an entry with identical label and color occurs multiple
|
||||
// times.
|
||||
for (Pair<String, Color> legendEntry : legendEntries) {
|
||||
// System.out.println(legendEntries[i].toString() + "\tcontaines: "
|
||||
// + set.contains(legendEntries[i]));
|
||||
g.setColor(legendEntry.tail);
|
||||
Rectangle2D stringBounds = fm.getStringBounds(legendEntry.head, g);
|
||||
xOffs = (int) (maxX - stringBounds.getWidth() - 5);
|
||||
g.drawString(legendEntry.head, xOffs, yOffs);
|
||||
// g.drawString(legendEntries[i].head, 80, 80);
|
||||
yOffs += (5 + stringBounds.getHeight());
|
||||
}
|
||||
g.setColor(origCol);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class GraphWindow {
|
||||
*
|
||||
*/
|
||||
public static GraphWindow getInstance(String graphWindowName,
|
||||
String strx, String stry) {
|
||||
String strx, String stry) {
|
||||
if (plotContainer == null) {
|
||||
plotContainer = new PlotContainer();
|
||||
}
|
||||
|
||||
@@ -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
|
||||
* @param problem InterfaceOptimizationProblem
|
||||
/**
|
||||
* 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;
|
||||
@@ -260,7 +262,7 @@ public class Plot implements PlotInterface, Serializable {
|
||||
* Toggle whether the graphs should be annotated by tool tip info strings.
|
||||
*
|
||||
* @param doShowGraphToolTips true if the graphs should be annotated by tool
|
||||
* tip info strings
|
||||
* tip info strings
|
||||
*/
|
||||
public void setShowGraphToolTips(boolean doShowGraphToolTips) {
|
||||
m_PlotArea.setShowGraphToolTips(doShowGraphToolTips);
|
||||
@@ -455,7 +457,7 @@ public class Plot implements PlotInterface, Serializable {
|
||||
} catch (IOException ex) {
|
||||
JOptionPane.showMessageDialog(m_Frame,
|
||||
"Couldn't write to file: " + sFile.getName() + "\n"
|
||||
+ ex.getMessage(), "Save object",
|
||||
+ ex.getMessage(), "Save object",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package eva2.gui.plot;
|
||||
|
||||
/*
|
||||
* Title: EvA2
|
||||
* Description:
|
||||
@@ -13,25 +14,34 @@ package eva2.gui.plot;
|
||||
* IMPORTS
|
||||
*==========================================================================*/
|
||||
public interface PlotInterface {
|
||||
public void setConnectedPoint (double x,double y,int GraphLabel);
|
||||
|
||||
/**
|
||||
* Add two graphs to form an average graph
|
||||
*
|
||||
* @param g1 graph object one
|
||||
* @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 String getName();
|
||||
public int getPointCount(int graphLabel);
|
||||
// public FunctionArea getFunctionArea(); // this is bad for RMI
|
||||
public boolean isValid();
|
||||
public void init();
|
||||
public void setConnectedPoint(double x, double y, int GraphLabel);
|
||||
|
||||
/**
|
||||
* Add two graphs to form an average graph
|
||||
*
|
||||
* @param g1 graph object one
|
||||
* @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 String getName();
|
||||
|
||||
public int getPointCount(int graphLabel);
|
||||
|
||||
// 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,52 +26,55 @@ import javax.swing.JPanel;
|
||||
/*==========================================================================*
|
||||
* CLASS DECLARATION
|
||||
*==========================================================================*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class TopoPlot extends Plot {
|
||||
Interface2DBorderProblem prob=null;
|
||||
double[][] range=null;
|
||||
boolean withGrads=false;
|
||||
private int gridx = 50;
|
||||
private int gridy = 50;
|
||||
int colorScale = ColorBarCalculator.BLUE_TO_RED;
|
||||
Interface2DBorderProblem prob = null;
|
||||
double[][] range = null;
|
||||
boolean withGrads = false;
|
||||
private int gridx = 50;
|
||||
private int gridy = 50;
|
||||
int colorScale = ColorBarCalculator.BLUE_TO_RED;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
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) {
|
||||
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()) {
|
||||
gridX = m_Frame.getWidth();
|
||||
}
|
||||
if (gridY>m_Frame.getHeight()) {
|
||||
gridY = m_Frame.getHeight();
|
||||
}
|
||||
gridx = gridX;
|
||||
gridy = gridY;
|
||||
colorScale = color_scale;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public TopoPlot(String PlotName, String xname, String yname) {
|
||||
super(PlotName, xname, yname, true);
|
||||
//if (TRACE) System.out.println("Constructor TopoPlot "+PlotName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void installButtons(JPanel buttonPan) {
|
||||
super.installButtons(buttonPan);
|
||||
// TODO this actually works, but it is horribly slow
|
||||
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()) {
|
||||
gridX = m_Frame.getWidth();
|
||||
}
|
||||
if (gridY > m_Frame.getHeight()) {
|
||||
gridY = m_Frame.getHeight();
|
||||
}
|
||||
gridx = gridX;
|
||||
gridy = gridY;
|
||||
colorScale = color_scale;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void installButtons(JPanel buttonPan) {
|
||||
super.installButtons(buttonPan);
|
||||
// TODO this actually works, but it is horribly slow
|
||||
// JButton refineButton = new JButton ("Refine");
|
||||
// refineButton.setToolTipText("Refine the graph resolution");
|
||||
// refineButton.addActionListener(new ActionListener() {
|
||||
@@ -80,90 +85,93 @@ 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
|
||||
*/
|
||||
public void setParams(int gridX, int gridY) {
|
||||
setParams(gridX, gridY, colorScale);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the topology (by setting a specific problem) and draws the topology
|
||||
*/
|
||||
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;
|
||||
double[] pos = new double[2];
|
||||
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));
|
||||
if (TRACEMETH) {
|
||||
System.out.println(pos[0] + " " + pos[1] + " " + tmp);
|
||||
}
|
||||
if (tmp < min) {
|
||||
min = tmp;
|
||||
}
|
||||
if (tmp > max) {
|
||||
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]));
|
||||
} // maximum deriv of first 2 dims
|
||||
}
|
||||
|
||||
} // for y
|
||||
} // for x
|
||||
fitRange = java.lang.Math.abs(max - min);
|
||||
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)));
|
||||
// Color color = new Color(255,(int)(problem.doEvaluation(pos)[0]/fitRange*255),(int)(problem.doEvaluation(pos)[0]/fitRange*255));
|
||||
// Color color = new Color(colorBar.getRGB((float)(problem.functionValue(pos)/fitRange))); // Color color = new Color(255,(int)(problem.doEvaluation(pos)[0]/fitRange*255),(int)(problem.doEvaluation(pos)[0]/fitRange*255));
|
||||
rect.setColor(color);
|
||||
rect.setFillColor(color);
|
||||
m_PlotArea.addDElement(rect);
|
||||
} // 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);
|
||||
Mathematics.vvAdd(pos, derivPos, derivPos);
|
||||
getFunctionArea().drawLine(pos, derivPos);
|
||||
getFunctionArea().drawIcon(1, "", derivPos, 0);
|
||||
} // for y
|
||||
} // for x
|
||||
}
|
||||
m_Frame.setVisible(true);
|
||||
} // setTopology
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public void setParams(int gridX, int gridY) {
|
||||
setParams(gridX, gridY, colorScale);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the topology (by setting a specific problem) and draws the topology
|
||||
*/
|
||||
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;
|
||||
double[] pos = new double[2];
|
||||
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));
|
||||
if (TRACEMETH) {
|
||||
System.out.println(pos[0] + " " + pos[1] + " " + tmp);
|
||||
}
|
||||
if (tmp < min) {
|
||||
min = tmp;
|
||||
}
|
||||
if (tmp > max) {
|
||||
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]));
|
||||
} // maximum deriv of first 2 dims
|
||||
}
|
||||
|
||||
} // for y
|
||||
} // for x
|
||||
fitRange = java.lang.Math.abs(max - min);
|
||||
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)));
|
||||
// Color color = new Color(255,(int)(problem.doEvaluation(pos)[0]/fitRange*255),(int)(problem.doEvaluation(pos)[0]/fitRange*255));
|
||||
// Color color = new Color(colorBar.getRGB((float)(problem.functionValue(pos)/fitRange))); // Color color = new Color(255,(int)(problem.doEvaluation(pos)[0]/fitRange*255),(int)(problem.doEvaluation(pos)[0]/fitRange*255));
|
||||
rect.setColor(color);
|
||||
rect.setFillColor(color);
|
||||
m_PlotArea.addDElement(rect);
|
||||
} // 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);
|
||||
Mathematics.vvAdd(pos, derivPos, derivPos);
|
||||
getFunctionArea().drawLine(pos, derivPos);
|
||||
getFunctionArea().drawIcon(1, "", derivPos, 0);
|
||||
} // for y
|
||||
} // for x
|
||||
}
|
||||
m_Frame.setVisible(true);
|
||||
} // setTopology
|
||||
} // class
|
||||
|
||||
@@ -96,13 +96,13 @@ public class CustomTabbedPaneUI extends BasicTabbedPaneUI {
|
||||
|
||||
@Override
|
||||
protected int calculateTabHeight(int tabPlacement, int tabIndex,
|
||||
int fontHeight) {
|
||||
int fontHeight) {
|
||||
return 21;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int calculateTabWidth(int tabPlacement, int tabIndex,
|
||||
FontMetrics metrics) {
|
||||
FontMetrics metrics) {
|
||||
int w = super.calculateTabWidth(tabPlacement, tabIndex, metrics);
|
||||
int wid = metrics.charWidth('M');
|
||||
w += wid * 2;
|
||||
@@ -134,7 +134,7 @@ public class CustomTabbedPaneUI extends BasicTabbedPaneUI {
|
||||
|
||||
@Override
|
||||
protected void paintTabBackground(Graphics g, int tabPlacement,
|
||||
int tabIndex, int x, int y, int w, int h, boolean isSelected) {
|
||||
int tabIndex, int x, int y, int w, int h, boolean isSelected) {
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
ColorSet colorSet;
|
||||
|
||||
@@ -174,7 +174,7 @@ public class CustomTabbedPaneUI extends BasicTabbedPaneUI {
|
||||
|
||||
@Override
|
||||
protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex,
|
||||
int x, int y, int w, int h, boolean isSelected) {
|
||||
int x, int y, int w, int h, boolean isSelected) {
|
||||
Rectangle rect = getTabBounds(tabIndex, new Rectangle(x, y, w, h));
|
||||
g.setColor(dividerColor);
|
||||
g.drawLine(rect.x + rect.width, 0, rect.x + rect.width, 20);
|
||||
@@ -182,37 +182,37 @@ public class CustomTabbedPaneUI extends BasicTabbedPaneUI {
|
||||
|
||||
@Override
|
||||
protected void paintContentBorderTopEdge(Graphics g, int tabPlacement,
|
||||
int selectedIndex, int x, int y, int w, int h) {
|
||||
int selectedIndex, int x, int y, int w, int h) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintContentBorderRightEdge(Graphics g, int tabPlacement,
|
||||
int selectedIndex, int x, int y, int w, int h) {
|
||||
int selectedIndex, int x, int y, int w, int h) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintContentBorderLeftEdge(Graphics g, int tabPlacement,
|
||||
int selectedIndex, int x, int y, int w, int h) {
|
||||
int selectedIndex, int x, int y, int w, int h) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintContentBorderBottomEdge(Graphics g, int tabPlacement,
|
||||
int selectedIndex, int x, int y, int w, int h) {
|
||||
int selectedIndex, int x, int y, int w, int h) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintFocusIndicator(Graphics g, int tabPlacement,
|
||||
Rectangle[] rects, int tabIndex, Rectangle iconRect,
|
||||
Rectangle textRect, boolean isSelected) {
|
||||
Rectangle[] rects, int tabIndex, Rectangle iconRect,
|
||||
Rectangle textRect, boolean isSelected) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getTabLabelShiftY(int tabPlacement, int tabIndex,
|
||||
boolean isSelected) {
|
||||
boolean isSelected) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,79 +8,78 @@ import javax.swing.JComponent;
|
||||
import javax.swing.plaf.basic.BasicButtonUI;
|
||||
|
||||
public class VerticalButtonUI extends BasicButtonUI {
|
||||
|
||||
|
||||
protected int angle;
|
||||
|
||||
|
||||
public VerticalButtonUI(int angle) {
|
||||
super();
|
||||
this.angle = angle;
|
||||
}
|
||||
|
||||
|
||||
@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();
|
||||
private static Rectangle paintTextR = new Rectangle();
|
||||
private static Rectangle paintViewR = new Rectangle();
|
||||
private static Insets paintViewInsets = new Insets(0, 0, 0, 0);
|
||||
|
||||
|
||||
@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();
|
||||
|
||||
|
||||
if ((icon == null) && (text == null)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
FontMetrics fm = g.getFontMetrics();
|
||||
paintViewInsets = c.getInsets(paintViewInsets);
|
||||
|
||||
|
||||
paintViewR.x = paintViewInsets.left;
|
||||
paintViewR.y = paintViewInsets.top;
|
||||
|
||||
|
||||
// Use inverted height & width
|
||||
paintViewR.height = c.getWidth() - (paintViewInsets.left + paintViewInsets.right);
|
||||
paintViewR.width = c.getHeight() - (paintViewInsets.top + paintViewInsets.bottom);
|
||||
|
||||
|
||||
paintIconR.x = paintIconR.y = paintIconR.width = paintIconR.height = 0;
|
||||
paintTextR.x = paintTextR.y = paintTextR.width = paintTextR.height = 0;
|
||||
|
||||
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
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;
|
||||
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;
|
||||
}
|
||||
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) {
|
||||
icon.paintIcon(c, g, paintIconR.x, paintIconR.y);
|
||||
}
|
||||
|
||||
|
||||
if (text != null) {
|
||||
int textX = paintTextR.x;
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -4,12 +4,14 @@ package eva2.optimization;
|
||||
* Description: API for distributed and parallel computing.
|
||||
* Copyright: Copyright (c) 2004
|
||||
* Company: University of Tuebingen
|
||||
* @version: $Revision: 259 $
|
||||
* @version: $Revision: 259 $
|
||||
* $Date: 2007-11-16 17:25:09 +0100 (Fri, 16 Nov 2007) $
|
||||
* $Author: mkron $
|
||||
*/
|
||||
|
||||
import eva2.optimization.go.InterfaceOptimizationParameters;
|
||||
import eva2.optimization.modules.ModuleAdapter;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -5,15 +5,17 @@ package eva2.optimization;
|
||||
* Description: API for distributed and parallel computing.
|
||||
* Copyright: Copyright (c) 2004
|
||||
* Company: University of Tuebingen
|
||||
* @version: $Revision: 315 $
|
||||
* @version: $Revision: 315 $
|
||||
* $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;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class EvAMainAdapterImpl implements EvAMainAdapter {
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -92,7 +94,7 @@ public class ModuleServer {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
String[] x = new String[moduleNameList.size()];
|
||||
moduleNameList.toArray(x);
|
||||
return x;
|
||||
@@ -153,7 +155,7 @@ public class ModuleServer {
|
||||
constrIndex++;
|
||||
}
|
||||
moduleAdapter = (ModuleAdapter) constructorArr[constrIndex].newInstance(param);
|
||||
}
|
||||
}
|
||||
// m_RunnungModules.add(m_ModuleAdapter);
|
||||
} catch (Exception ex) {
|
||||
LOGGER.log(Level.SEVERE, "Error in RMI-Moduladapter initialization", ex);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
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"};
|
||||
}
|
||||
BDM, K2, BIC;
|
||||
|
||||
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;
|
||||
//", "DE2 - DE/current-to-best/1", "DE/best/2", "Trigonometric DE"};
|
||||
DE1_Rand_1, DE2_CurrentToBest, DE_Best_2, TrigonometricDE, DE_CurrentToRand;
|
||||
//", "DE2 - DE/current-to-best/1", "DE/best/2", "Trigonometric DE"};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
package eva2.optimization.enums;
|
||||
|
||||
public enum ESMutationInitialSigma {
|
||||
halfRange, quarterRange, avgInitialDistance, userDefined;
|
||||
halfRange, quarterRange, avgInitialDistance, userDefined;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
package eva2.optimization.enums;
|
||||
|
||||
public enum MutateESCrossoverTypeEnum {
|
||||
none, intermediate, discrete;
|
||||
none, intermediate, discrete;
|
||||
}
|
||||
|
||||
@@ -1,53 +1,63 @@
|
||||
package eva2.optimization.enums;
|
||||
|
||||
public enum PSOTopologyEnum {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
linear,
|
||||
/**
|
||||
*
|
||||
*/
|
||||
grid,
|
||||
/**
|
||||
*
|
||||
*/
|
||||
star,
|
||||
/**
|
||||
*
|
||||
*/
|
||||
multiSwarm,
|
||||
/**
|
||||
*
|
||||
*/
|
||||
tree,
|
||||
/**
|
||||
*
|
||||
*/
|
||||
hpso,
|
||||
/**
|
||||
*
|
||||
*/
|
||||
random,
|
||||
dms;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
linear,
|
||||
/**
|
||||
*
|
||||
*/
|
||||
grid,
|
||||
/**
|
||||
*
|
||||
*/
|
||||
star,
|
||||
/**
|
||||
*
|
||||
*/
|
||||
multiSwarm,
|
||||
/**
|
||||
*
|
||||
*/
|
||||
tree,
|
||||
/**
|
||||
*
|
||||
*/
|
||||
hpso,
|
||||
/**
|
||||
*
|
||||
*/
|
||||
random,
|
||||
dms;
|
||||
|
||||
/**
|
||||
* 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.");
|
||||
return grid;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 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.");
|
||||
return grid;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
package eva2.optimization.enums;
|
||||
|
||||
public enum PostProcessMethod {
|
||||
hillClimber, nelderMead, cmaES;
|
||||
hillClimber, nelderMead, cmaES;
|
||||
}
|
||||
@@ -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.
|
||||
@@ -572,7 +573,7 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
* 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.
|
||||
* @param name Could be used to indicate the nature of the event.
|
||||
*/
|
||||
@Override
|
||||
public void registerPopulationStateChanged(Object source, String name) {
|
||||
@@ -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.
|
||||
|
||||
@@ -17,57 +17,57 @@ import eva2.optimization.problems.InterfaceOptimizationProblem;
|
||||
* Minimal interface for an EA individual.
|
||||
*/
|
||||
public interface IndividualInterface {
|
||||
/**
|
||||
* Create a clone of the individual instance.
|
||||
*
|
||||
* @return a clone of the individual instance
|
||||
*/
|
||||
IndividualInterface getClone();
|
||||
/**
|
||||
* Create a clone of the individual instance.
|
||||
*
|
||||
* @return a clone of the individual instance
|
||||
*/
|
||||
IndividualInterface getClone();
|
||||
|
||||
/**
|
||||
* Get the fitness array of the individual which may be null if none has been set.
|
||||
*
|
||||
* @return the fitness array of the individual
|
||||
*/
|
||||
double[] getFitness();
|
||||
/**
|
||||
* Get the fitness array of the individual which may be null if none has been set.
|
||||
*
|
||||
* @return the fitness array of the individual
|
||||
*/
|
||||
double[] getFitness();
|
||||
|
||||
/**
|
||||
* Set the fitness array to the given array.
|
||||
*
|
||||
* @param fit new fitness of the individual
|
||||
*/
|
||||
void setFitness (double[] fit);
|
||||
/**
|
||||
* Set the fitness array to the given array.
|
||||
*
|
||||
* @param fit new fitness of the individual
|
||||
*/
|
||||
void setFitness(double[] fit);
|
||||
|
||||
/**
|
||||
* Check whether the instance is dominating the given other individual and return
|
||||
* true in this case.
|
||||
*
|
||||
* @param other a second individual of the same type
|
||||
* @return true if the instance dominates the other individual, else false
|
||||
*/
|
||||
boolean isDominant(double[] fitness);
|
||||
/**
|
||||
* Check whether the instance is dominating the given other individual and return
|
||||
* true in this case.
|
||||
*
|
||||
* @param other a second individual of the same type
|
||||
* @return true if the instance dominates the other individual, else false
|
||||
*/
|
||||
boolean isDominant(double[] fitness);
|
||||
|
||||
/**
|
||||
* Check whether the instance is dominating the given other individual and return
|
||||
* true in this case.
|
||||
* Should behave equally to {@link #isDominant(double[])} if called with the fitness
|
||||
* of the given individual.
|
||||
*
|
||||
* @param other a second individual of the same type
|
||||
* @return true if the instance dominates the other individual, else false
|
||||
*/
|
||||
boolean isDominant(IndividualInterface other);
|
||||
/**
|
||||
* Check whether the instance is dominating the given other individual and return
|
||||
* true in this case.
|
||||
* Should behave equally to {@link #isDominant(double[])} if called with the fitness
|
||||
* of the given individual.
|
||||
*
|
||||
* @param other a second individual of the same type
|
||||
* @return true if the instance dominates the other individual, else false
|
||||
*/
|
||||
boolean isDominant(IndividualInterface other);
|
||||
|
||||
/**
|
||||
* Perform a standard mutation operation on the individual. The exact implementation
|
||||
* depends on the implemented genotype.
|
||||
*/
|
||||
void defaultMutate();
|
||||
/**
|
||||
* Perform a standard mutation operation on the individual. The exact implementation
|
||||
* depends on the implemented genotype.
|
||||
*/
|
||||
void defaultMutate();
|
||||
|
||||
/**
|
||||
* Initialize the genotype randomly, usually in a uniform distribution. Make sure,
|
||||
* if the problem has an initial range (it implements InterfaceHasInitialRange), that this
|
||||
* initial range is used.
|
||||
*/
|
||||
void defaultInit(InterfaceOptimizationProblem prob);
|
||||
/**
|
||||
* Initialize the genotype randomly, usually in a uniform distribution. Make sure,
|
||||
* if the problem has an initial range (it implements InterfaceHasInitialRange), that this
|
||||
* initial range is used.
|
||||
*/
|
||||
void defaultInit(InterfaceOptimizationProblem prob);
|
||||
}
|
||||
@@ -9,5 +9,6 @@ package eva2.optimization.go;
|
||||
*/
|
||||
public interface InterfaceGOStandalone {
|
||||
void startExperiment();
|
||||
|
||||
void setShow(boolean t);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package eva2.optimization.go;
|
||||
|
||||
import eva2.optimization.problems.InterfaceAdditionalPopulationInformer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface InterfaceNotifyOnInformers {
|
||||
/**
|
||||
* Notify the object about informer instances.
|
||||
*/
|
||||
public void setInformers(List<InterfaceAdditionalPopulationInformer> informers);
|
||||
/**
|
||||
* Notify the object about informer instances.
|
||||
*/
|
||||
public void setInformers(List<InterfaceAdditionalPopulationInformer> informers);
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
* @param x Long seed.
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @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,9 +10,11 @@ package eva2.optimization.go;
|
||||
*/
|
||||
public interface InterfacePopulationChangedEventListener {
|
||||
|
||||
/** 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.
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
void registerPopulationStateChanged(Object source, String name);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ public interface InterfaceProcessor {
|
||||
|
||||
/**
|
||||
* Get Info String about the Optimization.
|
||||
*
|
||||
* @return The info String
|
||||
*/
|
||||
String getInfoString();
|
||||
|
||||
@@ -6,22 +6,24 @@ import eva2.optimization.problems.InterfaceOptimizationProblem;
|
||||
|
||||
/**
|
||||
* Interface for a termination criterion.
|
||||
*
|
||||
* @author mkron, streiche
|
||||
*
|
||||
* @author mkron, streiche
|
||||
*/
|
||||
public interface InterfaceTerminator {
|
||||
/**
|
||||
* Test a given population for convergence with the criterion defined by the instance.
|
||||
*
|
||||
* @param pop the population to test
|
||||
* @return true if the population fulfills the termination criterion, else false
|
||||
*/
|
||||
public boolean isTerminated(PopulationInterface pop);
|
||||
public boolean isTerminated(InterfaceSolutionSet pop);
|
||||
/**
|
||||
* Test a given population for convergence with the criterion defined by the instance.
|
||||
*
|
||||
* @param pop the population to test
|
||||
* @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);
|
||||
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;
|
||||
@@ -46,23 +47,24 @@ import javax.swing.*;
|
||||
*/
|
||||
public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulationChangedEventListener, Serializable {
|
||||
|
||||
public volatile MOCCOState m_State;
|
||||
private SwingWorker worker;
|
||||
private volatile boolean m_StillWorking = false;
|
||||
public int m_Iteration = -1;
|
||||
public JFrame m_JFrame;
|
||||
public volatile MOCCOState m_State;
|
||||
private SwingWorker worker;
|
||||
private volatile boolean m_StillWorking = false;
|
||||
public int m_Iteration = -1;
|
||||
public JFrame m_JFrame;
|
||||
//public ParetoFrontView n_ParetoFrontView;
|
||||
public boolean m_Debug = false;
|
||||
public MOCCOViewer m_View;
|
||||
public JPanel m_JPanelMain, m_JPanelParameters, m_JPanelControl, m_JPanelButtom;
|
||||
private JLabel m_CurrentState;
|
||||
private JProgressBar m_ProgressBar;
|
||||
public boolean m_Debug = false;
|
||||
public MOCCOViewer m_View;
|
||||
public JPanel m_JPanelMain, m_JPanelParameters, m_JPanelControl, m_JPanelButtom;
|
||||
private JLabel m_CurrentState;
|
||||
private JProgressBar m_ProgressBar;
|
||||
|
||||
public MOCCOStandalone() {
|
||||
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() {
|
||||
@@ -80,12 +82,12 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
||||
}
|
||||
});
|
||||
// init basic panel structure
|
||||
this.m_JPanelMain = new JPanel();
|
||||
this.m_JPanelMain = new JPanel();
|
||||
this.m_JPanelParameters = new JPanel();
|
||||
this.m_JPanelParameters.setPreferredSize(new Dimension(500, 300));
|
||||
this.m_JPanelParameters.setMinimumSize(new Dimension(500, 300));
|
||||
this.m_JPanelControl = new JPanel();
|
||||
this.m_View = new MOCCOViewer(this);
|
||||
this.m_JPanelControl = new JPanel();
|
||||
this.m_View = new MOCCOViewer(this);
|
||||
this.m_JFrame.getContentPane().add(this.m_JPanelMain);
|
||||
this.m_JPanelMain.setLayout(new BorderLayout());
|
||||
this.m_JPanelMain.add(this.m_JPanelParameters, BorderLayout.WEST);
|
||||
@@ -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();
|
||||
@@ -109,22 +111,37 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
||||
}
|
||||
|
||||
public void MOCCOOptimization() {
|
||||
boolean cont = true;
|
||||
boolean cont = true;
|
||||
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,12 +151,17 @@ 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) { } }
|
||||
this.m_State.makeFitnessCache(true);
|
||||
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();
|
||||
this.m_View.problemChanged(true);
|
||||
@@ -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,54 +427,58 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
||||
}
|
||||
}
|
||||
|
||||
/** This methods loads the current state of MOCO from a serialized file
|
||||
* @param loadFrom The name of the 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
|
||||
*/
|
||||
public Object openObject(String loadFrom) {
|
||||
File selected = new File(loadFrom);
|
||||
try {
|
||||
ObjectInputStream oi = new ObjectInputStream(new BufferedInputStream(new FileInputStream(selected)));
|
||||
try {
|
||||
ObjectInputStream oi = new ObjectInputStream(new BufferedInputStream(new FileInputStream(selected)));
|
||||
Object obj = oi.readObject();
|
||||
oi.close();
|
||||
if (!(obj instanceof MOCCOState)) {
|
||||
throw new Exception("Object not of type MOCCOState");
|
||||
} return obj;
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
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 {
|
||||
System.out.println("Couldn't read object: " + selected.getName() + "\n" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
JOptionPane.showMessageDialog(this.m_JFrame, "Couldn't read object: " + selected.getName() + "\n" + ex.getMessage(), "Open object file", JOptionPane.ERROR_MESSAGE);
|
||||
} 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
|
||||
* @param saveAs The name of the outputfile
|
||||
/**
|
||||
* This method saves the current MOCOData into a serialized file
|
||||
*
|
||||
* @param saveAs The name of the outputfile
|
||||
*/
|
||||
public void saveObject(String saveAs) {
|
||||
File sFile = new File(saveAs);
|
||||
try {
|
||||
ObjectOutputStream oo = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(sFile)));
|
||||
File sFile = new File(saveAs);
|
||||
try {
|
||||
ObjectOutputStream oo = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(sFile)));
|
||||
oo.writeObject(this.m_State);
|
||||
oo.close();
|
||||
} catch (Exception ex) {
|
||||
} 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 {
|
||||
System.out.println("Couldn't write to file: " + sFile.getName() + "\n" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
JOptionPane.showMessageDialog(this.m_JFrame, "Couldn't write to file: " + sFile.getName() + "\n" + ex.getMessage(), "Save object", JOptionPane.ERROR_MESSAGE);
|
||||
} else {
|
||||
System.out.println("Couldn't write to file: " + sFile.getName() + "\n" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************************************************************************
|
||||
* 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,27 +583,29 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
||||
/***********************************************************************************************
|
||||
* InterfacePopulationChangedEventListener
|
||||
*/
|
||||
/** 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.
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@Override
|
||||
public void registerPopulationStateChanged(Object source, String name) {
|
||||
int currentProgress;
|
||||
if (name.equals(Population.nextGenerationPerformed)) {
|
||||
if (this.m_State.isVisible) {
|
||||
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);
|
||||
} else {
|
||||
currentProgress = (int)(0);
|
||||
}
|
||||
updateStatus("Optimizing...",currentProgress);
|
||||
} else {
|
||||
// perhaps i could write it to file!?
|
||||
}
|
||||
}
|
||||
int currentProgress;
|
||||
if (name.equals(Population.nextGenerationPerformed)) {
|
||||
if (this.m_State.isVisible) {
|
||||
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);
|
||||
} else {
|
||||
currentProgress = (int) (0);
|
||||
}
|
||||
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.
|
||||
@@ -20,36 +21,45 @@ public abstract class SwingWorker {
|
||||
private Object value; // see getValue(), setValue()
|
||||
private Thread thread;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Class to maintain reference to current worker thread
|
||||
* under separate synchronization control.
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* Get the value produced by the worker thread, or null if it
|
||||
/**
|
||||
* Get the value produced by the worker thread, or null if it
|
||||
* hasn't been constructed yet.
|
||||
*/
|
||||
protected synchronized Object getValue() {
|
||||
return value;
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value produced by worker thread
|
||||
/**
|
||||
* Set the value produced by worker thread
|
||||
*/
|
||||
private synchronized void setValue(Object x) {
|
||||
value = x;
|
||||
value = x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute the value to be returned by the <code>get</code> method.
|
||||
/**
|
||||
* Compute the value to be returned by the <code>get</code> method.
|
||||
*/
|
||||
public abstract Object construct();
|
||||
|
||||
@@ -61,22 +71,21 @@ public abstract class SwingWorker {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value created by the <code>construct</code> method.
|
||||
* Return the value created by the <code>construct</code> method.
|
||||
* Returns null if either the constructing thread or the current
|
||||
* thread was interrupted before a value was produced.
|
||||
*
|
||||
*
|
||||
* @return the value created by the <code>construct</code> method
|
||||
*/
|
||||
public Object get() {
|
||||
while (true) {
|
||||
while (true) {
|
||||
Thread t = threadVar.get();
|
||||
if (t == null) {
|
||||
return getValue();
|
||||
}
|
||||
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.
|
||||
@@ -44,7 +46,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
||||
private double constraintViolation = 0;
|
||||
public boolean areaConst4ParallelViolated = false; // no idea what felix used this for...
|
||||
public boolean isMarked = false; // is for GUI only!
|
||||
public boolean isPenalized = false; // may be set true for penalty based constraints
|
||||
public boolean isPenalized = false; // may be set true for penalty based constraints
|
||||
protected double[] selectionProbability = new double[1];
|
||||
|
||||
protected double crossoverProbability = 1.0;
|
||||
@@ -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.
|
||||
@@ -627,7 +634,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
||||
/**
|
||||
* This method allows you to set the i-th fitness value
|
||||
*
|
||||
* @param index The index of the fitness value to set.
|
||||
* @param index The index of the fitness value to set.
|
||||
* @param fitness The new fitness value.
|
||||
*/
|
||||
public void SetFitness(int index, double fitness) {
|
||||
@@ -764,7 +771,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
||||
*
|
||||
* @param indy The individual to compare to.
|
||||
* @return 1 if the instance is better (regarding constraints only), -1 if
|
||||
* is worse, 0 if they are equal in that respect.
|
||||
* is worse, 0 if they are equal in that respect.
|
||||
*/
|
||||
public int compareConstraintViolation(AbstractEAIndividual indy) {
|
||||
if ((this.constraintViolation > 0) && (indy.constraintViolation <= 0)) {
|
||||
@@ -883,7 +890,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
||||
* This method allows you to set the i-th selection probability value
|
||||
*
|
||||
* @param index The index of the selection probability value to set.
|
||||
* @param sel The new selection probability value.
|
||||
* @param sel The new selection probability value.
|
||||
*/
|
||||
public void SetSelectionProbability(int index, double sel) {
|
||||
if (this.selectionProbability.length > index) {
|
||||
@@ -998,7 +1005,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
||||
* name.
|
||||
*
|
||||
* @param name The identifying name.
|
||||
* @param obj The object that is to be stored.
|
||||
* @param obj The object that is to be stored.
|
||||
*/
|
||||
public void putData(String name, Object obj) {
|
||||
dataHash.put(name, obj);
|
||||
@@ -1010,7 +1017,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
||||
* fitness array.
|
||||
*
|
||||
* @param name The name of the requested Object
|
||||
* @return Object The associated object or null if none is found
|
||||
* @return Object The associated object or null if none is found
|
||||
*/
|
||||
public Object getData(String name) {
|
||||
// if (name.equalsIgnoreCase("SelectionProbability")) return this.getSelectionProbability();
|
||||
@@ -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()
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user