-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Nuix/intersection_report_prototype
Intersection report prototype
- Loading branch information
Showing
14 changed files
with
1,038 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
Java/src/main/java/com/nuix/superutilities/reporting/AsposeCellsColorHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
Java/src/main/java/com/nuix/superutilities/reporting/AsposeCellsStyleHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
Java/src/main/java/com/nuix/superutilities/reporting/ColorRing.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
Java/src/main/java/com/nuix/superutilities/reporting/ColumnValueGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.