MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / __add__

Method __add__

src/main/java/field/graphics/FLine.java:1948–2009  ·  view source on GitHub ↗
(Object b)

Source from the content-addressed store, hash-verified

1946 } else if (b instanceof Vec3) {
1947 Vec3 finalB = (Vec3) b;
1948 return byTransforming(x -> new Vec3(x).add(finalB));
1949 } else if (b instanceof Quat) {
1950 Quat finalB = (Quat) b;
1951 return byTransforming(x -> finalB.transform(x, new Vec3()));
1952 } else if (b instanceof FLine) {
1953 Shape s1 = FLinesAndJavaShapes.flineToJavaShape(this);
1954 Shape s2 = FLinesAndJavaShapes.flineToJavaShape((FLine) b);
1955
1956 Area a1 = new Area(s1);
1957 Area a2 = new Area(s2);
1958 a1.add(a2);
1959 FLine ret = FLinesAndJavaShapes.javaShapeToFLine(a1);
1960 ret.attributes = this.attributes.duplicate(ret);
1961 return ret;
1962 } else if (b instanceof ScriptObjectMirror && ((ScriptObjectMirror) b).isArray()) {
1963 List b2 = ((ScriptObjectMirror) b).to(List.class);
1964
1965 if (b2 instanceof List && (((List) b2).size() > 0)) {
1966
1967 Object oo = ((List) b2).get(0);
1968 if (oo instanceof Vec3) {
1969 return new FLine().append((List<FLine>) ((List) b2).stream().map(x -> this.__add__(x)).collect(Collectors.toList())).copyAttributesFrom(this);
1970 } else if (oo instanceof Vec2) {
1971 return new FLine().append((List<FLine>) ((List) b2).stream().map(x -> this.__add__(x)).collect(Collectors.toList())).copyAttributesFrom(this);
1972 } else if (oo instanceof OverloadedMath) {
1973 List m = (List) ((List) b2).stream().map(x -> this.__add__(x)).collect(Collectors.toList());
1974 if (m.size() > 0) {
1975 if (m.get(0) instanceof FLine) {
1976 return new FLine().append((List<FLine>) m);
1977 }
1978 }
1979 return m;
1980 }
1981 }
1982 } else if (b instanceof List && (((List) b).size() > 0)) {
1983
1984 Object oo = ((List) b).get(0);
1985 if (oo instanceof Vec3) {
1986 return new FLine().append((List<FLine>) ((List) b).stream().map(x -> this.__add__(x)).collect(Collectors.toList())).copyAttributesFrom(this);
1987 } else if (oo instanceof Vec2) {
1988 return new FLine().append((List<FLine>) ((List) b).stream().map(x -> this.__add__(x)).collect(Collectors.toList())).copyAttributesFrom(this);
1989 } else if (oo instanceof OverloadedMath) {
1990 List m = (List) ((List) b).stream().map(x -> this.__add__(x)).collect(Collectors.toList());
1991 if (m.size() > 0) {
1992 if (m.get(0) instanceof FLine) {
1993 return new FLine().append((List<FLine>) m);
1994 }
1995 }
1996 return m;
1997 }
1998
1999
2000 } else if (b instanceof OverloadedMath) return ((OverloadedMath) b).__radd__(this);
2001 throw new ClassCastException(" can't add '" + b + "' to this FLine");
2002 }
2003
2004 @Override
2005 @HiddenInAutocomplete

Callers 1

__sub__Method · 0.95

Calls 15

byTransformingMethod · 0.95
transformMethod · 0.95
flineToJavaShapeMethod · 0.95
javaShapeToFLineMethod · 0.95
toMethod · 0.80
copyAttributesFromMethod · 0.80
collectMethod · 0.80
duplicateMethod · 0.65
getMethod · 0.65
__radd__Method · 0.65
toVec3Method · 0.45
addMethod · 0.45

Tested by

no test coverage detected