Removed unused classes (dating back to < 2007..)
This commit is contained in:
parent
a08655a60f
commit
049304e9c1
@ -1,108 +0,0 @@
|
|||||||
package eva2.gui;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.event.ItemEvent;
|
|
||||||
import java.awt.event.ItemListener;
|
|
||||||
import java.beans.PropertyChangeSupport;
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class PropertySheetPanelStat extends JPanel implements Serializable {
|
|
||||||
private Object[] values;
|
|
||||||
private JCheckBoxFlag[] views;
|
|
||||||
private JLabel[] labels;
|
|
||||||
private boolean[] flags;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates the property sheet panel.
|
|
||||||
*/
|
|
||||||
public PropertySheetPanelStat() {
|
|
||||||
setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A support object for handling property change listeners
|
|
||||||
*/
|
|
||||||
private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
|
|
||||||
|
|
||||||
public synchronized void setTarget(String[] names, boolean[] flag) {
|
|
||||||
int componentOffset = 0;
|
|
||||||
// Close any child windows at this point
|
|
||||||
removeAll();
|
|
||||||
GridBagLayout gbLayout = new GridBagLayout();
|
|
||||||
setLayout(gbLayout);
|
|
||||||
setVisible(false);
|
|
||||||
|
|
||||||
values = new Object[flag.length];
|
|
||||||
views = new JCheckBoxFlag[flag.length];
|
|
||||||
labels = new JLabel[names.length];
|
|
||||||
|
|
||||||
for (int i = 0; i < names.length; i++) {
|
|
||||||
labels[i] = new JLabel(names[i], SwingConstants.RIGHT);
|
|
||||||
labels[i].setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 5));
|
|
||||||
views[i] = new JCheckBoxFlag(flag[i]);
|
|
||||||
GridBagConstraints gbConstraints = new GridBagConstraints();
|
|
||||||
gbConstraints.anchor = GridBagConstraints.EAST;
|
|
||||||
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
|
|
||||||
gbConstraints.gridy = i + componentOffset;
|
|
||||||
gbConstraints.gridx = 0;
|
|
||||||
gbLayout.setConstraints(labels[i], gbConstraints);
|
|
||||||
add(labels[i]);
|
|
||||||
JPanel newPanel = new JPanel();
|
|
||||||
newPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 10));
|
|
||||||
|
|
||||||
newPanel.setLayout(new BorderLayout());
|
|
||||||
newPanel.add(views[i], BorderLayout.CENTER);
|
|
||||||
gbConstraints = new GridBagConstraints();
|
|
||||||
gbConstraints.anchor = GridBagConstraints.WEST;
|
|
||||||
gbConstraints.fill = GridBagConstraints.BOTH;
|
|
||||||
gbConstraints.gridy = i + componentOffset;
|
|
||||||
gbConstraints.gridx = 1;
|
|
||||||
gbConstraints.weightx = 100;
|
|
||||||
gbLayout.setConstraints(newPanel, gbConstraints);
|
|
||||||
add(newPanel);
|
|
||||||
}
|
|
||||||
validate();
|
|
||||||
setVisible(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public boolean[] getState() {
|
|
||||||
boolean[] ret = new boolean[this.views.length];
|
|
||||||
for (int i = 0; i < ret.length; i++) {
|
|
||||||
ret[i] = views[i].isSelected();
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class JCheckBoxFlag extends JCheckBox {
|
|
||||||
|
|
||||||
private boolean flag = true;
|
|
||||||
|
|
||||||
public JCheckBoxFlag(boolean flag) {
|
|
||||||
super();
|
|
||||||
this.flag = flag;
|
|
||||||
addItemListener(new ItemListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void itemStateChanged(ItemEvent evt) {
|
|
||||||
if (evt.getStateChange() == ItemEvent.SELECTED) {
|
|
||||||
JCheckBoxFlag.this.flag = true;
|
|
||||||
}
|
|
||||||
if (evt.getStateChange() == ItemEvent.DESELECTED) {
|
|
||||||
JCheckBoxFlag.this.flag = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,149 +0,0 @@
|
|||||||
package eva2.gui.editor;
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
import eva2.gui.PropertySheetPanelStat;
|
|
||||||
import eva2.optimization.statistics.GenericStatistics;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.beans.PropertyChangeEvent;
|
|
||||||
import java.beans.PropertyChangeListener;
|
|
||||||
import java.beans.PropertyChangeSupport;
|
|
||||||
import java.beans.PropertyEditor;
|
|
||||||
|
|
||||||
public class StatisticsEditor implements PropertyEditor {
|
|
||||||
|
|
||||||
private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
|
|
||||||
private PropertySheetPanelStat statPanel;
|
|
||||||
private JScrollPane scrollPane;
|
|
||||||
private JPanel panel;
|
|
||||||
private GenericStatistics statistics;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public StatisticsEditor() {
|
|
||||||
super();
|
|
||||||
statPanel = new PropertySheetPanelStat();
|
|
||||||
statPanel.addPropertyChangeListener(
|
|
||||||
new PropertyChangeListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void propertyChange(PropertyChangeEvent evt) {
|
|
||||||
propertyChangeSupport.firePropertyChange("", null, null);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
scrollPane = new JScrollPane(statPanel);
|
|
||||||
panel = new JPanel();
|
|
||||||
panel.setLayout(new BorderLayout());
|
|
||||||
|
|
||||||
panel.add(scrollPane, BorderLayout.CENTER);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setValue(Object value) {
|
|
||||||
if (value instanceof GenericStatistics) {
|
|
||||||
statistics = (GenericStatistics) value;
|
|
||||||
statPanel.setTarget(statistics.getPropertyNames(), statistics.getState());
|
|
||||||
}
|
|
||||||
propertyChangeSupport.firePropertyChange("", null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Object getValue() {
|
|
||||||
System.out.println("getValue !!!!!!!!!!!!");
|
|
||||||
statistics.setState(statPanel.getState());
|
|
||||||
return statistics;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String getJavaInitializationString() {
|
|
||||||
return "null";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean isPaintable() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void paintValue(Graphics gfx, Rectangle box) {
|
|
||||||
FontMetrics fm = gfx.getFontMetrics();
|
|
||||||
int vpad = (box.height - fm.getAscent()) / 2;
|
|
||||||
gfx.drawString("StatisticeEditor", 2, fm.getHeight() + vpad - 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String getAsText() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setAsText(String text) throws IllegalArgumentException {
|
|
||||||
throw new IllegalArgumentException(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String[] getTags() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean supportsCustomEditor() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Component getCustomEditor() {
|
|
||||||
return panel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
|
||||||
if (propertyChangeSupport == null) {
|
|
||||||
propertyChangeSupport = new PropertyChangeSupport(this);
|
|
||||||
}
|
|
||||||
propertyChangeSupport.addPropertyChangeListener(l);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
|
||||||
if (propertyChangeSupport == null) {
|
|
||||||
propertyChangeSupport = new PropertyChangeSupport(this);
|
|
||||||
}
|
|
||||||
propertyChangeSupport.removePropertyChangeListener(l);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,184 +0,0 @@
|
|||||||
package eva2.optimization.statistics;
|
|
||||||
|
|
||||||
|
|
||||||
import eva2.gui.plot.DataViewer;
|
|
||||||
import eva2.gui.plot.DataViewerInterface;
|
|
||||||
import eva2.gui.plot.Graph;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class GenericStatistics implements Serializable {
|
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(GenericStatistics.class.getName());
|
|
||||||
private int test;
|
|
||||||
private String[] propertyNames;
|
|
||||||
private boolean[] states;
|
|
||||||
private transient Field[] fields;
|
|
||||||
private DataViewerInterface viewer;
|
|
||||||
private Graph graph;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public GenericStatistics getClone() {
|
|
||||||
return new GenericStatistics(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private GenericStatistics(GenericStatistics Source) {
|
|
||||||
test = Source.test;
|
|
||||||
propertyNames = Source.propertyNames;
|
|
||||||
states = Source.states;
|
|
||||||
fields = Source.fields;
|
|
||||||
viewer = Source.viewer;
|
|
||||||
graph = Source.graph;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public GenericStatistics(Object target) {
|
|
||||||
try {
|
|
||||||
fields = getDeclaredFields(target);
|
|
||||||
propertyNames = new String[fields.length];
|
|
||||||
states = new boolean[fields.length];
|
|
||||||
for (int i = 0; i < fields.length; i++) {
|
|
||||||
String desc = fields[i].toString(); //System.out.println("desc "+desc);
|
|
||||||
int isTransient = desc.indexOf("transient");
|
|
||||||
Object FieldValue = null;
|
|
||||||
if (isTransient == -1 || fields[i].getName().equals("elementData")) { // the elementdatahack
|
|
||||||
fields[i].setAccessible(true);
|
|
||||||
FieldValue = fields[i].get(target);
|
|
||||||
}
|
|
||||||
propertyNames[i] = fields[i].getName();
|
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
|
||||||
LOGGER.severe("GenericStatistics:" + ex.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public void setTest(int Test) {
|
|
||||||
test = Test;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public int getTest() {
|
|
||||||
return test;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public String[] getPropertyNames() {
|
|
||||||
return propertyNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public boolean[] getState() {
|
|
||||||
return states;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public void setState(boolean[] x) {
|
|
||||||
states = x;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public void initViewer() {
|
|
||||||
viewer = DataViewer.getInstance("test");
|
|
||||||
graph = viewer.getNewGraph("test");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public Field[] getDeclaredFields(Object target) {
|
|
||||||
Field[] ret_1 = target.getClass().getSuperclass().getDeclaredFields();
|
|
||||||
Field[] ret_2 = target.getClass().getDeclaredFields();
|
|
||||||
Field[] ret = new Field[ret_1.length + ret_2.length];
|
|
||||||
int index = 0;
|
|
||||||
for (int i = 0; i < ret_1.length; i++) {
|
|
||||||
ret[index] = ret_1[i];
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
for (int i = 0; i < ret_2.length; i++) {
|
|
||||||
ret[index] = ret_2[i];
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public void statechanged(Object target) {
|
|
||||||
int len = 0;
|
|
||||||
for (int i = 0; i < states.length; i++) {
|
|
||||||
if (states[i]) {
|
|
||||||
len++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (len == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (viewer == null) {
|
|
||||||
initViewer();
|
|
||||||
}
|
|
||||||
double[] data = new double[len];
|
|
||||||
try {
|
|
||||||
fields = getDeclaredFields(target);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
LOGGER.severe("ERROR in GenericStatistics:" + ex.getMessage());
|
|
||||||
}
|
|
||||||
int index = 0;
|
|
||||||
for (int i = 0; i < fields.length; i++) {
|
|
||||||
for (int n = 0; n < propertyNames.length; n++) {
|
|
||||||
if (!this.states[n]) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (fields[i].getName().equals(propertyNames[n])) {
|
|
||||||
String desc = fields[i].toString();
|
|
||||||
int isTransient = desc.indexOf("transient");
|
|
||||||
|
|
||||||
Object fieldValue = null;
|
|
||||||
if (isTransient == -1 || fields[i].getName().equals("elementData")) { // the elementdatahack
|
|
||||||
fields[i].setAccessible(true);
|
|
||||||
try {
|
|
||||||
fieldValue = fields[i].get(target);
|
|
||||||
if (fieldValue instanceof Double) {
|
|
||||||
data[index] = (Double) fieldValue;
|
|
||||||
}
|
|
||||||
if (fieldValue instanceof Integer) {
|
|
||||||
data[index] = ((Integer) fieldValue).doubleValue();
|
|
||||||
}
|
|
||||||
index++;
|
|
||||||
} catch (Exception ex) {
|
|
||||||
LOGGER.severe("ERROR in GenericStatistics:" + ex.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
graph.setConnectedPoint(data[1], data[0]);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user