From 865bf19f0550d026e3f6855ad5e1a7db73b91ced Mon Sep 17 00:00:00 2001 From: "antonio.fabio" Date: Wed, 21 Feb 2007 16:10:09 +0000 Subject: [PATCH] merged branch 2.0.x into main trunk --- NEWS | 4 +- build.xml | 2 +- .../core/algorithms/NativeBasinsAlgorithm.java | 81 ------------ .../org/tsho/dmc2/core/chart/BasinRenderer.java | 137 +++++++++------------ .../org/tsho/dmc2/core/chart/CowebRenderer.java | 23 ++-- src/java/org/tsho/dmc2/core/dlua/LuaIterator.java | 15 ++- .../org/tsho/dmc2/ui/basin/BasinComponent.java | 18 +-- 7 files changed, 87 insertions(+), 193 deletions(-) delete mode 100644 src/java/org/tsho/dmc2/core/algorithms/NativeBasinsAlgorithm.java diff --git a/NEWS b/NEWS index 34ad5d8..3d1b6ad 100644 --- a/NEWS +++ b/NEWS @@ -85,5 +85,5 @@ * 2.0.2 - added 'black' color to cycles routine for eigenvalues near to 1 -* 2.1.0 -- added new 'native' basins of attraction algorithm +* 2.0.3 +- fixed issues 2,3 diff --git a/build.xml b/build.xml index 89b7f00..13cd38f 100644 --- a/build.xml +++ b/build.xml @@ -13,7 +13,7 @@ - + diff --git a/src/java/org/tsho/dmc2/core/algorithms/NativeBasinsAlgorithm.java b/src/java/org/tsho/dmc2/core/algorithms/NativeBasinsAlgorithm.java deleted file mode 100644 index 1495438..0000000 --- a/src/java/org/tsho/dmc2/core/algorithms/NativeBasinsAlgorithm.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * iDMC the interactive Dynamical Model Calculator simulates and performs - * graphical and numerical analysis of systems of differential and - * difference equations. - * - * Copyright (C) 2007 Marji Lines and Alfredo Medio. - * - * Written by Daniele Pizzoni . - * Extended by Alexei Grigoriev . - * - * - * - * The software program was developed within a research project financed - * by the Italian Ministry of Universities, the Universities of Udine and - * Ca'Foscari of Venice, the Friuli-Venezia Giulia Region. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or any - * later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - */ -package org.tsho.dmc2.core.algorithms; - -import java.util.Vector; -import org.tsho.dmc2.core.chart.BasinRenderer; -import org.tsho.dmc2.core.model.SimpleMap; -import org.tsho.jidmclib.*; - -public class NativeBasinsAlgorithm implements BasinsAlgorithm { - private BasinRenderer br; - private Basin basin; - - private static final int INFINITY = 1; - - private Vector attractorsSamplePoints; - - private int rate, index; - double[] startPoint, currentPoint; // (x, y) - - public NativeBasinsAlgorithm(BasinRenderer br){ - this.br = br; - Grid grid = br.getGrid(); - double ranges[] = grid.getRanges(); - SimpleMap map = br.getMap(); - double parameters[] = br.getParameters(); - basin = new Basin((Model) map, parameters, - ranges[0], ranges[1], grid.nc, - ranges[2], ranges[3], grid.nr, - br.getAttractorLimit(), br.getAttractorIterations()); - rate = br.getRate(); - attractorsSamplePoints = br.getAttractorsSamplePoints(); - index=0; - } - - public void run() { - SWIGTYPE_p_int b_data = basin.getData(); - int br_data[] = br.getGrid().getData(); - int len = br_data.length; - index=0; - while (basin.finished()==0) { - basin.step_n(rate); - index+=rate; - /*Fill raster data as wanted by BasinRenderer*/ - for(int i=0; (i. * Extended by Alexei Grigoriev . @@ -52,7 +52,6 @@ public class BasinRenderer implements DmcPlotRenderer { public static final int FAST_ALGORITHM = 0; public static final int SLOW_ALGORITHM = 1; - public static final int NATIVE_ALGORITHM = 2; private int type; /** parameters */ @@ -142,8 +141,6 @@ public class BasinRenderer implements DmcPlotRenderer { bA = new FastBasinsAlgorithm(this); else if(type==SLOW_ALGORITHM) bA = new SlowBasinsAlgorithm(this); - else if(type==NATIVE_ALGORITHM) - bA = new NativeBasinsAlgorithm(this); bA.run(); /** Now that grid is computed, pass it to the BasinComponent for possible storing */ @@ -230,85 +227,73 @@ public class BasinRenderer implements DmcPlotRenderer { bigDotsEnabled=flag; } - /** - * @return the grid - */ - public Grid getGrid() { - return grid; - } + /** + * @return the grid + */ + public Grid getGrid() { + return grid; + } - /** - * @return the infinity - */ - public double getInfinity() { - return infinity; - } + /** + * @return the infinity + */ + public double getInfinity() { + return infinity; + } - /** - * @return the attractorLimit - */ - public int getAttractorLimit() { - return attractorLimit; - } + /** + * @return the attractorLimit + */ + public int getAttractorLimit() { + return attractorLimit; + } - /** - * @return the attractorIterations - */ - public int getAttractorIterations() { - return attractorIterations; - } + /** + * @return the attractorIterations + */ + public int getAttractorIterations() { + return attractorIterations; + } - /** - * @return the stopped - */ - public boolean isStopped() { - return stopped; - } + /** + * @return the stopped + */ + public boolean isStopped() { + return stopped; + } - /** - * @return the numberOfRandomPoints - */ - public int getNumberOfRandomPoints() { - return numberOfRandomPoints; - } + /** + * @return the numberOfRandomPoints + */ + public int getNumberOfRandomPoints() { + return numberOfRandomPoints; + } - /** - * @return the rate - */ - public int getRate() { - return rate; - } + /** + * @return the rate + */ + public int getRate() { + return rate; + } - /** - * @return the attractorsSamplePoints - */ - public Vector getAttractorsSamplePoints() { - return attractorsSamplePoints; - } + /** + * @return the attractorsSamplePoints + */ + public Vector getAttractorsSamplePoints() { + return attractorsSamplePoints; + } - /** - * @return the colorSettings - */ - public ColorSettings getColorSettings() { - return colorSettings; - } + /** + * @return the colorSettings + */ + public ColorSettings getColorSettings() { + return colorSettings; + } - /** - * @param colorSettings the colorSettings to set - */ - public void setColorSettings(ColorSettings colorSettings) { - BasinRenderer.colorSettings = colorSettings; - } - - public SimpleMap getMap() { - return map; - } - - public double[] getParameters() { - return parameters; - } - - public void setParameters(double[] parameters) { - this.parameters = parameters; - } + /** + * @param colorSettings the colorSettings to set + */ + public void setColorSettings(ColorSettings colorSettings) { + BasinRenderer.colorSettings = colorSettings; + } } diff --git a/src/java/org/tsho/dmc2/core/chart/CowebRenderer.java b/src/java/org/tsho/dmc2/core/chart/CowebRenderer.java index 2de4a5c..1050e73 100644 --- a/src/java/org/tsho/dmc2/core/chart/CowebRenderer.java +++ b/src/java/org/tsho/dmc2/core/chart/CowebRenderer.java @@ -3,7 +3,7 @@ * graphical and numerical analysis of systems of differential and * difference equations. * - * Copyright (C) 2004 Marji Lines and Alfredo Medio. + * Copyright (C) 2004, 2007 Marji Lines and Alfredo Medio. * * Written by Daniele Pizzoni . * Extended by Alexei Grigoriev . @@ -26,6 +26,7 @@ */ package org.tsho.dmc2.core.chart; +import com.sun.org.apache.xerces.internal.impl.xpath.regex.Match; import java.awt.AlphaComposite; import java.awt.BasicStroke; import java.awt.Color; @@ -102,26 +103,24 @@ public class CowebRenderer implements DmcPlotRenderer { if (plot.isAlpha()) { g2.setComposite(AlphaComposite.SrcOver); - } Stepper.Point2D result = stepper.getCurrentPoint2D(); int transX, transY; -// double start = Math.floor(dataArea.getMinX() + 0.5); -// double end = Math.floor(dataArea.getMaxX() + 0.5); - double start = (int) dataArea.getMinX(); double end = (int) dataArea.getMaxX(); double[] value = new double[1]; int prevY = 0; + boolean flagOld=false; + boolean flagNew=false; label: for (double i = start; i <= end; i += 1) { - value[0] = this.domainAxis.valueToJava2D( + value[0] = this.domainAxis.java2DToValue( i, dataArea, RectangleEdge.BOTTOM); stepper.setInitialValue(value); @@ -136,15 +135,7 @@ public class CowebRenderer implements DmcPlotRenderer { transX = (int) i; transY = (int) rangeAxis.valueToJava2D( result.getX(), dataArea, RectangleEdge.LEFT); - -// transX = (int) Math.round(i); -// transY = (int) Math.round(rangeAxis.translateValueToJava2D( -// result.getX(), dataArea, RectangleEdge.LEFT)); - - -// System.out.println( -// "i = " + i + "; transX = " + transX + "; value = " + value[0] -// + "; j = " + transY + "; y = " + result.getX()); + flagNew = Double.isNaN(result.getX()); if (bigDots) { g2.fillRect(transX - 1, transY - 1, 3, 3); @@ -155,10 +146,12 @@ public class CowebRenderer implements DmcPlotRenderer { if (connectWithLines) { if (i > start) { + if(!flagOld && !flagNew) g2.drawLine(transX, transY, transX - 1, prevY); } prevY = transY; + flagOld = flagNew; } if (stopped) { diff --git a/src/java/org/tsho/dmc2/core/dlua/LuaIterator.java b/src/java/org/tsho/dmc2/core/dlua/LuaIterator.java index 6179d91..b023d41 100644 --- a/src/java/org/tsho/dmc2/core/dlua/LuaIterator.java +++ b/src/java/org/tsho/dmc2/core/dlua/LuaIterator.java @@ -74,7 +74,20 @@ class LuaIterator implements MapStepper { initialValue, 0, this.currentValues, 0, dim); } - public void initialize(){} + public void initialize(){ + System.arraycopy( + initialValues, 0, lastValues, 0, initialValues.length); + + count = 0; + + currentValues = new double[dim]; + + copyArrays(lastValues, currentValues); + currentPoint2D.x = currentValues[xIdx]; + currentPoint2D.y = currentValues[yIdx]; + lastPoint2D.x = lastValues[xIdx]; + lastPoint2D.y = lastValues[yIdx]; + } public void setAxes(int x, int y) { this.xIdx = x; diff --git a/src/java/org/tsho/dmc2/ui/basin/BasinComponent.java b/src/java/org/tsho/dmc2/ui/basin/BasinComponent.java index 5178993..96cc99b 100644 --- a/src/java/org/tsho/dmc2/ui/basin/BasinComponent.java +++ b/src/java/org/tsho/dmc2/ui/basin/BasinComponent.java @@ -3,7 +3,7 @@ * graphical and numerical analysis of systems of differential and * difference equations. * - * Copyright (C) 2004,2007 Marji Lines and Alfredo Medio. + * Copyright (C) 2004 Marji Lines and Alfredo Medio. * * Written by Daniele Pizzoni . * Extended by Alexei Grigoriev . @@ -131,22 +131,6 @@ public class BasinComponent extends AbstractPlotComponent } }); - menuItem = new JRadioButtonMenuItem("Native algorithm"); - menuItem.setMnemonic(KeyEvent.VK_N); - group.add(menuItem); - menu.add(menuItem); - menuItem.addActionListener(new ActionListener() { - public void actionPerformed(final ActionEvent e) { - //change flag in basin control form and in basin renderer - BasinRenderer plotRenderer=manager.getPlotRenderer(); - plotRenderer.setType(BasinRenderer.NATIVE_ALGORITHM); - privateControlForm.setType(BasinRenderer.NATIVE_ALGORITHM); - controlForm.updateSamplesMenu(); - } - }); - menuItem.setSelected(false); - - menu.addSeparator(); menu.add(colorSettingsAction); -- 2.11.4.GIT