From c9b5aeba7e327af2cbc66ef88c4e75c1c33ab7cd Mon Sep 17 00:00:00 2001 From: Martin Pernollet Date: Sun, 13 Oct 2013 12:24:53 +0200 Subject: [PATCH] refactor parametrized mapper, complete main pom file --- .../factories/ChartComponentFactory.java | 5 - .../plot3d/builder/AbstractRemapTask.java | 68 +++++++++ .../builder/IncreaseParamRemapTask.java | 16 +++ .../api/org/jzy3d/plot3d/builder/Mapper.java | 40 +++++- .../plot3d/builder/SingleParameterMapper.java | 25 ++++ .../plot3d/rendering/canvas/ICanvas.java | 2 - .../plot3d/rendering/canvas/VoidCanvas.java | 1 - .../view/controllers/ViewMouseController.java | 1 - .../selection/AWTScatterMouseSelector.java | 1 - .../plot3d/text/overlay/TextOverlay.java | 1 - .../src/swing/org/jzy3d/chart/SwingChart.java | 2 +- .../plot3d/text/overlay/SwingTextOverlay.java | 15 -- .../tests/TestPointOrderingStrategy.java | 3 +- pom.xml | 130 +++++++++++------- 14 files changed, 224 insertions(+), 86 deletions(-) create mode 100644 jzy3d-api/src/api/org/jzy3d/plot3d/builder/AbstractRemapTask.java create mode 100644 jzy3d-api/src/api/org/jzy3d/plot3d/builder/IncreaseParamRemapTask.java create mode 100644 jzy3d-api/src/api/org/jzy3d/plot3d/builder/SingleParameterMapper.java diff --git a/jzy3d-api/src/api/org/jzy3d/chart/factories/ChartComponentFactory.java b/jzy3d-api/src/api/org/jzy3d/chart/factories/ChartComponentFactory.java index 0ca3030c..845a4b83 100644 --- a/jzy3d-api/src/api/org/jzy3d/chart/factories/ChartComponentFactory.java +++ b/jzy3d-api/src/api/org/jzy3d/chart/factories/ChartComponentFactory.java @@ -4,7 +4,6 @@ import java.util.Date; import javax.media.opengl.GLCapabilities; -import org.apache.log4j.Logger; import org.jzy3d.bridge.IFrame; import org.jzy3d.chart.Chart; import org.jzy3d.chart.ChartScene; @@ -19,17 +18,13 @@ import org.jzy3d.chart.controllers.keyboard.screenshot.NewtScreenshotKeyControll import org.jzy3d.chart.controllers.mouse.camera.AWTCameraMouseController; import org.jzy3d.chart.controllers.mouse.camera.ICameraMouseController; import org.jzy3d.chart.controllers.mouse.camera.NewtCameraMouseController; -import org.jzy3d.chart.factories.IChartComponentFactory.Toolkit; import org.jzy3d.maths.BoundingBox3d; import org.jzy3d.maths.Coord3d; -import org.jzy3d.maths.Dimension; import org.jzy3d.maths.Rectangle; import org.jzy3d.maths.Utils; import org.jzy3d.plot3d.primitives.axes.AxeBase; import org.jzy3d.plot3d.primitives.axes.IAxe; -import org.jzy3d.plot3d.rendering.canvas.CanvasNewtAwt; import org.jzy3d.plot3d.rendering.canvas.ICanvas; -import org.jzy3d.plot3d.rendering.canvas.OffscreenCanvas; import org.jzy3d.plot3d.rendering.canvas.Quality; import org.jzy3d.plot3d.rendering.canvas.VoidCanvas; import org.jzy3d.plot3d.rendering.ordering.AbstractOrderingStrategy; diff --git a/jzy3d-api/src/api/org/jzy3d/plot3d/builder/AbstractRemapTask.java b/jzy3d-api/src/api/org/jzy3d/plot3d/builder/AbstractRemapTask.java new file mode 100644 index 00000000..6956af4a --- /dev/null +++ b/jzy3d-api/src/api/org/jzy3d/plot3d/builder/AbstractRemapTask.java @@ -0,0 +1,68 @@ +package org.jzy3d.plot3d.builder; + +import org.jzy3d.maths.TicToc; +import org.jzy3d.maths.Utils; +import org.jzy3d.plot3d.primitives.Shape; + +/** + * A remapping task that let a remapping be performed in a simple while loop. + * + * To be used by an Executor or Thread. + * @author martin + * + */ +public abstract class AbstractRemapTask implements Runnable{ + protected SingleParameterMapper mapper; + protected String info; + protected TicToc time = new TicToc(); + + + public AbstractRemapTask(Shape surface, SingleParameterMapper mapper) { + this.surface = surface; + this.mapper = mapper; + this.info = "n/a"; + } + + public abstract void remap(); + + protected Shape surface; + + @Override + public void run() { + while (true) { + try { + Thread.sleep(1); + } catch (InterruptedException e) { + } + time.tic(); + remap(); + time.toc(); + + info = Utils.num2str(time.elapsedSecond(), 4) + "s to remap surface"; + } + } + + public Shape getSurface() { + return surface; + } + + public void setSurface(Shape surface) { + this.surface = surface; + } + + public SingleParameterMapper getMapper() { + return mapper; + } + + public void setMapper(SingleParameterMapper mapper) { + this.mapper = mapper; + } + + public String getInfo() { + return info; + } + + public void setInfo(String info) { + this.info = info; + } +} \ No newline at end of file diff --git a/jzy3d-api/src/api/org/jzy3d/plot3d/builder/IncreaseParamRemapTask.java b/jzy3d-api/src/api/org/jzy3d/plot3d/builder/IncreaseParamRemapTask.java new file mode 100644 index 00000000..bb1da8f3 --- /dev/null +++ b/jzy3d-api/src/api/org/jzy3d/plot3d/builder/IncreaseParamRemapTask.java @@ -0,0 +1,16 @@ +package org.jzy3d.plot3d.builder; + +import org.jzy3d.plot3d.primitives.Shape; + +public class IncreaseParamRemapTask extends AbstractRemapTask { + + public IncreaseParamRemapTask(Shape surface, SingleParameterMapper mapper) { + super(surface, mapper); + } + + + public void remap() { + mapper.setParam(mapper.getParam() + 0.0001); + mapper.remap(surface); + } +} diff --git a/jzy3d-api/src/api/org/jzy3d/plot3d/builder/Mapper.java b/jzy3d-api/src/api/org/jzy3d/plot3d/builder/Mapper.java index dc8b7bb3..45fbdb1d 100644 --- a/jzy3d-api/src/api/org/jzy3d/plot3d/builder/Mapper.java +++ b/jzy3d-api/src/api/org/jzy3d/plot3d/builder/Mapper.java @@ -1,11 +1,42 @@ package org.jzy3d.plot3d.builder; +import java.util.List; + +import org.jzy3d.maths.Coord3d; +import org.jzy3d.plot3d.primitives.AbstractComposite; +import org.jzy3d.plot3d.primitives.AbstractDrawable; +import org.jzy3d.plot3d.primitives.Point; +import org.jzy3d.plot3d.primitives.Polygon; + public abstract class Mapper { public abstract double f(double x, double y); - /*************************************************************************************/ + /** + * Update the shape by remapping its polygon points' z coordinate + * according to f(x,y) + */ + public void remap(AbstractComposite shape){ + List polygons = shape.getDrawables(); + for(AbstractDrawable d: polygons){ + remapDrawable(d); + } + } + + public void remapDrawable(AbstractDrawable d) { + if(d instanceof Polygon){ + Polygon p = (Polygon) d; + remapPolygon(p); + } + } + + public void remapPolygon(Polygon p) { + for(int i=0; iorg.jzy3d jzy3d-master 0.9.1-SNAPSHOT - pom + pom - Jzy3d Master Project + Jzy3d Master Project + http://www.jzy3d.org + A java API to draw 3d charts. + + + martin.pernollet + Martin Pernollet + martin@jzy3d.org + http://twitter.com/jzy3d + + + nils.hoffmann + Nils Hoffmann + + + juan.barandiaran + Juan Barandiaran + + + + + + The (New) BSD License + http://www.opensource.org/licenses/bsd-license.php + repo + + + + scm:git:git://github.com/jzy3d-api + + + Github + https://github.com/jzy3d/jzy3d-api/issues + - - jzy3d-api - jzy3d-jdt-core - jzy3d-swt - jzy3d-tutorials - + + jzy3d-api + jzy3d-jdt-core + jzy3d-swt + jzy3d-tutorials + - - UTF-8 - - 0.9.1-SNAPSHOT - - 1.6 - 1.6 + + UTF-8 + 0.9.1-SNAPSHOT + 1.6 + 1.6 3.0 1.0-beta-6 2.4 - 4.10 4.2.1 - - - jzy3d-ftp-maven - Jzy3d Maven Folder - ftp://www.jzy3d.org/v1/maven/releases - - - jzy3d-ftp-maven - Jzy3d Maven Folder SNAPSHOTS - ftp://www.jzy3d.org/v1/maven/snapshots - - + + + jzy3d-ftp-maven + Jzy3d Maven Folder + ftp://www.jzy3d.org/v1/maven/releases + + + jzy3d-ftp-maven + Jzy3d Maven Folder SNAPSHOTS + ftp://www.jzy3d.org/v1/maven/snapshots + + - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${version.mvn.compiler} - - ${version.java.source} - ${version.java.target} - - - - - - - org.apache.maven.wagon - wagon-ftp - ${version.mvn.ftp} - - - + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${version.mvn.compiler} + + ${version.java.source} + ${version.java.target} + + + + + + + org.apache.maven.wagon + wagon-ftp + ${version.mvn.ftp} + + +