format conflicting classes

This commit is contained in:
Martin Pernollet 2014-12-27 11:29:48 +01:00
parent 7bea9b6c10
commit 10d51dc798
19 changed files with 2098 additions and 1302 deletions

8
.travis.yml Normal file
View File

@ -0,0 +1,8 @@
language: java
jdk:
- openjdk7
#- oraclejdk8
#- oraclejdk7
#- openjdk6
before_install: openssl aes-256-cbc -K $encrypted_7d767fcac9aa_key -iv $encrypted_7d767fcac9aa_iv -in settings-obf.xml.enc -out settings-obf.xml -d
after_success: mvn deploy --settings settings-obf.xml

View File

@ -0,0 +1,49 @@
package org.jzy3d.chart2d;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import org.jzy3d.plot2d.primitives.LineSerie2d;
import org.jzy3d.plot2d.primitives.ScatterPointSerie2d;
import org.jzy3d.plot2d.primitives.ScatterSerie2d;
import org.jzy3d.plot2d.primitives.Serie2d;
public class SerieManager {
static SerieManager instance;
public static SerieManager get() {
if (instance == null)
instance = new SerieManager();
return instance;
}
public Collection<Serie2d> getSeries(){
return series.values();
}
public Serie2d getSerie(String name, Serie2d.Type type) {
Serie2d serie = null;
if (!series.keySet().contains(name)) {
serie = newSerie(name, type, serie);
} else {
serie = series.get(name);
}
return serie;
}
protected Serie2d newSerie(String name, Serie2d.Type type, Serie2d serie) {
if (Serie2d.Type.LINE.equals(type))
serie = new LineSerie2d(name);
else if (Serie2d.Type.SCATTER.equals(type))
serie = new ScatterSerie2d(name);
else if (Serie2d.Type.SCATTER_POINTS.equals(type))
serie = new ScatterPointSerie2d(name);
else
throw new IllegalArgumentException("Unsupported serie type " + type);
return serie;
}
protected Map<String, Serie2d> series = new HashMap<String, Serie2d>();
}

View File

