fixed convex hull, update pom file

This commit is contained in:
Martin Pernollet 2013-03-29 18:01:45 +01:00
parent 4cfe72803b
commit d1e31e1466
6 changed files with 141 additions and 30 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@ doc/javadoc
*.class
*.log
*~/
/target

View File

@ -10,6 +10,16 @@ Source organisation
- ChartTest, a tool to compare a chart with a previously saved screenshot
- Replay, a utility to record and validate a sequence of mouse and key interactions results on a chart (work in progress)
Build
- Eclipse: .project & .classpath files
- Ant: build.xml
- Maven: pom.xml
- Javadoc: javadoc.xml
Project dependencies
These project dependencies are set through eclipse .classpath file, ant build files and maven pom files.
- jzy3d-tools-convexhull
Library dependencies
- jogl2
- jdt (currently copied in API but will be externalized soon)
@ -18,15 +28,6 @@ Library dependencies
- log4j
- junit
Project dependencies
These project dependencies are set through eclipse .classpath file.
- jzy3d-tools-convexhull
Build files
- build.xml
- javadoc.xml
Satellite projects depending on Jzy3d
--------------
Satellite projects are extensions of the framework that remain external to the API.

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

110
pom.xml Normal file
View File

@ -0,0 +1,110 @@
<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/xsd/maven-4.0.0.xsd">
<!--
To install a lib locally:
mvn install:install-file \
-DgroupId=org.jzyio \
-DartifactId=jzyio \
-Dversion=0.1 \
-Dpackaging=jar \
-Dfile=./lib/misc/org.jzyio-0.1.jar
-->
<modelVersion>4.0.0</modelVersion>
<groupId>org.jzy3d</groupId>
<artifactId>jzy3d-api</artifactId>
<version>0.9-SNAPSHOT</version>
<name>jzy3d</name>
<description>A Java API for 3d charts</description>
<repositories>
<repository>
<id>swt-repo</id>
<url>https://swt-repo.googlecode.com/svn/repo/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.jogamp.gluegen</groupId>
<artifactId>gluegen-rt-main</artifactId>
<version>2.0-rc11</version>
</dependency>
<dependency>
<groupId>org.jogamp.jogl</groupId>
<artifactId>jogl-all-main</artifactId>
<version>2.0-rc11</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
<dependency>
<groupId>org.eclipse.swt</groupId>
<artifactId>org.eclipse.swt.gtk.linux.x86_64</artifactId>
<version>4.2.1</version>
</dependency>
<dependency>
<groupId>net.sf.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>2.1</version>
</dependency>
<!--
The next dep was installed locally by adding a POM to its project and executing 'mvn install'.
-->
<dependency>
<groupId>org.jzy3d</groupId>
<artifactId>jzy3d-convexhull</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<testSourceDirectory>src/tests</testSourceDirectory>
<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>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<!-- TODO: Change to 1.7 -->
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<exclude>org/jzy3d/junit/ChartTest.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,6 +1,8 @@
package org.jzy3d.chart.controllers.mouse.selection;
import java.awt.Graphics2D;
import java.awt.geom.Point2D;
import java.util.Deque;
import java.util.List;
import org.jzy3d.maths.ConvexHull;
@ -9,9 +11,6 @@ import org.jzy3d.plot3d.primitives.selectable.SelectableSphere;
import org.jzy3d.plot3d.rendering.scene.Scene;
import org.jzy3d.plot3d.rendering.view.View;
import utils.Stack;
import algorithms.Point2f;
public class SphereMouseSelector extends AbstractMouseSelector {
public SphereMouseSelector(SelectableSphere scatter) {
this.sphere = scatter;
@ -39,10 +38,10 @@ protected void drawSelection(Graphics2D g2d, int width, int height) {
if(projection!=null && sphere.isHighlighted()){
hull = ConvexHull.build2d(projection);
Point2f prev = hull.pop();
Point2f next;
Point2D prev = hull.pop();
Point2D next;
g2d.setColor(java.awt.Color.GREEN);
while (!hull.empty()) {
while (!hull.isEmpty()) {
next = hull.pop();
g2d.drawOval((int) prev.getX() - 4, (int) prev.getY() - 4, 8, 8);
g2d.drawLine((int) prev.getX(), (int) prev.getY(), (int) next.getX(), (int) next.getY() );
@ -64,5 +63,5 @@ protected void drawSelection(Graphics2D g2d, int width, int height) {
protected int width;
protected int height;
protected List<Coord3d> projection;
protected Stack<Point2f> hull;
protected Deque<Point2D> hull;
}

View File

@ -1,44 +1,44 @@
package org.jzy3d.maths;
import java.awt.geom.Point2D;
import java.util.Deque;
import java.util.List;
import utils.Stack;
import algorithms.Point2f;
import convexhull.ConvexHullFunction;
import convexhull.GrahamScan;
import org.jzy3d.convexhull.ConvexHullFunction;
import org.jzy3d.convexhull.GrahamScan;
public class ConvexHull {
public static java.awt.Polygon hull(List<Coord3d> cell){
java.awt.Polygon out = new java.awt.Polygon();
Stack<Point2f> hull = ConvexHull.build2d(cell);
while (!hull.empty()) {
Point2f p = hull.pop();
Deque<Point2D> hull = ConvexHull.build2d(cell);
while (!hull.isEmpty()) {
Point2D p = hull.pop();
out.addPoint( (int)p.getX(), (int)p.getY());
}
return out;
}
public static Stack<Point2f> build2d(List<Coord3d> input2d){
public static Deque<Point2D> build2d(List<Coord3d> input2d){
int np = input2d.size();
Point2f[] data = new Point2f[ np ];
Point2D[] data = new Point2D[ np ];
for (int i = 0; i < data.length; i++) {
data[i] = asPoint2f( input2d.get(i) );
}
return f.getConvexHull( data );
}
public static Stack<Point2f> build2d(PolygonArray input2d){
public static Deque<Point2D> build2d(PolygonArray input2d){
int np = input2d.length();
Point2f[] data = new Point2f[ np ];
Point2D[] data = new Point2D[ np ];
for (int i = 0; i < np; i++) {
data[i] = new Point2f(input2d.x[i], input2d.y[i]);
data[i] = new Point2D.Float(input2d.x[i], input2d.y[i]);
}
return f.getConvexHull( data );
}
protected static Point2f asPoint2f(Coord3d c){
return new Point2f(c.x, c.y);
protected static Point2D asPoint2f(Coord3d c){
return new Point2D.Float(c.x, c.y);
}
protected static ConvexHullFunction f = new GrahamScan();//new JarvisMarch();