From eb1eea4e09f2175a9df89773cd489a8c9fd5adc6 Mon Sep 17 00:00:00 2001 From: gwlucastrig Date: Sun, 10 Jan 2021 16:34:00 -0500 Subject: [PATCH] Prep for release 2.1.5 --- analysis/pom.xml | 2 +- core/pom.xml | 2 +- demo/pom.xml | 2 +- .../org/tinfour/demo/examples/LogoPanel.java | 71 +++++++++------ .../demo/performance/TimeDueToSampleSize.java | 90 +++++-------------- gis/pom.xml | 2 +- pom.xml | 2 +- svm/pom.xml | 2 +- 8 files changed, 72 insertions(+), 101 deletions(-) diff --git a/analysis/pom.xml b/analysis/pom.xml index 41616d4b..446a74e5 100644 --- a/analysis/pom.xml +++ b/analysis/pom.xml @@ -10,7 +10,7 @@ org.tinfour Tinfour - 2.1.5-SNAPSHOT + 2.1.5 TinfourAnalysis diff --git a/core/pom.xml b/core/pom.xml index e19024a9..24e07341 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -10,7 +10,7 @@ org.tinfour Tinfour - 2.1.5-SNAPSHOT + 2.1.5 TinfourCore diff --git a/demo/pom.xml b/demo/pom.xml index ecfe8ef6..abf214b2 100644 --- a/demo/pom.xml +++ b/demo/pom.xml @@ -10,7 +10,7 @@ org.tinfour Tinfour - 2.1.5-SNAPSHOT + 2.1.5 TinfourDemo diff --git a/demo/src/main/java/org/tinfour/demo/examples/LogoPanel.java b/demo/src/main/java/org/tinfour/demo/examples/LogoPanel.java index 349fe902..16d86541 100644 --- a/demo/src/main/java/org/tinfour/demo/examples/LogoPanel.java +++ b/demo/src/main/java/org/tinfour/demo/examples/LogoPanel.java @@ -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 @@ -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(); @@ -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); @@ -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 @@ -206,9 +220,8 @@ public void paintComponent(Graphics g) { Object obj = constraint.getApplicationData(); g2d.setColor((Color) obj); TriangleCollector.visitTrianglesForConstrainedRegion( - constraint, - new Consumer() - { + constraint, + new Consumer() { @Override public void accept(final Vertex[] triangle) { p0.setLocation(triangle[0].x, triangle[0].y); @@ -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); @@ -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); } diff --git a/demo/src/main/java/org/tinfour/demo/performance/TimeDueToSampleSize.java b/demo/src/main/java/org/tinfour/demo/performance/TimeDueToSampleSize.java index b73063c8..3d5a2c09 100644 --- a/demo/src/main/java/org/tinfour/demo/performance/TimeDueToSampleSize.java +++ b/demo/src/main/java/org/tinfour/demo/performance/TimeDueToSampleSize.java @@ -15,7 +15,7 @@ * --------------------------------------------------------------------- */ -/* + /* * ----------------------------------------------------------------------- * * Revision History: @@ -27,7 +27,7 @@ * * ----------------------------------------------------------------------- */ -package org.tinfour.test.performance; +package org.tinfour.demo.performance; import java.io.File; import java.io.IOException; @@ -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 @@ -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 { double timeMS; long nVertices; + long timeOfExecution; Result(double timeMS, long nVertices) { this.timeMS = timeMS; this.nVertices = nVertices; + this.timeOfExecution = System.currentTimeMillis(); } @@ -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 ", @@ -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(); @@ -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); @@ -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); @@ -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(); } @@ -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; } - ListvertexList = new ArrayList<>(); - int skip = (int)Math.ceil(1.0/thinningFactor); - for(int i=0; i 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(); diff --git a/gis/pom.xml b/gis/pom.xml index abebcc9d..b7513b17 100644 --- a/gis/pom.xml +++ b/gis/pom.xml @@ -8,7 +8,7 @@ org.tinfour Tinfour - 2.1.5-SNAPSHOT + 2.1.5 TinfourGis diff --git a/pom.xml b/pom.xml index 085654c0..707127aa 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ org.tinfour Tinfour - 2.1.5-SNAPSHOT + 2.1.5 pom Tinfour diff --git a/svm/pom.xml b/svm/pom.xml index 26729f0c..6c4d5418 100644 --- a/svm/pom.xml +++ b/svm/pom.xml @@ -10,7 +10,7 @@ org.tinfour Tinfour - 2.1.5-SNAPSHOT + 2.1.5 TinfourSvm