@ -7,380 +7,394 @@ import org.jzy3d.plot3d.primitives.Point;
import org.jzy3d.plot3d.primitives.Polygon;
import org.jzy3d.plot3d.primitives.axeTransformablePrimitive.axeTransformers.AxeTransformerSet;
/** A BoundingBox3d stores a couple of maximal and minimal limit on
* each dimension (x, y, and z). It provides functions for enlarging
* the box by adding coordinates, Point3d, Polygon3d or an other
* BoundingBox3d (that is equivalent to computing the union of the
* current BoundingBox and another one).
/**
* A BoundingBox3d stores a couple of maximal and minimal limit on each
* dimension (x, y, and z). It provides functions for enlarging the box by
* adding coordinates, Point3d, Polygon3d or an other BoundingBox3d (that is
* equivalent to computing the union of the current BoundingBox and another
* one).
*
* @author Martin Pernollet
*/
public class BoundingBox3d {
/** Initialize a BoundingBox by calling its reset method, leaving the box in an inconsitent state,
* with minimums = Float.MAX_VALUE and maximums = -Float.MAX_VALUE. In other words, calling box.valid()
* will return false. */
public BoundingBox3d(){
reset();
}
public BoundingBox3d(List<Coord3d> coords){
reset();
for(Coord3d c: coords)
add( c );
}
public BoundingBox3d(Polygon polygon){
reset();
for(Point c: polygon.getPoints())
add( c );
}
public BoundingBox3d(Coord3d center, float edgeLength){
this.xmin = center.x - edgeLength / 2;
this.xmax = center.x + edgeLength / 2;
this.ymin = center.y - edgeLength / 2;
this.ymax = center.y + edgeLength / 2;
this.zmin = center.z - edgeLength / 2;
this.zmax = center.z + edgeLength / 2;
}
public BoundingBox3d(BoundingBox3d box){
this.xmin = box.xmin;
this.xmax = box.xmax;
this.ymin = box.ymin;
this.ymax = box.ymax;
this.zmin = box.zmin;
this.zmax = box.zmax;
}
/** Initialize a BoundingBox with raw values.*/
public BoundingBox3d(float xmin, float xmax, float ymin, float ymax, float zmin, float zmax){
this.xmin = xmin;
this.xmax = xmax;
this.ymin = ymin;
this.ymax = ymax;
this.zmin = zmin;
this.zmax = zmax;
}
public BoundingBox3d(Range xRange, Range yRange, Range zRange){
this.xmin = (float)xRange.getMin();
this.xmax = (float)xRange.getMax();
this.ymin = (float)yRange.getMin();
this.ymax = (float)yRange.getMax();
this.zmin = (float)zRange.getMin();
this.zmax = (float)zRange.getMax();
}
/*********************************************************/
/**
* Initialize the bounding box with Float.MAX_VALUE as minimum
* value, and -Float.MAX_VALUE as maximum value for each dimension.
*/
public void reset(){
xmin = Float.MAX_VALUE;
xmax = -Float.MAX_VALUE;
ymin = Float.MAX_VALUE;
ymax = -Float.MAX_VALUE;
zmin = Float.MAX_VALUE;
zmax = -Float.MAX_VALUE;
}
public boolean valid(){
return (xmin<=xmax && ymin<=ymax && zmin<=zmax);
}
/**
* Adds an x,y,z point to the bounding box, and enlarge the bounding
* box if this points lies outside of it.
*
* @param x
* @param y
* @param z
*/
public void add(float x, float y, float z){
if(x>xmax) xmax = x;
if(x<xmin) xmin = x;
if(y>ymax) ymax = y;
if(y<ymin) ymin = y;
if(z>zmax) zmax = z;
if(z<zmin) zmin = z;
}
/**
* Add a Coord3d to the BoundingBox3d.
* A shortcut for:
* <code>add(c.x, c.y, c.z);</code>
* @param p
*/
public void add(Coord3d c){
add(c.x, c.y, c.z);
}
public void add(List<Point> pts){
for(Point p: pts)
add(p.xyz.x, p.xyz.y, p.xyz.z);
/**
* Initialize a BoundingBox by calling its reset method, leaving the box in
* an inconsitent state, with minimums = Float.MAX_VALUE and maximums =
* -Float.MAX_VALUE. In other words, calling box.valid() will return false.
*/
public BoundingBox3d() {
reset();
}
/**
* Add a Point3d to the BoundingBox3d.
* A shortcut for:
* <code>add(p.x, p.y, p.z);</code>
* @param p
*/
public void add(Point p){
add(p.xyz.x, p.xyz.y, p.xyz.z);
}
/**
* Add the points of a Polygon to the BoundingBox3d.
* @param p
*/
public void add(Polygon p){
for(int i=0; i<p.size(); i++)
add(p.get(i).xyz.x, p.get(i).xyz.y, p.get(i).xyz.z);
}
/**
* Add a BoundingBox3d volume to the current one.
* A convenient shortcut for:
* <code>
* add(b.xmin, b.ymin, b.zmin);
* add(b.xmax, b.ymax, b.zmax);
* </code>
* @param p
*/
public void add(BoundingBox3d b){
add(b.xmin, b.ymin, b.zmin);
add(b.xmax, b.ymax, b.zmax);
}
public BoundingBox3d(List<Coord3d> coords) {
reset();
for (Coord3d c : coords)
add(c);
}
/*********************************************************/
public BoundingBox3d(Polygon polygon) {
reset();
for (Point c : polygon.getPoints())
add(c);
}
/** Compute and return the center point of the BoundingBox3d
* @return the center.
*/
public Coord3d getCenter(){
return new Coord3d((xmin+xmax)/2, (ymin+ymax)/2, (zmin+zmax)/2);
}
public Coord3d getTransformedCenter(AxeTransformerSet transformers) {
return new Coord3d((transformers.getX().compute(xmin) + transformers.getX().compute(xmax)) / 2,
(transformers.getY().compute(ymin) + transformers.getY().compute(ymax)) / 2,
(transformers.getZ().compute(zmin) + transformers.getZ().compute(zmax)) /2);
}
/** Return the radius of the Sphere containing the Bounding Box,
* i.e., the distance between the center and the point (xmin, ymin, zmin).
* @return the box radius.
*/
public double getRadius(){
return getCenter().distance(new Coord3d(xmin, ymin, zmin));
}
public double getTransformedRadius(AxeTransformerSet transformers) {
return getTransformedCenter(transformers).distance(transformers.computePoint(new Coord3d(xmin, ymin, zmin)));
}
/** Return a copy of the current bounding box after scaling.
* Scaling does not modify the current bounding box.
* @return the scaled bounding box
*/
public BoundingBox3d scale(Coord3d scale){
BoundingBox3d b = new BoundingBox3d();
b.xmax = xmax*scale.x;
b.xmin = xmin*scale.x;
b.ymax = ymax*scale.y;
b.ymin = ymin*scale.y;
b.zmax = zmax*scale.z;
b.zmin = zmin*scale.z;
return b;
}
public BoundingBox3d shift(Coord3d offset){
BoundingBox3d b = new BoundingBox3d();
b.xmax = xmax+offset.x;
b.xmin = xmin+offset.x;
b.ymax = ymax+offset.y;
b.ymin = ymin+offset.y;
b.zmax = zmax+offset.z;
b.zmin = zmin+offset.z;
return b;
}
/** Return true if b2 is contained by this.*/
public boolean contains(BoundingBox3d b2){
return xmin <= b2.xmin && b2.xmax <= xmax
&& ymin <= b2.ymin && b2.ymax <= ymax
&& zmin <= b2.zmin && b2.zmax <= zmax;
}
/** Return true if intersect b2.*/
public boolean intersect(BoundingBox3d b2){
return xmin <= b2.xmin && b2.xmin <= xmax
|| xmin <= b2.xmax && b2.xmax <= xmax
|| ymin <= b2.ymin && b2.ymin <= ymax
|| ymin <= b2.ymax && b2.ymax <= ymax
|| zmin <= b2.zmin && b2.zmin <= zmax
|| zmin <= b2.zmax && b2.zmax <= zmax;
}
/*********************************************************/
public BoundingBox3d(Coord3d center, float edgeLength) {
this.xmin = center.x - edgeLength / 2;
this.xmax = center.x + edgeLength / 2;
this.ymin = center.y - edgeLength / 2;
this.ymax = center.y + edgeLength / 2;
this.zmin = center.z - edgeLength / 2;
this.zmax = center.z + edgeLength / 2;
}
public BoundingBox3d margin(float margin){
BoundingBox3d b = new BoundingBox3d();
b.xmax = xmax + margin;
b.xmin = xmin + margin;
b.ymax = ymax + margin;
b.ymin = ymin + margin;
b.zmax = zmax + margin;
b.zmin = zmin + margin;
return b;
}
public BoundingBox3d selfMargin(float margin){
xmax += margin;
xmin -= margin;
ymax += margin;
ymin -= margin;
zmax += margin;
zmin -= margin;
return this;
}
/*********************************************************/
public Range getXRange(){
return new Range(xmin, xmax);
}
public Range getYRange(){
return new Range(ymin, ymax);
}
public Range getZRange(){
return new Range(zmin, zmax);
}
public float getXmin(){
return xmin;
}
public void setXmin(float value){
xmin = value;
}
public float getXmax(){
return xmax;
}
public void setXmax(float value){
xmax = value;
}
public float getYmin(){
return ymin;
}
public void setYmin(float value){
ymin = value;
}
public float getYmax(){
return ymax;
}
public void setYmax(float value){
ymax = value;
}
public float getZmin(){
return zmin;
}
public void setZmin(float value){
zmin = value;
}
public float getZmax(){
return zmax;
}
public void setZmax(float value){
zmax = value;
}
public List<Coord3d> getVertices(){
List<Coord3d> edges = new ArrayList<Coord3d>(8);
edges.add( new Coord3d(xmin, ymin, zmin) );
edges.add( new Coord3d(xmin, ymax, zmin) );
edges.add( new Coord3d(xmax, ymax, zmin) );
edges.add( new Coord3d(xmax, ymin, zmin) );
edges.add( new Coord3d(xmin, ymin, zmax) );
edges.add( new Coord3d(xmin, ymax, zmax) );
edges.add( new Coord3d(xmax, ymax, zmax) );
edges.add( new Coord3d(xmax, ymin, zmax) );
return edges;
}
/*********************************************************/
public BoundingBox3d(BoundingBox3d box) {
this.xmin = box.xmin;
this.xmax = box.xmax;
this.ymin = box.ymin;
this.ymax = box.ymax;
this.zmin = box.zmin;
this.zmax = box.zmax;
}
public static BoundingBox3d newBoundsAtOrigin(){
return new BoundingBox3d(Coord3d.ORIGIN, 0);
}
/*********************************************************/
public String toString(){
return toString(0);
}
public String toString(int depth){
return Utils.blanks(depth) + "(BoundingBox3d)" + xmin + "<=x<=" + xmax + " | " + ymin + "<=y<=" + ymax + " | " + zmin + "<=z<=" + zmax;
}
/*********************************************************/
/** Initialize a BoundingBox with raw values. */
public BoundingBox3d(float xmin, float xmax, float ymin, float ymax, float zmin, float zmax) {
this.xmin = xmin;
this.xmax = xmax;
this.ymin = ymin;
this.ymax = ymax;
this.zmin = zmin;
this.zmax = zmax;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + Float.floatToIntBits(xmax);
result = prime * result + Float.floatToIntBits(xmin);
result = prime * result + Float.floatToIntBits(ymax);
result = prime * result + Float.floatToIntBits(ymin);
result = prime * result + Float.floatToIntBits(zmax);
result = prime * result + Float.floatToIntBits(zmin);
return result;
}
public BoundingBox3d(Range xRange, Range yRange, Range zRange) {
this.xmin = (float) xRange.getMin();
this.xmax = (float) xRange.getMax();
this.ymin = (float) yRange.getMin();
this.ymax = (float) yRange.getMax();
this.zmin = (float) zRange.getMin();
this.zmax = (float) zRange.getMax();
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (!(obj instanceof BoundingBox3d)) return false;
/*********************************************************/
BoundingBox3d other = (BoundingBox3d) obj;
if (Float.floatToIntBits(xmax) != Float.floatToIntBits(other.xmax)) return false;
if (Float.floatToIntBits(xmin) != Float.floatToIntBits(other.xmin)) return false;
if (Float.floatToIntBits(ymax) != Float.floatToIntBits(other.ymax)) return false;
if (Float.floatToIntBits(ymin) != Float.floatToIntBits(other.ymin)) return false;
if (Float.floatToIntBits(zmax) != Float.floatToIntBits(other.zmax)) return false;
if (Float.floatToIntBits(zmin) != Float.floatToIntBits(other.zmin)) return false;
/**
* Initialize the bounding box with Float.MAX_VALUE as minimum value, and
* -Float.MAX_VALUE as maximum value for each dimension.
*/
public void reset() {
xmin = Float.MAX_VALUE;
xmax = -Float.MAX_VALUE;
ymin = Float.MAX_VALUE;
ymax = -Float.MAX_VALUE;
zmin = Float.MAX_VALUE;
zmax = -Float.MAX_VALUE;
}
return true;
}
/*********************************************************/
public boolean valid() {
return (xmin <= xmax && ymin <= ymax && zmin <= zmax);
}
private float xmin;
private float xmax;
private float ymin;
private float ymax;
private float zmin;
private float zmax;
/**
* Adds an x,y,z point to the bounding box, and enlarge the bounding box if
* this points lies outside of it.
*
* @param x
* @param y
* @param z
*/
public void add(float x, float y, float z) {
if (x > xmax)
xmax = x;
if (x < xmin)
xmin = x;
if (y > ymax)
ymax = y;
if (y < ymin)
ymin = y;
if (z > zmax)
zmax = z;
if (z < zmin)
zmin = z;
}
/**
* Add a Coord3d to the BoundingBox3d. A shortcut for:
* <code>add(c.x, c.y, c.z);</code>
*
* @param p
*/
public void add(Coord3d c) {
add(c.x, c.y, c.z);
}
public void add(List<Point> pts) {
for (Point p : pts)
add(p.xyz.x, p.xyz.y, p.xyz.z);
}
/**
* Add a Point3d to the BoundingBox3d. A shortcut for:
* <code>add(p.x, p.y, p.z);</code>
*
* @param p
*/
public void add(Point p) {
add(p.xyz.x, p.xyz.y, p.xyz.z);
}
/**
* Add the points of a Polygon to the BoundingBox3d.
*
* @param p
*/
public void add(Polygon p) {
for (int i = 0; i < p.size(); i++)
add(p.get(i).xyz.x, p.get(i).xyz.y, p.get(i).xyz.z);
}
/**
* Add a BoundingBox3d volume to the current one. A convenient shortcut for:
* <code>
* add(b.xmin, b.ymin, b.zmin);
* add(b.xmax, b.ymax, b.zmax);
* </code>
*
* @param p
*/
public void add(BoundingBox3d b) {
add(b.xmin, b.ymin, b.zmin);
add(b.xmax, b.ymax, b.zmax);
}
/*********************************************************/
/**
* Compute and return the center point of the BoundingBox3d
*
* @return the center.
*/
public Coord3d getCenter() {
return new Coord3d((xmin + xmax) / 2, (ymin + ymax) / 2, (zmin + zmax) / 2);
}
public Coord3d getTransformedCenter(AxeTransformerSet transformers) {
return new Coord3d((transformers.getX().compute(xmin) + transformers.getX().compute(xmax)) / 2, (transformers.getY().compute(ymin) + transformers.getY().compute(ymax)) / 2, (transformers.getZ().compute(zmin) + transformers.getZ().compute(zmax)) / 2);
}
/**
* Return the radius of the Sphere containing the Bounding Box, i.e., the
* distance between the center and the point (xmin, ymin, zmin).
*
* @return the box radius.
*/
public double getRadius() {
return getCenter().distance(new Coord3d(xmin, ymin, zmin));
}
public double getTransformedRadius(AxeTransformerSet transformers) {
return getTransformedCenter(transformers).distance(transformers.computePoint(new Coord3d(xmin, ymin, zmin)));
}
/**
* Return a copy of the current bounding box after scaling. Scaling does not
* modify the current bounding box.
*
* @return the scaled bounding box
*/
public BoundingBox3d scale(Coord3d scale) {
BoundingBox3d b = new BoundingBox3d();
b.xmax = xmax * scale.x;
b.xmin = xmin * scale.x;
b.ymax = ymax * scale.y;
b.ymin = ymin * scale.y;
b.zmax = zmax * scale.z;
b.zmin = zmin * scale.z;
return b;
}
public BoundingBox3d shift(Coord3d offset) {
BoundingBox3d b = new BoundingBox3d();
b.xmax = xmax + offset.x;
b.xmin = xmin + offset.x;
b.ymax = ymax + offset.y;
b.ymin = ymin + offset.y;
b.zmax = zmax + offset.z;
b.zmin = zmin + offset.z;
return b;
}
/** Return true if b2 is contained by this. */
public boolean contains(BoundingBox3d b2) {
return xmin <= b2.xmin && b2.xmax <= xmax && ymin <= b2.ymin && b2.ymax <= ymax && zmin <= b2.zmin && b2.zmax <= zmax;
}
/** Return true if intersect b2. */
public boolean intersect(BoundingBox3d b2) {
return xmin <= b2.xmin && b2.xmin <= xmax || xmin <= b2.xmax && b2.xmax <= xmax || ymin <= b2.ymin && b2.ymin <= ymax || ymin <= b2.ymax && b2.ymax <= ymax || zmin <= b2.zmin && b2.zmin <= zmax || zmin <= b2.zmax && b2.zmax <= zmax;
}
/*********************************************************/
public BoundingBox3d margin(float margin) {
BoundingBox3d b = new BoundingBox3d();
b.xmax = xmax + margin;
b.xmin = xmin + margin;
b.ymax = ymax + margin;
b.ymin = ymin + margin;
b.zmax = zmax + margin;
b.zmin = zmin + margin;
return b;
}
public BoundingBox3d selfMargin(float margin) {
xmax += margin;
xmin -= margin;
ymax += margin;
ymin -= margin;
zmax += margin;
zmin -= margin;
return this;
}
/*********************************************************/
public Range getXRange() {
return new Range(xmin, xmax);
}
public Range getYRange() {
return new Range(ymin, ymax);
}
public Range getZRange() {
return new Range(zmin, zmax);
}
public float getXmin() {
return xmin;
}
public void setXmin(float value) {
xmin = value;
}
public float getXmax() {
return xmax;
}
public void setXmax(float value) {
xmax = value;
}
public float getYmin() {
return ymin;
}
public void setYmin(float value) {
ymin = value;
}
public float getYmax() {
return ymax;
}
public void setYmax(float value) {
ymax = value;
}
public float getZmin() {
return zmin;
}
public void setZmin(float value) {
zmin = value;
}
public float getZmax() {
return zmax;
}
public void setZmax(float value) {
zmax = value;
}
public List<Coord3d> getVertices() {
List<Coord3d> edges = new ArrayList<Coord3d>(8);
edges.add(new Coord3d(xmin, ymin, zmin));
edges.add(new Coord3d(xmin, ymax, zmin));
edges.add(new Coord3d(xmax, ymax, zmin));
edges.add(new Coord3d(xmax, ymin, zmin));
edges.add(new Coord3d(xmin, ymin, zmax));
edges.add(new Coord3d(xmin, ymax, zmax));
edges.add(new Coord3d(xmax, ymax, zmax));
edges.add(new Coord3d(xmax, ymin, zmax));
return edges;
}
/*********************************************************/
public static BoundingBox3d newBoundsAtOrigin() {
return new BoundingBox3d(Coord3d.ORIGIN, 0);
}
/*********************************************************/
public String toString() {
return toString(0);
}
public String toString(int depth) {
return Utils.blanks(depth) + "(BoundingBox3d)" + xmin + "<=x<=" + xmax + " | " + ymin + "<=y<=" + ymax + " | " + zmin + "<=z<=" + zmax;
}
/*********************************************************/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + Float.floatToIntBits(xmax);
result = prime * result + Float.floatToIntBits(xmin);
result = prime * result + Float.floatToIntBits(ymax);
result = prime * result + Float.floatToIntBits(ymin);
result = prime * result + Float.floatToIntBits(zmax);
result = prime * result + Float.floatToIntBits(zmin);
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (!(obj instanceof BoundingBox3d))
return false;
BoundingBox3d other = (BoundingBox3d) obj;
if (Float.floatToIntBits(xmax) != Float.floatToIntBits(other.xmax))
return false;
if (Float.floatToIntBits(xmin) != Float.floatToIntBits(other.xmin))
return false;
if (Float.floatToIntBits(ymax) != Float.floatToIntBits(other.ymax))
return false;
if (Float.floatToIntBits(ymin) != Float.floatToIntBits(other.ymin))
return false;
if (Float.floatToIntBits(zmax) != Float.floatToIntBits(other.zmax))
return false;
if (Float.floatToIntBits(zmin) != Float.floatToIntBits(other.zmin))
return false;
return true;
}
/*********************************************************/
private float xmin;
private float xmax;
private float ymin;
private float ymax;
private float zmin;
private float zmax;
}

