FunctionArea may now plot circles easily. The FLensProblemViewer seems to be cured.
This commit is contained in:
@@ -3,6 +3,7 @@ package eva2;
|
|||||||
/**
|
/**
|
||||||
* Main product and version information strings.
|
* Main product and version information strings.
|
||||||
*
|
*
|
||||||
|
* 2.025: FunctionArea may now plot circles easily. The FLensProblemViewer seems to be cured.
|
||||||
* 2.024: Cleaned up AbstractGOParams, deactivated parent logging (saving memory)
|
* 2.024: Cleaned up AbstractGOParams, deactivated parent logging (saving memory)
|
||||||
* 2.023: Cleaned up the PF strategy
|
* 2.023: Cleaned up the PF strategy
|
||||||
* 2.022: Some changes to the SimpleProblemWrapper, not of great interest. However,
|
* 2.022: Some changes to the SimpleProblemWrapper, not of great interest. However,
|
||||||
@@ -14,7 +15,7 @@ package eva2;
|
|||||||
public class EvAInfo {
|
public class EvAInfo {
|
||||||
public static final String productName = "EvA 2";
|
public static final String productName = "EvA 2";
|
||||||
public static final String productLongName = "Evolutionary Algorithms Workbench 2";
|
public static final String productLongName = "Evolutionary Algorithms Workbench 2";
|
||||||
public static final String versionNum = new String ("2.024");
|
public static final String versionNum = new String ("2.025");
|
||||||
public static final String url = "http://www.ra.cs.uni-tuebingen.de/software/EvA2";
|
public static final String url = "http://www.ra.cs.uni-tuebingen.de/software/EvA2";
|
||||||
|
|
||||||
public static final String propertyFile = "resources/EvA2.props";
|
public static final String propertyFile = "resources/EvA2.props";
|
||||||
|
@@ -16,6 +16,7 @@ public class Chart2DDPointIconText implements DPointIcon {
|
|||||||
|
|
||||||
private DPointIcon m_Icon = new Chart2DDPointIconCross();
|
private DPointIcon m_Icon = new Chart2DDPointIconCross();
|
||||||
private String m_Text = " ";
|
private String m_Text = " ";
|
||||||
|
private Color m_Color;
|
||||||
|
|
||||||
public Chart2DDPointIconText(String s) {
|
public Chart2DDPointIconText(String s) {
|
||||||
m_Text = s;
|
m_Text = s;
|
||||||
@@ -34,6 +35,7 @@ public class Chart2DDPointIconText implements DPointIcon {
|
|||||||
*/
|
*/
|
||||||
public void paint( Graphics g ){
|
public void paint( Graphics g ){
|
||||||
this.m_Icon.paint(g);
|
this.m_Icon.paint(g);
|
||||||
|
g.setColor(m_Color);
|
||||||
g.drawString(this.m_Text, 4, 4);
|
g.drawString(this.m_Text, 4, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,4 +48,13 @@ public class Chart2DDPointIconText implements DPointIcon {
|
|||||||
public DBorder getDBorder() {
|
public DBorder getDBorder() {
|
||||||
return new DBorder(4, 4, 4, 4);
|
return new DBorder(4, 4, 4, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the color for the text.
|
||||||
|
*
|
||||||
|
* @param col
|
||||||
|
*/
|
||||||
|
public void setColor(Color col) {
|
||||||
|
m_Color = col;
|
||||||
|
}
|
||||||
}
|
}
|
@@ -89,6 +89,50 @@ public class FunctionArea extends DArea implements Serializable {
|
|||||||
notifyNegLog = true;
|
notifyNegLog = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plot a circle icon to the function area which is annotated with a char and
|
||||||
|
* a double value.
|
||||||
|
*
|
||||||
|
* @param c
|
||||||
|
* @param val
|
||||||
|
* @param position
|
||||||
|
*/
|
||||||
|
public void drawCircle(double val, double[] position, int graphID) {
|
||||||
|
drawCircle(""+val, position, graphID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plot a circle icon to the function area which is annotated with a char and
|
||||||
|
* a double value.
|
||||||
|
*
|
||||||
|
* @param c
|
||||||
|
* @param val
|
||||||
|
* @param position
|
||||||
|
* @param graphID
|
||||||
|
*/
|
||||||
|
public void drawCircle(char c, double val, double[] position, int graphID) {
|
||||||
|
drawCircle(c+""+val, position, graphID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plot a circle icon to the function area which is annotated with a char and
|
||||||
|
* a double value. The color corresponds to the color of the graph with given ID
|
||||||
|
*
|
||||||
|
* @param label
|
||||||
|
* @param position
|
||||||
|
* @param graphID
|
||||||
|
*/
|
||||||
|
public void drawCircle(String label, double[] position, int graphID) {
|
||||||
|
DPointSet popRep;
|
||||||
|
popRep = new DPointSet();
|
||||||
|
popRep.addDPoint(new DPoint(position[0], position[1]));
|
||||||
|
DPointIcon icon = new Chart2DDPointIconText(label);
|
||||||
|
((Chart2DDPointIconText)icon).setIcon(new Chart2DDPointIconCircle());
|
||||||
|
((Chart2DDPointIconText)icon).setColor(getGraphPointSet(graphID).getColor());
|
||||||
|
popRep.setIcon(icon);
|
||||||
|
addDElement(popRep);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@@ -40,7 +40,7 @@ public class GraphPointSet {
|
|||||||
private Color m_Color;
|
private Color m_Color;
|
||||||
private DPointIcon m_Icon;
|
private DPointIcon m_Icon;
|
||||||
private int m_CacheIndex = 0;
|
private int m_CacheIndex = 0;
|
||||||
private int m_CacheSize = 1;
|
private int m_CacheSize = 0;
|
||||||
private double [] m_cachex;
|
private double [] m_cachex;
|
||||||
private double [] m_cachey;
|
private double [] m_cachey;
|
||||||
/**
|
/**
|
||||||
|
@@ -13,6 +13,7 @@ package eva2.gui;
|
|||||||
* IMPORTS
|
* IMPORTS
|
||||||
*==========================================================================*/
|
*==========================================================================*/
|
||||||
import java.awt.AWTException;
|
import java.awt.AWTException;
|
||||||
|
import java.awt.Dimension;
|
||||||
import java.awt.FlowLayout;
|
import java.awt.FlowLayout;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.awt.Robot;
|
import java.awt.Robot;
|
||||||
@@ -276,6 +277,13 @@ public class Plot implements PlotInterface, Serializable {
|
|||||||
m_Frame.setVisible(true);
|
m_Frame.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPreferredSize(Dimension prefSize) {
|
||||||
|
if (m_Frame != null) {
|
||||||
|
m_Frame.setPreferredSize(prefSize);
|
||||||
|
m_Frame.pack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if the Plot object is valid.
|
* Return true if the Plot object is valid.
|
||||||
*
|
*
|
||||||
|
@@ -21,9 +21,9 @@ import eva2.tools.EVAERROR;
|
|||||||
/** 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 genotpye and phenotype interfaces.
|
* In that case the EA individuals only implement the genotype and phenotype interfaces.
|
||||||
* The names of the implementation should be build like this:
|
* The names of the implementation should be build like this:
|
||||||
* (Genotpye)Individual(Phenotype)
|
* (Genotype)Individual(Phenotype)
|
||||||
* Thus a binary individual coding double values is named GAIndividualDoubleData and a
|
* Thus a binary individual coding double values is named GAIndividualDoubleData and a
|
||||||
* real-valued individual coding binary values is named ESIndividualBinaryData.
|
* real-valued individual coding binary values is named ESIndividualBinaryData.
|
||||||
* Created by IntelliJ IDEA.
|
* Created by IntelliJ IDEA.
|
||||||
@@ -911,6 +911,10 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
|||||||
else return this.getFitness();
|
else return this.getFitness();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDominantNotEqual(double[] otherFitness) {
|
||||||
|
return isDominatingFitnessNotEqual(m_Fitness, otherFitness);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isDominant(double[] otherFitness) {
|
public boolean isDominant(double[] otherFitness) {
|
||||||
return isDominatingFitness(m_Fitness, otherFitness);
|
return isDominatingFitness(m_Fitness, otherFitness);
|
||||||
}
|
}
|
||||||
|
@@ -1,14 +1,11 @@
|
|||||||
package eva2.server.go.individuals;
|
package eva2.server.go.individuals;
|
||||||
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import wsi.ra.math.RNG;
|
||||||
|
|
||||||
import eva2.server.go.IndividualInterface;
|
|
||||||
import eva2.server.go.operators.crossover.CrossoverESDefault;
|
import eva2.server.go.operators.crossover.CrossoverESDefault;
|
||||||
import eva2.server.go.operators.mutation.InterfaceMutation;
|
import eva2.server.go.operators.mutation.InterfaceMutation;
|
||||||
import eva2.server.go.operators.mutation.MutateESGlobal;
|
import eva2.server.go.operators.mutation.MutateESGlobal;
|
||||||
import eva2.server.go.problems.InterfaceOptimizationProblem;
|
import eva2.server.go.problems.InterfaceOptimizationProblem;
|
||||||
import wsi.ra.math.RNG;
|
|
||||||
|
|
||||||
/** This individual uses a real-valued genotype to code for double values.
|
/** This individual uses a real-valued genotype to code for double values.
|
||||||
* Created by IntelliJ IDEA.
|
* Created by IntelliJ IDEA.
|
||||||
|
@@ -210,7 +210,7 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
|
|||||||
this.firstindex = firstindex;
|
this.firstindex = firstindex;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* AbstractEAIndividual methods
|
* AbstractEAIndividual methods
|
||||||
*/
|
*/
|
||||||
/** This method will allow a default initialisation of the individual
|
/** This method will allow a default initialisation of the individual
|
||||||
@@ -260,7 +260,7 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* InterfaceESIndividual methods
|
* InterfaceESIndividual methods
|
||||||
*/
|
*/
|
||||||
/** This method will allow the user to read the ES 'genotype'
|
/** This method will allow the user to read the ES 'genotype'
|
||||||
@@ -358,7 +358,7 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************************************************************
|
/**********************************************************************************************************************
|
||||||
* These are for GUI
|
* These are for GUI
|
||||||
*/
|
*/
|
||||||
/** This method allows the CommonJavaObjectEditorPanel to read the
|
/** This method allows the CommonJavaObjectEditorPanel to read the
|
||||||
|
@@ -1,31 +1,46 @@
|
|||||||
package eva2.server.go.problems;
|
package eva2.server.go.problems;
|
||||||
|
|
||||||
|
|
||||||
import javax.swing.*;
|
import java.awt.BasicStroke;
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.Rectangle;
|
||||||
|
import java.awt.Shape;
|
||||||
|
import java.awt.Stroke;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
|
import javax.swing.JComponent;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JTextArea;
|
||||||
|
|
||||||
|
import wsi.ra.math.RNG;
|
||||||
import eva2.server.go.GOStandaloneVersion;
|
import eva2.server.go.GOStandaloneVersion;
|
||||||
import eva2.server.go.individuals.AbstractEAIndividual;
|
import eva2.server.go.individuals.AbstractEAIndividual;
|
||||||
import eva2.server.go.individuals.ESIndividualDoubleData;
|
import eva2.server.go.individuals.ESIndividualDoubleData;
|
||||||
import eva2.server.go.individuals.GAIndividualDoubleData;
|
|
||||||
import eva2.server.go.individuals.InterfaceDataTypeDouble;
|
import eva2.server.go.individuals.InterfaceDataTypeDouble;
|
||||||
import eva2.server.go.populations.Population;
|
import eva2.server.go.populations.Population;
|
||||||
import eva2.server.go.strategies.InterfaceOptimizer;
|
import eva2.server.go.strategies.InterfaceOptimizer;
|
||||||
import wsi.ra.math.RNG;
|
|
||||||
import eva2.server.modules.GOParameters;
|
import eva2.server.modules.GOParameters;
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
|
|
||||||
class MyLensViewer extends JPanel {
|
class MyLensViewer extends JPanel {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 7945150208043416139L;
|
||||||
private double[] m_BestVariables;
|
private double[] m_BestVariables;
|
||||||
private double m_BestFitness;
|
private double m_BestFitness;
|
||||||
private int m_Height, m_Width, m_CenterX, m_CenterY;
|
private int m_Height, m_Width;
|
||||||
FLensProblem m_LensProblem;
|
FLensProblem m_LensProblem;
|
||||||
|
|
||||||
public MyLensViewer (FLensProblem f) {
|
public MyLensViewer (FLensProblem f) {
|
||||||
this.m_LensProblem = f;
|
this.m_LensProblem = f;
|
||||||
Dimension d = new Dimension (450, 350);
|
Dimension d = new Dimension (280, 220);
|
||||||
this.setPreferredSize(d);
|
this.setPreferredSize(d);
|
||||||
this.setMinimumSize(d);
|
this.setMinimumSize(d);
|
||||||
resetBest();
|
resetBest();
|
||||||
@@ -40,12 +55,12 @@ class MyLensViewer extends JPanel {
|
|||||||
Shape tmpShape;
|
Shape tmpShape;
|
||||||
BufferedImage bufferedImage;
|
BufferedImage bufferedImage;
|
||||||
BasicStroke ds = new BasicStroke();
|
BasicStroke ds = new BasicStroke();
|
||||||
Stroke dashStroke, lineStroke, pointStroke;
|
Stroke dashStroke;
|
||||||
int currentPos, width, mag = 10;
|
int mag = 10;
|
||||||
int centerLens, centerScreen, segment;
|
int centerLens, centerScreen, segment;
|
||||||
|
|
||||||
lineStroke = ds;
|
// lineStroke = ds;
|
||||||
pointStroke = new BasicStroke(ds.getLineWidth(), ds.getEndCap(), ds.getLineJoin(), ds.getMiterLimit() , new float[] {1, 4}, 0);
|
// pointStroke = new BasicStroke(ds.getLineWidth(), ds.getEndCap(), ds.getLineJoin(), ds.getMiterLimit() , new float[] {1, 4}, 0);
|
||||||
dashStroke = new BasicStroke(ds.getLineWidth(), ds.getEndCap(), ds.getLineJoin(), ds.getMiterLimit() , new float[] {8, 8}, 0);
|
dashStroke = new BasicStroke(ds.getLineWidth(), ds.getEndCap(), ds.getLineJoin(), ds.getMiterLimit() , new float[] {8, 8}, 0);
|
||||||
|
|
||||||
super.paint(g);
|
super.paint(g);
|
||||||
@@ -54,16 +69,24 @@ class MyLensViewer extends JPanel {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Create a buffered image in which to draw
|
// Create a buffered image in which to draw
|
||||||
try {
|
// try {
|
||||||
this.m_Height = (int)g.getClipBounds().getHeight();
|
// this.m_Height = (int)g.getClipBounds().getHeight();
|
||||||
this.m_Width = (int)g.getClipBounds().getWidth();
|
// this.m_Width = (int)g.getClipBounds().getWidth();
|
||||||
this.m_CenterX = (int)g.getClipBounds().getCenterX();
|
// this.m_CenterX = (int)g.getClipBounds().getCenterX();
|
||||||
this.m_CenterY = (int)g.getClipBounds().getCenterY();
|
// this.m_CenterY = (int)g.getClipBounds().getCenterY();
|
||||||
} catch (java.lang.NullPointerException npe) {
|
// } catch (java.lang.NullPointerException npe) {
|
||||||
//System.out.println("Try fail...");
|
// //System.out.println("Try fail...");
|
||||||
}
|
// }
|
||||||
if (this.m_Height == 0) this.m_Height = 250;
|
// This might cure the eternal display problems: just ignore clipping and leave it up to swing
|
||||||
if (this.m_Width == 0) this.m_Width = 350;
|
Dimension winDim = getSize();
|
||||||
|
m_Height = winDim.height;
|
||||||
|
m_Width = winDim.width;
|
||||||
|
// m_CenterX = m_Width/2;
|
||||||
|
// m_CenterY = m_Height/2;
|
||||||
|
|
||||||
|
// if (this.m_Height == 0) this.m_Height = 250;
|
||||||
|
// if (this.m_Width == 0) this.m_Width = 350;
|
||||||
|
// System.out.println(" h w cx cy " + m_Height + " " + m_Width + " " + m_CenterX + " " + m_CenterY );
|
||||||
bufferedImage = new BufferedImage(this.m_Width, this.m_Height, BufferedImage.TYPE_INT_RGB);
|
bufferedImage = new BufferedImage(this.m_Width, this.m_Height, BufferedImage.TYPE_INT_RGB);
|
||||||
// Create a graphics contents on the buffered image
|
// Create a graphics contents on the buffered image
|
||||||
Graphics2D g2D = bufferedImage.createGraphics();
|
Graphics2D g2D = bufferedImage.createGraphics();
|
||||||
@@ -139,6 +162,10 @@ class MyLensViewer extends JPanel {
|
|||||||
*/
|
*/
|
||||||
public class FLensProblem extends AbstractOptimizationProblem implements InterfaceOptimizationProblem, java.io.Serializable {
|
public class FLensProblem extends AbstractOptimizationProblem implements InterfaceOptimizationProblem, java.io.Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 4694920294291719310L;
|
||||||
protected AbstractEAIndividual m_OverallBest = null;
|
protected AbstractEAIndividual m_OverallBest = null;
|
||||||
protected int m_ProblemDimension = 10;
|
protected int m_ProblemDimension = 10;
|
||||||
protected double m_Noise = 0.0;
|
protected double m_Noise = 0.0;
|
||||||
@@ -244,25 +271,6 @@ public class FLensProblem extends AbstractOptimizationProblem implements Interfa
|
|||||||
population.init();
|
population.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
// /** This method evaluates a given population and set the fitness values
|
|
||||||
// * accordingly
|
|
||||||
// * @param population The population that is to be evaluated.
|
|
||||||
// */
|
|
||||||
// public void evaluate(Population population) {
|
|
||||||
// evaluatePopulationStart(population);
|
|
||||||
// AbstractEAIndividual tmpIndy;
|
|
||||||
//
|
|
||||||
// for (int i = 0; i < population.size(); i++) {
|
|
||||||
// tmpIndy = (AbstractEAIndividual) population.get(i);
|
|
||||||
// tmpIndy.resetConstraintViolation();
|
|
||||||
// this.evaluate(tmpIndy);
|
|
||||||
// population.incrFunctionCalls();
|
|
||||||
// }
|
|
||||||
// evaluatePopulationEnd(population);
|
|
||||||
// //if (sleepTime > 0 ) try { Thread.sleep(sleepTime); } catch(Exception e) {}
|
|
||||||
//// if (this.m_Show) this.updateProblemFrame(population);
|
|
||||||
// }
|
|
||||||
|
|
||||||
public void evaluatePopulationEnd(Population pop) {
|
public void evaluatePopulationEnd(Population pop) {
|
||||||
if (this.m_Show) this.updateProblemFrame(pop);
|
if (this.m_Show) this.updateProblemFrame(pop);
|
||||||
}
|
}
|
||||||
|
@@ -588,8 +588,8 @@ public class Mathematics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Normalizes the doubles in the array by their sum.
|
* Normalizes the doubles in the array by their sum,
|
||||||
*
|
* so that they add up to one.
|
||||||
* @param doubles the array of double
|
* @param doubles the array of double
|
||||||
* @exception IllegalArgumentException if sum is Zero or NaN
|
* @exception IllegalArgumentException if sum is Zero or NaN
|
||||||
*/
|
*/
|
||||||
|
@@ -57,7 +57,11 @@ public class DLine extends DComponent
|
|||||||
if( color != null ) g.setColor( color );
|
if( color != null ) g.setColor( color );
|
||||||
Point p1 = m.getPoint( start ),
|
Point p1 = m.getPoint( start ),
|
||||||
p2 = m.getPoint( end ) ;
|
p2 = m.getPoint( end ) ;
|
||||||
|
if ((p1!=null) && (p2!=null)) {
|
||||||
g.drawLine( p1.x, p1.y, p2.x, p2.y );
|
g.drawLine( p1.x, p1.y, p2.x, p2.y );
|
||||||
|
} else {
|
||||||
|
System.err.println("Couldnt paint rect!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString(){
|
public String toString(){
|
||||||
|
@@ -87,6 +87,9 @@ private boolean under_construction = false;
|
|||||||
*/
|
*/
|
||||||
public Point getPoint( double x, double y ){
|
public Point getPoint( double x, double y ){
|
||||||
DRectangle rect = getSourceOf( getDRectangle() );
|
DRectangle rect = getSourceOf( getDRectangle() );
|
||||||
|
if (rect == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
try{
|
try{
|
||||||
if( x_scale != null ) x = x_scale.getSourceOf( x );
|
if( x_scale != null ) x = x_scale.getSourceOf( x );
|
||||||
if( y_scale != null ) y = y_scale.getSourceOf( y );
|
if( y_scale != null ) y = y_scale.getSourceOf( y );
|
||||||
@@ -214,8 +217,11 @@ private boolean under_construction = false;
|
|||||||
*/
|
*/
|
||||||
DRectangle getSourceOf( DRectangle rect ){
|
DRectangle getSourceOf( DRectangle rect ){
|
||||||
if( under_construction ) System.out.println("DMeasures.getSourceOf: "+rect);
|
if( under_construction ) System.out.println("DMeasures.getSourceOf: "+rect);
|
||||||
if( !getDRectangle().contains( rect ) ) throw
|
if( !getDRectangle().contains( rect ) ) {
|
||||||
new IllegalArgumentException("The rectangle lies not in the currently painted rectangle");
|
return null;
|
||||||
|
//throw new IllegalArgumentException("The rectangle lies not in the currently painted rectangle");
|
||||||
|
}
|
||||||
|
|
||||||
if( x_scale == null && y_scale == null ) return rect;
|
if( x_scale == null && y_scale == null ) return rect;
|
||||||
if( rect.isEmpty() ) return (DRectangle)rect.clone();
|
if( rect.isEmpty() ) return (DRectangle)rect.clone();
|
||||||
DPoint p1 = new DPoint( rect.x, rect.y ),
|
DPoint p1 = new DPoint( rect.x, rect.y ),
|
||||||
|
@@ -191,7 +191,10 @@ public class RNG extends Random {
|
|||||||
return (float)random.nextGaussian()*dev;
|
return (float)random.nextGaussian()*dev;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
* Return a Gaussian double with mean 0 and deviation dev.
|
||||||
*
|
*
|
||||||
|
* @param dev the deviation of the distribution.
|
||||||
|
* @return a Gaussian double with mean 0 and given deviation.
|
||||||
*/
|
*/
|
||||||
public static double gaussianDouble(double dev) {
|
public static double gaussianDouble(double dev) {
|
||||||
//counter++;
|
//counter++;
|
||||||
|
@@ -188,6 +188,7 @@ public class BasicResourceLoader implements ResourceLoader
|
|||||||
* @param rawData Strings containing an array with double data columns
|
* @param rawData Strings containing an array with double data columns
|
||||||
* @param colSplit String regexp for the splitting of a line
|
* @param colSplit String regexp for the splitting of a line
|
||||||
* @param selectedCols indices of the columns to retrieve, null for all.
|
* @param selectedCols indices of the columns to retrieve, null for all.
|
||||||
|
* @see java.util.regex.Pattern
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static double[][] parseDoubleArray(ArrayList<String> rawData, String colSplit, int[] selectedCols) {
|
public static double[][] parseDoubleArray(ArrayList<String> rawData, String colSplit, int[] selectedCols) {
|
||||||
@@ -270,11 +271,19 @@ public class BasicResourceLoader implements ResourceLoader
|
|||||||
}
|
}
|
||||||
if (cols == null) {
|
if (cols == null) {
|
||||||
for (int i=0; i<entries.length; i++) {
|
for (int i=0; i<entries.length; i++) {
|
||||||
|
try {
|
||||||
dest[lineCnt][i] = Double.valueOf(entries[i]);
|
dest[lineCnt][i] = Double.valueOf(entries[i]);
|
||||||
|
} catch(NumberFormatException ex) {
|
||||||
|
System.err.println("Invalid Double format in line " + lineCnt + ", data was " + entries[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int i=0; i<cols.length; i++) {
|
for (int i=0; i<cols.length; i++) {
|
||||||
|
try {
|
||||||
dest[lineCnt][i] = Double.valueOf(entries[cols[i]]);
|
dest[lineCnt][i] = Double.valueOf(entries[cols[i]]);
|
||||||
|
} catch(NumberFormatException ex) {
|
||||||
|
System.err.println("Invalid Double format in line " + lineCnt + ", data was " + entries[cols[i]]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user