Reformat all Code.
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
package eva2.gui;
|
package eva2.gui;
|
||||||
|
|
||||||
import eva2.tools.BasicResourceLoader;
|
import eva2.tools.BasicResourceLoader;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
@@ -13,24 +14,23 @@ import javax.swing.event.HyperlinkEvent;
|
|||||||
import javax.swing.event.HyperlinkListener;
|
import javax.swing.event.HyperlinkListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author becker
|
* @author becker
|
||||||
*/
|
*/
|
||||||
public class AboutDialog extends JDialog {
|
public class AboutDialog extends JDialog {
|
||||||
private JLabel imageLabel;
|
private JLabel imageLabel;
|
||||||
private JEditorPane infoEditorPane;
|
private JEditorPane infoEditorPane;
|
||||||
private JTextArea aboutTextArea;
|
private JTextArea aboutTextArea;
|
||||||
|
|
||||||
public AboutDialog(Frame parent) {
|
public AboutDialog(Frame parent) {
|
||||||
super(parent);
|
super(parent);
|
||||||
initComponents();
|
initComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
setTitle("About");
|
setTitle("About");
|
||||||
setLayout(new GridBagLayout());
|
setLayout(new GridBagLayout());
|
||||||
GridBagConstraints gbConstraints = new GridBagConstraints();
|
GridBagConstraints gbConstraints = new GridBagConstraints();
|
||||||
|
|
||||||
setSize(new Dimension(470, 600));
|
setSize(new Dimension(470, 600));
|
||||||
setResizable(false);
|
setResizable(false);
|
||||||
|
|
||||||
@@ -41,19 +41,19 @@ public class AboutDialog extends JDialog {
|
|||||||
|
|
||||||
/* Create a new JLabel with the image */
|
/* Create a new JLabel with the image */
|
||||||
imageLabel = new JLabel(imageIcon);
|
imageLabel = new JLabel(imageIcon);
|
||||||
|
|
||||||
gbConstraints.gridx = 0;
|
gbConstraints.gridx = 0;
|
||||||
gbConstraints.gridy = 0;
|
gbConstraints.gridy = 0;
|
||||||
gbConstraints.ipady = 10;
|
gbConstraints.ipady = 10;
|
||||||
gbConstraints.insets = new Insets(10, 10, 0, 10);
|
gbConstraints.insets = new Insets(10, 10, 0, 10);
|
||||||
gbConstraints.anchor = GridBagConstraints.PAGE_START;
|
gbConstraints.anchor = GridBagConstraints.PAGE_START;
|
||||||
add(imageLabel, gbConstraints);
|
add(imageLabel, gbConstraints);
|
||||||
|
|
||||||
String infoMessage = "<html><head></head><body>"
|
String infoMessage = "<html><head></head><body>"
|
||||||
+"<p>EvA2 (an Evolutionary Algorithms framework, revised version 2) is a comprehensive heuristic optimization framework with emphasis on Evolutionary Algorithms implemented in Java™.</p>"
|
+ "<p>EvA2 (an Evolutionary Algorithms framework, revised version 2) is a comprehensive heuristic optimization framework with emphasis on Evolutionary Algorithms implemented in Java™.</p>"
|
||||||
+"<p>For more information, please visit the <a href=\"http://www.cogsys.cs.uni-tuebingen.de/software/JavaEvA/\">EvA2 Homepage</a>.</p>"
|
+ "<p>For more information, please visit the <a href=\"http://www.cogsys.cs.uni-tuebingen.de/software/JavaEvA/\">EvA2 Homepage</a>.</p>"
|
||||||
+"</body></html>";
|
+ "</body></html>";
|
||||||
|
|
||||||
infoEditorPane = new JEditorPane("text/html", infoMessage);
|
infoEditorPane = new JEditorPane("text/html", infoMessage);
|
||||||
infoEditorPane.setEditable(false);
|
infoEditorPane.setEditable(false);
|
||||||
infoEditorPane.setOpaque(false);
|
infoEditorPane.setOpaque(false);
|
||||||
@@ -74,10 +74,10 @@ public class AboutDialog extends JDialog {
|
|||||||
gbConstraints.gridy++;
|
gbConstraints.gridy++;
|
||||||
gbConstraints.anchor = GridBagConstraints.CENTER;
|
gbConstraints.anchor = GridBagConstraints.CENTER;
|
||||||
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
|
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
|
||||||
gbConstraints.weightx = 1.0;
|
gbConstraints.weightx = 1.0;
|
||||||
add(infoEditorPane, gbConstraints);
|
add(infoEditorPane, gbConstraints);
|
||||||
|
|
||||||
aboutTextArea = new JTextArea();
|
aboutTextArea = new JTextArea();
|
||||||
aboutTextArea.setEditable(false);
|
aboutTextArea.setEditable(false);
|
||||||
aboutTextArea.setRows(8);
|
aboutTextArea.setRows(8);
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ public class AboutDialog extends JDialog {
|
|||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
AboutDialog.this.dispose();
|
AboutDialog.this.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
gbConstraints.gridy++;
|
gbConstraints.gridy++;
|
||||||
gbConstraints.fill = GridBagConstraints.NONE;
|
gbConstraints.fill = GridBagConstraints.NONE;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import eva2.tools.Pair;
|
|||||||
import eva2.tools.SelectedTag;
|
import eva2.tools.SelectedTag;
|
||||||
import eva2.tools.StringTools;
|
import eva2.tools.StringTools;
|
||||||
import eva2.tools.Tag;
|
import eva2.tools.Tag;
|
||||||
|
|
||||||
import java.beans.BeanInfo;
|
import java.beans.BeanInfo;
|
||||||
import java.beans.IntrospectionException;
|
import java.beans.IntrospectionException;
|
||||||
import java.beans.Introspector;
|
import java.beans.Introspector;
|
||||||
@@ -23,7 +24,6 @@ import java.util.logging.Logger;
|
|||||||
* generic display.
|
* generic display.
|
||||||
*
|
*
|
||||||
* @author mkron, Holger Ulmer, Felix Streichert, Hannes Planatscher
|
* @author mkron, Holger Ulmer, Felix Streichert, Hannes Planatscher
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class BeanInspector {
|
public class BeanInspector {
|
||||||
private static final Logger LOGGER = Logger.getLogger(BeanInspector.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(BeanInspector.class.getName());
|
||||||
@@ -108,9 +108,9 @@ public class BeanInspector {
|
|||||||
/**
|
/**
|
||||||
* Produce a String representation of an arbitrary object.
|
* Produce a String representation of an arbitrary object.
|
||||||
*
|
*
|
||||||
* @see #toString(Object, char, boolean, String)
|
|
||||||
* @param obj
|
* @param obj
|
||||||
* @return
|
* @return
|
||||||
|
* @see #toString(Object, char, boolean, String)
|
||||||
*/
|
*/
|
||||||
public static String toString(Object obj) {
|
public static String toString(Object obj) {
|
||||||
return toString(obj, ';', false, "", 1, false);
|
return toString(obj, ';', false, "", 1, false);
|
||||||
@@ -475,7 +475,7 @@ public class BeanInspector {
|
|||||||
*
|
*
|
||||||
* @param obj
|
* @param obj
|
||||||
* @param mName the method name
|
* @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
|
* @return the method or null if it isn't found
|
||||||
*/
|
*/
|
||||||
public static Method hasMethod(Object obj, String mName, Object[] args) {
|
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.
|
* parameter signature. Return it if found, or null if not.
|
||||||
*
|
*
|
||||||
* @param obj
|
* @param obj
|
||||||
* @param mName the method name
|
* @param mName the method name
|
||||||
* @param paramTypes the parameter types, null allowed if no parameters are
|
* @param paramTypes the parameter types, null allowed if no parameters are
|
||||||
* expected
|
* expected
|
||||||
* @return the method or null if it isn't found
|
* @return the method or null if it isn't found
|
||||||
*/
|
*/
|
||||||
public static Method hasMethod(Object obj, String mName, Class[] paramTypes) {
|
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
|
* For a Java primitive wrapper class return the corresponding primitive
|
||||||
* class.
|
* class.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public static Class getUnboxedType(Class cls) {
|
public static Class getUnboxedType(Class cls) {
|
||||||
if (cls == Double.class) {
|
if (cls == Double.class) {
|
||||||
@@ -604,8 +603,8 @@ public class BeanInspector {
|
|||||||
* Just concatenates getClassDescription(obj) and getMemberDescriptions(obj,
|
* Just concatenates getClassDescription(obj) and getMemberDescriptions(obj,
|
||||||
* withValues).
|
* withValues).
|
||||||
*
|
*
|
||||||
* @param obj target object
|
* @param obj target object
|
||||||
* @param withValues if true, member values are displayed as well
|
* @param withValues if true, member values are displayed as well
|
||||||
* @return an info string about class and members of the given object
|
* @return an info string about class and members of the given object
|
||||||
*/
|
*/
|
||||||
public static String getDescription(Object obj, boolean withValues) {
|
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
|
* member property is normal or hidden, meaning it may have effect depending
|
||||||
* on settings of other members only, for instance.
|
* on settings of other members only, for instance.
|
||||||
*
|
*
|
||||||
* @param obj target object
|
* @param obj target object
|
||||||
* @param withValues if true, member values are displayed as well
|
* @param withValues if true, member values are displayed as well
|
||||||
* @return an info string about class and members of the given object
|
* @return an info string about class and members of the given object
|
||||||
*/
|
*/
|
||||||
public static String[] getMemberDescriptions(Object obj, boolean withValues) {
|
public static String[] getMemberDescriptions(Object obj, boolean withValues) {
|
||||||
@@ -741,7 +740,7 @@ public class BeanInspector {
|
|||||||
System.err.println("Skipping property " + name + " ; exception: " + ex.getMessage());
|
System.err.println("Skipping property " + name + " ; exception: " + ex.getMessage());
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
} // end try
|
} // end try
|
||||||
} // end for
|
} // end for
|
||||||
return memberInfoList.toArray(new String[1]);
|
return memberInfoList.toArray(new String[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1018,9 +1017,9 @@ public class BeanInspector {
|
|||||||
/**
|
/**
|
||||||
* This method simply looks for an appropriate tiptext
|
* 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 methods A list of methods to search.
|
||||||
* @param target The target object
|
* @param target The target object
|
||||||
* @return String for the ToolTip.
|
* @return String for the ToolTip.
|
||||||
*/
|
*/
|
||||||
public static String getToolTipText(String name, MethodDescriptor[] methods, Object target, boolean stripToolTipToFirstPoint, int toHTMLLen) {
|
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
|
* 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 methods A list of methods to search.
|
||||||
* @param target The target object
|
* @param target The target object
|
||||||
* @return String for the ToolTip.
|
* @return String for the ToolTip.
|
||||||
*/
|
*/
|
||||||
public static String getToolTipText(String name, MethodDescriptor[] methods, Object target) {
|
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) $
|
* $Date: 2007-11-27 14:37:05 +0100 (Tue, 27 Nov 2007) $
|
||||||
* $Author: mkron $
|
* $Author: mkron $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import eva2.optimization.OptimizationStateListener;
|
import eva2.optimization.OptimizationStateListener;
|
||||||
import eva2.optimization.modules.ModuleAdapter;
|
import eva2.optimization.modules.ModuleAdapter;
|
||||||
import eva2.optimization.stat.OptimizationJob;
|
import eva2.optimization.stat.OptimizationJob;
|
||||||
import eva2.tools.ToolBoxGui;
|
import eva2.tools.ToolBoxGui;
|
||||||
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
@@ -53,9 +55,9 @@ public class EvAModuleButtonPanelMaker implements OptimizationStateListener, Ser
|
|||||||
public JToolBar makePanel() {
|
public JToolBar makePanel() {
|
||||||
toolBar = new JToolBar();
|
toolBar = new JToolBar();
|
||||||
toolBar.setFloatable(false);
|
toolBar.setFloatable(false);
|
||||||
|
|
||||||
moduleAdapter.addOptimizationStateListener((OptimizationStateListener) (this));
|
moduleAdapter.addOptimizationStateListener((OptimizationStateListener) (this));
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////
|
||||||
runButton = ToolBoxGui.createIconifiedButton("images/Play24.gif", "Start", true);
|
runButton = ToolBoxGui.createIconifiedButton("images/Play24.gif", "Start", true);
|
||||||
@@ -111,7 +113,7 @@ public class EvAModuleButtonPanelMaker implements OptimizationStateListener, Ser
|
|||||||
});
|
});
|
||||||
postProcessButton.setEnabled(runningState && moduleAdapter.hasPostProcessing());
|
postProcessButton.setEnabled(runningState && moduleAdapter.hasPostProcessing());
|
||||||
toolBar.add(postProcessButton);
|
toolBar.add(postProcessButton);
|
||||||
|
|
||||||
scheduleButton = ToolBoxGui.createIconifiedButton("images/Server24.gif", "Schedule", true);
|
scheduleButton = ToolBoxGui.createIconifiedButton("images/Server24.gif", "Schedule", true);
|
||||||
scheduleButton.setToolTipText("Schedule the currently configured optimization as a job.");
|
scheduleButton.setToolTipText("Schedule the currently configured optimization as a job.");
|
||||||
//scheduleButton.setBorderPainted(false);
|
//scheduleButton.setBorderPainted(false);
|
||||||
@@ -139,7 +141,7 @@ public class EvAModuleButtonPanelMaker implements OptimizationStateListener, Ser
|
|||||||
stopButton.setEnabled(true);
|
stopButton.setEnabled(true);
|
||||||
runButton.setEnabled(false);
|
runButton.setEnabled(false);
|
||||||
postProcessButton.setEnabled(false);
|
postProcessButton.setEnabled(false);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
System.err.print("Error in run: " + ex + " : " + ex.getMessage());
|
System.err.print("Error in run: " + ex + " : " + ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ package eva2.gui;
|
|||||||
|
|
||||||
import eva2.optimization.go.InterfaceNotifyOnInformers;
|
import eva2.optimization.go.InterfaceNotifyOnInformers;
|
||||||
import eva2.optimization.problems.InterfaceAdditionalPopulationInformer;
|
import eva2.optimization.problems.InterfaceAdditionalPopulationInformer;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
@@ -71,7 +72,7 @@ public class EvATabbedFrameMaker implements Serializable, PanelMaker, InterfaceN
|
|||||||
tabbedPane.addTab(((JParaPanel) element).getName(), panel);
|
tabbedPane.addTab(((JParaPanel) element).getName(), panel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < tabbedPane.getTabCount(); i++) {
|
for (int i = 0; i < tabbedPane.getTabCount(); i++) {
|
||||||
tabbedPane.setTabComponentAt(i, new ClosableTabComponent(tabbedPane, tabToolBar));
|
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
|
* @return The toolbar with control buttons
|
||||||
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
public JExtToolBar getToolBar() {
|
public JExtToolBar getToolBar() {
|
||||||
return extToolBar;
|
return extToolBar;
|
||||||
@@ -151,16 +152,16 @@ public class EvATabbedFrameMaker implements Serializable, PanelMaker, InterfaceN
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Component to be used as tabComponent;
|
* Component to be used as tabComponent;
|
||||||
* Contains a JLabel to show the text and
|
* Contains a JLabel to show the text and
|
||||||
* a JButton to close the tab it belongs to
|
* a JButton to close the tab it belongs to
|
||||||
*/
|
*/
|
||||||
class ClosableTabComponent extends JPanel {
|
class ClosableTabComponent extends JPanel {
|
||||||
private final JTabbedPane pane;
|
private final JTabbedPane pane;
|
||||||
private final JToolBar toolBar;
|
private final JToolBar toolBar;
|
||||||
|
|
||||||
public ClosableTabComponent(final JTabbedPane pane, final JToolBar toolBar) {
|
public ClosableTabComponent(final JTabbedPane pane, final JToolBar toolBar) {
|
||||||
super(new FlowLayout(FlowLayout.LEADING, 0, 0));
|
super(new FlowLayout(FlowLayout.LEADING, 0, 0));
|
||||||
|
|
||||||
if (pane == null) {
|
if (pane == null) {
|
||||||
throw new NullPointerException("TabbedPane is null");
|
throw new NullPointerException("TabbedPane is null");
|
||||||
}
|
}
|
||||||
@@ -168,7 +169,7 @@ class ClosableTabComponent extends JPanel {
|
|||||||
this.toolBar = toolBar;
|
this.toolBar = toolBar;
|
||||||
this.toolBar.setVisible(false);
|
this.toolBar.setVisible(false);
|
||||||
setOpaque(false);
|
setOpaque(false);
|
||||||
|
|
||||||
//make JLabel read titles from JTabbedPane
|
//make JLabel read titles from JTabbedPane
|
||||||
JLabel label = new JLabel() {
|
JLabel label = new JLabel() {
|
||||||
@Override
|
@Override
|
||||||
@@ -180,18 +181,18 @@ class ClosableTabComponent extends JPanel {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
add(label);
|
add(label);
|
||||||
//add more space between the label and the button
|
//add more space between the label and the button
|
||||||
label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
|
label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
|
||||||
//tab button
|
//tab button
|
||||||
JButton button = new TabButton();
|
JButton button = new TabButton();
|
||||||
|
|
||||||
add(button);
|
add(button);
|
||||||
//add more space to the top of the component
|
//add more space to the top of the component
|
||||||
setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0));
|
setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TabButton extends JButton implements ActionListener {
|
private class TabButton extends JButton implements ActionListener {
|
||||||
public TabButton() {
|
public TabButton() {
|
||||||
int size = 17;
|
int size = 17;
|
||||||
@@ -212,7 +213,7 @@ class ClosableTabComponent extends JPanel {
|
|||||||
//Close the proper tab by clicking the button
|
//Close the proper tab by clicking the button
|
||||||
addActionListener(this);
|
addActionListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
int i = pane.indexOfTabComponent(ClosableTabComponent.this);
|
int i = pane.indexOfTabComponent(ClosableTabComponent.this);
|
||||||
@@ -220,9 +221,9 @@ class ClosableTabComponent extends JPanel {
|
|||||||
final String tabTitle = pane.getTitleAt(i);
|
final String tabTitle = pane.getTitleAt(i);
|
||||||
final Component tabPane = pane.getComponentAt(i);
|
final Component tabPane = pane.getComponentAt(i);
|
||||||
final int tabPosition = i;
|
final int tabPosition = i;
|
||||||
|
|
||||||
pane.remove(i);
|
pane.remove(i);
|
||||||
if(pane.getTabCount() == 0) {
|
if (pane.getTabCount() == 0) {
|
||||||
pane.setVisible(false);
|
pane.setVisible(false);
|
||||||
}
|
}
|
||||||
/* Create a button to be shown in the ToolBar */
|
/* Create a button to be shown in the ToolBar */
|
||||||
@@ -233,33 +234,33 @@ class ClosableTabComponent extends JPanel {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
/* Add the Tab Panel again */
|
/* Add the Tab Panel again */
|
||||||
// ToDo: Fix indexing problem
|
// ToDo: Fix indexing problem
|
||||||
pane.insertTab(tabTitle, null, tabPane, "", tabPosition);
|
pane.insertTab(tabTitle, null, tabPane, "", tabPosition);
|
||||||
/* Set the tab component (closable) */
|
/* Set the tab component (closable) */
|
||||||
pane.setTabComponentAt(tabPosition, ClosableTabComponent.this);
|
pane.setTabComponentAt(tabPosition, ClosableTabComponent.this);
|
||||||
pane.setVisible(true);
|
pane.setVisible(true);
|
||||||
/* Remove the Button */
|
/* Remove the Button */
|
||||||
toolBar.remove((Component)e.getSource());
|
toolBar.remove((Component) e.getSource());
|
||||||
/* If the Button was the last one, hide ToolBar again */
|
/* If the Button was the last one, hide ToolBar again */
|
||||||
if(toolBar.getComponentCount() == 0) {
|
if (toolBar.getComponentCount() == 0) {
|
||||||
toolBar.setVisible(false);
|
toolBar.setVisible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
/* Add it to the ToolBar */
|
/* Add it to the ToolBar */
|
||||||
if(!toolBar.isVisible()) {
|
if (!toolBar.isVisible()) {
|
||||||
toolBar.setVisible(true);
|
toolBar.setVisible(true);
|
||||||
}
|
}
|
||||||
toolBar.add(tabButton);
|
toolBar.add(tabButton);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//we don't want to update UI for this button
|
//we don't want to update UI for this button
|
||||||
@Override
|
@Override
|
||||||
public void updateUI() {
|
public void updateUI() {
|
||||||
}
|
}
|
||||||
|
|
||||||
//paint the cross
|
//paint the cross
|
||||||
@Override
|
@Override
|
||||||
protected void paintComponent(Graphics g) {
|
protected void paintComponent(Graphics g) {
|
||||||
@@ -277,7 +278,7 @@ class ClosableTabComponent extends JPanel {
|
|||||||
g2.dispose();
|
g2.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static MouseListener buttonMouseListener = new MouseAdapter() {
|
private final static MouseListener buttonMouseListener = new MouseAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void mouseEntered(MouseEvent e) {
|
public void mouseEntered(MouseEvent e) {
|
||||||
@@ -287,7 +288,7 @@ class ClosableTabComponent extends JPanel {
|
|||||||
button.setBorderPainted(true);
|
button.setBorderPainted(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseExited(MouseEvent e) {
|
public void mouseExited(MouseEvent e) {
|
||||||
Component component = e.getComponent();
|
Component component = e.getComponent();
|
||||||
|
|||||||
@@ -8,85 +8,83 @@ import javax.swing.tree.DefaultMutableTreeNode;
|
|||||||
* OptimizationParameters object, however this is not necessary.
|
* OptimizationParameters object, however this is not necessary.
|
||||||
* The tree is constructed using the reflection functionality of PropertySheetPanel
|
* The tree is constructed using the reflection functionality of PropertySheetPanel
|
||||||
* which is also used to generate the nested panels for parameter configuration.
|
* which is also used to generate the nested panels for parameter configuration.
|
||||||
*
|
*
|
||||||
|
* @author mkron
|
||||||
* @see PropertySheetPanel
|
* @see PropertySheetPanel
|
||||||
* @see GOParameters
|
* @see GOParameters
|
||||||
* @author mkron
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class EvATreeNode extends DefaultMutableTreeNode {
|
public class EvATreeNode extends DefaultMutableTreeNode {
|
||||||
private String[] childrenNames = null;
|
private String[] childrenNames = null;
|
||||||
private Object[] childrenValues = null;
|
private Object[] childrenValues = null;
|
||||||
private String myName="EvATreeNode";
|
private String myName = "EvATreeNode";
|
||||||
private boolean doListPrimitives=false;
|
private boolean doListPrimitives = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A default constructor setting the name and target object of
|
* A default constructor setting the name and target object of
|
||||||
* the tree. The children are generated immediately.
|
* the tree. The children are generated immediately.
|
||||||
* The node label is constructed from the name String and the
|
* The node label is constructed from the name String and the
|
||||||
* information retrieved from the target object if it implements the getName method.
|
* information retrieved from the target object if it implements the getName method.
|
||||||
*
|
*
|
||||||
* @param name title of the node
|
* @param name title of the node
|
||||||
* @param target
|
* @param target
|
||||||
*/
|
*/
|
||||||
public EvATreeNode(String name, Object target) {
|
public EvATreeNode(String name, Object target) {
|
||||||
super(target);
|
super(target);
|
||||||
myName = name;
|
myName = name;
|
||||||
setObject(target, true);
|
setObject(target, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the target object of the tree. Note that the name is not automatically
|
* 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
|
* updated and may be out of date if the new target object is incompatible to the
|
||||||
* old name.
|
* old name.
|
||||||
*
|
*
|
||||||
* @param target the new target object
|
* @param target the new target object
|
||||||
* @param expand should be true to generate child nodes immediately
|
* @param expand should be true to generate child nodes immediately
|
||||||
*/
|
*/
|
||||||
public void setObject(Object target, boolean expand) {
|
public void setObject(Object target, boolean expand) {
|
||||||
super.setUserObject(target);
|
super.setUserObject(target);
|
||||||
childrenNames = PropertySheetPanel.getPropertyNames(target);
|
childrenNames = PropertySheetPanel.getPropertyNames(target);
|
||||||
childrenValues = PropertySheetPanel.getPropertyValues(target, true, true, true);
|
childrenValues = PropertySheetPanel.getPropertyValues(target, true, true, true);
|
||||||
super.removeAllChildren();
|
super.removeAllChildren();
|
||||||
if (expand) {
|
if (expand) {
|
||||||
initChildren();
|
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) {
|
@Override
|
||||||
myName=name;
|
public String toString() {
|
||||||
}
|
String extendedInfo = null;
|
||||||
|
try {
|
||||||
public String getName() {
|
extendedInfo = (String) BeanInspector.callIfAvailable(this.getUserObject(), "getName", new Object[]{});
|
||||||
return myName;
|
} catch (Exception e) {
|
||||||
}
|
extendedInfo = null;
|
||||||
|
}
|
||||||
/**
|
if (extendedInfo != null) {
|
||||||
* Actually create child nodes.
|
return myName + " - " + extendedInfo;
|
||||||
*/
|
} else {
|
||||||
private void initChildren() {
|
return myName;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,68 +12,69 @@ import javax.swing.tree.TreePath;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Listener for use with the EvATreeNode class. It implements both the tree selection listener
|
* 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
|
* and the property change listener to
|
||||||
* react to changes in the parameters (and update the tree).
|
* react to changes in the parameters (and update the tree).
|
||||||
* @author mkron
|
|
||||||
*
|
*
|
||||||
|
* @author mkron
|
||||||
*/
|
*/
|
||||||
public class EvATreeSelectionListener implements TreeSelectionListener, PropertyChangeListener {
|
public class EvATreeSelectionListener implements TreeSelectionListener, PropertyChangeListener {
|
||||||
private PropertyEditor goe=null;
|
private PropertyEditor goe = null;
|
||||||
private EvATreeNode root = null;
|
private EvATreeNode root = null;
|
||||||
private JTree jtree = null;
|
private JTree jtree = null;
|
||||||
public static final boolean TRACE = true;
|
public static final boolean TRACE = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a tree listener and hook it up in the editor to listen to parameter changes
|
* Create a tree listener and hook it up in the editor to listen to parameter changes
|
||||||
* and in the JTree to update it.
|
* and in the JTree to update it.
|
||||||
*
|
*
|
||||||
* @param rootNode the root node of the tree
|
* @param rootNode the root node of the tree
|
||||||
* @param goEditor the editor containing the parameter panel
|
* @param goEditor the editor containing the parameter panel
|
||||||
* @param jt the GUI view of the tree
|
* @param jt the GUI view of the tree
|
||||||
*/
|
*/
|
||||||
public EvATreeSelectionListener(EvATreeNode rootNode, PropertyEditor goEditor, JTree jt) {
|
public EvATreeSelectionListener(EvATreeNode rootNode, PropertyEditor goEditor, JTree jt) {
|
||||||
goe = goEditor;
|
goe = goEditor;
|
||||||
root = rootNode;
|
root = rootNode;
|
||||||
jtree = jt;
|
jtree = jt;
|
||||||
|
|
||||||
if (jtree!=null) {
|
if (jtree != null) {
|
||||||
jtree.addTreeSelectionListener(this);
|
jtree.addTreeSelectionListener(this);
|
||||||
} // listen to tree selection changes
|
} // listen to tree selection changes
|
||||||
if (goEditor!=null) {
|
if (goEditor != null) {
|
||||||
goEditor.addPropertyChangeListener(this);
|
goEditor.addPropertyChangeListener(this);
|
||||||
} // listen to changes to the parameters
|
} // listen to changes to the parameters
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void valueChanged(TreeSelectionEvent e) {
|
public void valueChanged(TreeSelectionEvent e) {
|
||||||
if (TRACE) {
|
if (TRACE) {
|
||||||
System.out.println("valueChanged to " + BeanInspector.toString(e.getPath()));
|
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) {
|
EvATreeNode leafNode = (EvATreeNode) tp.getLastPathComponent();
|
||||||
for (int i=tp.getPathCount()-1; i>=0; i--) {
|
|
||||||
System.out.println("* " + i + " " + tp.getPathComponent(i));
|
|
||||||
} }
|
|
||||||
EvATreeNode leafNode = (EvATreeNode)tp.getLastPathComponent();
|
|
||||||
// goe.setValue(leafNode.getUserObject());
|
// goe.setValue(leafNode.getUserObject());
|
||||||
Component editComp = goe.getCustomEditor();
|
Component editComp = goe.getCustomEditor();
|
||||||
if (editComp instanceof GOEPanel) {
|
if (editComp instanceof GOEPanel) {
|
||||||
// update the object in the main GOEPanel
|
// update the object in the main GOEPanel
|
||||||
((GOEPanel)editComp).setTarget(leafNode.getUserObject());
|
((GOEPanel) editComp).setTarget(leafNode.getUserObject());
|
||||||
} else {
|
} else {
|
||||||
System.err.println("Error, unable to notify custom editor of type " + editComp.getClass() + ", expected GOEPanel (EvATreeSelectionListener)");
|
System.err.println("Error, unable to notify custom editor of type " + editComp.getClass() + ", expected GOEPanel (EvATreeSelectionListener)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void propertyChange(PropertyChangeEvent evt) {
|
public void propertyChange(PropertyChangeEvent evt) {
|
||||||
if (TRACE) {
|
if (TRACE) {
|
||||||
System.out.println("EvATreeNode received change event " + evt);
|
System.out.println("EvATreeNode received change event " + evt);
|
||||||
}
|
}
|
||||||
root.setObject(evt.getNewValue(), true);
|
root.setObject(evt.getNewValue(), true);
|
||||||
if (jtree !=null) {
|
if (jtree != null) {
|
||||||
jtree.setModel(new DefaultTreeModel(root));
|
jtree.setModel(new DefaultTreeModel(root));
|
||||||
} // TODO this should be done differently so that the tree is not collapsed on each change!
|
} // TODO this should be done differently so that the tree is not collapsed on each change!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,67 +3,66 @@ package eva2.gui;
|
|||||||
import eva2.tools.chart2d.DFunction;
|
import eva2.tools.chart2d.DFunction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an exponential scaling function.
|
* Represents an exponential scaling function.
|
||||||
* MK: added a guard against undefined values: the smallest positive position can
|
* MK: added a guard against undefined values: the smallest positive position can
|
||||||
* be stored and used instead of invalid points.
|
* be stored and used instead of invalid points.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class Exp extends DFunction {
|
public class Exp extends DFunction {
|
||||||
private double minValue = 1e-10; // think of a minimal value we want to show in case invalid (<=0) values are requested
|
private double minValue = 1e-10; // think of a minimal value we want to show in case invalid (<=0) values are requested
|
||||||
|
|
||||||
public void setMinValue(double v) {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
public void setMinValue(double v) {
|
||||||
* (non-Javadoc)
|
if (v > 0) {
|
||||||
* @see eva2.tools.chart2d.DFunction#isInvertibleAt(double)
|
minValue = v;
|
||||||
*/
|
} else {
|
||||||
@Override
|
System.err.println("Error, minimal value for Exp must be positive!");
|
||||||
public boolean isInvertibleAt(double image) {
|
}
|
||||||
return image > 0;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see eva2.tools.chart2d.DFunction#getImageOf(double)
|
* @see eva2.tools.chart2d.DFunction#isDefinedAt(double)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public double getImageOf(double source) {
|
public boolean isDefinedAt(double source) {
|
||||||
return Math.exp(source);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see eva2.tools.chart2d.DFunction#getSourceOf(double)
|
* @see eva2.tools.chart2d.DFunction#isInvertibleAt(double)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public double getSourceOf(double target) {
|
public boolean isInvertibleAt(double image) {
|
||||||
if (target <= 0) {
|
return image > 0;
|
||||||
return Math.log(minValue); // think of a minimal value we want to show in case invalid values are requested
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (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(
|
// throw new IllegalArgumentException(
|
||||||
// "Can not calculate log on values smaller than or equal 0 --> target = "
|
// "Can not calculate log on values smaller than or equal 0 --> target = "
|
||||||
// + target);
|
// + target);
|
||||||
}
|
}
|
||||||
return Math.log(target);
|
return Math.log(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateMinValue(double y) {
|
public void updateMinValue(double y) {
|
||||||
if (y<minValue && (y>0)) {
|
if (y < minValue && (y > 0)) {
|
||||||
minValue=y;
|
minValue = y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,60 +12,67 @@ package eva2.gui;
|
|||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
* IMPORTS
|
* IMPORTS
|
||||||
*==========================================================================*/
|
*==========================================================================*/
|
||||||
|
|
||||||
import javax.swing.AbstractAction;
|
import javax.swing.AbstractAction;
|
||||||
import javax.swing.Action;
|
import javax.swing.Action;
|
||||||
import javax.swing.Icon;
|
import javax.swing.Icon;
|
||||||
import javax.swing.KeyStroke;
|
import javax.swing.KeyStroke;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class ExtAction extends AbstractAction {
|
public abstract class ExtAction extends AbstractAction {
|
||||||
public final static String CAPTION = "Caption";
|
public final static String CAPTION = "Caption";
|
||||||
public final static String MNEMONIC = "Mnemonic";
|
public final static String MNEMONIC = "Mnemonic";
|
||||||
public final static String TOOLTIP = "ToolTip";
|
public final static String TOOLTIP = "ToolTip";
|
||||||
public final static String KEYSTROKE = "KeyStroke";
|
public final static String KEYSTROKE = "KeyStroke";
|
||||||
/**
|
|
||||||
*
|
/**
|
||||||
*/
|
*
|
||||||
private void setValues(String s, String toolTip){
|
*/
|
||||||
Mnemonic m = new Mnemonic(s);
|
private void setValues(String s, String toolTip) {
|
||||||
putValue(MNEMONIC, new Character(m.getMnemonic()));
|
Mnemonic m = new Mnemonic(s);
|
||||||
putValue(Action.NAME, m.getText());
|
putValue(MNEMONIC, new Character(m.getMnemonic()));
|
||||||
putValue(TOOLTIP, toolTip);
|
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) {
|
public ExtAction(String s, Icon i, String toolTip, KeyStroke key) {
|
||||||
System.out.println("Icon == null");
|
this(s, i, toolTip);
|
||||||
}
|
if (i == null) {
|
||||||
putValue(KEYSTROKE, key);
|
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");
|
public ExtAction(String s, Icon i, String toolTip) {
|
||||||
}
|
super(null, i);
|
||||||
setValues(s, toolTip);
|
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, KeyStroke key) {
|
||||||
*
|
this(s, toolTip);
|
||||||
*/
|
putValue(KEYSTROKE, key);
|
||||||
public ExtAction(String s, String toolTip){
|
}
|
||||||
super();
|
|
||||||
setValues(s, toolTip);
|
/**
|
||||||
}
|
*
|
||||||
|
*/
|
||||||
|
public ExtAction(String s, String toolTip) {
|
||||||
|
super();
|
||||||
|
setValues(s, toolTip);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,30 +12,35 @@ package eva2.gui;
|
|||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
* IMPORTS
|
* IMPORTS
|
||||||
*==========================================================================*/
|
*==========================================================================*/
|
||||||
|
|
||||||
import java.beans.PropertyChangeEvent;
|
import java.beans.PropertyChangeEvent;
|
||||||
import java.beans.PropertyChangeListener;
|
import java.beans.PropertyChangeListener;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class ExtActionChangedListener implements PropertyChangeListener{
|
public abstract class ExtActionChangedListener implements PropertyChangeListener {
|
||||||
protected JComponent component;
|
protected JComponent component;
|
||||||
/**
|
|
||||||
*
|
/**
|
||||||
*/
|
*
|
||||||
ExtActionChangedListener(JComponent c){
|
*/
|
||||||
super();
|
ExtActionChangedListener(JComponent c) {
|
||||||
setTarget(c);
|
super();
|
||||||
}
|
setTarget(c);
|
||||||
/**
|
}
|
||||||
*
|
|
||||||
*/
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public abstract void propertyChange(PropertyChangeEvent e);
|
public abstract void propertyChange(PropertyChangeEvent e);
|
||||||
/**
|
|
||||||
*
|
/**
|
||||||
*/
|
*
|
||||||
public void setTarget(JComponent c){
|
*/
|
||||||
component = c;
|
public void setTarget(JComponent c) {
|
||||||
}
|
component = c;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ package eva2.gui;
|
|||||||
* $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $
|
* $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $
|
||||||
* $Author: streiche $
|
* $Author: streiche $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.Event;
|
import java.awt.Event;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@@ -22,7 +23,7 @@ import javax.swing.KeyStroke;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ExtDesktopManager extends DefaultDesktopManager {
|
public class ExtDesktopManager extends DefaultDesktopManager {
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(ExtDesktopManager.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(ExtDesktopManager.class.getName());
|
||||||
|
|
||||||
int WINDOW_LIST_START;
|
int WINDOW_LIST_START;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import eva2.optimization.tools.FileTools;
|
|||||||
import eva2.tools.BasicResourceLoader;
|
import eva2.tools.BasicResourceLoader;
|
||||||
import eva2.tools.EVAHELP;
|
import eva2.tools.EVAHELP;
|
||||||
import eva2.tools.SerializedObject;
|
import eva2.tools.SerializedObject;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
@@ -29,7 +30,7 @@ import javax.swing.plaf.basic.BasicComboBoxRenderer;
|
|||||||
public class GOEPanel extends JPanel implements ItemListener {
|
public class GOEPanel extends JPanel implements ItemListener {
|
||||||
|
|
||||||
private Object backupObject;
|
private Object backupObject;
|
||||||
private PropertyChangeSupport propChangeSupport;
|
private PropertyChangeSupport propChangeSupport;
|
||||||
/**
|
/**
|
||||||
* The chooser component
|
* The chooser component
|
||||||
*/
|
*/
|
||||||
@@ -97,11 +98,11 @@ public class GOEPanel extends JPanel implements ItemListener {
|
|||||||
propertySheetPanel = new PropertySheetPanel();
|
propertySheetPanel = new PropertySheetPanel();
|
||||||
propertySheetPanel.addPropertyChangeListener(
|
propertySheetPanel.addPropertyChangeListener(
|
||||||
new PropertyChangeListener() {
|
new PropertyChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void propertyChange(final PropertyChangeEvent event) {
|
public void propertyChange(final PropertyChangeEvent event) {
|
||||||
propChangeSupport.firePropertyChange("", backupObject, genericObjectEditor.getValue());
|
propChangeSupport.firePropertyChange("", backupObject, genericObjectEditor.getValue());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
openButton = makeIconButton("images/Open16.gif", "Open");
|
openButton = makeIconButton("images/Open16.gif", "Open");
|
||||||
openButton.setToolTipText("Load a configured object");
|
openButton.setToolTipText("Load a configured object");
|
||||||
openButton.setEnabled(true);
|
openButton.setEnabled(true);
|
||||||
@@ -409,8 +410,8 @@ public class GOEPanel extends JPanel implements ItemListener {
|
|||||||
objectChooser.setSelectedIndex(0);
|
objectChooser.setSelectedIndex(0);
|
||||||
JOptionPane.showMessageDialog(this,
|
JOptionPane.showMessageDialog(this,
|
||||||
"Could not create an example of\n"
|
"Could not create an example of\n"
|
||||||
+ className + "\n"
|
+ className + "\n"
|
||||||
+ "from the current classpath. Is the resource folder at the right place?\nIs the class abstract or the default constructor missing?",
|
+ "from the current classpath. Is the resource folder at the right place?\nIs the class abstract or the default constructor missing?",
|
||||||
"GenericObjectEditor",
|
"GenericObjectEditor",
|
||||||
JOptionPane.ERROR_MESSAGE);
|
JOptionPane.ERROR_MESSAGE);
|
||||||
EVAHELP.getSystemPropertyString();
|
EVAHELP.getSystemPropertyString();
|
||||||
@@ -431,7 +432,7 @@ class ToolTipComboBoxRenderer extends BasicComboBoxRenderer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component getListCellRendererComponent(JList list, Object value,
|
public Component getListCellRendererComponent(JList list, Object value,
|
||||||
int index, boolean isSelected, boolean cellHasFocus) {
|
int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
if (isSelected) {
|
if (isSelected) {
|
||||||
setBackground(list.getSelectionBackground());
|
setBackground(list.getSelectionBackground());
|
||||||
setForeground(list.getSelectionForeground());
|
setForeground(list.getSelectionForeground());
|
||||||
|
|||||||
@@ -9,8 +9,10 @@ package eva2.gui;
|
|||||||
* $Date: 2007-10-23 16:58:12 +0200 (Tue, 23 Oct 2007) $
|
* $Date: 2007-10-23 16:58:12 +0200 (Tue, 23 Oct 2007) $
|
||||||
* $Author: mkron $
|
* $Author: mkron $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import eva2.EvAInfo;
|
import eva2.EvAInfo;
|
||||||
import eva2.tools.BasicResourceLoader;
|
import eva2.tools.BasicResourceLoader;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
@@ -25,48 +27,53 @@ import javax.swing.event.HyperlinkEvent;
|
|||||||
import javax.swing.event.HyperlinkListener;
|
import javax.swing.event.HyperlinkListener;
|
||||||
import javax.swing.text.html.HTMLDocument;
|
import javax.swing.text.html.HTMLDocument;
|
||||||
import javax.swing.text.html.HTMLFrameHyperlinkEvent;
|
import javax.swing.text.html.HTMLFrameHyperlinkEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class HtmlDemo {
|
public class HtmlDemo {
|
||||||
private JEditorPane m_html;
|
private JEditorPane m_html;
|
||||||
private String m_name;
|
private String m_name;
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public HtmlDemo(String name) {
|
|
||||||
m_name = name;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public JEditorPane getPane() {
|
|
||||||
return m_html;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
public HtmlDemo(String name) {
|
||||||
|
m_name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public JEditorPane getPane() {
|
||||||
|
return m_html;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
HtmlDemo demo = new HtmlDemo("ES.html");
|
HtmlDemo demo = new HtmlDemo("ES.html");
|
||||||
demo.show();
|
demo.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean resourceExists() {
|
public boolean resourceExists() {
|
||||||
URL url = ClassLoader.getSystemResource("html/"+m_name);
|
URL url = ClassLoader.getSystemResource("html/" + m_name);
|
||||||
return (url != null);
|
return (url != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean resourceExists(String mname) {
|
public static boolean resourceExists(String mname) {
|
||||||
URL url = ClassLoader.getSystemResource("html/"+mname);
|
URL url = ClassLoader.getSystemResource("html/" + mname);
|
||||||
return (url != null);
|
return (url != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void show() {
|
public void show() {
|
||||||
try {
|
try {
|
||||||
URL url = null;
|
URL url = null;
|
||||||
url = this.getClass().getClassLoader().getSystemResource("html/"+m_name);
|
url = this.getClass().getClassLoader().getSystemResource("html/" + m_name);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
m_html = new JEditorPane(url);
|
m_html = new JEditorPane(url);
|
||||||
@@ -86,39 +93,39 @@ public class HtmlDemo {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JFrame frame = new JFrame (m_name);
|
JFrame frame = new JFrame(m_name);
|
||||||
BasicResourceLoader loader = BasicResourceLoader.instance();
|
BasicResourceLoader loader = BasicResourceLoader.instance();
|
||||||
byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation, true);
|
byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation, true);
|
||||||
frame.setIconImage(Toolkit.getDefaultToolkit().createImage(bytes));
|
frame.setIconImage(Toolkit.getDefaultToolkit().createImage(bytes));
|
||||||
JScrollPane scroller = new JScrollPane();
|
JScrollPane scroller = new JScrollPane();
|
||||||
JViewport vp = scroller.getViewport();
|
JViewport vp = scroller.getViewport();
|
||||||
vp.add(m_html);
|
vp.add(m_html);
|
||||||
scroller.setPreferredSize( new Dimension(600,500) );
|
scroller.setPreferredSize(new Dimension(600, 500));
|
||||||
frame.getContentPane().add(scroller, BorderLayout.CENTER);
|
frame.getContentPane().add(scroller, BorderLayout.CENTER);
|
||||||
frame.pack();
|
frame.pack();
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public HyperlinkListener createHyperLinkListener() {
|
public HyperlinkListener createHyperLinkListener() {
|
||||||
return new HyperlinkListener() {
|
return new HyperlinkListener() {
|
||||||
@Override
|
@Override
|
||||||
public void hyperlinkUpdate(HyperlinkEvent e) {
|
public void hyperlinkUpdate(HyperlinkEvent e) {
|
||||||
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
|
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
|
||||||
if (e instanceof HTMLFrameHyperlinkEvent) {
|
if (e instanceof HTMLFrameHyperlinkEvent) {
|
||||||
((HTMLDocument)m_html.getDocument()).processHTMLFrameHyperlinkEvent(
|
((HTMLDocument) m_html.getDocument()).processHTMLFrameHyperlinkEvent(
|
||||||
(HTMLFrameHyperlinkEvent)e);
|
(HTMLFrameHyperlinkEvent) e);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
m_html.setPage(e.getURL());
|
m_html.setPage(e.getURL());
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
System.out.println("IOE: " + ioe);
|
System.out.println("IOE: " + ioe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,28 +12,37 @@ import eva2.optimization.mocco.paretofrontviewer.InterfaceRefSolutionListener;
|
|||||||
*/
|
*/
|
||||||
public interface InterfaceSelectablePointIcon {
|
public interface InterfaceSelectablePointIcon {
|
||||||
|
|
||||||
/** This method allows to add a selection listner to the PointIcon
|
/**
|
||||||
|
* This method allows to add a selection listner to the PointIcon
|
||||||
* it should need more than one listener to this abstruse event
|
* it should need more than one listener to this abstruse event
|
||||||
|
*
|
||||||
* @param a The selection listener
|
* @param a The selection listener
|
||||||
*/
|
*/
|
||||||
public void addSelectionListener(InterfaceRefSolutionListener a);
|
public void addSelectionListener(InterfaceRefSolutionListener a);
|
||||||
|
|
||||||
/** This method allows to remove the selection listner to the PointIcon
|
/**
|
||||||
|
* This method allows to remove the selection listner to the PointIcon
|
||||||
*/
|
*/
|
||||||
public void removeSelectionListeners();
|
public void removeSelectionListeners();
|
||||||
|
|
||||||
/** This method returns the selection listner to the PointIcon
|
/**
|
||||||
|
* This method returns the selection listner to the PointIcon
|
||||||
|
*
|
||||||
* @return InterfacePointIconSelectionListener
|
* @return InterfacePointIconSelectionListener
|
||||||
*/
|
*/
|
||||||
public InterfaceRefSolutionListener getSelectionListener();
|
public InterfaceRefSolutionListener getSelectionListener();
|
||||||
|
|
||||||
/** Of course the PointIcon needs a reference to the individual
|
/**
|
||||||
|
* Of course the PointIcon needs a reference to the individual
|
||||||
* otherwise it can't tell the listener what has been selected.
|
* otherwise it can't tell the listener what has been selected.
|
||||||
|
*
|
||||||
* @param indy
|
* @param indy
|
||||||
*/
|
*/
|
||||||
public void setEAIndividual(AbstractEAIndividual indy);
|
public void setEAIndividual(AbstractEAIndividual indy);
|
||||||
|
|
||||||
/** This method allows you to get the EAIndividual the icon stands for
|
/**
|
||||||
|
* This method allows you to get the EAIndividual the icon stands for
|
||||||
|
*
|
||||||
* @return AbstractEAIndividual
|
* @return AbstractEAIndividual
|
||||||
*/
|
*/
|
||||||
public AbstractEAIndividual getEAIndividual();
|
public AbstractEAIndividual getEAIndividual();
|
||||||
|
|||||||
@@ -9,89 +9,102 @@ package eva2.gui;
|
|||||||
* $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $
|
* $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $
|
||||||
* $Author: streiche $
|
* $Author: streiche $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import javax.swing.JInternalFrame;
|
import javax.swing.JInternalFrame;
|
||||||
import javax.swing.JMenu;
|
import javax.swing.JMenu;
|
||||||
import javax.swing.JToolBar;
|
import javax.swing.JToolBar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class JDocFrame extends JInternalFrame{
|
public abstract class JDocFrame extends JInternalFrame {
|
||||||
private File m_file;
|
private File m_file;
|
||||||
private String titleStr;
|
private String titleStr;
|
||||||
protected boolean changed = false;
|
protected boolean changed = false;
|
||||||
/**
|
|
||||||
*
|
/**
|
||||||
*/
|
*
|
||||||
public JDocFrame(String title){
|
*/
|
||||||
super(title, true, true /* not closable*/, true, true);
|
public JDocFrame(String title) {
|
||||||
titleStr = 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();
|
|
||||||
}
|
}
|
||||||
setChangedImpl(false);
|
|
||||||
}
|
/**
|
||||||
/**
|
*
|
||||||
*
|
*/
|
||||||
*/
|
public JDocFrame(File file) {
|
||||||
private void setChangedImpl(boolean value){
|
this(file.getName());
|
||||||
changed = value;
|
m_file = file;
|
||||||
if(changed) {
|
}
|
||||||
setTitle(titleStr + " *");
|
|
||||||
}
|
/**
|
||||||
else {
|
*
|
||||||
setTitle(titleStr);
|
*/
|
||||||
}
|
public File getFile() {
|
||||||
}
|
return m_file;
|
||||||
/**
|
}
|
||||||
*
|
|
||||||
*/
|
/**
|
||||||
protected void setChanged(boolean value){
|
*
|
||||||
if(changed != value) {
|
*/
|
||||||
setChangedImpl(value);
|
public String getFileTitle() {
|
||||||
}
|
return titleStr;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
*
|
/**
|
||||||
*/
|
*
|
||||||
public boolean isChanged(){
|
*/
|
||||||
return changed;
|
public void save() {
|
||||||
}
|
if (m_file != null) {
|
||||||
public abstract String[] getActionGroups();
|
save(m_file);
|
||||||
public abstract JMenu getMenu(String group);
|
}
|
||||||
public abstract JToolBar getToolBar(String group);
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
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;
|
import javax.swing.event.InternalFrameListener;
|
||||||
|
|
||||||
public class JEFrame extends JInternalFrame {
|
public class JEFrame extends JInternalFrame {
|
||||||
private boolean closeAllOnClose = false;
|
private boolean closeAllOnClose = false;
|
||||||
|
|
||||||
public JEFrame() {
|
|
||||||
super();
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
public JEFrame(String name) {
|
public JEFrame() {
|
||||||
super(name);
|
super();
|
||||||
init();
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public JEFrame(String name) {
|
||||||
public void addInternalFrameListener(InternalFrameListener l) {
|
super(name);
|
||||||
super.addInternalFrameListener(l);
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init() {
|
/**
|
||||||
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
* Set to true if all registered JEFrames should be closed if this frame is closed.
|
||||||
|
*
|
||||||
this.addInternalFrameListener(new InternalFrameAdapter() {
|
* @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
|
@Override
|
||||||
public void internalFrameClosed(InternalFrameEvent e) {
|
public void internalFrameClosed(InternalFrameEvent e) {
|
||||||
super.internalFrameClosed(e);
|
super.internalFrameClosed(e);
|
||||||
JEFrameRegister.getInstance().unregister((JEFrame) e.getInternalFrame());
|
JEFrameRegister.getInstance().unregister((JEFrame) e.getInternalFrame());
|
||||||
if (closeAllOnClose) {
|
if (closeAllOnClose) {
|
||||||
JEFrameRegister.getInstance().closeAll();
|
JEFrameRegister.getInstance().closeAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -70,59 +70,59 @@ public class JEFrame extends JInternalFrame {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void internalFrameActivated(InternalFrameEvent e) {
|
public void internalFrameActivated(InternalFrameEvent e) {
|
||||||
JEFrameRegister.getInstance().register((JEFrame) e.getInternalFrame());
|
JEFrameRegister.getInstance().register((JEFrame) e.getInternalFrame());
|
||||||
super.internalFrameActivated(e);
|
super.internalFrameActivated(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
|
this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
|
||||||
KeyStroke.getKeyStroke(KeyEvent.VK_F, Event.CTRL_MASK),
|
KeyStroke.getKeyStroke(KeyEvent.VK_F, Event.CTRL_MASK),
|
||||||
"ctrlFpressed"
|
"ctrlFpressed"
|
||||||
);
|
);
|
||||||
this.getRootPane().getActionMap().put(
|
this.getRootPane().getActionMap().put(
|
||||||
"ctrlFpressed",
|
"ctrlFpressed",
|
||||||
new AbstractAction("ctrlFpressed") {
|
new AbstractAction("ctrlFpressed") {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent actionEvent) {
|
public void actionPerformed(ActionEvent actionEvent) {
|
||||||
JEFrameRegister.getInstance().getFrameList().get(0).toFront();
|
JEFrameRegister.getInstance().getFrameList().get(0).toFront();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
|
this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
|
||||||
KeyStroke.getKeyStroke(KeyEvent.VK_O, Event.CTRL_MASK),
|
KeyStroke.getKeyStroke(KeyEvent.VK_O, Event.CTRL_MASK),
|
||||||
"ctrlOpressed"
|
"ctrlOpressed"
|
||||||
);
|
);
|
||||||
this.getRootPane().getActionMap().put(
|
this.getRootPane().getActionMap().put(
|
||||||
"ctrlOpressed",
|
"ctrlOpressed",
|
||||||
new AbstractAction("ctrlOpressed") {
|
new AbstractAction("ctrlOpressed") {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent actionEvent) {
|
public void actionPerformed(ActionEvent actionEvent) {
|
||||||
java.util.List<JEFrame> frameList = JEFrameRegister.getInstance().getFrameList();
|
java.util.List<JEFrame> frameList = JEFrameRegister.getInstance().getFrameList();
|
||||||
for (JEFrame frame : frameList) {
|
for (JEFrame frame : frameList) {
|
||||||
frame.toFront();
|
frame.toFront();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
|
this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
|
||||||
KeyStroke.getKeyStroke(KeyEvent.VK_LESS , Event.CTRL_MASK),
|
KeyStroke.getKeyStroke(KeyEvent.VK_LESS, Event.CTRL_MASK),
|
||||||
"ctrlSmallerpressed"
|
"ctrlSmallerpressed"
|
||||||
);
|
);
|
||||||
final JEFrame self = this;
|
final JEFrame self = this;
|
||||||
this.getRootPane().getActionMap().put(
|
this.getRootPane().getActionMap().put(
|
||||||
"ctrlSmallerpressed",
|
"ctrlSmallerpressed",
|
||||||
new AbstractAction("ctrlSmallerpressed") {
|
new AbstractAction("ctrlSmallerpressed") {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent actionEvent) {
|
public void actionPerformed(ActionEvent actionEvent) {
|
||||||
JEFrameRegister.getInstance().setFocusToNext(self);
|
JEFrameRegister.getInstance().setFocusToNext(self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
this.setMaximizable(true);
|
this.setMaximizable(true);
|
||||||
this.setResizable(true);
|
this.setResizable(true);
|
||||||
this.setIconifiable(true);
|
this.setIconifiable(true);
|
||||||
this.setClosable(true);
|
this.setClosable(true);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
package eva2.gui;
|
package eva2.gui;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.swing.JDesktopPane;
|
import javax.swing.JDesktopPane;
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public class JExtDesktopPane extends JDesktopPane {
|
|||||||
*/
|
*/
|
||||||
public JExtDesktopPane() {
|
public JExtDesktopPane() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
windowMenu = new JExtMenu("&Windows");
|
windowMenu = new JExtMenu("&Windows");
|
||||||
desktopManager = new ExtDesktopManager(this);
|
desktopManager = new ExtDesktopManager(this);
|
||||||
setDesktopManager(desktopManager);
|
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)) {
|
KeyStroke.getKeyStroke(KeyEvent.VK_PERIOD, Event.CTRL_MASK)) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -89,10 +89,10 @@ public class JExtDesktopPane extends JDesktopPane {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to access the window actions.
|
* Method to access the window actions.
|
||||||
*
|
*
|
||||||
* @deprecated
|
|
||||||
* @param action The desired action (use JExtDesktopPane constants). Default is null
|
* @param action The desired action (use JExtDesktopPane constants). Default is null
|
||||||
* @return The ExtAction
|
* @return The ExtAction
|
||||||
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
public ExtAction getWindowAction(int action) {
|
public ExtAction getWindowAction(int action) {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package eva2.gui;
|
package eva2.gui;
|
||||||
|
|
||||||
import eva2.tools.ToolBoxGui;
|
import eva2.tools.ToolBoxGui;
|
||||||
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
@@ -8,19 +9,18 @@ import javax.swing.JToolBar;
|
|||||||
import javax.swing.SwingConstants;
|
import javax.swing.SwingConstants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author becker
|
* @author becker
|
||||||
*/
|
*/
|
||||||
public class JExtDesktopPaneToolBar extends JToolBar {
|
public class JExtDesktopPaneToolBar extends JToolBar {
|
||||||
|
|
||||||
private JExtDesktopPane desktopPane;
|
private JExtDesktopPane desktopPane;
|
||||||
|
|
||||||
public JExtDesktopPaneToolBar(JExtDesktopPane desktopPane) {
|
public JExtDesktopPaneToolBar(JExtDesktopPane desktopPane) {
|
||||||
this.desktopPane = desktopPane;
|
this.desktopPane = desktopPane;
|
||||||
|
|
||||||
initComponents();
|
initComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
/* We don't want the ToolBar to be draggable */
|
/* We don't want the ToolBar to be draggable */
|
||||||
setFloatable(false);
|
setFloatable(false);
|
||||||
@@ -33,10 +33,10 @@ public class JExtDesktopPaneToolBar extends JToolBar {
|
|||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
desktopPane.tileWindows(SwingConstants.VERTICAL);
|
desktopPane.tileWindows(SwingConstants.VERTICAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
add(verticalButton);
|
add(verticalButton);
|
||||||
|
|
||||||
JButton horizontalButton = ToolBoxGui.createIconifiedButton("images/TileHorizontal16.png", "Tile horizontally", false);
|
JButton horizontalButton = ToolBoxGui.createIconifiedButton("images/TileHorizontal16.png", "Tile horizontally", false);
|
||||||
horizontalButton.addActionListener(new ActionListener() {
|
horizontalButton.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
@@ -44,10 +44,10 @@ public class JExtDesktopPaneToolBar extends JToolBar {
|
|||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
desktopPane.tileWindows(SwingConstants.HORIZONTAL);
|
desktopPane.tileWindows(SwingConstants.HORIZONTAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
add(horizontalButton);
|
add(horizontalButton);
|
||||||
|
|
||||||
JButton cascadeButton = ToolBoxGui.createIconifiedButton("images/Cascade16.png", "Cascade windows", false);
|
JButton cascadeButton = ToolBoxGui.createIconifiedButton("images/Cascade16.png", "Cascade windows", false);
|
||||||
cascadeButton.addActionListener(new ActionListener() {
|
cascadeButton.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ public class JExtDesktopPaneToolBar extends JToolBar {
|
|||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
desktopPane.overlapWindows();
|
desktopPane.overlapWindows();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
add(cascadeButton);
|
add(cascadeButton);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,32 +12,33 @@ package eva2.gui;
|
|||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
* IMPORTS
|
* IMPORTS
|
||||||
*==========================================================================*/
|
*==========================================================================*/
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
public class JExtFileChooser extends JFileChooser{
|
public class JExtFileChooser extends JFileChooser {
|
||||||
private boolean overwriteWarning = true;
|
private boolean overwriteWarning = true;
|
||||||
|
|
||||||
public void setOverwriteWarning(boolean value){
|
public void setOverwriteWarning(boolean value) {
|
||||||
overwriteWarning = value;
|
overwriteWarning = value;
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getOverwriteWarning(){
|
|
||||||
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();
|
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) $
|
* $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $
|
||||||
* $Author: streiche $
|
* $Author: streiche $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.beans.PropertyChangeEvent;
|
import java.beans.PropertyChangeEvent;
|
||||||
import java.beans.PropertyChangeListener;
|
import java.beans.PropertyChangeListener;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class JExtToolBar extends JToolBar{
|
public class JExtToolBar extends JToolBar {
|
||||||
@Override
|
@Override
|
||||||
public JButton add(Action a){
|
public JButton add(Action a) {
|
||||||
JButton button = super.add(a);
|
JButton button = super.add(a);
|
||||||
button.setText(null);
|
button.setText(null);
|
||||||
button.setMargin(new Insets(0, 0, 0, 0));
|
button.setMargin(new Insets(0, 0, 0, 0));
|
||||||
|
|
||||||
Object o;
|
Object o;
|
||||||
o = a.getValue(ExtAction.TOOLTIP);
|
o = a.getValue(ExtAction.TOOLTIP);
|
||||||
String toolTip = o != null ? (String)o : "";
|
String toolTip = o != null ? (String) o : "";
|
||||||
|
|
||||||
o = a.getValue(ExtAction.KEYSTROKE);
|
o = a.getValue(ExtAction.KEYSTROKE);
|
||||||
button.setToolTipText(toolTip + getKeyText((KeyStroke)o));
|
button.setToolTipText(toolTip + getKeyText((KeyStroke) o));
|
||||||
|
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getKeyText(KeyStroke k){
|
private String getKeyText(KeyStroke k) {
|
||||||
StringBuffer result = new StringBuffer();
|
StringBuffer result = new StringBuffer();
|
||||||
|
|
||||||
if(k != null){
|
if (k != null) {
|
||||||
int modifiers = k.getModifiers();
|
int modifiers = k.getModifiers();
|
||||||
if(modifiers > 0) {
|
if (modifiers > 0) {
|
||||||
result.append(KeyEvent.getKeyModifiersText(modifiers) + "+");
|
result.append(KeyEvent.getKeyModifiersText(modifiers) + "+");
|
||||||
|
}
|
||||||
|
result.append(KeyEvent.getKeyText(k.getKeyCode()));
|
||||||
|
}
|
||||||
|
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
|
@Override
|
||||||
protected PropertyChangeListener createActionChangeListener(JButton b){
|
protected PropertyChangeListener createActionChangeListener(JButton b) {
|
||||||
return new ExtActionChangedListener(b){
|
return new ExtActionChangedListener(b) {
|
||||||
@Override
|
@Override
|
||||||
public void propertyChange(PropertyChangeEvent e){
|
public void propertyChange(PropertyChangeEvent e) {
|
||||||
JButton button = (JButton)component;
|
JButton button = (JButton) component;
|
||||||
|
|
||||||
String propertyName = e.getPropertyName();
|
String propertyName = e.getPropertyName();
|
||||||
if(propertyName.equals(Action.NAME)){
|
if (propertyName.equals(Action.NAME)) {
|
||||||
/* Nichts tun! */
|
/* Nichts tun! */
|
||||||
}
|
} else if (propertyName.equals("enabled")) {
|
||||||
else if(propertyName.equals("enabled")){
|
button.setEnabled(((Boolean) e.getNewValue()).booleanValue());
|
||||||
button.setEnabled(((Boolean)e.getNewValue()).booleanValue());
|
button.repaint();
|
||||||
button.repaint();
|
} else if (e.getPropertyName().equals(Action.SMALL_ICON)) {
|
||||||
}
|
button.setIcon((Icon) e.getNewValue());
|
||||||
else if(e.getPropertyName().equals(Action.SMALL_ICON)){
|
button.invalidate();
|
||||||
button.setIcon((Icon)e.getNewValue());
|
button.repaint();
|
||||||
button.invalidate();
|
} else if (propertyName.equals(ExtAction.TOOLTIP) || propertyName.equals(ExtAction.KEYSTROKE)) {
|
||||||
button.repaint();
|
Action source = (Action) e.getSource();
|
||||||
}
|
|
||||||
else if(propertyName.equals(ExtAction.TOOLTIP) || propertyName.equals(ExtAction.KEYSTROKE)){
|
|
||||||
Action source = (Action)e.getSource();
|
|
||||||
|
|
||||||
Object o = source.getValue(ExtAction.TOOLTIP);
|
Object o = source.getValue(ExtAction.TOOLTIP);
|
||||||
String toolTip = o != null ? (String)o : "";
|
String toolTip = o != null ? (String) o : "";
|
||||||
o = source.getValue(ExtAction.KEYSTROKE);
|
o = source.getValue(ExtAction.KEYSTROKE);
|
||||||
button.setToolTipText(toolTip + getKeyText((KeyStroke)o));
|
button.setToolTipText(toolTip + getKeyText((KeyStroke) o));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class JParaPanel implements Serializable, PanelMaker {
|
|||||||
protected Object localParameter;
|
protected Object localParameter;
|
||||||
protected Object proxyParameter;
|
protected Object proxyParameter;
|
||||||
protected PropertyEditor propertyEditor;
|
protected PropertyEditor propertyEditor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ToDo: Should be removed in future.
|
* 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 */
|
/* ToDo: First parameter is useless and should be removed */
|
||||||
propertyEditor = OptimizationJobList.makeEditor(tempPanel, (OptimizationJobList) localParameter);
|
propertyEditor = OptimizationJobList.makeEditor(tempPanel, (OptimizationJobList) localParameter);
|
||||||
} else {
|
} else {
|
||||||
propertyEditor = new GenericObjectEditor();
|
propertyEditor = new GenericObjectEditor();
|
||||||
((GenericObjectEditor) (propertyEditor)).setClassType(localParameter.getClass());
|
((GenericObjectEditor) (propertyEditor)).setClassType(localParameter.getClass());
|
||||||
((GenericObjectEditor) (propertyEditor)).setValue(localParameter);
|
((GenericObjectEditor) (propertyEditor)).setValue(localParameter);
|
||||||
((GenericObjectEditor) (propertyEditor)).disableOKCancel();
|
((GenericObjectEditor) (propertyEditor)).disableOKCancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
return (JComponent) propertyEditor.getCustomEditor();
|
return (JComponent) propertyEditor.getCustomEditor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,10 +65,12 @@ public class JParaPanel implements Serializable, PanelMaker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public PropertyEditor getEditor() {
|
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 object
|
||||||
* @param editor
|
* @param editor
|
||||||
* @return False if failed true else.
|
* @return False if failed true else.
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ package eva2.gui;
|
|||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
* IMPORTS
|
* IMPORTS
|
||||||
*==========================================================================*/
|
*==========================================================================*/
|
||||||
|
|
||||||
import java.awt.Event;
|
import java.awt.Event;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
@@ -22,296 +23,301 @@ import javax.swing.text.*;
|
|||||||
import javax.swing.undo.*;
|
import javax.swing.undo.*;
|
||||||
|
|
||||||
|
|
||||||
public class JTextEditorInternalFrame extends JDocFrame{
|
public class JTextEditorInternalFrame extends JDocFrame {
|
||||||
public final static String GROUP_EDIT = "Edit";
|
public final static String GROUP_EDIT = "Edit";
|
||||||
private JTextArea textArea;
|
private JTextArea textArea;
|
||||||
private final String[] actionGroups = {GROUP_EDIT};
|
private final String[] actionGroups = {GROUP_EDIT};
|
||||||
protected UndoManager undo = new UndoManager();
|
protected UndoManager undo = new UndoManager();
|
||||||
private class UndoAction extends ExtAction{
|
|
||||||
public UndoAction(){
|
|
||||||
super("R<EFBFBD>ckg<EFBFBD>ngig", new ImageIcon("images/EditUndo.gif"), "Macht die letzte Aktion r<>ckg<6B>ngig",
|
|
||||||
KeyStroke.getKeyStroke(KeyEvent.VK_Z, Event.CTRL_MASK));
|
|
||||||
setEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
private class UndoAction extends ExtAction {
|
||||||
public void actionPerformed(ActionEvent e){
|
public UndoAction() {
|
||||||
try{
|
super("R<EFBFBD>ckg<EFBFBD>ngig", new ImageIcon("images/EditUndo.gif"), "Macht die letzte Aktion r<>ckg<6B>ngig",
|
||||||
undo.undo();
|
KeyStroke.getKeyStroke(KeyEvent.VK_Z, Event.CTRL_MASK));
|
||||||
}
|
setEnabled(false);
|
||||||
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]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mnuEdit = new JExtMenu("&Bearbeiten");
|
@Override
|
||||||
barEdit = new JExtToolBar();
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
try {
|
||||||
|
undo.undo();
|
||||||
|
} catch (CannotUndoException exc) {
|
||||||
|
}
|
||||||
|
|
||||||
Action a;
|
update();
|
||||||
Keymap keys = textArea.getKeymap();
|
actRedo.update();
|
||||||
KeyStroke[] keyActions;
|
}
|
||||||
|
|
||||||
mnuEdit.add(actUndo);
|
private void update() {
|
||||||
barEdit.add(actUndo);
|
if (undo.canUndo()) {
|
||||||
mnuEdit.add(actRedo);
|
setEnabled(true);
|
||||||
mnuEdit.addSeparator();
|
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]);
|
private class RedoAction extends ExtAction {
|
||||||
}
|
public RedoAction() {
|
||||||
a.putValue(Action.SMALL_ICON, new ImageIcon("images/EditCut.gif"));
|
super("Wiederholen", "Wiederholt die letzte Aktion", KeyStroke.getKeyStroke(KeyEvent.VK_Z, Event.CTRL_MASK | Event.SHIFT_MASK));
|
||||||
a.putValue(ExtAction.CAPTION, "Ausschneiden");
|
setEnabled(false);
|
||||||
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);
|
@Override
|
||||||
keyActions = keys.getKeyStrokesForAction(a);
|
public void actionPerformed(ActionEvent e) {
|
||||||
if(keyActions != null && keyActions.length > 0) {
|
try {
|
||||||
a.putValue(ExtAction.KEYSTROKE, keyActions[0]);
|
undo.redo();
|
||||||
}
|
} catch (CannotRedoException exc) {
|
||||||
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);
|
update();
|
||||||
keyActions = keys.getKeyStrokesForAction(a);
|
actUndo.update();
|
||||||
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();
|
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);
|
private UndoAction actUndo;
|
||||||
keyActions = keys.getKeyStrokesForAction(a);
|
private RedoAction actRedo;
|
||||||
if(keyActions != null && keyActions.length > 0) {
|
public final static String undoAction = "undo";
|
||||||
a.putValue(ExtAction.KEYSTROKE, keyActions[0]);
|
public final static String redoAction = "redo";
|
||||||
}
|
|
||||||
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 String[] getActionGroups() {
|
||||||
@Override
|
return actionGroups;
|
||||||
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();
|
private JMenu mnuEdit;
|
||||||
createActions();
|
private JToolBar barEdit;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save(File f){
|
public JMenu getMenu(String group) {
|
||||||
FileWriter out = null;
|
if (GROUP_EDIT.equals(group)) {
|
||||||
try{
|
return mnuEdit;
|
||||||
out = new FileWriter(f);
|
} else {
|
||||||
textArea.write(out);
|
return null;
|
||||||
}
|
|
||||||
catch(IOException exc){}
|
|
||||||
finally{
|
|
||||||
if(out != null) {
|
|
||||||
try{
|
|
||||||
out.close();
|
|
||||||
}
|
|
||||||
catch(IOException exc){}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
@Override
|
||||||
public void setSelected(boolean value) throws java.beans.PropertyVetoException{
|
public void save(File f) {
|
||||||
super.setSelected(value);
|
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) {
|
super.save(f);
|
||||||
textArea.requestFocus();
|
}
|
||||||
}
|
|
||||||
}
|
@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.EvAInfo;
|
||||||
import eva2.optimization.tools.FileTools;
|
import eva2.optimization.tools.FileTools;
|
||||||
import eva2.tools.BasicResourceLoader;
|
import eva2.tools.BasicResourceLoader;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public final class LoggingLevelLabel extends JLabel {
|
|||||||
private JPopupMenu menu;
|
private JPopupMenu menu;
|
||||||
private String[] options;
|
private String[] options;
|
||||||
private Logger logger;
|
private Logger logger;
|
||||||
|
|
||||||
public LoggingLevelLabel(final Logger logger) {
|
public LoggingLevelLabel(final Logger logger) {
|
||||||
options = new String[]{"Info", "Warning", "Severe", "Fine", "Finer", "Finest", "All"};
|
options = new String[]{"Info", "Warning", "Severe", "Fine", "Finer", "Finest", "All"};
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ public final class LoggingLevelLabel extends JLabel {
|
|||||||
createPopupMenu();
|
createPopupMenu();
|
||||||
updateText();
|
updateText();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createPopupMenu() {
|
private void createPopupMenu() {
|
||||||
this.menu = new JPopupMenu();
|
this.menu = new JPopupMenu();
|
||||||
addMouseListener(new MouseListener() {
|
addMouseListener(new MouseListener() {
|
||||||
@@ -59,7 +59,7 @@ public final class LoggingLevelLabel extends JLabel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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 */
|
/* Show the updated text */
|
||||||
setText("<html><b>Level</b>: " + lvl.getName());
|
setText("<html><b>Level</b>: " + lvl.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the level of the logger to a new level.
|
* Sets the level of the logger to a new level.
|
||||||
*
|
*
|
||||||
* @param level The new level for the logger
|
* @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
|
// Recursively set logging level for all classes under eva2
|
||||||
Logger.getLogger("eva2").setLevel(level);
|
Logger.getLogger("eva2").setLevel(level);
|
||||||
logger.log(Level.INFO, "Logging Level changed to {0}", level.getName());
|
logger.log(Level.INFO, "Logging Level changed to {0}", level.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class MenuActionListener implements ActionListener {
|
class MenuActionListener implements ActionListener {
|
||||||
|
|
||||||
@@ -115,6 +115,6 @@ public final class LoggingLevelLabel extends JLabel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LoggingLevelLabel.this.updateText();
|
LoggingLevelLabel.this.updateText();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ package eva2.gui;
|
|||||||
* $Date: 2007-10-23 12:56:51 +0200 (Tue, 23 Oct 2007) $
|
* $Date: 2007-10-23 12:56:51 +0200 (Tue, 23 Oct 2007) $
|
||||||
* $Author: mkron $
|
* $Author: mkron $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
@@ -26,91 +27,95 @@ import javax.swing.event.ChangeListener;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class LoggingPanel extends JPanel {
|
public class LoggingPanel extends JPanel {
|
||||||
protected static Logger logger;
|
protected static Logger logger;
|
||||||
protected JTextArea loggingTextArea = new JTextArea(10,20);
|
protected JTextArea loggingTextArea = new JTextArea(10, 20);
|
||||||
protected boolean firstMessage = true;
|
protected boolean firstMessage = true;
|
||||||
protected Handler loggingHandler;
|
protected Handler loggingHandler;
|
||||||
protected JPopupMenu loggingLevelMenu;
|
protected JPopupMenu loggingLevelMenu;
|
||||||
/**
|
|
||||||
*
|
/**
|
||||||
*/
|
*
|
||||||
public LoggingPanel(Logger logger) {
|
*/
|
||||||
this.logger = logger;
|
public LoggingPanel(Logger logger) {
|
||||||
loggingTextArea.setEditable(false);
|
this.logger = logger;
|
||||||
loggingTextArea.setLineWrap(true);
|
loggingTextArea.setEditable(false);
|
||||||
|
loggingTextArea.setLineWrap(true);
|
||||||
loggingTextArea.setBorder(BorderFactory.createEmptyBorder());
|
loggingTextArea.setBorder(BorderFactory.createEmptyBorder());
|
||||||
|
|
||||||
setLayout(new BorderLayout());
|
setLayout(new BorderLayout());
|
||||||
|
|
||||||
add(new JLabel("Info"), BorderLayout.PAGE_START);
|
add(new JLabel("Info"), BorderLayout.PAGE_START);
|
||||||
|
|
||||||
this.loggingHandler = new LoggingHandler(this);
|
this.loggingHandler = new LoggingHandler(this);
|
||||||
logger.addHandler(loggingHandler);
|
logger.addHandler(loggingHandler);
|
||||||
|
|
||||||
final JScrollPane scrollpane = new JScrollPane(loggingTextArea);
|
final JScrollPane scrollpane = new JScrollPane(loggingTextArea);
|
||||||
scrollpane.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
|
scrollpane.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
|
||||||
// scrollpane.setAutoscrolls(false);
|
// scrollpane.setAutoscrolls(false);
|
||||||
add(scrollpane, BorderLayout.CENTER);
|
add(scrollpane, BorderLayout.CENTER);
|
||||||
scrollpane.getViewport().addChangeListener(new ChangeListener() {
|
scrollpane.getViewport().addChangeListener(new ChangeListener() {
|
||||||
private int lastHeight;
|
private int lastHeight;
|
||||||
//
|
|
||||||
|
//
|
||||||
@Override
|
@Override
|
||||||
public void stateChanged(ChangeEvent e) {
|
public void stateChanged(ChangeEvent e) {
|
||||||
JViewport viewport = (JViewport)e.getSource();
|
JViewport viewport = (JViewport) e.getSource();
|
||||||
int height = viewport.getViewSize().height;
|
int height = viewport.getViewSize().height;
|
||||||
if (height != lastHeight) {
|
if (height != lastHeight) {
|
||||||
lastHeight = height;
|
lastHeight = height;
|
||||||
int x = height - viewport.getExtentSize().height;
|
int x = height - viewport.getExtentSize().height;
|
||||||
viewport.setViewPosition(new Point(0, x));
|
viewport.setViewPosition(new Point(0, x));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
*
|
/**
|
||||||
*/
|
*
|
||||||
protected static String getTimestamp() {
|
*/
|
||||||
return (new SimpleDateFormat("HH:mm:ss:")).format(new Date());
|
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 logMessage(String message) {
|
||||||
}
|
loggingTextArea.append(LoggingPanel.getTimestamp() + ' ' + message);
|
||||||
|
loggingTextArea.append("\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoggingHandler extends Handler {
|
class LoggingHandler extends Handler {
|
||||||
protected LoggingPanel loggingPanel;
|
protected LoggingPanel loggingPanel;
|
||||||
|
|
||||||
public LoggingHandler(LoggingPanel loggingPanel) {
|
|
||||||
this.loggingPanel = loggingPanel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public LoggingHandler(LoggingPanel loggingPanel) {
|
||||||
public void publish(LogRecord record) {
|
this.loggingPanel = loggingPanel;
|
||||||
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
|
@Override
|
||||||
public void flush() {
|
public void publish(LogRecord record) {
|
||||||
/*
|
StringBuilder sBuilder = new StringBuilder();
|
||||||
* We do nothing here as we don't buffer the entries
|
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
|
@Override
|
||||||
public void close() throws SecurityException {
|
public void close() throws SecurityException {
|
||||||
/*
|
/*
|
||||||
* Nothing to close
|
* Nothing to close
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -77,7 +77,7 @@ public class Main extends JFrame implements OptimizationStateListener {
|
|||||||
private ExtAction actLicense;
|
private ExtAction actLicense;
|
||||||
|
|
||||||
// if not null, the module is loaded automatically and no other can be selected
|
// 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 showLoadModules = false;
|
||||||
private boolean localMode = 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
|
* Constructor of GUI of EvA2. Works as client for the EvA2 server. Note
|
||||||
* that the Main initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()}
|
* that the Main initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()}
|
||||||
* to await full initialization if necessary.
|
* to await full initialization if necessary.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public Main(final String hostName) {
|
public Main(final String hostName) {
|
||||||
this(hostName, null, false, false);
|
this(hostName, null, false, false);
|
||||||
@@ -126,11 +125,11 @@ public class Main extends JFrame implements OptimizationStateListener {
|
|||||||
* efficiency. Use {@link #awaitGuiInitialized()} to await full
|
* efficiency. Use {@link #awaitGuiInitialized()} to await full
|
||||||
* initialization if necessary.
|
* initialization if necessary.
|
||||||
*
|
*
|
||||||
* @see #EvAClient(String, java.awt.Window, String, boolean, boolean, boolean)
|
|
||||||
* @param hostName
|
* @param hostName
|
||||||
* @param paramsFile
|
* @param paramsFile
|
||||||
* @param autorun
|
* @param autorun
|
||||||
* @param nosplash
|
* @param nosplash
|
||||||
|
* @see #EvAClient(String, java.awt.Window, String, boolean, boolean, boolean)
|
||||||
*/
|
*/
|
||||||
public Main(final String hostName, final String paramsFile, boolean autorun, boolean nosplash) {
|
public Main(final String hostName, final String paramsFile, boolean autorun, boolean nosplash) {
|
||||||
this(hostName, null, paramsFile, null, autorun, nosplash, false, false);
|
this(hostName, null, paramsFile, null, autorun, nosplash, false, false);
|
||||||
@@ -141,11 +140,10 @@ public class Main extends JFrame implements OptimizationStateListener {
|
|||||||
* initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()}
|
* initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()}
|
||||||
* to await full initialization if necessary.
|
* to await full initialization if necessary.
|
||||||
*
|
*
|
||||||
* @see #Main(String, String, boolean, boolean)
|
|
||||||
*
|
|
||||||
* @param hostName
|
* @param hostName
|
||||||
* @param autorun
|
* @param autorun
|
||||||
* @param nosplash
|
* @param nosplash
|
||||||
|
* @see #Main(String, String, boolean, boolean)
|
||||||
*/
|
*/
|
||||||
public Main(final String hostName, boolean autorun, boolean nosplash) {
|
public Main(final String hostName, boolean autorun, boolean nosplash) {
|
||||||
this(hostName, null, autorun, nosplash);
|
this(hostName, null, autorun, nosplash);
|
||||||
@@ -156,12 +154,12 @@ public class Main extends JFrame implements OptimizationStateListener {
|
|||||||
* initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()}
|
* initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()}
|
||||||
* to await full initialization if necessary.
|
* to await full initialization if necessary.
|
||||||
*
|
*
|
||||||
* @see #Main(String, String, boolean, boolean)
|
|
||||||
* @param hostName
|
* @param hostName
|
||||||
* @param paramsFile
|
* @param paramsFile
|
||||||
* @param autorun
|
* @param autorun
|
||||||
* @param noSplash
|
* @param noSplash
|
||||||
* @param noGui
|
* @param noGui
|
||||||
|
* @see #Main(String, String, boolean, boolean)
|
||||||
*/
|
*/
|
||||||
public Main(final String hostName, String paramsFile, boolean autorun, boolean noSplash, boolean noGui, boolean withTreeView) {
|
public Main(final String hostName, String paramsFile, boolean autorun, boolean noSplash, boolean noGui, boolean withTreeView) {
|
||||||
this(hostName, null, paramsFile, null, autorun, noSplash, noGui, withTreeView);
|
this(hostName, null, paramsFile, null, autorun, noSplash, noGui, withTreeView);
|
||||||
@@ -172,13 +170,12 @@ public class Main extends JFrame implements OptimizationStateListener {
|
|||||||
* initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()}
|
* initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()}
|
||||||
* to await full initialization if necessary.
|
* to await full initialization if necessary.
|
||||||
*
|
*
|
||||||
* @see #Main(String, String, boolean, boolean)
|
|
||||||
*
|
|
||||||
* @param hostName
|
* @param hostName
|
||||||
* @param paramsFile
|
* @param paramsFile
|
||||||
* @param autorun
|
* @param autorun
|
||||||
* @param noSplash
|
* @param noSplash
|
||||||
* @param noGui
|
* @param noGui
|
||||||
|
* @see #Main(String, String, boolean, boolean)
|
||||||
*/
|
*/
|
||||||
public Main(final String hostName, InterfaceOptimizationParameters goParams, boolean autorun, boolean noSplash, boolean noGui) {
|
public Main(final String hostName, InterfaceOptimizationParameters goParams, boolean autorun, boolean noSplash, boolean noGui) {
|
||||||
this(hostName, null, null, goParams, autorun, noSplash, noGui, false);
|
this(hostName, null, null, goParams, autorun, noSplash, noGui, false);
|
||||||
@@ -401,7 +398,7 @@ public class Main extends JFrame implements OptimizationStateListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
logPanel = new LoggingPanel(LOGGER);
|
logPanel = new LoggingPanel(LOGGER);
|
||||||
logPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
|
logPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
|
||||||
|
|
||||||
|
|
||||||
if (EvAInfo.propShowModules() != null) {
|
if (EvAInfo.propShowModules() != null) {
|
||||||
@@ -551,7 +548,6 @@ public class Main extends JFrame implements OptimizationStateListener {
|
|||||||
/**
|
/**
|
||||||
* Refresh the parameter panels (if settings have been changed outside of
|
* Refresh the parameter panels (if settings have been changed outside of
|
||||||
* the GUI which should be updated in the GUI.
|
* the GUI which should be updated in the GUI.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public void refreshMainPanels() {
|
public void refreshMainPanels() {
|
||||||
frameMaker.refreshPanels();
|
frameMaker.refreshPanels();
|
||||||
@@ -567,8 +563,8 @@ public class Main extends JFrame implements OptimizationStateListener {
|
|||||||
* @param args command line parameters
|
* @param args command line parameters
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
/*============================COPIED FROM SYSBIO==============================*/
|
/*============================COPIED FROM SYSBIO==============================*/
|
||||||
// Properties for Mac OS X support.
|
// Properties for Mac OS X support.
|
||||||
if ((System.getProperty("mrj.version") != null)
|
if ((System.getProperty("mrj.version") != null)
|
||||||
|| (System.getProperty("os.name").toLowerCase().indexOf("mac") != -1)) {
|
|| (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.growbox.intrudes", "false");
|
||||||
System.setProperty("com.apple.mrj.application.live-resize", "true");
|
System.setProperty("com.apple.mrj.application.live-resize", "true");
|
||||||
}
|
}
|
||||||
/*==========================================================================*/
|
/*==========================================================================*/
|
||||||
|
|
||||||
|
|
||||||
/* Available command-line parameters */
|
/* Available command-line parameters */
|
||||||
String[] keys = new String[]{
|
String[] keys = new String[]{
|
||||||
"--help", "--autorun", "--nosplash", "--nogui",
|
"--help", "--autorun", "--nosplash", "--nogui",
|
||||||
"--remotehost", "--params", "--treeView"
|
"--remotehost", "--params", "--treeView"
|
||||||
};
|
};
|
||||||
/* Number of arguments per parameter */
|
/* Number of arguments per parameter */
|
||||||
int[] arities = new int[]{0, 0, 0, 0, 1, 1, 0};
|
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
|
* Initialize the client GUI with given parameters and set listeners. This
|
||||||
* will return as soon as the GUI is visible and ready.
|
* will return as soon as the GUI is visible and ready.
|
||||||
*
|
*
|
||||||
* @param goParams optimization parameters
|
* @param goParams optimization parameters
|
||||||
* @param statisticsListener statistics listener receiving data during
|
* @param statisticsListener statistics listener receiving data during
|
||||||
* optimization
|
* optimization
|
||||||
* @param windowListener additional window listener for client frame
|
* @param windowListener additional window listener for client frame
|
||||||
*/
|
*/
|
||||||
public static Main initClientGUI(OptimizationParameters goParams,
|
public static Main initClientGUI(OptimizationParameters goParams,
|
||||||
InterfaceStatisticsListener statisticsListener,
|
InterfaceStatisticsListener statisticsListener,
|
||||||
WindowListener windowListener, final Window parent) {
|
WindowListener windowListener, final Window parent) {
|
||||||
Main evaClient;
|
Main evaClient;
|
||||||
|
|
||||||
evaClient = new Main(null, parent, null, goParams,
|
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
|
* Create a tree view of an object based on EvATreeNode. It is encapsulated
|
||||||
* in a JScrollPane.
|
* in a JScrollPane.
|
||||||
*
|
*
|
||||||
* @see eva2.gui.EvATreeNode
|
|
||||||
* @param title
|
* @param title
|
||||||
* @param object
|
* @param object
|
||||||
* @return
|
* @return
|
||||||
|
* @see eva2.gui.EvATreeNode
|
||||||
*/
|
*/
|
||||||
public JComponent getEvATreeView(JParaPanel goPanel, String title, Object object) {
|
public JComponent getEvATreeView(JParaPanel goPanel, String title, Object object) {
|
||||||
EvATreeNode root = new EvATreeNode(title, object); // the root of the tree
|
EvATreeNode root = new EvATreeNode(title, object); // the root of the tree
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ package eva2.gui;
|
|||||||
* Time: 18:30:44
|
* Time: 18:30:44
|
||||||
* To change this template use Options | File Templates.
|
* To change this template use Options | File Templates.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -5,21 +5,23 @@ package eva2.gui;
|
|||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class MultiLineString {
|
public class MultiLineString {
|
||||||
|
|
||||||
String string = "";
|
String string = "";
|
||||||
|
|
||||||
public MultiLineString() {
|
public MultiLineString() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
MultiLineString multiLineString1 = new MultiLineString();
|
MultiLineString multiLineString1 = new MultiLineString();
|
||||||
}
|
}
|
||||||
public String getString() {
|
|
||||||
return string;
|
public String getString() {
|
||||||
}
|
return string;
|
||||||
public void setString(String string) {
|
}
|
||||||
this.string = string;
|
|
||||||
}
|
public void setString(String string) {
|
||||||
|
this.string = string;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import javax.swing.JComponent;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple helper interface.
|
* Simple helper interface.
|
||||||
* @author mkron
|
|
||||||
*
|
*
|
||||||
|
* @author mkron
|
||||||
*/
|
*/
|
||||||
public interface PanelMaker {
|
public interface PanelMaker {
|
||||||
public JComponent makePanel();
|
public JComponent makePanel();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ package eva2.gui;
|
|||||||
import eva2.EvAInfo;
|
import eva2.EvAInfo;
|
||||||
import eva2.tools.BasicResourceLoader;
|
import eva2.tools.BasicResourceLoader;
|
||||||
import eva2.tools.EVAHELP;
|
import eva2.tools.EVAHELP;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.beans.PropertyEditor;
|
import java.beans.PropertyEditor;
|
||||||
@@ -25,7 +26,7 @@ public class PropertyDialog extends JDialog {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public PropertyDialog(PropertyEditor editor, String title, int x, int y) {
|
public PropertyDialog(PropertyEditor editor, String title, int x, int y) {
|
||||||
super();
|
super();
|
||||||
setTitle(getFrameNameFromEditor(editor));
|
setTitle(getFrameNameFromEditor(editor));
|
||||||
//super(getFrameNameFromEditor(editor)); // that was the long class name !!
|
//super(getFrameNameFromEditor(editor)); // that was the long class name !!
|
||||||
BasicResourceLoader loader = BasicResourceLoader.instance();
|
BasicResourceLoader loader = BasicResourceLoader.instance();
|
||||||
|
|||||||
@@ -8,13 +8,13 @@ public class PropertyDoubleArray implements java.io.Serializable {
|
|||||||
private int m_numCols = 1;
|
private int m_numCols = 1;
|
||||||
|
|
||||||
public PropertyDoubleArray(double[] d) {
|
public PropertyDoubleArray(double[] d) {
|
||||||
setDoubleArray(d);
|
setDoubleArray(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PropertyDoubleArray(double[][] d) {
|
public PropertyDoubleArray(double[][] d) {
|
||||||
setDoubleArray(d);
|
setDoubleArray(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PropertyDoubleArray(PropertyDoubleArray d) {
|
public PropertyDoubleArray(PropertyDoubleArray d) {
|
||||||
this.m_DoubleArray = d.m_DoubleArray.clone();
|
this.m_DoubleArray = d.m_DoubleArray.clone();
|
||||||
this.m_numCols = d.m_numCols;
|
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
|
* Constructor that creates a double matrix with given dimensions and fills
|
||||||
* it cyclically with values given.
|
* it cyclically with values given.
|
||||||
|
*
|
||||||
* @param rows
|
* @param rows
|
||||||
* @param cols
|
* @param cols
|
||||||
* @param d
|
* @param d
|
||||||
*/
|
*/
|
||||||
public PropertyDoubleArray(int rows, int cols, double ... d) {
|
public PropertyDoubleArray(int rows, int cols, double... d) {
|
||||||
if (rows>0 && cols>0) {
|
if (rows > 0 && cols > 0) {
|
||||||
this.m_DoubleArray = new double[rows][cols];
|
this.m_DoubleArray = new double[rows][cols];
|
||||||
|
} else {
|
||||||
|
this.m_DoubleArray = null;
|
||||||
}
|
}
|
||||||
else {
|
this.m_numCols = cols;
|
||||||
this.m_DoubleArray=null;
|
int index = 0;
|
||||||
|
for (int i = 0; i < rows; i++) {
|
||||||
|
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
|
@Override
|
||||||
public Object clone() {
|
public Object clone() {
|
||||||
return (Object) new PropertyDoubleArray(this);
|
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) {
|
public void setDoubleArray(double[] d) {
|
||||||
this.m_DoubleArray = new double[d.length][1];
|
this.m_DoubleArray = new double[d.length][1];
|
||||||
for (int i=0; i<d.length; i++) {
|
for (int i = 0; i < d.length; i++) {
|
||||||
m_DoubleArray[i][0] = d[i];
|
m_DoubleArray[i][0] = d[i];
|
||||||
}
|
}
|
||||||
m_numCols=1;
|
m_numCols = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method will allow you to set the value of the double array
|
/**
|
||||||
* @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) {
|
public void setDoubleArray(double[][] d) {
|
||||||
this.m_DoubleArray = d;
|
this.m_DoubleArray = d;
|
||||||
if (d.length>0) {
|
if (d.length > 0) {
|
||||||
m_numCols=d[0].length;
|
m_numCols = d[0].length;
|
||||||
}
|
} else {
|
||||||
else {
|
m_numCols = 1;
|
||||||
m_numCols=1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the double array itself (no clone)
|
* @return the double array itself (no clone)
|
||||||
*/
|
*/
|
||||||
public double[][] getDoubleArrayShallow() {
|
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)
|
||||||
|
*
|
||||||
* @return a column as a vector (in copy)
|
* @return a column as a vector (in copy)
|
||||||
*/
|
*/
|
||||||
public double[] getDoubleColumnAsVector(int col) {
|
public double[] getDoubleColumnAsVector(int col) {
|
||||||
if (col>=m_numCols) {
|
if (col >= m_numCols) {
|
||||||
throw new IllegalArgumentException("Error, invalid column selected, " + col + " of " + m_numCols);
|
throw new IllegalArgumentException("Error, invalid column selected, " + col + " of " + m_numCols);
|
||||||
}
|
|
||||||
double[] ret = new double[m_DoubleArray.length];
|
|
||||||
for (int i=0; i<ret.length; i++) {
|
|
||||||
ret[i]=m_DoubleArray[i][col];
|
|
||||||
}
|
}
|
||||||
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() {
|
public int getNumCols() {
|
||||||
return m_numCols;
|
return m_numCols;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getNumRows() {
|
public int getNumRows() {
|
||||||
return m_DoubleArray.length;
|
return m_DoubleArray.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getValue(int i, int j) {
|
public double getValue(int i, int j) {
|
||||||
if (i<0 || j<0 || (i>=getNumRows()) || (j>=getNumCols())) {
|
if (i < 0 || j < 0 || (i >= getNumRows()) || (j >= getNumCols())) {
|
||||||
throw new IllegalArgumentException("Error, invalid access to double array: " + i + "," + j + " within " + getNumRows() + ","+getNumCols());
|
throw new IllegalArgumentException("Error, invalid access to double array: " + i + "," + j + " within " + getNumRows() + "," + getNumCols());
|
||||||
}
|
}
|
||||||
return m_DoubleArray[i][j];
|
return m_DoubleArray[i][j];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void adaptRowCount(int k) {
|
public void adaptRowCount(int k) {
|
||||||
if (k!=m_DoubleArray.length) {
|
if (k != m_DoubleArray.length) {
|
||||||
double[][] newDD = new double[k][m_numCols];
|
double[][] newDD = new double[k][m_numCols];
|
||||||
for (int i=0; i<k; i++) {
|
for (int i = 0; i < k; i++) {
|
||||||
for (int j=0; j<m_numCols; j++) {
|
for (int j = 0; j < m_numCols; j++) {
|
||||||
if (i<m_DoubleArray.length) {
|
if (i < m_DoubleArray.length) {
|
||||||
newDD[i][j]=m_DoubleArray[i][j];
|
newDD[i][j] = m_DoubleArray[i][j];
|
||||||
}
|
} else {
|
||||||
else {
|
newDD[i][j] = m_DoubleArray[m_DoubleArray.length - 1][j];
|
||||||
newDD[i][j]=m_DoubleArray[m_DoubleArray.length-1][j];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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) {
|
setDoubleArray(newDD);
|
||||||
for (int j=0; j<getNumCols(); j++) {
|
}
|
||||||
newDD[newDD.length-1][j] = newDD[k][j];
|
}
|
||||||
} }
|
|
||||||
else {
|
public void deleteRow(int k) {
|
||||||
for (int j=0; j<getNumCols(); j++) {
|
if (k < 0 || k >= getNumRows()) {
|
||||||
newDD[newDD.length-1][j] = 1.;
|
throw new IllegalArgumentException("Invalid index to deleteRow: " + k + " is not a valid row.");
|
||||||
} } // if the array was empty
|
}
|
||||||
setDoubleArray(newDD);
|
double[][] newDD = new double[getNumRows() - 1][getNumCols()];
|
||||||
}
|
int inc = 0;
|
||||||
|
for (int i = 0; i < newDD.length; i++) {
|
||||||
/**
|
if (i == k) {
|
||||||
* Normalize all columns of the array by dividing through the sum.
|
inc = 1;
|
||||||
*/
|
}
|
||||||
public void normalizeColumns() {
|
for (int j = 0; j < getNumCols(); j++) {
|
||||||
double colSum=0;
|
newDD[i][j] = m_DoubleArray[i + inc][j];
|
||||||
for (int j=0; j<getNumCols(); j++) {
|
}
|
||||||
colSum=0;
|
}
|
||||||
for (int i = 0; i < getNumRows(); i++) {
|
setDoubleArray(newDD);
|
||||||
colSum += m_DoubleArray[i][j];
|
}
|
||||||
}
|
|
||||||
if (colSum!=0) {
|
/**
|
||||||
for (int i = 0; i < getNumRows(); i++) {
|
* Add a copy of an indexed row at the end. If the given index
|
||||||
m_DoubleArray[i][j]/=colSum;
|
* 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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return BeanInspector.toString(m_DoubleArray);
|
return BeanInspector.toString(m_DoubleArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
// /** This method will allow you to set the value of the double array
|
// /** This method will allow you to set the value of the double array
|
||||||
// * @param d The double[]
|
// * @param d The double[]
|
||||||
// */
|
// */
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ package eva2.gui;
|
|||||||
*/
|
*/
|
||||||
public class PropertyEpsilonConstraint implements java.io.Serializable {
|
public class PropertyEpsilonConstraint implements java.io.Serializable {
|
||||||
|
|
||||||
public double[] m_TargetValue;
|
public double[] m_TargetValue;
|
||||||
public int m_OptimizeObjective;
|
public int m_OptimizeObjective;
|
||||||
|
|
||||||
public PropertyEpsilonConstraint() {
|
public PropertyEpsilonConstraint() {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ package eva2.gui;
|
|||||||
*/
|
*/
|
||||||
public class PropertyEpsilonThreshold implements java.io.Serializable {
|
public class PropertyEpsilonThreshold implements java.io.Serializable {
|
||||||
|
|
||||||
public double[] m_Punishment;
|
public double[] m_Punishment;
|
||||||
public double[] m_TargetValue;
|
public double[] m_TargetValue;
|
||||||
public int m_OptimizeObjective;
|
public int m_OptimizeObjective;
|
||||||
|
|
||||||
public PropertyEpsilonThreshold() {
|
public PropertyEpsilonThreshold() {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,48 +10,47 @@ import eva2.tools.ReflectPackage;
|
|||||||
* To change this template use Options | File Templates.
|
* To change this template use Options | File Templates.
|
||||||
*/
|
*/
|
||||||
public class PropertyFilePath implements java.io.Serializable {
|
public class PropertyFilePath implements java.io.Serializable {
|
||||||
|
|
||||||
public String FileName = "";
|
public String FileName = "";
|
||||||
public String FilePath = "";
|
public String FilePath = "";
|
||||||
public String FileExtension = "";
|
public String FileExtension = "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor setting the absolute path. F
|
* Constructor setting the absolute path. F
|
||||||
*
|
*
|
||||||
* @param s
|
* @param s
|
||||||
*/
|
*/
|
||||||
private PropertyFilePath(String s) {
|
private PropertyFilePath(String s) {
|
||||||
this.setCompleteFilePath(s);
|
this.setCompleteFilePath(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PropertyFilePath(PropertyFilePath d) {
|
public PropertyFilePath(PropertyFilePath d) {
|
||||||
this.FileName = d.FileName;
|
this.FileName = d.FileName;
|
||||||
this.FilePath = d.FilePath;
|
this.FilePath = d.FilePath;
|
||||||
this.FileExtension = d.FileExtension;
|
this.FileExtension = d.FileExtension;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an instance by an absolute path.
|
* Get an instance by an absolute path.
|
||||||
*
|
*
|
||||||
* @param path
|
* @param path
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static PropertyFilePath getFilePathAbsolute(String path) {
|
public static PropertyFilePath getFilePathAbsolute(String path) {
|
||||||
return new PropertyFilePath(path);
|
return new PropertyFilePath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an instance by a relative path.
|
* Get an instance by a relative path.
|
||||||
*
|
*
|
||||||
* @param relPath
|
* @param relPath
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static PropertyFilePath getFilePathFromResource(String relPath) {
|
public static PropertyFilePath getFilePathFromResource(String relPath) {
|
||||||
String fName = ReflectPackage.getResourcePathFromCP(relPath);
|
String fName = ReflectPackage.getResourcePathFromCP(relPath);
|
||||||
if (fName == null) {
|
if (fName == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return new PropertyFilePath(fName);
|
return new PropertyFilePath(fName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -61,29 +60,31 @@ public class PropertyFilePath implements java.io.Serializable {
|
|||||||
return (Object) new PropertyFilePath(this);
|
return (Object) new PropertyFilePath(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method will allow you to set a complete string
|
/**
|
||||||
|
* This method will allow you to set a complete string
|
||||||
* which will be separated into Path, Name and extension
|
* which will be separated into Path, Name and extension
|
||||||
* @param s The complete filepath and filename
|
*
|
||||||
|
* @param s The complete filepath and filename
|
||||||
*/
|
*/
|
||||||
public void setCompleteFilePath(String s) {
|
public void setCompleteFilePath(String s) {
|
||||||
boolean trace = false;
|
boolean trace = false;
|
||||||
String filesep;
|
String filesep;
|
||||||
|
|
||||||
String old = this.getCompleteFilePath();
|
String old = this.getCompleteFilePath();
|
||||||
try {
|
try {
|
||||||
if (trace) {
|
if (trace) {
|
||||||
System.out.println("Complete Filename: " +s);
|
System.out.println("Complete Filename: " + s);
|
||||||
}
|
}
|
||||||
filesep = System.getProperty("file.separator");
|
filesep = System.getProperty("file.separator");
|
||||||
if (trace) {
|
if (trace) {
|
||||||
System.out.println("File.Separator: " +filesep);
|
System.out.println("File.Separator: " + filesep);
|
||||||
}
|
}
|
||||||
this.FileName = s.substring(s.lastIndexOf(filesep)+1);
|
this.FileName = s.substring(s.lastIndexOf(filesep) + 1);
|
||||||
this.FileExtension = this.FileName.substring(this.FileName.lastIndexOf("."));
|
this.FileExtension = this.FileName.substring(this.FileName.lastIndexOf("."));
|
||||||
this.FilePath = s.substring(0, s.lastIndexOf(filesep)+1);
|
this.FilePath = s.substring(0, s.lastIndexOf(filesep) + 1);
|
||||||
|
|
||||||
if (trace) {
|
if (trace) {
|
||||||
System.out.println("FilePath: " +this.FilePath);
|
System.out.println("FilePath: " + this.FilePath);
|
||||||
}
|
}
|
||||||
if (trace) {
|
if (trace) {
|
||||||
System.out.println("Filename: " + this.FileName);
|
System.out.println("Filename: " + this.FileName);
|
||||||
@@ -96,8 +97,10 @@ public class PropertyFilePath implements java.io.Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method will return the complete name of the file
|
/**
|
||||||
|
* This method will return the complete name of the file
|
||||||
* which filepath
|
* which filepath
|
||||||
|
*
|
||||||
* @return The complete filename with path.
|
* @return The complete filename with path.
|
||||||
*/
|
*/
|
||||||
public String getCompleteFilePath() {
|
public String getCompleteFilePath() {
|
||||||
|
|||||||
@@ -24,14 +24,18 @@ public class PropertyIntArray implements java.io.Serializable {
|
|||||||
return (Object) new PropertyIntArray(this);
|
return (Object) new PropertyIntArray(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method will allow you to set the value of the double array
|
/**
|
||||||
* @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) {
|
public void setIntArray(int[] d) {
|
||||||
this.m_IntArray = d;
|
this.m_IntArray = d;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method will return the int array
|
/**
|
||||||
|
* This method will return the int array
|
||||||
|
*
|
||||||
* @return The int array
|
* @return The int array
|
||||||
*/
|
*/
|
||||||
public int[] getIntArray() {
|
public int[] getIntArray() {
|
||||||
|
|||||||
@@ -10,21 +10,22 @@ import eva2.optimization.problems.InterfaceOptimizationObjective;
|
|||||||
* To change this template use File | Settings | File Templates.
|
* To change this template use File | Settings | File Templates.
|
||||||
*/
|
*/
|
||||||
public class PropertyOptimizationObjectives implements java.io.Serializable {
|
public class PropertyOptimizationObjectives implements java.io.Serializable {
|
||||||
public InterfaceOptimizationObjective[] m_AvailableObjectives;
|
public InterfaceOptimizationObjective[] m_AvailableObjectives;
|
||||||
public InterfaceOptimizationObjective[] m_SelectedObjectives;
|
public InterfaceOptimizationObjective[] m_SelectedObjectives;
|
||||||
|
|
||||||
public PropertyOptimizationObjectives(InterfaceOptimizationObjective[] d) {
|
public PropertyOptimizationObjectives(InterfaceOptimizationObjective[] d) {
|
||||||
this.m_AvailableObjectives = d;
|
this.m_AvailableObjectives = d;
|
||||||
this.m_SelectedObjectives = null;
|
this.m_SelectedObjectives = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PropertyOptimizationObjectives(PropertyOptimizationObjectives d) {
|
public PropertyOptimizationObjectives(PropertyOptimizationObjectives d) {
|
||||||
this.m_AvailableObjectives = new InterfaceOptimizationObjective[d.m_AvailableObjectives.length];
|
this.m_AvailableObjectives = new InterfaceOptimizationObjective[d.m_AvailableObjectives.length];
|
||||||
for (int i = 0; i < this.m_AvailableObjectives.length; i++) {
|
for (int i = 0; i < this.m_AvailableObjectives.length; i++) {
|
||||||
this.m_AvailableObjectives[i] = (InterfaceOptimizationObjective)d.m_AvailableObjectives[i].clone();
|
this.m_AvailableObjectives[i] = (InterfaceOptimizationObjective) d.m_AvailableObjectives[i].clone();
|
||||||
}
|
}
|
||||||
this.m_SelectedObjectives = new InterfaceOptimizationObjective[d.m_SelectedObjectives.length];
|
this.m_SelectedObjectives = new InterfaceOptimizationObjective[d.m_SelectedObjectives.length];
|
||||||
for (int i = 0; i < this.m_SelectedObjectives.length; i++) {
|
for (int i = 0; i < this.m_SelectedObjectives.length; i++) {
|
||||||
this.m_SelectedObjectives[i] = (InterfaceOptimizationObjective)d.m_SelectedObjectives[i].clone();
|
this.m_SelectedObjectives[i] = (InterfaceOptimizationObjective) d.m_SelectedObjectives[i].clone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,36 +34,44 @@ public class PropertyOptimizationObjectives implements java.io.Serializable {
|
|||||||
return (Object) new PropertyOptimizationObjectives(this);
|
return (Object) new PropertyOptimizationObjectives(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method will allow you to set the value of the InterfaceOptimizationTarget array
|
/**
|
||||||
* @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) {
|
public void setSelectedTargets(InterfaceOptimizationObjective[] d) {
|
||||||
this.m_SelectedObjectives = d;
|
this.m_SelectedObjectives = d;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method will return the InterfaceOptimizationTarget array
|
/**
|
||||||
|
* This method will return the InterfaceOptimizationTarget array
|
||||||
|
*
|
||||||
* @return The InterfaceOptimizationTarget[].
|
* @return The InterfaceOptimizationTarget[].
|
||||||
*/
|
*/
|
||||||
public InterfaceOptimizationObjective[] getSelectedTargets() {
|
public InterfaceOptimizationObjective[] getSelectedTargets() {
|
||||||
return this.m_SelectedObjectives;
|
return this.m_SelectedObjectives;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method will return the InterfaceOptimizationTarget array
|
/**
|
||||||
|
* This method will return the InterfaceOptimizationTarget array
|
||||||
|
*
|
||||||
* @return The InterfaceOptimizationTarget[].
|
* @return The InterfaceOptimizationTarget[].
|
||||||
*/
|
*/
|
||||||
public InterfaceOptimizationObjective[] getAvailableTargets() {
|
public InterfaceOptimizationObjective[] getAvailableTargets() {
|
||||||
return this.m_AvailableObjectives;
|
return this.m_AvailableObjectives;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method allows you to remove a Target from the list
|
/**
|
||||||
* @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) {
|
public void removeTarget(int index) {
|
||||||
if ((index < 0) || (index >= this.m_SelectedObjectives.length)) {
|
if ((index < 0) || (index >= this.m_SelectedObjectives.length)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
InterfaceOptimizationObjective[] newList = new InterfaceOptimizationObjective[this.m_SelectedObjectives.length-1];
|
InterfaceOptimizationObjective[] newList = new InterfaceOptimizationObjective[this.m_SelectedObjectives.length - 1];
|
||||||
int j = 0;
|
int j = 0;
|
||||||
for (int i = 0; i < this.m_SelectedObjectives.length; i++) {
|
for (int i = 0; i < this.m_SelectedObjectives.length; i++) {
|
||||||
if (index != i) {
|
if (index != i) {
|
||||||
@@ -73,11 +82,13 @@ public class PropertyOptimizationObjectives implements java.io.Serializable {
|
|||||||
this.m_SelectedObjectives = newList;
|
this.m_SelectedObjectives = newList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method allows you to add a new target to the list
|
/**
|
||||||
|
* This method allows you to add a new target to the list
|
||||||
|
*
|
||||||
* @param optTarget
|
* @param optTarget
|
||||||
*/
|
*/
|
||||||
public void addTarget(InterfaceOptimizationObjective optTarget) {
|
public void addTarget(InterfaceOptimizationObjective optTarget) {
|
||||||
InterfaceOptimizationObjective[] newList = new InterfaceOptimizationObjective[this.m_SelectedObjectives.length+1];
|
InterfaceOptimizationObjective[] newList = new InterfaceOptimizationObjective[this.m_SelectedObjectives.length + 1];
|
||||||
for (int i = 0; i < this.m_SelectedObjectives.length; i++) {
|
for (int i = 0; i < this.m_SelectedObjectives.length; i++) {
|
||||||
newList[i] = this.m_SelectedObjectives[i];
|
newList[i] = this.m_SelectedObjectives[i];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,28 +11,29 @@ import eva2.optimization.problems.InterfaceOptimizationObjective;
|
|||||||
*/
|
*/
|
||||||
public class PropertyOptimizationObjectivesWithParam implements java.io.Serializable {
|
public class PropertyOptimizationObjectivesWithParam implements java.io.Serializable {
|
||||||
|
|
||||||
public InterfaceOptimizationObjective[] m_AvailableObjectives;
|
public InterfaceOptimizationObjective[] m_AvailableObjectives;
|
||||||
public InterfaceOptimizationObjective[] m_SelectedObjectives;
|
public InterfaceOptimizationObjective[] m_SelectedObjectives;
|
||||||
public double[] m_Weights;
|
public double[] m_Weights;
|
||||||
public String m_DescriptiveString = "No Description given.";
|
public String m_DescriptiveString = "No Description given.";
|
||||||
public String m_WeightsLabel = "-";
|
public String m_WeightsLabel = "-";
|
||||||
public boolean m_NormalizationEnabled = true;
|
public boolean m_NormalizationEnabled = true;
|
||||||
|
|
||||||
public PropertyOptimizationObjectivesWithParam(InterfaceOptimizationObjective[] d) {
|
public PropertyOptimizationObjectivesWithParam(InterfaceOptimizationObjective[] d) {
|
||||||
this.m_AvailableObjectives = d;
|
this.m_AvailableObjectives = d;
|
||||||
this.m_SelectedObjectives = null;
|
this.m_SelectedObjectives = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PropertyOptimizationObjectivesWithParam(PropertyOptimizationObjectivesWithParam d) {
|
public PropertyOptimizationObjectivesWithParam(PropertyOptimizationObjectivesWithParam d) {
|
||||||
this.m_DescriptiveString = d.m_DescriptiveString;
|
this.m_DescriptiveString = d.m_DescriptiveString;
|
||||||
this.m_WeightsLabel = d.m_WeightsLabel;
|
this.m_WeightsLabel = d.m_WeightsLabel;
|
||||||
this.m_NormalizationEnabled = d.m_NormalizationEnabled;
|
this.m_NormalizationEnabled = d.m_NormalizationEnabled;
|
||||||
this.m_AvailableObjectives = new InterfaceOptimizationObjective[d.m_AvailableObjectives.length];
|
this.m_AvailableObjectives = new InterfaceOptimizationObjective[d.m_AvailableObjectives.length];
|
||||||
for (int i = 0; i < this.m_AvailableObjectives.length; i++) {
|
for (int i = 0; i < this.m_AvailableObjectives.length; i++) {
|
||||||
this.m_AvailableObjectives[i] = (InterfaceOptimizationObjective)d.m_AvailableObjectives[i].clone();
|
this.m_AvailableObjectives[i] = (InterfaceOptimizationObjective) d.m_AvailableObjectives[i].clone();
|
||||||
}
|
}
|
||||||
this.m_SelectedObjectives = new InterfaceOptimizationObjective[d.m_SelectedObjectives.length];
|
this.m_SelectedObjectives = new InterfaceOptimizationObjective[d.m_SelectedObjectives.length];
|
||||||
for (int i = 0; i < this.m_SelectedObjectives.length; i++) {
|
for (int i = 0; i < this.m_SelectedObjectives.length; i++) {
|
||||||
this.m_SelectedObjectives[i] = (InterfaceOptimizationObjective)d.m_SelectedObjectives[i].clone();
|
this.m_SelectedObjectives[i] = (InterfaceOptimizationObjective) d.m_SelectedObjectives[i].clone();
|
||||||
}
|
}
|
||||||
if (d.m_Weights != null) {
|
if (d.m_Weights != null) {
|
||||||
this.m_Weights = new double[d.m_Weights.length];
|
this.m_Weights = new double[d.m_Weights.length];
|
||||||
@@ -45,8 +46,10 @@ public class PropertyOptimizationObjectivesWithParam implements java.io.Serializ
|
|||||||
return (Object) new PropertyOptimizationObjectivesWithParam(this);
|
return (Object) new PropertyOptimizationObjectivesWithParam(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method will allow you to set the value of the InterfaceOptimizationTarget array
|
/**
|
||||||
* @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) {
|
public void setSelectedTargets(InterfaceOptimizationObjective[] d) {
|
||||||
this.m_SelectedObjectives = d;
|
this.m_SelectedObjectives = d;
|
||||||
@@ -62,7 +65,7 @@ public class PropertyOptimizationObjectivesWithParam implements java.io.Serializ
|
|||||||
if (d.length == this.m_Weights.length) {
|
if (d.length == this.m_Weights.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d.length > this.m_Weights.length) {
|
if (d.length > this.m_Weights.length) {
|
||||||
double[] newWeights = new double[d.length];
|
double[] newWeights = new double[d.length];
|
||||||
for (int i = 0; i < this.m_Weights.length; i++) {
|
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[].
|
* @return The InterfaceOptimizationTarget[].
|
||||||
*/
|
*/
|
||||||
public InterfaceOptimizationObjective[] getSelectedTargets() {
|
public InterfaceOptimizationObjective[] getSelectedTargets() {
|
||||||
return this.m_SelectedObjectives;
|
return this.m_SelectedObjectives;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method will return the InterfaceOptimizationTarget array
|
/**
|
||||||
|
* This method will return the InterfaceOptimizationTarget array
|
||||||
|
*
|
||||||
* @return The InterfaceOptimizationTarget[].
|
* @return The InterfaceOptimizationTarget[].
|
||||||
*/
|
*/
|
||||||
public InterfaceOptimizationObjective[] getAvailableTargets() {
|
public InterfaceOptimizationObjective[] getAvailableTargets() {
|
||||||
return this.m_AvailableObjectives;
|
return this.m_AvailableObjectives;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method allows you to read the weights
|
/**
|
||||||
|
* This method allows you to read the weights
|
||||||
|
*
|
||||||
* @return the weights
|
* @return the weights
|
||||||
*/
|
*/
|
||||||
public double[] getWeights() {
|
public double[] getWeights() {
|
||||||
return this.m_Weights;
|
return this.m_Weights;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWeights(double[] d) {
|
public void setWeights(double[] d) {
|
||||||
this.m_Weights = d;
|
this.m_Weights = d;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method allows you to set/get the descriptive string
|
/**
|
||||||
|
* This method allows you to set/get the descriptive string
|
||||||
|
*
|
||||||
* @return the string
|
* @return the string
|
||||||
*/
|
*/
|
||||||
public String getDescriptiveString() {
|
public String getDescriptiveString() {
|
||||||
return this.m_DescriptiveString;
|
return this.m_DescriptiveString;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDescriptiveString(String d) {
|
public void setDescriptiveString(String d) {
|
||||||
this.m_DescriptiveString = d;
|
this.m_DescriptiveString = d;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method allows you to set/get the weights label
|
/**
|
||||||
|
* This method allows you to set/get the weights label
|
||||||
|
*
|
||||||
* @return the string
|
* @return the string
|
||||||
*/
|
*/
|
||||||
public String getWeigthsLabel() {
|
public String getWeigthsLabel() {
|
||||||
return this.m_WeightsLabel;
|
return this.m_WeightsLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWeightsLabel(String d) {
|
public void setWeightsLabel(String d) {
|
||||||
this.m_WeightsLabel = d;
|
this.m_WeightsLabel = d;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method allows you to set/get the weights label
|
/**
|
||||||
|
* This method allows you to set/get the weights label
|
||||||
|
*
|
||||||
* @return the string
|
* @return the string
|
||||||
*/
|
*/
|
||||||
public boolean isNormalizationEnabled() {
|
public boolean isNormalizationEnabled() {
|
||||||
return this.m_NormalizationEnabled;
|
return this.m_NormalizationEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enableNormalization(boolean d) {
|
public void enableNormalization(boolean d) {
|
||||||
this.m_NormalizationEnabled = d;
|
this.m_NormalizationEnabled = d;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method allows you to remove a Target from the list
|
/**
|
||||||
* @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) {
|
public void removeTarget(int index) {
|
||||||
if ((index < 0) || (index >= this.m_SelectedObjectives.length)) {
|
if ((index < 0) || (index >= this.m_SelectedObjectives.length)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
InterfaceOptimizationObjective[] newList = new InterfaceOptimizationObjective[this.m_SelectedObjectives.length-1];
|
InterfaceOptimizationObjective[] newList = new InterfaceOptimizationObjective[this.m_SelectedObjectives.length - 1];
|
||||||
double[] newWeights = new double[this.m_Weights.length - 1];
|
double[] newWeights = new double[this.m_Weights.length - 1];
|
||||||
int j = 0;
|
int j = 0;
|
||||||
for (int i = 0; i < this.m_SelectedObjectives.length; i++) {
|
for (int i = 0; i < this.m_SelectedObjectives.length; i++) {
|
||||||
if (index != i) {
|
if (index != i) {
|
||||||
@@ -150,23 +171,25 @@ public class PropertyOptimizationObjectivesWithParam implements java.io.Serializ
|
|||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.m_SelectedObjectives = newList;
|
this.m_SelectedObjectives = newList;
|
||||||
this.m_Weights = newWeights;
|
this.m_Weights = newWeights;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method allows you to add a new target to the list
|
/**
|
||||||
|
* This method allows you to add a new target to the list
|
||||||
|
*
|
||||||
* @param optTarget
|
* @param optTarget
|
||||||
*/
|
*/
|
||||||
public void addTarget(InterfaceOptimizationObjective optTarget) {
|
public void addTarget(InterfaceOptimizationObjective optTarget) {
|
||||||
InterfaceOptimizationObjective[] newList = new InterfaceOptimizationObjective[this.m_SelectedObjectives.length+1];
|
InterfaceOptimizationObjective[] newList = new InterfaceOptimizationObjective[this.m_SelectedObjectives.length + 1];
|
||||||
double[] newWeights = new double[this.m_Weights.length + 1];
|
double[] newWeights = new double[this.m_Weights.length + 1];
|
||||||
for (int i = 0; i < this.m_SelectedObjectives.length; i++) {
|
for (int i = 0; i < this.m_SelectedObjectives.length; i++) {
|
||||||
newList[i] = this.m_SelectedObjectives[i];
|
newList[i] = this.m_SelectedObjectives[i];
|
||||||
newWeights[i] = this.m_Weights[i];
|
newWeights[i] = this.m_Weights[i];
|
||||||
}
|
}
|
||||||
newList[this.m_SelectedObjectives.length] = optTarget;
|
newList[this.m_SelectedObjectives.length] = optTarget;
|
||||||
newWeights[this.m_SelectedObjectives.length] = 1.0;
|
newWeights[this.m_SelectedObjectives.length] = 1.0;
|
||||||
this.m_SelectedObjectives = newList;
|
this.m_SelectedObjectives = newList;
|
||||||
this.m_Weights = newWeights;
|
this.m_Weights = newWeights;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,9 @@ package eva2.gui;
|
|||||||
* $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $
|
* $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $
|
||||||
* $Author: streiche $
|
* $Author: streiche $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import eva2.tools.EVAHELP;
|
import eva2.tools.EVAHELP;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
@@ -18,76 +20,77 @@ import javax.swing.BorderFactory;
|
|||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class PropertyPanel extends JPanel {
|
public class PropertyPanel extends JPanel {
|
||||||
private PropertyEditor propertyEditor;
|
private PropertyEditor propertyEditor;
|
||||||
private PropertyDialog propertyDialog;
|
private PropertyDialog propertyDialog;
|
||||||
|
|
||||||
private JLabel textLabel;
|
private JLabel textLabel;
|
||||||
/**
|
|
||||||
*
|
/**
|
||||||
*/
|
*
|
||||||
public PropertyPanel(PropertyEditor editor) {
|
*/
|
||||||
setToolTipText("Click to edit properties for this object");
|
public PropertyPanel(PropertyEditor editor) {
|
||||||
setOpaque(true);
|
setToolTipText("Click to edit properties for this object");
|
||||||
|
setOpaque(true);
|
||||||
|
|
||||||
setLayout(new GridBagLayout());
|
setLayout(new GridBagLayout());
|
||||||
GridBagConstraints gbConstraints = new GridBagConstraints();
|
GridBagConstraints gbConstraints = new GridBagConstraints();
|
||||||
gbConstraints.gridx = 0;
|
gbConstraints.gridx = 0;
|
||||||
gbConstraints.gridy = 0;
|
gbConstraints.gridy = 0;
|
||||||
gbConstraints.weightx = 1.0;
|
gbConstraints.weightx = 1.0;
|
||||||
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
|
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
|
||||||
propertyEditor = editor;
|
propertyEditor = editor;
|
||||||
|
|
||||||
textLabel = new JLabel();
|
textLabel = new JLabel();
|
||||||
|
|
||||||
add(textLabel, gbConstraints);
|
add(textLabel, gbConstraints);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showDialog(int initX, int initY) {
|
public void showDialog(int initX, int initY) {
|
||||||
if (propertyDialog == null) {
|
if (propertyDialog == null) {
|
||||||
propertyDialog = new PropertyDialog(propertyEditor, EVAHELP.cutClassName(propertyEditor.getClass().getName()) , initX, initY);
|
propertyDialog = new PropertyDialog(propertyEditor, EVAHELP.cutClassName(propertyEditor.getClass().getName()), initX, initY);
|
||||||
propertyDialog.setPreferredSize(new Dimension(500,300));
|
propertyDialog.setPreferredSize(new Dimension(500, 300));
|
||||||
propertyDialog.setModal(true);
|
propertyDialog.setModal(true);
|
||||||
propertyDialog.setVisible(true);
|
propertyDialog.setVisible(true);
|
||||||
}
|
} else {
|
||||||
else {
|
propertyDialog.updateFrameTitle(propertyEditor);
|
||||||
propertyDialog.updateFrameTitle(propertyEditor);
|
propertyDialog.setVisible(false);
|
||||||
propertyDialog.setVisible(false);
|
propertyDialog.requestFocus();
|
||||||
propertyDialog.requestFocus();
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
*
|
||||||
*
|
*/
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void removeNotify() {
|
public void removeNotify() {
|
||||||
if (propertyDialog != null) {
|
if (propertyDialog != null) {
|
||||||
propertyDialog = null;
|
propertyDialog = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void paintComponent(Graphics g) {
|
public void paintComponent(Graphics g) {
|
||||||
Insets i = textLabel.getInsets();
|
Insets i = textLabel.getInsets();
|
||||||
Rectangle box = new Rectangle(i.left, i.top,
|
Rectangle box = new Rectangle(i.left, i.top,
|
||||||
getSize().width - i.left - i.right ,
|
getSize().width - i.left - i.right,
|
||||||
getSize().height - i.top - i.bottom);
|
getSize().height - i.top - i.bottom);
|
||||||
g.clearRect(i.left, i.top,
|
g.clearRect(i.left, i.top,
|
||||||
getSize().width - i.right - i.left,
|
getSize().width - i.right - i.left,
|
||||||
getSize().height - i.bottom - i.top);
|
getSize().height - i.bottom - i.top);
|
||||||
propertyEditor.paintValue(g, box);
|
propertyEditor.paintValue(g, box);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PropertyEditor getEditor() {
|
public PropertyEditor getEditor() {
|
||||||
return propertyEditor;
|
return propertyEditor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,18 +12,18 @@ import java.beans.PropertyChangeSupport;
|
|||||||
*/
|
*/
|
||||||
public class PropertySelectableList<T> implements java.io.Serializable {
|
public class PropertySelectableList<T> implements java.io.Serializable {
|
||||||
|
|
||||||
protected T[] m_Objects;
|
protected T[] m_Objects;
|
||||||
protected boolean[] m_Selection;
|
protected boolean[] m_Selection;
|
||||||
private transient PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
private transient PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||||
|
|
||||||
// public PropertySelectableList() {
|
// public PropertySelectableList() {
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
public PropertySelectableList(T[] initial) {
|
public PropertySelectableList(T[] initial) {
|
||||||
m_Objects = initial;
|
m_Objects = initial;
|
||||||
m_Selection = new boolean[initial.length];
|
m_Selection = new boolean[initial.length];
|
||||||
}
|
}
|
||||||
|
|
||||||
public PropertySelectableList(PropertySelectableList<T> b) {
|
public PropertySelectableList(PropertySelectableList<T> b) {
|
||||||
if (b.m_Objects != null) {
|
if (b.m_Objects != null) {
|
||||||
this.m_Objects = b.m_Objects.clone();
|
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);
|
System.arraycopy(b.m_Selection, 0, this.m_Selection, 0, this.m_Selection.length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object clone() {
|
public Object clone() {
|
||||||
return (Object) new PropertySelectableList<T>(this);
|
return (Object) new PropertySelectableList<T>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setObjects(T[] o) {
|
public void setObjects(T[] o) {
|
||||||
this.m_Objects = o;
|
this.m_Objects = o;
|
||||||
this.m_Selection = new boolean[o.length];
|
this.m_Selection = new boolean[o.length];
|
||||||
m_Support.firePropertyChange("PropertySelectableList", null, this);
|
m_Support.firePropertyChange("PropertySelectableList", null, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setObjects(T[] o, boolean[] selection) {
|
public void setObjects(T[] o, boolean[] selection) {
|
||||||
this.m_Objects = o;
|
this.m_Objects = o;
|
||||||
this.m_Selection = selection;
|
this.m_Selection = selection;
|
||||||
@@ -53,77 +53,77 @@ public class PropertySelectableList<T> implements java.io.Serializable {
|
|||||||
}
|
}
|
||||||
m_Support.firePropertyChange("PropertySelectableList", null, this);
|
m_Support.firePropertyChange("PropertySelectableList", null, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public T[] getObjects() {
|
public T[] getObjects() {
|
||||||
return this.m_Objects;
|
return this.m_Objects;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the elements represented by this list where only the selected elements are non-null.
|
* Returns the elements represented by this list where only the selected elements are non-null.
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public T[] getSelectedObjects() {
|
public T[] getSelectedObjects() {
|
||||||
T[] selObjects = getObjects().clone();
|
T[] selObjects = getObjects().clone();
|
||||||
for (int i=0; i<selObjects.length; i++) {
|
for (int i = 0; i < selObjects.length; i++) {
|
||||||
if (!m_Selection[i]) {
|
if (!m_Selection[i]) {
|
||||||
selObjects[i]=null;
|
selObjects[i] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return selObjects;
|
return selObjects;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the selection by giving a list of selected indices.
|
* Set the selection by giving a list of selected indices.
|
||||||
*
|
*
|
||||||
* @param selection
|
* @param selection
|
||||||
*/
|
*/
|
||||||
public void setSelectionByIndices(int[] selection) {
|
public void setSelectionByIndices(int[] selection) {
|
||||||
m_Selection = new boolean[getObjects().length];
|
m_Selection = new boolean[getObjects().length];
|
||||||
for (int i=0; i<selection.length; i++) {
|
for (int i = 0; i < selection.length; i++) {
|
||||||
m_Selection[selection[i]]=true;
|
m_Selection[selection[i]] = true;
|
||||||
}
|
}
|
||||||
m_Support.firePropertyChange("PropertySelectableList", null, this);
|
m_Support.firePropertyChange("PropertySelectableList", null, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSelection(boolean[] selection) {
|
public void setSelection(boolean[] selection) {
|
||||||
this.m_Selection = selection;
|
this.m_Selection = selection;
|
||||||
m_Support.firePropertyChange("PropertySelectableList", null, this);
|
m_Support.firePropertyChange("PropertySelectableList", null, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean[] getSelection() {
|
public boolean[] getSelection() {
|
||||||
return this.m_Selection;
|
return this.m_Selection;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSelectionForElement(int index, boolean b) {
|
public void setSelectionForElement(int index, boolean b) {
|
||||||
if (m_Selection[index]!=b) {
|
if (m_Selection[index] != b) {
|
||||||
this.m_Selection[index] = b;
|
this.m_Selection[index] = b;
|
||||||
m_Support.firePropertyChange("PropertySelectableList", null, this);
|
m_Support.firePropertyChange("PropertySelectableList", null, this);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int size() {
|
|
||||||
if (m_Objects == null) {
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
else {
|
}
|
||||||
|
|
||||||
|
public int size() {
|
||||||
|
if (m_Objects == null) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
return m_Objects.length;
|
return m_Objects.length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public T get(int i) {
|
public T get(int i) {
|
||||||
return m_Objects[i];
|
return m_Objects[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSelected(int i) {
|
public boolean isSelected(int i) {
|
||||||
return m_Selection[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.
|
// * Append an object at the end of the list and immediately select it.
|
||||||
// * @param o
|
// * @param o
|
||||||
@@ -144,18 +144,18 @@ public class PropertySelectableList<T> implements java.io.Serializable {
|
|||||||
// }
|
// }
|
||||||
// m_Support.firePropertyChange("PropertySelectableList", null, this);
|
// 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) {
|
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||||
if (m_Support == null) {
|
if (m_Support == null) {
|
||||||
m_Support = new PropertyChangeSupport(this);
|
m_Support = new PropertyChangeSupport(this);
|
||||||
}
|
}
|
||||||
m_Support.removePropertyChangeListener(l);
|
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) $
|
* $Date: 2007-12-05 11:29:32 +0100 (Wed, 05 Dec 2007) $
|
||||||
* $Author: mkron $
|
* $Author: mkron $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import eva2.gui.editor.GenericObjectEditor;
|
import eva2.gui.editor.GenericObjectEditor;
|
||||||
import eva2.tools.EVAHELP;
|
import eva2.tools.EVAHELP;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
@@ -25,6 +27,7 @@ import javax.swing.table.DefaultTableModel;
|
|||||||
import javax.swing.table.TableCellEditor;
|
import javax.swing.table.TableCellEditor;
|
||||||
import javax.swing.table.TableCellRenderer;
|
import javax.swing.table.TableCellRenderer;
|
||||||
import javax.swing.table.TableModel;
|
import javax.swing.table.TableModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* There are some trick methods interpreted here. Check EvA2Notes.txt.
|
* There are some trick methods interpreted here. Check EvA2Notes.txt.
|
||||||
*/
|
*/
|
||||||
@@ -92,7 +95,7 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
|||||||
boolean stripToolTipToFirstPoint = false;
|
boolean stripToolTipToFirstPoint = false;
|
||||||
private JTable propertyTable;
|
private JTable propertyTable;
|
||||||
private DefaultTableModel propertyTableModel;
|
private DefaultTableModel propertyTableModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the property sheet panel.
|
* Creates the property sheet panel.
|
||||||
*/
|
*/
|
||||||
@@ -120,7 +123,7 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
|||||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||||
if (propertyChangeSupport == null) {
|
if (propertyChangeSupport == null) {
|
||||||
propertyChangeSupport = new PropertyChangeSupport(this);
|
propertyChangeSupport = new PropertyChangeSupport(this);
|
||||||
}
|
}
|
||||||
propertyChangeSupport.addPropertyChangeListener(l);
|
propertyChangeSupport.addPropertyChangeListener(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,41 +131,41 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
|||||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||||
if (propertyChangeSupport == null) {
|
if (propertyChangeSupport == null) {
|
||||||
propertyChangeSupport = new PropertyChangeSupport(this);
|
propertyChangeSupport = new PropertyChangeSupport(this);
|
||||||
}
|
}
|
||||||
propertyChangeSupport.removePropertyChangeListener(l);
|
propertyChangeSupport.removePropertyChangeListener(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a fitting viewer component for an editor instance. If none can be
|
* Create a fitting viewer component for an editor instance. If none can be
|
||||||
* identified, null is returned.
|
* identified, null is returned.
|
||||||
*
|
*
|
||||||
* @param editor
|
* @param editor
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static JComponent getView(PropertyEditor editor) {
|
public static JComponent getView(PropertyEditor editor) {
|
||||||
JComponent view = null;
|
JComponent view = null;
|
||||||
// Now figure out how to display it...
|
// Now figure out how to display it...
|
||||||
if (editor.isPaintable() && editor.supportsCustomEditor()) {
|
if (editor.isPaintable() && editor.supportsCustomEditor()) {
|
||||||
view = new PropertyPanel(editor);
|
view = new PropertyPanel(editor);
|
||||||
} else {
|
} else {
|
||||||
String[] tags = editor.getTags();
|
String[] tags = editor.getTags();
|
||||||
if (tags != null) {
|
if (tags != null) {
|
||||||
if ((tags.length == 2) && (tags[0].equals("True")) && (tags[1].equals("False"))) {
|
if ((tags.length == 2) && (tags[0].equals("True")) && (tags[1].equals("False"))) {
|
||||||
view = new PropertyBoolSelector(editor);
|
view = new PropertyBoolSelector(editor);
|
||||||
} else {
|
} else {
|
||||||
view = new PropertyValueSelector(editor);
|
view = new PropertyValueSelector(editor);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (editor.getAsText() != null) {
|
if (editor.getAsText() != null) {
|
||||||
view = new PropertyText(editor);
|
view = new PropertyText(editor);
|
||||||
} else {
|
} else {
|
||||||
view = null;
|
view = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a new target object for customisation.
|
* Sets a new target object for customisation.
|
||||||
*
|
*
|
||||||
@@ -171,7 +174,7 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
|||||||
public synchronized void setTarget(Object targ) {
|
public synchronized void setTarget(Object targ) {
|
||||||
propertyTableModel = new DefaultTableModel();
|
propertyTableModel = new DefaultTableModel();
|
||||||
propertyTableModel.addColumn("Key");
|
propertyTableModel.addColumn("Key");
|
||||||
propertyTableModel.addColumn("Value");
|
propertyTableModel.addColumn("Value");
|
||||||
propertyTable = new JTable(propertyTableModel);
|
propertyTable = new JTable(propertyTableModel);
|
||||||
propertyTable.setDefaultRenderer(Object.class, new PropertyCellRenderer());
|
propertyTable.setDefaultRenderer(Object.class, new PropertyCellRenderer());
|
||||||
propertyTable.setDefaultEditor(Object.class, new PropertyCellEditor());
|
propertyTable.setDefaultEditor(Object.class, new PropertyCellEditor());
|
||||||
@@ -194,7 +197,7 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
int rowHeight = 12;
|
int rowHeight = 12;
|
||||||
|
|
||||||
GridBagConstraints gbConstraints = new GridBagConstraints();
|
GridBagConstraints gbConstraints = new GridBagConstraints();
|
||||||
gbConstraints.fill = GridBagConstraints.BOTH;
|
gbConstraints.fill = GridBagConstraints.BOTH;
|
||||||
|
|
||||||
@@ -212,7 +215,7 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
|||||||
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
|
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
|
||||||
gbConstraints.anchor = GridBagConstraints.PAGE_START;
|
gbConstraints.anchor = GridBagConstraints.PAGE_START;
|
||||||
add(infoPanel, gbConstraints);
|
add(infoPanel, gbConstraints);
|
||||||
}
|
}
|
||||||
methsFound++;
|
methsFound++;
|
||||||
} // end if (name.equals("globalInfo")) {
|
} // end if (name.equals("globalInfo")) {
|
||||||
else if (name.equals("hideHideable")) {
|
else if (name.equals("hideHideable")) {
|
||||||
@@ -221,10 +224,10 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
|||||||
meth.invoke(targetObject, args);
|
meth.invoke(targetObject, args);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
}
|
}
|
||||||
methsFound++;
|
methsFound++;
|
||||||
} else if (name.equals("customPropertyOrder")) {
|
} else if (name.equals("customPropertyOrder")) {
|
||||||
methsFound++;
|
methsFound++;
|
||||||
reorderProperties(meth);
|
reorderProperties(meth);
|
||||||
}
|
}
|
||||||
if (methsFound == 3) {
|
if (methsFound == 3) {
|
||||||
break; // small speed-up
|
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++) {
|
} // end for (int i = 0; i < m_Methods.length; i++) {
|
||||||
// restore hide states of all properties
|
// restore hide states of all properties
|
||||||
// GenericObjectEditor.setHideProperties(m_Target.getClass(), hideStateBackup);
|
// GenericObjectEditor.setHideProperties(m_Target.getClass(), hideStateBackup);
|
||||||
|
|
||||||
// Now lets search for the individual properties, their
|
// Now lets search for the individual properties, their
|
||||||
// values, views and editors...
|
// values, views and editors...
|
||||||
propertyEditors = new PropertyEditor[propertyDescriptors.length];
|
propertyEditors = new PropertyEditor[propertyDescriptors.length];
|
||||||
@@ -243,7 +246,7 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
|||||||
propertyLabels = new JLabel[propertyDescriptors.length];
|
propertyLabels = new JLabel[propertyDescriptors.length];
|
||||||
toolTips = new String[propertyDescriptors.length];
|
toolTips = new String[propertyDescriptors.length];
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < propertyDescriptors.length; i++) {
|
for (int i = 0; i < propertyDescriptors.length; i++) {
|
||||||
// For each property do this
|
// For each property do this
|
||||||
// Don't display hidden or expert properties.
|
// Don't display hidden or expert properties.
|
||||||
@@ -278,7 +281,7 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
|||||||
name = eva2.tools.StringTools.humaniseCamelCase(name);
|
name = eva2.tools.StringTools.humaniseCamelCase(name);
|
||||||
propertyTableModel.addRow(new Object[]{name, newView});
|
propertyTableModel.addRow(new Object[]{name, newView});
|
||||||
}
|
}
|
||||||
|
|
||||||
JScrollPane scrollableTable = new JScrollPane(propertyTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
JScrollPane scrollableTable = new JScrollPane(propertyTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||||
gbConstraints.gridx = 0;
|
gbConstraints.gridx = 0;
|
||||||
gbConstraints.gridy = 1;
|
gbConstraints.gridy = 1;
|
||||||
@@ -294,38 +297,38 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
|||||||
|
|
||||||
public static PropertyDescriptor[] getProperties(Object target) {
|
public static PropertyDescriptor[] getProperties(Object target) {
|
||||||
BeanInfo bi;
|
BeanInfo bi;
|
||||||
try {
|
try {
|
||||||
bi = Introspector.getBeanInfo(target.getClass());
|
bi = Introspector.getBeanInfo(target.getClass());
|
||||||
} catch (IntrospectionException e) {
|
} catch (IntrospectionException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return bi.getPropertyDescriptors();
|
return bi.getPropertyDescriptors();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] getPropertyNames(Object target) {
|
public static String[] getPropertyNames(Object target) {
|
||||||
return getNames(getProperties(target));
|
return getNames(getProperties(target));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object[] getPropertyValues(Object target, boolean omitExpert, boolean omitHidden, boolean onlySetAndGettable) {
|
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) {
|
public static String[] getNames(PropertyDescriptor[] props) {
|
||||||
String[] names = new String[props.length];
|
String[] names = new String[props.length];
|
||||||
for (int i = 0; i < props.length; i++) {
|
for (int i = 0; i < props.length; i++) {
|
||||||
names[i] = props[i].getDisplayName();
|
names[i] = props[i].getDisplayName();
|
||||||
}
|
}
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cycle the properties and request the value of each in an array. Null
|
* 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
|
* values may indicate missing getter/setter, expert flag or hidden flag set
|
||||||
* depending on the parameters. Note that to show hidden properties
|
* depending on the parameters. Note that to show hidden properties
|
||||||
* dynamically, views may need be constructed for them anyways, so do not
|
* dynamically, views may need be constructed for them anyways, so do not
|
||||||
* omit them here.
|
* omit them here.
|
||||||
*
|
*
|
||||||
* @param props
|
* @param props
|
||||||
* @param omitExpert
|
* @param omitExpert
|
||||||
* @param omitHidden
|
* @param omitHidden
|
||||||
@@ -338,7 +341,7 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
|||||||
// For each property do this
|
// For each property do this
|
||||||
// Don't display hidden or expert properties.
|
// Don't display hidden or expert properties.
|
||||||
// if (m_Properties[i].isHidden() || m_Properties[i].isExpert()) continue;
|
// 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();
|
String name = props[i].getDisplayName();
|
||||||
if (props[i].isExpert() && omitExpert) {
|
if (props[i].isExpert() && omitExpert) {
|
||||||
continue;
|
continue;
|
||||||
@@ -353,49 +356,49 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Object args[] = {};
|
Object args[] = {};
|
||||||
Object value = null;
|
Object value = null;
|
||||||
try {
|
try {
|
||||||
value = getter.invoke(target, args);
|
value = getter.invoke(target, args);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("Exception on getting value for property " + name + " on target " + target.toString());
|
System.out.println("Exception on getting value for property " + name + " on target " + target.toString());
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
values[i] = null;
|
values[i] = null;
|
||||||
}
|
}
|
||||||
// PropertyEditor editor = null;
|
// PropertyEditor editor = null;
|
||||||
//Class pec = m_Properties[i].getPropertyEditorClass();
|
//Class pec = m_Properties[i].getPropertyEditorClass();
|
||||||
values[i] = value;
|
values[i] = value;
|
||||||
|
|
||||||
} // end for each property
|
} // end for each property
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a label to be shown if no other properties are shown.
|
* Create a label to be shown if no other properties are shown.
|
||||||
*
|
*
|
||||||
* @param componentOffset
|
* @param componentOffset
|
||||||
* @param gbLayout
|
* @param gbLayout
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private JLabel createDummyLabel(int componentOffset, GridBagLayout gbLayout) {
|
private JLabel createDummyLabel(int componentOffset, GridBagLayout gbLayout) {
|
||||||
JLabel empty = new JLabel("No editable properties", SwingConstants.CENTER);
|
JLabel empty = new JLabel("No editable properties", SwingConstants.CENTER);
|
||||||
Dimension d = empty.getPreferredSize();
|
Dimension d = empty.getPreferredSize();
|
||||||
empty.setPreferredSize(new Dimension(d.width * 2, d.height * 2));
|
empty.setPreferredSize(new Dimension(d.width * 2, d.height * 2));
|
||||||
empty.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 10));
|
empty.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 10));
|
||||||
GridBagConstraints gbConstraints = new GridBagConstraints();
|
GridBagConstraints gbConstraints = new GridBagConstraints();
|
||||||
gbConstraints.anchor = GridBagConstraints.CENTER;
|
gbConstraints.anchor = GridBagConstraints.CENTER;
|
||||||
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
|
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
|
||||||
gbConstraints.gridy = componentOffset;
|
gbConstraints.gridy = componentOffset;
|
||||||
gbConstraints.gridx = 0;
|
gbConstraints.gridx = 0;
|
||||||
gbLayout.setConstraints(empty, gbConstraints);
|
gbLayout.setConstraints(empty, gbConstraints);
|
||||||
return empty;
|
return empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PropertyEditor makeEditor(PropertyDescriptor property, String name, Object value) {
|
private PropertyEditor makeEditor(PropertyDescriptor property, String name, Object value) {
|
||||||
PropertyEditor editor = PropertyEditorProvider.findEditor(property, value);
|
PropertyEditor editor = PropertyEditorProvider.findEditor(property, value);
|
||||||
if (editor == null) {
|
if (editor == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't try to set null values:
|
// Don't try to set null values:
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
// If it's a user-defined property we give a warning.
|
// 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);
|
editor.setValue(value);
|
||||||
|
|
||||||
// System.out.println("PSP editor class: " + editor.getClass());
|
// System.out.println("PSP editor class: " + editor.getClass());
|
||||||
|
|
||||||
editor.addPropertyChangeListener(this);
|
editor.addPropertyChangeListener(this);
|
||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addLabelView(int componentOffset, GridBagLayout gbLayout,
|
private void addLabelView(int componentOffset, GridBagLayout gbLayout,
|
||||||
int i, String name, JComponent newView) {
|
int i, String name, JComponent newView) {
|
||||||
|
|
||||||
propertyLabels[i] = makeLabel(name);
|
propertyLabels[i] = makeLabel(name);
|
||||||
views[i] = newView;
|
views[i] = newView;
|
||||||
viewWrappers[i] = new JPanel();
|
viewWrappers[i] = new JPanel();
|
||||||
@@ -425,50 +428,50 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
|||||||
add(propertyLabels[i]);
|
add(propertyLabels[i]);
|
||||||
JPanel newPanel = makeViewPanel(toolTips[i], propertyLabels[i], views[i], viewWrappers[i]);
|
JPanel newPanel = makeViewPanel(toolTips[i], propertyLabels[i], views[i], viewWrappers[i]);
|
||||||
gbLayout.setConstraints(newPanel, makeViewConstraints(i + componentOffset));
|
gbLayout.setConstraints(newPanel, makeViewConstraints(i + componentOffset));
|
||||||
add(newPanel);
|
add(newPanel);
|
||||||
}
|
}
|
||||||
|
|
||||||
private JLabel makeLabel(String name) {
|
private JLabel makeLabel(String name) {
|
||||||
JLabel label = new JLabel(name, SwingConstants.RIGHT);
|
JLabel label = new JLabel(name, SwingConstants.RIGHT);
|
||||||
label.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 5));
|
label.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 5));
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static JPanel makeViewPanel(String tipText, JLabel label,
|
private static JPanel makeViewPanel(String tipText, JLabel label,
|
||||||
JComponent view, JComponent viewWrapper) {
|
JComponent view, JComponent viewWrapper) {
|
||||||
JPanel newPanel = new JPanel();
|
JPanel newPanel = new JPanel();
|
||||||
if (tipText != null) {
|
if (tipText != null) {
|
||||||
label.setToolTipText(tipText);
|
label.setToolTipText(tipText);
|
||||||
view.setToolTipText(tipText);
|
view.setToolTipText(tipText);
|
||||||
}
|
}
|
||||||
newPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 10));
|
newPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 10));
|
||||||
newPanel.setLayout(new BorderLayout());
|
newPanel.setLayout(new BorderLayout());
|
||||||
// @todo: Streiche here i could add the ViewWrapper
|
// @todo: Streiche here i could add the ViewWrapper
|
||||||
viewWrapper.add(view, BorderLayout.CENTER);
|
viewWrapper.add(view, BorderLayout.CENTER);
|
||||||
newPanel.add(viewWrapper, BorderLayout.CENTER);
|
newPanel.add(viewWrapper, BorderLayout.CENTER);
|
||||||
return newPanel;
|
return newPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private GridBagConstraints makeLabelConstraints(int componentIndex) {
|
private GridBagConstraints makeLabelConstraints(int componentIndex) {
|
||||||
GridBagConstraints gbConstraints = new GridBagConstraints();
|
GridBagConstraints gbConstraints = new GridBagConstraints();
|
||||||
gbConstraints.anchor = GridBagConstraints.EAST;
|
gbConstraints.anchor = GridBagConstraints.EAST;
|
||||||
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
|
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
|
||||||
gbConstraints.gridy = componentIndex;
|
gbConstraints.gridy = componentIndex;
|
||||||
gbConstraints.gridx = 0;
|
gbConstraints.gridx = 0;
|
||||||
return gbConstraints;
|
return gbConstraints;
|
||||||
}
|
}
|
||||||
|
|
||||||
private GridBagConstraints makeViewConstraints(int componentIndex) {
|
private GridBagConstraints makeViewConstraints(int componentIndex) {
|
||||||
GridBagConstraints gbConstraints = new GridBagConstraints();
|
GridBagConstraints gbConstraints = new GridBagConstraints();
|
||||||
gbConstraints.anchor = GridBagConstraints.WEST;
|
gbConstraints.anchor = GridBagConstraints.WEST;
|
||||||
gbConstraints.fill = GridBagConstraints.BOTH;
|
gbConstraints.fill = GridBagConstraints.BOTH;
|
||||||
gbConstraints.gridy = componentIndex;
|
gbConstraints.gridy = componentIndex;
|
||||||
gbConstraints.gridx = 1;
|
gbConstraints.gridx = 1;
|
||||||
gbConstraints.weightx = 100;
|
gbConstraints.weightx = 100;
|
||||||
return gbConstraints;
|
return gbConstraints;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Be sure to give a clone
|
* Be sure to give a clone
|
||||||
*
|
*
|
||||||
* @param oldProps
|
* @param oldProps
|
||||||
@@ -479,79 +482,79 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
|||||||
// Mathematics.revertArray(oldProps, newProps);
|
// Mathematics.revertArray(oldProps, newProps);
|
||||||
Object[] args = {};
|
Object[] args = {};
|
||||||
Object retV = null;
|
Object retV = null;
|
||||||
PropertyDescriptor[] newProps = null;
|
PropertyDescriptor[] newProps = null;
|
||||||
try {
|
try {
|
||||||
retV = meth.invoke(targetObject, args); // should return String[] to be interpreted as a list of ordered properties
|
retV = meth.invoke(targetObject, args); // should return String[] to be interpreted as a list of ordered properties
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
}
|
}
|
||||||
if (retV != null) {
|
if (retV != null) {
|
||||||
try {
|
try {
|
||||||
if (retV.getClass().isArray()) { // reorder the properties
|
if (retV.getClass().isArray()) { // reorder the properties
|
||||||
String[] swProps = (String[]) retV;
|
String[] swProps = (String[]) retV;
|
||||||
PropertyDescriptor[] oldProps = propertyDescriptors.clone();
|
PropertyDescriptor[] oldProps = propertyDescriptors.clone();
|
||||||
newProps = new PropertyDescriptor[oldProps.length];
|
newProps = new PropertyDescriptor[oldProps.length];
|
||||||
//int findFirst=findFirstProp(props[0], oldProps);
|
//int findFirst=findFirstProp(props[0], oldProps);
|
||||||
int firstNonNull = 0;
|
int firstNonNull = 0;
|
||||||
for (int i = 0; i < oldProps.length; i++) {
|
for (int i = 0; i < oldProps.length; i++) {
|
||||||
if (i < swProps.length) {
|
if (i < swProps.length) {
|
||||||
int pInOld = findProp(oldProps, swProps[i]);
|
int pInOld = findProp(oldProps, swProps[i]);
|
||||||
newProps[i] = oldProps[pInOld];
|
newProps[i] = oldProps[pInOld];
|
||||||
oldProps[pInOld] = null;
|
oldProps[pInOld] = null;
|
||||||
} else {
|
} else {
|
||||||
firstNonNull = findFirstNonNullAfter(oldProps, firstNonNull);
|
firstNonNull = findFirstNonNullAfter(oldProps, firstNonNull);
|
||||||
newProps[i] = oldProps[firstNonNull];
|
newProps[i] = oldProps[firstNonNull];
|
||||||
firstNonNull++;
|
firstNonNull++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
propertyDescriptors = newProps;
|
propertyDescriptors = newProps;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.err.println("Error during reordering properties: " + e.getMessage());
|
System.err.println("Error during reordering properties: " + e.getMessage());
|
||||||
return propertyDescriptors;
|
return propertyDescriptors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return newProps;
|
return newProps;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find the first non-null entry in an Array at or after the given index and
|
* 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.
|
* return its index. If only null entries are found, -1 is returned.
|
||||||
*
|
*
|
||||||
* @param arr
|
* @param arr
|
||||||
* @param firstLook
|
* @param firstLook
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private int findFirstNonNullAfter(PropertyDescriptor[] arr,
|
private int findFirstNonNullAfter(PropertyDescriptor[] arr,
|
||||||
int firstLook) {
|
int firstLook) {
|
||||||
for (int i = firstLook; i < arr.length; i++) {
|
for (int i = firstLook; i < arr.length; i++) {
|
||||||
if (arr[i] != null) {
|
if (arr[i] != null) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find a string property in an array and return its index or -1 if not
|
* Find a string property in an array and return its index or -1 if not
|
||||||
* found.
|
* found.
|
||||||
*
|
*
|
||||||
* @param oldProps
|
* @param oldProps
|
||||||
* @param string
|
* @param string
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private int findProp(PropertyDescriptor[] oldProps, String string) {
|
private int findProp(PropertyDescriptor[] oldProps, String string) {
|
||||||
for (int i = 0; i < oldProps.length; i++) {
|
for (int i = 0; i < oldProps.length; i++) {
|
||||||
if (oldProps[i] == null) {
|
if (oldProps[i] == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String name = oldProps[i].getDisplayName();
|
String name = oldProps[i].getDisplayName();
|
||||||
if (name.compareTo(string) == 0) {
|
if (name.compareTo(string) == 0) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.err.println("Error, property not found: " + string);
|
System.err.println("Error, property not found: " + string);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JPanel makeInfoPanel(Method meth, Object targ, int rowHeight) {
|
private JPanel makeInfoPanel(Method meth, Object targ, int rowHeight) {
|
||||||
if (meth.getReturnType().equals(String.class)) {
|
if (meth.getReturnType().equals(String.class)) {
|
||||||
@@ -583,9 +586,9 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
|||||||
infoPanel.setBorder(BorderFactory.createTitledBorder("Info"));
|
infoPanel.setBorder(BorderFactory.createTitledBorder("Info"));
|
||||||
infoPanel.setLayout(new BorderLayout());
|
infoPanel.setLayout(new BorderLayout());
|
||||||
infoPanel.add(infoTextArea, BorderLayout.CENTER);
|
infoPanel.add(infoTextArea, BorderLayout.CENTER);
|
||||||
|
|
||||||
if (HtmlDemo.resourceExists(getHelpFileName())) {
|
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);
|
infoPanel.add(helpButton, BorderLayout.LINE_END);
|
||||||
} else {
|
} else {
|
||||||
LOGGER.log(Level.FINE, "Not adding help button because of missing {0}", getHelpFileName());
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String translateGreek(String name) {
|
private String translateGreek(String name) {
|
||||||
// Add some specific display for some greeks here
|
// Add some specific display for some greeks here
|
||||||
if (name.equalsIgnoreCase("alpha")) {
|
if (name.equalsIgnoreCase("alpha")) {
|
||||||
@@ -703,19 +706,19 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
|||||||
if (name.equalsIgnoreCase("pib")) {
|
if (name.equalsIgnoreCase("pib")) {
|
||||||
return "\u03A0";
|
return "\u03A0";
|
||||||
}
|
}
|
||||||
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
* Get the html help file name.
|
* Get the html help file name.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected String getHelpFileName() {
|
protected String getHelpFileName() {
|
||||||
return EVAHELP.cutClassName(className) + ".html";
|
return EVAHELP.cutClassName(className) + ".html";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method opens a help frame.
|
* This method opens a help frame.
|
||||||
*/
|
*/
|
||||||
@@ -732,10 +735,10 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
|||||||
public int editableProperties() {
|
public int editableProperties() {
|
||||||
return numEditableProperties;
|
return numEditableProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if the modification was successful.
|
* Return true if the modification was successful.
|
||||||
*
|
*
|
||||||
* @param i
|
* @param i
|
||||||
* @param newValue
|
* @param newValue
|
||||||
* @return
|
* @return
|
||||||
@@ -761,12 +764,12 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
|||||||
((GenericObjectEditor) tmpEdit).setClassType(propertyDescriptors[i].getPropertyType());
|
((GenericObjectEditor) tmpEdit).setClassType(propertyDescriptors[i].getPropertyType());
|
||||||
}
|
}
|
||||||
propertyEditors[i].setValue(newValue);
|
propertyEditors[i].setValue(newValue);
|
||||||
JComponent newView = null;
|
JComponent newView = null;
|
||||||
newView = getView(tmpEdit);
|
newView = getView(tmpEdit);
|
||||||
if (newView == null) {
|
if (newView == null) {
|
||||||
System.err.println("Warning: Property \"" + propertyDescriptors[i].getDisplayName() + "\" has non-displayable editor. Skipping.");
|
System.err.println("Warning: Property \"" + propertyDescriptors[i].getDisplayName() + "\" has non-displayable editor. Skipping.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
propertyEditors[i].addPropertyChangeListener(this);
|
propertyEditors[i].addPropertyChangeListener(this);
|
||||||
views[i] = newView;
|
views[i] = newView;
|
||||||
if (toolTips[i] != null) {
|
if (toolTips[i] != null) {
|
||||||
@@ -777,7 +780,7 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
|||||||
viewWrappers[i].add(views[i], BorderLayout.CENTER);
|
viewWrappers[i].add(views[i], BorderLayout.CENTER);
|
||||||
viewWrappers[i].repaint();
|
viewWrappers[i].repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
// System.out.println("Value: "+value +" / m_Values[i]: " + m_Values[i]);
|
// System.out.println("Value: "+value +" / m_Values[i]: " + m_Values[i]);
|
||||||
// Now try to update the target with the new value of the property
|
// 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
|
// 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();
|
PropertyEditor editor = (PropertyEditor) evt.getSource();
|
||||||
for (int i = 0; i < propertyEditors.length; i++) {
|
for (int i = 0; i < propertyEditors.length; i++) {
|
||||||
if (propertyEditors[i] == editor) {
|
if (propertyEditors[i] == editor) {
|
||||||
propIndex = i;
|
propIndex = i;
|
||||||
if (wasModified(i, editor.getValue(), true)) {
|
if (wasModified(i, editor.getValue(), true)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (propIndex == -1) {
|
if (propIndex == -1) {
|
||||||
System.err.println("error: could not identify event editor! (PropertySheetPanel)");
|
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)");
|
System.err.println("unknown event source! (PropertySheetPanel)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the propertysheet when a value has been changed (from outside the
|
* Updates the propertysheet when a value has been changed (from outside the
|
||||||
* propertysheet?).
|
* propertysheet?).
|
||||||
@@ -855,24 +858,24 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
|||||||
synchronized boolean wasModified(int propIndex, Object value, boolean followDependencies) {
|
synchronized boolean wasModified(int propIndex, Object value, boolean followDependencies) {
|
||||||
if (!updateValue(propIndex, value)) {
|
if (!updateValue(propIndex, value)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean doRepaint = 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
|
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)) {
|
if (updateFieldView(i)) {
|
||||||
doRepaint = true;
|
doRepaint = true;
|
||||||
}
|
}
|
||||||
}// end if (m_Editors[i] == editor) {
|
}// end if (m_Editors[i] == editor) {
|
||||||
} // end for (int i = 0 ; i < m_Editors.length; i++) {
|
} // end for (int i = 0 ; i < m_Editors.length; i++) {
|
||||||
if (doRepaint) { // some components have been hidden or reappeared
|
if (doRepaint) { // some components have been hidden or reappeared
|
||||||
// MK this finally seems to work right, with a scroll pane, too.
|
// MK this finally seems to work right, with a scroll pane, too.
|
||||||
Container p = this;
|
Container p = this;
|
||||||
while (p != null && (!p.getSize().equals(p.getPreferredSize()))) {
|
while (p != null && (!p.getSize().equals(p.getPreferredSize()))) {
|
||||||
p.setSize(p.getPreferredSize());
|
p.setSize(p.getPreferredSize());
|
||||||
p = p.getParent();
|
p = p.getParent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now re-read all the properties and update the editors
|
// Now re-read all the properties and update the editors
|
||||||
@@ -888,44 +891,44 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
|||||||
Object args[] = {};
|
Object args[] = {};
|
||||||
o = getter.invoke(targetObject, args);
|
o = getter.invoke(targetObject, args);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
o = null;
|
o = null;
|
||||||
System.err.println(ex.getMessage());
|
System.err.println(ex.getMessage());
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
if ((o != null) && o == objectValues[i] && (BeanInspector.isJavaPrimitive(o.getClass()))) {
|
if ((o != null) && o == objectValues[i] && (BeanInspector.isJavaPrimitive(o.getClass()))) {
|
||||||
// The property is equal to its old value.
|
// The property is equal to its old value.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (o != null && o.equals(objectValues[i])) {
|
if (o != null && o.equals(objectValues[i])) {
|
||||||
// The property is equal to its old value.
|
// The property is equal to its old value.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
objectValues[i] = o;
|
objectValues[i] = o;
|
||||||
// Make sure we have an editor for this property...
|
// Make sure we have an editor for this property...
|
||||||
if (propertyEditors[i] == null) {
|
if (propertyEditors[i] == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// The property has changed! Update the editor.
|
// The property has changed! Update the editor.
|
||||||
propertyEditors[i].removePropertyChangeListener(this);
|
propertyEditors[i].removePropertyChangeListener(this);
|
||||||
propertyEditors[i].setValue(o);
|
propertyEditors[i].setValue(o);
|
||||||
propertyEditors[i].addPropertyChangeListener(this);
|
propertyEditors[i].addPropertyChangeListener(this);
|
||||||
if (views[i] != null) {
|
if (views[i] != null) {
|
||||||
//System.out.println("Trying to repaint " + (i + 1));
|
//System.out.println("Trying to repaint " + (i + 1));
|
||||||
views[i].repaint();
|
views[i].repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (followDependencies) {
|
if (followDependencies) {
|
||||||
// Handle the special method getGOEPropertyUpdateLinks which returns a list of pairs
|
// 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
|
// 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
|
// 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.)
|
// 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);
|
Object o = BeanInspector.callIfAvailable(targetObject, "getGOEPropertyUpdateLinks", null);
|
||||||
if ((o != null) && (o instanceof String[])) {
|
if ((o != null) && (o instanceof String[])) {
|
||||||
maybeTriggerUpdates(propIndex, (String[]) o);
|
maybeTriggerUpdates(propIndex, (String[]) o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the target bean gets repainted.
|
// Make sure the target bean gets repainted.
|
||||||
if (Beans.isInstanceOf(targetObject, Component.class)) {
|
if (Beans.isInstanceOf(targetObject, Component.class)) {
|
||||||
//System.out.println("Beans.getInstanceOf repaint ");
|
//System.out.println("Beans.getInstanceOf repaint ");
|
||||||
@@ -942,100 +945,100 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private boolean updateFieldView(int i) {
|
private boolean updateFieldView(int i) {
|
||||||
// looking at another field (not changed explicitly, maybe implicitly
|
// looking at another field (not changed explicitly, maybe implicitly
|
||||||
boolean valChanged = false;
|
boolean valChanged = false;
|
||||||
boolean doRepaint = false;
|
boolean doRepaint = false;
|
||||||
Object args[] = {};
|
Object args[] = {};
|
||||||
Method getter = propertyDescriptors[i].getReadMethod();
|
Method getter = propertyDescriptors[i].getReadMethod();
|
||||||
if (propertyDescriptors[i].isHidden() || propertyDescriptors[i].isExpert()) {
|
if (propertyDescriptors[i].isHidden() || propertyDescriptors[i].isExpert()) {
|
||||||
if ((propertyLabels[i] != null) && (propertyLabels[i].isVisible())) {
|
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);
|
viewWrappers[i].setVisible(false);
|
||||||
views[i].setVisible(false);
|
views[i].setVisible(false);
|
||||||
propertyLabels[i].setVisible(false);
|
propertyLabels[i].setVisible(false);
|
||||||
doRepaint = true;
|
doRepaint = true;
|
||||||
}
|
}
|
||||||
return doRepaint;
|
return doRepaint;
|
||||||
} else {
|
} else {
|
||||||
if ((propertyLabels[i] != null) && !(propertyLabels[i].isVisible())) {
|
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);
|
viewWrappers[i].setVisible(true);
|
||||||
views[i].setVisible(true);
|
views[i].setVisible(true);
|
||||||
propertyLabels[i].setVisible(true);
|
propertyLabels[i].setVisible(true);
|
||||||
doRepaint = true;
|
doRepaint = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try { // check if view i is up to date and in sync with the value of the getter
|
try { // check if view i is up to date and in sync with the value of the getter
|
||||||
if (views[i] != null) {
|
if (views[i] != null) {
|
||||||
Object val = getter.invoke(targetObject, args);
|
Object val = getter.invoke(targetObject, args);
|
||||||
if (views[i] instanceof PropertyBoolSelector) {
|
if (views[i] instanceof PropertyBoolSelector) {
|
||||||
valChanged = (((PropertyBoolSelector) views[i]).isSelected() != ((Boolean) val));
|
valChanged = (((PropertyBoolSelector) views[i]).isSelected() != ((Boolean) val));
|
||||||
if (valChanged) {
|
if (valChanged) {
|
||||||
((PropertyBoolSelector) views[i]).setSelected(((Boolean) val));
|
((PropertyBoolSelector) views[i]).setSelected(((Boolean) val));
|
||||||
}
|
}
|
||||||
} else if (views[i] instanceof PropertyText) {
|
} else if (views[i] instanceof PropertyText) {
|
||||||
valChanged = !(((PropertyText) views[i]).getText()).equals(val.toString());
|
valChanged = !(((PropertyText) views[i]).getText()).equals(val.toString());
|
||||||
if (valChanged) {
|
if (valChanged) {
|
||||||
((PropertyText) views[i]).setText(val.toString());
|
((PropertyText) views[i]).setText(val.toString());
|
||||||
}
|
}
|
||||||
} else if (views[i] instanceof PropertyPanel) {
|
} else if (views[i] instanceof PropertyPanel) {
|
||||||
valChanged = false;//!((PropertyPanel)m_Views[i]).equals(value);
|
valChanged = false;//!((PropertyPanel)m_Views[i]).equals(value);
|
||||||
// disregard whole panels and hope for the best
|
// disregard whole panels and hope for the best
|
||||||
} else if (views[i] instanceof PropertyValueSelector) {
|
} else if (views[i] instanceof PropertyValueSelector) {
|
||||||
//changed = !((SelectedTag)val).isSelectedString((String)((PropertyValueSelector)m_Views[i]).getSelectedItem());
|
//changed = !((SelectedTag)val).isSelectedString((String)((PropertyValueSelector)m_Views[i]).getSelectedItem());
|
||||||
// interestingly there seems to be an implicit update of the ValueSelector, possible changes
|
// 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
|
// are already applied, all we need to see it is a repaint
|
||||||
views[i].repaint();
|
views[i].repaint();
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Warning: Property \"" + i
|
System.out.println("Warning: Property \"" + i
|
||||||
+ "\" not recognized. Skipping.");
|
+ "\" not recognized. Skipping.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception exc) {
|
} catch (Exception exc) {
|
||||||
System.err.println("Exception in PropertySheetPanel");
|
System.err.println("Exception in PropertySheetPanel");
|
||||||
}
|
}
|
||||||
return doRepaint;
|
return doRepaint;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check the given link list and trigger updates of indicated properties.
|
* Check the given link list and trigger updates of indicated properties.
|
||||||
*
|
*
|
||||||
* @param propIndex
|
* @param propIndex
|
||||||
* @param links
|
* @param links
|
||||||
*/
|
*/
|
||||||
private void maybeTriggerUpdates(int propIndex, String[] links) {
|
private void maybeTriggerUpdates(int propIndex, String[] links) {
|
||||||
int max = links.length;
|
int max = links.length;
|
||||||
if (max % 2 == 1) {
|
if (max % 2 == 1) {
|
||||||
System.err.println("Error in PropertySheetPanel:maybeTriggerUpdates: odd number of strings provided!");
|
System.err.println("Error in PropertySheetPanel:maybeTriggerUpdates: odd number of strings provided!");
|
||||||
max -= 1;
|
max -= 1;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < max; i += 2) {
|
for (int i = 0; i < max; i += 2) {
|
||||||
if (links[i].equals(propertyDescriptors[propIndex].getName())) {
|
if (links[i].equals(propertyDescriptors[propIndex].getName())) {
|
||||||
updateLinkedProperty(links[i + 1]);
|
updateLinkedProperty(links[i + 1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateLinkedProperty(String propName) {
|
private void updateLinkedProperty(String propName) {
|
||||||
for (int i = 0; i < propertyDescriptors.length; i++) {
|
for (int i = 0; i < propertyDescriptors.length; i++) {
|
||||||
if (propertyDescriptors[i].getName().equals(propName)) {
|
if (propertyDescriptors[i].getName().equals(propName)) {
|
||||||
Method getter = propertyDescriptors[i].getReadMethod();
|
Method getter = propertyDescriptors[i].getReadMethod();
|
||||||
Object val = null;
|
Object val = null;
|
||||||
try {
|
try {
|
||||||
val = getter.invoke(targetObject, (Object[]) null);
|
val = getter.invoke(targetObject, (Object[]) null);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
val = null;
|
val = null;
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
if (val != null) {
|
if (val != null) {
|
||||||
propertyEditors[i].setValue(val);
|
propertyEditors[i].setValue(val);
|
||||||
} else {
|
} else {
|
||||||
System.err.println("Error in PropertySheetPanel:updateLinkedProperty");
|
System.err.println("Error in PropertySheetPanel:updateLinkedProperty");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class PropertyTableModel extends DefaultTableModel implements TableModel {
|
class PropertyTableModel extends DefaultTableModel implements TableModel {
|
||||||
@@ -1062,11 +1065,11 @@ class PropertyCellRenderer implements TableCellRenderer {
|
|||||||
} else if (value instanceof PropertyValueSelector) {
|
} else if (value instanceof PropertyValueSelector) {
|
||||||
return (PropertyValueSelector) value;
|
return (PropertyValueSelector) value;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
throw new UnsupportedOperationException("Not supported yet.");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class PropertyCellEditor extends AbstractCellEditor implements TableCellEditor {
|
class PropertyCellEditor extends AbstractCellEditor implements TableCellEditor {
|
||||||
@@ -1145,5 +1148,4 @@ class PropertyCellEditor extends AbstractCellEditor implements TableCellEditor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -12,6 +12,7 @@ package eva2.gui;
|
|||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
* IMPORTS
|
* IMPORTS
|
||||||
*==========================================================================*/
|
*==========================================================================*/
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.GridBagConstraints;
|
import java.awt.GridBagConstraints;
|
||||||
import java.awt.GridBagLayout;
|
import java.awt.GridBagLayout;
|
||||||
@@ -24,82 +25,84 @@ import javax.swing.JCheckBox;
|
|||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.SwingConstants;
|
import javax.swing.SwingConstants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class PropertySheetPanelStat extends JPanel implements Serializable {
|
public class PropertySheetPanelStat extends JPanel implements Serializable {
|
||||||
|
|
||||||
public final static boolean TRACE = false;
|
public final static boolean TRACE = false;
|
||||||
private Object[] m_Values;
|
private Object[] m_Values;
|
||||||
private JCheckBoxFlag[] m_Views;
|
private JCheckBoxFlag[] m_Views;
|
||||||
private JLabel[] m_Labels;
|
private JLabel[] m_Labels;
|
||||||
private boolean[] m_flag;
|
private boolean[] m_flag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the property sheet panel.
|
* Creates the property sheet panel.
|
||||||
*/
|
*/
|
||||||
public PropertySheetPanelStat() {
|
public PropertySheetPanelStat() {
|
||||||
// setBorder(BorderFactory.createLineBorder(Color.red));
|
// setBorder(BorderFactory.createLineBorder(Color.red));
|
||||||
setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
|
setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A support object for handling property change listeners
|
* A support object for handling property change listeners
|
||||||
*/
|
*/
|
||||||
private PropertyChangeSupport m_support = new PropertyChangeSupport(this);
|
private PropertyChangeSupport m_support = new PropertyChangeSupport(this);
|
||||||
|
|
||||||
public synchronized void setTarget(String[] names, boolean[] flag) {
|
public synchronized void setTarget(String[] names, boolean[] flag) {
|
||||||
int componentOffset = 0;
|
int componentOffset = 0;
|
||||||
// Close any child windows at this point
|
// Close any child windows at this point
|
||||||
removeAll();
|
removeAll();
|
||||||
GridBagLayout gbLayout = new GridBagLayout();
|
GridBagLayout gbLayout = new GridBagLayout();
|
||||||
setLayout(gbLayout);
|
setLayout(gbLayout);
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
|
|
||||||
int rowHeight = 12;
|
int rowHeight = 12;
|
||||||
|
|
||||||
m_Values = new Object[flag.length];
|
m_Values = new Object[flag.length];
|
||||||
m_Views = new JCheckBoxFlag[flag.length];
|
m_Views = new JCheckBoxFlag[flag.length];
|
||||||
m_Labels = new JLabel[names.length];
|
m_Labels = new JLabel[names.length];
|
||||||
|
|
||||||
for (int i = 0; i < names.length; i++) {
|
for (int i = 0; i < names.length; i++) {
|
||||||
m_Labels[i] = new JLabel(names[i], SwingConstants.RIGHT);
|
m_Labels[i] = new JLabel(names[i], SwingConstants.RIGHT);
|
||||||
m_Labels[i].setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 5));
|
m_Labels[i].setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 5));
|
||||||
m_Views[i] = new JCheckBoxFlag(flag[i]);
|
m_Views[i] = new JCheckBoxFlag(flag[i]);
|
||||||
GridBagConstraints gbConstraints = new GridBagConstraints();
|
GridBagConstraints gbConstraints = new GridBagConstraints();
|
||||||
gbConstraints.anchor = GridBagConstraints.EAST;
|
gbConstraints.anchor = GridBagConstraints.EAST;
|
||||||
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
|
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
|
||||||
gbConstraints.gridy = i + componentOffset;
|
gbConstraints.gridy = i + componentOffset;
|
||||||
gbConstraints.gridx = 0;
|
gbConstraints.gridx = 0;
|
||||||
gbLayout.setConstraints(m_Labels[i], gbConstraints);
|
gbLayout.setConstraints(m_Labels[i], gbConstraints);
|
||||||
add(m_Labels[i]);
|
add(m_Labels[i]);
|
||||||
JPanel newPanel = new JPanel();
|
JPanel newPanel = new JPanel();
|
||||||
newPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 10));
|
newPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 10));
|
||||||
|
|
||||||
newPanel.setLayout(new BorderLayout());
|
newPanel.setLayout(new BorderLayout());
|
||||||
newPanel.add(m_Views[i], BorderLayout.CENTER);
|
newPanel.add(m_Views[i], BorderLayout.CENTER);
|
||||||
gbConstraints = new GridBagConstraints();
|
gbConstraints = new GridBagConstraints();
|
||||||
gbConstraints.anchor = GridBagConstraints.WEST;
|
gbConstraints.anchor = GridBagConstraints.WEST;
|
||||||
gbConstraints.fill = GridBagConstraints.BOTH;
|
gbConstraints.fill = GridBagConstraints.BOTH;
|
||||||
gbConstraints.gridy = i + componentOffset;
|
gbConstraints.gridy = i + componentOffset;
|
||||||
gbConstraints.gridx = 1;
|
gbConstraints.gridx = 1;
|
||||||
gbConstraints.weightx = 100;
|
gbConstraints.weightx = 100;
|
||||||
gbLayout.setConstraints(newPanel, gbConstraints);
|
gbLayout.setConstraints(newPanel, gbConstraints);
|
||||||
add(newPanel);
|
add(newPanel);
|
||||||
|
}
|
||||||
|
validate();
|
||||||
|
setVisible(true);
|
||||||
}
|
}
|
||||||
validate();
|
|
||||||
setVisible(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public boolean[] getState() {
|
public boolean[] getState() {
|
||||||
boolean[] ret = new boolean[this.m_Views.length];
|
boolean[] ret = new boolean[this.m_Views.length];
|
||||||
for (int i = 0; i < ret.length; i++) {
|
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 {
|
class JCheckBoxFlag extends JCheckBox {
|
||||||
|
|
||||||
private boolean m_Flag = true;
|
private boolean m_Flag = true;
|
||||||
|
|
||||||
public JCheckBoxFlag(boolean flag) {
|
public JCheckBoxFlag(boolean flag) {
|
||||||
super();
|
super();
|
||||||
m_Flag = flag;
|
m_Flag = flag;
|
||||||
addItemListener(new ItemListener() {
|
addItemListener(new ItemListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void itemStateChanged(ItemEvent evt) {
|
public void itemStateChanged(ItemEvent evt) {
|
||||||
if (evt.getStateChange() == evt.SELECTED) {
|
if (evt.getStateChange() == evt.SELECTED) {
|
||||||
m_Flag = true;
|
m_Flag = true;
|
||||||
}
|
}
|
||||||
if (evt.getStateChange() == evt.DESELECTED) {
|
if (evt.getStateChange() == evt.DESELECTED) {
|
||||||
m_Flag = false;
|
m_Flag = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ package eva2.gui;
|
|||||||
* Architecture @author Holger Ulmer, Felix Streichert, Hannes Planatscher @version: $Revision: 10 $
|
* Architecture @author Holger Ulmer, Felix Streichert, Hannes Planatscher @version: $Revision: 10 $
|
||||||
* $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $ $Author: streiche $
|
* $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $ $Author: streiche $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.awt.event.FocusAdapter;
|
import java.awt.event.FocusAdapter;
|
||||||
import java.awt.event.FocusEvent;
|
import java.awt.event.FocusEvent;
|
||||||
import java.awt.event.KeyAdapter;
|
import java.awt.event.KeyAdapter;
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import javax.swing.JTextField;
|
|||||||
/**
|
/**
|
||||||
* A text property editor view. Updates the editor on key release and lost focus
|
* A text property editor view. Updates the editor on key release and lost focus
|
||||||
* events.
|
* events.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class PropertyText extends JTextField {
|
public class PropertyText extends JTextField {
|
||||||
|
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ package eva2.gui;
|
|||||||
*/
|
*/
|
||||||
public class PropertyWeightedLPTchebycheff implements java.io.Serializable {
|
public class PropertyWeightedLPTchebycheff implements java.io.Serializable {
|
||||||
|
|
||||||
public double[] m_IdealValue;
|
public double[] m_IdealValue;
|
||||||
public double[] m_Weights;
|
public double[] m_Weights;
|
||||||
public int m_P = 0;
|
public int m_P = 0;
|
||||||
|
|
||||||
public PropertyWeightedLPTchebycheff() {
|
public PropertyWeightedLPTchebycheff() {
|
||||||
}
|
}
|
||||||
@@ -25,7 +25,7 @@ public class PropertyWeightedLPTchebycheff implements java.io.Serializable {
|
|||||||
this.m_Weights = new double[e.m_Weights.length];
|
this.m_Weights = new double[e.m_Weights.length];
|
||||||
System.arraycopy(e.m_Weights, 0, this.m_Weights, 0, this.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
|
@Override
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ package eva2.gui;
|
|||||||
* @version: $Revision: 322 $ $Date: 2007-12-11 17:24:07 +0100 (Tue, 11 Dec 2007)$
|
* @version: $Revision: 322 $ $Date: 2007-12-11 17:24:07 +0100 (Tue, 11 Dec 2007)$
|
||||||
* $Author: mkron $
|
* $Author: mkron $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import eva2.tools.BasicResourceLoader;
|
import eva2.tools.BasicResourceLoader;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
@@ -28,7 +29,7 @@ class SplashScreen extends Frame {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the splash screen to the end user.
|
* Show the splash screen to the end user.
|
||||||
*
|
* <p/>
|
||||||
* <P>Once this method returns, the splash screen is realized, which means
|
* <P>Once this method returns, the splash screen is realized, which means
|
||||||
* that almost all work on the splash screen should proceed through the
|
* that almost all work on the splash screen should proceed through the
|
||||||
* event dispatch thread. In particular, any call to
|
* event dispatch thread. In particular, any call to
|
||||||
@@ -41,11 +42,11 @@ class SplashScreen extends Frame {
|
|||||||
byte[] bytes = loader.getBytesFromResourceLocation(imgLocation, true);
|
byte[] bytes = loader.getBytesFromResourceLocation(imgLocation, true);
|
||||||
ImageIcon ii = new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes));
|
ImageIcon ii = new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes));
|
||||||
JLabel splashLabel = new JLabel(ii);
|
JLabel splashLabel = new JLabel(ii);
|
||||||
|
|
||||||
splashWindow.add(splashLabel);
|
splashWindow.add(splashLabel);
|
||||||
splashWindow.pack();
|
splashWindow.pack();
|
||||||
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||||
splashWindow.setLocation(screenSize.width / 2 - splashWindow.getSize().width / 2, screenSize.height / 2 - splashWindow.getSize().height / 2);
|
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 {
|
public abstract class AbstractListSelectionEditor extends JPanel implements PropertyEditor, PropertyChangeListener {
|
||||||
|
|
||||||
/** Handles property change notification */
|
/**
|
||||||
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
* Handles property change notification
|
||||||
/** The label for when we can't edit that type */
|
*/
|
||||||
protected JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER);
|
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||||
|
/**
|
||||||
/** The graphics stuff */
|
* The label for when we can't edit that type
|
||||||
private JPanel m_CustomEditor, m_NodePanel;
|
*/
|
||||||
protected JCheckBox[] m_BlackCheck;
|
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() {
|
private void initCustomEditor() {
|
||||||
this.m_CustomEditor = new JPanel();
|
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 the number of elements in the list.
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected abstract int getElementCount();
|
protected abstract int getElementCount();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the display name of an element.
|
* Get the display name of an element.
|
||||||
*
|
*
|
||||||
* @param i
|
* @param i
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected abstract String getElementName(int i);
|
protected abstract String getElementName(int i);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the tool tip of an element or null if none is available.
|
* Get the tool tip of an element or null if none is available.
|
||||||
*
|
*
|
||||||
* @param i
|
* @param i
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected String getElementToolTip(int i) {
|
protected String getElementToolTip(int i) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the selection state of an element.
|
* Get the selection state of an element.
|
||||||
*
|
*
|
||||||
* @param i
|
* @param i
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected abstract boolean isElementSelected(int i);
|
protected abstract boolean isElementSelected(int i);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The object may have changed update the editor. This notifies change listeners automatically.
|
* The object may have changed update the editor. This notifies change listeners automatically.
|
||||||
*/
|
*/
|
||||||
private void updateEditor() {
|
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_NodePanel.setLayout(new GridLayout(getElementCount(), 1));
|
||||||
this.m_BlackCheck = new JCheckBox[getElementCount()];
|
this.m_BlackCheck = new JCheckBox[getElementCount()];
|
||||||
for (int i = 0; i < getElementCount(); i++) {
|
for (int i = 0; i < getElementCount(); i++) {
|
||||||
this.m_BlackCheck[i] = new JCheckBox(getElementName(i), isElementSelected(i));
|
this.m_BlackCheck[i] = new JCheckBox(getElementName(i), isElementSelected(i));
|
||||||
this.m_BlackCheck[i].setToolTipText(getElementToolTip(i));
|
this.m_BlackCheck[i].setToolTipText(getElementToolTip(i));
|
||||||
this.m_BlackCheck[i].addActionListener(new ActionListener() {
|
this.m_BlackCheck[i].addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent ev) {
|
public void actionPerformed(ActionEvent ev) {
|
||||||
if (actionOnSelect()) {
|
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.
|
* Perform actions when the selection state changes. Return true if there was an actual change.
|
||||||
*/
|
*/
|
||||||
protected abstract boolean actionOnSelect();
|
protected abstract boolean actionOnSelect();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the base object, return true on success. Make sure that the editor instance is
|
* Set the base object, return true on success. Make sure that the editor instance is
|
||||||
* added as a listener to the object (if supported).
|
* added as a listener to the object (if supported).
|
||||||
*
|
*
|
||||||
* @param o
|
* @param o
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected abstract boolean setObject(Object o);
|
protected abstract boolean setObject(Object o);
|
||||||
|
|
||||||
/** This method will set the value of object that is to be edited.
|
/**
|
||||||
|
* This method will set the value of object that is to be edited.
|
||||||
|
*
|
||||||
* @param o an object that must be an array.
|
* @param o an object that must be an array.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setValue(Object o) {
|
public void setValue(Object o) {
|
||||||
if (setObject(o)) {
|
if (setObject(o)) {
|
||||||
updateEditor();
|
updateEditor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current object.
|
* Returns the current object.
|
||||||
|
*
|
||||||
* @return the current object
|
* @return the current object
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -148,7 +159,7 @@ public abstract class AbstractListSelectionEditor extends JPanel implements Prop
|
|||||||
public String getAsText() {
|
public String getAsText() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAsText(String text) throws IllegalArgumentException {
|
public void setAsText(String text) throws IllegalArgumentException {
|
||||||
throw new IllegalArgumentException(text);
|
throw new IllegalArgumentException(text);
|
||||||
@@ -172,16 +183,19 @@ public abstract class AbstractListSelectionEditor extends JPanel implements Prop
|
|||||||
if (m_Support == null) {
|
if (m_Support == null) {
|
||||||
m_Support = new PropertyChangeSupport(this);
|
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
|
* @return true
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isPaintable() {
|
public boolean isPaintable() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Paints a representation of the current classifier.
|
* Paints a representation of the current classifier.
|
||||||
*
|
*
|
||||||
@@ -193,11 +207,12 @@ public abstract class AbstractListSelectionEditor extends JPanel implements Prop
|
|||||||
FontMetrics fm = gfx.getFontMetrics();
|
FontMetrics fm = gfx.getFontMetrics();
|
||||||
int vpad = (box.height - fm.getAscent()) / 2;
|
int vpad = (box.height - fm.getAscent()) / 2;
|
||||||
String rep = "Select from list";
|
String rep = "Select from list";
|
||||||
gfx.drawString(rep, 2, fm.getHeight() + vpad - 3 );
|
gfx.drawString(rep, 2, fm.getHeight() + vpad - 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true because we do support a custom editor.
|
* Returns true because we do support a custom editor.
|
||||||
|
*
|
||||||
* @return true
|
* @return true
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -205,9 +220,11 @@ public abstract class AbstractListSelectionEditor extends JPanel implements Prop
|
|||||||
return true;
|
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
|
@Override
|
||||||
public Component getCustomEditor() {
|
public Component getCustomEditor() {
|
||||||
if (this.m_CustomEditor == null) {
|
if (this.m_CustomEditor == null) {
|
||||||
@@ -215,9 +232,9 @@ public abstract class AbstractListSelectionEditor extends JPanel implements Prop
|
|||||||
}
|
}
|
||||||
return m_CustomEditor;
|
return m_CustomEditor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void propertyChange(PropertyChangeEvent evt) {
|
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
|
* IMPORTS
|
||||||
*==========================================================================*/
|
*==========================================================================*/
|
||||||
|
|
||||||
import eva2.gui.PropertyDialog;
|
import eva2.gui.PropertyDialog;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
import java.beans.*;
|
import java.beans.*;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
@@ -23,212 +24,219 @@ import javax.swing.*;
|
|||||||
* CLASS DECLARATION
|
* CLASS DECLARATION
|
||||||
*==========================================================================*/
|
*==========================================================================*/
|
||||||
public class BigStringEditor implements PropertyEditor {
|
public class BigStringEditor implements PropertyEditor {
|
||||||
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||||
private PropertyEditor m_ElementEditor;
|
private PropertyEditor m_ElementEditor;
|
||||||
private JTextArea m_TextArea;
|
private JTextArea m_TextArea;
|
||||||
private JScrollPane m_ScrollPane;
|
private JScrollPane m_ScrollPane;
|
||||||
private JPanel m_Panel;
|
private JPanel m_Panel;
|
||||||
// private Source m_Source;
|
// private Source m_Source;
|
||||||
private JButton m_SetButton;
|
private JButton m_SetButton;
|
||||||
static private boolean m_finished = false;
|
static private boolean m_finished = false;
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public static void editSource (String file) {
|
|
||||||
|
|
||||||
try {
|
/**
|
||||||
m_finished=false;
|
*
|
||||||
BigStringEditor editor = new BigStringEditor();
|
*/
|
||||||
|
public static void editSource(String file) {
|
||||||
|
|
||||||
PropertyDialog dialog = new PropertyDialog(editor,file, 50, 50);
|
try {
|
||||||
//frame.setSize(200, 200);
|
m_finished = false;
|
||||||
dialog.addWindowListener(new WindowListener() {
|
BigStringEditor editor = new BigStringEditor();
|
||||||
|
|
||||||
|
PropertyDialog dialog = new PropertyDialog(editor, file, 50, 50);
|
||||||
|
//frame.setSize(200, 200);
|
||||||
|
dialog.addWindowListener(new WindowListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void windowOpened(WindowEvent e) {
|
public void windowOpened(WindowEvent e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void windowClosing(WindowEvent e) {
|
public void windowClosing(WindowEvent e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void windowClosed(WindowEvent e) {
|
public void windowClosed(WindowEvent e) {
|
||||||
m_finished = true;
|
m_finished = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void windowIconified(WindowEvent e) {
|
public void windowIconified(WindowEvent e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void windowDeiconified(WindowEvent e) {
|
public void windowDeiconified(WindowEvent e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void windowActivated(WindowEvent e) {
|
public void windowActivated(WindowEvent e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void windowDeactivated(WindowEvent e) {
|
public void windowDeactivated(WindowEvent e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
while (m_finished==false) {
|
while (m_finished == false) {
|
||||||
try {Thread.sleep(1000);}
|
try {
|
||||||
catch (Exception e) {
|
Thread.sleep(1000);
|
||||||
System.out.println("e+"+e.getMessage());
|
} catch (Exception e) {
|
||||||
|
System.out.println("e+" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
System.out.println(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
System.out.println(e.getMessage());
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public BigStringEditor () {
|
public BigStringEditor() {
|
||||||
super();
|
super();
|
||||||
// m_TextArea = new JEditTextArea();
|
// m_TextArea = new JEditTextArea();
|
||||||
// m_TextArea.setTokenMarker(new JavaTokenMarker());
|
// m_TextArea.setTokenMarker(new JavaTokenMarker());
|
||||||
m_TextArea = new JTextArea(60,60);
|
m_TextArea = new JTextArea(60, 60);
|
||||||
m_TextArea.setEditable(true);
|
m_TextArea.setEditable(true);
|
||||||
m_TextArea.setBorder(BorderFactory.createEmptyBorder(4,4,4,4));
|
m_TextArea.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
|
||||||
m_ScrollPane = new JScrollPane(m_TextArea);
|
m_ScrollPane = new JScrollPane(m_TextArea);
|
||||||
m_Panel = new JPanel();
|
m_Panel = new JPanel();
|
||||||
m_Panel.setBorder(BorderFactory.createTitledBorder("Sourcecode"));
|
m_Panel.setBorder(BorderFactory.createTitledBorder("Sourcecode"));
|
||||||
m_Panel.setLayout(new BorderLayout());
|
m_Panel.setLayout(new BorderLayout());
|
||||||
m_SetButton = new JButton("SET");
|
m_SetButton = new JButton("SET");
|
||||||
m_SetButton.addActionListener(new ActionListener() {
|
m_SetButton.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
setValue(m_TextArea.getText());
|
setValue(m_TextArea.getText());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
m_Panel.add(m_ScrollPane, BorderLayout.CENTER);
|
m_Panel.add(m_ScrollPane, BorderLayout.CENTER);
|
||||||
m_Panel.add(m_SetButton, BorderLayout.SOUTH);
|
m_Panel.add(m_SetButton, BorderLayout.SOUTH);
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setValue (Object value) {
|
|
||||||
m_ElementEditor = null;
|
|
||||||
if (value instanceof String) {
|
|
||||||
// m_Source.setString((String)value);
|
|
||||||
m_TextArea.setText((String)value);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@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) {
|
/* if (value instanceof Source) {
|
||||||
// m_Source = (Source) value;
|
// m_Source = (Source) value;
|
||||||
m_TextArea.setText(((Source)value).getString());
|
m_TextArea.setText(((Source)value).getString());
|
||||||
}*/
|
}*/
|
||||||
m_Support.firePropertyChange("", null, null);
|
m_Support.firePropertyChange("", null, null);
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Object getValue () {
|
|
||||||
// m_Source.setString(m_TextArea.getText());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String getJavaInitializationString () {
|
|
||||||
return "null";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true to indicate that we can paint a representation of the
|
*
|
||||||
* string array
|
*/
|
||||||
*
|
|
||||||
* @return true
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPaintable () {
|
public Object getValue() {
|
||||||
return true;
|
// 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
|
@Override
|
||||||
public void paintValue (Graphics gfx, Rectangle box) {
|
public String getJavaInitializationString() {
|
||||||
FontMetrics fm = gfx.getFontMetrics();
|
return "null";
|
||||||
int vpad = (box.height - fm.getAscent())/2;
|
}
|
||||||
//String rep = EVAHELP.cutClassName(m_ElementClass.getName());
|
|
||||||
gfx.drawString("BigStringEditor", 2, fm.getHeight() + vpad - 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Returns true to indicate that we can paint a representation of the
|
||||||
*/
|
* string array
|
||||||
|
*
|
||||||
|
* @return true
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getAsText () {
|
public boolean isPaintable() {
|
||||||
return null;
|
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
|
@Override
|
||||||
public void setAsText (String text) throws IllegalArgumentException {
|
public void paintValue(Graphics gfx, Rectangle box) {
|
||||||
throw new IllegalArgumentException(text);
|
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
|
@Override
|
||||||
public String[] getTags () {
|
public String getAsText() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsCustomEditor () {
|
public void setAsText(String text) throws IllegalArgumentException {
|
||||||
return true;
|
throw new IllegalArgumentException(text);
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
*
|
/**
|
||||||
*/
|
*
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Component getCustomEditor () {
|
public String[] getTags() {
|
||||||
return m_Panel;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean supportsCustomEditor() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Component getCustomEditor() {
|
||||||
|
return m_Panel;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||||
if (m_Support == null) {
|
if (m_Support == null) {
|
||||||
m_Support = new PropertyChangeSupport(this);
|
m_Support = new PropertyChangeSupport(this);
|
||||||
}
|
}
|
||||||
m_Support.addPropertyChangeListener(l);
|
m_Support.addPropertyChangeListener(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||||
if (m_Support == null) {
|
if (m_Support == null) {
|
||||||
m_Support = new PropertyChangeSupport(this);
|
m_Support = new PropertyChangeSupport(this);
|
||||||
}
|
}
|
||||||
m_Support.removePropertyChangeListener(l);
|
m_Support.removePropertyChangeListener(l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
package eva2.gui.editor;
|
package eva2.gui.editor;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Title: EvA2
|
* Title: EvA2
|
||||||
* Description:
|
* Description:
|
||||||
@@ -10,5 +11,5 @@ package eva2.gui.editor;
|
|||||||
* $Author: streiche $
|
* $Author: streiche $
|
||||||
*/
|
*/
|
||||||
public interface ComponentFilter {
|
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.
|
* To change this template use Options | File Templates.
|
||||||
*/
|
*/
|
||||||
public class EnumEditor extends PropertyEditorSupport {
|
public class EnumEditor extends PropertyEditorSupport {
|
||||||
/** The Enum values that may be chosen */
|
/**
|
||||||
private Enum[] enumConstants;
|
* The Enum values that may be chosen
|
||||||
|
*/
|
||||||
|
private Enum[] enumConstants;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getAsText() {
|
public String getAsText() {
|
||||||
return getValue().toString();
|
return getValue().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setValue(Object value) {
|
public void setValue(Object value) {
|
||||||
if (value instanceof Enum) {
|
if (value instanceof Enum) {
|
||||||
enumConstants = ((Enum)value).getClass().getEnumConstants();
|
enumConstants = ((Enum) value).getClass().getEnumConstants();
|
||||||
// enumType = ((Enum)value);
|
// enumType = ((Enum)value);
|
||||||
super.setValue(value);
|
super.setValue(value);
|
||||||
} else if (value.getClass().isArray() && value.getClass().getComponentType().isEnum() ) {
|
} else if (value.getClass().isArray() && value.getClass().getComponentType().isEnum()) {
|
||||||
// values = value.getClass().getComponentType().getEnumConstants();
|
// values = value.getClass().getComponentType().getEnumConstants();
|
||||||
Enum<?>[] e = (Enum[])(value);
|
Enum<?>[] e = (Enum[]) (value);
|
||||||
enumConstants =(Enum[]) e.getClass().getComponentType().getEnumConstants();
|
enumConstants = (Enum[]) e.getClass().getComponentType().getEnumConstants();
|
||||||
super.setValue(value);
|
super.setValue(value);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
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;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Test the editor.
|
public void setAsText(String text) throws IllegalArgumentException {
|
||||||
*
|
for (int i = 0; i < enumConstants.length; i++) {
|
||||||
* @param args ignored
|
if (text.equals(enumConstants[i].toString())) {
|
||||||
*/
|
setValue((Enum) enumConstants[i]);
|
||||||
public static void main(String [] args) {
|
return;
|
||||||
try {
|
}
|
||||||
Enum<?> initial = TestEnum.asdf;
|
}
|
||||||
EnumEditor ed = new EnumEditor();
|
throw new IllegalArgumentException("Invalid text for enum");
|
||||||
ed.setValue(initial);
|
}
|
||||||
PropertyValueSelector ps = new PropertyValueSelector(ed);
|
|
||||||
JFrame f = new JFrame();
|
@Override
|
||||||
f.addWindowListener(new WindowAdapter() {
|
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
|
@Override
|
||||||
public void windowClosing(WindowEvent e) {
|
public void windowClosing(WindowEvent e) {
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
f.getContentPane().setLayout(new BorderLayout());
|
f.getContentPane().setLayout(new BorderLayout());
|
||||||
f.getContentPane().add(ps, BorderLayout.CENTER);
|
f.getContentPane().add(ps, BorderLayout.CENTER);
|
||||||
f.pack();
|
f.pack();
|
||||||
f.setVisible(true);
|
f.setVisible(true);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
System.err.println(ex.getMessage());
|
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.
|
* To change this template use Options | File Templates.
|
||||||
*/
|
*/
|
||||||
public class GenericAreaEditor extends AbstractListSelectionEditor {
|
public class GenericAreaEditor extends AbstractListSelectionEditor {
|
||||||
/** The GPArea that is to be edited*/
|
/**
|
||||||
private GPArea m_AreaObject;
|
* The GPArea that is to be edited
|
||||||
|
*/
|
||||||
|
private GPArea m_AreaObject;
|
||||||
|
|
||||||
public GenericAreaEditor() {
|
public GenericAreaEditor() {
|
||||||
// compiled code
|
// compiled code
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int getElementCount() {
|
|
||||||
return m_AreaObject.getCompleteList().size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getElementName(int i) {
|
protected int getElementCount() {
|
||||||
AbstractGPNode an = (AbstractGPNode)m_AreaObject.getCompleteList().get(i);
|
return m_AreaObject.getCompleteList().size();
|
||||||
return an.getName();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isElementSelected(int i) {
|
protected String getElementName(int i) {
|
||||||
return ((Boolean)m_AreaObject.getBlackList().get(i)).booleanValue();
|
AbstractGPNode an = (AbstractGPNode) m_AreaObject.getCompleteList().get(i);
|
||||||
}
|
return an.getName();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean actionOnSelect() {
|
protected boolean isElementSelected(int i) {
|
||||||
/** This method checks the current BlackList and compiles it
|
return ((Boolean) m_AreaObject.getBlackList().get(i)).booleanValue();
|
||||||
* 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
|
@Override
|
||||||
protected boolean setObject(Object o) {
|
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) {
|
if (o instanceof GPArea) {
|
||||||
this.m_AreaObject = (GPArea) o;
|
this.m_AreaObject = (GPArea) o;
|
||||||
m_AreaObject.addPropertyChangeListener(this);
|
m_AreaObject.addPropertyChangeListener(this);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getValue() {
|
public Object getValue() {
|
||||||
return this.m_AreaObject;
|
return this.m_AreaObject;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package eva2.gui.editor;
|
|||||||
import eva2.gui.*;
|
import eva2.gui.*;
|
||||||
import eva2.tools.EVAHELP;
|
import eva2.tools.EVAHELP;
|
||||||
import eva2.tools.SerializedObject;
|
import eva2.tools.SerializedObject;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
import java.beans.PropertyChangeEvent;
|
import java.beans.PropertyChangeEvent;
|
||||||
@@ -165,7 +166,7 @@ public class GenericArrayEditor extends JPanel implements PropertyEditor {
|
|||||||
}
|
}
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Listens to list items being selected and takes appropriate action
|
* Listens to list items being selected and takes appropriate action
|
||||||
*/
|
*/
|
||||||
@@ -173,7 +174,7 @@ public class GenericArrayEditor extends JPanel implements PropertyEditor {
|
|||||||
new ListSelectionListener() {
|
new ListSelectionListener() {
|
||||||
//
|
//
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void valueChanged(ListSelectionEvent e) {
|
public void valueChanged(ListSelectionEvent e) {
|
||||||
|
|
||||||
if (e.getSource() == elementList) {
|
if (e.getSource() == elementList) {
|
||||||
@@ -261,7 +262,7 @@ public class GenericArrayEditor extends JPanel implements PropertyEditor {
|
|||||||
* Creates the list cell renderer.
|
* Creates the list cell renderer.
|
||||||
*
|
*
|
||||||
* @param editorClass The class of the property editor for array objects
|
* @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) {
|
public EditorListCellRenderer(Class editorClass, Class valueClass) {
|
||||||
this.editorClass = editorClass;
|
this.editorClass = editorClass;
|
||||||
@@ -271,24 +272,24 @@ public class GenericArrayEditor extends JPanel implements PropertyEditor {
|
|||||||
/**
|
/**
|
||||||
* Creates a cell rendering component.
|
* Creates a cell rendering component.
|
||||||
*
|
*
|
||||||
* @param JList the list that will be rendered in
|
* @param JList the list that will be rendered in
|
||||||
* @param Object the cell value
|
* @param Object the cell value
|
||||||
* @param int which element of the list to render
|
* @param int which element of the list to render
|
||||||
* @param boolean true if the cell is selected
|
* @param boolean true if the cell is selected
|
||||||
* @param boolean true if the cell has the focus
|
* @param boolean true if the cell has the focus
|
||||||
* @return the rendering component
|
* @return the rendering component
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Component getListCellRendererComponent(final JList list,
|
public Component getListCellRendererComponent(final JList list,
|
||||||
final Object value,
|
final Object value,
|
||||||
final int index,
|
final int index,
|
||||||
final boolean isSelected,
|
final boolean isSelected,
|
||||||
final boolean cellHasFocus) {
|
final boolean cellHasFocus) {
|
||||||
try {
|
try {
|
||||||
final PropertyEditor e = (PropertyEditor) editorClass.newInstance();
|
final PropertyEditor e = (PropertyEditor) editorClass.newInstance();
|
||||||
if (e instanceof GenericObjectEditor) {
|
if (e instanceof GenericObjectEditor) {
|
||||||
((GenericObjectEditor) e).setClassType(valueClass);
|
((GenericObjectEditor) e).setClassType(valueClass);
|
||||||
}
|
}
|
||||||
e.setValue(value);
|
e.setValue(value);
|
||||||
JPanel cellPanel = new JPanel() {
|
JPanel cellPanel = new JPanel() {
|
||||||
|
|
||||||
@@ -644,7 +645,7 @@ public class GenericArrayEditor extends JPanel implements PropertyEditor {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private JMenuItem createMenuItem(String title, boolean enabled,
|
private JMenuItem createMenuItem(String title, boolean enabled,
|
||||||
ActionListener aListener) {
|
ActionListener aListener) {
|
||||||
JMenuItem item = new JMenuItem(title);
|
JMenuItem item = new JMenuItem(title);
|
||||||
// if (bgColor!=null) item.setForeground(bgColor);
|
// if (bgColor!=null) item.setForeground(bgColor);
|
||||||
item.addActionListener(aListener);
|
item.addActionListener(aListener);
|
||||||
|
|||||||
@@ -26,32 +26,36 @@ import javax.swing.SwingConstants;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple focus listener with an object ID and callback.
|
* A simple focus listener with an object ID and callback.
|
||||||
*
|
|
||||||
* @author mkron
|
|
||||||
*
|
*
|
||||||
|
* @author mkron
|
||||||
*/
|
*/
|
||||||
class MyFocusListener implements FocusListener {
|
class MyFocusListener implements FocusListener {
|
||||||
private int myID = -1;
|
private int myID = -1;
|
||||||
private GenericDoubleArrayEditor arrEditor = null;
|
private GenericDoubleArrayEditor arrEditor = null;
|
||||||
|
|
||||||
public MyFocusListener(int id, GenericDoubleArrayEditor gdae) {
|
public MyFocusListener(int id, GenericDoubleArrayEditor gdae) {
|
||||||
myID = id;
|
myID = id;
|
||||||
this.arrEditor = gdae;
|
this.arrEditor = gdae;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see java.awt.event.FocusListener#focusLost(java.awt.event.FocusEvent)
|
* @see java.awt.event.FocusListener#focusLost(java.awt.event.FocusEvent)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void focusLost(FocusEvent e) { }
|
public void focusLost(FocusEvent e) {
|
||||||
|
}
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
/*
|
||||||
* @see java.awt.event.FocusListener#focusGained(java.awt.event.FocusEvent)
|
* (non-Javadoc)
|
||||||
*/
|
* @see java.awt.event.FocusListener#focusGained(java.awt.event.FocusEvent)
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void focusGained(FocusEvent e) { arrEditor.notifyFocusID(myID);};
|
public void focusGained(FocusEvent e) {
|
||||||
|
arrEditor.notifyFocusID(myID);
|
||||||
|
}
|
||||||
|
|
||||||
|
;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -60,29 +64,41 @@ class MyFocusListener implements FocusListener {
|
|||||||
*/
|
*/
|
||||||
public class GenericDoubleArrayEditor extends JPanel implements PropertyEditor {
|
public class GenericDoubleArrayEditor extends JPanel implements PropertyEditor {
|
||||||
|
|
||||||
private static final long serialVersionUID = 7749892624600018812L;
|
private static final long serialVersionUID = 7749892624600018812L;
|
||||||
/** Handles property change notification */
|
/**
|
||||||
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
* Handles property change notification
|
||||||
/** The label for when we can't edit that type */
|
*/
|
||||||
private JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER);
|
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||||
/** The FilePath that is to be edited*/
|
/**
|
||||||
|
* 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;
|
private PropertyDoubleArray m_DoubleArray;
|
||||||
|
|
||||||
/** The gaphix stuff */
|
/**
|
||||||
private JPanel m_CustomEditor, m_DataPanel, m_ButtonPanel;
|
* The gaphix stuff
|
||||||
private JTextField[][] m_InputTextFields;
|
*/
|
||||||
private JButton m_OKButton, m_AddButton, m_DeleteButton, m_NormalizeButton;
|
private JPanel m_CustomEditor, m_DataPanel, m_ButtonPanel;
|
||||||
|
private JTextField[][] m_InputTextFields;
|
||||||
/** Which columns has the focus? **/
|
private JButton m_OKButton, m_AddButton, m_DeleteButton, m_NormalizeButton;
|
||||||
private int lastFocussedRow = -1;
|
|
||||||
|
/**
|
||||||
|
* Which columns has the focus? *
|
||||||
|
*/
|
||||||
|
private int lastFocussedRow = -1;
|
||||||
|
|
||||||
public GenericDoubleArrayEditor() {
|
public GenericDoubleArrayEditor() {
|
||||||
// compiled code
|
// compiled code
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method will init the CustomEditor Panel
|
/**
|
||||||
|
* This method will init the CustomEditor Panel
|
||||||
*/
|
*/
|
||||||
private void initCustomEditor() {
|
private void initCustomEditor() {
|
||||||
this.m_CustomEditor = new JPanel();
|
this.m_CustomEditor = new JPanel();
|
||||||
this.m_CustomEditor.setLayout(new BorderLayout());
|
this.m_CustomEditor.setLayout(new BorderLayout());
|
||||||
|
|
||||||
this.m_CustomEditor.add(new JLabel("Current Double Array:"), BorderLayout.NORTH);
|
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_DeleteButton.addActionListener(this.deleteAction);
|
||||||
this.m_NormalizeButton = new JButton("Normalize");
|
this.m_NormalizeButton = new JButton("Normalize");
|
||||||
this.m_NormalizeButton.addActionListener(this.normalizeAction);
|
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.setEnabled(true);
|
||||||
this.m_OKButton.addActionListener(new ActionListener() {
|
this.m_OKButton.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
//m_Backup = copyObject(m_Object);
|
//m_Backup = copyObject(m_Object);
|
||||||
if ((m_CustomEditor.getTopLevelAncestor() != null) && (m_CustomEditor.getTopLevelAncestor() instanceof Window)) {
|
if ((m_CustomEditor.getTopLevelAncestor() != null) && (m_CustomEditor.getTopLevelAncestor() instanceof Window)) {
|
||||||
Window w = (Window) m_CustomEditor.getTopLevelAncestor();
|
Window w = (Window) m_CustomEditor.getTopLevelAncestor();
|
||||||
w.dispose();
|
w.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.m_ButtonPanel.add(this.m_AddButton);
|
this.m_ButtonPanel.add(this.m_AddButton);
|
||||||
this.m_ButtonPanel.add(this.m_DeleteButton);
|
this.m_ButtonPanel.add(this.m_DeleteButton);
|
||||||
@@ -120,74 +136,79 @@ public class GenericDoubleArrayEditor extends JPanel implements PropertyEditor {
|
|||||||
this.updateEditor();
|
this.updateEditor();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This action listener adds an element to DoubleArray
|
/**
|
||||||
|
* This action listener adds an element to DoubleArray
|
||||||
*/
|
*/
|
||||||
ActionListener addAction = new ActionListener() {
|
ActionListener addAction = new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent event) {
|
public void actionPerformed(ActionEvent event) {
|
||||||
m_DoubleArray.addRowCopy(lastFocussedRow); // copy the last focussed row
|
m_DoubleArray.addRowCopy(lastFocussedRow); // copy the last focussed row
|
||||||
updateEditor();
|
updateEditor();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** This action listener removes an element from the DoubleArray.
|
/**
|
||||||
|
* This action listener removes an element from the DoubleArray.
|
||||||
*/
|
*/
|
||||||
ActionListener deleteAction = new ActionListener() {
|
ActionListener deleteAction = new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent event) {
|
public void actionPerformed(ActionEvent event) {
|
||||||
if (!m_DoubleArray.isValidRow(lastFocussedRow)) {
|
if (!m_DoubleArray.isValidRow(lastFocussedRow)) {
|
||||||
m_DoubleArray.deleteRow(m_DoubleArray.getNumRows()-1);
|
m_DoubleArray.deleteRow(m_DoubleArray.getNumRows() - 1);
|
||||||
} else {
|
} else {
|
||||||
m_DoubleArray.deleteRow(lastFocussedRow);
|
m_DoubleArray.deleteRow(lastFocussedRow);
|
||||||
}
|
}
|
||||||
updateEditor();
|
updateEditor();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This action listener nomalizes each columng of the values of the DoubleArray.
|
* This action listener nomalizes each columng of the values of the DoubleArray.
|
||||||
*/
|
*/
|
||||||
ActionListener normalizeAction = new ActionListener() {
|
ActionListener normalizeAction = new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent event) {
|
public void actionPerformed(ActionEvent event) {
|
||||||
m_DoubleArray.normalizeColumns();
|
m_DoubleArray.normalizeColumns();
|
||||||
updateEditor();
|
updateEditor();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** This action listener reads all values
|
/**
|
||||||
|
* This action listener reads all values
|
||||||
*/
|
*/
|
||||||
KeyListener readDoubleArrayAction = new KeyListener() {
|
KeyListener readDoubleArrayAction = new KeyListener() {
|
||||||
@Override
|
@Override
|
||||||
public void keyPressed(KeyEvent event) {
|
public void keyPressed(KeyEvent event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void keyTyped(KeyEvent event) {
|
public void keyTyped(KeyEvent event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void keyReleased(KeyEvent event) {
|
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 i = 0; i < tmpDD.length; i++) {
|
||||||
for (int j=0; j< tmpDD[0].length; j++) {
|
for (int j = 0; j < tmpDD[0].length; j++) {
|
||||||
try {
|
try {
|
||||||
double d = 0;
|
double d = 0;
|
||||||
d = new Double(m_InputTextFields[i][j].getText()).doubleValue();
|
d = new Double(m_InputTextFields[i][j].getText()).doubleValue();
|
||||||
tmpDD[i][j] = d;
|
tmpDD[i][j] = d;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//tmpD[i] = new Double(m_InputTextField[i].getText()).doubleValue();
|
//tmpD[i] = new Double(m_InputTextField[i].getText()).doubleValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_DoubleArray.setDoubleArray(tmpDD);
|
m_DoubleArray.setDoubleArray(tmpDD);
|
||||||
//updateEditor();
|
//updateEditor();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/** The object may have changed update the editor.
|
/**
|
||||||
|
* The object may have changed update the editor.
|
||||||
*/
|
*/
|
||||||
private void updateEditor() {
|
private void updateEditor() {
|
||||||
if (this.m_CustomEditor != null) {
|
if (this.m_CustomEditor != null) {
|
||||||
@@ -215,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() {
|
private void updateDataPanel() {
|
||||||
int numRows = m_DoubleArray.getNumRows();
|
int numRows = m_DoubleArray.getNumRows();
|
||||||
int numCols = m_DoubleArray.getNumCols();
|
int numCols = m_DoubleArray.getNumCols();
|
||||||
this.m_DataPanel.removeAll();
|
this.m_DataPanel.removeAll();
|
||||||
this.m_DataPanel.setLayout(new GridLayout(numRows, numCols+1));
|
this.m_DataPanel.setLayout(new GridLayout(numRows, numCols + 1));
|
||||||
this.m_InputTextFields = new JTextField[numRows][numCols];
|
this.m_InputTextFields = new JTextField[numRows][numCols];
|
||||||
for (int i = 0; i < numRows; i++) {
|
for (int i = 0; i < numRows; i++) {
|
||||||
JLabel label = new JLabel("Value X"+i+": ");
|
JLabel label = new JLabel("Value X" + i + ": ");
|
||||||
this.m_DataPanel.add(label);
|
this.m_DataPanel.add(label);
|
||||||
for (int j=0; j<numCols; j++) {
|
for (int j = 0; j < numCols; j++) {
|
||||||
this.m_InputTextFields[i][j] = new JTextField();
|
this.m_InputTextFields[i][j] = new JTextField();
|
||||||
this.m_InputTextFields[i][j].setText(""+m_DoubleArray.getValue(i,j));
|
this.m_InputTextFields[i][j].setText("" + m_DoubleArray.getValue(i, j));
|
||||||
this.m_InputTextFields[i][j].addKeyListener(this.readDoubleArrayAction);
|
this.m_InputTextFields[i][j].addKeyListener(this.readDoubleArrayAction);
|
||||||
this.m_InputTextFields[i][j].addFocusListener(new MyFocusListener(i, this));
|
this.m_InputTextFields[i][j].addFocusListener(new MyFocusListener(i, this));
|
||||||
this.m_DataPanel.add(this.m_InputTextFields[i][j]);
|
this.m_DataPanel.add(this.m_InputTextFields[i][j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void notifyFocusID(int id) {
|
public void notifyFocusID(int id) {
|
||||||
// notification of which column has the focus
|
// notification of which column has the focus
|
||||||
lastFocussedRow =id;
|
lastFocussedRow = id;
|
||||||
// System.out.println("Focus now on " + id);
|
// System.out.println("Focus now on " + id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method will set the value of object that is to be edited.
|
/**
|
||||||
|
* This method will set the value of object that is to be edited.
|
||||||
|
*
|
||||||
* @param o an object that must be an array.
|
* @param o an object that must be an array.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -253,7 +277,9 @@ public class GenericDoubleArrayEditor extends JPanel implements PropertyEditor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the current object.
|
/**
|
||||||
|
* Returns the current object.
|
||||||
|
*
|
||||||
* @return the current object
|
* @return the current object
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -292,35 +318,41 @@ public class GenericDoubleArrayEditor extends JPanel implements PropertyEditor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||||
if (m_Support == null) {
|
if (m_Support == null) {
|
||||||
m_Support = new PropertyChangeSupport(this);
|
m_Support = new PropertyChangeSupport(this);
|
||||||
}
|
}
|
||||||
m_Support.addPropertyChangeListener(l);
|
m_Support.addPropertyChangeListener(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||||
if (m_Support == null) {
|
if (m_Support == null) {
|
||||||
m_Support = new PropertyChangeSupport(this);
|
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.
|
* @param a The action listener.
|
||||||
*/
|
*/
|
||||||
public void addOkListener(ActionListener a) {
|
public void addOkListener(ActionListener a) {
|
||||||
m_OKButton.addActionListener(a);
|
m_OKButton.addActionListener(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This is used to remove an action listener from the ok button
|
/**
|
||||||
|
* This is used to remove an action listener from the ok button
|
||||||
|
*
|
||||||
* @param a The action listener
|
* @param a The action listener
|
||||||
*/
|
*/
|
||||||
public void removeOkListener(ActionListener a) {
|
public void removeOkListener(ActionListener a) {
|
||||||
m_OKButton.removeActionListener(a);
|
m_OKButton.removeActionListener(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true since the Object can be shown
|
/**
|
||||||
|
* Returns true since the Object can be shown
|
||||||
|
*
|
||||||
* @return true
|
* @return true
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -328,7 +360,8 @@ public class GenericDoubleArrayEditor extends JPanel implements PropertyEditor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Paints a representation of the current classifier.
|
/**
|
||||||
|
* Paints a representation of the current classifier.
|
||||||
*
|
*
|
||||||
* @param gfx the graphics context to use
|
* @param gfx the graphics context to use
|
||||||
* @param box the area we are allowed to paint into
|
* @param box the area we are allowed to paint into
|
||||||
@@ -338,20 +371,24 @@ public class GenericDoubleArrayEditor extends JPanel implements PropertyEditor {
|
|||||||
FontMetrics fm = gfx.getFontMetrics();
|
FontMetrics fm = gfx.getFontMetrics();
|
||||||
int vpad = (box.height - fm.getAscent()) / 2;
|
int vpad = (box.height - fm.getAscent()) / 2;
|
||||||
String rep = "Edit double array...";
|
String rep = "Edit double array...";
|
||||||
gfx.drawString(rep, 2, fm.getHeight() + vpad - 3 );
|
gfx.drawString(rep, 2, fm.getHeight() + vpad - 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true because we do support a custom editor.
|
/**
|
||||||
* @return true
|
* Returns true because we do support a custom editor.
|
||||||
*/
|
*
|
||||||
|
* @return true
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsCustomEditor() {
|
public boolean supportsCustomEditor() {
|
||||||
return true;
|
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
|
@Override
|
||||||
public Component getCustomEditor() {
|
public Component getCustomEditor() {
|
||||||
if (this.m_CustomEditor == null) {
|
if (this.m_CustomEditor == null) {
|
||||||
|
|||||||
@@ -18,27 +18,36 @@ import javax.swing.*;
|
|||||||
*/
|
*/
|
||||||
public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEditor {
|
public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEditor {
|
||||||
|
|
||||||
/** Handles property change notification */
|
/**
|
||||||
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
* Handles property change notification
|
||||||
/** The label for when we can't edit that type */
|
*/
|
||||||
private JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER);
|
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||||
/** The FilePath that is to be edited*/
|
/**
|
||||||
|
* 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;
|
private PropertyEpsilonConstraint m_EpsilonConstraint;
|
||||||
|
|
||||||
/** The gaphix stuff */
|
/**
|
||||||
private JPanel m_CustomEditor, m_DataPanel, m_ButtonPanel, m_TargetPanel;
|
* The gaphix stuff
|
||||||
private JTextField[] m_TargetTextField;
|
*/
|
||||||
private JComboBox m_Objective;
|
private JPanel m_CustomEditor, m_DataPanel, m_ButtonPanel, m_TargetPanel;
|
||||||
private JButton m_OKButton;
|
private JTextField[] m_TargetTextField;
|
||||||
|
private JComboBox m_Objective;
|
||||||
|
private JButton m_OKButton;
|
||||||
|
|
||||||
public GenericEpsilonConstraintEditor() {
|
public GenericEpsilonConstraintEditor() {
|
||||||
// compiled code
|
// compiled code
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method will init the CustomEditor Panel
|
/**
|
||||||
|
* This method will init the CustomEditor Panel
|
||||||
*/
|
*/
|
||||||
private void initCustomEditor() {
|
private void initCustomEditor() {
|
||||||
this.m_CustomEditor = new JPanel();
|
this.m_CustomEditor = new JPanel();
|
||||||
this.m_CustomEditor.setLayout(new BorderLayout());
|
this.m_CustomEditor.setLayout(new BorderLayout());
|
||||||
|
|
||||||
// target panel
|
// target panel
|
||||||
@@ -47,7 +56,7 @@ public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEd
|
|||||||
this.m_TargetPanel.add(new JLabel("Optimize:"));
|
this.m_TargetPanel.add(new JLabel("Optimize:"));
|
||||||
this.m_Objective = new JComboBox();
|
this.m_Objective = new JComboBox();
|
||||||
for (int i = 0; i < this.m_EpsilonConstraint.m_TargetValue.length; i++) {
|
for (int i = 0; i < this.m_EpsilonConstraint.m_TargetValue.length; i++) {
|
||||||
this.m_Objective.addItem("Objective "+i);
|
this.m_Objective.addItem("Objective " + i);
|
||||||
}
|
}
|
||||||
this.m_TargetPanel.add(this.m_Objective);
|
this.m_TargetPanel.add(this.m_Objective);
|
||||||
this.m_Objective.addItemListener(this.objectiveAction);
|
this.m_Objective.addItemListener(this.objectiveAction);
|
||||||
@@ -60,46 +69,49 @@ public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEd
|
|||||||
|
|
||||||
// init button panel
|
// init button panel
|
||||||
this.m_ButtonPanel = new JPanel();
|
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.setEnabled(true);
|
||||||
this.m_OKButton.addActionListener(new ActionListener() {
|
this.m_OKButton.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
//m_Backup = copyObject(m_Object);
|
//m_Backup = copyObject(m_Object);
|
||||||
if ((m_CustomEditor.getTopLevelAncestor() != null) && (m_CustomEditor.getTopLevelAncestor() instanceof Window)) {
|
if ((m_CustomEditor.getTopLevelAncestor() != null) && (m_CustomEditor.getTopLevelAncestor() instanceof Window)) {
|
||||||
Window w = (Window) m_CustomEditor.getTopLevelAncestor();
|
Window w = (Window) m_CustomEditor.getTopLevelAncestor();
|
||||||
w.dispose();
|
w.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.m_ButtonPanel.add(this.m_OKButton);
|
this.m_ButtonPanel.add(this.m_OKButton);
|
||||||
this.m_CustomEditor.add(this.m_ButtonPanel, BorderLayout.SOUTH);
|
this.m_CustomEditor.add(this.m_ButtonPanel, BorderLayout.SOUTH);
|
||||||
this.updateEditor();
|
this.updateEditor();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This action listener adds an element to DoubleArray
|
/**
|
||||||
|
* This action listener adds an element to DoubleArray
|
||||||
*/
|
*/
|
||||||
ItemListener objectiveAction = new ItemListener() {
|
ItemListener objectiveAction = new ItemListener() {
|
||||||
@Override
|
@Override
|
||||||
public void itemStateChanged(ItemEvent event) {
|
public void itemStateChanged(ItemEvent event) {
|
||||||
m_EpsilonConstraint.m_OptimizeObjective = m_Objective.getSelectedIndex();
|
m_EpsilonConstraint.m_OptimizeObjective = m_Objective.getSelectedIndex();
|
||||||
updateEditor();
|
updateEditor();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** This action listener reads all values
|
/**
|
||||||
|
* This action listener reads all values
|
||||||
*/
|
*/
|
||||||
KeyListener readDoubleArrayAction = new KeyListener() {
|
KeyListener readDoubleArrayAction = new KeyListener() {
|
||||||
@Override
|
@Override
|
||||||
public void keyPressed(KeyEvent event) {
|
public void keyPressed(KeyEvent event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void keyTyped(KeyEvent event) {
|
public void keyTyped(KeyEvent event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void keyReleased(KeyEvent event) {
|
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++) {
|
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() {
|
private void updateEditor() {
|
||||||
if (this.m_CustomEditor != null) {
|
if (this.m_CustomEditor != null) {
|
||||||
@@ -126,22 +139,23 @@ public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEd
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method updates the data panel
|
/**
|
||||||
|
* This method updates the data panel
|
||||||
*/
|
*/
|
||||||
private void updateDataPanel() {
|
private void updateDataPanel() {
|
||||||
double[] tmpT = this.m_EpsilonConstraint.m_TargetValue;
|
double[] tmpT = this.m_EpsilonConstraint.m_TargetValue;
|
||||||
int obj = this.m_EpsilonConstraint.m_OptimizeObjective;
|
int obj = this.m_EpsilonConstraint.m_OptimizeObjective;
|
||||||
|
|
||||||
this.m_DataPanel.removeAll();
|
this.m_DataPanel.removeAll();
|
||||||
this.m_DataPanel.setLayout(new GridLayout(tmpT.length+1, 2));
|
this.m_DataPanel.setLayout(new GridLayout(tmpT.length + 1, 2));
|
||||||
this.m_DataPanel.add(new JLabel());
|
this.m_DataPanel.add(new JLabel());
|
||||||
this.m_DataPanel.add(new JLabel("Target Value"));
|
this.m_DataPanel.add(new JLabel("Target Value"));
|
||||||
this.m_TargetTextField = new JTextField[tmpT.length];
|
this.m_TargetTextField = new JTextField[tmpT.length];
|
||||||
for (int i = 0; i < tmpT.length; i++) {
|
for (int i = 0; i < tmpT.length; i++) {
|
||||||
JLabel label = new JLabel("Objective "+i+": ");
|
JLabel label = new JLabel("Objective " + i + ": ");
|
||||||
this.m_DataPanel.add(label);
|
this.m_DataPanel.add(label);
|
||||||
this.m_TargetTextField[i] = new JTextField();
|
this.m_TargetTextField[i] = new JTextField();
|
||||||
this.m_TargetTextField[i].setText(""+tmpT[i]);
|
this.m_TargetTextField[i].setText("" + tmpT[i]);
|
||||||
this.m_TargetTextField[i].addKeyListener(this.readDoubleArrayAction);
|
this.m_TargetTextField[i].addKeyListener(this.readDoubleArrayAction);
|
||||||
this.m_DataPanel.add(this.m_TargetTextField[i]);
|
this.m_DataPanel.add(this.m_TargetTextField[i]);
|
||||||
}
|
}
|
||||||
@@ -149,7 +163,9 @@ public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEd
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** This method will set the value of object that is to be edited.
|
/**
|
||||||
|
* This method will set the value of object that is to be edited.
|
||||||
|
*
|
||||||
* @param o an object that must be an array.
|
* @param o an object that must be an array.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -160,7 +176,9 @@ public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEd
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the current object.
|
/**
|
||||||
|
* Returns the current object.
|
||||||
|
*
|
||||||
* @return the current object
|
* @return the current object
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -199,35 +217,41 @@ public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEd
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||||
if (m_Support == null) {
|
if (m_Support == null) {
|
||||||
m_Support = new PropertyChangeSupport(this);
|
m_Support = new PropertyChangeSupport(this);
|
||||||
}
|
}
|
||||||
m_Support.addPropertyChangeListener(l);
|
m_Support.addPropertyChangeListener(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||||
if (m_Support == null) {
|
if (m_Support == null) {
|
||||||
m_Support = new PropertyChangeSupport(this);
|
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.
|
* @param a The action listener.
|
||||||
*/
|
*/
|
||||||
public void addOkListener(ActionListener a) {
|
public void addOkListener(ActionListener a) {
|
||||||
m_OKButton.addActionListener(a);
|
m_OKButton.addActionListener(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This is used to remove an action listener from the ok button
|
/**
|
||||||
|
* This is used to remove an action listener from the ok button
|
||||||
|
*
|
||||||
* @param a The action listener
|
* @param a The action listener
|
||||||
*/
|
*/
|
||||||
public void removeOkListener(ActionListener a) {
|
public void removeOkListener(ActionListener a) {
|
||||||
m_OKButton.removeActionListener(a);
|
m_OKButton.removeActionListener(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true since the Object can be shown
|
/**
|
||||||
|
* Returns true since the Object can be shown
|
||||||
|
*
|
||||||
* @return true
|
* @return true
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -235,7 +259,8 @@ public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEd
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Paints a representation of the current classifier.
|
/**
|
||||||
|
* Paints a representation of the current classifier.
|
||||||
*
|
*
|
||||||
* @param gfx the graphics context to use
|
* @param gfx the graphics context to use
|
||||||
* @param box the area we are allowed to paint into
|
* @param box the area we are allowed to paint into
|
||||||
@@ -245,20 +270,24 @@ public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEd
|
|||||||
FontMetrics fm = gfx.getFontMetrics();
|
FontMetrics fm = gfx.getFontMetrics();
|
||||||
int vpad = (box.height - fm.getAscent()) / 2;
|
int vpad = (box.height - fm.getAscent()) / 2;
|
||||||
String rep = "Edit Epsilon Constraint";
|
String rep = "Edit Epsilon Constraint";
|
||||||
gfx.drawString(rep, 2, fm.getHeight() + vpad - 3 );
|
gfx.drawString(rep, 2, fm.getHeight() + vpad - 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true because we do support a custom editor.
|
/**
|
||||||
* @return true
|
* Returns true because we do support a custom editor.
|
||||||
*/
|
*
|
||||||
|
* @return true
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsCustomEditor() {
|
public boolean supportsCustomEditor() {
|
||||||
return true;
|
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
|
@Override
|
||||||
public Component getCustomEditor() {
|
public Component getCustomEditor() {
|
||||||
if (this.m_CustomEditor == null) {
|
if (this.m_CustomEditor == null) {
|
||||||
|
|||||||
@@ -18,27 +18,36 @@ import javax.swing.*;
|
|||||||
*/
|
*/
|
||||||
public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEditor {
|
public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEditor {
|
||||||
|
|
||||||
/** Handles property change notification */
|
/**
|
||||||
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
* Handles property change notification
|
||||||
/** The label for when we can't edit that type */
|
*/
|
||||||
private JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER);
|
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||||
/** The FilePath that is to be edited*/
|
/**
|
||||||
|
* 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;
|
private PropertyEpsilonThreshold m_EpsilonThreshhold;
|
||||||
|
|
||||||
/** The gaphix stuff */
|
/**
|
||||||
private JPanel m_CustomEditor, m_DataPanel, m_ButtonPanel, m_TargetPanel;
|
* The gaphix stuff
|
||||||
private JTextField[] m_TargetTextField, m_PunishTextField;
|
*/
|
||||||
private JComboBox m_Objective;
|
private JPanel m_CustomEditor, m_DataPanel, m_ButtonPanel, m_TargetPanel;
|
||||||
private JButton m_OKButton;
|
private JTextField[] m_TargetTextField, m_PunishTextField;
|
||||||
|
private JComboBox m_Objective;
|
||||||
|
private JButton m_OKButton;
|
||||||
|
|
||||||
public GenericEpsilonThresholdEditor() {
|
public GenericEpsilonThresholdEditor() {
|
||||||
// compiled code
|
// compiled code
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method will init the CustomEditor Panel
|
/**
|
||||||
|
* This method will init the CustomEditor Panel
|
||||||
*/
|
*/
|
||||||
private void initCustomEditor() {
|
private void initCustomEditor() {
|
||||||
this.m_CustomEditor = new JPanel();
|
this.m_CustomEditor = new JPanel();
|
||||||
this.m_CustomEditor.setLayout(new BorderLayout());
|
this.m_CustomEditor.setLayout(new BorderLayout());
|
||||||
|
|
||||||
// target panel
|
// target panel
|
||||||
@@ -47,7 +56,7 @@ public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEdi
|
|||||||
this.m_TargetPanel.add(new JLabel("Optimize:"));
|
this.m_TargetPanel.add(new JLabel("Optimize:"));
|
||||||
this.m_Objective = new JComboBox();
|
this.m_Objective = new JComboBox();
|
||||||
for (int i = 0; i < this.m_EpsilonThreshhold.m_TargetValue.length; i++) {
|
for (int i = 0; i < this.m_EpsilonThreshhold.m_TargetValue.length; i++) {
|
||||||
this.m_Objective.addItem("Objective "+i);
|
this.m_Objective.addItem("Objective " + i);
|
||||||
}
|
}
|
||||||
this.m_TargetPanel.add(this.m_Objective);
|
this.m_TargetPanel.add(this.m_Objective);
|
||||||
this.m_Objective.addItemListener(this.objectiveAction);
|
this.m_Objective.addItemListener(this.objectiveAction);
|
||||||
@@ -60,47 +69,50 @@ public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEdi
|
|||||||
|
|
||||||
// init button panel
|
// init button panel
|
||||||
this.m_ButtonPanel = new JPanel();
|
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.setEnabled(true);
|
||||||
this.m_OKButton.addActionListener(new ActionListener() {
|
this.m_OKButton.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
//m_Backup = copyObject(m_Object);
|
//m_Backup = copyObject(m_Object);
|
||||||
if ((m_CustomEditor.getTopLevelAncestor() != null) && (m_CustomEditor.getTopLevelAncestor() instanceof Window)) {
|
if ((m_CustomEditor.getTopLevelAncestor() != null) && (m_CustomEditor.getTopLevelAncestor() instanceof Window)) {
|
||||||
Window w = (Window) m_CustomEditor.getTopLevelAncestor();
|
Window w = (Window) m_CustomEditor.getTopLevelAncestor();
|
||||||
w.dispose();
|
w.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.m_ButtonPanel.add(this.m_OKButton);
|
this.m_ButtonPanel.add(this.m_OKButton);
|
||||||
this.m_CustomEditor.add(this.m_ButtonPanel, BorderLayout.SOUTH);
|
this.m_CustomEditor.add(this.m_ButtonPanel, BorderLayout.SOUTH);
|
||||||
this.updateEditor();
|
this.updateEditor();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This action listener adds an element to DoubleArray
|
/**
|
||||||
|
* This action listener adds an element to DoubleArray
|
||||||
*/
|
*/
|
||||||
ItemListener objectiveAction = new ItemListener() {
|
ItemListener objectiveAction = new ItemListener() {
|
||||||
@Override
|
@Override
|
||||||
public void itemStateChanged(ItemEvent event) {
|
public void itemStateChanged(ItemEvent event) {
|
||||||
m_EpsilonThreshhold.m_OptimizeObjective = m_Objective.getSelectedIndex();
|
m_EpsilonThreshhold.m_OptimizeObjective = m_Objective.getSelectedIndex();
|
||||||
updateEditor();
|
updateEditor();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** This action listener reads all values
|
/**
|
||||||
|
* This action listener reads all values
|
||||||
*/
|
*/
|
||||||
KeyListener readDoubleArrayAction = new KeyListener() {
|
KeyListener readDoubleArrayAction = new KeyListener() {
|
||||||
@Override
|
@Override
|
||||||
public void keyPressed(KeyEvent event) {
|
public void keyPressed(KeyEvent event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void keyTyped(KeyEvent event) {
|
public void keyTyped(KeyEvent event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void keyReleased(KeyEvent event) {
|
public void keyReleased(KeyEvent event) {
|
||||||
double[] tmpT = m_EpsilonThreshhold.m_TargetValue;
|
double[] tmpT = m_EpsilonThreshhold.m_TargetValue;
|
||||||
double[] tmpP = m_EpsilonThreshhold.m_Punishment;
|
double[] tmpP = m_EpsilonThreshhold.m_Punishment;
|
||||||
|
|
||||||
for (int i = 0; i < tmpT.length; i++) {
|
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_TargetValue = tmpT;
|
||||||
m_EpsilonThreshhold.m_Punishment = tmpP;
|
m_EpsilonThreshhold.m_Punishment = tmpP;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** The object may have changed update the editor.
|
/**
|
||||||
|
* The object may have changed update the editor.
|
||||||
*/
|
*/
|
||||||
private void updateEditor() {
|
private void updateEditor() {
|
||||||
if (this.m_CustomEditor != null) {
|
if (this.m_CustomEditor != null) {
|
||||||
@@ -135,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() {
|
private void updateDataPanel() {
|
||||||
double[] tmpT = this.m_EpsilonThreshhold.m_TargetValue;
|
double[] tmpT = this.m_EpsilonThreshhold.m_TargetValue;
|
||||||
double[] tmpP = this.m_EpsilonThreshhold.m_Punishment;
|
double[] tmpP = this.m_EpsilonThreshhold.m_Punishment;
|
||||||
int obj = this.m_EpsilonThreshhold.m_OptimizeObjective;
|
int obj = this.m_EpsilonThreshhold.m_OptimizeObjective;
|
||||||
|
|
||||||
this.m_DataPanel.removeAll();
|
this.m_DataPanel.removeAll();
|
||||||
this.m_DataPanel.setLayout(new GridLayout(tmpT.length+1, 3));
|
this.m_DataPanel.setLayout(new GridLayout(tmpT.length + 1, 3));
|
||||||
this.m_DataPanel.add(new JLabel());
|
this.m_DataPanel.add(new JLabel());
|
||||||
this.m_DataPanel.add(new JLabel("Target Value"));
|
this.m_DataPanel.add(new JLabel("Target Value"));
|
||||||
this.m_DataPanel.add(new JLabel("Punishment"));
|
this.m_DataPanel.add(new JLabel("Punishment"));
|
||||||
this.m_TargetTextField = new JTextField[tmpT.length];
|
this.m_TargetTextField = new JTextField[tmpT.length];
|
||||||
this.m_PunishTextField = new JTextField[tmpT.length];
|
this.m_PunishTextField = new JTextField[tmpT.length];
|
||||||
for (int i = 0; i < tmpT.length; i++) {
|
for (int i = 0; i < tmpT.length; i++) {
|
||||||
JLabel label = new JLabel("Objective "+i+": ");
|
JLabel label = new JLabel("Objective " + i + ": ");
|
||||||
this.m_DataPanel.add(label);
|
this.m_DataPanel.add(label);
|
||||||
this.m_TargetTextField[i] = new JTextField();
|
this.m_TargetTextField[i] = new JTextField();
|
||||||
this.m_TargetTextField[i].setText(""+tmpT[i]);
|
this.m_TargetTextField[i].setText("" + tmpT[i]);
|
||||||
this.m_TargetTextField[i].addKeyListener(this.readDoubleArrayAction);
|
this.m_TargetTextField[i].addKeyListener(this.readDoubleArrayAction);
|
||||||
this.m_DataPanel.add(this.m_TargetTextField[i]);
|
this.m_DataPanel.add(this.m_TargetTextField[i]);
|
||||||
this.m_PunishTextField[i] = new JTextField();
|
this.m_PunishTextField[i] = new JTextField();
|
||||||
this.m_PunishTextField[i].setText(""+tmpP[i]);
|
this.m_PunishTextField[i].setText("" + tmpP[i]);
|
||||||
this.m_PunishTextField[i].addKeyListener(this.readDoubleArrayAction);
|
this.m_PunishTextField[i].addKeyListener(this.readDoubleArrayAction);
|
||||||
this.m_DataPanel.add(this.m_PunishTextField[i]);
|
this.m_DataPanel.add(this.m_PunishTextField[i]);
|
||||||
}
|
}
|
||||||
@@ -166,7 +180,9 @@ public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEdi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** This method will set the value of object that is to be edited.
|
/**
|
||||||
|
* This method will set the value of object that is to be edited.
|
||||||
|
*
|
||||||
* @param o an object that must be an array.
|
* @param o an object that must be an array.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -177,7 +193,9 @@ public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEdi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the current object.
|
/**
|
||||||
|
* Returns the current object.
|
||||||
|
*
|
||||||
* @return the current object
|
* @return the current object
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -216,35 +234,41 @@ public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEdi
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||||
if (m_Support == null) {
|
if (m_Support == null) {
|
||||||
m_Support = new PropertyChangeSupport(this);
|
m_Support = new PropertyChangeSupport(this);
|
||||||
}
|
}
|
||||||
m_Support.addPropertyChangeListener(l);
|
m_Support.addPropertyChangeListener(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||||
if (m_Support == null) {
|
if (m_Support == null) {
|
||||||
m_Support = new PropertyChangeSupport(this);
|
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.
|
* @param a The action listener.
|
||||||
*/
|
*/
|
||||||
public void addOkListener(ActionListener a) {
|
public void addOkListener(ActionListener a) {
|
||||||
m_OKButton.addActionListener(a);
|
m_OKButton.addActionListener(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This is used to remove an action listener from the ok button
|
/**
|
||||||
|
* This is used to remove an action listener from the ok button
|
||||||
|
*
|
||||||
* @param a The action listener
|
* @param a The action listener
|
||||||
*/
|
*/
|
||||||
public void removeOkListener(ActionListener a) {
|
public void removeOkListener(ActionListener a) {
|
||||||
m_OKButton.removeActionListener(a);
|
m_OKButton.removeActionListener(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true since the Object can be shown
|
/**
|
||||||
|
* Returns true since the Object can be shown
|
||||||
|
*
|
||||||
* @return true
|
* @return true
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -252,7 +276,8 @@ public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEdi
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Paints a representation of the current classifier.
|
/**
|
||||||
|
* Paints a representation of the current classifier.
|
||||||
*
|
*
|
||||||
* @param gfx the graphics context to use
|
* @param gfx the graphics context to use
|
||||||
* @param box the area we are allowed to paint into
|
* @param box the area we are allowed to paint into
|
||||||
@@ -262,20 +287,24 @@ public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEdi
|
|||||||
FontMetrics fm = gfx.getFontMetrics();
|
FontMetrics fm = gfx.getFontMetrics();
|
||||||
int vpad = (box.height - fm.getAscent()) / 2;
|
int vpad = (box.height - fm.getAscent()) / 2;
|
||||||
String rep = "Edit Epsilon Threshhold";
|
String rep = "Edit Epsilon Threshhold";
|
||||||
gfx.drawString(rep, 2, fm.getHeight() + vpad - 3 );
|
gfx.drawString(rep, 2, fm.getHeight() + vpad - 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true because we do support a custom editor.
|
/**
|
||||||
* @return true
|
* Returns true because we do support a custom editor.
|
||||||
*/
|
*
|
||||||
|
* @return true
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsCustomEditor() {
|
public boolean supportsCustomEditor() {
|
||||||
return true;
|
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
|
@Override
|
||||||
public Component getCustomEditor() {
|
public Component getCustomEditor() {
|
||||||
if (this.m_CustomEditor == null) {
|
if (this.m_CustomEditor == null) {
|
||||||
|
|||||||
@@ -23,22 +23,32 @@ import javax.swing.SwingConstants;
|
|||||||
*/
|
*/
|
||||||
public class GenericFilePathEditor extends JPanel implements PropertyEditor {
|
public class GenericFilePathEditor extends JPanel implements PropertyEditor {
|
||||||
|
|
||||||
/** Handles property change notification */
|
/**
|
||||||
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
* Handles property change notification
|
||||||
/** The label for when we can't edit that type */
|
*/
|
||||||
private JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER);
|
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||||
/** The FilePath that is to be edited*/
|
/**
|
||||||
|
* 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;
|
private PropertyFilePath m_FilePath;
|
||||||
|
|
||||||
/** The gaphix stuff */
|
/**
|
||||||
private JFileChooser m_FileChooser;
|
* The gaphix stuff
|
||||||
private JPanel m_Panel;
|
*/
|
||||||
|
private JFileChooser m_FileChooser;
|
||||||
|
private JPanel m_Panel;
|
||||||
|
|
||||||
public GenericFilePathEditor() {
|
public GenericFilePathEditor() {
|
||||||
// compiled code
|
// compiled code
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method will set the value of object that is to be edited.
|
/**
|
||||||
|
* This method will set the value of object that is to be edited.
|
||||||
|
*
|
||||||
* @param o an object that must be an array.
|
* @param o an object that must be an array.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -48,7 +58,9 @@ public class GenericFilePathEditor extends JPanel implements PropertyEditor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the current object.
|
/**
|
||||||
|
* Returns the current object.
|
||||||
|
*
|
||||||
* @return the current object
|
* @return the current object
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -87,21 +99,23 @@ public class GenericFilePathEditor extends JPanel implements PropertyEditor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||||
if (m_Support == null) {
|
if (m_Support == null) {
|
||||||
m_Support = new PropertyChangeSupport(this);
|
m_Support = new PropertyChangeSupport(this);
|
||||||
}
|
}
|
||||||
m_Support.addPropertyChangeListener(l);
|
m_Support.addPropertyChangeListener(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||||
if (m_Support == null) {
|
if (m_Support == null) {
|
||||||
m_Support = new PropertyChangeSupport(this);
|
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
|
* @return true
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -109,7 +123,8 @@ public class GenericFilePathEditor extends JPanel implements PropertyEditor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Paints a representation of the current classifier.
|
/**
|
||||||
|
* Paints a representation of the current classifier.
|
||||||
*
|
*
|
||||||
* @param gfx the graphics context to use
|
* @param gfx the graphics context to use
|
||||||
* @param box the area we are allowed to paint into
|
* @param box the area we are allowed to paint into
|
||||||
@@ -119,24 +134,28 @@ public class GenericFilePathEditor extends JPanel implements PropertyEditor {
|
|||||||
FontMetrics fm = gfx.getFontMetrics();
|
FontMetrics fm = gfx.getFontMetrics();
|
||||||
int vpad = (box.height - fm.getAscent()) / 2;
|
int vpad = (box.height - fm.getAscent()) / 2;
|
||||||
String rep = this.m_FilePath.FileName;
|
String rep = this.m_FilePath.FileName;
|
||||||
gfx.drawString(rep, 2, fm.getHeight() + vpad - 3 );
|
gfx.drawString(rep, 2, fm.getHeight() + vpad - 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true because we do support a custom editor.
|
/**
|
||||||
* @return true
|
* Returns true because we do support a custom editor.
|
||||||
*/
|
*
|
||||||
|
* @return true
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsCustomEditor() {
|
public boolean supportsCustomEditor() {
|
||||||
return true;
|
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
|
@Override
|
||||||
public Component getCustomEditor() {
|
public Component getCustomEditor() {
|
||||||
this.m_Panel = new JPanel();
|
this.m_Panel = new JPanel();
|
||||||
this.m_FileChooser = new JFileChooser();
|
this.m_FileChooser = new JFileChooser();
|
||||||
File file = new File(this.m_FilePath.getCompleteFilePath());
|
File file = new File(this.m_FilePath.getCompleteFilePath());
|
||||||
this.m_FileChooser.setSelectedFile(file);
|
this.m_FileChooser.setSelectedFile(file);
|
||||||
this.m_FileChooser.setMultiSelectionEnabled(false);
|
this.m_FileChooser.setMultiSelectionEnabled(false);
|
||||||
@@ -145,7 +164,8 @@ public class GenericFilePathEditor extends JPanel implements PropertyEditor {
|
|||||||
return this.m_Panel;
|
return this.m_Panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This action listener, called by the "train" button, causes
|
/**
|
||||||
|
* This action listener, called by the "train" button, causes
|
||||||
* the SOM to recalculate the mapping.
|
* the SOM to recalculate the mapping.
|
||||||
*/
|
*/
|
||||||
ActionListener fileChooserAction = new ActionListener() {
|
ActionListener fileChooserAction = new ActionListener() {
|
||||||
@@ -155,7 +175,7 @@ public class GenericFilePathEditor extends JPanel implements PropertyEditor {
|
|||||||
m_FilePath.setCompleteFilePath(m_FileChooser.getSelectedFile().getAbsolutePath());
|
m_FilePath.setCompleteFilePath(m_FileChooser.getSelectedFile().getAbsolutePath());
|
||||||
m_Support.firePropertyChange("", m_FilePath, null);
|
m_Support.firePropertyChange("", m_FilePath, null);
|
||||||
Window w = (Window) m_FileChooser.getTopLevelAncestor();
|
Window w = (Window) m_FileChooser.getTopLevelAncestor();
|
||||||
w.dispose();
|
w.dispose();
|
||||||
m_Panel = null;
|
m_Panel = null;
|
||||||
}
|
}
|
||||||
if (event.getActionCommand() == "CancelSelection") {
|
if (event.getActionCommand() == "CancelSelection") {
|
||||||
|
|||||||
@@ -21,26 +21,35 @@ import javax.swing.*;
|
|||||||
*/
|
*/
|
||||||
public class GenericIntArrayEditor extends JPanel implements PropertyEditor {
|
public class GenericIntArrayEditor extends JPanel implements PropertyEditor {
|
||||||
|
|
||||||
/** Handles property change notification */
|
/**
|
||||||
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
* Handles property change notification
|
||||||
/** The label for when we can't edit that type */
|
*/
|
||||||
private JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER);
|
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||||
/** The FilePath that is to be edited*/
|
/**
|
||||||
|
* 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;
|
private PropertyIntArray m_IntArray;
|
||||||
|
|
||||||
/** The gaphix stuff */
|
/**
|
||||||
private JPanel m_CustomEditor, m_DataPanel, m_ButtonPanel;
|
* The gaphix stuff
|
||||||
private JTextField[] m_InputTextField;
|
*/
|
||||||
private JButton m_OKButton;
|
private JPanel m_CustomEditor, m_DataPanel, m_ButtonPanel;
|
||||||
|
private JTextField[] m_InputTextField;
|
||||||
|
private JButton m_OKButton;
|
||||||
|
|
||||||
public GenericIntArrayEditor() {
|
public GenericIntArrayEditor() {
|
||||||
// compiled code
|
// compiled code
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method will init the CustomEditor Panel
|
/**
|
||||||
|
* This method will init the CustomEditor Panel
|
||||||
*/
|
*/
|
||||||
private void initCustomEditor() {
|
private void initCustomEditor() {
|
||||||
this.m_CustomEditor = new JPanel();
|
this.m_CustomEditor = new JPanel();
|
||||||
this.m_CustomEditor.setLayout(new BorderLayout());
|
this.m_CustomEditor.setLayout(new BorderLayout());
|
||||||
|
|
||||||
this.m_CustomEditor.add(new JLabel("Current Int Array:"), BorderLayout.NORTH);
|
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
|
// init button panel
|
||||||
this.m_ButtonPanel = new JPanel();
|
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.setEnabled(true);
|
||||||
this.m_OKButton.addActionListener(new ActionListener() {
|
this.m_OKButton.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
//m_Backup = copyObject(m_Object);
|
//m_Backup = copyObject(m_Object);
|
||||||
if ((m_CustomEditor.getTopLevelAncestor() != null) && (m_CustomEditor.getTopLevelAncestor() instanceof Window)) {
|
if ((m_CustomEditor.getTopLevelAncestor() != null) && (m_CustomEditor.getTopLevelAncestor() instanceof Window)) {
|
||||||
Window w = (Window) m_CustomEditor.getTopLevelAncestor();
|
Window w = (Window) m_CustomEditor.getTopLevelAncestor();
|
||||||
w.dispose();
|
w.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.m_ButtonPanel.add(this.m_OKButton);
|
this.m_ButtonPanel.add(this.m_OKButton);
|
||||||
this.m_CustomEditor.add(this.m_ButtonPanel, BorderLayout.SOUTH);
|
this.m_CustomEditor.add(this.m_ButtonPanel, BorderLayout.SOUTH);
|
||||||
this.updateEditor();
|
this.updateEditor();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This action listener reads all values
|
/**
|
||||||
|
* This action listener reads all values
|
||||||
*/
|
*/
|
||||||
KeyListener readIntArrayAction = new KeyListener() {
|
KeyListener readIntArrayAction = new KeyListener() {
|
||||||
@Override
|
@Override
|
||||||
public void keyPressed(KeyEvent event) {
|
public void keyPressed(KeyEvent event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void keyTyped(KeyEvent event) {
|
public void keyTyped(KeyEvent event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void keyReleased(KeyEvent event) {
|
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++) {
|
for (int i = 0; i < tmpD.length; i++) {
|
||||||
try {
|
try {
|
||||||
@@ -93,10 +104,11 @@ public class GenericIntArrayEditor extends JPanel implements PropertyEditor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_IntArray.setIntArray(tmpD);
|
m_IntArray.setIntArray(tmpD);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** The object may have changed update the editor.
|
/**
|
||||||
|
* The object may have changed update the editor.
|
||||||
*/
|
*/
|
||||||
private void updateEditor() {
|
private void updateEditor() {
|
||||||
if (this.m_CustomEditor != null) {
|
if (this.m_CustomEditor != null) {
|
||||||
@@ -106,7 +118,8 @@ public class GenericIntArrayEditor extends JPanel implements PropertyEditor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method updates the data panel
|
/**
|
||||||
|
* This method updates the data panel
|
||||||
*/
|
*/
|
||||||
private void updateDataPanel() {
|
private void updateDataPanel() {
|
||||||
int[] tmpD = this.m_IntArray.getIntArray();
|
int[] tmpD = this.m_IntArray.getIntArray();
|
||||||
@@ -115,17 +128,19 @@ public class GenericIntArrayEditor extends JPanel implements PropertyEditor {
|
|||||||
this.m_DataPanel.setLayout(new GridLayout(tmpD.length, 2));
|
this.m_DataPanel.setLayout(new GridLayout(tmpD.length, 2));
|
||||||
this.m_InputTextField = new JTextField[tmpD.length];
|
this.m_InputTextField = new JTextField[tmpD.length];
|
||||||
for (int i = 0; i < tmpD.length; i++) {
|
for (int i = 0; i < tmpD.length; i++) {
|
||||||
JLabel label = new JLabel("Value X"+i+": ");
|
JLabel label = new JLabel("Value X" + i + ": ");
|
||||||
this.m_DataPanel.add(label);
|
this.m_DataPanel.add(label);
|
||||||
this.m_InputTextField[i] = new JTextField();
|
this.m_InputTextField[i] = new JTextField();
|
||||||
this.m_InputTextField[i].setText(""+tmpD[i]);
|
this.m_InputTextField[i].setText("" + tmpD[i]);
|
||||||
this.m_InputTextField[i].addKeyListener(this.readIntArrayAction);
|
this.m_InputTextField[i].addKeyListener(this.readIntArrayAction);
|
||||||
this.m_DataPanel.add(this.m_InputTextField[i]);
|
this.m_DataPanel.add(this.m_InputTextField[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** This method will set the value of object that is to be edited.
|
/**
|
||||||
|
* This method will set the value of object that is to be edited.
|
||||||
|
*
|
||||||
* @param o an object that must be an array.
|
* @param o an object that must be an array.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -136,7 +151,9 @@ public class GenericIntArrayEditor extends JPanel implements PropertyEditor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the current object.
|
/**
|
||||||
|
* Returns the current object.
|
||||||
|
*
|
||||||
* @return the current object
|
* @return the current object
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -175,35 +192,41 @@ public class GenericIntArrayEditor extends JPanel implements PropertyEditor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||||
if (m_Support == null) {
|
if (m_Support == null) {
|
||||||
m_Support = new PropertyChangeSupport(this);
|
m_Support = new PropertyChangeSupport(this);
|
||||||
}
|
}
|
||||||
m_Support.addPropertyChangeListener(l);
|
m_Support.addPropertyChangeListener(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||||
if (m_Support == null) {
|
if (m_Support == null) {
|
||||||
m_Support = new PropertyChangeSupport(this);
|
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.
|
* @param a The action listener.
|
||||||
*/
|
*/
|
||||||
public void addOkListener(ActionListener a) {
|
public void addOkListener(ActionListener a) {
|
||||||
m_OKButton.addActionListener(a);
|
m_OKButton.addActionListener(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This is used to remove an action listener from the ok button
|
/**
|
||||||
|
* This is used to remove an action listener from the ok button
|
||||||
|
*
|
||||||
* @param a The action listener
|
* @param a The action listener
|
||||||
*/
|
*/
|
||||||
public void removeOkListener(ActionListener a) {
|
public void removeOkListener(ActionListener a) {
|
||||||
m_OKButton.removeActionListener(a);
|
m_OKButton.removeActionListener(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true since the Object can be shown
|
/**
|
||||||
|
* Returns true since the Object can be shown
|
||||||
|
*
|
||||||
* @return true
|
* @return true
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -211,7 +234,8 @@ public class GenericIntArrayEditor extends JPanel implements PropertyEditor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Paints a representation of the current classifier.
|
/**
|
||||||
|
* Paints a representation of the current classifier.
|
||||||
*
|
*
|
||||||
* @param gfx the graphics context to use
|
* @param gfx the graphics context to use
|
||||||
* @param box the area we are allowed to paint into
|
* @param box the area we are allowed to paint into
|
||||||
@@ -221,20 +245,24 @@ public class GenericIntArrayEditor extends JPanel implements PropertyEditor {
|
|||||||
FontMetrics fm = gfx.getFontMetrics();
|
FontMetrics fm = gfx.getFontMetrics();
|
||||||
int vpad = (box.height - fm.getAscent()) / 2;
|
int vpad = (box.height - fm.getAscent()) / 2;
|
||||||
String rep = "Edit int[]";
|
String rep = "Edit int[]";
|
||||||
gfx.drawString(rep, 2, fm.getHeight() + vpad - 3 );
|
gfx.drawString(rep, 2, fm.getHeight() + vpad - 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true because we do support a custom editor.
|
/**
|
||||||
* @return true
|
* Returns true because we do support a custom editor.
|
||||||
*/
|
*
|
||||||
|
* @return true
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsCustomEditor() {
|
public boolean supportsCustomEditor() {
|
||||||
return true;
|
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
|
@Override
|
||||||
public Component getCustomEditor() {
|
public Component getCustomEditor() {
|
||||||
if (this.m_CustomEditor == null) {
|
if (this.m_CustomEditor == null) {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ package eva2.gui.editor;
|
|||||||
import eva2.EvAInfo;
|
import eva2.EvAInfo;
|
||||||
import eva2.gui.GOEPanel;
|
import eva2.gui.GOEPanel;
|
||||||
import eva2.tools.ReflectPackage;
|
import eva2.tools.ReflectPackage;
|
||||||
|
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.FontMetrics;
|
import java.awt.FontMetrics;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
@@ -76,9 +77,9 @@ public class GenericObjectEditor implements PropertyEditor {
|
|||||||
* "hideFromGOE" this method will skip it. Abstract classes and interfaces will be skipped as
|
* "hideFromGOE" this method will skip it. Abstract classes and interfaces will be skipped as
|
||||||
* well.
|
* well.
|
||||||
*
|
*
|
||||||
* @see ReflectPackage.getAssignableClassesInPackage
|
|
||||||
* @param className
|
* @param className
|
||||||
* @return
|
* @return
|
||||||
|
* @see ReflectPackage.getAssignableClassesInPackage
|
||||||
*/
|
*/
|
||||||
public static ArrayList<String> getClassesFromClassPath(String className, ArrayList<Class<?>> instances) {
|
public static ArrayList<String> getClassesFromClassPath(String className, ArrayList<Class<?>> instances) {
|
||||||
ArrayList<String> classes = new ArrayList<String>();
|
ArrayList<String> classes = new ArrayList<String>();
|
||||||
@@ -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 {
|
try {
|
||||||
Class<?>[] params = new Class[0];
|
Class<?>[] params = new Class[0];
|
||||||
clazz.getConstructor(params);
|
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
|
* this only sets the hidden property of the java bean which is checked in the wasModified
|
||||||
* method of PropertySheetPanel.
|
* method of PropertySheetPanel.
|
||||||
*
|
*
|
||||||
* @param cls class the property belongs to
|
* @param cls class the property belongs to
|
||||||
* @param property string name of the property
|
* @param property string name of the property
|
||||||
* @param hide desired value to set, true for hidden, false for visible
|
* @param hide desired value to set, true for hidden, false for visible
|
||||||
* @return false, if an error occurs, else true
|
* @return false, if an error occurs, else true
|
||||||
*/
|
*/
|
||||||
public static boolean setExpertProperty(Class<?> cls, String property, boolean expertValue) {
|
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
|
* this only sets the hidden property of the java bean which is checked in the wasModified
|
||||||
* method of PropertySheetPanel.
|
* method of PropertySheetPanel.
|
||||||
*
|
*
|
||||||
* @param cls class the property belongs to
|
* @param cls class the property belongs to
|
||||||
* @param property string name of the property
|
* @param property string name of the property
|
||||||
* @param hide desired value to set, true for hidden, false for visible
|
* @param hide desired value to set, true for hidden, false for visible
|
||||||
* @return false, if an error occurs, else true
|
* @return false, if an error occurs, else true
|
||||||
*/
|
*/
|
||||||
public static boolean setHideProperty(Class<?> cls, String property, boolean hide) {
|
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'
|
* @param type a value of type 'Class'
|
||||||
*/
|
*/
|
||||||
public void setClassType(Class<?> type) {
|
public void setClassType(Class<?> type) {
|
||||||
classType = type;
|
classType = type;
|
||||||
if (editorComponent != null) {
|
if (editorComponent != null) {
|
||||||
editorComponent.updateClassType();
|
editorComponent.updateClassType();
|
||||||
@@ -286,7 +287,7 @@ public class GenericObjectEditor implements PropertyEditor {
|
|||||||
|
|
||||||
Vector<String> v = null;
|
Vector<String> v = null;
|
||||||
v = new Vector<String>(getClassesFromProperties(classType.getName(), null));
|
v = new Vector<String>(getClassesFromProperties(classType.getName(), null));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (v.size() > 0) {
|
if (v.size() > 0) {
|
||||||
setObject((Object) Class.forName((String) v.get(0)).newInstance());
|
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.
|
* Returns null as we don't support getting/setting values as text.
|
||||||
*
|
*
|
||||||
* @param text the text value
|
* @param text the text value
|
||||||
* @exception IllegalArgumentException as we don't support getting/setting values as text.
|
* @throws IllegalArgumentException as we don't support getting/setting values as text.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setAsText(String text) throws IllegalArgumentException {
|
public void setAsText(String text) throws IllegalArgumentException {
|
||||||
|
|||||||
@@ -4,52 +4,54 @@ import eva2.gui.PropertySelectableList;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* An editor for a selectable List.
|
* An editor for a selectable List.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class GenericObjectListSelectionEditor extends AbstractListSelectionEditor {
|
public class GenericObjectListSelectionEditor extends AbstractListSelectionEditor {
|
||||||
private PropertySelectableList objList;
|
private PropertySelectableList objList;
|
||||||
|
|
||||||
public GenericObjectListSelectionEditor() {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int getElementCount() {
|
|
||||||
return objList.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public GenericObjectListSelectionEditor() {
|
||||||
protected String getElementName(int i) {
|
}
|
||||||
return objList.get(i).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isElementSelected(int i) {
|
protected int getElementCount() {
|
||||||
return objList.isSelected(i);
|
return objList.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean actionOnSelect() {
|
protected String getElementName(int i) {
|
||||||
boolean changed=false;
|
return objList.get(i).toString();
|
||||||
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
|
@Override
|
||||||
protected boolean setObject(Object o) {
|
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) {
|
if (o instanceof PropertySelectableList) {
|
||||||
this.objList = (PropertySelectableList) o;
|
this.objList = (PropertySelectableList) o;
|
||||||
objList.addPropertyChangeListener(this);
|
objList.addPropertyChangeListener(this);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Retruns the current object.
|
/**
|
||||||
|
* Retruns the current object.
|
||||||
|
*
|
||||||
* @return the current object
|
* @return the current object
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import eva2.optimization.problems.InterfaceOptimizationTarget;
|
|||||||
import eva2.optimization.tools.AbstractObjectEditor;
|
import eva2.optimization.tools.AbstractObjectEditor;
|
||||||
import eva2.optimization.tools.GeneralGOEProperty;
|
import eva2.optimization.tools.GeneralGOEProperty;
|
||||||
import eva2.tools.BasicResourceLoader;
|
import eva2.tools.BasicResourceLoader;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
@@ -44,28 +45,37 @@ import javax.swing.SwingConstants;
|
|||||||
*/
|
*/
|
||||||
public class GenericOptimizationObjectivesEditor extends JPanel implements PropertyEditor, java.beans.PropertyChangeListener {
|
public class GenericOptimizationObjectivesEditor extends JPanel implements PropertyEditor, java.beans.PropertyChangeListener {
|
||||||
|
|
||||||
/** Handles property change notification */
|
/**
|
||||||
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
* Handles property change notification
|
||||||
/** The label for when we can't edit that type */
|
*/
|
||||||
private JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER);
|
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||||
/** The FilePath that is to be edited*/
|
/**
|
||||||
|
* 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;
|
private PropertyOptimizationObjectives m_OptimizationObjectives;
|
||||||
|
|
||||||
/** The gaphix stuff */
|
/**
|
||||||
private JComponent m_Editor;
|
* The gaphix stuff
|
||||||
private JPanel m_TargetList;
|
*/
|
||||||
private JComponent[] m_Targets;
|
private JComponent m_Editor;
|
||||||
private JButton[] m_Delete;
|
private JPanel m_TargetList;
|
||||||
private JScrollPane m_ScrollTargets;
|
private JComponent[] m_Targets;
|
||||||
private GeneralGOEProperty[] m_Editors;
|
private JButton[] m_Delete;
|
||||||
private PropertyChangeListener m_self;
|
private JScrollPane m_ScrollTargets;
|
||||||
|
private GeneralGOEProperty[] m_Editors;
|
||||||
|
private PropertyChangeListener m_self;
|
||||||
|
|
||||||
public GenericOptimizationObjectivesEditor() {
|
public GenericOptimizationObjectivesEditor() {
|
||||||
m_self = this;
|
m_self = this;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method will init the CustomEditor Panel
|
/**
|
||||||
|
* This method will init the CustomEditor Panel
|
||||||
*/
|
*/
|
||||||
private void initCustomEditor() {
|
private void initCustomEditor() {
|
||||||
m_self = this;
|
m_self = this;
|
||||||
@@ -74,14 +84,14 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
|
|||||||
this.m_Editor.setMinimumSize(new Dimension(400, 200));
|
this.m_Editor.setMinimumSize(new Dimension(400, 200));
|
||||||
|
|
||||||
// init the editors
|
// init the editors
|
||||||
InterfaceOptimizationObjective[] list = this.m_OptimizationObjectives.getSelectedTargets();
|
InterfaceOptimizationObjective[] list = this.m_OptimizationObjectives.getSelectedTargets();
|
||||||
this.m_Editors = new GeneralGOEProperty[list.length];
|
this.m_Editors = new GeneralGOEProperty[list.length];
|
||||||
for (int i = 0; i < list.length; i++) {
|
for (int i = 0; i < list.length; i++) {
|
||||||
this.m_Editors[i] = new GeneralGOEProperty();
|
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 {
|
try {
|
||||||
this.m_Editors[i].m_Value = list[i];
|
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_Editor = PropertyEditorProvider.findEditor(this.m_Editors[i].m_Value.getClass());
|
||||||
if (this.m_Editors[i].m_Editor == null) {
|
if (this.m_Editors[i].m_Editor == null) {
|
||||||
this.m_Editors[i].m_Editor = PropertyEditorProvider.findEditor(InterfaceOptimizationObjective.class);
|
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.m_TargetList = new JPanel();
|
||||||
this.updateTargetList();
|
this.updateTargetList();
|
||||||
this.m_ScrollTargets = new JScrollPane(this.m_TargetList);
|
this.m_ScrollTargets = new JScrollPane(this.m_TargetList);
|
||||||
|
|
||||||
this.m_Editor.setLayout(new BorderLayout());
|
this.m_Editor.setLayout(new BorderLayout());
|
||||||
this.m_Editor.add(this.m_ScrollTargets, BorderLayout.CENTER);
|
this.m_Editor.add(this.m_ScrollTargets, BorderLayout.CENTER);
|
||||||
|
|
||||||
// the add button
|
// the add button
|
||||||
JButton addButton = new JButton("Add Opt. Target");
|
JButton addButton = new JButton("Add Opt. Target");
|
||||||
addButton.addActionListener(addTarget);
|
addButton.addActionListener(addTarget);
|
||||||
this.m_Editor.add(addButton, BorderLayout.SOUTH);
|
this.m_Editor.add(addButton, BorderLayout.SOUTH);
|
||||||
|
|
||||||
// Some description would be nice
|
// Some description would be nice
|
||||||
JTextArea jt = new JTextArea();
|
JTextArea jt = new JTextArea();
|
||||||
jt.setFont(new Font("SansSerif", Font.PLAIN,12));
|
jt.setFont(new Font("SansSerif", Font.PLAIN, 12));
|
||||||
jt.setEditable(false);
|
jt.setEditable(false);
|
||||||
jt.setLineWrap(true);
|
jt.setLineWrap(true);
|
||||||
jt.setWrapStyleWord(true);
|
jt.setWrapStyleWord(true);
|
||||||
jt.setText("Choose and parameterize optimization objectives.");
|
jt.setText("Choose and parameterize optimization objectives.");
|
||||||
jt.setBackground(getBackground());
|
jt.setBackground(getBackground());
|
||||||
JPanel jp = new JPanel();
|
JPanel jp = new JPanel();
|
||||||
jp.setBorder(BorderFactory.createCompoundBorder(
|
jp.setBorder(BorderFactory.createCompoundBorder(
|
||||||
BorderFactory.createTitledBorder("Info"),
|
BorderFactory.createTitledBorder("Info"),
|
||||||
BorderFactory.createEmptyBorder(0, 5, 5, 5)
|
BorderFactory.createEmptyBorder(0, 5, 5, 5)
|
||||||
));
|
));
|
||||||
jp.setLayout(new BorderLayout());
|
jp.setLayout(new BorderLayout());
|
||||||
jp.add(jt, BorderLayout.CENTER);
|
jp.add(jt, BorderLayout.CENTER);
|
||||||
JPanel p2 = new JPanel();
|
JPanel p2 = new JPanel();
|
||||||
p2.setLayout(new BorderLayout());
|
p2.setLayout(new BorderLayout());
|
||||||
JButton help = new JButton("Help");
|
JButton help = new JButton("Help");
|
||||||
help.setEnabled(false);
|
help.setEnabled(false);
|
||||||
p2.add(help, BorderLayout.NORTH);
|
p2.add(help, BorderLayout.NORTH);
|
||||||
jp.add(p2, BorderLayout.EAST);
|
jp.add(p2, BorderLayout.EAST);
|
||||||
GridBagConstraints gbConstraints = new GridBagConstraints();
|
GridBagConstraints gbConstraints = new GridBagConstraints();
|
||||||
this.m_Editor.add(jp, BorderLayout.NORTH);
|
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() {
|
private void updateTargetList() {
|
||||||
BasicResourceLoader loader = BasicResourceLoader.instance();
|
BasicResourceLoader loader = BasicResourceLoader.instance();
|
||||||
byte[] bytes;
|
byte[] bytes;
|
||||||
InterfaceOptimizationObjective[] list = this.m_OptimizationObjectives.getSelectedTargets();
|
InterfaceOptimizationObjective[] list = this.m_OptimizationObjectives.getSelectedTargets();
|
||||||
|
|
||||||
this.m_TargetList.removeAll();
|
this.m_TargetList.removeAll();
|
||||||
this.m_TargetList.setLayout(new GridBagLayout());
|
this.m_TargetList.setLayout(new GridBagLayout());
|
||||||
GridBagConstraints gbc = new GridBagConstraints();
|
GridBagConstraints gbc = new GridBagConstraints();
|
||||||
this.m_Targets = new JComponent[list.length];
|
this.m_Targets = new JComponent[list.length];
|
||||||
this.m_Delete = new JButton[list.length];
|
this.m_Delete = new JButton[list.length];
|
||||||
String[] cups = new String[8];
|
String[] cups = new String[8];
|
||||||
for (int i = 0; i < cups.length; i++) {
|
for (int i = 0; i < cups.length; i++) {
|
||||||
cups[i] = ""+(i+1);
|
cups[i] = "" + (i + 1);
|
||||||
}
|
}
|
||||||
// The head title
|
// The head title
|
||||||
gbc.anchor = GridBagConstraints.WEST;
|
gbc.anchor = GridBagConstraints.WEST;
|
||||||
gbc.fill = GridBagConstraints.BOTH;
|
gbc.fill = GridBagConstraints.BOTH;
|
||||||
gbc.gridx = 0;
|
gbc.gridx = 0;
|
||||||
gbc.weightx = 10;
|
gbc.weightx = 10;
|
||||||
this.m_TargetList.add(new JLabel("Target"), gbc);
|
this.m_TargetList.add(new JLabel("Target"), gbc);
|
||||||
gbc.anchor = GridBagConstraints.WEST;
|
gbc.anchor = GridBagConstraints.WEST;
|
||||||
gbc.fill = GridBagConstraints.REMAINDER;
|
gbc.fill = GridBagConstraints.REMAINDER;
|
||||||
gbc.gridx = 1;
|
gbc.gridx = 1;
|
||||||
gbc.weightx = 1;
|
gbc.weightx = 1;
|
||||||
this.m_TargetList.add(new JLabel("Remove"), gbc);
|
this.m_TargetList.add(new JLabel("Remove"), gbc);
|
||||||
for (int i = 0; i < list.length; i++) {
|
for (int i = 0; i < list.length; i++) {
|
||||||
// the status indicator
|
// the status indicator
|
||||||
gbc.anchor = GridBagConstraints.WEST;
|
gbc.anchor = GridBagConstraints.WEST;
|
||||||
gbc.fill = GridBagConstraints.BOTH;
|
gbc.fill = GridBagConstraints.BOTH;
|
||||||
gbc.gridx = 0;
|
gbc.gridx = 0;
|
||||||
gbc.weightx = 10;
|
gbc.weightx = 10;
|
||||||
// this.m_Targets[i] = new JButton(""+list[i].getName());
|
// this.m_Targets[i] = new JButton(""+list[i].getName());
|
||||||
// this.m_Targets[i].setEnabled(false);
|
// this.m_Targets[i].setEnabled(false);
|
||||||
this.m_Targets[i] = this.m_Editors[i].m_View;
|
this.m_Targets[i] = this.m_Editors[i].m_View;
|
||||||
this.m_TargetList.add(this.m_Targets[i], gbc);
|
this.m_TargetList.add(this.m_Targets[i], gbc);
|
||||||
// The delete button
|
// The delete button
|
||||||
gbc.anchor = GridBagConstraints.WEST;
|
gbc.anchor = GridBagConstraints.WEST;
|
||||||
gbc.fill = GridBagConstraints.REMAINDER;
|
gbc.fill = GridBagConstraints.REMAINDER;
|
||||||
gbc.gridx = 1;
|
gbc.gridx = 1;
|
||||||
gbc.weightx = 1;
|
gbc.weightx = 1;
|
||||||
bytes = loader.getBytesFromResourceLocation("images/Sub24.gif", true);
|
bytes = loader.getBytesFromResourceLocation("images/Sub24.gif", true);
|
||||||
this.m_Delete[i] = new JButton("", new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes)));
|
this.m_Delete[i] = new JButton("", new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes)));
|
||||||
this.m_Delete[i].addActionListener(deleteTarget);
|
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() {
|
ActionListener updateTargets = new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -206,12 +217,13 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** This action listener,...
|
/**
|
||||||
|
* This action listener,...
|
||||||
*/
|
*/
|
||||||
ActionListener addTarget = new ActionListener() {
|
ActionListener addTarget = new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent event) {
|
public void actionPerformed(ActionEvent event) {
|
||||||
m_OptimizationObjectives.addTarget((InterfaceOptimizationObjective)m_OptimizationObjectives.getAvailableTargets()[0].clone());
|
m_OptimizationObjectives.addTarget((InterfaceOptimizationObjective) m_OptimizationObjectives.getAvailableTargets()[0].clone());
|
||||||
int l = m_OptimizationObjectives.getSelectedTargets().length;
|
int l = m_OptimizationObjectives.getSelectedTargets().length;
|
||||||
GeneralGOEProperty[] newEdit = new GeneralGOEProperty[l];
|
GeneralGOEProperty[] newEdit = new GeneralGOEProperty[l];
|
||||||
for (int i = 0; i < m_Editors.length; i++) {
|
for (int i = 0; i < m_Editors.length; i++) {
|
||||||
@@ -219,11 +231,11 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
|
|||||||
}
|
}
|
||||||
InterfaceOptimizationObjective[] list = m_OptimizationObjectives.getSelectedTargets();
|
InterfaceOptimizationObjective[] list = m_OptimizationObjectives.getSelectedTargets();
|
||||||
l--;
|
l--;
|
||||||
newEdit[l] = new GeneralGOEProperty();
|
newEdit[l] = new GeneralGOEProperty();
|
||||||
newEdit[l].m_Name = list[l].getName();
|
newEdit[l].m_Name = list[l].getName();
|
||||||
try {
|
try {
|
||||||
newEdit[l].m_Value = list[l];
|
newEdit[l].m_Value = list[l];
|
||||||
newEdit[l].m_Editor = PropertyEditorProvider.findEditor(newEdit[l].m_Value.getClass());
|
newEdit[l].m_Editor = PropertyEditorProvider.findEditor(newEdit[l].m_Value.getClass());
|
||||||
if (newEdit[l].m_Editor == null) {
|
if (newEdit[l].m_Editor == null) {
|
||||||
newEdit[l].m_Editor = PropertyEditorProvider.findEditor(InterfaceOptimizationObjective.class);
|
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() {
|
ActionListener deleteTarget = new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent event) {
|
public void actionPerformed(ActionEvent event) {
|
||||||
int l = m_OptimizationObjectives.getSelectedTargets().length, j = 0;
|
int l = m_OptimizationObjectives.getSelectedTargets().length, j = 0;
|
||||||
GeneralGOEProperty[] newEdit = new GeneralGOEProperty[l-1];
|
GeneralGOEProperty[] newEdit = new GeneralGOEProperty[l - 1];
|
||||||
for (int i = 0; i < m_Delete.length; i++) {
|
for (int i = 0; i < m_Delete.length; i++) {
|
||||||
if (event.getSource().equals(m_Delete[i])) {
|
if (event.getSource().equals(m_Delete[i])) {
|
||||||
m_OptimizationObjectives.removeTarget(i);
|
m_OptimizationObjectives.removeTarget(i);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
newEdit[j] = m_Editors[i];
|
newEdit[j] = m_Editors[i];
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
@@ -265,7 +277,8 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** The object may have changed update the editor.
|
/**
|
||||||
|
* The object may have changed update the editor.
|
||||||
*/
|
*/
|
||||||
private void updateEditor() {
|
private void updateEditor() {
|
||||||
if (this.m_Editor != null) {
|
if (this.m_Editor != null) {
|
||||||
@@ -279,18 +292,22 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** This method will set the value of object that is to be edited.
|
/**
|
||||||
|
* This method will set the value of object that is to be edited.
|
||||||
|
*
|
||||||
* @param o an object that must be an array.
|
* @param o an object that must be an array.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setValue(Object o) {
|
public void setValue(Object o) {
|
||||||
if (o instanceof PropertyOptimizationObjectives) {
|
if (o instanceof PropertyOptimizationObjectives) {
|
||||||
this.m_OptimizationObjectives= (PropertyOptimizationObjectives) o;
|
this.m_OptimizationObjectives = (PropertyOptimizationObjectives) o;
|
||||||
this.updateEditor();
|
this.updateEditor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the current object.
|
/**
|
||||||
|
* Returns the current object.
|
||||||
|
*
|
||||||
* @return the current object
|
* @return the current object
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -327,21 +344,27 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This is used to hook an action listener to the ok button
|
/**
|
||||||
|
* This is used to hook an action listener to the ok button
|
||||||
|
*
|
||||||
* @param a The action listener.
|
* @param a The action listener.
|
||||||
*/
|
*/
|
||||||
public void addOkListener(ActionListener a) {
|
public void addOkListener(ActionListener a) {
|
||||||
//m_OKButton.addActionListener(a);
|
//m_OKButton.addActionListener(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This is used to remove an action listener from the ok button
|
/**
|
||||||
|
* This is used to remove an action listener from the ok button
|
||||||
|
*
|
||||||
* @param a The action listener
|
* @param a The action listener
|
||||||
*/
|
*/
|
||||||
public void removeOkListener(ActionListener a) {
|
public void removeOkListener(ActionListener a) {
|
||||||
//m_OKButton.removeActionListener(a);
|
//m_OKButton.removeActionListener(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true since the Object can be shown
|
/**
|
||||||
|
* Returns true since the Object can be shown
|
||||||
|
*
|
||||||
* @return true
|
* @return true
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -349,7 +372,8 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Paints a representation of the current classifier.
|
/**
|
||||||
|
* Paints a representation of the current classifier.
|
||||||
*
|
*
|
||||||
* @param gfx the graphics context to use
|
* @param gfx the graphics context to use
|
||||||
* @param box the area we are allowed to paint into
|
* @param box the area we are allowed to paint into
|
||||||
@@ -359,20 +383,24 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
|
|||||||
FontMetrics fm = gfx.getFontMetrics();
|
FontMetrics fm = gfx.getFontMetrics();
|
||||||
int vpad = (box.height - fm.getAscent()) / 2;
|
int vpad = (box.height - fm.getAscent()) / 2;
|
||||||
String rep = "Optimization Targets";
|
String rep = "Optimization Targets";
|
||||||
gfx.drawString(rep, 2, fm.getHeight() + vpad - 3 );
|
gfx.drawString(rep, 2, fm.getHeight() + vpad - 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true because we do support a custom editor.
|
/**
|
||||||
* @return true
|
* Returns true because we do support a custom editor.
|
||||||
*/
|
*
|
||||||
|
* @return true
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsCustomEditor() {
|
public boolean supportsCustomEditor() {
|
||||||
return true;
|
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
|
@Override
|
||||||
public Component getCustomEditor() {
|
public Component getCustomEditor() {
|
||||||
if (this.m_Editor == null) {
|
if (this.m_Editor == null) {
|
||||||
@@ -381,7 +409,8 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
|
|||||||
return m_Editor;
|
return m_Editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method will udate the status of the object taking the values from all
|
/**
|
||||||
|
* This method will udate the status of the object taking the values from all
|
||||||
* supsequent editors and setting them to my object.
|
* supsequent editors and setting them to my object.
|
||||||
*/
|
*/
|
||||||
public void updateCenterComponent(PropertyChangeEvent evt) {
|
public void updateCenterComponent(PropertyChangeEvent evt) {
|
||||||
@@ -389,39 +418,44 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
|
|||||||
this.updateEditor();
|
this.updateEditor();
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************* java.beans.PropertyChangeListener *************************/
|
/**
|
||||||
|
* ****************************** java.beans.PropertyChangeListener ************************
|
||||||
|
*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||||
if (m_Support == null) {
|
if (m_Support == null) {
|
||||||
m_Support = new PropertyChangeSupport(this);
|
m_Support = new PropertyChangeSupport(this);
|
||||||
}
|
}
|
||||||
m_Support.addPropertyChangeListener(l);
|
m_Support.addPropertyChangeListener(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||||
if (m_Support == null) {
|
if (m_Support == null) {
|
||||||
m_Support = new PropertyChangeSupport(this);
|
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.
|
* editing an object.
|
||||||
|
*
|
||||||
* @param evt
|
* @param evt
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void propertyChange(PropertyChangeEvent evt) {
|
public void propertyChange(PropertyChangeEvent evt) {
|
||||||
Object newVal = evt.getNewValue();
|
Object newVal = evt.getNewValue();
|
||||||
Object oldVal = evt.getOldValue();
|
Object oldVal = evt.getOldValue();
|
||||||
InterfaceOptimizationObjective[] list = this.m_OptimizationObjectives.getSelectedTargets();
|
InterfaceOptimizationObjective[] list = this.m_OptimizationObjectives.getSelectedTargets();
|
||||||
for (int i = 0; i < list.length; i++) {
|
for (int i = 0; i < list.length; i++) {
|
||||||
if (oldVal.equals(list[i])) {
|
if (oldVal.equals(list[i])) {
|
||||||
list[i] = (InterfaceOptimizationObjective)newVal;
|
list[i] = (InterfaceOptimizationObjective) newVal;
|
||||||
this.m_Editors[i].m_Name = list[i].getName();
|
this.m_Editors[i].m_Name = list[i].getName();
|
||||||
try {
|
try {
|
||||||
this.m_Editors[i].m_Value = list[i];
|
this.m_Editors[i].m_Value = list[i];
|
||||||
this.m_Editors[i].m_Editor = PropertyEditorProvider.findEditor(this.m_Editors[i].m_Value.getClass());
|
this.m_Editors[i].m_Editor = PropertyEditorProvider.findEditor(this.m_Editors[i].m_Value.getClass());
|
||||||
if (this.m_Editors[i].m_Editor == null) {
|
if (this.m_Editors[i].m_Editor == null) {
|
||||||
this.m_Editors[i].m_Editor = PropertyEditorProvider.findEditor(InterfaceOptimizationObjective.class);
|
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.AbstractObjectEditor;
|
||||||
import eva2.optimization.tools.GeneralGOEProperty;
|
import eva2.optimization.tools.GeneralGOEProperty;
|
||||||
import eva2.tools.BasicResourceLoader;
|
import eva2.tools.BasicResourceLoader;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
@@ -47,28 +48,37 @@ import javax.swing.SwingConstants;
|
|||||||
*/
|
*/
|
||||||
public class GenericOptimizationObjectivesWithParamEditor extends JPanel implements PropertyEditor, java.beans.PropertyChangeListener {
|
public class GenericOptimizationObjectivesWithParamEditor extends JPanel implements PropertyEditor, java.beans.PropertyChangeListener {
|
||||||
|
|
||||||
/** Handles property change notification */
|
/**
|
||||||
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
* Handles property change notification
|
||||||
/** The label for when we can't edit that type */
|
*/
|
||||||
private JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER);
|
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||||
/** The FilePath that is to be edited*/
|
/**
|
||||||
|
* 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;
|
private PropertyOptimizationObjectivesWithParam m_OptimizationObjectivesWithWeights;
|
||||||
|
|
||||||
/** The gaphix stuff */
|
/**
|
||||||
private JComponent m_Editor;
|
* The gaphix stuff
|
||||||
private JPanel m_TargetList;
|
*/
|
||||||
private JTextField[] m_Weights;
|
private JComponent m_Editor;
|
||||||
private JComponent[] m_Targets;
|
private JPanel m_TargetList;
|
||||||
private JButton[] m_Delete;
|
private JTextField[] m_Weights;
|
||||||
private JScrollPane m_ScrollTargets;
|
private JComponent[] m_Targets;
|
||||||
private GeneralGOEProperty[] m_Editors;
|
private JButton[] m_Delete;
|
||||||
private PropertyChangeListener m_self;
|
private JScrollPane m_ScrollTargets;
|
||||||
|
private GeneralGOEProperty[] m_Editors;
|
||||||
|
private PropertyChangeListener m_self;
|
||||||
|
|
||||||
public GenericOptimizationObjectivesWithParamEditor() {
|
public GenericOptimizationObjectivesWithParamEditor() {
|
||||||
m_self = this;
|
m_self = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method will init the CustomEditor Panel
|
/**
|
||||||
|
* This method will init the CustomEditor Panel
|
||||||
*/
|
*/
|
||||||
private void initCustomEditor() {
|
private void initCustomEditor() {
|
||||||
m_self = this;
|
m_self = this;
|
||||||
@@ -77,14 +87,14 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
|||||||
this.m_Editor.setMinimumSize(new Dimension(450, 200));
|
this.m_Editor.setMinimumSize(new Dimension(450, 200));
|
||||||
|
|
||||||
// init the editors
|
// init the editors
|
||||||
InterfaceOptimizationObjective[] list = this.m_OptimizationObjectivesWithWeights.getSelectedTargets();
|
InterfaceOptimizationObjective[] list = this.m_OptimizationObjectivesWithWeights.getSelectedTargets();
|
||||||
this.m_Editors = new GeneralGOEProperty[list.length];
|
this.m_Editors = new GeneralGOEProperty[list.length];
|
||||||
for (int i = 0; i < list.length; i++) {
|
for (int i = 0; i < list.length; i++) {
|
||||||
this.m_Editors[i] = new GeneralGOEProperty();
|
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 {
|
try {
|
||||||
this.m_Editors[i].m_Value = list[i];
|
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_Editor = PropertyEditorProvider.findEditor(this.m_Editors[i].m_Value.getClass());
|
||||||
if (this.m_Editors[i].m_Editor == null) {
|
if (this.m_Editors[i].m_Editor == null) {
|
||||||
this.m_Editors[i].m_Editor = PropertyEditorProvider.findEditor(InterfaceOptimizationObjective.class);
|
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.m_TargetList = new JPanel();
|
||||||
this.updateTargetList();
|
this.updateTargetList();
|
||||||
this.m_ScrollTargets = new JScrollPane(this.m_TargetList);
|
this.m_ScrollTargets = new JScrollPane(this.m_TargetList);
|
||||||
|
|
||||||
this.m_Editor.setLayout(new BorderLayout());
|
this.m_Editor.setLayout(new BorderLayout());
|
||||||
this.m_Editor.add(this.m_ScrollTargets, BorderLayout.CENTER);
|
this.m_Editor.add(this.m_ScrollTargets, BorderLayout.CENTER);
|
||||||
|
|
||||||
// The Button Panel
|
// The Button Panel
|
||||||
JPanel buttonPanel = new JPanel();
|
JPanel buttonPanel = new JPanel();
|
||||||
buttonPanel.setLayout(new GridLayout(1,2));
|
buttonPanel.setLayout(new GridLayout(1, 2));
|
||||||
JButton addButton = new JButton("Add Opt. Target");
|
JButton addButton = new JButton("Add Opt. Target");
|
||||||
JButton normButton = new JButton("Normalize Weights");
|
JButton normButton = new JButton("Normalize Weights");
|
||||||
normButton.setEnabled(this.m_OptimizationObjectivesWithWeights.isNormalizationEnabled());
|
normButton.setEnabled(this.m_OptimizationObjectivesWithWeights.isNormalizationEnabled());
|
||||||
normButton.addActionListener(normalizeWeights);
|
normButton.addActionListener(normalizeWeights);
|
||||||
addButton.addActionListener(addTarget);
|
addButton.addActionListener(addTarget);
|
||||||
@@ -122,89 +132,89 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
|||||||
this.m_Editor.add(buttonPanel, BorderLayout.SOUTH);
|
this.m_Editor.add(buttonPanel, BorderLayout.SOUTH);
|
||||||
|
|
||||||
// Some description would be nice
|
// Some description would be nice
|
||||||
JTextArea jt = new JTextArea();
|
JTextArea jt = new JTextArea();
|
||||||
jt.setFont(new Font("SansSerif", Font.PLAIN,12));
|
jt.setFont(new Font("SansSerif", Font.PLAIN, 12));
|
||||||
jt.setEditable(false);
|
jt.setEditable(false);
|
||||||
jt.setLineWrap(true);
|
jt.setLineWrap(true);
|
||||||
jt.setWrapStyleWord(true);
|
jt.setWrapStyleWord(true);
|
||||||
jt.setText(this.m_OptimizationObjectivesWithWeights.getDescriptiveString());
|
jt.setText(this.m_OptimizationObjectivesWithWeights.getDescriptiveString());
|
||||||
jt.setBackground(getBackground());
|
jt.setBackground(getBackground());
|
||||||
JPanel jp = new JPanel();
|
JPanel jp = new JPanel();
|
||||||
jp.setBorder(BorderFactory.createCompoundBorder(
|
jp.setBorder(BorderFactory.createCompoundBorder(
|
||||||
BorderFactory.createTitledBorder("Info"),
|
BorderFactory.createTitledBorder("Info"),
|
||||||
BorderFactory.createEmptyBorder(0, 5, 5, 5)
|
BorderFactory.createEmptyBorder(0, 5, 5, 5)
|
||||||
));
|
));
|
||||||
jp.setLayout(new BorderLayout());
|
jp.setLayout(new BorderLayout());
|
||||||
jp.add(jt, BorderLayout.CENTER);
|
jp.add(jt, BorderLayout.CENTER);
|
||||||
JPanel p2 = new JPanel();
|
JPanel p2 = new JPanel();
|
||||||
p2.setLayout(new BorderLayout());
|
p2.setLayout(new BorderLayout());
|
||||||
JButton help = new JButton("Help");
|
JButton help = new JButton("Help");
|
||||||
help.setEnabled(false);
|
help.setEnabled(false);
|
||||||
p2.add(help, BorderLayout.NORTH);
|
p2.add(help, BorderLayout.NORTH);
|
||||||
jp.add(p2, BorderLayout.EAST);
|
jp.add(p2, BorderLayout.EAST);
|
||||||
GridBagConstraints gbConstraints = new GridBagConstraints();
|
GridBagConstraints gbConstraints = new GridBagConstraints();
|
||||||
|
|
||||||
this.m_Editor.add(jp, BorderLayout.NORTH);
|
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() {
|
private void updateTargetList() {
|
||||||
BasicResourceLoader loader = BasicResourceLoader.instance();
|
BasicResourceLoader loader = BasicResourceLoader.instance();
|
||||||
byte[] bytes;
|
byte[] bytes;
|
||||||
InterfaceOptimizationObjective[] list = this.m_OptimizationObjectivesWithWeights.getSelectedTargets();
|
InterfaceOptimizationObjective[] list = this.m_OptimizationObjectivesWithWeights.getSelectedTargets();
|
||||||
double[] weights = this.m_OptimizationObjectivesWithWeights.getWeights();
|
double[] weights = this.m_OptimizationObjectivesWithWeights.getWeights();
|
||||||
|
|
||||||
this.m_TargetList.removeAll();
|
this.m_TargetList.removeAll();
|
||||||
this.m_TargetList.setLayout(new GridBagLayout());
|
this.m_TargetList.setLayout(new GridBagLayout());
|
||||||
GridBagConstraints gbc = new GridBagConstraints();
|
GridBagConstraints gbc = new GridBagConstraints();
|
||||||
this.m_Weights = new JTextField[list.length];
|
this.m_Weights = new JTextField[list.length];
|
||||||
this.m_Targets = new JComponent[list.length];
|
this.m_Targets = new JComponent[list.length];
|
||||||
this.m_Delete = new JButton[list.length];
|
this.m_Delete = new JButton[list.length];
|
||||||
String[] cups = new String[8];
|
String[] cups = new String[8];
|
||||||
for (int i = 0; i < cups.length; i++) {
|
for (int i = 0; i < cups.length; i++) {
|
||||||
cups[i] = ""+(i+1);
|
cups[i] = "" + (i + 1);
|
||||||
}
|
}
|
||||||
// The head title
|
// The head title
|
||||||
gbc.anchor = GridBagConstraints.WEST;
|
gbc.anchor = GridBagConstraints.WEST;
|
||||||
gbc.fill = GridBagConstraints.BOTH;
|
gbc.fill = GridBagConstraints.BOTH;
|
||||||
gbc.gridx = 0;
|
gbc.gridx = 0;
|
||||||
gbc.weightx = 2;
|
gbc.weightx = 2;
|
||||||
this.m_TargetList.add(new JLabel(this.m_OptimizationObjectivesWithWeights.getWeigthsLabel()), gbc);
|
this.m_TargetList.add(new JLabel(this.m_OptimizationObjectivesWithWeights.getWeigthsLabel()), gbc);
|
||||||
gbc.anchor = GridBagConstraints.WEST;
|
gbc.anchor = GridBagConstraints.WEST;
|
||||||
gbc.fill = GridBagConstraints.BOTH;
|
gbc.fill = GridBagConstraints.BOTH;
|
||||||
gbc.gridx = 1;
|
gbc.gridx = 1;
|
||||||
gbc.weightx = 10;
|
gbc.weightx = 10;
|
||||||
this.m_TargetList.add(new JLabel("Target"), gbc);
|
this.m_TargetList.add(new JLabel("Target"), gbc);
|
||||||
gbc.anchor = GridBagConstraints.WEST;
|
gbc.anchor = GridBagConstraints.WEST;
|
||||||
gbc.fill = GridBagConstraints.REMAINDER;
|
gbc.fill = GridBagConstraints.REMAINDER;
|
||||||
gbc.gridx = 2;
|
gbc.gridx = 2;
|
||||||
gbc.weightx = 1;
|
gbc.weightx = 1;
|
||||||
this.m_TargetList.add(new JLabel("Remove"), gbc);
|
this.m_TargetList.add(new JLabel("Remove"), gbc);
|
||||||
for (int i = 0; i < list.length; i++) {
|
for (int i = 0; i < list.length; i++) {
|
||||||
// the weight
|
// the weight
|
||||||
gbc.anchor = GridBagConstraints.WEST;
|
gbc.anchor = GridBagConstraints.WEST;
|
||||||
gbc.fill = GridBagConstraints.BOTH;
|
gbc.fill = GridBagConstraints.BOTH;
|
||||||
gbc.gridx = 0;
|
gbc.gridx = 0;
|
||||||
gbc.weightx = 2;
|
gbc.weightx = 2;
|
||||||
this.m_Weights[i] = new JTextField(""+weights[i]);
|
this.m_Weights[i] = new JTextField("" + weights[i]);
|
||||||
this.m_Weights[i].addKeyListener(this.readDoubleArrayAction);
|
this.m_Weights[i].addKeyListener(this.readDoubleArrayAction);
|
||||||
this.m_TargetList.add(this.m_Weights[i], gbc);
|
this.m_TargetList.add(this.m_Weights[i], gbc);
|
||||||
// the status indicator
|
// the status indicator
|
||||||
gbc.anchor = GridBagConstraints.WEST;
|
gbc.anchor = GridBagConstraints.WEST;
|
||||||
gbc.fill = GridBagConstraints.BOTH;
|
gbc.fill = GridBagConstraints.BOTH;
|
||||||
gbc.gridx = 1;
|
gbc.gridx = 1;
|
||||||
gbc.weightx = 10;
|
gbc.weightx = 10;
|
||||||
this.m_Targets[i] = this.m_Editors[i].m_View;
|
this.m_Targets[i] = this.m_Editors[i].m_View;
|
||||||
this.m_TargetList.add(this.m_Targets[i], gbc);
|
this.m_TargetList.add(this.m_Targets[i], gbc);
|
||||||
// The delete button
|
// The delete button
|
||||||
gbc.anchor = GridBagConstraints.WEST;
|
gbc.anchor = GridBagConstraints.WEST;
|
||||||
gbc.fill = GridBagConstraints.REMAINDER;
|
gbc.fill = GridBagConstraints.REMAINDER;
|
||||||
gbc.gridx = 2;
|
gbc.gridx = 2;
|
||||||
gbc.weightx = 1;
|
gbc.weightx = 1;
|
||||||
bytes = loader.getBytesFromResourceLocation("images/Sub24.gif", true);
|
bytes = loader.getBytesFromResourceLocation("images/Sub24.gif", true);
|
||||||
this.m_Delete[i] = new JButton("", new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes)));
|
this.m_Delete[i] = new JButton("", new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes)));
|
||||||
this.m_Delete[i].addActionListener(deleteTarget);
|
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() {
|
ActionListener updateTargets = new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -231,12 +242,13 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** This action listener,...
|
/**
|
||||||
|
* This action listener,...
|
||||||
*/
|
*/
|
||||||
ActionListener addTarget = new ActionListener() {
|
ActionListener addTarget = new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent event) {
|
public void actionPerformed(ActionEvent event) {
|
||||||
m_OptimizationObjectivesWithWeights.addTarget((InterfaceOptimizationObjective)m_OptimizationObjectivesWithWeights.getAvailableTargets()[0].clone());
|
m_OptimizationObjectivesWithWeights.addTarget((InterfaceOptimizationObjective) m_OptimizationObjectivesWithWeights.getAvailableTargets()[0].clone());
|
||||||
int l = m_OptimizationObjectivesWithWeights.getSelectedTargets().length;
|
int l = m_OptimizationObjectivesWithWeights.getSelectedTargets().length;
|
||||||
GeneralGOEProperty[] newEdit = new GeneralGOEProperty[l];
|
GeneralGOEProperty[] newEdit = new GeneralGOEProperty[l];
|
||||||
for (int i = 0; i < m_Editors.length; i++) {
|
for (int i = 0; i < m_Editors.length; i++) {
|
||||||
@@ -244,11 +256,11 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
|||||||
}
|
}
|
||||||
InterfaceOptimizationObjective[] list = m_OptimizationObjectivesWithWeights.getSelectedTargets();
|
InterfaceOptimizationObjective[] list = m_OptimizationObjectivesWithWeights.getSelectedTargets();
|
||||||
l--;
|
l--;
|
||||||
newEdit[l] = new GeneralGOEProperty();
|
newEdit[l] = new GeneralGOEProperty();
|
||||||
newEdit[l].m_Name = list[l].getName();
|
newEdit[l].m_Name = list[l].getName();
|
||||||
try {
|
try {
|
||||||
newEdit[l].m_Value = list[l];
|
newEdit[l].m_Value = list[l];
|
||||||
newEdit[l].m_Editor = PropertyEditorProvider.findEditor(newEdit[l].m_Value.getClass());
|
newEdit[l].m_Editor = PropertyEditorProvider.findEditor(newEdit[l].m_Value.getClass());
|
||||||
if (newEdit[l].m_Editor == null) {
|
if (newEdit[l].m_Editor == null) {
|
||||||
newEdit[l].m_Editor = PropertyEditorProvider.findEditor(InterfaceOptimizationObjective.class);
|
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() {
|
ActionListener deleteTarget = new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent event) {
|
public void actionPerformed(ActionEvent event) {
|
||||||
int l = m_OptimizationObjectivesWithWeights.getSelectedTargets().length, j = 0;
|
int l = m_OptimizationObjectivesWithWeights.getSelectedTargets().length, j = 0;
|
||||||
GeneralGOEProperty[] newEdit = new GeneralGOEProperty[l-1];
|
GeneralGOEProperty[] newEdit = new GeneralGOEProperty[l - 1];
|
||||||
for (int i = 0; i < m_Delete.length; i++) {
|
for (int i = 0; i < m_Delete.length; i++) {
|
||||||
if (event.getSource().equals(m_Delete[i])) {
|
if (event.getSource().equals(m_Delete[i])) {
|
||||||
m_OptimizationObjectivesWithWeights.removeTarget(i);
|
m_OptimizationObjectivesWithWeights.removeTarget(i);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
newEdit[j] = m_Editors[i];
|
newEdit[j] = m_Editors[i];
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
@@ -290,7 +302,8 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** This action listener,...
|
/**
|
||||||
|
* This action listener,...
|
||||||
*/
|
*/
|
||||||
ActionListener normalizeWeights = new ActionListener() {
|
ActionListener normalizeWeights = new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -310,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() {
|
KeyListener readDoubleArrayAction = new KeyListener() {
|
||||||
@Override
|
@Override
|
||||||
public void keyPressed(KeyEvent event) {
|
public void keyPressed(KeyEvent event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void keyTyped(KeyEvent event) {
|
public void keyTyped(KeyEvent event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void keyReleased(KeyEvent event) {
|
public void keyReleased(KeyEvent event) {
|
||||||
double[] newW = m_OptimizationObjectivesWithWeights.getWeights();
|
double[] newW = m_OptimizationObjectivesWithWeights.getWeights();
|
||||||
|
|
||||||
for (int i = 0; i < newW.length; i++) {
|
for (int i = 0; i < newW.length; i++) {
|
||||||
try {
|
try {
|
||||||
@@ -334,10 +349,11 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_OptimizationObjectivesWithWeights.setWeights(newW);
|
m_OptimizationObjectivesWithWeights.setWeights(newW);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** The object may have changed update the editor.
|
/**
|
||||||
|
* The object may have changed update the editor.
|
||||||
*/
|
*/
|
||||||
private void updateEditor() {
|
private void updateEditor() {
|
||||||
if (this.m_Editor != null) {
|
if (this.m_Editor != null) {
|
||||||
@@ -350,18 +366,22 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method will set the value of object that is to be edited.
|
/**
|
||||||
|
* This method will set the value of object that is to be edited.
|
||||||
|
*
|
||||||
* @param o an object that must be an array.
|
* @param o an object that must be an array.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setValue(Object o) {
|
public void setValue(Object o) {
|
||||||
if (o instanceof PropertyOptimizationObjectivesWithParam) {
|
if (o instanceof PropertyOptimizationObjectivesWithParam) {
|
||||||
this.m_OptimizationObjectivesWithWeights= (PropertyOptimizationObjectivesWithParam) o;
|
this.m_OptimizationObjectivesWithWeights = (PropertyOptimizationObjectivesWithParam) o;
|
||||||
this.updateEditor();
|
this.updateEditor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the current object.
|
/**
|
||||||
|
* Returns the current object.
|
||||||
|
*
|
||||||
* @return the current object
|
* @return the current object
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -398,21 +418,27 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This is used to hook an action listener to the ok button
|
/**
|
||||||
|
* This is used to hook an action listener to the ok button
|
||||||
|
*
|
||||||
* @param a The action listener.
|
* @param a The action listener.
|
||||||
*/
|
*/
|
||||||
public void addOkListener(ActionListener a) {
|
public void addOkListener(ActionListener a) {
|
||||||
//m_OKButton.addActionListener(a);
|
//m_OKButton.addActionListener(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This is used to remove an action listener from the ok button
|
/**
|
||||||
|
* This is used to remove an action listener from the ok button
|
||||||
|
*
|
||||||
* @param a The action listener
|
* @param a The action listener
|
||||||
*/
|
*/
|
||||||
public void removeOkListener(ActionListener a) {
|
public void removeOkListener(ActionListener a) {
|
||||||
//m_OKButton.removeActionListener(a);
|
//m_OKButton.removeActionListener(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true since the Object can be shown
|
/**
|
||||||
|
* Returns true since the Object can be shown
|
||||||
|
*
|
||||||
* @return true
|
* @return true
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -420,7 +446,8 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Paints a representation of the current classifier.
|
/**
|
||||||
|
* Paints a representation of the current classifier.
|
||||||
*
|
*
|
||||||
* @param gfx the graphics context to use
|
* @param gfx the graphics context to use
|
||||||
* @param box the area we are allowed to paint into
|
* @param box the area we are allowed to paint into
|
||||||
@@ -430,20 +457,24 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
|||||||
FontMetrics fm = gfx.getFontMetrics();
|
FontMetrics fm = gfx.getFontMetrics();
|
||||||
int vpad = (box.height - fm.getAscent()) / 2;
|
int vpad = (box.height - fm.getAscent()) / 2;
|
||||||
String rep = "Optimization Targets With Weights";
|
String rep = "Optimization Targets With Weights";
|
||||||
gfx.drawString(rep, 2, fm.getHeight() + vpad - 3 );
|
gfx.drawString(rep, 2, fm.getHeight() + vpad - 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true because we do support a custom editor.
|
/**
|
||||||
* @return true
|
* Returns true because we do support a custom editor.
|
||||||
*/
|
*
|
||||||
|
* @return true
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsCustomEditor() {
|
public boolean supportsCustomEditor() {
|
||||||
return true;
|
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
|
@Override
|
||||||
public Component getCustomEditor() {
|
public Component getCustomEditor() {
|
||||||
if (this.m_Editor == null) {
|
if (this.m_Editor == null) {
|
||||||
@@ -452,7 +483,8 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
|||||||
return m_Editor;
|
return m_Editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method will udate the status of the object taking the values from all
|
/**
|
||||||
|
* This method will udate the status of the object taking the values from all
|
||||||
* supsequent editors and setting them to my object.
|
* supsequent editors and setting them to my object.
|
||||||
*/
|
*/
|
||||||
public void updateCenterComponent(PropertyChangeEvent evt) {
|
public void updateCenterComponent(PropertyChangeEvent evt) {
|
||||||
@@ -460,39 +492,44 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
|||||||
this.updateEditor();
|
this.updateEditor();
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************* java.beans.PropertyChangeListener *************************/
|
/**
|
||||||
|
* ****************************** java.beans.PropertyChangeListener ************************
|
||||||
|
*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||||
if (m_Support == null) {
|
if (m_Support == null) {
|
||||||
m_Support = new PropertyChangeSupport(this);
|
m_Support = new PropertyChangeSupport(this);
|
||||||
}
|
}
|
||||||
m_Support.addPropertyChangeListener(l);
|
m_Support.addPropertyChangeListener(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||||
if (m_Support == null) {
|
if (m_Support == null) {
|
||||||
m_Support = new PropertyChangeSupport(this);
|
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.
|
* editing an object.
|
||||||
|
*
|
||||||
* @param evt
|
* @param evt
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void propertyChange(PropertyChangeEvent evt) {
|
public void propertyChange(PropertyChangeEvent evt) {
|
||||||
Object newVal = evt.getNewValue();
|
Object newVal = evt.getNewValue();
|
||||||
Object oldVal = evt.getOldValue();
|
Object oldVal = evt.getOldValue();
|
||||||
InterfaceOptimizationObjective[] list = this.m_OptimizationObjectivesWithWeights.getSelectedTargets();
|
InterfaceOptimizationObjective[] list = this.m_OptimizationObjectivesWithWeights.getSelectedTargets();
|
||||||
for (int i = 0; i < list.length; i++) {
|
for (int i = 0; i < list.length; i++) {
|
||||||
if (oldVal.equals(list[i])) {
|
if (oldVal.equals(list[i])) {
|
||||||
list[i] = (InterfaceOptimizationObjective)newVal;
|
list[i] = (InterfaceOptimizationObjective) newVal;
|
||||||
this.m_Editors[i].m_Name = list[i].getName();
|
this.m_Editors[i].m_Name = list[i].getName();
|
||||||
try {
|
try {
|
||||||
this.m_Editors[i].m_Value = list[i];
|
this.m_Editors[i].m_Value = list[i];
|
||||||
this.m_Editors[i].m_Editor = PropertyEditorProvider.findEditor(this.m_Editors[i].m_Value.getClass());
|
this.m_Editors[i].m_Editor = PropertyEditorProvider.findEditor(this.m_Editors[i].m_Value.getClass());
|
||||||
if (this.m_Editors[i].m_Editor == null) {
|
if (this.m_Editors[i].m_Editor == null) {
|
||||||
this.m_Editors[i].m_Editor = PropertyEditorProvider.findEditor(InterfaceOptimizationObjective.class);
|
this.m_Editors[i].m_Editor = PropertyEditorProvider.findEditor(InterfaceOptimizationObjective.class);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,34 +18,43 @@ import javax.swing.*;
|
|||||||
*/
|
*/
|
||||||
public class GenericWeigthedLPTchebycheffEditor extends JPanel implements PropertyEditor {
|
public class GenericWeigthedLPTchebycheffEditor extends JPanel implements PropertyEditor {
|
||||||
|
|
||||||
/** Handles property change notification */
|
/**
|
||||||
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
* Handles property change notification
|
||||||
/** The label for when we can't edit that type */
|
*/
|
||||||
private JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER);
|
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||||
/** The FilePath that is to be edited*/
|
/**
|
||||||
|
* 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;
|
private PropertyWeightedLPTchebycheff m_WLPT;
|
||||||
|
|
||||||
/** The gaphix stuff */
|
/**
|
||||||
private JPanel m_CustomEditor, m_DataPanel, m_ButtonPanel, m_TargetPanel;
|
* The gaphix stuff
|
||||||
private JTextField[] m_IdealTextField, m_WeightTextField;
|
*/
|
||||||
private JTextField m_PValue;
|
private JPanel m_CustomEditor, m_DataPanel, m_ButtonPanel, m_TargetPanel;
|
||||||
private JButton m_OKButton;
|
private JTextField[] m_IdealTextField, m_WeightTextField;
|
||||||
|
private JTextField m_PValue;
|
||||||
|
private JButton m_OKButton;
|
||||||
|
|
||||||
public GenericWeigthedLPTchebycheffEditor() {
|
public GenericWeigthedLPTchebycheffEditor() {
|
||||||
// compiled code
|
// compiled code
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method will init the CustomEditor Panel
|
/**
|
||||||
|
* This method will init the CustomEditor Panel
|
||||||
*/
|
*/
|
||||||
private void initCustomEditor() {
|
private void initCustomEditor() {
|
||||||
this.m_CustomEditor = new JPanel();
|
this.m_CustomEditor = new JPanel();
|
||||||
this.m_CustomEditor.setLayout(new BorderLayout());
|
this.m_CustomEditor.setLayout(new BorderLayout());
|
||||||
|
|
||||||
// target panel
|
// target panel
|
||||||
this.m_TargetPanel = new JPanel();
|
this.m_TargetPanel = new JPanel();
|
||||||
this.m_TargetPanel.setLayout(new GridLayout(1, 2));
|
this.m_TargetPanel.setLayout(new GridLayout(1, 2));
|
||||||
this.m_TargetPanel.add(new JLabel("Choose P:"));
|
this.m_TargetPanel.add(new JLabel("Choose P:"));
|
||||||
this.m_PValue = new JTextField(""+this.m_WLPT.m_P);
|
this.m_PValue = new JTextField("" + this.m_WLPT.m_P);
|
||||||
this.m_TargetPanel.add(this.m_PValue);
|
this.m_TargetPanel.add(this.m_PValue);
|
||||||
this.m_PValue.addKeyListener(this.readDoubleAction);
|
this.m_PValue.addKeyListener(this.readDoubleAction);
|
||||||
this.m_CustomEditor.add(this.m_TargetPanel, BorderLayout.NORTH);
|
this.m_CustomEditor.add(this.m_TargetPanel, BorderLayout.NORTH);
|
||||||
@@ -57,58 +66,62 @@ public class GenericWeigthedLPTchebycheffEditor extends JPanel implements Proper
|
|||||||
|
|
||||||
// init button panel
|
// init button panel
|
||||||
this.m_ButtonPanel = new JPanel();
|
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.setEnabled(true);
|
||||||
this.m_OKButton.addActionListener(new ActionListener() {
|
this.m_OKButton.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
//m_Backup = copyObject(m_Object);
|
//m_Backup = copyObject(m_Object);
|
||||||
if ((m_CustomEditor.getTopLevelAncestor() != null) && (m_CustomEditor.getTopLevelAncestor() instanceof Window)) {
|
if ((m_CustomEditor.getTopLevelAncestor() != null) && (m_CustomEditor.getTopLevelAncestor() instanceof Window)) {
|
||||||
Window w = (Window) m_CustomEditor.getTopLevelAncestor();
|
Window w = (Window) m_CustomEditor.getTopLevelAncestor();
|
||||||
w.dispose();
|
w.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.m_ButtonPanel.add(this.m_OKButton);
|
this.m_ButtonPanel.add(this.m_OKButton);
|
||||||
this.m_CustomEditor.add(this.m_ButtonPanel, BorderLayout.SOUTH);
|
this.m_CustomEditor.add(this.m_ButtonPanel, BorderLayout.SOUTH);
|
||||||
this.updateEditor();
|
this.updateEditor();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This action listener reads all values
|
/**
|
||||||
|
* This action listener reads all values
|
||||||
*/
|
*/
|
||||||
KeyListener readDoubleAction = new KeyListener() {
|
KeyListener readDoubleAction = new KeyListener() {
|
||||||
@Override
|
@Override
|
||||||
public void keyPressed(KeyEvent event) {
|
public void keyPressed(KeyEvent event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void keyTyped(KeyEvent event) {
|
public void keyTyped(KeyEvent event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void keyReleased(KeyEvent event) {
|
public void keyReleased(KeyEvent event) {
|
||||||
try {
|
try {
|
||||||
int d = new Integer(m_PValue.getText()).intValue();
|
int d = new Integer(m_PValue.getText()).intValue();
|
||||||
m_WLPT.m_P = d;
|
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() {
|
KeyListener readDoubleArrayAction = new KeyListener() {
|
||||||
@Override
|
@Override
|
||||||
public void keyPressed(KeyEvent event) {
|
public void keyPressed(KeyEvent event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void keyTyped(KeyEvent event) {
|
public void keyTyped(KeyEvent event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void keyReleased(KeyEvent event) {
|
public void keyReleased(KeyEvent event) {
|
||||||
double[] tmpT = m_WLPT.m_IdealValue;
|
double[] tmpT = m_WLPT.m_IdealValue;
|
||||||
double[] tmpP = m_WLPT.m_Weights;
|
double[] tmpP = m_WLPT.m_Weights;
|
||||||
|
|
||||||
for (int i = 0; i < tmpT.length; i++) {
|
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_IdealValue = tmpT;
|
||||||
m_WLPT.m_Weights = tmpP;
|
m_WLPT.m_Weights = tmpP;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** The object may have changed update the editor.
|
/**
|
||||||
|
* The object may have changed update the editor.
|
||||||
*/
|
*/
|
||||||
private void updateEditor() {
|
private void updateEditor() {
|
||||||
if (this.m_CustomEditor != null) {
|
if (this.m_CustomEditor != null) {
|
||||||
@@ -143,37 +157,40 @@ public class GenericWeigthedLPTchebycheffEditor extends JPanel implements Proper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method updates the data panel
|
/**
|
||||||
|
* This method updates the data panel
|
||||||
*/
|
*/
|
||||||
private void updateDataPanel() {
|
private void updateDataPanel() {
|
||||||
double[] tmpT = this.m_WLPT.m_IdealValue;
|
double[] tmpT = this.m_WLPT.m_IdealValue;
|
||||||
double[] tmpP = this.m_WLPT.m_Weights;
|
double[] tmpP = this.m_WLPT.m_Weights;
|
||||||
int obj = this.m_WLPT.m_P;
|
int obj = this.m_WLPT.m_P;
|
||||||
|
|
||||||
this.m_PValue.setText(""+obj);
|
this.m_PValue.setText("" + obj);
|
||||||
this.m_DataPanel.removeAll();
|
this.m_DataPanel.removeAll();
|
||||||
this.m_DataPanel.setLayout(new GridLayout(tmpT.length+1, 3));
|
this.m_DataPanel.setLayout(new GridLayout(tmpT.length + 1, 3));
|
||||||
this.m_DataPanel.add(new JLabel());
|
this.m_DataPanel.add(new JLabel());
|
||||||
this.m_DataPanel.add(new JLabel("Ideal Value"));
|
this.m_DataPanel.add(new JLabel("Ideal Value"));
|
||||||
this.m_DataPanel.add(new JLabel("Weights"));
|
this.m_DataPanel.add(new JLabel("Weights"));
|
||||||
this.m_IdealTextField = new JTextField[tmpT.length];
|
this.m_IdealTextField = new JTextField[tmpT.length];
|
||||||
this.m_WeightTextField = new JTextField[tmpT.length];
|
this.m_WeightTextField = new JTextField[tmpT.length];
|
||||||
for (int i = 0; i < tmpT.length; i++) {
|
for (int i = 0; i < tmpT.length; i++) {
|
||||||
JLabel label = new JLabel("Objective "+i+": ");
|
JLabel label = new JLabel("Objective " + i + ": ");
|
||||||
this.m_DataPanel.add(label);
|
this.m_DataPanel.add(label);
|
||||||
this.m_IdealTextField[i] = new JTextField();
|
this.m_IdealTextField[i] = new JTextField();
|
||||||
this.m_IdealTextField[i].setText(""+tmpT[i]);
|
this.m_IdealTextField[i].setText("" + tmpT[i]);
|
||||||
this.m_IdealTextField[i].addKeyListener(this.readDoubleArrayAction);
|
this.m_IdealTextField[i].addKeyListener(this.readDoubleArrayAction);
|
||||||
this.m_DataPanel.add(this.m_IdealTextField[i]);
|
this.m_DataPanel.add(this.m_IdealTextField[i]);
|
||||||
this.m_WeightTextField[i] = new JTextField();
|
this.m_WeightTextField[i] = new JTextField();
|
||||||
this.m_WeightTextField[i].setText(""+tmpP[i]);
|
this.m_WeightTextField[i].setText("" + tmpP[i]);
|
||||||
this.m_WeightTextField[i].addKeyListener(this.readDoubleArrayAction);
|
this.m_WeightTextField[i].addKeyListener(this.readDoubleArrayAction);
|
||||||
this.m_DataPanel.add(this.m_WeightTextField[i]);
|
this.m_DataPanel.add(this.m_WeightTextField[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** This method will set the value of object that is to be edited.
|
/**
|
||||||
|
* This method will set the value of object that is to be edited.
|
||||||
|
*
|
||||||
* @param o an object that must be an array.
|
* @param o an object that must be an array.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -184,7 +201,9 @@ public class GenericWeigthedLPTchebycheffEditor extends JPanel implements Proper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the current object.
|
/**
|
||||||
|
* Returns the current object.
|
||||||
|
*
|
||||||
* @return the current object
|
* @return the current object
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -223,35 +242,41 @@ public class GenericWeigthedLPTchebycheffEditor extends JPanel implements Proper
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||||
if (m_Support == null) {
|
if (m_Support == null) {
|
||||||
m_Support = new PropertyChangeSupport(this);
|
m_Support = new PropertyChangeSupport(this);
|
||||||
}
|
}
|
||||||
m_Support.addPropertyChangeListener(l);
|
m_Support.addPropertyChangeListener(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||||
if (m_Support == null) {
|
if (m_Support == null) {
|
||||||
m_Support = new PropertyChangeSupport(this);
|
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.
|
* @param a The action listener.
|
||||||
*/
|
*/
|
||||||
public void addOkListener(ActionListener a) {
|
public void addOkListener(ActionListener a) {
|
||||||
m_OKButton.addActionListener(a);
|
m_OKButton.addActionListener(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This is used to remove an action listener from the ok button
|
/**
|
||||||
|
* This is used to remove an action listener from the ok button
|
||||||
|
*
|
||||||
* @param a The action listener
|
* @param a The action listener
|
||||||
*/
|
*/
|
||||||
public void removeOkListener(ActionListener a) {
|
public void removeOkListener(ActionListener a) {
|
||||||
m_OKButton.removeActionListener(a);
|
m_OKButton.removeActionListener(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true since the Object can be shown
|
/**
|
||||||
|
* Returns true since the Object can be shown
|
||||||
|
*
|
||||||
* @return true
|
* @return true
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -259,7 +284,8 @@ public class GenericWeigthedLPTchebycheffEditor extends JPanel implements Proper
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Paints a representation of the current classifier.
|
/**
|
||||||
|
* Paints a representation of the current classifier.
|
||||||
*
|
*
|
||||||
* @param gfx the graphics context to use
|
* @param gfx the graphics context to use
|
||||||
* @param box the area we are allowed to paint into
|
* @param box the area we are allowed to paint into
|
||||||
@@ -269,20 +295,24 @@ public class GenericWeigthedLPTchebycheffEditor extends JPanel implements Proper
|
|||||||
FontMetrics fm = gfx.getFontMetrics();
|
FontMetrics fm = gfx.getFontMetrics();
|
||||||
int vpad = (box.height - fm.getAscent()) / 2;
|
int vpad = (box.height - fm.getAscent()) / 2;
|
||||||
String rep = "Edit the ideal vector, p and ev. the weights.";
|
String rep = "Edit the ideal vector, p and ev. the weights.";
|
||||||
gfx.drawString(rep, 2, fm.getHeight() + vpad - 3 );
|
gfx.drawString(rep, 2, fm.getHeight() + vpad - 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true because we do support a custom editor.
|
/**
|
||||||
* @return true
|
* Returns true because we do support a custom editor.
|
||||||
*/
|
*
|
||||||
|
* @return true
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsCustomEditor() {
|
public boolean supportsCustomEditor() {
|
||||||
return true;
|
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
|
@Override
|
||||||
public Component getCustomEditor() {
|
public Component getCustomEditor() {
|
||||||
if (this.m_CustomEditor == null) {
|
if (this.m_CustomEditor == null) {
|
||||||
|
|||||||
@@ -12,80 +12,101 @@ import java.beans.*;
|
|||||||
* <p>Description: </p>
|
* <p>Description: </p>
|
||||||
* <p>Copyright: Copyright (c) 2003</p>
|
* <p>Copyright: Copyright (c) 2003</p>
|
||||||
* <p>Company: </p>
|
* <p>Company: </p>
|
||||||
|
*
|
||||||
* @author not attributable
|
* @author not attributable
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class MultiLineStringEditor implements PropertyEditor {
|
public class MultiLineStringEditor implements PropertyEditor {
|
||||||
protected MultiLineString value; // The value we will be editing.
|
protected MultiLineString value; // The value we will be editing.
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setValue(Object o) { value=(MultiLineString) o;}
|
public void setValue(Object o) {
|
||||||
@Override
|
value = (MultiLineString) o;
|
||||||
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
|
|
||||||
|
|
||||||
// Say that we allow custom editing.
|
|
||||||
@Override
|
@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
|
@Override
|
||||||
public Component getCustomEditor() {
|
public void setAsText(String s) {
|
||||||
final TextArea t = new TextArea(value.string);
|
value.setString(s);
|
||||||
t.setSize(300, 150); // TextArea doesn't have a preferred size, so set one
|
}
|
||||||
t.addTextListener(new TextListener() {
|
|
||||||
|
@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
|
@Override
|
||||||
public void textValueChanged(TextEvent e) {
|
public void textValueChanged(TextEvent e) {
|
||||||
value.setString(t.getText());
|
value.setString(t.getText());
|
||||||
listeners.firePropertyChange(null, null, null);
|
listeners.firePropertyChange(null, null, null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Visual display of the value, for use with the custom editor.
|
// Visual display of the value, for use with the custom editor.
|
||||||
// Just print some instructions and hope they fit in the in the box.
|
// Just print some instructions and hope they fit in the in the box.
|
||||||
// This could be more sophisticated.
|
// This could be more sophisticated.
|
||||||
@Override
|
@Override
|
||||||
public boolean isPaintable() { return true; }
|
public boolean isPaintable() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paintValue(Graphics g, Rectangle r) {
|
public void paintValue(Graphics g, Rectangle r) {
|
||||||
g.setClip(r);
|
g.setClip(r);
|
||||||
g.drawString("Click to edit...", r.x+5, r.y+15);
|
g.drawString("Click to edit...", r.x + 5, r.y + 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Important method for code generators. Note that it
|
// Important method for code generators. Note that it
|
||||||
// ought to add any necessary escape sequences.
|
// ought to add any necessary escape sequences.
|
||||||
@Override
|
@Override
|
||||||
public String getJavaInitializationString() { return "\"" + value + "\""; }
|
public String getJavaInitializationString() {
|
||||||
|
return "\"" + value + "\"";
|
||||||
|
}
|
||||||
|
|
||||||
// This code uses the PropertyChangeSupport class to maintain a list of
|
// This code uses the PropertyChangeSupport class to maintain a list of
|
||||||
// listeners interested in the edits we make to the value.
|
// listeners interested in the edits we make to the value.
|
||||||
protected PropertyChangeSupport listeners = new PropertyChangeSupport(this);
|
protected PropertyChangeSupport listeners = new PropertyChangeSupport(this);
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
|
||||||
if (listeners == null) {
|
|
||||||
listeners = new PropertyChangeSupport(this);
|
|
||||||
}
|
|
||||||
listeners.addPropertyChangeListener(l);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||||
if (listeners == null) {
|
if (listeners == null) {
|
||||||
listeners = new PropertyChangeSupport(this);
|
listeners = new PropertyChangeSupport(this);
|
||||||
}
|
}
|
||||||
listeners.removePropertyChangeListener(l);
|
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) $
|
* $Date: 2007-10-23 13:43:24 +0200 (Tue, 23 Oct 2007) $
|
||||||
* $Author: mkron $
|
* $Author: mkron $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import eva2.gui.PropertySheetPanelStat;
|
import eva2.gui.PropertySheetPanelStat;
|
||||||
import eva2.optimization.stat.GenericStatistics;
|
import eva2.optimization.stat.GenericStatistics;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.beans.*;
|
import java.beans.*;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
public class StatisticsEditor implements PropertyEditor {
|
public class StatisticsEditor implements PropertyEditor {
|
||||||
|
|
||||||
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||||
private PropertySheetPanelStat m_StatPanel;
|
private PropertySheetPanelStat m_StatPanel;
|
||||||
private JScrollPane m_ScrollPane;
|
private JScrollPane m_ScrollPane;
|
||||||
private JPanel m_Panel;
|
private JPanel m_Panel;
|
||||||
private GenericStatistics m_Value;
|
private GenericStatistics m_Value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public StatisticsEditor() {
|
public StatisticsEditor() {
|
||||||
super();
|
super();
|
||||||
m_StatPanel = new PropertySheetPanelStat();
|
m_StatPanel = new PropertySheetPanelStat();
|
||||||
m_StatPanel.addPropertyChangeListener(
|
m_StatPanel.addPropertyChangeListener(
|
||||||
new PropertyChangeListener() {
|
new PropertyChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void propertyChange(PropertyChangeEvent evt) {
|
public void propertyChange(PropertyChangeEvent evt) {
|
||||||
m_Support.firePropertyChange("", null, null);
|
m_Support.firePropertyChange("", null, null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
m_ScrollPane = new JScrollPane(m_StatPanel);
|
m_ScrollPane = new JScrollPane(m_StatPanel);
|
||||||
m_Panel = new JPanel();
|
m_Panel = new JPanel();
|
||||||
m_Panel.setLayout(new BorderLayout());
|
m_Panel.setLayout(new BorderLayout());
|
||||||
|
|
||||||
m_Panel.add(m_ScrollPane, BorderLayout.CENTER);
|
m_Panel.add(m_ScrollPane, BorderLayout.CENTER);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setValue(Object value) {
|
public void setValue(Object value) {
|
||||||
if (value instanceof GenericStatistics) {
|
if (value instanceof GenericStatistics) {
|
||||||
m_Value = (GenericStatistics) value;
|
m_Value = (GenericStatistics) value;
|
||||||
m_StatPanel.setTarget(m_Value.getPropertyNames(), m_Value.getState());
|
m_StatPanel.setTarget(m_Value.getPropertyNames(), m_Value.getState());
|
||||||
|
}
|
||||||
|
m_Support.firePropertyChange("", null, null);
|
||||||
}
|
}
|
||||||
m_Support.firePropertyChange("", null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Object getValue() {
|
public Object getValue() {
|
||||||
System.out.println("getValue !!!!!!!!!!!!");
|
System.out.println("getValue !!!!!!!!!!!!");
|
||||||
m_Value.setState(m_StatPanel.getState());
|
m_Value.setState(m_StatPanel.getState());
|
||||||
return m_Value;
|
return m_Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getJavaInitializationString() {
|
public String getJavaInitializationString() {
|
||||||
return "null";
|
return "null";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isPaintable() {
|
public boolean isPaintable() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void paintValue(Graphics gfx, Rectangle box) {
|
public void paintValue(Graphics gfx, Rectangle box) {
|
||||||
FontMetrics fm = gfx.getFontMetrics();
|
FontMetrics fm = gfx.getFontMetrics();
|
||||||
int vpad = (box.height - fm.getAscent()) / 2;
|
int vpad = (box.height - fm.getAscent()) / 2;
|
||||||
//String rep = EVAHELP.cutClassName(m_ElementClass.getName());
|
//String rep = EVAHELP.cutClassName(m_ElementClass.getName());
|
||||||
gfx.drawString("StatisticeEditor", 2, fm.getHeight() + vpad - 3);
|
gfx.drawString("StatisticeEditor", 2, fm.getHeight() + vpad - 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getAsText() {
|
public String getAsText() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setAsText(String text) throws IllegalArgumentException {
|
public void setAsText(String text) throws IllegalArgumentException {
|
||||||
throw new IllegalArgumentException(text);
|
throw new IllegalArgumentException(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String[] getTags() {
|
public String[] getTags() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsCustomEditor() {
|
public boolean supportsCustomEditor() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Component getCustomEditor() {
|
public Component getCustomEditor() {
|
||||||
return m_Panel;
|
return m_Panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||||
if (m_Support == null) {
|
if (m_Support == null) {
|
||||||
m_Support = new PropertyChangeSupport(this);
|
m_Support = new PropertyChangeSupport(this);
|
||||||
}
|
}
|
||||||
m_Support.addPropertyChangeListener(l);
|
m_Support.addPropertyChangeListener(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||||
if (m_Support == null) {
|
if (m_Support == null) {
|
||||||
m_Support = new PropertyChangeSupport(this);
|
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;
|
import eva2.tools.StringSelection;
|
||||||
|
|
||||||
public class StringSelectionEditor extends AbstractListSelectionEditor {
|
public class StringSelectionEditor extends AbstractListSelectionEditor {
|
||||||
StringSelection strs;
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public StringSelectionEditor() {
|
||||||
protected int getElementCount() {
|
strs = new StringSelection(new String[]{}, null);
|
||||||
return strs.getLength();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getElementName(int i) {
|
protected boolean actionOnSelect() {
|
||||||
return strs.getElement(i);
|
for (int i = 0; i < this.m_BlackCheck.length; i++) {
|
||||||
}
|
strs.setSelected(i, this.m_BlackCheck[i].isSelected());
|
||||||
|
}
|
||||||
@Override
|
return true;
|
||||||
protected String getElementToolTip(int i) {
|
}
|
||||||
return strs.getElementInfo(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getValue() {
|
protected int getElementCount() {
|
||||||
return strs;
|
return strs.getLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isElementSelected(int i) {
|
protected String getElementName(int i) {
|
||||||
return strs.isSelected(i);
|
return strs.getElement(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean setObject(Object o) {
|
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) {
|
if (o instanceof StringSelection) {
|
||||||
strs = (StringSelection) o;
|
strs = (StringSelection) o;
|
||||||
// m_AreaObject.addPropertyChangeListener(this);
|
// m_AreaObject.addPropertyChangeListener(this);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} 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
|
@Override
|
||||||
public String getName() {
|
public void setAsText(String text) throws IllegalArgumentException {
|
||||||
return "StringSelection";
|
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.BasicResourceLoader;
|
||||||
import eva2.tools.SelectedTag;
|
import eva2.tools.SelectedTag;
|
||||||
import eva2.tools.Tag;
|
import eva2.tools.Tag;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
import java.awt.event.WindowAdapter;
|
import java.awt.event.WindowAdapter;
|
||||||
@@ -22,123 +23,125 @@ import java.awt.event.WindowEvent;
|
|||||||
import java.beans.PropertyEditorManager;
|
import java.beans.PropertyEditorManager;
|
||||||
import java.beans.PropertyEditorSupport;
|
import java.beans.PropertyEditorSupport;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class TagEditor extends PropertyEditorSupport {
|
public class TagEditor extends PropertyEditorSupport {
|
||||||
/**
|
/**
|
||||||
* Returns a description of the property value as java source.
|
* Returns a description of the property value as java source.
|
||||||
*
|
*
|
||||||
* @return a value of type 'String'
|
* @return a value of type 'String'
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getJavaInitializationString() {
|
public String getJavaInitializationString() {
|
||||||
|
|
||||||
SelectedTag s = (SelectedTag)getValue();
|
SelectedTag s = (SelectedTag) getValue();
|
||||||
Tag [] tags = s.getTags();
|
Tag[] tags = s.getTags();
|
||||||
String result = "new SelectedTag("
|
String result = "new SelectedTag("
|
||||||
+ s.getSelectedTag().getID()
|
+ s.getSelectedTag().getID()
|
||||||
+ ", {\n";
|
+ ", {\n";
|
||||||
for (int i = 0; i < tags.length; i++) {
|
for (int i = 0; i < tags.length; i++) {
|
||||||
result += "new Tag(" + tags[i].getID()
|
result += "new Tag(" + tags[i].getID()
|
||||||
+ ",\"" + tags[i].getString()
|
+ ",\"" + tags[i].getString()
|
||||||
+ "\")";
|
+ "\")";
|
||||||
if (i < tags.length - 1) {
|
if (i < tags.length - 1) {
|
||||||
result += ',';
|
result += ',';
|
||||||
}
|
}
|
||||||
result += '\n';
|
result += '\n';
|
||||||
|
}
|
||||||
|
return result + "})";
|
||||||
}
|
}
|
||||||
return result + "})";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the current value as text.
|
* Gets the current value as text.
|
||||||
*
|
*
|
||||||
* @return a value of type 'String'
|
* @return a value of type 'String'
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getAsText() {
|
public String getAsText() {
|
||||||
SelectedTag s = (SelectedTag)getValue();
|
SelectedTag s = (SelectedTag) getValue();
|
||||||
return s.getSelectedTag().getString();
|
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);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the list of tags that can be selected from.
|
* Sets the current property value as text.
|
||||||
*
|
*
|
||||||
* @return an array of string tags.
|
* @param text the text of the selected tag.
|
||||||
*/
|
* @throws java.lang.IllegalArgumentException
|
||||||
|
* if an error occurs
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String[] getTags() {
|
public void setAsText(String text) throws java.lang.IllegalArgumentException {
|
||||||
|
SelectedTag s = (SelectedTag) getValue();
|
||||||
SelectedTag s = (SelectedTag)getValue();
|
Tag[] tags = s.getTags();
|
||||||
Tag [] tags = s.getTags();
|
try {
|
||||||
String [] result = new String [tags.length];
|
for (int i = 0; i < tags.length; i++) {
|
||||||
for (int i = 0; i < tags.length; i++) {
|
if (text.equals(tags[i].getString())) {
|
||||||
result[i] = 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.
|
* Gets the list of tags that can be selected from.
|
||||||
*
|
*
|
||||||
* @param args ignored
|
* @return an array of string tags.
|
||||||
*/
|
*/
|
||||||
public static void main(String [] args) {
|
@Override
|
||||||
try {
|
public String[] getTags() {
|
||||||
PropertyEditorManager.registerEditor(SelectedTag.class,TagEditor.class);
|
|
||||||
Tag [] tags = {
|
SelectedTag s = (SelectedTag) getValue();
|
||||||
new Tag(0, "First option"),
|
Tag[] tags = s.getTags();
|
||||||
new Tag(1, "Second option"),
|
String[] result = new String[tags.length];
|
||||||
new Tag(2, "Third option"),
|
for (int i = 0; i < tags.length; i++) {
|
||||||
new Tag(3, "Fourth option"),
|
result[i] = tags[i].getString
|
||||||
new Tag(4, "Fifth option"),
|
();
|
||||||
};
|
}
|
||||||
SelectedTag initial = new SelectedTag(1, tags);
|
return result;
|
||||||
TagEditor ce = new TagEditor();
|
}
|
||||||
ce.setValue(initial);
|
|
||||||
PropertyValueSelector ps = new PropertyValueSelector(ce);
|
/**
|
||||||
JFrame f = new JFrame();
|
* Tests out the selectedtag editor from the command line.
|
||||||
BasicResourceLoader loader = BasicResourceLoader.instance();
|
*
|
||||||
byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation, true);
|
* @param args ignored
|
||||||
f.setIconImage(Toolkit.getDefaultToolkit().createImage(bytes));
|
*/
|
||||||
f.addWindowListener(new WindowAdapter() {
|
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
|
@Override
|
||||||
public void windowClosing(WindowEvent e) {
|
public void windowClosing(WindowEvent e) {
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
f.getContentPane().setLayout(new BorderLayout());
|
f.getContentPane().setLayout(new BorderLayout());
|
||||||
f.getContentPane().add(ps, BorderLayout.CENTER);
|
f.getContentPane().add(ps, BorderLayout.CENTER);
|
||||||
f.pack();
|
f.pack();
|
||||||
f.setVisible(true);
|
f.setVisible(true);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
System.err.println(ex.getMessage());
|
System.err.println(ex.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package eva2.gui.plot;
|
package eva2.gui.plot;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import eva2.tools.chart2d.DArray;
|
import eva2.tools.chart2d.DArray;
|
||||||
import eva2.tools.chart2d.DBorder;
|
import eva2.tools.chart2d.DBorder;
|
||||||
import eva2.tools.chart2d.DComponent;
|
import eva2.tools.chart2d.DComponent;
|
||||||
@@ -11,6 +10,7 @@ import eva2.tools.chart2d.DPoint;
|
|||||||
import eva2.tools.chart2d.DPointIcon;
|
import eva2.tools.chart2d.DPointIcon;
|
||||||
import eva2.tools.chart2d.DPointSet;
|
import eva2.tools.chart2d.DPointSet;
|
||||||
import eva2.tools.chart2d.DRectangle;
|
import eva2.tools.chart2d.DRectangle;
|
||||||
|
|
||||||
import java.awt.BasicStroke;
|
import java.awt.BasicStroke;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
@@ -25,74 +25,61 @@ import java.util.ArrayList;
|
|||||||
* Time: 16:17:35
|
* Time: 16:17:35
|
||||||
* To change this template use File | Settings | File Templates.
|
* To change this template use File | Settings | File Templates.
|
||||||
*/
|
*/
|
||||||
public class DPointSetMultiIcon extends DComponent
|
public class DPointSetMultiIcon extends DComponent {
|
||||||
{
|
|
||||||
//~ Instance fields ////////////////////////////////////////////////////////
|
//~ Instance fields ////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this class stores the jump positions (see this.jump)
|
* this class stores the jump positions (see this.jump)
|
||||||
*/
|
*/
|
||||||
class JumpManager
|
class JumpManager {
|
||||||
{
|
|
||||||
protected int index = -1;
|
protected int index = -1;
|
||||||
protected ArrayList<Integer> jumps = new ArrayList<Integer>();
|
protected ArrayList<Integer> jumps = new ArrayList<Integer>();
|
||||||
|
|
||||||
public void addJump()
|
public void addJump() {
|
||||||
{
|
|
||||||
jumps.add(getSize());
|
jumps.add(getSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasMoreIntervals()
|
public boolean hasMoreIntervals() {
|
||||||
{
|
|
||||||
return index < jumps.size();
|
return index < jumps.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int[] nextInterval()
|
public int[] nextInterval() {
|
||||||
{
|
|
||||||
int no_jumps = jumps.size();
|
int no_jumps = jumps.size();
|
||||||
|
|
||||||
if (index >= no_jumps)
|
if (index >= no_jumps) {
|
||||||
{
|
|
||||||
throw new ArrayIndexOutOfBoundsException(
|
throw new ArrayIndexOutOfBoundsException(
|
||||||
"No more intervals in JumpManager");
|
"No more intervals in JumpManager");
|
||||||
}
|
}
|
||||||
|
|
||||||
int[] inter = new int[2];
|
int[] inter = new int[2];
|
||||||
|
|
||||||
if (index == -1)
|
if (index == -1) {
|
||||||
{
|
|
||||||
inter[0] = 0;
|
inter[0] = 0;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
inter[0] = jumps.get(index);
|
inter[0] = jumps.get(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
if (index < no_jumps)
|
if (index < no_jumps) {
|
||||||
{
|
|
||||||
inter[1] = jumps.get(index);
|
inter[1] = jumps.get(index);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
inter[1] = getSize();
|
inter[1] = getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
return inter;
|
return inter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset()
|
public void reset() {
|
||||||
{
|
|
||||||
index = -1;
|
index = -1;
|
||||||
jumps.clear();
|
jumps.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void restore()
|
public void restore() {
|
||||||
{
|
|
||||||
index = -1;
|
index = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean connectedMI;
|
protected boolean connectedMI;
|
||||||
protected DPointIcon iconMI = null;
|
protected DPointIcon iconMI = null;
|
||||||
protected DPointSetMultiIcon.JumpManager jumperMI = new DPointSetMultiIcon.JumpManager();
|
protected DPointSetMultiIcon.JumpManager jumperMI = new DPointSetMultiIcon.JumpManager();
|
||||||
@@ -104,17 +91,14 @@ public class DPointSetMultiIcon extends DComponent
|
|||||||
|
|
||||||
protected DIntDoubleMap yMI;
|
protected DIntDoubleMap yMI;
|
||||||
|
|
||||||
public DPointSetMultiIcon()
|
public DPointSetMultiIcon() {
|
||||||
{
|
|
||||||
this(10, 2);
|
this(10, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DPointSetMultiIcon(DIntDoubleMap x_values, DIntDoubleMap y_values)
|
public DPointSetMultiIcon(DIntDoubleMap x_values, DIntDoubleMap y_values) {
|
||||||
{
|
if (x_values.getSize() != y_values.getSize()) {
|
||||||
if (x_values.getSize() != y_values.getSize())
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"The number of x-values has to be the same than the number of y-values");
|
"The number of x-values has to be the same than the number of y-values");
|
||||||
}
|
}
|
||||||
|
|
||||||
xMI = x_values;
|
xMI = x_values;
|
||||||
@@ -123,26 +107,22 @@ public class DPointSetMultiIcon extends DComponent
|
|||||||
setDBorder(new DBorder(1, 1, 1, 1));
|
setDBorder(new DBorder(1, 1, 1, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public DPointSetMultiIcon(int initial_capacity)
|
public DPointSetMultiIcon(int initial_capacity) {
|
||||||
{
|
|
||||||
this(initial_capacity, 2);
|
this(initial_capacity, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
//~ Methods ////////////////////////////////////////////////////////////////
|
//~ Methods ////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
public DPointSetMultiIcon(int initial_capacity, int length_multiplier)
|
public DPointSetMultiIcon(int initial_capacity, int length_multiplier) {
|
||||||
{
|
|
||||||
this(new DArray(initial_capacity, length_multiplier),
|
this(new DArray(initial_capacity, length_multiplier),
|
||||||
new DArray(initial_capacity, length_multiplier));
|
new DArray(initial_capacity, length_multiplier));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addDPoint(double x, double y)
|
public void addDPoint(double x, double y) {
|
||||||
{
|
|
||||||
addDPoint(new DPoint(x, y));
|
addDPoint(new DPoint(x, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addDPoint(DPoint p)
|
public void addDPoint(DPoint p) {
|
||||||
{
|
|
||||||
xMI.addImage(p.x);
|
xMI.addImage(p.x);
|
||||||
yMI.addImage(p.y);
|
yMI.addImage(p.y);
|
||||||
m_IconsMI.add(p.getIcon());
|
m_IconsMI.add(p.getIcon());
|
||||||
@@ -156,10 +136,8 @@ public class DPointSetMultiIcon extends DComponent
|
|||||||
* @param index the index of the DPoint
|
* @param index the index of the DPoint
|
||||||
* @return the DPoint at the given index
|
* @return the DPoint at the given index
|
||||||
*/
|
*/
|
||||||
public DPoint getDPoint(int index)
|
public DPoint getDPoint(int index) {
|
||||||
{
|
if (index >= xMI.getSize()) {
|
||||||
if (index >= xMI.getSize())
|
|
||||||
{
|
|
||||||
throw new ArrayIndexOutOfBoundsException(index);
|
throw new ArrayIndexOutOfBoundsException(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,8 +148,7 @@ public class DPointSetMultiIcon extends DComponent
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DPointSet getDPointSet()
|
public DPointSet getDPointSet() {
|
||||||
{
|
|
||||||
return new DPointSet(xMI, yMI);
|
return new DPointSet(xMI, yMI);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,8 +157,7 @@ public class DPointSetMultiIcon extends DComponent
|
|||||||
*
|
*
|
||||||
* @return the DPointIcon
|
* @return the DPointIcon
|
||||||
*/
|
*/
|
||||||
public DPointIcon getIcon()
|
public DPointIcon getIcon() {
|
||||||
{
|
|
||||||
return iconMI;
|
return iconMI;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,16 +170,12 @@ public class DPointSetMultiIcon extends DComponent
|
|||||||
*
|
*
|
||||||
* @return the nearest <code>DPoint</code>
|
* @return the nearest <code>DPoint</code>
|
||||||
*/
|
*/
|
||||||
public DPoint getNearestDPoint(DPoint point)
|
public DPoint getNearestDPoint(DPoint point) {
|
||||||
{
|
|
||||||
int minIndex = getNearestDPointIndex(point);
|
int minIndex = getNearestDPointIndex(point);
|
||||||
|
|
||||||
if (minIndex == -1)
|
if (minIndex == -1) {
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
DPoint result = new DPoint(xMI.getImage(minIndex),
|
DPoint result = new DPoint(xMI.getImage(minIndex),
|
||||||
yMI.getImage(minIndex));
|
yMI.getImage(minIndex));
|
||||||
result.setIcon((DPointIcon) this.m_IconsMI.get(minIndex));
|
result.setIcon((DPointIcon) this.m_IconsMI.get(minIndex));
|
||||||
@@ -212,22 +184,21 @@ public class DPointSetMultiIcon extends DComponent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** method returns the index to the nearest <code>DPoint</code> in this <code>DPointSet</code>.
|
/**
|
||||||
|
* method returns the index to the nearest <code>DPoint</code> in this <code>DPointSet</code>.
|
||||||
|
*
|
||||||
* @return the index to the nearest <code>DPoint</code>. -1 if no nearest <code>DPoint</code> was found.
|
* @return the index to the nearest <code>DPoint</code>. -1 if no nearest <code>DPoint</code> was found.
|
||||||
*/
|
*/
|
||||||
public int getNearestDPointIndex(DPoint point)
|
public int getNearestDPointIndex(DPoint point) {
|
||||||
{
|
|
||||||
double minValue = Double.MAX_VALUE;
|
double minValue = Double.MAX_VALUE;
|
||||||
int minIndex = -1;
|
int minIndex = -1;
|
||||||
|
|
||||||
for (int i = 0; i < xMI.getSize(); i++)
|
for (int i = 0; i < xMI.getSize(); i++) {
|
||||||
{
|
|
||||||
double dx = point.x - xMI.getImage(i);
|
double dx = point.x - xMI.getImage(i);
|
||||||
double dy = point.y - yMI.getImage(i);
|
double dy = point.y - yMI.getImage(i);
|
||||||
double dummy = (dx * dx) + (dy * dy);
|
double dummy = (dx * dx) + (dy * dy);
|
||||||
|
|
||||||
if (dummy < minValue)
|
if (dummy < minValue) {
|
||||||
{
|
|
||||||
minValue = dummy;
|
minValue = dummy;
|
||||||
minIndex = i;
|
minIndex = i;
|
||||||
}
|
}
|
||||||
@@ -236,8 +207,7 @@ public class DPointSetMultiIcon extends DComponent
|
|||||||
return minIndex;
|
return minIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSize()
|
public int getSize() {
|
||||||
{
|
|
||||||
int size = Math.min(xMI.getSize(), yMI.getSize());
|
int size = Math.min(xMI.getSize(), yMI.getSize());
|
||||||
|
|
||||||
// int size = x.getSize();
|
// int size = x.getSize();
|
||||||
@@ -254,8 +224,7 @@ public class DPointSetMultiIcon extends DComponent
|
|||||||
*
|
*
|
||||||
* @return the stroke
|
* @return the stroke
|
||||||
*/
|
*/
|
||||||
public Stroke getStroke()
|
public Stroke getStroke() {
|
||||||
{
|
|
||||||
return strokeMI;
|
return strokeMI;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,58 +232,46 @@ public class DPointSetMultiIcon extends DComponent
|
|||||||
* This method causes the DPointSet to interupt the connected painting at the
|
* This method causes the DPointSet to interupt the connected painting at the
|
||||||
* current position.
|
* current position.
|
||||||
*/
|
*/
|
||||||
public void jump()
|
public void jump() {
|
||||||
{
|
|
||||||
jumperMI.addJump();
|
jumperMI.addJump();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paint(DMeasures m)
|
public void paint(DMeasures m) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
Graphics2D g = (Graphics2D) m.getGraphics();
|
Graphics2D g = (Graphics2D) m.getGraphics();
|
||||||
g.setStroke(strokeMI);
|
g.setStroke(strokeMI);
|
||||||
|
|
||||||
if (color != null)
|
if (color != null) {
|
||||||
{
|
|
||||||
g.setColor(color);
|
g.setColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
int size = getSize();
|
int size = getSize();
|
||||||
|
|
||||||
if (connectedMI && (size > 1))
|
if (connectedMI && (size > 1)) {
|
||||||
{
|
|
||||||
jumperMI.restore();
|
jumperMI.restore();
|
||||||
|
|
||||||
while (jumperMI.hasMoreIntervals())
|
while (jumperMI.hasMoreIntervals()) {
|
||||||
{
|
|
||||||
int[] interval = jumperMI.nextInterval();
|
int[] interval = jumperMI.nextInterval();
|
||||||
Point p1 = null;
|
Point p1 = null;
|
||||||
Point p2;
|
Point p2;
|
||||||
|
|
||||||
for (int i = interval[0]; i < interval[1]; i++)
|
for (int i = interval[0]; i < interval[1]; i++) {
|
||||||
{
|
|
||||||
p2 = m.getPoint(xMI.getImage(i), yMI.getImage(i));
|
p2 = m.getPoint(xMI.getImage(i), yMI.getImage(i));
|
||||||
if (p1 != null)
|
if (p1 != null) {
|
||||||
{
|
if (p2 != null) {
|
||||||
if (p2!=null) {
|
g.drawLine(p1.x, p1.y, p2.x, p2.y);
|
||||||
g.drawLine(p1.x, p1.y, p2.x, p2.y);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((i < this.m_IconsMI.size()) && (this.m_IconsMI.get(i) != null))
|
if ((i < this.m_IconsMI.size()) && (this.m_IconsMI.get(i) != null)) {
|
||||||
{
|
|
||||||
g.setStroke(new BasicStroke());
|
g.setStroke(new BasicStroke());
|
||||||
g.translate(p2.x, p2.y);
|
g.translate(p2.x, p2.y);
|
||||||
((DPointIcon) this.m_IconsMI.get(i)).paint(g);
|
((DPointIcon) this.m_IconsMI.get(i)).paint(g);
|
||||||
g.translate(-p2.x, -p2.y);
|
g.translate(-p2.x, -p2.y);
|
||||||
g.setStroke(strokeMI);
|
g.setStroke(strokeMI);
|
||||||
}
|
} else {
|
||||||
else
|
if (iconMI != null) {
|
||||||
{
|
|
||||||
if (iconMI != null)
|
|
||||||
{
|
|
||||||
g.setStroke(new BasicStroke());
|
g.setStroke(new BasicStroke());
|
||||||
g.translate(p2.x, p2.y);
|
g.translate(p2.x, p2.y);
|
||||||
iconMI.paint(g);
|
iconMI.paint(g);
|
||||||
@@ -326,66 +283,50 @@ public class DPointSetMultiIcon extends DComponent
|
|||||||
p1 = p2;
|
p1 = p2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
Point p;
|
Point p;
|
||||||
|
|
||||||
//for (int i = 0; i < size; i++)
|
//for (int i = 0; i < size; i++)
|
||||||
// @todo Streiche: Mal wieder eine index out of bounds exception, dass ist einfach mist...
|
// @todo Streiche: Mal wieder eine index out of bounds exception, dass ist einfach mist...
|
||||||
for (int i = 0; i < this.m_IconsMI.size(); i++)
|
for (int i = 0; i < this.m_IconsMI.size(); i++) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
p = m.getPoint(xMI.getImage(i), yMI.getImage(i));
|
p = m.getPoint(xMI.getImage(i), yMI.getImage(i));
|
||||||
|
|
||||||
if (p==null) {
|
if (p == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (this.m_IconsMI.get(i) != null)
|
if (this.m_IconsMI.get(i) != null) {
|
||||||
{
|
|
||||||
g.setStroke(new BasicStroke());
|
g.setStroke(new BasicStroke());
|
||||||
g.translate(p.x, p.y);
|
g.translate(p.x, p.y);
|
||||||
((DPointIcon) this.m_IconsMI.get(i)).paint(g);
|
((DPointIcon) this.m_IconsMI.get(i)).paint(g);
|
||||||
g.translate(-p.x, -p.y);
|
g.translate(-p.x, -p.y);
|
||||||
g.setStroke(strokeMI);
|
g.setStroke(strokeMI);
|
||||||
}
|
} else {
|
||||||
else
|
if (iconMI == null) {
|
||||||
{
|
|
||||||
if (iconMI == null)
|
|
||||||
{
|
|
||||||
g.drawLine(p.x - 1, p.y - 1, p.x + 1, p.y + 1);
|
g.drawLine(p.x - 1, p.y - 1, p.x + 1, p.y + 1);
|
||||||
g.drawLine(p.x + 1, p.y - 1, p.x - 1, p.y + 1);
|
g.drawLine(p.x + 1, p.y - 1, p.x - 1, p.y + 1);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
g.setStroke(new BasicStroke());
|
g.setStroke(new BasicStroke());
|
||||||
g.translate(p.x, p.y);
|
g.translate(p.x, p.y);
|
||||||
iconMI.paint(g);
|
iconMI.paint(g);
|
||||||
g.translate(-p.x, -p.y);
|
g.translate(-p.x, -p.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (java.lang.IllegalArgumentException e) {
|
||||||
catch (java.lang.IllegalArgumentException e)
|
|
||||||
{
|
|
||||||
System.out.println(
|
System.out.println(
|
||||||
"The rectangle lies not in the currently painted rectangle.");
|
"The rectangle lies not in the currently painted rectangle.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g.setStroke(new BasicStroke());
|
g.setStroke(new BasicStroke());
|
||||||
}
|
} catch (java.lang.ArrayIndexOutOfBoundsException e) {
|
||||||
catch (java.lang.ArrayIndexOutOfBoundsException e)
|
|
||||||
{
|
|
||||||
// *pff*
|
// *pff*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeAllPoints()
|
public void removeAllPoints() {
|
||||||
{
|
if (xMI.getSize() == 0) {
|
||||||
if (xMI.getSize() == 0)
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -401,15 +342,12 @@ public class DPointSetMultiIcon extends DComponent
|
|||||||
* if the DPointSet is connected, all points will be painted connected to
|
* if the DPointSet is connected, all points will be painted connected to
|
||||||
* their following point
|
* their following point
|
||||||
*/
|
*/
|
||||||
public void removeJumps()
|
public void removeJumps() {
|
||||||
{
|
|
||||||
jumperMI.reset();
|
jumperMI.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void restore()
|
protected void restore() {
|
||||||
{
|
if (getSize() == 0) {
|
||||||
if (getSize() == 0)
|
|
||||||
{
|
|
||||||
rectangle = DRectangle.getEmpty();
|
rectangle = DRectangle.getEmpty();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -422,13 +360,11 @@ public class DPointSetMultiIcon extends DComponent
|
|||||||
rectangle = new DRectangle(min_x, min_y, max_x - min_x, max_y - min_y);
|
rectangle = new DRectangle(min_x, min_y, max_x - min_x, max_y - min_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setConnected(boolean aFlag)
|
public void setConnected(boolean aFlag) {
|
||||||
{
|
|
||||||
boolean changed = !(aFlag == connectedMI);
|
boolean changed = !(aFlag == connectedMI);
|
||||||
connectedMI = aFlag;
|
connectedMI = aFlag;
|
||||||
|
|
||||||
if (changed)
|
if (changed) {
|
||||||
{
|
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -439,10 +375,8 @@ public class DPointSetMultiIcon extends DComponent
|
|||||||
* @param index the index of the point
|
* @param index the index of the point
|
||||||
* @param p the point to insert
|
* @param p the point to insert
|
||||||
*/
|
*/
|
||||||
public void setDPoint(int index, DPoint p)
|
public void setDPoint(int index, DPoint p) {
|
||||||
{
|
if (index >= xMI.getSize()) {
|
||||||
if (index >= xMI.getSize())
|
|
||||||
{
|
|
||||||
throw new ArrayIndexOutOfBoundsException(index);
|
throw new ArrayIndexOutOfBoundsException(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -459,30 +393,24 @@ public class DPointSetMultiIcon extends DComponent
|
|||||||
*
|
*
|
||||||
* @param icon the DPointIcon
|
* @param icon the DPointIcon
|
||||||
*/
|
*/
|
||||||
public void setIcon(DPointIcon icon)
|
public void setIcon(DPointIcon icon) {
|
||||||
{
|
|
||||||
this.iconMI = icon;
|
this.iconMI = icon;
|
||||||
|
|
||||||
if (icon == null)
|
if (icon == null) {
|
||||||
{
|
|
||||||
setDBorder(new DBorder(1, 1, 1, 1));
|
setDBorder(new DBorder(1, 1, 1, 1));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
setDBorder(icon.getDBorder());
|
setDBorder(icon.getDBorder());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* method sets the stroke of the line
|
* method sets the stroke of the line
|
||||||
* if the points were not connected, they now will be connected
|
* if the points were not connected, they now will be connected
|
||||||
*
|
*
|
||||||
* @param s the new stroke
|
* @param s the new stroke
|
||||||
*/
|
*/
|
||||||
public void setStroke(Stroke s)
|
public void setStroke(Stroke s) {
|
||||||
{
|
if (s == null) {
|
||||||
if (s == null)
|
|
||||||
{
|
|
||||||
s = new BasicStroke();
|
s = new BasicStroke();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -493,12 +421,10 @@ public class DPointSetMultiIcon extends DComponent
|
|||||||
//~ Inner Classes //////////////////////////////////////////////////////////
|
//~ Inner Classes //////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
|
||||||
String text = "eva2.tools.chart2d.DPointSet[size:" + getSize();
|
String text = "eva2.tools.chart2d.DPointSet[size:" + getSize();
|
||||||
|
|
||||||
for (int i = 0; i < xMI.getSize(); i++)
|
for (int i = 0; i < xMI.getSize(); i++) {
|
||||||
{
|
|
||||||
text += (",(" + xMI.getImage(i) + "," + yMI.getImage(i) + ")");
|
text += (",(" + xMI.getImage(i) + "," + yMI.getImage(i) + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class DataViewer implements DataViewerInterface {
|
|||||||
}
|
}
|
||||||
DataViewerInterface ret = null;
|
DataViewerInterface ret = null;
|
||||||
try {
|
try {
|
||||||
if (!viewContainer.containsName(graphWindowName)) {
|
if (!viewContainer.containsName(graphWindowName)) {
|
||||||
ret = new DataViewer(graphWindowName, true);
|
ret = new DataViewer(graphWindowName, true);
|
||||||
viewContainer.add(ret);
|
viewContainer.add(ret);
|
||||||
} else {
|
} else {
|
||||||
@@ -89,7 +89,8 @@ class ViewContainer extends ArrayList {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public ViewContainer() { }
|
public ViewContainer() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import eva2.gui.plot.Graph;
|
|||||||
* IMPORTS
|
* IMPORTS
|
||||||
*==========================================================================*/
|
*==========================================================================*/
|
||||||
public interface DataViewerInterface {
|
public interface DataViewerInterface {
|
||||||
public Graph getNewGraph(String InfoString);
|
public Graph getNewGraph(String InfoString);
|
||||||
public void init();
|
|
||||||
|
public void init();
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,7 @@ package eva2.gui.plot;
|
|||||||
* IMPORTS
|
* IMPORTS
|
||||||
*==========================================================================
|
*==========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import eva2.gui.*;
|
import eva2.gui.*;
|
||||||
import eva2.optimization.individuals.AbstractEAIndividual;
|
import eva2.optimization.individuals.AbstractEAIndividual;
|
||||||
import eva2.optimization.mocco.paretofrontviewer.InterfaceRefPointListener;
|
import eva2.optimization.mocco.paretofrontviewer.InterfaceRefPointListener;
|
||||||
@@ -27,6 +28,7 @@ import eva2.tools.chart2d.DPoint;
|
|||||||
import eva2.tools.chart2d.DPointIcon;
|
import eva2.tools.chart2d.DPointIcon;
|
||||||
import eva2.tools.chart2d.DPointSet;
|
import eva2.tools.chart2d.DPointSet;
|
||||||
import eva2.tools.chart2d.ScaledBorder;
|
import eva2.tools.chart2d.ScaledBorder;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
@@ -205,11 +207,11 @@ public class FunctionArea extends DArea implements Serializable {
|
|||||||
+ " graph tool tips";
|
+ " graph tool tips";
|
||||||
addMenuItem(graphPopupMenu, togGTTName,
|
addMenuItem(graphPopupMenu, togGTTName,
|
||||||
new ActionListener() {
|
new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent ee) {
|
public void actionPerformed(ActionEvent ee) {
|
||||||
setShowGraphToolTips(!isShowGraphToolTips());
|
setShowGraphToolTips(!isShowGraphToolTips());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
String togLName = (isShowLegend() ? "Hide" : "Show")
|
String togLName = (isShowLegend() ? "Hide" : "Show")
|
||||||
+ " legend";
|
+ " legend";
|
||||||
@@ -230,11 +232,11 @@ public class FunctionArea extends DArea implements Serializable {
|
|||||||
if (FunctionArea.this.pointSetContainer.size() > 0) {
|
if (FunctionArea.this.pointSetContainer.size() > 0) {
|
||||||
addMenuItem(graphPopupMenu, "Recolor all graphs",
|
addMenuItem(graphPopupMenu, "Recolor all graphs",
|
||||||
new ActionListener() {
|
new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent ee) {
|
public void actionPerformed(ActionEvent ee) {
|
||||||
recolorAllGraphsByIndex();
|
recolorAllGraphsByIndex();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (refPointListener != null) {
|
if (refPointListener != null) {
|
||||||
@@ -242,16 +244,16 @@ public class FunctionArea extends DArea implements Serializable {
|
|||||||
addMenuItem(graphPopupMenu, "Select Reference Point:("
|
addMenuItem(graphPopupMenu, "Select Reference Point:("
|
||||||
+ temp.x + "/" + temp.y + ")",
|
+ temp.x + "/" + temp.y + ")",
|
||||||
new ActionListener() {
|
new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent ee) {
|
public void actionPerformed(ActionEvent ee) {
|
||||||
DPoint temp = getDMeasures().getDPoint(
|
DPoint temp = getDMeasures().getDPoint(
|
||||||
xPos, yPos);
|
xPos, yPos);
|
||||||
double[] point = new double[2];
|
double[] point = new double[2];
|
||||||
point[0] = temp.x;
|
point[0] = temp.x;
|
||||||
point[1] = temp.y;
|
point[1] = temp.y;
|
||||||
refPointListener.refPointGiven(point);
|
refPointListener.refPointGiven(point);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// darn this point is an empty copy !!
|
// darn this point is an empty copy !!
|
||||||
@@ -261,19 +263,19 @@ public class FunctionArea extends DArea implements Serializable {
|
|||||||
addMenuItem(graphPopupMenu, "Nearest point: ("
|
addMenuItem(graphPopupMenu, "Nearest point: ("
|
||||||
+ point.x + "/" + point.y + ")",
|
+ point.x + "/" + point.y + ")",
|
||||||
new ActionListener() {
|
new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent ee) {
|
public void actionPerformed(ActionEvent ee) {
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
addMenuItem(graphPopupMenu, " Remove point",
|
addMenuItem(graphPopupMenu, " Remove point",
|
||||||
new ActionListener() {
|
new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent ee) {
|
public void actionPerformed(ActionEvent ee) {
|
||||||
removePoint(FunctionArea.this.xPos,
|
removePoint(FunctionArea.this.xPos,
|
||||||
FunctionArea.this.yPos);
|
FunctionArea.this.yPos);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (point.getIcon() instanceof InterfaceSelectablePointIcon) {
|
if (point.getIcon() instanceof InterfaceSelectablePointIcon) {
|
||||||
currentPointIcon = point.getIcon();
|
currentPointIcon = point.getIcon();
|
||||||
@@ -283,13 +285,13 @@ public class FunctionArea extends DArea implements Serializable {
|
|||||||
: " Select individual";
|
: " Select individual";
|
||||||
addMenuItem(graphPopupMenu, selectTitle,
|
addMenuItem(graphPopupMenu, selectTitle,
|
||||||
new ActionListener() {
|
new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(
|
public void actionPerformed(
|
||||||
ActionEvent ee) {
|
ActionEvent ee) {
|
||||||
((InterfaceSelectablePointIcon) currentPointIcon).getSelectionListener().individualSelected(
|
((InterfaceSelectablePointIcon) currentPointIcon).getSelectionListener().individualSelected(
|
||||||
((InterfaceSelectablePointIcon) currentPointIcon).getEAIndividual());
|
((InterfaceSelectablePointIcon) currentPointIcon).getEAIndividual());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,16 +299,16 @@ public class FunctionArea extends DArea implements Serializable {
|
|||||||
currentPointIcon = point.getIcon();
|
currentPointIcon = point.getIcon();
|
||||||
addMenuItem(graphPopupMenu, " Show individual",
|
addMenuItem(graphPopupMenu, " Show individual",
|
||||||
new ActionListener() {
|
new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(
|
public void actionPerformed(
|
||||||
ActionEvent ee) {
|
ActionEvent ee) {
|
||||||
((InterfaceDPointWithContent) currentPointIcon).showIndividual();
|
((InterfaceDPointWithContent) currentPointIcon).showIndividual();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (FunctionArea.this.pointSetContainer.size() > 0) {
|
if (FunctionArea.this.pointSetContainer.size() > 0) {
|
||||||
// there is at least one graph
|
// there is at least one graph
|
||||||
// The graph info element
|
// The graph info element
|
||||||
// int gIndex = getNearestGraphIndex(e.getX(),
|
// int gIndex = getNearestGraphIndex(e.getX(),
|
||||||
@@ -314,45 +316,45 @@ public class FunctionArea extends DArea implements Serializable {
|
|||||||
addMenuItem(graphPopupMenu, "Graph Info: "
|
addMenuItem(graphPopupMenu, "Graph Info: "
|
||||||
+ getGraphInfo(e.getX(), e.getY()),
|
+ getGraphInfo(e.getX(), e.getY()),
|
||||||
new ActionListener() {
|
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
|
@Override
|
||||||
public DBorder getDBorder() {
|
public void actionPerformed(ActionEvent ee) {
|
||||||
return new DBorder(4, 4, 4, 4);
|
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
|
@Override
|
||||||
public void paint(Graphics g) {
|
public void paint(Graphics g) {
|
||||||
g.drawLine(-2, 0, 2, 0);
|
g.drawLine(-2, 0, 2, 0);
|
||||||
g.drawLine(0, 0, 0, 4);
|
g.drawLine(0, 0, 0, 4);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
temp.setIcon(icon1);
|
||||||
|
FunctionArea.this.addDElement(temp);
|
||||||
}
|
}
|
||||||
};
|
}, false);
|
||||||
temp.setIcon(icon1);
|
|
||||||
FunctionArea.this.addDElement(temp);
|
|
||||||
}
|
|
||||||
}, false);
|
|
||||||
|
|
||||||
addMenuItem(graphPopupMenu, " Remove graph",
|
addMenuItem(graphPopupMenu, " Remove graph",
|
||||||
new ActionListener() {
|
new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent ee) {
|
public void actionPerformed(ActionEvent ee) {
|
||||||
clearGraph(FunctionArea.this.xPos,
|
clearGraph(FunctionArea.this.xPos,
|
||||||
FunctionArea.this.yPos);
|
FunctionArea.this.yPos);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
addMenuItem(graphPopupMenu, " Change graph color",
|
addMenuItem(graphPopupMenu, " Change graph color",
|
||||||
new ActionListener() {
|
new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent ee) {
|
public void actionPerformed(ActionEvent ee) {
|
||||||
changeColorGraph(FunctionArea.this.xPos,
|
changeColorGraph(FunctionArea.this.xPos,
|
||||||
FunctionArea.this.yPos);
|
FunctionArea.this.yPos);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
graphPopupMenu.show(FunctionArea.this, e.getX(), e.getY());
|
graphPopupMenu.show(FunctionArea.this, e.getX(), e.getY());
|
||||||
}
|
}
|
||||||
@@ -370,7 +372,7 @@ public class FunctionArea extends DArea implements Serializable {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private JMenuItem addMenuItem(JPopupMenu menu, String title,
|
private JMenuItem addMenuItem(JPopupMenu menu, String title,
|
||||||
ActionListener aListener) {
|
ActionListener aListener) {
|
||||||
return addMenuItem(menu, title, aListener, true);
|
return addMenuItem(menu, title, aListener, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -385,7 +387,7 @@ public class FunctionArea extends DArea implements Serializable {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private JMenuItem addMenuItem(JPopupMenu menu, String title,
|
private JMenuItem addMenuItem(JPopupMenu menu, String title,
|
||||||
ActionListener aListener, boolean enabled) {
|
ActionListener aListener, boolean enabled) {
|
||||||
JMenuItem item = new JMenuItem(title);
|
JMenuItem item = new JMenuItem(title);
|
||||||
// if (bgColor!=null) item.setForeground(bgColor);
|
// if (bgColor!=null) item.setForeground(bgColor);
|
||||||
item.addActionListener(aListener);
|
item.addActionListener(aListener);
|
||||||
@@ -431,7 +433,6 @@ public class FunctionArea extends DArea implements Serializable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Re-color all graphs which are nonempty by their index.
|
* Re-color all graphs which are nonempty by their index.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public void recolorAllGraphsByIndex() {
|
public void recolorAllGraphsByIndex() {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
@@ -446,7 +447,6 @@ public class FunctionArea extends DArea implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean checkLoggable() {
|
public boolean checkLoggable() {
|
||||||
@@ -602,7 +602,7 @@ public class FunctionArea extends DArea implements Serializable {
|
|||||||
* @param graphID
|
* @param graphID
|
||||||
*/
|
*/
|
||||||
public void drawIcon(DPointIcon theIcon, String label, double[] position,
|
public void drawIcon(DPointIcon theIcon, String label, double[] position,
|
||||||
int graphID) {
|
int graphID) {
|
||||||
DPointSet popRep;
|
DPointSet popRep;
|
||||||
popRep = new DPointSet();
|
popRep = new DPointSet();
|
||||||
popRep.addDPoint(new DPoint(position[0], position[1]));
|
popRep.addDPoint(new DPoint(position[0], position[1]));
|
||||||
@@ -623,7 +623,7 @@ public class FunctionArea extends DArea implements Serializable {
|
|||||||
* @param graphID
|
* @param graphID
|
||||||
*/
|
*/
|
||||||
public void drawIcon(int iconType, String label, double[] position,
|
public void drawIcon(int iconType, String label, double[] position,
|
||||||
int graphID) {
|
int graphID) {
|
||||||
DPointIcon theIcon;
|
DPointIcon theIcon;
|
||||||
switch (iconType) {
|
switch (iconType) {
|
||||||
case 0:
|
case 0:
|
||||||
@@ -656,7 +656,6 @@ public class FunctionArea extends DArea implements Serializable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Export contained data to standard output.
|
* Export contained data to standard output.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public void exportToAscii() {
|
public void exportToAscii() {
|
||||||
exportToAscii((File) null);
|
exportToAscii((File) null);
|
||||||
@@ -758,7 +757,6 @@ public class FunctionArea extends DArea implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param x
|
* @param x
|
||||||
* @param y
|
* @param y
|
||||||
* @return
|
* @return
|
||||||
@@ -798,7 +796,6 @@ public class FunctionArea extends DArea implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param GraphLabel
|
* @param GraphLabel
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -857,7 +854,6 @@ public class FunctionArea extends DArea implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param x
|
* @param x
|
||||||
* @param y
|
* @param y
|
||||||
* @return
|
* @return
|
||||||
@@ -941,7 +937,6 @@ public class FunctionArea extends DArea implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public DPointSet[] printPoints() {
|
public DPointSet[] printPoints() {
|
||||||
@@ -957,7 +952,6 @@ public class FunctionArea extends DArea implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param i
|
* @param i
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -971,7 +965,6 @@ public class FunctionArea extends DArea implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param x
|
* @param x
|
||||||
* @param y
|
* @param y
|
||||||
*/
|
*/
|
||||||
@@ -1004,7 +997,6 @@ public class FunctionArea extends DArea implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param p
|
* @param p
|
||||||
* @param graphLabel
|
* @param graphLabel
|
||||||
*/
|
*/
|
||||||
@@ -1013,7 +1005,6 @@ public class FunctionArea extends DArea implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param GraphLabel
|
* @param GraphLabel
|
||||||
* @param color
|
* @param color
|
||||||
*/
|
*/
|
||||||
@@ -1022,7 +1013,6 @@ public class FunctionArea extends DArea implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param GraphLabel
|
* @param GraphLabel
|
||||||
* @param colorindex
|
* @param colorindex
|
||||||
*/
|
*/
|
||||||
@@ -1031,7 +1021,6 @@ public class FunctionArea extends DArea implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param GraphLabel
|
* @param GraphLabel
|
||||||
* @param Info
|
* @param Info
|
||||||
* @param stroke
|
* @param stroke
|
||||||
@@ -1054,7 +1043,6 @@ public class FunctionArea extends DArea implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param x
|
* @param x
|
||||||
* @param y
|
* @param y
|
||||||
* @param GraphLabel
|
* @param GraphLabel
|
||||||
@@ -1073,7 +1061,6 @@ public class FunctionArea extends DArea implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param p
|
* @param p
|
||||||
* @param GraphLabel
|
* @param GraphLabel
|
||||||
*/
|
*/
|
||||||
@@ -1191,7 +1178,7 @@ public class FunctionArea extends DArea implements Serializable {
|
|||||||
* Allows setting whether or not to paint the y-axis in logarithmic scale.
|
* 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
|
* @param log if true logarithmic scale is used, linear scale in case of
|
||||||
* false.
|
* false.
|
||||||
*/
|
*/
|
||||||
public void toggleLog(boolean log) {
|
public void toggleLog(boolean log) {
|
||||||
if (log != log) {
|
if (log != log) {
|
||||||
@@ -1201,7 +1188,6 @@ public class FunctionArea extends DArea implements Serializable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Recreate the legend object with the current point sets.
|
* Recreate the legend object with the current point sets.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public void updateLegend() {
|
public void updateLegend() {
|
||||||
GraphPointSetLegend lb = new GraphPointSetLegend(pointSetContainer,
|
GraphPointSetLegend lb = new GraphPointSetLegend(pointSetContainer,
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ public class Graph implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param Info
|
* @param Info
|
||||||
* @param stroke
|
* @param stroke
|
||||||
*/
|
*/
|
||||||
@@ -84,7 +83,7 @@ public class Graph implements Serializable {
|
|||||||
* false if force was used and points possibly have been lost.
|
* 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
|
* @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
|
* @see PlotInterface.addGraph
|
||||||
*/
|
*/
|
||||||
public boolean addGraph(Graph x) {
|
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.Pair;
|
||||||
import eva2.tools.StringTools;
|
import eva2.tools.StringTools;
|
||||||
import eva2.tools.chart2d.SlimRect;
|
import eva2.tools.chart2d.SlimRect;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.FontMetrics;
|
import java.awt.FontMetrics;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
@@ -22,180 +23,172 @@ import javax.swing.JPanel;
|
|||||||
* A class representing the legend of a plot. It is created from a list of
|
* 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
|
* GraphPointSets as used in FunctionArea. Painting is done in FunctionArea. As
|
||||||
* an alternative, an own frame could be created.
|
* an alternative, an own frame could be created.
|
||||||
*
|
*
|
||||||
* @author mkron, draeger
|
* @author mkron, draeger
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class GraphPointSetLegend {
|
public class GraphPointSetLegend {
|
||||||
SortedSet<Pair<String, Color>> legendEntries;
|
SortedSet<Pair<String, Color>> legendEntries;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author draeger
|
||||||
* @author draeger
|
*/
|
||||||
*
|
private static class PairComp implements Comparator<Pair<String, Color>> {
|
||||||
*/
|
|
||||||
private static class PairComp implements Comparator<Pair<String, Color>> {
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
|
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int compare(Pair<String, Color> o1, Pair<String, Color> o2) {
|
public int compare(Pair<String, Color> o1, Pair<String, Color> o2) {
|
||||||
int comp = o1.car().compareTo(o2.car());
|
int comp = o1.car().compareTo(o2.car());
|
||||||
// Same text; let us see if the color is also identical.
|
// Same text; let us see if the color is also identical.
|
||||||
return comp == 0 ? comp = Integer.valueOf(o1.cdr().getRGB())
|
return comp == 0 ? comp = Integer.valueOf(o1.cdr().getRGB())
|
||||||
.compareTo(Integer.valueOf(o2.cdr().getRGB())) : comp;
|
.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.
|
* A constructor which may enumerate the point sets.
|
||||||
*
|
*
|
||||||
* @param pointSetContainer the set of point sets to be shown.
|
* @param pointSetContainer the set of point sets to be shown.
|
||||||
* @param appendIndex if true, the string entries are enumerated according to the index
|
* @param appendIndex if true, the string entries are enumerated according to the index
|
||||||
*/
|
*/
|
||||||
public GraphPointSetLegend(List<GraphPointSet> pointSetContainer, boolean appendIndex) {
|
public GraphPointSetLegend(List<GraphPointSet> pointSetContainer, boolean appendIndex) {
|
||||||
legendEntries = new TreeSet<Pair<String, Color>>(comparator);
|
legendEntries = new TreeSet<Pair<String, Color>>(comparator);
|
||||||
for (int i = 0; i < pointSetContainer.size(); i++) {
|
for (int i = 0; i < pointSetContainer.size(); i++) {
|
||||||
GraphPointSet pointset = pointSetContainer.get(i);
|
GraphPointSet pointset = pointSetContainer.get(i);
|
||||||
if (pointset.getPointSet().getSize()>0) {
|
if (pointset.getPointSet().getSize() > 0) {
|
||||||
String entryStr;
|
String entryStr;
|
||||||
if (appendIndex) {
|
if (appendIndex) {
|
||||||
entryStr = StringTools.expandPrefixZeros(i, pointSetContainer.size()-1) + ": " + pointset.getInfoString();
|
entryStr = StringTools.expandPrefixZeros(i, pointSetContainer.size() - 1) + ": " + pointset.getInfoString();
|
||||||
}
|
} else {
|
||||||
else {
|
entryStr = pointset.getInfoString();
|
||||||
entryStr = pointset.getInfoString();
|
}
|
||||||
}
|
legendEntries.add(new Pair<String, Color>(entryStr, pointset.getColor()));
|
||||||
legendEntries.add(new Pair<String, Color>(entryStr,pointset.getColor()));
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A constructor without enumeration.
|
* A constructor without enumeration.
|
||||||
*
|
*
|
||||||
* @param pointSetContainer the set of point sets to be shown.
|
* @param pointSetContainer the set of point sets to be shown.
|
||||||
*/
|
*/
|
||||||
public GraphPointSetLegend(List<GraphPointSet> pointSetContainer) {
|
public GraphPointSetLegend(List<GraphPointSet> pointSetContainer) {
|
||||||
this(pointSetContainer, false);
|
this(pointSetContainer, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the legend labels to a container.
|
* Add the legend labels to a container.
|
||||||
*
|
*
|
||||||
* @param comp
|
* @param comp
|
||||||
*/
|
*/
|
||||||
public void addToContainer(JComponent comp) {
|
public void addToContainer(JComponent comp) {
|
||||||
for (Pair<String, Color> legendEntry : legendEntries) {
|
for (Pair<String, Color> legendEntry : legendEntries) {
|
||||||
JLabel label = new JLabel(legendEntry.head);
|
JLabel label = new JLabel(legendEntry.head);
|
||||||
label.setForeground(legendEntry.tail);
|
label.setForeground(legendEntry.tail);
|
||||||
comp.add(label);
|
comp.add(label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @param bgCol
|
||||||
* @param bgCol
|
* @param pointSetContainer
|
||||||
* @param pointSetContainer
|
* @return
|
||||||
* @return
|
*/
|
||||||
*/
|
public static JPanel makeLegendPanel(Color bgCol,
|
||||||
public static JPanel makeLegendPanel(Color bgCol,
|
ArrayList<GraphPointSet> pointSetContainer) {
|
||||||
ArrayList<GraphPointSet> pointSetContainer) {
|
JPanel pan = new JPanel();
|
||||||
JPanel pan = new JPanel();
|
pan.setBackground(bgCol);
|
||||||
pan.setBackground(bgCol);
|
pan.setLayout(new BoxLayout(pan, BoxLayout.Y_AXIS));
|
||||||
pan.setLayout(new BoxLayout(pan, BoxLayout.Y_AXIS));
|
GraphPointSetLegend lBox = new GraphPointSetLegend(pointSetContainer);
|
||||||
GraphPointSetLegend lBox = new GraphPointSetLegend(pointSetContainer);
|
lBox.addToContainer(pan);
|
||||||
lBox.addToContainer(pan);
|
return pan;
|
||||||
return pan;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @param bgCol
|
||||||
* @param bgCol
|
* @param pointSetContainer
|
||||||
* @param pointSetContainer
|
* @return
|
||||||
* @return
|
*/
|
||||||
*/
|
public static JFrame makeLegendFrame(Color bgCol,
|
||||||
public static JFrame makeLegendFrame(Color bgCol,
|
ArrayList<GraphPointSet> pointSetContainer) {
|
||||||
ArrayList<GraphPointSet> pointSetContainer) {
|
JFrame frame = new JFrame("Legend");
|
||||||
JFrame frame = new JFrame("Legend");
|
// LegendBox lBox = new LegendBox(bgCol, pointSetContainer);
|
||||||
// LegendBox lBox = new LegendBox(bgCol, pointSetContainer);
|
frame.add(makeLegendPanel(bgCol, pointSetContainer));
|
||||||
frame.add(makeLegendPanel(bgCol, pointSetContainer));
|
frame.pack();
|
||||||
frame.pack();
|
frame.setVisible(true);
|
||||||
frame.setVisible(true);
|
return frame;
|
||||||
return frame;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @param component
|
||||||
* @param component
|
*/
|
||||||
*/
|
public void paintIn(JComponent component) {
|
||||||
public void paintIn(JComponent component) {
|
Graphics g = component.getGraphics();
|
||||||
Graphics g = component.getGraphics();
|
FontMetrics fm = g.getFontMetrics();
|
||||||
FontMetrics fm = g.getFontMetrics();
|
int yOffs = 5 + fm.getHeight();
|
||||||
int yOffs = 5 + fm.getHeight();
|
int xOffs = 0;
|
||||||
int xOffs = 0;
|
Color origCol = g.getColor();
|
||||||
Color origCol = g.getColor();
|
|
||||||
|
|
||||||
for (Pair<String, Color> legendEntry : legendEntries) {
|
for (Pair<String, Color> legendEntry : legendEntries) {
|
||||||
g.setColor(legendEntry.tail);
|
g.setColor(legendEntry.tail);
|
||||||
Rectangle2D rect = fm.getStringBounds(legendEntry.head, g);
|
Rectangle2D rect = fm.getStringBounds(legendEntry.head, g);
|
||||||
xOffs = (int) (component.getWidth() - rect.getWidth() - 5);
|
xOffs = (int) (component.getWidth() - rect.getWidth() - 5);
|
||||||
g.drawString(legendEntry.head, xOffs, yOffs);
|
g.drawString(legendEntry.head, xOffs, yOffs);
|
||||||
yOffs += (5 + rect.getHeight());
|
yOffs += (5 + rect.getHeight());
|
||||||
}
|
}
|
||||||
g.setColor(origCol);
|
g.setColor(origCol);
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void paintIn(Graphics g, Dimension dim) {
|
// public void paintIn(Graphics g, Dimension dim) {
|
||||||
// paintIn(g, dim.width);
|
// paintIn(g, dim.width);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// public void paintIn(Graphics g, Rectangle rect) {
|
// public void paintIn(Graphics g, Rectangle rect) {
|
||||||
// paintIn(g, rect.width);
|
// paintIn(g, rect.width);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// public void paintIn(Graphics g, DRectangle rect) {
|
// public void paintIn(Graphics g, DRectangle rect) {
|
||||||
// paintIn(g, (int)rect.width);
|
// paintIn(g, (int)rect.width);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void paintIn(Graphics g, SlimRect rect) {
|
public void paintIn(Graphics g, SlimRect rect) {
|
||||||
paintIn(g, (int) rect.getX(), (int) rect.getY(), (int) rect.getX()
|
paintIn(g, (int) rect.getX(), (int) rect.getY(), (int) rect.getX()
|
||||||
+ (int) rect.getWidth());
|
+ (int) rect.getWidth());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @param g
|
||||||
* @param g
|
* @param x
|
||||||
* @param x
|
* @param y
|
||||||
* @param y
|
* @param maxX
|
||||||
* @param maxX
|
*/
|
||||||
*/
|
private void paintIn(Graphics g, int x, int y, int maxX) {
|
||||||
private void paintIn(Graphics g, int x, int y, int maxX) {
|
FontMetrics fm = g.getFontMetrics();
|
||||||
FontMetrics fm = g.getFontMetrics();
|
// System.out.println("In LegendBox.paintIn!");
|
||||||
// System.out.println("In LegendBox.paintIn!");
|
int yOffs = 5 + y + fm.getHeight();
|
||||||
int yOffs = 5 + y + fm.getHeight();
|
int xOffs = x;
|
||||||
int xOffs = x;
|
Color origCol = g.getColor();
|
||||||
Color origCol = g.getColor();
|
// avoid that an entry with identical label and color occurs multiple
|
||||||
// avoid that an entry with identical label and color occurs multiple
|
// times.
|
||||||
// times.
|
for (Pair<String, Color> legendEntry : legendEntries) {
|
||||||
for (Pair<String, Color> legendEntry : legendEntries) {
|
// System.out.println(legendEntries[i].toString() + "\tcontaines: "
|
||||||
// System.out.println(legendEntries[i].toString() + "\tcontaines: "
|
// + set.contains(legendEntries[i]));
|
||||||
// + set.contains(legendEntries[i]));
|
g.setColor(legendEntry.tail);
|
||||||
g.setColor(legendEntry.tail);
|
Rectangle2D stringBounds = fm.getStringBounds(legendEntry.head, g);
|
||||||
Rectangle2D stringBounds = fm.getStringBounds(legendEntry.head, g);
|
xOffs = (int) (maxX - stringBounds.getWidth() - 5);
|
||||||
xOffs = (int) (maxX - stringBounds.getWidth() - 5);
|
g.drawString(legendEntry.head, xOffs, yOffs);
|
||||||
g.drawString(legendEntry.head, xOffs, yOffs);
|
// g.drawString(legendEntries[i].head, 80, 80);
|
||||||
// g.drawString(legendEntries[i].head, 80, 80);
|
yOffs += (5 + stringBounds.getHeight());
|
||||||
yOffs += (5 + stringBounds.getHeight());
|
}
|
||||||
}
|
g.setColor(origCol);
|
||||||
g.setColor(origCol);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class GraphWindow {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static GraphWindow getInstance(String graphWindowName,
|
public static GraphWindow getInstance(String graphWindowName,
|
||||||
String strx, String stry) {
|
String strx, String stry) {
|
||||||
if (plotContainer == null) {
|
if (plotContainer == null) {
|
||||||
plotContainer = new PlotContainer();
|
plotContainer = new PlotContainer();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,15 +12,20 @@ import eva2.optimization.problems.InterfaceOptimizationProblem;
|
|||||||
*/
|
*/
|
||||||
public interface InterfaceDPointWithContent {
|
public interface InterfaceDPointWithContent {
|
||||||
public void setEAIndividual(AbstractEAIndividual indy);
|
public void setEAIndividual(AbstractEAIndividual indy);
|
||||||
|
|
||||||
public AbstractEAIndividual getEAIndividual();
|
public AbstractEAIndividual getEAIndividual();
|
||||||
|
|
||||||
/** This method allows you to set the according optimization problem
|
/**
|
||||||
* @param problem InterfaceOptimizationProblem
|
* This method allows you to set the according optimization problem
|
||||||
|
*
|
||||||
|
* @param problem InterfaceOptimizationProblem
|
||||||
*/
|
*/
|
||||||
public void setProblem(InterfaceOptimizationProblem problem);
|
public void setProblem(InterfaceOptimizationProblem problem);
|
||||||
|
|
||||||
public InterfaceOptimizationProblem getProblem();
|
public InterfaceOptimizationProblem getProblem();
|
||||||
|
|
||||||
/** This method allows you to draw additional data of the individual
|
/**
|
||||||
|
* This method allows you to draw additional data of the individual
|
||||||
*/
|
*/
|
||||||
public void showIndividual();
|
public void showIndividual();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,12 +6,14 @@ package eva2.gui.plot;
|
|||||||
* Hannes Planatscher @version: $Revision: 322 $ $Date: 2007-12-11 17:24:07
|
* Hannes Planatscher @version: $Revision: 322 $ $Date: 2007-12-11 17:24:07
|
||||||
* +0100 (Tue, 11 Dec 2007) $ $Author: mkron $
|
* +0100 (Tue, 11 Dec 2007) $ $Author: mkron $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import eva2.EvAInfo;
|
import eva2.EvAInfo;
|
||||||
import eva2.gui.JEFrame;
|
import eva2.gui.JEFrame;
|
||||||
import eva2.optimization.individuals.AbstractEAIndividual;
|
import eva2.optimization.individuals.AbstractEAIndividual;
|
||||||
import eva2.optimization.population.Population;
|
import eva2.optimization.population.Population;
|
||||||
import eva2.tools.BasicResourceLoader;
|
import eva2.tools.BasicResourceLoader;
|
||||||
import eva2.tools.chart2d.DPointSet;
|
import eva2.tools.chart2d.DPointSet;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
@@ -260,7 +262,7 @@ public class Plot implements PlotInterface, Serializable {
|
|||||||
* Toggle whether the graphs should be annotated by tool tip info strings.
|
* Toggle whether the graphs should be annotated by tool tip info strings.
|
||||||
*
|
*
|
||||||
* @param doShowGraphToolTips true if the graphs should be annotated by tool
|
* @param doShowGraphToolTips true if the graphs should be annotated by tool
|
||||||
* tip info strings
|
* tip info strings
|
||||||
*/
|
*/
|
||||||
public void setShowGraphToolTips(boolean doShowGraphToolTips) {
|
public void setShowGraphToolTips(boolean doShowGraphToolTips) {
|
||||||
m_PlotArea.setShowGraphToolTips(doShowGraphToolTips);
|
m_PlotArea.setShowGraphToolTips(doShowGraphToolTips);
|
||||||
@@ -455,7 +457,7 @@ public class Plot implements PlotInterface, Serializable {
|
|||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
JOptionPane.showMessageDialog(m_Frame,
|
JOptionPane.showMessageDialog(m_Frame,
|
||||||
"Couldn't write to file: " + sFile.getName() + "\n"
|
"Couldn't write to file: " + sFile.getName() + "\n"
|
||||||
+ ex.getMessage(), "Save object",
|
+ ex.getMessage(), "Save object",
|
||||||
JOptionPane.ERROR_MESSAGE);
|
JOptionPane.ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
package eva2.gui.plot;
|
package eva2.gui.plot;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Title: EvA2
|
* Title: EvA2
|
||||||
* Description:
|
* Description:
|
||||||
@@ -13,25 +14,34 @@ package eva2.gui.plot;
|
|||||||
* IMPORTS
|
* IMPORTS
|
||||||
*==========================================================================*/
|
*==========================================================================*/
|
||||||
public interface PlotInterface {
|
public interface PlotInterface {
|
||||||
public void setConnectedPoint (double x,double y,int GraphLabel);
|
public void setConnectedPoint(double x, double y, int GraphLabel);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add two graphs to form an average graph
|
* Add two graphs to form an average graph
|
||||||
*
|
*
|
||||||
* @param g1 graph object one
|
* @param g1 graph object one
|
||||||
* @param g2 graph object two
|
* @param g2 graph object two
|
||||||
* @param forceAdd if the graph mismatch in point counts, try to add them anyway in a useful manner.
|
* @param forceAdd if the graph mismatch in point counts, try to add them anyway in a useful manner.
|
||||||
*/
|
*/
|
||||||
public void addGraph (int g1,int g2, boolean forceAdd);
|
public void addGraph(int g1, int g2, boolean forceAdd);
|
||||||
public void setUnconnectedPoint (double x, double y,int GraphLabel);
|
|
||||||
public void clearAll ();
|
public void setUnconnectedPoint(double x, double y, int GraphLabel);
|
||||||
public void clearGraph (int GraphNumber);
|
|
||||||
public void setInfoString (int GraphLabel, String Info, float stroke);
|
public void clearAll();
|
||||||
public void jump ();
|
|
||||||
public String getName();
|
public void clearGraph(int GraphNumber);
|
||||||
public int getPointCount(int graphLabel);
|
|
||||||
// public FunctionArea getFunctionArea(); // this is bad for RMI
|
public void setInfoString(int GraphLabel, String Info, float stroke);
|
||||||
public boolean isValid();
|
|
||||||
public void init();
|
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
|
* IMPORTS
|
||||||
*==========================================================================*/
|
*==========================================================================*/
|
||||||
|
|
||||||
import eva2.optimization.problems.Interface2DBorderProblem;
|
import eva2.optimization.problems.Interface2DBorderProblem;
|
||||||
import eva2.optimization.problems.InterfaceFirstOrderDerivableProblem;
|
import eva2.optimization.problems.InterfaceFirstOrderDerivableProblem;
|
||||||
import eva2.tools.chart2d.DRectangle;
|
import eva2.tools.chart2d.DRectangle;
|
||||||
import eva2.tools.diagram.ColorBarCalculator;
|
import eva2.tools.diagram.ColorBarCalculator;
|
||||||
import eva2.tools.math.Mathematics;
|
import eva2.tools.math.Mathematics;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
@@ -24,52 +26,55 @@ import javax.swing.JPanel;
|
|||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
* CLASS DECLARATION
|
* CLASS DECLARATION
|
||||||
*==========================================================================*/
|
*==========================================================================*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class TopoPlot extends Plot {
|
public class TopoPlot extends Plot {
|
||||||
Interface2DBorderProblem prob=null;
|
Interface2DBorderProblem prob = null;
|
||||||
double[][] range=null;
|
double[][] range = null;
|
||||||
boolean withGrads=false;
|
boolean withGrads = false;
|
||||||
private int gridx = 50;
|
private int gridx = 50;
|
||||||
private int gridy = 50;
|
private int gridy = 50;
|
||||||
int colorScale = ColorBarCalculator.BLUE_TO_RED;
|
int colorScale = ColorBarCalculator.BLUE_TO_RED;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public TopoPlot(String PlotName,String xname,String yname) {
|
public TopoPlot(String PlotName, String xname, String yname) {
|
||||||
super(PlotName, xname, yname, true);
|
super(PlotName, xname, yname, true);
|
||||||
//if (TRACE) System.out.println("Constructor TopoPlot "+PlotName);
|
//if (TRACE) System.out.println("Constructor TopoPlot "+PlotName);
|
||||||
}
|
}
|
||||||
public TopoPlot(String PlotName,String xname,String yname,double[] a, double[] b) {
|
|
||||||
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, double[] a, double[] b) {
|
||||||
|
super(PlotName, xname, yname, a, b);
|
||||||
@Override
|
//if (TRACE) System.out.println("Constructor TopoPlot "+PlotName);
|
||||||
protected void installButtons(JPanel buttonPan) {
|
}
|
||||||
super.installButtons(buttonPan);
|
|
||||||
// TODO this actually works, but it is horribly slow
|
/**
|
||||||
|
* 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");
|
// JButton refineButton = new JButton ("Refine");
|
||||||
// refineButton.setToolTipText("Refine the graph resolution");
|
// refineButton.setToolTipText("Refine the graph resolution");
|
||||||
// refineButton.addActionListener(new ActionListener() {
|
// refineButton.addActionListener(new ActionListener() {
|
||||||
@@ -80,90 +85,93 @@ public class TopoPlot extends Plot {
|
|||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
// buttonPan.add(refineButton);
|
// 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
|
} // class
|
||||||
|
|||||||
@@ -96,13 +96,13 @@ public class CustomTabbedPaneUI extends BasicTabbedPaneUI {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int calculateTabHeight(int tabPlacement, int tabIndex,
|
protected int calculateTabHeight(int tabPlacement, int tabIndex,
|
||||||
int fontHeight) {
|
int fontHeight) {
|
||||||
return 21;
|
return 21;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int calculateTabWidth(int tabPlacement, int tabIndex,
|
protected int calculateTabWidth(int tabPlacement, int tabIndex,
|
||||||
FontMetrics metrics) {
|
FontMetrics metrics) {
|
||||||
int w = super.calculateTabWidth(tabPlacement, tabIndex, metrics);
|
int w = super.calculateTabWidth(tabPlacement, tabIndex, metrics);
|
||||||
int wid = metrics.charWidth('M');
|
int wid = metrics.charWidth('M');
|
||||||
w += wid * 2;
|
w += wid * 2;
|
||||||
@@ -134,7 +134,7 @@ public class CustomTabbedPaneUI extends BasicTabbedPaneUI {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void paintTabBackground(Graphics g, int tabPlacement,
|
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;
|
Graphics2D g2d = (Graphics2D) g;
|
||||||
ColorSet colorSet;
|
ColorSet colorSet;
|
||||||
|
|
||||||
@@ -174,7 +174,7 @@ public class CustomTabbedPaneUI extends BasicTabbedPaneUI {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex,
|
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));
|
Rectangle rect = getTabBounds(tabIndex, new Rectangle(x, y, w, h));
|
||||||
g.setColor(dividerColor);
|
g.setColor(dividerColor);
|
||||||
g.drawLine(rect.x + rect.width, 0, rect.x + rect.width, 20);
|
g.drawLine(rect.x + rect.width, 0, rect.x + rect.width, 20);
|
||||||
@@ -182,37 +182,37 @@ public class CustomTabbedPaneUI extends BasicTabbedPaneUI {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void paintContentBorderTopEdge(Graphics g, int tabPlacement,
|
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
|
@Override
|
||||||
protected void paintContentBorderRightEdge(Graphics g, int tabPlacement,
|
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
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void paintContentBorderLeftEdge(Graphics g, int tabPlacement,
|
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
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void paintContentBorderBottomEdge(Graphics g, int tabPlacement,
|
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
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void paintFocusIndicator(Graphics g, int tabPlacement,
|
protected void paintFocusIndicator(Graphics g, int tabPlacement,
|
||||||
Rectangle[] rects, int tabIndex, Rectangle iconRect,
|
Rectangle[] rects, int tabIndex, Rectangle iconRect,
|
||||||
Rectangle textRect, boolean isSelected) {
|
Rectangle textRect, boolean isSelected) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getTabLabelShiftY(int tabPlacement, int tabIndex,
|
protected int getTabLabelShiftY(int tabPlacement, int tabIndex,
|
||||||
boolean isSelected) {
|
boolean isSelected) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,79 +8,78 @@ import javax.swing.JComponent;
|
|||||||
import javax.swing.plaf.basic.BasicButtonUI;
|
import javax.swing.plaf.basic.BasicButtonUI;
|
||||||
|
|
||||||
public class VerticalButtonUI extends BasicButtonUI {
|
public class VerticalButtonUI extends BasicButtonUI {
|
||||||
|
|
||||||
protected int angle;
|
protected int angle;
|
||||||
|
|
||||||
public VerticalButtonUI(int angle) {
|
public VerticalButtonUI(int angle) {
|
||||||
super();
|
super();
|
||||||
this.angle = angle;
|
this.angle = angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dimension getPreferredSize(JComponent c) {
|
public Dimension getPreferredSize(JComponent c) {
|
||||||
Dimension dim = super.getPreferredSize(c);
|
Dimension dim = super.getPreferredSize(c);
|
||||||
return new Dimension( dim.height, dim.width );
|
return new Dimension(dim.height, dim.width);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Rectangle paintIconR = new Rectangle();
|
private static Rectangle paintIconR = new Rectangle();
|
||||||
private static Rectangle paintTextR = new Rectangle();
|
private static Rectangle paintTextR = new Rectangle();
|
||||||
private static Rectangle paintViewR = new Rectangle();
|
private static Rectangle paintViewR = new Rectangle();
|
||||||
private static Insets paintViewInsets = new Insets(0, 0, 0, 0);
|
private static Insets paintViewInsets = new Insets(0, 0, 0, 0);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paint(Graphics g, JComponent c) {
|
public void paint(Graphics g, JComponent c) {
|
||||||
JButton button = (JButton)c;
|
JButton button = (JButton) c;
|
||||||
String text = button.getText();
|
String text = button.getText();
|
||||||
Icon icon = (button.isEnabled()) ? button.getIcon() : button.getDisabledIcon();
|
Icon icon = (button.isEnabled()) ? button.getIcon() : button.getDisabledIcon();
|
||||||
|
|
||||||
if ((icon == null) && (text == null)) {
|
if ((icon == null) && (text == null)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FontMetrics fm = g.getFontMetrics();
|
FontMetrics fm = g.getFontMetrics();
|
||||||
paintViewInsets = c.getInsets(paintViewInsets);
|
paintViewInsets = c.getInsets(paintViewInsets);
|
||||||
|
|
||||||
paintViewR.x = paintViewInsets.left;
|
paintViewR.x = paintViewInsets.left;
|
||||||
paintViewR.y = paintViewInsets.top;
|
paintViewR.y = paintViewInsets.top;
|
||||||
|
|
||||||
// Use inverted height & width
|
// Use inverted height & width
|
||||||
paintViewR.height = c.getWidth() - (paintViewInsets.left + paintViewInsets.right);
|
paintViewR.height = c.getWidth() - (paintViewInsets.left + paintViewInsets.right);
|
||||||
paintViewR.width = c.getHeight() - (paintViewInsets.top + paintViewInsets.bottom);
|
paintViewR.width = c.getHeight() - (paintViewInsets.top + paintViewInsets.bottom);
|
||||||
|
|
||||||
paintIconR.x = paintIconR.y = paintIconR.width = paintIconR.height = 0;
|
paintIconR.x = paintIconR.y = paintIconR.width = paintIconR.height = 0;
|
||||||
paintTextR.x = paintTextR.y = paintTextR.width = paintTextR.height = 0;
|
paintTextR.x = paintTextR.y = paintTextR.width = paintTextR.height = 0;
|
||||||
|
|
||||||
Graphics2D g2 = (Graphics2D) g;
|
Graphics2D g2 = (Graphics2D) g;
|
||||||
AffineTransform tr = g2.getTransform();
|
AffineTransform tr = g2.getTransform();
|
||||||
|
|
||||||
if (angle == 90) {
|
if (angle == 90) {
|
||||||
g2.rotate( Math.PI / 2 );
|
g2.rotate(Math.PI / 2);
|
||||||
g2.translate( 0, - c.getWidth() );
|
g2.translate(0, -c.getWidth());
|
||||||
paintViewR.x = c.getHeight()/2 - (int)fm.getStringBounds(text, g).getWidth()/2;
|
paintViewR.x = c.getHeight() / 2 - (int) fm.getStringBounds(text, g).getWidth() / 2;
|
||||||
paintViewR.y = c.getWidth()/2 - (int)fm.getStringBounds(text, g).getHeight()/2;
|
paintViewR.y = c.getWidth() / 2 - (int) fm.getStringBounds(text, g).getHeight() / 2;
|
||||||
|
} else if (angle == 270 || angle == -90) {
|
||||||
|
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) {
|
if (icon != null) {
|
||||||
icon.paintIcon(c, g, paintIconR.x, paintIconR.y);
|
icon.paintIcon(c, g, paintIconR.x, paintIconR.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (text != null) {
|
if (text != null) {
|
||||||
int textX = paintTextR.x;
|
int textX = paintTextR.x;
|
||||||
int textY = paintTextR.y + fm.getAscent();
|
int textY = paintTextR.y + fm.getAscent();
|
||||||
|
|
||||||
if (button.isEnabled()) {
|
if (button.isEnabled()) {
|
||||||
paintText(g,c,new Rectangle(paintViewR.x,paintViewR.y,textX,textY),text);
|
paintText(g, c, new Rectangle(paintViewR.x, paintViewR.y, textX, textY), text);
|
||||||
} else {
|
} else {
|
||||||
paintText(g,c,new Rectangle(paintViewR.x,paintViewR.y,textX,textY),text);
|
paintText(g, c, new Rectangle(paintViewR.x, paintViewR.y, textX, textY), text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g2.setTransform( tr );
|
g2.setTransform(tr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,12 +4,14 @@ package eva2.optimization;
|
|||||||
* Description: API for distributed and parallel computing.
|
* Description: API for distributed and parallel computing.
|
||||||
* Copyright: Copyright (c) 2004
|
* Copyright: Copyright (c) 2004
|
||||||
* Company: University of Tuebingen
|
* Company: University of Tuebingen
|
||||||
* @version: $Revision: 259 $
|
* @version: $Revision: 259 $
|
||||||
* $Date: 2007-11-16 17:25:09 +0100 (Fri, 16 Nov 2007) $
|
* $Date: 2007-11-16 17:25:09 +0100 (Fri, 16 Nov 2007) $
|
||||||
* $Author: mkron $
|
* $Author: mkron $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import eva2.optimization.go.InterfaceOptimizationParameters;
|
import eva2.optimization.go.InterfaceOptimizationParameters;
|
||||||
import eva2.optimization.modules.ModuleAdapter;
|
import eva2.optimization.modules.ModuleAdapter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -5,15 +5,17 @@ package eva2.optimization;
|
|||||||
* Description: API for distributed and parallel computing.
|
* Description: API for distributed and parallel computing.
|
||||||
* Copyright: Copyright (c) 2004
|
* Copyright: Copyright (c) 2004
|
||||||
* Company: University of Tuebingen
|
* Company: University of Tuebingen
|
||||||
* @version: $Revision: 315 $
|
* @version: $Revision: 315 $
|
||||||
* $Date: 2007-12-04 15:23:57 +0100 (Tue, 04 Dec 2007) $
|
* $Date: 2007-12-04 15:23:57 +0100 (Tue, 04 Dec 2007) $
|
||||||
* $Author: mkron $
|
* $Author: mkron $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import eva2.EvAInfo;
|
import eva2.EvAInfo;
|
||||||
import eva2.optimization.go.InterfaceOptimizationParameters;
|
import eva2.optimization.go.InterfaceOptimizationParameters;
|
||||||
import eva2.optimization.modules.ModuleAdapter;
|
import eva2.optimization.modules.ModuleAdapter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class EvAMainAdapterImpl implements EvAMainAdapter {
|
public class EvAMainAdapterImpl implements EvAMainAdapter {
|
||||||
|
|
||||||
|
|||||||
@@ -10,11 +10,13 @@ package eva2.optimization;
|
|||||||
* $Date: 2007-12-06 16:05:11 +0100 (Thu, 06 Dec 2007) $
|
* $Date: 2007-12-06 16:05:11 +0100 (Thu, 06 Dec 2007) $
|
||||||
* $Author: mkron $
|
* $Author: mkron $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import eva2.optimization.go.InterfaceOptimizationParameters;
|
import eva2.optimization.go.InterfaceOptimizationParameters;
|
||||||
import eva2.optimization.modules.GOModuleAdapter;
|
import eva2.optimization.modules.GOModuleAdapter;
|
||||||
import eva2.optimization.modules.ModuleAdapter;
|
import eva2.optimization.modules.ModuleAdapter;
|
||||||
import eva2.tools.EVAERROR;
|
import eva2.tools.EVAERROR;
|
||||||
import eva2.tools.ReflectPackage;
|
import eva2.tools.ReflectPackage;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -92,7 +94,7 @@ public class ModuleServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] x = new String[moduleNameList.size()];
|
String[] x = new String[moduleNameList.size()];
|
||||||
moduleNameList.toArray(x);
|
moduleNameList.toArray(x);
|
||||||
return x;
|
return x;
|
||||||
@@ -153,7 +155,7 @@ public class ModuleServer {
|
|||||||
constrIndex++;
|
constrIndex++;
|
||||||
}
|
}
|
||||||
moduleAdapter = (ModuleAdapter) constructorArr[constrIndex].newInstance(param);
|
moduleAdapter = (ModuleAdapter) constructorArr[constrIndex].newInstance(param);
|
||||||
}
|
}
|
||||||
// m_RunnungModules.add(m_ModuleAdapter);
|
// m_RunnungModules.add(m_ModuleAdapter);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
LOGGER.log(Level.SEVERE, "Error in RMI-Moduladapter initialization", ex);
|
LOGGER.log(Level.SEVERE, "Error in RMI-Moduladapter initialization", ex);
|
||||||
|
|||||||
@@ -5,12 +5,14 @@
|
|||||||
package eva2.optimization;
|
package eva2.optimization;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author becker
|
* @author becker
|
||||||
*/
|
*/
|
||||||
public interface OptimizationStateListener {
|
public interface OptimizationStateListener {
|
||||||
void performedStop();
|
void performedStop();
|
||||||
|
|
||||||
void performedStart(String infoString);
|
void performedStart(String infoString);
|
||||||
|
|
||||||
void performedRestart(String infoString);
|
void performedRestart(String infoString);
|
||||||
|
|
||||||
void updateProgress(final int percent, String msg);
|
void updateProgress(final int percent, String msg);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package eva2.optimization.enums;
|
package eva2.optimization.enums;
|
||||||
|
|
||||||
public enum BOAScoringMethods {
|
public enum BOAScoringMethods {
|
||||||
BDM, K2, BIC;
|
BDM, K2, BIC;
|
||||||
|
|
||||||
public static String[] getInfoStrings(){
|
public static String[] getInfoStrings() {
|
||||||
return new String[] {"The Bayesian Dirichlet Metric", "The K2 Metric", "The Bayesian Information Criterion"};
|
return new String[]{"The Bayesian Dirichlet Metric", "The K2 Metric", "The Bayesian Information Criterion"};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package eva2.optimization.enums;
|
package eva2.optimization.enums;
|
||||||
|
|
||||||
public enum DETypeEnum {
|
public enum DETypeEnum {
|
||||||
DE1_Rand_1, DE2_CurrentToBest, DE_Best_2, TrigonometricDE,DE_CurrentToRand;
|
DE1_Rand_1, DE2_CurrentToBest, DE_Best_2, TrigonometricDE, DE_CurrentToRand;
|
||||||
//", "DE2 - DE/current-to-best/1", "DE/best/2", "Trigonometric DE"};
|
//", "DE2 - DE/current-to-best/1", "DE/best/2", "Trigonometric DE"};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
package eva2.optimization.enums;
|
package eva2.optimization.enums;
|
||||||
|
|
||||||
public enum ESMutationInitialSigma {
|
public enum ESMutationInitialSigma {
|
||||||
halfRange, quarterRange, avgInitialDistance, userDefined;
|
halfRange, quarterRange, avgInitialDistance, userDefined;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
package eva2.optimization.enums;
|
package eva2.optimization.enums;
|
||||||
|
|
||||||
public enum MutateESCrossoverTypeEnum {
|
public enum MutateESCrossoverTypeEnum {
|
||||||
none, intermediate, discrete;
|
none, intermediate, discrete;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,53 +1,63 @@
|
|||||||
package eva2.optimization.enums;
|
package eva2.optimization.enums;
|
||||||
|
|
||||||
public enum PSOTopologyEnum {
|
public enum PSOTopologyEnum {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
linear,
|
linear,
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
grid,
|
grid,
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
star,
|
star,
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
multiSwarm,
|
multiSwarm,
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
tree,
|
tree,
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
hpso,
|
hpso,
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
random,
|
random,
|
||||||
dms;
|
dms;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A method to translate the "old" integer tags into the enum type.
|
* A method to translate the "old" integer tags into the enum type.
|
||||||
* @param oldID
|
*
|
||||||
* @return
|
* @param oldID
|
||||||
*/
|
* @return
|
||||||
public static PSOTopologyEnum translateOldID(int oldID) {
|
*/
|
||||||
switch (oldID) {
|
public static PSOTopologyEnum translateOldID(int oldID) {
|
||||||
case 0: return linear;
|
switch (oldID) {
|
||||||
case 1: return grid;
|
case 0:
|
||||||
case 2: return star;
|
return linear;
|
||||||
case 3: return multiSwarm;
|
case 1:
|
||||||
case 4: return tree;
|
return grid;
|
||||||
case 5: return hpso;
|
case 2:
|
||||||
case 6: return random;
|
return star;
|
||||||
case 7: return dms;
|
case 3:
|
||||||
default: System.err.println("Error: invalid old topology ID in PSOTopologyEnum translateOldID! Returning grid.");
|
return multiSwarm;
|
||||||
return grid;
|
case 4:
|
||||||
}
|
return tree;
|
||||||
}
|
case 5:
|
||||||
|
return hpso;
|
||||||
|
case 6:
|
||||||
|
return random;
|
||||||
|
case 7:
|
||||||
|
return dms;
|
||||||
|
default:
|
||||||
|
System.err.println("Error: invalid old topology ID in PSOTopologyEnum translateOldID! Returning grid.");
|
||||||
|
return grid;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
package eva2.optimization.enums;
|
package eva2.optimization.enums;
|
||||||
|
|
||||||
public enum PostProcessMethod {
|
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.GeneticAlgorithm;
|
||||||
import eva2.optimization.strategies.InterfaceOptimizer;
|
import eva2.optimization.strategies.InterfaceOptimizer;
|
||||||
import eva2.tools.math.RNG;
|
import eva2.tools.math.RNG;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.List;
|
import java.awt.List;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
@@ -54,7 +55,7 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
|||||||
transient private JProgressBar m_ProgressBar;
|
transient private JProgressBar m_ProgressBar;
|
||||||
transient private SwingWorker worker;
|
transient private SwingWorker worker;
|
||||||
transient private boolean show = false;
|
transient private boolean show = false;
|
||||||
// transient private InterfaceTest test = new Test1();
|
// transient private InterfaceTest test = new Test1();
|
||||||
// Opt. Algorithms and Parameters
|
// Opt. Algorithms and Parameters
|
||||||
//transient private InterfaceOptimizer optimizer = new EvolutionaryMultiObjectiveOptimization();
|
//transient private InterfaceOptimizer optimizer = new EvolutionaryMultiObjectiveOptimization();
|
||||||
//transient private InterfaceOptimizationProblem problem = new TF1Problem();
|
//transient private InterfaceOptimizationProblem problem = new TF1Problem();
|
||||||
@@ -68,7 +69,7 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
|||||||
transient private String m_ExperimentName;
|
transient private String m_ExperimentName;
|
||||||
transient private String m_OutputPath = "";
|
transient private String m_OutputPath = "";
|
||||||
transient private String m_OutputFileName = "none";
|
transient private String m_OutputFileName = "none";
|
||||||
// transient private GOStandaloneVersion m_yself;
|
// transient private GOStandaloneVersion m_yself;
|
||||||
// these parameters are for the continue option
|
// these parameters are for the continue option
|
||||||
transient private Population m_Backup;
|
transient private Population m_Backup;
|
||||||
transient private boolean m_ContinueFlag;
|
transient private boolean m_ContinueFlag;
|
||||||
@@ -97,7 +98,6 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This method allows you to get the current GO parameters
|
* This method allows you to get the current GO parameters
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public OptimizationParameters getGOParameters() {
|
public OptimizationParameters getGOParameters() {
|
||||||
return this.m_GO;
|
return this.m_GO;
|
||||||
@@ -192,6 +192,7 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
|||||||
this.m_Frame.validate();
|
this.m_Frame.validate();
|
||||||
this.m_Frame.setVisible(true);
|
this.m_Frame.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This action listener, called by the "Run/Restart" button, will init the
|
* This action listener, called by the "Run/Restart" button, will init the
|
||||||
* problem and start the computation.
|
* problem and start the computation.
|
||||||
@@ -572,7 +573,7 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
|||||||
* This method allows an optimizer to register a change in the optimizer.
|
* This method allows an optimizer to register a change in the optimizer.
|
||||||
*
|
*
|
||||||
* @param source The source of the event.
|
* @param source The source of the event.
|
||||||
* @param name Could be used to indicate the nature of the event.
|
* @param name Could be used to indicate the nature of the event.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void registerPopulationStateChanged(Object source, String name) {
|
public void registerPopulationStateChanged(Object source, String name) {
|
||||||
@@ -695,6 +696,7 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
|||||||
// public String seedTipText() {
|
// public String seedTipText() {
|
||||||
// return "Choose the seed for the random number generator.";
|
// return "Choose the seed for the random number generator.";
|
||||||
// }
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method sets the name of the current experiment as it will occur in
|
* This method sets the name of the current experiment as it will occur in
|
||||||
* the plot legend.
|
* the plot legend.
|
||||||
|
|||||||
@@ -17,57 +17,57 @@ import eva2.optimization.problems.InterfaceOptimizationProblem;
|
|||||||
* Minimal interface for an EA individual.
|
* Minimal interface for an EA individual.
|
||||||
*/
|
*/
|
||||||
public interface IndividualInterface {
|
public interface IndividualInterface {
|
||||||
/**
|
/**
|
||||||
* Create a clone of the individual instance.
|
* Create a clone of the individual instance.
|
||||||
*
|
*
|
||||||
* @return a clone of the individual instance
|
* @return a clone of the individual instance
|
||||||
*/
|
*/
|
||||||
IndividualInterface getClone();
|
IndividualInterface getClone();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the fitness array of the individual which may be null if none has been set.
|
* Get the fitness array of the individual which may be null if none has been set.
|
||||||
*
|
*
|
||||||
* @return the fitness array of the individual
|
* @return the fitness array of the individual
|
||||||
*/
|
*/
|
||||||
double[] getFitness();
|
double[] getFitness();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the fitness array to the given array.
|
* Set the fitness array to the given array.
|
||||||
*
|
*
|
||||||
* @param fit new fitness of the individual
|
* @param fit new fitness of the individual
|
||||||
*/
|
*/
|
||||||
void setFitness (double[] fit);
|
void setFitness(double[] fit);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether the instance is dominating the given other individual and return
|
* Check whether the instance is dominating the given other individual and return
|
||||||
* true in this case.
|
* true in this case.
|
||||||
*
|
*
|
||||||
* @param other a second individual of the same type
|
* @param other a second individual of the same type
|
||||||
* @return true if the instance dominates the other individual, else false
|
* @return true if the instance dominates the other individual, else false
|
||||||
*/
|
*/
|
||||||
boolean isDominant(double[] fitness);
|
boolean isDominant(double[] fitness);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether the instance is dominating the given other individual and return
|
* Check whether the instance is dominating the given other individual and return
|
||||||
* true in this case.
|
* true in this case.
|
||||||
* Should behave equally to {@link #isDominant(double[])} if called with the fitness
|
* Should behave equally to {@link #isDominant(double[])} if called with the fitness
|
||||||
* of the given individual.
|
* of the given individual.
|
||||||
*
|
*
|
||||||
* @param other a second individual of the same type
|
* @param other a second individual of the same type
|
||||||
* @return true if the instance dominates the other individual, else false
|
* @return true if the instance dominates the other individual, else false
|
||||||
*/
|
*/
|
||||||
boolean isDominant(IndividualInterface other);
|
boolean isDominant(IndividualInterface other);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform a standard mutation operation on the individual. The exact implementation
|
* Perform a standard mutation operation on the individual. The exact implementation
|
||||||
* depends on the implemented genotype.
|
* depends on the implemented genotype.
|
||||||
*/
|
*/
|
||||||
void defaultMutate();
|
void defaultMutate();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the genotype randomly, usually in a uniform distribution. Make sure,
|
* Initialize the genotype randomly, usually in a uniform distribution. Make sure,
|
||||||
* if the problem has an initial range (it implements InterfaceHasInitialRange), that this
|
* if the problem has an initial range (it implements InterfaceHasInitialRange), that this
|
||||||
* initial range is used.
|
* initial range is used.
|
||||||
*/
|
*/
|
||||||
void defaultInit(InterfaceOptimizationProblem prob);
|
void defaultInit(InterfaceOptimizationProblem prob);
|
||||||
}
|
}
|
||||||
@@ -9,5 +9,6 @@ package eva2.optimization.go;
|
|||||||
*/
|
*/
|
||||||
public interface InterfaceGOStandalone {
|
public interface InterfaceGOStandalone {
|
||||||
void startExperiment();
|
void startExperiment();
|
||||||
|
|
||||||
void setShow(boolean t);
|
void setShow(boolean t);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
package eva2.optimization.go;
|
package eva2.optimization.go;
|
||||||
|
|
||||||
import eva2.optimization.problems.InterfaceAdditionalPopulationInformer;
|
import eva2.optimization.problems.InterfaceAdditionalPopulationInformer;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface InterfaceNotifyOnInformers {
|
public interface InterfaceNotifyOnInformers {
|
||||||
/**
|
/**
|
||||||
* Notify the object about informer instances.
|
* Notify the object about informer instances.
|
||||||
*/
|
*/
|
||||||
public void setInformers(List<InterfaceAdditionalPopulationInformer> informers);
|
public void setInformers(List<InterfaceAdditionalPopulationInformer> informers);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,63 +19,85 @@ public interface InterfaceOptimizationParameters {
|
|||||||
*/
|
*/
|
||||||
// public String globalInfo();
|
// public String globalInfo();
|
||||||
|
|
||||||
/** This method allows you to serialize the current parameters into a *.ser file
|
/**
|
||||||
|
* This method allows you to serialize the current parameters into a *.ser file
|
||||||
*/
|
*/
|
||||||
public void saveInstance();
|
public void saveInstance();
|
||||||
|
|
||||||
/** This method returns the name
|
/**
|
||||||
|
* This method returns the name
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public String getName();
|
public String getName();
|
||||||
|
|
||||||
/** This methods allow you to set and get the Seed for the Random Number Generator.
|
/**
|
||||||
* @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 void setSeed(long x);
|
||||||
|
|
||||||
public long getSeed();
|
public long getSeed();
|
||||||
|
|
||||||
public String seedTipText();
|
public String seedTipText();
|
||||||
|
|
||||||
/** This method allows you to choose a termination criteria for the
|
/**
|
||||||
|
* This method allows you to choose a termination criteria for the
|
||||||
* evolutionary algorithm.
|
* evolutionary algorithm.
|
||||||
* @param term The new terminator
|
*
|
||||||
|
* @param term The new terminator
|
||||||
*/
|
*/
|
||||||
public void setTerminator(InterfaceTerminator term);
|
public void setTerminator(InterfaceTerminator term);
|
||||||
|
|
||||||
public InterfaceTerminator getTerminator();
|
public InterfaceTerminator getTerminator();
|
||||||
|
|
||||||
public String terminatorTipText();
|
public String terminatorTipText();
|
||||||
|
|
||||||
/** This method allows you to set the current optimizing algorithm
|
/**
|
||||||
|
* This method allows you to set the current optimizing algorithm
|
||||||
|
*
|
||||||
* @param optimizer The new optimizing algorithm
|
* @param optimizer The new optimizing algorithm
|
||||||
*/
|
*/
|
||||||
public void setOptimizer(InterfaceOptimizer optimizer);
|
public void setOptimizer(InterfaceOptimizer optimizer);
|
||||||
|
|
||||||
public InterfaceOptimizer getOptimizer();
|
public InterfaceOptimizer getOptimizer();
|
||||||
// public String optimizerTipText();
|
// public String optimizerTipText();
|
||||||
|
|
||||||
/** This method will set the problem that is to be optimized
|
/**
|
||||||
|
* This method will set the problem that is to be optimized
|
||||||
|
*
|
||||||
* @param problem
|
* @param problem
|
||||||
*/
|
*/
|
||||||
public void setProblem (InterfaceOptimizationProblem problem);
|
public void setProblem(InterfaceOptimizationProblem problem);
|
||||||
public InterfaceOptimizationProblem getProblem ();
|
|
||||||
|
public InterfaceOptimizationProblem getProblem();
|
||||||
|
|
||||||
public String problemTipText();
|
public String problemTipText();
|
||||||
|
|
||||||
/** This method will set the output filename
|
/**
|
||||||
* @param name
|
* This method will set the output filename
|
||||||
* TODO invalidate these!
|
*
|
||||||
|
* @param name TODO invalidate these!
|
||||||
*/
|
*/
|
||||||
// public void setOutputFileName (String name);
|
// public void setOutputFileName (String name);
|
||||||
// public String getOutputFileName ();
|
// public String getOutputFileName ();
|
||||||
// public String outputFileNameTipText();
|
// public String outputFileNameTipText();
|
||||||
|
|
||||||
public InterfacePostProcessParams getPostProcessParams();
|
public InterfacePostProcessParams getPostProcessParams();
|
||||||
|
|
||||||
public void setPostProcessParams(InterfacePostProcessParams ppp);
|
public void setPostProcessParams(InterfacePostProcessParams ppp);
|
||||||
|
|
||||||
public String postProcessParamsTipText();
|
public String postProcessParamsTipText();
|
||||||
|
|
||||||
public void setDoPostProcessing(boolean doPP);
|
public void setDoPostProcessing(boolean doPP);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Give an instance which should be informed about elements which are additional informers.
|
* Give an instance which should be informed about elements which are additional informers.
|
||||||
*
|
*
|
||||||
* @see InterfaceAdditionalPopulationInformer
|
|
||||||
* @param o
|
* @param o
|
||||||
|
* @see InterfaceAdditionalPopulationInformer
|
||||||
*/
|
*/
|
||||||
public void addInformableInstance(InterfaceNotifyOnInformers o);
|
public void addInformableInstance(InterfaceNotifyOnInformers o);
|
||||||
|
|
||||||
public boolean removeInformableInstance(InterfaceNotifyOnInformers o);
|
public boolean removeInformableInstance(InterfaceNotifyOnInformers o);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,9 +10,11 @@ package eva2.optimization.go;
|
|||||||
*/
|
*/
|
||||||
public interface InterfacePopulationChangedEventListener {
|
public interface InterfacePopulationChangedEventListener {
|
||||||
|
|
||||||
/** This method allows an optimizer to register a change in the optimizer.
|
/**
|
||||||
* @param source The source of the event.
|
* This method allows an optimizer to register a change in the optimizer.
|
||||||
* @param name Could be used to indicate the nature of the event.
|
*
|
||||||
|
* @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);
|
void registerPopulationStateChanged(Object source, String name);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ public interface InterfaceProcessor {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Info String about the Optimization.
|
* Get Info String about the Optimization.
|
||||||
|
*
|
||||||
* @return The info String
|
* @return The info String
|
||||||
*/
|
*/
|
||||||
String getInfoString();
|
String getInfoString();
|
||||||
|
|||||||
@@ -6,22 +6,24 @@ import eva2.optimization.problems.InterfaceOptimizationProblem;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for a termination criterion.
|
* Interface for a termination criterion.
|
||||||
*
|
|
||||||
* @author mkron, streiche
|
|
||||||
*
|
*
|
||||||
|
* @author mkron, streiche
|
||||||
*/
|
*/
|
||||||
public interface InterfaceTerminator {
|
public interface InterfaceTerminator {
|
||||||
/**
|
/**
|
||||||
* Test a given population for convergence with the criterion defined by the instance.
|
* Test a given population for convergence with the criterion defined by the instance.
|
||||||
*
|
*
|
||||||
* @param pop the population to test
|
* @param pop the population to test
|
||||||
* @return true if the population fulfills the termination criterion, else false
|
* @return true if the population fulfills the termination criterion, else false
|
||||||
*/
|
*/
|
||||||
public boolean isTerminated(PopulationInterface pop);
|
public boolean isTerminated(PopulationInterface pop);
|
||||||
public boolean isTerminated(InterfaceSolutionSet pop);
|
|
||||||
|
public boolean isTerminated(InterfaceSolutionSet pop);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString();
|
public String toString();
|
||||||
public String lastTerminationMessage();
|
|
||||||
public void init(InterfaceOptimizationProblem prob);
|
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.population.Population;
|
||||||
import eva2.optimization.strategies.InterfaceOptimizer;
|
import eva2.optimization.strategies.InterfaceOptimizer;
|
||||||
import eva2.optimization.strategies.IslandModelEA;
|
import eva2.optimization.strategies.IslandModelEA;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.GridLayout;
|
import java.awt.GridLayout;
|
||||||
@@ -46,23 +47,24 @@ import javax.swing.*;
|
|||||||
*/
|
*/
|
||||||
public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulationChangedEventListener, Serializable {
|
public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulationChangedEventListener, Serializable {
|
||||||
|
|
||||||
public volatile MOCCOState m_State;
|
public volatile MOCCOState m_State;
|
||||||
private SwingWorker worker;
|
private SwingWorker worker;
|
||||||
private volatile boolean m_StillWorking = false;
|
private volatile boolean m_StillWorking = false;
|
||||||
public int m_Iteration = -1;
|
public int m_Iteration = -1;
|
||||||
public JFrame m_JFrame;
|
public JFrame m_JFrame;
|
||||||
//public ParetoFrontView n_ParetoFrontView;
|
//public ParetoFrontView n_ParetoFrontView;
|
||||||
public boolean m_Debug = false;
|
public boolean m_Debug = false;
|
||||||
public MOCCOViewer m_View;
|
public MOCCOViewer m_View;
|
||||||
public JPanel m_JPanelMain, m_JPanelParameters, m_JPanelControl, m_JPanelButtom;
|
public JPanel m_JPanelMain, m_JPanelParameters, m_JPanelControl, m_JPanelButtom;
|
||||||
private JLabel m_CurrentState;
|
private JLabel m_CurrentState;
|
||||||
private JProgressBar m_ProgressBar;
|
private JProgressBar m_ProgressBar;
|
||||||
|
|
||||||
public MOCCOStandalone() {
|
public MOCCOStandalone() {
|
||||||
this.m_State = new MOCCOState();
|
this.m_State = new MOCCOState();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method will init the main MOCCO GUI
|
/**
|
||||||
|
* This method will init the main MOCCO GUI
|
||||||
* frame
|
* frame
|
||||||
*/
|
*/
|
||||||
public void initMOCCOFrame() {
|
public void initMOCCOFrame() {
|
||||||
@@ -80,12 +82,12 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
// init basic panel structure
|
// init basic panel structure
|
||||||
this.m_JPanelMain = new JPanel();
|
this.m_JPanelMain = new JPanel();
|
||||||
this.m_JPanelParameters = new JPanel();
|
this.m_JPanelParameters = new JPanel();
|
||||||
this.m_JPanelParameters.setPreferredSize(new Dimension(500, 300));
|
this.m_JPanelParameters.setPreferredSize(new Dimension(500, 300));
|
||||||
this.m_JPanelParameters.setMinimumSize(new Dimension(500, 300));
|
this.m_JPanelParameters.setMinimumSize(new Dimension(500, 300));
|
||||||
this.m_JPanelControl = new JPanel();
|
this.m_JPanelControl = new JPanel();
|
||||||
this.m_View = new MOCCOViewer(this);
|
this.m_View = new MOCCOViewer(this);
|
||||||
this.m_JFrame.getContentPane().add(this.m_JPanelMain);
|
this.m_JFrame.getContentPane().add(this.m_JPanelMain);
|
||||||
this.m_JPanelMain.setLayout(new BorderLayout());
|
this.m_JPanelMain.setLayout(new BorderLayout());
|
||||||
this.m_JPanelMain.add(this.m_JPanelParameters, BorderLayout.WEST);
|
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 = new JPanel();
|
||||||
this.m_JPanelButtom.setLayout(new BorderLayout());
|
this.m_JPanelButtom.setLayout(new BorderLayout());
|
||||||
JPanel tmpP = new JPanel();
|
JPanel tmpP = new JPanel();
|
||||||
tmpP.setLayout(new GridLayout(2,1));
|
tmpP.setLayout(new GridLayout(2, 1));
|
||||||
this.m_CurrentState = new JLabel("Problem Initialization");
|
this.m_CurrentState = new JLabel("Problem Initialization");
|
||||||
tmpP.add(this.m_CurrentState);
|
tmpP.add(this.m_CurrentState);
|
||||||
this.m_ProgressBar = new JProgressBar();
|
this.m_ProgressBar = new JProgressBar();
|
||||||
tmpP.add(this.m_ProgressBar);
|
tmpP.add(this.m_ProgressBar);
|
||||||
this.m_JPanelButtom.add(tmpP, BorderLayout.CENTER);
|
this.m_JPanelButtom.add(tmpP, BorderLayout.CENTER);
|
||||||
this.m_JPanelControl.setMinimumSize(new Dimension(400,0));
|
this.m_JPanelControl.setMinimumSize(new Dimension(400, 0));
|
||||||
this.m_JPanelControl.setPreferredSize(new Dimension(400,0));
|
this.m_JPanelControl.setPreferredSize(new Dimension(400, 0));
|
||||||
this.m_JPanelButtom.add(this.m_JPanelControl, BorderLayout.EAST);
|
this.m_JPanelButtom.add(this.m_JPanelControl, BorderLayout.EAST);
|
||||||
this.m_JPanelMain.add(this.m_JPanelButtom, BorderLayout.SOUTH);
|
this.m_JPanelMain.add(this.m_JPanelButtom, BorderLayout.SOUTH);
|
||||||
this.m_JFrame.validate();
|
this.m_JFrame.validate();
|
||||||
@@ -109,22 +111,37 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void MOCCOOptimization() {
|
public void MOCCOOptimization() {
|
||||||
boolean cont = true;
|
boolean cont = true;
|
||||||
InterfaceProcessElement tmpP;
|
InterfaceProcessElement tmpP;
|
||||||
while (cont) {
|
while (cont) {
|
||||||
this.m_Iteration++;
|
this.m_Iteration++;
|
||||||
while (m_StillWorking) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { } }
|
while (m_StillWorking) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (java.lang.InterruptedException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
if (this.m_State.m_OriginalProblem == null) {
|
if (this.m_State.m_OriginalProblem == null) {
|
||||||
this.m_State.m_OriginalProblem = new TF1Problem();
|
this.m_State.m_OriginalProblem = new TF1Problem();
|
||||||
tmpP = new MOCCOProblemInitialization(this);
|
tmpP = new MOCCOProblemInitialization(this);
|
||||||
tmpP.initProcessElementParametrization();
|
tmpP.initProcessElementParametrization();
|
||||||
while (!tmpP.isFinished()) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { }}
|
while (!tmpP.isFinished()) {
|
||||||
this.m_State.m_CurrentProblem = (InterfaceOptimizationProblem)this.m_State.m_OriginalProblem.clone();
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (java.lang.InterruptedException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.m_State.m_CurrentProblem = (InterfaceOptimizationProblem) this.m_State.m_OriginalProblem.clone();
|
||||||
this.m_View.problemChanged(true);
|
this.m_View.problemChanged(true);
|
||||||
this.m_JPanelParameters.removeAll();
|
this.m_JPanelParameters.removeAll();
|
||||||
tmpP = new MOCCOInitialPopulationSize(this);
|
tmpP = new MOCCOInitialPopulationSize(this);
|
||||||
tmpP.initProcessElementParametrization();
|
tmpP.initProcessElementParametrization();
|
||||||
while (!tmpP.isFinished()) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { }}
|
while (!tmpP.isFinished()) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (java.lang.InterruptedException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
this.m_State.m_InitialPopulationSize = Math.max(1, this.m_State.m_InitialPopulationSize);
|
this.m_State.m_InitialPopulationSize = Math.max(1, this.m_State.m_InitialPopulationSize);
|
||||||
Population pop = new Population();
|
Population pop = new Population();
|
||||||
pop.setTargetSize(this.m_State.m_InitialPopulationSize);
|
pop.setTargetSize(this.m_State.m_InitialPopulationSize);
|
||||||
@@ -134,12 +151,17 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
|||||||
this.m_State.addPopulation2History(pop);
|
this.m_State.addPopulation2History(pop);
|
||||||
this.m_View.problemChanged(true);
|
this.m_View.problemChanged(true);
|
||||||
}
|
}
|
||||||
((InterfaceMultiObjectiveDeNovoProblem)this.m_State.m_CurrentProblem).deactivateRepresentationEdit();
|
((InterfaceMultiObjectiveDeNovoProblem) this.m_State.m_CurrentProblem).deactivateRepresentationEdit();
|
||||||
this.updateStatus("Analysis/Redefinition", 33);
|
this.updateStatus("Analysis/Redefinition", 33);
|
||||||
tmpP = new MOCCOProblemRedefinition(this);
|
tmpP = new MOCCOProblemRedefinition(this);
|
||||||
tmpP.initProcessElementParametrization();
|
tmpP.initProcessElementParametrization();
|
||||||
while (!tmpP.isFinished()) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { } }
|
while (!tmpP.isFinished()) {
|
||||||
this.m_State.makeFitnessCache(true);
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (java.lang.InterruptedException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.m_State.makeFitnessCache(true);
|
||||||
this.m_State.m_CurrentProblem.initializeProblem();
|
this.m_State.m_CurrentProblem.initializeProblem();
|
||||||
this.m_State.makeBackup();
|
this.m_State.makeBackup();
|
||||||
this.m_View.problemChanged(true);
|
this.m_View.problemChanged(true);
|
||||||
@@ -147,70 +169,125 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
|||||||
this.updateStatus("MO Strategy Selection", 50);
|
this.updateStatus("MO Strategy Selection", 50);
|
||||||
tmpP = new MOCCOChooseMOStrategy(this);
|
tmpP = new MOCCOChooseMOStrategy(this);
|
||||||
tmpP.initProcessElementParametrization();
|
tmpP.initProcessElementParametrization();
|
||||||
while (!tmpP.isFinished()) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { } }
|
while (!tmpP.isFinished()) {
|
||||||
switch (((MOCCOChooseMOStrategy)tmpP).getMOStrategy()) {
|
try {
|
||||||
case MOCCOChooseMOStrategy.STRATEGY_MOEA : {
|
Thread.sleep(1000);
|
||||||
|
} catch (java.lang.InterruptedException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
switch (((MOCCOChooseMOStrategy) tmpP).getMOStrategy()) {
|
||||||
|
case MOCCOChooseMOStrategy.STRATEGY_MOEA: {
|
||||||
this.updateStatus("MOEA Parameterization", 75);
|
this.updateStatus("MOEA Parameterization", 75);
|
||||||
tmpP = new MOCCOParameterizeMO(this);
|
tmpP = new MOCCOParameterizeMO(this);
|
||||||
tmpP.initProcessElementParametrization();
|
tmpP.initProcessElementParametrization();
|
||||||
while (!tmpP.isFinished()) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { } }
|
while (!tmpP.isFinished()) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (java.lang.InterruptedException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MOCCOChooseMOStrategy.STRATEGY_STEP : {
|
case MOCCOChooseMOStrategy.STRATEGY_STEP: {
|
||||||
this.updateStatus("Reference Solution...", 75);
|
this.updateStatus("Reference Solution...", 75);
|
||||||
tmpP = new MOCCOChooseReferenceSolution(this);
|
tmpP = new MOCCOChooseReferenceSolution(this);
|
||||||
tmpP.initProcessElementParametrization();
|
tmpP.initProcessElementParametrization();
|
||||||
while (!tmpP.isFinished()) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { } }
|
while (!tmpP.isFinished()) {
|
||||||
AbstractEAIndividual reference = ((MOCCOChooseReferenceSolution)tmpP).getReferenceSolution();
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (java.lang.InterruptedException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AbstractEAIndividual reference = ((MOCCOChooseReferenceSolution) tmpP).getReferenceSolution();
|
||||||
this.updateStatus("STEP Parameterization...", 90);
|
this.updateStatus("STEP Parameterization...", 90);
|
||||||
tmpP = new MOCCOParameterizeSTEP(this);
|
tmpP = new MOCCOParameterizeSTEP(this);
|
||||||
((MOCCOParameterizeSTEP)tmpP).setReferenceSolution(reference);
|
((MOCCOParameterizeSTEP) tmpP).setReferenceSolution(reference);
|
||||||
tmpP.initProcessElementParametrization();
|
tmpP.initProcessElementParametrization();
|
||||||
while (!tmpP.isFinished()) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { } }
|
while (!tmpP.isFinished()) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (java.lang.InterruptedException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MOCCOChooseMOStrategy.STRATEGY_REFP : {
|
case MOCCOChooseMOStrategy.STRATEGY_REFP: {
|
||||||
this.updateStatus("Reference Point...", 75);
|
this.updateStatus("Reference Point...", 75);
|
||||||
tmpP = new MOCCOChooseReferencePoint(this);
|
tmpP = new MOCCOChooseReferencePoint(this);
|
||||||
tmpP.initProcessElementParametrization();
|
tmpP.initProcessElementParametrization();
|
||||||
while (!tmpP.isFinished()) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { } }
|
while (!tmpP.isFinished()) {
|
||||||
double[] reference = ((MOCCOChooseReferencePoint)tmpP).getReferencePoint();
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (java.lang.InterruptedException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
double[] reference = ((MOCCOChooseReferencePoint) tmpP).getReferencePoint();
|
||||||
this.updateStatus("Reference Point Parameterization...", 90);
|
this.updateStatus("Reference Point Parameterization...", 90);
|
||||||
tmpP = new MOCCOParameterizeRefPoint(this);
|
tmpP = new MOCCOParameterizeRefPoint(this);
|
||||||
((MOCCOParameterizeRefPoint)tmpP).setReferencePoint(reference);
|
((MOCCOParameterizeRefPoint) tmpP).setReferencePoint(reference);
|
||||||
tmpP.initProcessElementParametrization();
|
tmpP.initProcessElementParametrization();
|
||||||
while (!tmpP.isFinished()) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { } }
|
while (!tmpP.isFinished()) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (java.lang.InterruptedException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MOCCOChooseMOStrategy.STRATEGY_TBCH : {
|
case MOCCOChooseMOStrategy.STRATEGY_TBCH: {
|
||||||
this.updateStatus("Reference Point...", 75);
|
this.updateStatus("Reference Point...", 75);
|
||||||
tmpP = new MOCCOChooseReferencePoint(this);
|
tmpP = new MOCCOChooseReferencePoint(this);
|
||||||
tmpP.initProcessElementParametrization();
|
tmpP.initProcessElementParametrization();
|
||||||
while (!tmpP.isFinished()) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { } }
|
while (!tmpP.isFinished()) {
|
||||||
double[] reference = ((MOCCOChooseReferencePoint)tmpP).getReferencePoint();
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (java.lang.InterruptedException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
double[] reference = ((MOCCOChooseReferencePoint) tmpP).getReferencePoint();
|
||||||
this.updateStatus("Tchebycheff Method Parameterization...", 90);
|
this.updateStatus("Tchebycheff Method Parameterization...", 90);
|
||||||
tmpP = new MOCCOParameterizeTchebycheff(this);
|
tmpP = new MOCCOParameterizeTchebycheff(this);
|
||||||
((MOCCOParameterizeTchebycheff)tmpP).setReferencePoint(reference);
|
((MOCCOParameterizeTchebycheff) tmpP).setReferencePoint(reference);
|
||||||
tmpP.initProcessElementParametrization();
|
tmpP.initProcessElementParametrization();
|
||||||
while (!tmpP.isFinished()) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { } }
|
while (!tmpP.isFinished()) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (java.lang.InterruptedException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MOCCOChooseMOStrategy.STRATEGY_GDF : {
|
case MOCCOChooseMOStrategy.STRATEGY_GDF: {
|
||||||
this.updateStatus("Reference Solution...", 75);
|
this.updateStatus("Reference Solution...", 75);
|
||||||
tmpP = new MOCCOChooseReferenceSolution(this);
|
tmpP = new MOCCOChooseReferenceSolution(this);
|
||||||
tmpP.initProcessElementParametrization();
|
tmpP.initProcessElementParametrization();
|
||||||
while (!tmpP.isFinished()) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { } }
|
while (!tmpP.isFinished()) {
|
||||||
AbstractEAIndividual reference = ((MOCCOChooseReferenceSolution)tmpP).getReferenceSolution();
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (java.lang.InterruptedException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AbstractEAIndividual reference = ((MOCCOChooseReferenceSolution) tmpP).getReferenceSolution();
|
||||||
this.updateStatus("Geoffrion-Dyer-Feinberg Method Parameterization...", 90);
|
this.updateStatus("Geoffrion-Dyer-Feinberg Method Parameterization...", 90);
|
||||||
tmpP = new MOCCOParameterizeGDF(this);
|
tmpP = new MOCCOParameterizeGDF(this);
|
||||||
((MOCCOParameterizeGDF)tmpP).setReferenceSolution(reference);
|
((MOCCOParameterizeGDF) tmpP).setReferenceSolution(reference);
|
||||||
tmpP.initProcessElementParametrization();
|
tmpP.initProcessElementParametrization();
|
||||||
while (!tmpP.isFinished()) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { } }
|
while (!tmpP.isFinished()) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (java.lang.InterruptedException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default : {
|
default: {
|
||||||
tmpP = new MOCCOParameterizeMO(this);
|
tmpP = new MOCCOParameterizeMO(this);
|
||||||
while (!tmpP.isFinished()) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { } }
|
while (!tmpP.isFinished()) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (java.lang.InterruptedException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -218,7 +295,12 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
|||||||
this.updateStatus("SO-Optimizer Parameterization", 66);
|
this.updateStatus("SO-Optimizer Parameterization", 66);
|
||||||
tmpP = new MOCCOParameterizeSO(this);
|
tmpP = new MOCCOParameterizeSO(this);
|
||||||
tmpP.initProcessElementParametrization();
|
tmpP.initProcessElementParametrization();
|
||||||
while (!tmpP.isFinished()) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { } }
|
while (!tmpP.isFinished()) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (java.lang.InterruptedException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// now optimize
|
// now optimize
|
||||||
this.updateStatus("Optimizing...", 0);
|
this.updateStatus("Optimizing...", 0);
|
||||||
@@ -227,27 +309,24 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void checkForObjectives(String w) {
|
private void checkForObjectives(String w) {
|
||||||
System.out.println("I'm currently "+w);
|
System.out.println("I'm currently " + w);
|
||||||
System.out.print("Original Problem is ");
|
System.out.print("Original Problem is ");
|
||||||
if (this.m_State.m_OriginalProblem.isMultiObjective()) {
|
if (this.m_State.m_OriginalProblem.isMultiObjective()) {
|
||||||
System.out.println("multi-objective.");
|
System.out.println("multi-objective.");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
System.out.println("single-objective.");
|
System.out.println("single-objective.");
|
||||||
}
|
}
|
||||||
System.out.print("Current Problem is ");
|
System.out.print("Current Problem is ");
|
||||||
if (this.m_State.m_CurrentProblem.isMultiObjective()) {
|
if (this.m_State.m_CurrentProblem.isMultiObjective()) {
|
||||||
System.out.println("multi-objective.");
|
System.out.println("multi-objective.");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
System.out.println("single-objective.");
|
System.out.println("single-objective.");
|
||||||
}
|
}
|
||||||
if (this.m_State.m_BackupProblem != null) {
|
if (this.m_State.m_BackupProblem != null) {
|
||||||
System.out.print("Backup Problem is ");
|
System.out.print("Backup Problem is ");
|
||||||
if (this.m_State.m_BackupProblem.isMultiObjective()) {
|
if (this.m_State.m_BackupProblem.isMultiObjective()) {
|
||||||
System.out.println("multi-objective.");
|
System.out.println("multi-objective.");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
System.out.println("single-objective.");
|
System.out.println("single-objective.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -257,30 +336,30 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
|||||||
|
|
||||||
private void checktForMOSO(String w) {
|
private void checktForMOSO(String w) {
|
||||||
String s;
|
String s;
|
||||||
System.out.println("I'm currently at "+w);
|
System.out.println("I'm currently at " + w);
|
||||||
InterfaceMOSOConverter moso = ((AbstractMultiObjectiveOptimizationProblem)this.m_State.m_CurrentProblem).getMOSOConverter();
|
InterfaceMOSOConverter moso = ((AbstractMultiObjectiveOptimizationProblem) this.m_State.m_CurrentProblem).getMOSOConverter();
|
||||||
System.out.println("MOSO selected: "+moso.getName());
|
System.out.println("MOSO selected: " + moso.getName());
|
||||||
InterfaceOptimizationObjective[] obj = ((InterfaceMultiObjectiveDeNovoProblem)this.m_State.m_CurrentProblem).getProblemObjectives();
|
InterfaceOptimizationObjective[] obj = ((InterfaceMultiObjectiveDeNovoProblem) this.m_State.m_CurrentProblem).getProblemObjectives();
|
||||||
s = "Objectives: {";
|
s = "Objectives: {";
|
||||||
for (int i = 0; i < obj.length; i++) {
|
for (int i = 0; i < obj.length; i++) {
|
||||||
s += obj[i].getIdentName();
|
s += obj[i].getIdentName();
|
||||||
if (i < (obj.length-1)) {
|
if (i < (obj.length - 1)) {
|
||||||
s += "; ";
|
s += "; ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s += "}";
|
s += "}";
|
||||||
System.out.println(""+s);
|
System.out.println("" + s);
|
||||||
if (moso instanceof MOSOWeightedFitness) {
|
if (moso instanceof MOSOWeightedFitness) {
|
||||||
PropertyDoubleArray prop = ((MOSOWeightedFitness)moso).getWeights();
|
PropertyDoubleArray prop = ((MOSOWeightedFitness) moso).getWeights();
|
||||||
s = "Weights : {";
|
s = "Weights : {";
|
||||||
for (int i = 0; i < prop.getNumRows(); i++) {
|
for (int i = 0; i < prop.getNumRows(); i++) {
|
||||||
s += prop.getValue(i,0);
|
s += prop.getValue(i, 0);
|
||||||
if (i < (prop.getNumRows()-1)) {
|
if (i < (prop.getNumRows() - 1)) {
|
||||||
s += "; ";
|
s += "; ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s += "}";
|
s += "}";
|
||||||
System.out.println(""+s);
|
System.out.println("" + s);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -318,7 +397,8 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
|||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
/** This is the main method
|
/**
|
||||||
|
* This is the main method
|
||||||
*
|
*
|
||||||
* @param args
|
* @param args
|
||||||
*/
|
*/
|
||||||
@@ -337,8 +417,8 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
|||||||
if (go.m_State.m_Optimizer.getPopulation().getFunctionCalls() == 0) {
|
if (go.m_State.m_Optimizer.getPopulation().getFunctionCalls() == 0) {
|
||||||
// start to optimize
|
// start to optimize
|
||||||
go.startExperiment();
|
go.startExperiment();
|
||||||
file = file.replaceAll(".ser","");
|
file = file.replaceAll(".ser", "");
|
||||||
go.saveObject(file+"_Finished.ser");
|
go.saveObject(file + "_Finished.ser");
|
||||||
} else {
|
} else {
|
||||||
// start GUI
|
// start GUI
|
||||||
go.initMOCCOFrame();
|
go.initMOCCOFrame();
|
||||||
@@ -347,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
|
* @return The new state of MOCO
|
||||||
*/
|
*/
|
||||||
public Object openObject(String loadFrom) {
|
public Object openObject(String loadFrom) {
|
||||||
File selected = new File(loadFrom);
|
File selected = new File(loadFrom);
|
||||||
try {
|
try {
|
||||||
ObjectInputStream oi = new ObjectInputStream(new BufferedInputStream(new FileInputStream(selected)));
|
ObjectInputStream oi = new ObjectInputStream(new BufferedInputStream(new FileInputStream(selected)));
|
||||||
Object obj = oi.readObject();
|
Object obj = oi.readObject();
|
||||||
oi.close();
|
oi.close();
|
||||||
if (!(obj instanceof MOCCOState)) {
|
if (!(obj instanceof MOCCOState)) {
|
||||||
throw new Exception("Object not of type MOCCOState");
|
throw new Exception("Object not of type MOCCOState");
|
||||||
} return obj;
|
}
|
||||||
} catch (Exception ex) {
|
return obj;
|
||||||
|
} catch (Exception ex) {
|
||||||
if (this.m_JFrame != null) {
|
if (this.m_JFrame != null) {
|
||||||
JOptionPane.showMessageDialog(this.m_JFrame, "Couldn't read object: " + selected.getName() + "\n" + ex.getMessage(), "Open object file", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(this.m_JFrame, "Couldn't read object: " + selected.getName() + "\n" + ex.getMessage(), "Open object file", JOptionPane.ERROR_MESSAGE);
|
||||||
}
|
} else {
|
||||||
else {
|
System.out.println("Couldn't read object: " + selected.getName() + "\n" + ex.getMessage());
|
||||||
System.out.println("Couldn't read object: " + selected.getName() + "\n" + ex.getMessage());
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method saves the current MOCOData into a serialized file
|
/**
|
||||||
* @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) {
|
public void saveObject(String saveAs) {
|
||||||
File sFile = new File(saveAs);
|
File sFile = new File(saveAs);
|
||||||
try {
|
try {
|
||||||
ObjectOutputStream oo = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(sFile)));
|
ObjectOutputStream oo = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(sFile)));
|
||||||
oo.writeObject(this.m_State);
|
oo.writeObject(this.m_State);
|
||||||
oo.close();
|
oo.close();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
if (this.m_JFrame != null) {
|
if (this.m_JFrame != null) {
|
||||||
JOptionPane.showMessageDialog(this.m_JFrame, "Couldn't write to file: " + sFile.getName() + "\n" + ex.getMessage(), "Save object", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(this.m_JFrame, "Couldn't write to file: " + sFile.getName() + "\n" + ex.getMessage(), "Save object", JOptionPane.ERROR_MESSAGE);
|
||||||
}
|
} else {
|
||||||
else {
|
System.out.println("Couldn't write to file: " + sFile.getName() + "\n" + ex.getMessage());
|
||||||
System.out.println("Couldn't write to file: " + sFile.getName() + "\n" + ex.getMessage());
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************************************
|
/***********************************************************************************************
|
||||||
* InterfaceGOStandalone
|
* InterfaceGOStandalone
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** This method starts the actual optimization procedure
|
/**
|
||||||
|
* This method starts the actual optimization procedure
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void startExperiment() {
|
public void startExperiment() {
|
||||||
@@ -403,7 +487,7 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
|||||||
this.m_StillWorking = true;
|
this.m_StillWorking = true;
|
||||||
this.m_State.m_Optimizer.setProblem(this.m_State.m_CurrentProblem);
|
this.m_State.m_Optimizer.setProblem(this.m_State.m_CurrentProblem);
|
||||||
if (this.m_Debug) {
|
if (this.m_Debug) {
|
||||||
System.out.println(""+this.m_State.m_Optimizer.getStringRepresentation());
|
System.out.println("" + this.m_State.m_Optimizer.getStringRepresentation());
|
||||||
}
|
}
|
||||||
this.m_State.m_CurrentProblem.evaluate(this.m_State.m_Optimizer.getPopulation());
|
this.m_State.m_CurrentProblem.evaluate(this.m_State.m_Optimizer.getPopulation());
|
||||||
this.m_State.m_Optimizer.getPopulation().SetFunctionCalls(0);
|
this.m_State.m_Optimizer.getPopulation().SetFunctionCalls(0);
|
||||||
@@ -416,11 +500,12 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
|||||||
public Object construct() {
|
public Object construct() {
|
||||||
return doWork();
|
return doWork();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void finished() {
|
public void finished() {
|
||||||
Population[] pop = null;
|
Population[] pop = null;
|
||||||
if (m_State.m_Optimizer instanceof IslandModelEA) {
|
if (m_State.m_Optimizer instanceof IslandModelEA) {
|
||||||
InterfaceOptimizer[] opt = ((IslandModelEA)m_State.m_Optimizer).getOptimizers();
|
InterfaceOptimizer[] opt = ((IslandModelEA) m_State.m_Optimizer).getOptimizers();
|
||||||
pop = new Population[opt.length];
|
pop = new Population[opt.length];
|
||||||
for (int i = 0; i < opt.length; i++) {
|
for (int i = 0; i < opt.length; i++) {
|
||||||
pop[i] = opt[i].getPopulation();
|
pop[i] = opt[i].getPopulation();
|
||||||
@@ -444,7 +529,8 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
|||||||
worker.start();
|
worker.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** When the worker needs to update the GUI we do so by queuing
|
/**
|
||||||
|
* When the worker needs to update the GUI we do so by queuing
|
||||||
* a Runnable for the event dispatching thread with
|
* a Runnable for the event dispatching thread with
|
||||||
* SwingUtilities.invokeLater(). In this case we're just
|
* SwingUtilities.invokeLater(). In this case we're just
|
||||||
* changing the progress bars value.
|
* changing the progress bars value.
|
||||||
@@ -462,7 +548,8 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
|||||||
this.m_CurrentState.setText(t);
|
this.m_CurrentState.setText(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method represents the application code that we'd like to
|
/**
|
||||||
|
* This method represents the application code that we'd like to
|
||||||
* run on a separate thread. It simulates slowly computing
|
* run on a separate thread. It simulates slowly computing
|
||||||
* a value, in this case just a string 'All Done'. It updates the
|
* a value, in this case just a string 'All Done'. It updates the
|
||||||
* progress bar every half second to remind the user that
|
* progress bar every half second to remind the user that
|
||||||
@@ -480,8 +567,7 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
|||||||
this.m_State.m_Optimizer.optimize();
|
this.m_State.m_Optimizer.optimize();
|
||||||
}
|
}
|
||||||
System.gc();
|
System.gc();
|
||||||
}
|
} catch (InterruptedException e) {
|
||||||
catch (InterruptedException e) {
|
|
||||||
updateStatus("Interrupted", 0);
|
updateStatus("Interrupted", 0);
|
||||||
return "Interrupted";
|
return "Interrupted";
|
||||||
}
|
}
|
||||||
@@ -497,27 +583,29 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
|||||||
/***********************************************************************************************
|
/***********************************************************************************************
|
||||||
* InterfacePopulationChangedEventListener
|
* InterfacePopulationChangedEventListener
|
||||||
*/
|
*/
|
||||||
/** This method allows an optimizer to register a change in the optimizer.
|
/**
|
||||||
* @param source The source of the event.
|
* This method allows an optimizer to register a change in the optimizer.
|
||||||
* @param name Could be used to indicate the nature of the event.
|
*
|
||||||
|
* @param source The source of the event.
|
||||||
|
* @param name Could be used to indicate the nature of the event.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void registerPopulationStateChanged(Object source, String name) {
|
public void registerPopulationStateChanged(Object source, String name) {
|
||||||
int currentProgress;
|
int currentProgress;
|
||||||
if (name.equals(Population.nextGenerationPerformed)) {
|
if (name.equals(Population.nextGenerationPerformed)) {
|
||||||
if (this.m_State.isVisible) {
|
if (this.m_State.isVisible) {
|
||||||
Population population = ((InterfaceOptimizer)source).getPopulation();
|
Population population = ((InterfaceOptimizer) source).getPopulation();
|
||||||
double x = 100;
|
double x = 100;
|
||||||
if (this.m_State.m_Terminator instanceof EvaluationTerminator) {
|
if (this.m_State.m_Terminator instanceof EvaluationTerminator) {
|
||||||
double y = x/(double)((EvaluationTerminator)this.m_State.m_Terminator).getFitnessCalls();
|
double y = x / (double) ((EvaluationTerminator) this.m_State.m_Terminator).getFitnessCalls();
|
||||||
currentProgress = (int)(population.getFunctionCalls()*y);
|
currentProgress = (int) (population.getFunctionCalls() * y);
|
||||||
} else {
|
} else {
|
||||||
currentProgress = (int)(0);
|
currentProgress = (int) (0);
|
||||||
}
|
}
|
||||||
updateStatus("Optimizing...",currentProgress);
|
updateStatus("Optimizing...", currentProgress);
|
||||||
} else {
|
} else {
|
||||||
// perhaps i could write it to file!?
|
// perhaps i could write it to file!?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
package eva2.optimization.go;
|
package eva2.optimization.go;
|
||||||
|
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -6,11 +7,11 @@ import javax.swing.SwingUtilities;
|
|||||||
* SwingWorker 3), an abstract class that you subclass to
|
* SwingWorker 3), an abstract class that you subclass to
|
||||||
* perform GUI-related work in a dedicated thread. For
|
* perform GUI-related work in a dedicated thread. For
|
||||||
* instructions on using this class, see:
|
* instructions on using this class, see:
|
||||||
*
|
* <p/>
|
||||||
* http://java.sun.com/products/jfc/tsc/articles/threads/threads2.html
|
* http://java.sun.com/products/jfc/tsc/articles/threads/threads2.html
|
||||||
* or
|
* or
|
||||||
* http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html
|
* http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html
|
||||||
*
|
* <p/>
|
||||||
* Note that the API changed slightly in the 3rd version:
|
* Note that the API changed slightly in the 3rd version:
|
||||||
* You must now invoke start() on the SwingWorker after
|
* You must now invoke start() on the SwingWorker after
|
||||||
* creating it.
|
* creating it.
|
||||||
@@ -20,36 +21,45 @@ public abstract class SwingWorker {
|
|||||||
private Object value; // see getValue(), setValue()
|
private Object value; // see getValue(), setValue()
|
||||||
private Thread thread;
|
private Thread thread;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to maintain reference to current worker thread
|
* Class to maintain reference to current worker thread
|
||||||
* under separate synchronization control.
|
* under separate synchronization control.
|
||||||
*/
|
*/
|
||||||
private static class ThreadVar {
|
private static class ThreadVar {
|
||||||
private Thread thread;
|
private Thread thread;
|
||||||
ThreadVar(Thread t) { thread = t; }
|
|
||||||
synchronized Thread get() { return thread; }
|
ThreadVar(Thread t) {
|
||||||
synchronized void clear() { thread = null; }
|
thread = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized Thread get() {
|
||||||
|
return thread;
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized void clear() {
|
||||||
|
thread = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ThreadVar threadVar;
|
private ThreadVar threadVar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
* hasn't been constructed yet.
|
||||||
*/
|
*/
|
||||||
protected synchronized Object getValue() {
|
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) {
|
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();
|
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
|
* Returns null if either the constructing thread or the current
|
||||||
* thread was interrupted before a value was produced.
|
* thread was interrupted before a value was produced.
|
||||||
*
|
*
|
||||||
* @return the value created by the <code>construct</code> method
|
* @return the value created by the <code>construct</code> method
|
||||||
*/
|
*/
|
||||||
public Object get() {
|
public Object get() {
|
||||||
while (true) {
|
while (true) {
|
||||||
Thread t = threadVar.get();
|
Thread t = threadVar.get();
|
||||||
if (t == null) {
|
if (t == null) {
|
||||||
return getValue();
|
return getValue();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
t.join();
|
t.join();
|
||||||
}
|
} catch (InterruptedException e) {
|
||||||
catch (InterruptedException e) {
|
|
||||||
Thread.currentThread().interrupt(); // propagate
|
Thread.currentThread().interrupt(); // propagate
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -90,7 +99,9 @@ public abstract class SwingWorker {
|
|||||||
public SwingWorker() {
|
public SwingWorker() {
|
||||||
final Runnable doFinished = new Runnable() {
|
final Runnable doFinished = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() { finished(); }
|
public void run() {
|
||||||
|
finished();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Runnable doConstruct = new Runnable() {
|
Runnable doConstruct = new Runnable() {
|
||||||
@@ -98,8 +109,7 @@ public abstract class SwingWorker {
|
|||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
setValue(construct());
|
setValue(construct());
|
||||||
}
|
} finally {
|
||||||
finally {
|
|
||||||
threadVar.clear();
|
threadVar.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,9 +14,11 @@ import eva2.optimization.population.Population;
|
|||||||
import eva2.optimization.problems.InterfaceOptimizationProblem;
|
import eva2.optimization.problems.InterfaceOptimizationProblem;
|
||||||
import eva2.tools.EVAERROR;
|
import eva2.tools.EVAERROR;
|
||||||
import eva2.tools.math.RNG;
|
import eva2.tools.math.RNG;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/** This is the abstract EA individual implementing the most important methods giving
|
/**
|
||||||
|
* This is the abstract EA individual implementing the most important methods giving
|
||||||
* access to mutation and crossover rates and operators, fitness values and selection
|
* access to mutation and crossover rates and operators, fitness values and selection
|
||||||
* probabilities. All EA individuals should typically extend this abstract EA individual.
|
* probabilities. All EA individuals should typically extend this abstract EA individual.
|
||||||
* In that case the EA individuals only implement the genotype and phenotype interfaces.
|
* In that case the EA individuals only implement the genotype and phenotype interfaces.
|
||||||
@@ -44,7 +46,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
|||||||
private double constraintViolation = 0;
|
private double constraintViolation = 0;
|
||||||
public boolean areaConst4ParallelViolated = false; // no idea what felix used this for...
|
public boolean areaConst4ParallelViolated = false; // no idea what felix used this for...
|
||||||
public boolean isMarked = false; // is for GUI only!
|
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[] selectionProbability = new double[1];
|
||||||
|
|
||||||
protected double crossoverProbability = 1.0;
|
protected double crossoverProbability = 1.0;
|
||||||
@@ -249,6 +251,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
|||||||
// public String getIndividualName() {
|
// public String getIndividualName() {
|
||||||
// return this.m_Name;
|
// return this.m_Name;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is used when a new offspring is created the increment the
|
* This method is used when a new offspring is created the increment the
|
||||||
* name.
|
* name.
|
||||||
@@ -307,6 +310,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
|||||||
// return false;
|
// return false;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method will allow a default initialisation of the individual
|
* This method will allow a default initialisation of the individual
|
||||||
*
|
*
|
||||||
@@ -385,6 +389,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
|||||||
// public void setLogHeritagetLen(int logLen) {
|
// public void setLogHeritagetLen(int logLen) {
|
||||||
// logParentLen = logLen;
|
// logParentLen = logLen;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an ancestor generation with multiple parents.
|
* Add an ancestor generation with multiple parents.
|
||||||
*
|
*
|
||||||
@@ -446,6 +451,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
|||||||
// heritage.add(parentIDs);
|
// heritage.add(parentIDs);
|
||||||
//// if (heritage.size() > logParentLen) heritage.remove(0);
|
//// if (heritage.size() > logParentLen) heritage.remove(0);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an ancestor generation with only one parent.
|
* Add an ancestor generation with only one parent.
|
||||||
*
|
*
|
||||||
@@ -468,6 +474,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
|||||||
// if (heritage != null) return heritage.getLast();
|
// if (heritage != null) return heritage.getLast();
|
||||||
// else return null;
|
// else return null;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method will allow you to get the current age of an individual Zero
|
* This method will allow you to get the current age of an individual Zero
|
||||||
* means it has not even been evaluated.
|
* means it has not even been evaluated.
|
||||||
@@ -627,7 +634,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
|||||||
/**
|
/**
|
||||||
* This method allows you to set the i-th fitness value
|
* 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.
|
* @param fitness The new fitness value.
|
||||||
*/
|
*/
|
||||||
public void SetFitness(int index, double fitness) {
|
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.
|
* @param indy The individual to compare to.
|
||||||
* @return 1 if the instance is better (regarding constraints only), -1 if
|
* @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) {
|
public int compareConstraintViolation(AbstractEAIndividual indy) {
|
||||||
if ((this.constraintViolation > 0) && (indy.constraintViolation <= 0)) {
|
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
|
* This method allows you to set the i-th selection probability value
|
||||||
*
|
*
|
||||||
* @param index The index of the selection probability value to set.
|
* @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) {
|
public void SetSelectionProbability(int index, double sel) {
|
||||||
if (this.selectionProbability.length > index) {
|
if (this.selectionProbability.length > index) {
|
||||||
@@ -998,7 +1005,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
|||||||
* name.
|
* name.
|
||||||
*
|
*
|
||||||
* @param name The identifying 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) {
|
public void putData(String name, Object obj) {
|
||||||
dataHash.put(name, obj);
|
dataHash.put(name, obj);
|
||||||
@@ -1010,7 +1017,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
|||||||
* fitness array.
|
* fitness array.
|
||||||
*
|
*
|
||||||
* @param name The name of the requested Object
|
* @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) {
|
public Object getData(String name) {
|
||||||
// if (name.equalsIgnoreCase("SelectionProbability")) return this.getSelectionProbability();
|
// 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
|
* @return true if parent history logging is activated
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
protected boolean isLogParents() {
|
protected boolean isLogParents() {
|
||||||
return logParents;
|
return logParents;
|
||||||
@@ -1309,7 +1315,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
|||||||
return (IndividualInterface) this.clone();
|
return (IndividualInterface) this.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
// /** This method is used to get the basic data type of an individual double[].
|
// /** This method is used to get the basic data type of an individual double[].
|
||||||
// * @deprecated Since not all EAIndividuals provide double as basic data type
|
// * @deprecated Since not all EAIndividuals provide double as basic data type
|
||||||
// * the fitness can be is returned as default value.
|
// * the fitness can be is returned as default value.
|
||||||
// * @see #getFitness()
|
// * @see #getFitness()
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user