View File

@ -0,0 +1,6 @@
package org.jzy3d.maths;
public interface IBoundingPolicy {
public abstract BoundingBox3d apply(BoundingBox3d box);
}

View File

@ -0,0 +1,16 @@
package org.jzy3d.maths;
public class Timer {
public static double TEN_POW_9 = 1000000000.0;
public static double TEN_POW_6 = 1000000.0;
protected long start;
public void start() {
start = System.nanoTime();
}
public double elapsed() {
return (System.nanoTime() - start) / TEN_POW_9;
}
}

View File

@ -0,0 +1,27 @@
package org.jzy3d.plot2d.primitives;
import org.jzy3d.colors.Color;
import org.jzy3d.maths.Coord3d;
import org.jzy3d.plot3d.primitives.ConcurrentLineStripSplitted;
import org.jzy3d.plot3d.primitives.Point;
public class LineSerie2dSplitted extends LineSerie2d implements Serie2d {
public LineSerie2dSplitted(String name){
super(name);
this.line = new ConcurrentLineStripSplitted();
}
public void addAndSplit(float x, float y, Color color) {
line().addAndSplit(new Point(new Coord3d(x, y, 0), color));
}
@Override
public void add(float x, float y, Color color) {
line().add(new Point(new Coord3d(x, y, 0), color));
}
public ConcurrentLineStripSplitted line(){
return (ConcurrentLineStripSplitted)line;
}
}

