FunctionArea may now plot circles easily. The FLensProblemViewer seems to be cured.
This commit is contained in:
@@ -57,7 +57,11 @@ public class DLine extends DComponent
|
||||
if( color != null ) g.setColor( color );
|
||||
Point p1 = m.getPoint( start ),
|
||||
p2 = m.getPoint( end ) ;
|
||||
g.drawLine( p1.x, p1.y, p2.x, p2.y );
|
||||
if ((p1!=null) && (p2!=null)) {
|
||||
g.drawLine( p1.x, p1.y, p2.x, p2.y );
|
||||
} else {
|
||||
System.err.println("Couldnt paint rect!");
|
||||
}
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
|
@@ -87,6 +87,9 @@ private boolean under_construction = false;
|
||||
*/
|
||||
public Point getPoint( double x, double y ){
|
||||
DRectangle rect = getSourceOf( getDRectangle() );
|
||||
if (rect == null) {
|
||||
return null;
|
||||
}
|
||||
try{
|
||||
if( x_scale != null ) x = x_scale.getSourceOf( x );
|
||||
if( y_scale != null ) y = y_scale.getSourceOf( y );
|
||||
@@ -214,8 +217,11 @@ private boolean under_construction = false;
|
||||
*/
|
||||
DRectangle getSourceOf( DRectangle rect ){
|
||||
if( under_construction ) System.out.println("DMeasures.getSourceOf: "+rect);
|
||||
if( !getDRectangle().contains( rect ) ) throw
|
||||
new IllegalArgumentException("The rectangle lies not in the currently painted rectangle");
|
||||
if( !getDRectangle().contains( rect ) ) {
|
||||
return null;
|
||||
//throw new IllegalArgumentException("The rectangle lies not in the currently painted rectangle");
|
||||
}
|
||||
|
||||
if( x_scale == null && y_scale == null ) return rect;
|
||||
if( rect.isEmpty() ) return (DRectangle)rect.clone();
|
||||
DPoint p1 = new DPoint( rect.x, rect.y ),
|
||||
|
@@ -191,7 +191,10 @@ public class RNG extends Random {
|
||||
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) {
|
||||
//counter++;
|
||||
|
@@ -188,6 +188,7 @@ public class BasicResourceLoader implements ResourceLoader
|
||||
* @param rawData Strings containing an array with double data columns
|
||||
* @param colSplit String regexp for the splitting of a line
|
||||
* @param selectedCols indices of the columns to retrieve, null for all.
|
||||
* @see java.util.regex.Pattern
|
||||
* @return
|
||||
*/
|
||||
public static double[][] parseDoubleArray(ArrayList<String> rawData, String colSplit, int[] selectedCols) {
|
||||
@@ -199,7 +200,7 @@ public class BasicResourceLoader implements ResourceLoader
|
||||
entries = rawData.get(i).split(colSplit);
|
||||
if (i == 0) { // at the first pass
|
||||
dat = new double[rawData.size()][(selectedCols == null) ? entries.length : selectedCols.length];
|
||||
}
|
||||
}
|
||||
fillLine(dat, i, entries, selectedCols);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -270,11 +271,19 @@ public class BasicResourceLoader implements ResourceLoader
|
||||
}
|
||||
if (cols == null) {
|
||||
for (int i=0; i<entries.length; i++) {
|
||||
dest[lineCnt][i] = Double.valueOf(entries[i]);
|
||||
try {
|
||||
dest[lineCnt][i] = Double.valueOf(entries[i]);
|
||||
} catch(NumberFormatException ex) {
|
||||
System.err.println("Invalid Double format in line " + lineCnt + ", data was " + entries[i]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int i=0; i<cols.length; i++) {
|
||||
dest[lineCnt][i] = Double.valueOf(entries[cols[i]]);
|
||||
try {
|
||||
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