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();
}
});
}
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();
}
});
}
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();
}
});
}
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);
}
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());
}
}
Aggregations