View File

@ -0,0 +1,133 @@
package org.jzy3d.plot3d.primitives;
import java.util.ArrayList;
import java.util.List;
import javax.media.opengl.GL;
import org.jzy3d.maths.Coord3d;
public class ConcurrentLineStripSplitted extends ConcurrentLineStrip {
// List<Integer> idOn = new ArrayList<Integer>();
List<Integer> idOff = new ArrayList<Integer>();
public ConcurrentLineStripSplitted() {
super(100);
}
public ConcurrentLineStripSplitted(int n) {
super(n);
}
public ConcurrentLineStripSplitted(List<Coord3d> coords) {
super(coords);
}
public ConcurrentLineStripSplitted(Point c1, Point c2) {
super(c1, c2);
}
@Override
public void drawLineGL2(GL gl) {
gl.getGL2().glLineWidth(wfwidth);
if (wfcolor == null) {
drawLineSegmentsGL2ByPointColor(gl);
} else {
drawLineSegmentsGL2ByWireColor(gl);
}
}
public void drawLineSegmentsGL2ByPointColor(GL gl) {
int nPt = 0;
int nOff = 0;
int nextOff = idOff.size() != 0 ? idOff.get(nOff) : 0;
begin(gl);
while (nPt <= points.size() - 1) {
// point
Point p = points.get(nPt);
pointColorSelf(gl, p);
// consume off
if (nextOff == nPt) {
end(gl);
begin(gl);
nOff++;
if (nOff <= idOff.size() - 1)
nextOff = idOff.get(nOff);
}
nPt++;
}
end(gl);
}
public void drawLineSegmentsGL2ByWireColor(GL gl) {
int nPt = 0;
int nOff = 0;
int nextOff = -1;
if (idOff.size() > 0)
nextOff = idOff.get(nOff);
begin(gl);
while (nPt <= points.size() - 1) {
// point
Point p = points.get(nPt);
pointColorWire(gl, p);
// consume off
if (nextOff == nPt) {
end(gl);
begin(gl);
nOff++;
if (nOff != -1 && nOff <= idOff.size() - 1)
nextOff = idOff.get(nOff);
}
nPt++;
}
end(gl);
}
public void pointColorWire(GL gl, Point p) {
gl.getGL2().glColor4f(wfcolor.r, wfcolor.g, wfcolor.b, wfcolor.a);
gl.getGL2().glVertex3f(p.xyz.x, p.xyz.y, p.xyz.z);
}
public void pointColorSelf(GL gl, Point p) {
gl.getGL2().glColor4f(p.rgb.r, p.rgb.g, p.rgb.b, p.rgb.a);
gl.getGL2().glVertex3f(p.xyz.x, p.xyz.y, p.xyz.z);
}
public void begin(GL gl) {
gl.getGL2().glBegin(GL.GL_LINE_STRIP);
}
public void end(GL gl) {
gl.getGL2().glEnd();
}
/* */
public void addAndSplit(Point point) {
synchronized (points) {
idOff.add(points.size());
points.add(point);
}
bbox.add(point);
}
@Override
public void add(Point point) {
synchronized (points) {
points.add(point);
}
bbox.add(point);
}
}

