Skip to content

Commit 3d6c173

Browse files
authored
Merge pull request #1 from Nuix/intersection_report_prototype
Intersection report prototype
2 parents 097098c + 93e19ca commit 3d6c173

14 files changed

+1038
-5
lines changed

Java/src/main/java/com/nuix/superutilities/SuperUtilities.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public BulkCaseProcessor createBulkCaseProcessor(){
187187
}
188188

189189
/***
190-
* Saves a diagnostics zip file (similar to same operation in the GUI)
190+
* Saves a diagnostics zip file (similar to same operation in the workbench GUI)
191191
* @param zipFile File object specifying where the zip file should be saved to.
192192
*/
193193
public void saveDiagnostics(File zipFile){

Java/src/main/java/com/nuix/superutilities/cases/BulkCaseProcessor.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,7 @@ public void withEachCase(Case currentCaseFromGui, CaseConsumer caseWorkFunction)
169169
}
170170
} catch (Exception e) {
171171
// User code threw exception but didnt catch it
172-
logger.error("Error in user provided case work function:");
173-
logger.error(e);
172+
logger.error("Error in user provided case work function:",e);
174173
if(userFunctionErrorCallback != null){
175174
WorkFunctionErrorEvent userFunctionErrorInfo = new WorkFunctionErrorEvent(caseInfo, e);
176175
userFunctionErrorCallback.accept(userFunctionErrorInfo);
@@ -192,8 +191,7 @@ public void withEachCase(Case currentCaseFromGui, CaseConsumer caseWorkFunction)
192191
}
193192

194193
} catch (Exception e) {
195-
logger.error("Error opening case: ");
196-
logger.error(e);
194+
logger.error("Error opening case: ",e);
197195
// On case open error notify callback if was provided
198196
if(caseErrorCallback != null){
199197
CaseOpenErrorEvent caseErrorInfo = new CaseOpenErrorEvent(caseInfo, e);
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package com.nuix.superutilities.reporting;
2+
3+
import com.aspose.cells.Color;
4+
5+
/***
6+
* A class containing helper methods for working with Aspose Cells colors.
7+
* @author Jason Wells
8+
*
9+
*/
10+
public class AsposeCellsColorHelper {
11+
/***
12+
* Tints a particular color channel value by a certain degree.
13+
* @param colorChannelValue Color channel value (0-255) to tint
14+
* @param degree The degree in which to tint the color channel.
15+
* @return A tinted version of the color channel value
16+
*/
17+
public static int tintChannel(int colorChannelValue, float degree){
18+
if(degree == 0)
19+
return colorChannelValue;
20+
21+
int tint = (int) (colorChannelValue + (degree * (255f - (float)colorChannelValue)));
22+
if(tint < 0)
23+
return 0;
24+
else if(tint > 255)
25+
return 255;
26+
else
27+
return tint;
28+
}
29+
30+
/***
31+
* Tints a color by the given degree
32+
* @param red Red color channel value (0-255)
33+
* @param green Green color channel value (0-255)
34+
* @param blue Blue color channel value (0-255)
35+
* @param degree Degree to which all the color channels will be tinted
36+
* @return A new Color object which has been tinted the specified amount
37+
*/
38+
public static Color getTint(int red, int green, int blue, float degree){
39+
return Color.fromArgb(
40+
tintChannel(red,degree),
41+
tintChannel(green,degree),
42+
tintChannel(blue,degree)
43+
);
44+
}
45+
46+
/***
47+
* Helper method to convert signed byte to unsigned int
48+
* @param b The input byte value
49+
* @return Unsigned int equivalent
50+
*/
51+
private static int byteToUnsignedInt(byte b) {
52+
return b & 0xFF;
53+
}
54+
55+
/***
56+
*
57+
* @param baseColor
58+
* @param degree
59+
* @return
60+
*/
61+
public static Color getTint(Color baseColor, float degree) {
62+
return getTint(
63+
byteToUnsignedInt(baseColor.getR()),
64+
byteToUnsignedInt(baseColor.getG()),
65+
byteToUnsignedInt(baseColor.getB()),
66+
degree
67+
);
68+
}
69+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.nuix.superutilities.reporting;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
6+
import com.aspose.cells.Border;
7+
import com.aspose.cells.BorderCollection;
8+
import com.aspose.cells.BorderType;
9+
import com.aspose.cells.CellBorderType;
10+
import com.aspose.cells.Color;
11+
import com.aspose.cells.Style;
12+
13+
/***
14+
* A class containing helper methods for working with Aspose Cells Styles.
15+
* @author Jason Wells
16+
*
17+
*/
18+
public class AsposeCellsStyleHelper {
19+
/***
20+
* Convenience method for applying a thin black border to all sides of a given cell style.
21+
* @param style The style to modify the borders of.
22+
*/
23+
public static void enableAllBorders(Style style) {
24+
BorderCollection bordersCollection = style.getBorders();
25+
List<Border> borders = new ArrayList<Border>();
26+
borders.add(bordersCollection.getByBorderType(BorderType.LEFT_BORDER));
27+
borders.add(bordersCollection.getByBorderType(BorderType.TOP_BORDER));
28+
borders.add(bordersCollection.getByBorderType(BorderType.RIGHT_BORDER));
29+
borders.add(bordersCollection.getByBorderType(BorderType.BOTTOM_BORDER));
30+
for(Border border : borders) {
31+
border.setColor(Color.getBlack());
32+
border.setLineStyle(CellBorderType.THIN);
33+
}
34+
}
35+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package com.nuix.superutilities.reporting;
2+
3+
import java.util.ArrayList;
4+
import java.util.Iterator;
5+
import java.util.List;
6+
7+
import com.aspose.cells.Color;
8+
9+
/***
10+
* Iterator over a collection of Aspose Cells Color objects. When the end of the collection is hit it
11+
* automatically starts at the beginning again, effectively creating an infinite circular collection.
12+
* @author Jason Wells
13+
*
14+
*/
15+
public class ColorRing implements Iterator<Color> {
16+
17+
private List<Color> colors = new ArrayList<Color>();
18+
int pos = 0;
19+
20+
@Override
21+
public boolean hasNext() {
22+
return colors.size() > 0;
23+
}
24+
25+
@Override
26+
public Color next() {
27+
Color nextColor = colors.get(pos);
28+
pos++;
29+
if(pos > colors.size() - 1) {
30+
pos = 0;
31+
}
32+
return nextColor;
33+
}
34+
35+
/***
36+
* Adds the provided base color and series of tinted variations to this instance.
37+
* @param baseColor The based color to start with
38+
* @param tintSteps The number of additional tinted versions of the base color to add
39+
*/
40+
public void addTintSeries(Color baseColor, int tintSteps) {
41+
for (int i = 0; i <= tintSteps; i++) {
42+
colors.add(AsposeCellsColorHelper.getTint(baseColor, (float)i));
43+
}
44+
}
45+
46+
/***
47+
* Clears all colors currently assigned to this instance.
48+
*/
49+
public void clearColors() {
50+
colors.clear();
51+
}
52+
53+
/***
54+
* Moves position of this collection back to the start so that next call to {@link #next()} will return
55+
* the first color in the sequence.
56+
*/
57+
public void restart() {
58+
pos = 0;
59+
}
60+
61+
public void addColor(int red, int green, int blue) {
62+
colors.add(Color.fromArgb(red, green, blue));
63+
}
64+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.nuix.superutilities.reporting;
2+
3+
import nuix.Case;
4+
5+
/***
6+
* Base class for reporting. You should not use this class directly, but instead use classes
7+
* derived from it.
8+
* @author Jason Wells
9+
*
10+
*/
11+
public class ColumnValueGenerator {
12+
protected String label = "Value";
13+
protected String columnLabel = null;
14+
public Object generateValue(Case nuixCase, String query) { return "Not Implemented"; }
15+
16+
/***
17+
* Gets the label associated to this instance.
18+
* @return The associated label
19+
*/
20+
public String getLabel() {
21+
return label;
22+
}
23+
24+
public String getColumnLabel() {
25+
if(columnLabel == null) { return label; }
26+
else { return columnLabel; }
27+
}
28+
29+
/***
30+
* Sets the label associated to this instance
31+
* @param label The label to associate
32+
*/
33+
public void setLabel(String label) {
34+
this.label = label;
35+
}
36+
37+
public void setColumnLabel(String categoryLabel) {
38+
this.columnLabel = categoryLabel;
39+
}
40+
}

0 commit comments

Comments
 (0)