Search in sources :

Example 1 with ProgressUpdate

use of org.hortonmachine.gears.ui.progress.ProgressUpdate in project hortonmachine by TheHortonMachine.

the class ExecutorExamples method runWithProgress.

public static void runWithProgress() {
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            int max = 15;
            new ExecutorProgressGui(max) {

                @Override
                public void backGroundWork() throws Exception {
                    for (int i = 0; i < max; i++) {
                        int workDone = i + 1;
                        publish(new ProgressUpdate("Working " + workDone + "...", workDone));
                        Thread.sleep(300);
                    }
                }
            }.execute();
        }
    });
}
Also used : ProgressUpdate(org.hortonmachine.gears.ui.progress.ProgressUpdate)

Example 2 with ProgressUpdate

use of org.hortonmachine.gears.ui.progress.ProgressUpdate in project hortonmachine by TheHortonMachine.

the class ExecutorExamples method runIndeterminate.

public static void runIndeterminate() {
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            new ExecutorIndeterminateGui() {

                @Override
                public void backGroundWork() throws Exception {
                    for (int i = 0; i < 15; i++) {
                        publish(new ProgressUpdate("Working...", (i + 1)));
                        Thread.sleep(300);
                    }
                }
            }.execute();
        }
    });
}
Also used : ProgressUpdate(org.hortonmachine.gears.ui.progress.ProgressUpdate)

Example 3 with ProgressUpdate

use of org.hortonmachine.gears.ui.progress.ProgressUpdate in project hortonmachine by TheHortonMachine.

the class ExecutorExamples method runWithProgressException.

public static void runWithProgressException() {
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            int max = 15;
            new ExecutorProgressGui(max) {

                @Override
                public void backGroundWork() throws Exception {
                    for (int i = 0; i < max; i++) {
                        int workDone = i + 1;
                        publish(new ProgressUpdate("Working " + workDone + "...", workDone));
                        Thread.sleep(300);
                        if (i == 3) {
                            throw new RuntimeException("Exiting due to error");
                        }
                    }
                }
            }.execute();
        }
    });
}
Also used : ProgressUpdate(org.hortonmachine.gears.ui.progress.ProgressUpdate)

Example 4 with ProgressUpdate

use of org.hortonmachine.gears.ui.progress.ProgressUpdate in project hortonmachine by TheHortonMachine.

the class HMExecutor method process.

@Override
protected void process(List<ProgressUpdate> chunks) {
    ProgressUpdate update = chunks.get(chunks.size() - 1);
    this.progress.publish(update);
}
Also used : ProgressUpdate(org.hortonmachine.gears.ui.progress.ProgressUpdate)

Example 5 with ProgressUpdate

use of org.hortonmachine.gears.ui.progress.ProgressUpdate in project hortonmachine by TheHortonMachine.

the class LasConstraints method applyConstraints.

/**
 * Get the data filtered by the current constraints.
 *
 * @param lasReader the reader.
 * @param doReread if true, the data are read again, else only the existing are filtered.
 * @param progressPrinter the monitor. This needs to consider that every 1000 a worked(1) is called.
 * @return the list of points to keep.
 * @throws Exception
 */
public void applyConstraints(ALasReader lasReader, boolean doReread, IProgressPrinter progressPrinter) throws Exception {
    boolean doSampling = false;
    int samp = -1;
    if (sampling != null) {
        doSampling = true;
        samp = sampling;
    }
    int count = 0;
    minInt = Double.POSITIVE_INFINITY;
    maxInt = Double.NEGATIVE_INFINITY;
    minClass = Double.POSITIVE_INFINITY;
    maxClass = Double.NEGATIVE_INFINITY;
    minImpulse = Double.POSITIVE_INFINITY;
    maxImpulse = Double.NEGATIVE_INFINITY;
    minElevation = Double.POSITIVE_INFINITY;
    maxElevation = Double.NEGATIVE_INFINITY;
    maxGroundHeight = Double.NEGATIVE_INFINITY;
    minGroundHeight = Double.POSITIVE_INFINITY;
    minIntensityConstrainD = minIntensityConstrain != null ? minIntensityConstrain : 0;
    maxIntensityConstrainD = maxIntensityConstrain != null ? maxIntensityConstrain : 0;
    westConstrainD = westConstrain != null ? westConstrain : 0;
    eastConstrainD = eastConstrain != null ? eastConstrain : 0;
    southConstrainD = southConstrain != null ? southConstrain : 0;
    northConstrainD = northConstrain != null ? northConstrain : 0;
    minZConstrainD = minZConstrain != null ? minZConstrain : 0;
    maxZConstrainD = maxZConstrain != null ? maxZConstrain : 0;
    lowerThresConstrainD = lowerThresConstrain != null ? lowerThresConstrain : 0;
    upperThresConstrainD = upperThresConstrain != null ? upperThresConstrain : 0;
    filteredEnvelope = new Envelope();
    if (doReread || lastReadPoints == null) {
        lastReadPoints = new ArrayList<>(1000000);
        try {
            int progress = 0;
            while (lasReader.hasNextPoint()) {
                if (count % 1000 == 0 && progressPrinter != null) {
                    progressPrinter.publish(new ProgressUpdate("Reading dataset...", progress++));
                }
                count++;
                LasRecord lasDot = lasReader.getNextPoint();
                boolean takeIt = checkPoint(lasDot, doSampling, samp, count);
                if (takeIt) {
                    lastReadPoints.add(lasDot);
                }
            }
            filteredPoints = lastReadPoints;
            System.out.println(filteredPoints.size());
        } finally {
            try {
                lasReader.rewind();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    } else {
        List<LasRecord> newFilteredPoints = new ArrayList<>(1000000);
        lastReadPoints.forEach(lr -> {
            // do not resample
            boolean takeIt = checkPoint(lr, false, -1, -1);
            if (takeIt) {
                newFilteredPoints.add(lr);
            }
        });
        filteredPoints = newFilteredPoints;
        System.out.println(filteredPoints.size());
    }
}
Also used : LasRecord(org.hortonmachine.gears.io.las.core.LasRecord) ArrayList(java.util.ArrayList) ProgressUpdate(org.hortonmachine.gears.ui.progress.ProgressUpdate) IOException(java.io.IOException) Envelope(org.locationtech.jts.geom.Envelope)

Aggregations

ProgressUpdate (org.hortonmachine.gears.ui.progress.ProgressUpdate)8 IOException (java.io.IOException)3 Envelope (org.locationtech.jts.geom.Envelope)3 ArrayList (java.util.ArrayList)2 SimpleFeatureCollection (org.geotools.data.simple.SimpleFeatureCollection)2 ReferencedEnvelope (org.geotools.geometry.jts.ReferencedEnvelope)2 ILasHeader (org.hortonmachine.gears.io.las.core.ILasHeader)2 ExecutorProgressGui (org.hortonmachine.gui.utils.executor.ExecutorProgressGui)2 Point (org.locationtech.jts.geom.Point)2 Polygon (org.locationtech.jts.geom.Polygon)2 BasicStroke (java.awt.BasicStroke)1 Color (java.awt.Color)1 Dimension (java.awt.Dimension)1 Graphics2D (java.awt.Graphics2D)1 Rectangle (java.awt.Rectangle)1 KeyEvent (java.awt.event.KeyEvent)1 KeyListener (java.awt.event.KeyListener)1 MouseEvent (java.awt.event.MouseEvent)1 MouseListener (java.awt.event.MouseListener)1 AffineTransform (java.awt.geom.AffineTransform)1