View File

@ -0,0 +1,31 @@
package org.jzy3d.plot3d.primitives.axes;
import javax.media.opengl.GL;
import org.jzy3d.maths.Coord2d;
import org.jzy3d.maths.Range;
public class AxeCrossAnnotation extends AxeLineAnnotation implements AxeAnnotation {
protected Coord2d value;
@Override
public void draw(GL gl, AxeBox axe) {
Range xrange = axe.getBoxBounds().getXRange();
Range yrange = axe.getBoxBounds().getYRange();
if (gl.isGL2()) {
drawHorizontalLineGL2(gl, xrange, value.y);
drawVerticalLineGL2(gl, yrange, value.x);
} else {
drawHorizontalLineGLES2(xrange, value.y);
drawVerticalLineGLES2(yrange, value.x);
}
}
public synchronized Coord2d getValue() {
return value;
}
public synchronized void setValue(Coord2d value) {
this.value = value;
}
}

View File

@ -0,0 +1,68 @@
package org.jzy3d.plot3d.primitives.axes;
import javax.media.opengl.GL;
import org.jzy3d.colors.Color;
import org.jzy3d.maths.Range;
import org.jzy3d.plot3d.rendering.compat.GLES2CompatUtils;
public class AxeLineAnnotation {
protected Color color = Color.RED;
protected float width = 3;
public AxeLineAnnotation() {
super();
}
public void drawVerticalLineGLES2(Range yrange, float value) {
GLES2CompatUtils.glBegin(GL.GL_LINE_STRIP);
GLES2CompatUtils.glLineWidth(width);
GLES2CompatUtils.glColor4f(color.r, color.g, color.b, color.a);
GLES2CompatUtils.glVertex3f(value, yrange.getMin(), 0);
GLES2CompatUtils.glVertex3f(value, yrange.getMax(), 0);
GLES2CompatUtils.glEnd();
}
public synchronized void drawVerticalLineGL2(GL gl, Range yrange, float value) {
gl.getGL2().glLineWidth(width);
gl.getGL2().glBegin(GL.GL_LINE_STRIP);
gl.getGL2().glColor4f(color.r, color.g, color.b, color.a);
gl.getGL2().glVertex3f(value, yrange.getMin()-yrange.getRange()/30, 0);
gl.getGL2().glVertex3f(value, yrange.getMax()+yrange.getRange()/30, 0);
gl.getGL2().glEnd();
}
public void drawHorizontalLineGLES2(Range xrange, float value) {
GLES2CompatUtils.glBegin(GL.GL_LINE_STRIP);
GLES2CompatUtils.glLineWidth(width);
GLES2CompatUtils.glColor4f(color.r, color.g, color.b, color.a);
GLES2CompatUtils.glVertex3f(xrange.getMin(), value, 0);
GLES2CompatUtils.glVertex3f(xrange.getMax(), value, 0);
GLES2CompatUtils.glEnd();
}
public synchronized void drawHorizontalLineGL2(GL gl, Range xrange, float value) {
gl.getGL2().glLineWidth(width);
gl.getGL2().glBegin(GL.GL_LINE_STRIP);
gl.getGL2().glColor4f(color.r, color.g, color.b, color.a);
gl.getGL2().glVertex3f(xrange.getMin()-xrange.getRange()/30, value, 0);
gl.getGL2().glVertex3f(xrange.getMax()+xrange.getRange()/30, value, 0);
gl.getGL2().glEnd();
}
public Color getColor() {
return color;
}
public void setColor(Color color) {
this.color = color;
}
public float getWidth() {
return width;
}
public void setWidth(float width) {
this.width = width;
}
}

