Search in sources :

Example 11 with Point

use of com.geophile.z.spatialobject.d2.Point in project study-effective-java by doyoung0205.

the class Item10Test method transitivity2.

@Test
@DisplayName("equals - 컴포지션 사용")
void transitivity2() {
    // given
    Point p1 = new Point(1, 2);
    ColorPoint p2 = new ColorPoint(1, 2, Color.ORANGE);
    ColorPointComposition p3 = new ColorPointComposition(1, 2, Color.ORANGE);
    // when // then
    assertTrue(p1.equals(p2));
    assertTrue(p1.equals(p3.asPoint()));
    assertTrue(p2.equals(p3.asPoint()));
}
Also used : ColorPointComposition(study.heejin.chapter3.item10.ColorPointComposition) ColorPoint(study.heejin.chapter3.item10.ColorPoint) ColorPoint(study.heejin.chapter3.item10.ColorPoint) Point(study.heejin.chapter3.item10.Point) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 12 with Point

use of com.geophile.z.spatialobject.d2.Point in project for-study by godndas2.

the class ColorPoint method main.

// // 코드 10-3 잘못된 코드 - 추이성 위배! (57쪽)
// @Override public boolean equals(Object o) {
// if (!(o instanceof Point))
// return false;
// 
// // o가 일반 Point면 색상을 무시하고 비교한다.
// if (!(o instanceof ColorPoint))
// return o.equals(this);
// 
// // o가 ColorPoint면 색상까지 비교한다.
// return super.equals(o) && ((ColorPoint) o).color == color;
// }
public static void main(String[] args) {
    // 첫 번째 equals 메서드(코드 10-2)는 대칭성을 위배한다. (57쪽)
    Point p = new Point(1, 2);
    ColorPoint cp = new ColorPoint(1, 2, Color.RED);
    System.out.println(p.equals(cp) + " " + cp.equals(p));
    // 두 번째 equals 메서드(코드 10-3)는 추이성을 위배한다. (57쪽)
    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));
}
Also used : Point(com.forstudy.efjava.ch03.item10.Point)

Example 13 with Point

use of com.geophile.z.spatialobject.d2.Point in project effective-java by whiteship.

the class ColorPoint method main.

public static void main(String[] args) {
    // 첫 번째 equals 메서드(코드 10-2)는 대칭성을 위배한다. (57쪽)
    // Point p = new Point(1, 2);
    // ColorPoint cp = new ColorPoint(1, 2, Color.RED);
    // System.out.println(p.equals(cp) + " " + cp.equals(p));
    // 두 번째 equals 메서드(코드 10-3)는 추이성을 위배한다. (57쪽)
    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));
}
Also used : Point(me.whiteship.chapter02.item10.Point)

Example 14 with Point

use of com.geophile.z.spatialobject.d2.Point in project Lectures by FER-OOP.

the class MainList method main.

public static void main(String[] args) {
    List<Point> list = new ArrayList<>();
    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));
    System.out.println("Original list:\n" + list);
    Comparator<Point> comp = new PointComparator();
    list.sort(comp);
    System.out.println("Sorted by distance:\n" + list);
    list.sort(Comparator.naturalOrder());
    System.out.println("Sorted by natural order:\n" + list);
}
Also used : ArrayList(java.util.ArrayList) Point(hr.fer.oop.recap2.task2.Point)

Example 15 with Point

use of com.geophile.z.spatialobject.d2.Point in project Lectures by FER-OOP.

the class MainTreeSetCompositeComparator 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));
}
Also used : Point(hr.fer.oop.recap2.task2.Point)

Aggregations

Point (net.imglib2.Point)33 ArrayList (java.util.ArrayList)16 FloatType (net.imglib2.type.numeric.real.FloatType)11 Test (org.junit.Test)9 List (java.util.List)8 Point (com.google.monitoring.v3.Point)7 Point (hr.fer.oop.recap2.task2.Point)7 FinalInterval (net.imglib2.FinalInterval)7 RealPoint (net.imglib2.RealPoint)7 TimeSeries (com.google.monitoring.v3.TimeSeries)6 Point (de.micromata.opengis.kml.v_2_2_0.Point)6 Interval (net.imglib2.Interval)6 RandomAccessibleInterval (net.imglib2.RandomAccessibleInterval)6 HyperSphere (net.imglib2.algorithm.region.hypersphere.HyperSphere)6 AffineTransform3D (net.imglib2.realtransform.AffineTransform3D)6 HashMap (java.util.HashMap)5 Metric (com.google.api.Metric)4 TimeInterval (com.google.monitoring.v3.TimeInterval)4 TypedValue (com.google.monitoring.v3.TypedValue)4 Map (java.util.Map)4