Skip to content

Commit

Permalink
Merge pull request #1 from Nuix/intersection_report_prototype
Browse files Browse the repository at this point in the history
Intersection report prototype
  • Loading branch information
JuicyDragon authored Jan 24, 2019
2 parents 097098c + 93e19ca commit 3d6c173
Show file tree
Hide file tree
Showing 14 changed files with 1,038 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public BulkCaseProcessor createBulkCaseProcessor(){
}

/***
* Saves a diagnostics zip file (similar to same operation in the GUI)
* Saves a diagnostics zip file (similar to same operation in the workbench GUI)
* @param zipFile File object specifying where the zip file should be saved to.
*/
public void saveDiagnostics(File zipFile){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,7 @@ public void withEachCase(Case currentCaseFromGui, CaseConsumer caseWorkFunction)
}
} catch (Exception e) {
// User code threw exception but didnt catch it
logger.error("Error in user provided case work function:");
logger.error(e);
logger.error("Error in user provided case work function:",e);
if(userFunctionErrorCallback != null){
WorkFunctionErrorEvent userFunctionErrorInfo = new WorkFunctionErrorEvent(caseInfo, e);
userFunctionErrorCallback.accept(userFunctionErrorInfo);
Expand All @@ -192,8 +191,7 @@ public void withEachCase(Case currentCaseFromGui, CaseConsumer caseWorkFunction)
}

} catch (Exception e) {
logger.error("Error opening case: ");
logger.error(e);
logger.error("Error opening case: ",e);
// On case open error notify callback if was provided
if(caseErrorCallback != null){
CaseOpenErrorEvent caseErrorInfo = new CaseOpenErrorEvent(caseInfo, e);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package com.nuix.superutilities.reporting;

import com.aspose.cells.Color;

/***
* A class containing helper methods for working with Aspose Cells colors.
* @author Jason Wells
*
*/
public class AsposeCellsColorHelper {
/***
* Tints a particular color channel value by a certain degree.
* @param colorChannelValue Color channel value (0-255) to tint
* @param degree The degree in which to tint the color channel.
* @return A tinted version of the color channel value
*/
public static int tintChannel(int colorChannelValue, float degree){
if(degree == 0)
return colorChannelValue;

int tint = (int) (colorChannelValue + (degree * (255f - (float)colorChannelValue)));
if(tint < 0)
return 0;
else if(tint > 255)
return 255;
else
return tint;
}

/***
* Tints a color by the given degree
* @param red Red color channel value (0-255)
* @param green Green color channel value (0-255)
* @param blue Blue color channel value (0-255)
* @param degree Degree to which all the color channels will be tinted
* @return A new Color object which has been tinted the specified amount
*/
public static Color getTint(int red, int green, int blue, float degree){
return Color.fromArgb(
tintChannel(red,degree),
tintChannel(green,degree),
tintChannel(blue,degree)
);
}

/***
* Helper method to convert signed byte to unsigned int
* @param b The input byte value
* @return Unsigned int equivalent
*/
private static int byteToUnsignedInt(byte b) {
return b & 0xFF;
}

/***
*
* @param baseColor
* @param degree
* @return
*/
public static Color getTint(Color baseColor, float degree) {
return getTint(
byteToUnsignedInt(baseColor.getR()),
byteToUnsignedInt(baseColor.getG()),
byteToUnsignedInt(baseColor.getB()),
degree
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.nuix.superutilities.reporting;

import java.util.ArrayList;
import java.util.List;

import com.aspose.cells.Border;
import com.aspose.cells.BorderCollection;
import com.aspose.cells.BorderType;
import com.aspose.cells.CellBorderType;
import com.aspose.cells.Color;
import com.aspose.cells.Style;

/***
* A class containing helper methods for working with Aspose Cells Styles.
* @author Jason Wells
*
*/
public class AsposeCellsStyleHelper {
/***
* Convenience method for applying a thin black border to all sides of a given cell style.
* @param style The style to modify the borders of.
*/
public static void enableAllBorders(Style style) {
BorderCollection bordersCollection = style.getBorders();
List<Border> borders = new ArrayList<Border>();
borders.add(bordersCollection.getByBorderType(BorderType.LEFT_BORDER));
borders.add(bordersCollection.getByBorderType(BorderType.TOP_BORDER));
borders.add(bordersCollection.getByBorderType(BorderType.RIGHT_BORDER));
borders.add(bordersCollection.getByBorderType(BorderType.BOTTOM_BORDER));
for(Border border : borders) {
border.setColor(Color.getBlack());
border.setLineStyle(CellBorderType.THIN);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package com.nuix.superutilities.reporting;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import com.aspose.cells.Color;

/***
* Iterator over a collection of Aspose Cells Color objects. When the end of the collection is hit it
* automatically starts at the beginning again, effectively creating an infinite circular collection.
* @author Jason Wells
*
*/
public class ColorRing implements Iterator<Color> {

private List<Color> colors = new ArrayList<Color>();
int pos = 0;

@Override
public boolean hasNext() {
return colors.size() > 0;
}

@Override
public Color next() {
Color nextColor = colors.get(pos);
pos++;
if(pos > colors.size() - 1) {
pos = 0;
}
return nextColor;
}

/***
* Adds the provided base color and series of tinted variations to this instance.
* @param baseColor The based color to start with
* @param tintSteps The number of additional tinted versions of the base color to add
*/
public void addTintSeries(Color baseColor, int tintSteps) {
for (int i = 0; i <= tintSteps; i++) {
colors.add(AsposeCellsColorHelper.getTint(baseColor, (float)i));
}
}

/***
* Clears all colors currently assigned to this instance.
*/
public void clearColors() {
colors.clear();
}

/***
* Moves position of this collection back to the start so that next call to {@link #next()} will return
* the first color in the sequence.
*/
public void restart() {
pos = 0;
}

public void addColor(int red, int green, int blue) {
colors.add(Color.fromArgb(red, green, blue));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.nuix.superutilities.reporting;

import nuix.Case;

/***
* Base class for reporting. You should not use this class directly, but instead use classes
* derived from it.
* @author Jason Wells
*
*/
public class ColumnValueGenerator {
protected String label = "Value";
protected String columnLabel = null;
public Object generateValue(Case nuixCase, String query) { return "Not Implemented"; }

/***
* Gets the label associated to this instance.
* @return The associated label
*/
public String getLabel() {
return label;
}

public String getColumnLabel() {
if(columnLabel == null) { return label; }
else { return columnLabel; }
}

/***
* Sets the label associated to this instance
* @param label The label to associate
*/
public void setLabel(String label) {
this.label = label;
}

public void setColumnLabel(String categoryLabel) {
this.columnLabel = categoryLabel;
}
}
Loading

0 comments on commit 3d6c173

Please sign in to comment.