View File

@ -0,0 +1,71 @@
package org.jzy3d.plot3d.primitives.axes;
import javax.media.opengl.GL;
import org.jzy3d.colors.Color;
import org.jzy3d.maths.Range;
import org.jzy3d.plot3d.rendering.compat.GLES2CompatUtils;
public class AxeYLineAnnotation implements AxeAnnotation {
protected float value;
protected Color color = Color.RED;
protected float width = 3;
@Override
public void draw(GL gl, AxeBox axe) {
Range xrange = axe.getBoxBounds().getXRange();
Range zrange = axe.getBoxBounds().getYRange();
if (gl.isGL2()) {
drawLineGL2(gl, xrange, zrange);
} else {
drawLineGLES2(xrange, zrange);
}
}
public void drawLineGLES2(Range yrange, Range zrange) {
GLES2CompatUtils.glBegin(GL.GL_LINE_STRIP);
GLES2CompatUtils.glLineWidth(width);
GLES2CompatUtils.glColor4f(color.r, color.g, color.b, color.a);
GLES2CompatUtils.glVertex3f(value, yrange.getMin(), 0);
GLES2CompatUtils.glVertex3f(value, yrange.getMax(), 0);
GLES2CompatUtils.glEnd();
}
public synchronized void drawLineGL2(GL gl, Range yrange, Range zrange) {
gl.getGL2().glLineWidth(width);
gl.getGL2().glBegin(GL.GL_LINE_STRIP);
gl.getGL2().glColor4f(color.r, color.g, color.b, color.a);
gl.getGL2().glVertex3f(value, yrange.getMin()-yrange.getRange()/30, zrange.getMin()-2);
gl.getGL2().glVertex3f(value, yrange.getMax()+yrange.getRange()/30, zrange.getMin()-2);
//System.out.println("x=" + value + " y:" + yrange);
gl.getGL2().glEnd();
}
public synchronized float getValue() {
return value;
}
public synchronized void setValue(float value) {
this.value = value;
}
public Color getColor() {
return color;
}
public void setColor(Color color) {
this.color = color;
}
public float getWidth() {
return width;
}
public void setWidth(float width) {
this.width = width;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,73 @@
package org.jzy3d.plot2d.primitive;
import java.awt.Font;
import java.awt.Graphics2D;
import org.jzy3d.colors.Color;
import org.jzy3d.colors.ColorAWT;
public abstract class AWTAbstractImageGenerator implements AWTImageGenerator{
public void configureText(Graphics2D graphic) {
graphic.setFont(font); //Text for the numbers in the ColorBar is Size=12
}
public void drawBackground(int width, int height, Graphics2D graphic) {
if(hasBackground){
graphic.setColor(ColorAWT.toAWT(backgroundColor));
graphic.fillRect(0, 0, width, height);
}
}
protected boolean hasBackground = false;
@Override
public boolean hasBackground() {
return hasBackground;
}
@Override
public void setHasBackground(boolean hasBackground) {
this.hasBackground = hasBackground;
}
@Override
public Color getBackgroundColor() {
return backgroundColor;
}
@Override
public void setBackgroundColor(Color backgroundColor) {
this.backgroundColor = backgroundColor;
}
@Override
public Color getForegroundColor() {
return foregroundColor;
}
@Override
public void setForegroundColor(Color foregroundColor) {
this.foregroundColor = foregroundColor;
}
public void drawLegendBorder(Graphics2D graphic, int width, int height) {
graphic.setColor(ColorAWT.toAWT(foregroundColor));
graphic.drawRect(0, 0, width - 1, height-1);
}
@Override
public Font getFont() {
return font;
}
@Override
public void setFont(Font font) {
this.font = font;
}
protected Font font;
protected int textSize;
protected Color backgroundColor;
protected Color foregroundColor = Color.BLACK;
public static final int MIN_BAR_WIDTH = 100;
public static final int MIN_BAR_HEIGHT = 100;
}

View File

@ -0,0 +1,93 @@
package org.jzy3d.plot2d.primitive;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import org.jzy3d.colors.Color;
import org.jzy3d.colors.ColorAWT;
import org.jzy3d.colors.ColorMapper;
import org.jzy3d.colors.colormaps.IColorMap;
import org.jzy3d.plot3d.primitives.axes.layout.providers.ITickProvider;
import org.jzy3d.plot3d.primitives.axes.layout.renderers.ITickRenderer;
/**
* @author Martin Pernollet
*/
public class AWTColorbarImageGenerator extends AWTAbstractImageGenerator implements AWTImageGenerator{
public AWTColorbarImageGenerator(IColorMap map, float min, float max, ITickProvider provider, ITickRenderer renderer){
this.mapper = new ColorMapper(map, min, max);
this.min = min;
this.max = max;
this.provider = provider;
this.renderer = renderer;
}
public AWTColorbarImageGenerator(ColorMapper mapper, ITickProvider provider, ITickRenderer renderer){
this.mapper = mapper;
this.provider = provider;
this.renderer = renderer;
this.min = mapper.getMin();
this.max = mapper.getMax();
this.textSize = 12;
this.font = new java.awt.Font("Arial",0,textSize);
}
@Override
public BufferedImage toImage(int width, int height) {
return toImage(width, height, 20);
}
/** Renders the {@link AWTColorbarImageGenerator} to an image. */
public BufferedImage toImage(int width, int height, int barWidth){
if(barWidth>width)
return null;
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
Graphics2D graphic = image.createGraphics();
configureText(graphic);
drawBackground(width, height, graphic);
drawBarColors(height, barWidth, graphic);
drawBarContour(height, barWidth, graphic);
drawTextAnnotations(height, barWidth, graphic);
return image;
}
public void drawBarContour(int height, int barWidth, Graphics2D graphic) {
graphic.setColor(ColorAWT.toAWT(foregroundColor));
graphic.drawRect(0, textSize/2, barWidth, height-textSize);
}
public void drawBarColors(int height, int barWidth, Graphics2D graphic) {
for(int h=textSize/2; h<=(height-textSize/2); h++){
// Compute value & color
double v = min + (max-min) * (h)/(height-textSize);
Color c = mapper.getColor(v); //To allow the Color to be a variable independent of the coordinates
// Draw line
graphic.setColor(ColorAWT.toAWT(c));
graphic.drawLine(0, height-h, barWidth, height-h);
}
}
public void drawTextAnnotations(int height, int barWidth, Graphics2D graphic) {
if(provider!=null){
double[] ticks = provider.generateTicks(min, max);
int ypos;
String txt;
for(int t=0; t<ticks.length; t++){
// ypos = (int)(height-height*((ticks[t]-min)/(max-min)));
ypos = (int)(textSize+(height-textSize-(height-textSize)*((ticks[t]-min)/(max-min)))); //Making sure that the first and last tick appear in the colorbar
txt = renderer.format(ticks[t]);
graphic.drawString(txt, barWidth+1, ypos);
}
}
}
/* */
protected ColorMapper mapper;
protected ITickProvider provider;
protected ITickRenderer renderer;
protected double min;
protected double max;
}

View File

@ -0,0 +1,27 @@
package org.jzy3d.plot2d.primitive;
import java.awt.Font;
import java.awt.image.BufferedImage;
import org.jzy3d.colors.Color;
public interface AWTImageGenerator {
public BufferedImage toImage(int width, int height);
public boolean hasBackground();
public void setHasBackground(boolean hasBackground);
public Color getBackgroundColor();
public void setBackgroundColor(Color backgroundColor);
public Color getForegroundColor();
public void setForegroundColor(Color foregroundColor);
public Font getFont() ;
public void setFont(Font font);
}

View File

@ -0,0 +1,55 @@
package org.jzy3d.plot3d.rendering.view;
import java.awt.image.BufferedImage;
import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLProfile;
import javax.media.opengl.glu.GLU;
import com.jogamp.opengl.util.awt.AWTGLReadBufferUtil;
public class AWTRenderer3d extends Renderer3d{
public AWTRenderer3d() {
super();
}
public AWTRenderer3d(View view, boolean traceGL, boolean debugGL, GLU glu) {
super(view, traceGL, debugGL, glu);
}
public AWTRenderer3d(View view, boolean traceGL, boolean debugGL) {
super(view, traceGL, debugGL);
}
public AWTRenderer3d(View view) {
super(view);
}
/**
* Uses a dedicated {@link AWTGLReadBufferUtil} to read a buffered image.
* @see {@link getLastScreenshotImage()} to retrieve the image
*/
@Override
public void display(GLAutoDrawable canvas) {
GL gl = canvas.getGL();
if (view != null) {
view.clear(gl);
view.render(gl, glu);
if (doScreenshotAtNextDisplay) {
AWTGLReadBufferUtil screenshot = new AWTGLReadBufferUtil(GLProfile.getGL2GL3(), true);
screenshot.readPixels(gl, true);
image = screenshot.getTextureData();
bufferedImage = screenshot.readPixelsToBufferedImage(gl, true);
doScreenshotAtNextDisplay = false;
}
}
}
public BufferedImage getLastScreenshotImage() {
return bufferedImage;
}
protected BufferedImage bufferedImage;
}

View File

@ -0,0 +1,7 @@
package org.jzy3d.tests;
import org.jzy3d.plot3d.primitives.AbstractComposite;
public class MyComposite extends AbstractComposite {
}

View File

@ -0,0 +1,123 @@
package org.jzy3d.tests;
import java.util.ArrayList;
import org.jzy3d.analysis.AbstractAnalysis;
import org.jzy3d.analysis.AnalysisLauncher;
import org.jzy3d.chart.factories.AWTChartComponentFactory;
import org.jzy3d.colors.Color;
import org.jzy3d.maths.Coord3d;
import org.jzy3d.plot3d.primitives.LineStrip;
import org.jzy3d.plot3d.primitives.Point;
import org.jzy3d.plot3d.primitives.pickable.PickablePoint;
import org.jzy3d.plot3d.rendering.canvas.CanvasAWT;
import org.jzy3d.plot3d.rendering.canvas.Quality;
import org.jzy3d.plot3d.rendering.view.modes.ViewPositionMode;
import org.jzy3d.plot3d.text.align.Halign;
import org.jzy3d.plot3d.text.drawable.DrawableTextBitmap;
import org.jzy3d.plot3d.transform.Rotate;
import org.jzy3d.plot3d.transform.Transform;
public class RotationTextTest extends AbstractAnalysis {
//https://github.com/zhivko/jzy3d-api.git
public static RotationTextTest instance;
public MyComposite myComposite;
public ArrayList<PickablePoint> points;
public static void main(String[] args) throws Exception {
System.setProperty("java.util.Arrays.useLegacyMergeSort", "true");
instance = new RotationTextTest();
AnalysisLauncher.open(instance);
CanvasAWT canvas = (CanvasAWT) instance.chart.getCanvas();
canvas.setSize(600, 600);
instance.chart.getView().setViewPositionMode(ViewPositionMode.FREE);
for (int i = 0; i < -1; i++) {
double angle = 4;
Rotate rotate = new Rotate(angle, new Coord3d(0, 0, 1));
Transform t = new Transform();
t.add(rotate);
instance.myComposite.applyGeometryTransform(t);
instance.chart.render();
Thread.currentThread();
Thread.sleep(300);
//File f = new File("c:\\temp\\pic_" + i + ".jpg");
// try {
//// instance.chart.screenshot(f);
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
}
}
@Override
public void init() {
System.out.println("Creating chart! Thread: " + Thread.currentThread().getName());
myComposite = new MyComposite();
points = new ArrayList<PickablePoint>();
chart = AWTChartComponentFactory.chart(Quality.Advanced, getCanvasType());
CanvasAWT canvas = (CanvasAWT) chart.getCanvas();
// canvas.getAnimator().start();
System.out.println("Animator started?: " + canvas.getAnimator().isStarted());
PickablePoint mp1 = new PickablePoint(new Coord3d(0, 2, 2), Color.GRAY, 5);
PickablePoint mp2 = new PickablePoint(new Coord3d(2, 2, 2), Color.GRAY, 5);
PickablePoint mp3 = new PickablePoint(new Coord3d(1, 5, 2), Color.GRAY, 5);
PickablePoint mp4 = new PickablePoint(new Coord3d(1, 3, 3), Color.GRAY, 5);
points.add(mp1);
points.add(mp2);
points.add(mp3);
points.add(mp4);
LineStrip ls = new LineStrip();
ls.setWireframeColor(Color.GRAY);
ls.add(mp1);
ls.add(mp2);
ls.add(mp3);
ls.add(mp4);
ls.add(mp2);
ls.add(mp4);
ls.add(mp1);
ls.setWireframeWidth(6);
ls.setWidth(6);
float distance = (float) mp2.xyz.distance(mp1.xyz);
Coord3d delta = mp2.xyz.sub(mp1.xyz).normalizeTo((float) (distance * 0.5));
Coord3d textPos = mp1.xyz.add(delta);
DrawableTextBitmap t4 = new DrawableTextBitmap("edge", textPos, Color.BLACK);
t4.setHalign(Halign.LEFT); // TODO: invert
myComposite.add(t4);
myComposite.add(ls);
addAxis();
chart.getScene().getGraph().add(myComposite,true);
}
public void addAxis() {
LineStrip yAxis = new LineStrip();
yAxis.setWireframeColor(Color.GREEN);
yAxis.add(new Point(new Coord3d(0, 0, 0)));
yAxis.add(new Point(new Coord3d(0, 1, 0)));
LineStrip xAxis = new LineStrip();
xAxis.setWireframeColor(Color.BLUE);
xAxis.add(new Point(new Coord3d(0, 0, 0)));
xAxis.add(new Point(new Coord3d(0.3, 0, 0)));
LineStrip zAxis = new LineStrip();
zAxis.setWireframeColor(Color.RED);
zAxis.add(new Point(new Coord3d(0, 0, 0)));
zAxis.add(new Point(new Coord3d(0, 0, 0.3)));
myComposite.add(xAxis);
myComposite.add(zAxis);
myComposite.add(yAxis);
}
}

2
settings-obf.xml.enc Normal file
View File

@ -0,0 +1,2 @@
$7v8й┼┌Л^┐q╣уг]z┼т}5Qд)b; ,NювХеТ╛DЪ5≥M╠рО┬0/ъ┴пм╕╖мЛ/XN┤╧i╧2Ey█Й╢5√n┼═╙█Sjф6ю0 jl╩E^0и╩бВ╥
ьnCОvlwуiбшд./Sw.dеD≤Й√GD╖├Ь7TR▐╬щQ▓╚┬┴┬┬&8╖Pь²║x┼┤pМ╕%┌KXPр

