Skip to content

Commit 259204b

Browse files
committed
formatting update
1 parent 9f48a4c commit 259204b

33 files changed

Lines changed: 136 additions & 1 deletion

build.gradle

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
buildscript {
2+
3+
dependencies {
4+
classpath 'org.eclipse.jdt:org.eclipse.jdt.core:3.35.0'
5+
classpath 'org.eclipse.platform:org.eclipse.text:3.14.0'
6+
}
7+
}
8+
import groovy.xml.XmlSlurper
9+
import org.eclipse.jdt.core.ToolFactory
10+
import org.eclipse.jdt.core.formatter.CodeFormatter
11+
import org.eclipse.jface.text.Document
12+
113
plugins {
214
id 'eclipse'
315
id 'java'
@@ -7,16 +19,36 @@ plugins {
719
id 'com.diffplug.spotless' version '6.25.0'
820
}
921

22+
1023
spotless {
1124
java {
1225
lineEndings = com.diffplug.spotless.LineEnding.UNIX
13-
eclipse('4.26')
26+
custom('eclipseFormatterDirect') { String source ->
27+
def configFile = new File(projectDir, 'config/eclipse-formatter.xml')
28+
def options = new HashMap<String, String>()
29+
def xml = new XmlSlurper().parse(configFile)
30+
xml.profile.setting.each { setting ->
31+
options[setting.@id.text()] = setting.@value.text()
32+
}
33+
def formatter = ToolFactory.createCodeFormatter(options, ToolFactory.M_FORMAT_EXISTING)
34+
def edit = formatter.format(
35+
CodeFormatter.K_COMPILATION_UNIT,
36+
source, 0, source.length(), 0, System.lineSeparator()
37+
)
38+
if (edit == null) {
39+
throw new GradleException("Eclipse formatter returned null — source may have a syntax error")
40+
}
41+
def doc = new Document(source)
42+
edit.apply(doc)
43+
doc.get()
44+
}
1445
removeUnusedImports()
1546
trimTrailingWhitespace()
1647
endWithNewline()
1748
}
1849
}
1950

51+
2052
java {
2153
sourceCompatibility = JavaVersion.VERSION_25
2254
targetCompatibility = JavaVersion.VERSION_25

config/eclipse-formatter.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<profiles version="21">
3+
<profile kind="CodeFormatterProfile" name="SpotlessProfile" version="21">
4+
<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="false"/>
5+
<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="false"/>
6+
<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="false"/>
7+
<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code_changes_on_save" value="false"/>
8+
9+
<!-- Preserve blank lines in code -->
10+
<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="2"/>
11+
12+
<!-- Preserve blank lines between declarations -->
13+
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/>
14+
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/>
15+
</profile>
16+
</profiles>

src/main/java/com/neuronrobotics/manifold3d/CSGManifold3d.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ public ArrayList<Polygon> sliceAtZero(CSG incoming, Transform slicePlane, double
163163
throw new RuntimeException("Failed to slice CSG at Z=0", e);
164164
}
165165
}
166+
166167
/**
167168
* Returns the union of two CSG solids. Uses {@code manifold.union(a, b)}
168169
* directly (wrapper around {@code manifold_union} in the C library).
@@ -181,6 +182,7 @@ public CSG minkowski_difference(CSG a, CSG b) throws Throwable {
181182
manifold.delete(mb);
182183
}
183184
}
185+
184186
/**
185187
* calculateAreaAndSurfaceArea
186188
*
@@ -197,6 +199,7 @@ public CSG minkowski_difference(CSG a, CSG b) throws Throwable {
197199
public CSG calculateAreaAndSurfaceArea(CSG in) throws Throwable {
198200
return fromManifold(toManifold(in), in.getColor());
199201
}
202+
200203
/**
201204
* Returns the union of two CSG solids. Uses {@code manifold.union(a, b)}
202205
* directly (wrapper around {@code manifold_union} in the C library).

src/main/java/eu/mihosoft/vrl/v3d/Bounds.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ public String toString() {
219219
public boolean contains(Transform com) {
220220
return contains(new Vector3d(com.getX(), com.getY(), com.getZ()));
221221
}
222+
222223
/**
223224
* Helper function wrapping bounding box values
224225
*
@@ -326,6 +327,7 @@ public double getTotalY() {
326327
public double getTotalZ() {
327328
return (-this.getMinZ() + this.getMaxZ());
328329
}
330+
329331
public boolean isBoundsTouching(Bounds incoming) {
330332
return this.getMaxX() > incoming.getMinX() && this.getMinX() < incoming.getMaxX()
331333
&& this.getMaxY() > incoming.getMinY() && this.getMinY() < incoming.getMaxY()

src/main/java/eu/mihosoft/vrl/v3d/CSG.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,7 @@ public MeshView getMesh() {
556556
setCurrentMeshView(newMesh());
557557
return getCurrentMeshView();
558558
}
559+
559560
/**
560561
* Gets the mesh.
561562
*
@@ -565,6 +566,7 @@ public MeshView getMesh() {
565566
public MeshView newMesh() {
566567
return newMesh(false);
567568
}
569+
568570
/**
569571
* Gets the mesh.
570572
*
@@ -3946,6 +3948,7 @@ public CSG setMaterialInfillPercent(double type) {
39463948
getStorage().set("materialInfillPercent", type);
39473949
return this;
39483950
}
3951+
39493952
public Optional<Double> getMateriaDensity() {
39503953
return getStorage().getValue("materialDensity");
39513954
}
@@ -3954,6 +3957,7 @@ public CSG setMaterialDensity(double type) {
39543957
getStorage().set("materialDensity", type);
39553958
return this;
39563959
}
3960+
39573961
private void syncCadoodleCatagories(CSG dyingCSG) {
39583962
setIsHole(dyingCSG.isHole());
39593963
setIsHide(dyingCSG.isHide());

src/main/java/eu/mihosoft/vrl/v3d/CSGResponse.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,14 @@ public void setState(ServerActionState state) {
5757
public String getMessage() {
5858
return message;
5959
}
60+
6061
public void setMessage(Throwable t) {
6162
StringWriter sw = new StringWriter();
6263
PrintWriter pw = new PrintWriter(sw);
6364
t.printStackTrace(pw);
6465
this.message = sw.toString();
6566
}
67+
6668
public void setMessage(String message) {
6769
this.message = message;
6870
}

src/main/java/eu/mihosoft/vrl/v3d/CSGServer.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,13 @@ public CSGServer(int port, File APIKEYS) {
6060
System.err.println("NO API KEYFILE Provided: " + APIKEYS.getAbsolutePath());
6161
}
6262
}
63+
6364
public void addListener(ICSGServerEvent e) {
6465
if (listeners.contains(e))
6566
return;
6667
listeners.add(e);
6768
}
69+
6870
public void removeListener(ICSGServerEvent e) {
6971
if (!listeners.contains(e))
7072
return;

src/main/java/eu/mihosoft/vrl/v3d/Cube.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ public Cube(Vector3d center, Vector3d dimensions) {
109109
public Cube(double w, double h, double d) {
110110
this(Vector3d.ZERO, new Vector3d(w, h, d));
111111
}
112+
112113
// public Cube(LengthParameter w, LengthParameter h, LengthParameter d) {
113114
// this(Vector3d.ZERO, new Vector3d(w.getMM(), h.getMM(), d.getMM()));
114115
//// parametrics.add(w);

src/main/java/eu/mihosoft/vrl/v3d/Cylinder.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ public Cylinder(double startRadius, double endRadius, double height, int numSlic
166166
this.endRadius = endRadius < MINIMUM_RADIUS ? MINIMUM_RADIUS : endRadius;
167167
this.numSlices = numSlices;
168168
}
169+
169170
/**
170171
* Constructor. Creates a cylinder ranging from {@code [0,0,0]} to
171172
* {@code [0,0,height]} with the specified {@code radius} and {@code height}.
@@ -201,6 +202,7 @@ public Cylinder(double startRadius, double endRadius, double height) {
201202
this.startRadius = startRadius < MINIMUM_RADIUS ? MINIMUM_RADIUS : startRadius;
202203
this.endRadius = endRadius < MINIMUM_RADIUS ? MINIMUM_RADIUS : endRadius;
203204
}
205+
204206
// public Cylinder(LengthParameter startRadius, LengthParameter endRadius,
205207
// LengthParameter height, int numSlices) {
206208
// this(startRadius.getMM(),endRadius.getMM(),height.getMM(),numSlices);

src/main/java/eu/mihosoft/vrl/v3d/Debug3dProvider.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ public static void addObject(Object o) {
66
if (isProviderAvailible())
77
provider.addObject(o);
88
}
9+
910
public static void clearScreen() {
1011
if (isProviderAvailible())
1112
provider.clearScreen();
1213
}
14+
1315
public static boolean isProviderAvailible() {
1416
return provider != null;
1517
}
18+
1619
/**
1720
* @param provider
1821
* the provider to set

0 commit comments

Comments
 (0)