Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX 902 #280

Merged
merged 3 commits into from
Jun 10, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class GFPDDeviceN extends GFPDColorSpace implements PDDeviceN {
public static final String ALTERNATE = "alternate";
public static final String COLORANT_NAMES = "colorantNames";
public static final String COLORANTS = "Colorants";
public static final String PROCESS_COLOR = "processColor";

public static final Set<ASAtom> IGNORED_COLORANTS;

Expand All @@ -69,7 +70,7 @@ private static boolean areColorantsPresent(org.verapdf.pd.colors.PDDeviceN simpl
if (attributes != null && attributes.getType() == COSObjType.COS_DICT) {
COSObject colorantsDict = attributes.getKey(ASAtom.COLORANTS);
List<COSObject> colorantsArray = simplePDObject.getNames();
Set<ASAtom> componentNames = new TreeSet<>();
Set<ASAtom> componentNames = new HashSet<>();
if (colorantsDict != null && colorantsDict.getType() == COSObjType.COS_DICT) {
componentNames.addAll(colorantsDict.getKeySet());
}
Expand Down Expand Up @@ -98,11 +99,11 @@ private static COSArray getProcessComponents(COSObject attributes) {
}

private static boolean areColorantsPresent(Set<ASAtom> colorantDictionaryEntries,
List<COSObject> colorantsArray) {
List<COSObject> colorantsArray) {
for (int i = 0; i < colorantsArray.size(); ++i) {
COSObject object = colorantsArray.get(i);
if (object != null && !isNone(object) && !IGNORED_COLORANTS.contains(object.getName()) &&
!colorantDictionaryEntries.contains(object.getName())) {
!colorantDictionaryEntries.contains(object.getName())) {
return false;
}
}
Expand All @@ -127,11 +128,33 @@ public List<? extends Object> getLinkedObjects(String link) {
return this.getColorantNames();
case COLORANTS:
return this.getColorants();
case PROCESS_COLOR:
return this.getProcessColor();
default:
return super.getLinkedObjects(link);
}
}

private List<PDColorSpace> getProcessColor() {
COSObject attributes = ((org.verapdf.pd.colors.PDDeviceN) this.simplePDObject).getAttributes();
if (isNullOrNotDictionary(attributes)) {
return Collections.emptyList();
}
COSObject processDict = attributes.getKey(ASAtom.PROCESS);
if (isNullOrNotDictionary(processDict)) {
return Collections.emptyList();
}
COSObject cs = processDict.getKey(ASAtom.COLORSPACE);
org.verapdf.pd.colors.PDColorSpace colorSpace = org.verapdf.factory.colors.ColorSpaceFactory
.getColorSpace(cs);

if (colorSpace == null) {
return Collections.emptyList();
}

return Collections.singletonList(ColorSpaceFactory.getColorSpace(colorSpace));
}

private List<PDColorSpace> getAlternate() {
org.verapdf.pd.colors.PDColorSpace alternateColorSpace = ((org.verapdf.pd.colors.PDDeviceN) this.simplePDObject)
.getAlternateSpace();
Expand Down Expand Up @@ -180,4 +203,8 @@ private static List<PDSeparation> getColorants(COSObject colorantsDict) {
}
return Collections.unmodifiableList(list);
}

private boolean isNullOrNotDictionary(COSObject toCheck) {
return toCheck == null || toCheck.getType() != COSObjType.COS_DICT;
}
}