22
travis.help Normal file
View File

@ -0,0 +1,22 @@
# THIS IS A DOC, TRAVIS USES .travis.yml file
# http://docs.travis-ci.com/user/deployment/custom/
# http://docs.travis-ci.com/user/encrypting-files/
# http://docs.travis-ci.com/user/build-configuration
# https://groups.google.com/forum/#!topic/travis-ci/4e_oA0wSeUE
# Commands
# travis encrypt CI_DEPLOY_USERNAME=
# travis encrypt CI_DEPLOY_PASSWORD=
language: java
jdk:
- oraclejdk8
- oraclejdk7
- openjdk7
- openjdk6
after_success: "mvn deploy --settings settings-travis.xml"
env:
global:
secure: "FVvp1Z6IlE/qUmu1lDN2CyeNeFKQbN9kqicxLhhw8SedcC2/04wtj7w4g8ICYLWMkBWHySNSgXXf57zZjk8oibRtvTWZd+MtaB/5tYA+Tdxcj0+IHngbzQQ82aelzZB10Re8L/a4mjorxUtWkTJ1adwb9aArFSYt7wKoHaN4E94="
secure: "Lj4s1NEsJT0kmVFJkzdBXMKCEX0kobiPIXg3u0ZYNAt77+DG1SQYd4/l/UFQEHYKv0r2Cbz58iQpxwPzlgOpxbfkrODOC0RxD2mxjkTlz5MfSPG349X+Y+5S0S5zqYklJTcs4rhjtt+YOMp6r8JXiSWFiDWah61JXzwDjHijB3g="