use of com.geophile.z.spatialobject.d2.Point in project flimj-ui by flimlib.
the class SettingsCtrl method IRFDatasetFromFile.
private FitParams<FloatType> IRFDatasetFromFile(String irfPath) throws IOException {
FitParams<FloatType> irfParams = new FitParams<>();
if (irfPath.endsWith(".asc")) {
// read whitespace separated data
ArrayList<Float> irfTrans = new ArrayList<>();
Scanner sc = new Scanner(new File(irfPath));
while (sc.hasNextBigDecimal()) irfTrans.add(sc.nextBigDecimal().floatValue());
sc.close();
// get origTrans' size and ltAxis
int ltAxis = fp.getParams().ltAxis;
long[] transDim = new long[3];
fp.getOrigTrans().dimensions(transDim);
float[] irfTransArr = new float[(int) transDim[ltAxis]];
// place the data at the end so that the leading 0's can be used for shifting
for (int i = Math.max(irfTransArr.length - irfTrans.size(), 0), j = 0; i < irfTransArr.length; i++, j++) irfTransArr[i] = irfTrans.get(j);
// create a fake image out of a single array along the ltAxis
irfParams.transMap = Views.interval(Views.extendBorder(ArrayImgs.floats(irfTransArr, new long[] { 1, 1, irfTransArr.length })), new long[] { 0, 0, 0 }, new long[] { transDim[0] - 1, transDim[1] - 1, transDim[2] - 1 });
irfParams.ltAxis = ltAxis;
} else if (getDss().canOpen(irfPath)) {
final Dataset dataset = getDss().open(irfPath);
final Localizable pos = new Point(Intervals.minAsLongArray(dataset));
if (!FitParamsPrompter.populate(irfParams, dataset, pos))
irfParams = null;
}
return irfParams;
}
use of com.geophile.z.spatialobject.d2.Point in project Lectures by FER-OOP.
the class MainTreeSet method addToSet.
private static void addToSet(Set<Point> set) {
set.add(new Point(-5, 12));
set.add(new Point(3, -4));
set.add(new Point(12, 9));
set.add(new Point(3, 4));
set.add(new Point(4, 3));
set.add(new Point(-9, 12));
set.add(new Point(-5, -12));
}
use of com.geophile.z.spatialobject.d2.Point in project Lectures by FER-OOP.
the class Main method addPoints.
private static void addPoints(List<Point> list) {
list.add(new Point(-5, 12));
list.add(new Point(3, -4));
list.add(new Point(12, 9));
list.add(new Point(3, 4));
list.add(new Point(4, 3));
list.add(new Point(-9, 12));
list.add(new Point(-5, -12));
}
use of com.geophile.z.spatialobject.d2.Point in project Lectures by FER-OOP.
the class Main method center.
// public static <T extends Point<? extends Number>> Point<Double> center(MyList<T> list){
public static Point<Double> center(MyList<Point<? extends Number>> list) {
double x = 0;
double y = 0;
int size = list.size();
for (int i = 0; i < size; i++) {
Point<? extends Number> p = list.elementAt(i);
x += p.getX().doubleValue();
y += p.getY().doubleValue();
}
Point<Double> point = new Point<>(x / size, y / size);
return point;
}
use of com.geophile.z.spatialobject.d2.Point in project wiki by acktsap.
the class ColorPoint method main.
// // Broken - violates transitivity! (page 42)
// @Override public boolean equals(Object o) {
// if (!(o instanceof Point))
// return false;
//
// // If o is a normal Point, do a color-blind comparison
// if (!(o instanceof ColorPoint))
// return o.equals(this);
//
// // o is a ColorPoint; do a full comparison
// return super.equals(o) && ((ColorPoint) o).color == color;
// }
public static void main(String[] args) {
// First equals function violates symmetry (Page 42)
Point p = new Point(1, 2);
ColorPoint cp = new ColorPoint(1, 2, Color.RED);
System.out.println(p.equals(cp) + " " + cp.equals(p));
// Second equals function violates transitivity (Page 42)
ColorPoint p1 = new ColorPoint(1, 2, Color.RED);
Point p2 = new Point(1, 2);
ColorPoint p3 = new ColorPoint(1, 2, Color.BLUE);
System.out.printf("%s %s %s%n", p1.equals(p2), p2.equals(p3), p1.equals(p3));
}
Aggregations