This commit is contained in:
Martin Pernollet 2017-06-05 23:29:00 +02:00
parent 9731751909
commit 6af2722999
7 changed files with 303 additions and 3 deletions

View File

@ -0,0 +1,174 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>jzy3d-master</artifactId>
<groupId>org.jzy3d</groupId>
<version>1.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.jzy3d</groupId>
<artifactId>jzy3d-api</artifactId>
<name>Jzy3d API</name>
<description>A Java API for 3d charts</description>
<build>
<testSourceDirectory>src/tests</testSourceDirectory>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/api</source>
<source>src/bridge</source>
<source>src/awt</source>
<source>src/swing</source>
<source>src/replay</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<phase>deploy</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<phase>deploy</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/api</source>
<source>src/bridge</source>
<source>src/awt</source>
<source>src/swing</source>
<source>src/replay</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<exclude>org/jzy3d/junit/ChartTest.java</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>maths-io-jar</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>maths-io</classifier>
<excludes>
<exclude>org/jzy3d/*</exclude>
</excludes>
<includes>
<include>org/jzy3d/maths/**</include>
<include>org/jzy3d/io/*</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<artifactSet>
<excludes>
<exclude>classworlds:classworlds</exclude>
<exclude>jmock:*</exclude>
<exclude>*:xml-apis</exclude>
<exclude>org.apache.maven:lib:tests</exclude>
</excludes>
</artifactSet>
<transformers>
<transformer />
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>jzy3d-snapshots</id>
<name>Jzy3d Snapshots</name>
<url>http://maven.jzy3d.org/snapshots/</url>
</repository>
<repository>
<id>jzy3d-releases</id>
<name>Jzy3d Snapshots</name>
<url>http://maven.jzy3d.org/releases/</url>
</repository>
</repositories>
</project>

View File

@ -136,6 +136,47 @@
</execution>
</executions>
</plugin>
<!-- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<artifactSet>
<excludes>
<exclude>classworlds:classworlds</exclude>
<exclude>jmock:*</exclude>
<exclude>*:xml-apis</exclude>
<exclude>org.apache.maven:lib:tests</exclude>
</excludes>
</artifactSet>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>-->
</plugins>

View File

@ -83,6 +83,15 @@ public class Color {
return this;
}
public Color mulSelf(float ratio){
this.r *= ratio;
this.g *= ratio;
this.b *= ratio;
return this;
}
/** Return the hexadecimal representation of this color.*/
public String toHex(){
String hexa = "#";

View File

@ -0,0 +1,69 @@
package org.jzy3d.maths;
import java.util.ArrayList;
import java.util.List;
import org.jzy3d.colors.Color;
/**
* A set of points.
*
* @author Martin Pernollet
*/
public class Coord3ds {
public float x[];
public float y[];
public float z[];
public float r[];
public float g[];
public float b[];
public float a[];
public Coord3ds(int size){
x = new float[size];
y = new float[size];
z = new float[size];
r = new float[size];
g = new float[size];
b = new float[size];
a = new float[size];
}
public void set(int id, float x, float y, float z, float r, float g, float b, float a){
this.x[id] = x;
this.y[id] = y;
this.z[id] = z;
this.r[id] = r;
this.g[id] = g;
this.b[id] = b;
this.a[id] = a;
}
public List<Coord3d> coords(){
List<Coord3d> coords = new ArrayList<>();
for (int i = 0; i < x.length; i++) {
coords.add(new Coord3d(x[i], y[i], z[i]));
}
return coords;
}
public Coord3d[] coordsArray(){
Coord3d[] coords = new Coord3d[x.length];
for (int i = 0; i < x.length; i++) {
coords[i] = new Coord3d(x[i], y[i], z[i]);
}
return coords;
}
public Color[] colorsArray(){
Color[] colors = new Color[r.length];
for (int i = 0; i < r.length; i++) {
colors[i] = new Color(r[i], g[i], b[i], a[i]);
}
return colors;
}
}

View File

@ -5,6 +5,7 @@ import org.jzy3d.colors.ISingleColorable;
import org.jzy3d.events.DrawableChangedEvent;
import org.jzy3d.maths.BoundingBox3d;
import org.jzy3d.maths.Coord3d;
import org.jzy3d.maths.Coord3ds;
import org.jzy3d.plot3d.rendering.compat.GLES2CompatUtils;
import org.jzy3d.plot3d.rendering.view.Camera;
import org.jzy3d.plot3d.transform.Transform;
@ -41,6 +42,10 @@ public class Scatter extends AbstractDrawable implements ISingleColorable {
setColor(rgb);
}
public Scatter(Coord3ds coords) {
this(coords.coordsArray(), coords.colorsArray());
}
public Scatter(Coord3d[] coordinates, Color[] colors) {
this(coordinates, colors, 1.0f);
}

View File

@ -58,7 +58,9 @@ public abstract class Abstract3dDemo {
}
protected static Chart getRegressionChart(SvmMapper mapper, Coord3d[] values) {
Chart chart = new AWTChart(Quality.Advanced);
Quality q = Quality.Advanced;
q.setSmoothPoint(true);
Chart chart = new AWTChart(q);
// shape
BoundingBox3d b = Conversion.getBounds(values);
@ -75,7 +77,7 @@ public abstract class Abstract3dDemo {
/* 3d OBJECTS GENERATION */
public static Scatter loadScatter(Chart chart, Coord3d[] coords) {
Scatter scatter = new Scatter(coords, Color.BLACK, 5);
Scatter scatter = new Scatter(coords, Color.GREEN.mulSelf(1.2f), 20);
chart.getScene().getGraph().add(scatter);
return scatter;
}

View File

@ -16,7 +16,7 @@
</repository>
<repository>
<id>jzy3d-releases</id>
<name>Jzy3d Snapshots</name>
<name>Jzy3d Releases</name>
<url>http://maven.jzy3d.org/releases/</url>
</repository>
</repositories>