mirror of https://github.com/rusefi/jzy3d-api.git
refactor parametrized mapper, complete main pom file
This commit is contained in:
parent
948fc1483a
commit
c9b5aeba7e
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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<AbstractDrawable> 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; i<p.size(); i++){
|
||||
Point pt = p.get(i);
|
||||
Coord3d c = pt.xyz;
|
||||
c.z = (float) f(c.x, c.y);
|
||||
}
|
||||
}
|
||||
|
||||
/** Default implementation providing iterative call to {@link f(double x, double y)}.*/
|
||||
public double[] f(double[] x, double[] y){
|
||||
double[] z = new double[x.length];
|
||||
|
||||
|
@ -14,7 +45,6 @@ public abstract class Mapper {
|
|||
return z;
|
||||
}
|
||||
|
||||
/** Default implementation providing iterative call to {@link f(double x, double y)}.*/
|
||||
public double[] f(double[][] xy){
|
||||
double[] z = new double[xy.length];
|
||||
|
||||
|
@ -23,7 +53,6 @@ public abstract class Mapper {
|
|||
return z;
|
||||
}
|
||||
|
||||
/** Default implementation providing iterative call to {@link f(double x, double y)}.*/
|
||||
public float[] fAsFloat(double[] x, double[] y){
|
||||
float[] z = new float[x.length];
|
||||
|
||||
|
@ -32,7 +61,6 @@ public abstract class Mapper {
|
|||
return z;
|
||||
}
|
||||
|
||||
/** Default implementation providing iterative call to {@link f(double x, double y)}.*/
|
||||
public float[] fAsFloat(float[] x, float[] y){
|
||||
float[] z = new float[x.length];
|
||||
|
||||
|
@ -41,7 +69,6 @@ public abstract class Mapper {
|
|||
return z;
|
||||
}
|
||||
|
||||
/** Default implementation providing iterative call to {@link f(double x, double y)}.*/
|
||||
public float[] fAsFloat(double[][] xy){
|
||||
float[] z = new float[xy.length];
|
||||
|
||||
|
@ -50,7 +77,6 @@ public abstract class Mapper {
|
|||
return z;
|
||||
}
|
||||
|
||||
/** Default implementation providing iterative call to {@link f(double x, double y)}.*/
|
||||
public float[] fAsFloat(float[][] xy){
|
||||
float[] z = new float[xy.length];
|
||||
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
package org.jzy3d.plot3d.builder;
|
||||
|
||||
import org.jzy3d.plot3d.builder.Mapper;
|
||||
|
||||
/**
|
||||
* A base implementation for a {@link Mapper} with a single parameter used while applying f(x,y).
|
||||
*
|
||||
* @author martin
|
||||
*
|
||||
*/
|
||||
public abstract class SingleParameterMapper extends Mapper{
|
||||
public SingleParameterMapper(double p){
|
||||
this.p = p;
|
||||
}
|
||||
|
||||
public void setParam(double p){
|
||||
this.p = p;
|
||||
}
|
||||
|
||||
public double getParam(){
|
||||
return p;
|
||||
}
|
||||
|
||||
protected double p;
|
||||
}
|
|
@ -8,8 +8,6 @@ import javax.media.opengl.GLDrawable;
|
|||
import org.jzy3d.plot3d.rendering.view.Renderer3d;
|
||||
import org.jzy3d.plot3d.rendering.view.View;
|
||||
|
||||
import com.jogamp.newt.event.KeyListener;
|
||||
import com.jogamp.newt.event.MouseListener;
|
||||
import com.jogamp.opengl.util.texture.TextureData;
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ package org.jzy3d.plot3d.rendering.canvas;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.media.opengl.GLCapabilities;
|
||||
import javax.media.opengl.GLDrawable;
|
||||
|
||||
import org.jzy3d.chart.factories.IChartComponentFactory;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.jzy3d.plot3d.rendering.view.controllers;
|
||||
|
||||
import org.jzy3d.chart.controllers.mouse.AWTMouseUtilities;
|
||||
import org.jzy3d.chart.controllers.mouse.NewtMouseUtilities;
|
||||
import org.jzy3d.chart.controllers.thread.camera.CameraThreadController;
|
||||
import org.jzy3d.maths.Coord2d;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.jzy3d.chart.controllers.mouse.selection;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
import org.jzy3d.maths.Coord3d;
|
||||
import org.jzy3d.plot3d.primitives.selectable.SelectableScatter;
|
||||
|
|
|
@ -16,7 +16,6 @@ import org.jzy3d.colors.Color;
|
|||
import org.jzy3d.maths.Coord2d;
|
||||
import org.jzy3d.maths.Coord3d;
|
||||
import org.jzy3d.plot3d.rendering.canvas.CanvasAWT;
|
||||
import org.jzy3d.plot3d.rendering.canvas.CanvasSwing;
|
||||
import org.jzy3d.plot3d.rendering.canvas.ICanvas;
|
||||
import org.jzy3d.plot3d.rendering.view.Camera;
|
||||
import org.jzy3d.plot3d.rendering.view.Renderer2d;
|
||||
|
|
|
@ -3,8 +3,8 @@ package org.jzy3d.chart;
|
|||
import javax.media.opengl.GLCapabilities;
|
||||
|
||||
import org.jzy3d.chart.factories.IChartComponentFactory;
|
||||
import org.jzy3d.chart.factories.SwingChartComponentFactory;
|
||||
import org.jzy3d.chart.factories.IChartComponentFactory.Toolkit;
|
||||
import org.jzy3d.chart.factories.SwingChartComponentFactory;
|
||||
import org.jzy3d.plot3d.rendering.canvas.Quality;
|
||||
import org.jzy3d.plot3d.rendering.view.AWTView;
|
||||
import org.jzy3d.plot3d.rendering.view.Renderer2d;
|
||||
|
|
|
@ -1,24 +1,9 @@
|
|||
package org.jzy3d.plot3d.text.overlay;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.ComponentListener;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.util.List;
|
||||
|
||||
import javax.media.opengl.GL;
|
||||
import javax.media.opengl.glu.GLU;
|
||||
|
||||
import org.jzy3d.colors.Color;
|
||||
import org.jzy3d.maths.Coord2d;
|
||||
import org.jzy3d.maths.Coord3d;
|
||||
import org.jzy3d.plot3d.rendering.canvas.CanvasSwing;
|
||||
import org.jzy3d.plot3d.rendering.canvas.ICanvas;
|
||||
import org.jzy3d.plot3d.rendering.view.Camera;
|
||||
import org.jzy3d.plot3d.text.align.Halign;
|
||||
import org.jzy3d.plot3d.text.align.Valign;
|
||||
|
||||
|
||||
public class SwingTextOverlay extends TextOverlay{
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
package org.jzy3d.tests;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Random;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.jzy3d.maths.Coord3d;
|
||||
import org.jzy3d.plot3d.rendering.ordering.PointOrderingStrategy;
|
||||
import org.jzy3d.plot3d.rendering.view.Camera;
|
||||
import org.jzy3d.maths.Coord3d;
|
||||
|
||||
public class TestPointOrderingStrategy {
|
||||
@Test
|
||||
|
|
130
pom.xml
130
pom.xml
|
@ -7,65 +7,95 @@
|
|||
<groupId>org.jzy3d</groupId>
|
||||
<artifactId>jzy3d-master</artifactId>
|
||||
<version>0.9.1-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Jzy3d Master Project</name>
|
||||
<name>Jzy3d Master Project</name>
|
||||
<url>http://www.jzy3d.org</url>
|
||||
<description>A java API to draw 3d charts.</description>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>martin.pernollet</id>
|
||||
<name>Martin Pernollet</name>
|
||||
<email>martin@jzy3d.org</email>
|
||||
<url>http://twitter.com/jzy3d</url>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>nils.hoffmann</id>
|
||||
<name>Nils Hoffmann</name>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>juan.barandiaran</id>
|
||||
<name>Juan Barandiaran</name>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>The (New) BSD License</name>
|
||||
<url>http://www.opensource.org/licenses/bsd-license.php</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/jzy3d-api</connection>
|
||||
</scm>
|
||||
<issueManagement>
|
||||
<system>Github</system>
|
||||
<url>https://github.com/jzy3d/jzy3d-api/issues</url>
|
||||
</issueManagement>
|
||||
|
||||
<modules>
|
||||
<module>jzy3d-api</module>
|
||||
<module>jzy3d-jdt-core</module>
|
||||
<module>jzy3d-swt</module>
|
||||
<module>jzy3d-tutorials</module>
|
||||
</modules>
|
||||
<modules>
|
||||
<module>jzy3d-api</module>
|
||||
<module>jzy3d-jdt-core</module>
|
||||
<module>jzy3d-swt</module>
|
||||
<module>jzy3d-tutorials</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
||||
<version.jzy3d>0.9.1-SNAPSHOT</version.jzy3d>
|
||||
|
||||
<version.java.source>1.6</version.java.source>
|
||||
<version.java.target>1.6</version.java.target>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<version.jzy3d>0.9.1-SNAPSHOT</version.jzy3d>
|
||||
<version.java.source>1.6</version.java.source>
|
||||
<version.java.target>1.6</version.java.target>
|
||||
<version.mvn.compiler>3.0</version.mvn.compiler>
|
||||
<version.mvn.ftp>1.0-beta-6</version.mvn.ftp>
|
||||
<version.mvn.deploy>2.4</version.mvn.deploy>
|
||||
|
||||
<version.libs.junit>4.10</version.libs.junit>
|
||||
<version.libs.swt>4.2.1</version.libs.swt>
|
||||
</properties>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>jzy3d-ftp-maven</id>
|
||||
<name>Jzy3d Maven Folder</name>
|
||||
<url>ftp://www.jzy3d.org/v1/maven/releases</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>jzy3d-ftp-maven</id>
|
||||
<name>Jzy3d Maven Folder SNAPSHOTS</name>
|
||||
<url>ftp://www.jzy3d.org/v1/maven/snapshots</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>jzy3d-ftp-maven</id>
|
||||
<name>Jzy3d Maven Folder</name>
|
||||
<url>ftp://www.jzy3d.org/v1/maven/releases</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>jzy3d-ftp-maven</id>
|
||||
<name>Jzy3d Maven Folder SNAPSHOTS</name>
|
||||
<url>ftp://www.jzy3d.org/v1/maven/snapshots</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${version.mvn.compiler}</version>
|
||||
<configuration>
|
||||
<source>${version.java.source}</source>
|
||||
<target>${version.java.target}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
<extensions>
|
||||
<extension>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-ftp</artifactId>
|
||||
<version>${version.mvn.ftp}</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
</build>
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${version.mvn.compiler}</version>
|
||||
<configuration>
|
||||
<source>${version.java.source}</source>
|
||||
<target>${version.java.target}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
<extensions>
|
||||
<extension>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-ftp</artifactId>
|
||||
<version>${version.mvn.ftp}</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
</build>
|
||||
</project>
|
||||
|
|
Loading…
Reference in New Issue