Skip to content

Commit fbdbc5c

Browse files
committed
Add warning message on import when opacity is always zero
1 parent 551491d commit fbdbc5c

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

modules/ImportAPI/src/main/java/org/gephi/io/importer/impl/ImportContainerImpl.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,10 @@ public boolean verify() {
766766
.getMessage(ImportContainerImpl.class, "ImportContainerLog.MultiGraphCount", edgeTypeMap.size() - 1));
767767
}
768768

769+
//Check that not all alpha are zeros
770+
checkColorAlpha(nodeList, "Node");
771+
checkColorAlpha(edgeList, "Edge");
772+
769773
return true;
770774
}
771775

@@ -1085,6 +1089,25 @@ private EdgeDraftImpl getOpposite(EdgeDraftImpl edge) {
10851089
return null;
10861090
}
10871091

1092+
private void checkColorAlpha(ObjectList<? extends ElementDraft> objectList, String elementType) {
1093+
if (!objectList.isEmpty()) {
1094+
int validElement = 0;
1095+
int withAlphaZero = 0;
1096+
for (ElementDraft element : objectList) {
1097+
if (element.getColor() != null) {
1098+
validElement++;
1099+
withAlphaZero += element.getColor().getAlpha() == 0 ? 1 : 0;
1100+
}
1101+
}
1102+
if (validElement > 0 && validElement == withAlphaZero) {
1103+
report.logIssue(new Issue(
1104+
NbBundle.getMessage(ImportContainerImpl.class,
1105+
"ImportContainerException_" + elementType + "_Color_Alpha_AllZero"),
1106+
Level.WARNING));
1107+
}
1108+
}
1109+
}
1110+
10881111
private void checkElementDraftImpl(ElementDraft elmt) {
10891112
if (elmt == null) {
10901113
throw new NullPointerException();

modules/ImportAPI/src/main/resources/org/gephi/io/importer/impl/Bundle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ ImportContainerException_Negative_Weight = Edge id=''{0}'' has a negative weight
3232
ImportContainerException_Column_Type_Mismatch = A column ''{0}'' already exists but with a different type=''{1}''
3333
ImportContainerException_Timestamp_Parse_Error = The graph timestamp ''{0}'' could not be parsed
3434
ImportContainerException_Interval_Parse_Error = The graph interval ''{0}'' could not be parsed
35+
ImportContainerException_Node_Color_Alpha_AllZero = All nodes color opacity is set as transparent
36+
ImportContainerException_Edge_Color_Alpha_AllZero = All edges color opacity is set as transparent
3537
3638
ElementFactoryException_NullNodeId = Node id can't be null
3739
ElementFactoryException_NullEdgeId = Edge id can't be null

0 commit comments

Comments
 (0)