Skip to content

Commit

Permalink
Prep for release 2.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
gwlucastrig committed Jan 10, 2021
1 parent 05c0d84 commit eb1eea4
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 101 deletions.
2 changes: 1 addition & 1 deletion analysis/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<groupId>org.tinfour</groupId>
<artifactId>Tinfour</artifactId>
<version>2.1.5-SNAPSHOT</version>
<version>2.1.5</version>
</parent>

<artifactId>TinfourAnalysis</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<groupId>org.tinfour</groupId>
<artifactId>Tinfour</artifactId>
<version>2.1.5-SNAPSHOT</version>
<version>2.1.5</version>
</parent>

<artifactId>TinfourCore</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<groupId>org.tinfour</groupId>
<artifactId>Tinfour</artifactId>
<version>2.1.5-SNAPSHOT</version>
<version>2.1.5</version>
</parent>

<artifactId>TinfourDemo</artifactId>
Expand Down
71 changes: 42 additions & 29 deletions demo/src/main/java/org/tinfour/demo/examples/LogoPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(
RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setRenderingHint(
RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

// set up an AffineTransform to map the TIN to the rendering area:
// a. The TIN should be scaled uniformly so that its
Expand All @@ -115,32 +115,46 @@ public void paintComponent(Graphics g) {
g.setColor(Color.white);
g.fillRect(0, 0, w, h);

// This particular application is going to draw the TIN twice,
// one image above the other. To do that, we adjust the h value to
// half its height, fit the TIN to that space, and then adjust it back.
h = h / 2; // half high
// This particular application is going to draw the TIN three times,
// with the images stacked vertically. To ensure uniform spacing
// between TINs, we allow a 1.1 vertical factor so that the spacing
// between rows is 0.1 times the hight of the figure.
Rectangle2D bounds = tin.getBounds();
double bH = (2 * 0.1 + 3) * bounds.getHeight();
double bW = bounds.getWidth();

// compare aspect ratios of the data bounds and panel to determine
// how to scale the data
// how to scale the data. Also, allow 10 pixels of white space on all sides
w -= 2 * 10;
h -= 2 * 10;
double scale;
double aB = bounds.getWidth() / bounds.getHeight();
double aB = bW / bH;
double aP = (double) w / (double) h;
if (aP / aB > 1) {
// the panel is fatter than the bounds
double aspectRatio = aP / aB;
if (aspectRatio > 1) {
// the panel is fatter than the adjusted bounds
// the height of the panel is the limiting factor
scale = h / (bounds.getHeight() * oversize);
scale = h / bH;
} else {
// the panel is skinnier than the bounds
// the width of the bounds is the limiting factor
scale = w / (bounds.getWidth() * oversize);
scale = w / bounds.getWidth();
}

// find the offset by scaling the center of the bounds and
// computing how far off from the pixel center it ends up
int xOffset = (int) ((w / 2.0 - scale * bounds.getCenterX()));
int yOffset = (int) ((h / 2.0 + scale * bounds.getCenterY()));
// compute the size of a single entry
double sHeight = bounds.getHeight() * scale;
double sWidth = bW * scale;

// Compute the X offset for the AffineTransformation by centering the
// overall image horizontally. The Y offset is a little more
// complicated because there are three rows of rendering and
// the initial offset is set for the top of the first row.
// This calculation will center the image set vertically.
double yOffset = getHeight() / 2 + bounds.getCenterY() * scale - sHeight * 1.1;
double xOffset = (getWidth() - sWidth) / 2;

AffineTransform af
= new AffineTransform(scale, 0, 0, -scale, xOffset, yOffset);
= new AffineTransform(scale, 0, 0, -scale, xOffset, yOffset);

final Point2D p0 = new Point2D.Double();
final Point2D p1 = new Point2D.Double();
Expand All @@ -162,7 +176,7 @@ public void paintComponent(Graphics g) {
// are drawn in light gray. For aesthetic reasons, we want
// the border edges to be drawn on top of the interior edges,
// so we conduct this render operation in two passes.
yOffset += 1.15 * scale * bounds.getHeight();
yOffset += 1.1 * sHeight;
af = new AffineTransform(scale, 0, 0, -scale, xOffset, yOffset);

g2d.setColor(Color.lightGray);
Expand All @@ -189,7 +203,7 @@ public void paintComponent(Graphics g) {
// would be the same triangles as the ones created by the
// containing polygon. So we check the polygon getArea() method.
// If it returns a negative value, we skip the polygon.
yOffset += 1.15 * scale * bounds.getHeight();
yOffset += 1.1 * sHeight;
af = new AffineTransform(scale, 0, 0, -scale, xOffset, yOffset);

final AffineTransform at = af; // Java needs this to be final
Expand All @@ -206,9 +220,8 @@ public void paintComponent(Graphics g) {
Object obj = constraint.getApplicationData();
g2d.setColor((Color) obj);
TriangleCollector.visitTrianglesForConstrainedRegion(
constraint,
new Consumer<Vertex[]>()
{
constraint,
new Consumer<Vertex[]>() {
@Override
public void accept(final Vertex[] triangle) {
p0.setLocation(triangle[0].x, triangle[0].y);
Expand Down Expand Up @@ -240,7 +253,7 @@ public void accept(final Vertex[] triangle) {
// from the constraint itself and draw it in a continuous path. The
// result takes advantage of Java's rendering logic and produces a more
// pleasing line.
g2d.setColor(new Color(128, 128, 128, 128));
g2d.setColor(new Color(64, 64, 64, 128));
for (IQuadEdge e : tin.edges()) {
if (e.isConstrainedRegionInterior()) {
mapEdge(e, af, p0, p1, l2d);
Expand Down Expand Up @@ -269,10 +282,10 @@ public static LogoPanel plot(final IIncrementalTin tin, final String header) {
try {
// Set System L&F
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException |
InstantiationException |
IllegalAccessException |
UnsupportedLookAndFeelException ex) {
} catch (ClassNotFoundException
| InstantiationException
| IllegalAccessException
| UnsupportedLookAndFeelException ex) {
ex.printStackTrace(System.err);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* ---------------------------------------------------------------------
*/

/*
/*
* -----------------------------------------------------------------------
*
* Revision History:
Expand All @@ -27,7 +27,7 @@
*
* -----------------------------------------------------------------------
*/
package org.tinfour.test.performance;
package org.tinfour.demo.performance;

import java.io.File;
import java.io.IOException;
Expand All @@ -45,9 +45,6 @@
import org.tinfour.demo.utils.IDevelopmentTest;
import org.tinfour.demo.utils.TestOptions;
import org.tinfour.demo.utils.VertexLoader;
import org.tinfour.gis.las.ILasRecordFilter;
import org.tinfour.gis.las.LasPoint;


/**
* Performs time test on randomly selected subsets of the samples from an input
Expand All @@ -56,53 +53,16 @@
*/
public class TimeDueToSampleSize implements IDevelopmentTest {

private static class RecordFilter implements ILasRecordFilter {

int classification;
double thinningFactor;
Random random = new Random();

/**
* Implement a thinning filter.
*
* @param classification only accept points of the designated
* classification (or -1 for wildcards).
* @param thinningFactor the fraction of the sample points to accept
* (1.0 to include all sample points).
*/
public RecordFilter(int classification, double thinningFactor) {
this.classification = classification;
this.thinningFactor = thinningFactor;
}

@Override
public boolean accept(LasPoint record) {
// on the theory that withheld records are relatively uncommon
// test on classification first
if (record.withheld) {
return false;
}
if (classification >= 0 && record.classification != classification) {
return false;
}
if (thinningFactor == 1) {
return true;
}
double test = random.nextDouble();
return test < thinningFactor;

}

}

private static class Result implements Comparable<Result> {

double timeMS;
long nVertices;
long timeOfExecution;

Result(double timeMS, long nVertices) {
this.timeMS = timeMS;
this.nVertices = nVertices;
this.timeOfExecution = System.currentTimeMillis();

}

Expand Down Expand Up @@ -136,7 +96,7 @@ public static void main(String args[]) {

}

private static final String[] usage = {
private static final String[] usage = {
"usage: TimeDueToSampleSize",
" Mandatory Arguments:",
" -in <valid LAS file or sample-point text file>",
Expand All @@ -163,21 +123,20 @@ public static void main(String args[]) {
" processed by each iteration."
};


@Override
public void runTest(PrintStream ps, String[] args) throws IOException {
if (args.length == 0) {
for(String s: usage){
ps.println(s);
for (String s : usage) {
ps.println(s);
}
return;
}
TestOptions options = new TestOptions();
boolean[] recognized = options.argumentScan(args);
File target = options.getInputFile();
if(target==null){
if (target == null) {
ps.println("Missing valid input target");
return;
return;
}

Class<?> tinClass = options.getTinClass();
Expand All @@ -189,7 +148,6 @@ public void runTest(PrintStream ps, String[] args) throws IOException {
+ " is not in valid range >0 to 1.0");
}


options.checkForUnrecognizedArgument(args, recognized);

long seed = options.getRandomSeed(0);
Expand All @@ -204,11 +162,11 @@ public void runTest(PrintStream ps, String[] args) throws IOException {
VertexLoader loader = new VertexLoader();
loader.setPreSortEnabed(true);
masterList = loader.readInputFile(options);
int nMasterVertices = masterList.size();
int nMasterVertices = masterList.size();

Date date = new Date();
SimpleDateFormat sdFormat =
new SimpleDateFormat("dd MMM yyyy HH:mm", Locale.getDefault());
SimpleDateFormat sdFormat
= new SimpleDateFormat("dd MMM yyyy HH:mm", Locale.getDefault());
sdFormat.setTimeZone(new SimpleTimeZone(0, "UTC"));
String dateString = sdFormat.format(date);
ps.println("Date of test: " + dateString);
Expand All @@ -226,18 +184,15 @@ public void runTest(PrintStream ps, String[] args) throws IOException {
ps.println("Max Samples: " + nMasterVertices);
ps.println("");



// The pre-test. We load the Tin a few of times to make sure the
// class loader and JIT have completed their initialization.

for (int iPretest = 0; iPretest < 3; iPretest++) {
ps.println("Running Pre-Test "+iPretest);
ps.println("Running Pre-Test " + iPretest);
IIncrementalTin tin = options.getNewInstanceOfTestTin();
if (tin == null) {
return;
}
tin.add(masterList, null);
tin.add(masterList, null);
tin.dispose();
getUsedMemory();
}
Expand All @@ -253,17 +208,20 @@ public void runTest(PrintStream ps, String[] args) throws IOException {
" n_vertices, m_vertices, time_ms, used_mb, total_mb, used_bytes");
for (int iThin = 1; iThin <= nTests; iThin++) {
mem0 = getUsedMemory();
double thinningFactor = 1.0;
double thinningFactor = random.nextDouble();
if (randomSize != null && randomSize > 0) {
thinningFactor = randomSize * random.nextDouble();
thinningFactor *= randomSize;
}
if(thinningFactor<0.025){
if (thinningFactor < 0.025) {
thinningFactor = 0.025;
}
List<Vertex>vertexList = new ArrayList<>();
int skip = (int)Math.ceil(1.0/thinningFactor);
for(int i=0; i<nMasterVertices; i+=skip){
vertexList.add(masterList.get(i));

List<Vertex> vertexList = new ArrayList<>();
for (int i = 0; i < nMasterVertices; i++) {
double test = random.nextDouble();
if (test <= thinningFactor) {
vertexList.add(masterList.get(i));
}
}
int nVertices = vertexList.size();
IIncrementalTin tin = options.getNewInstanceOfTestTin();
Expand Down
2 changes: 1 addition & 1 deletion gis/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>org.tinfour</groupId>
<artifactId>Tinfour</artifactId>
<version>2.1.5-SNAPSHOT</version>
<version>2.1.5</version>
</parent>

<artifactId>TinfourGis</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<groupId>org.tinfour</groupId>
<artifactId>Tinfour</artifactId>
<version>2.1.5-SNAPSHOT</version>
<version>2.1.5</version>
<packaging>pom</packaging>

<name>Tinfour</name>
Expand Down
2 changes: 1 addition & 1 deletion svm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<groupId>org.tinfour</groupId>
<artifactId>Tinfour</artifactId>
<version>2.1.5-SNAPSHOT</version>
<version>2.1.5</version>
</parent>

<artifactId>TinfourSvm</artifactId>
Expand Down

0 comments on commit eb1eea4

Please sign in to comment.