Skip to content

Commit

Permalink
Add GFPDMaskImage
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximPlusov committed Oct 15, 2024
1 parent 216166f commit 4c367d4
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public List<? extends Object> getLinkedObjects(String link) {
case GFPDXImage.IMAGE_CS:
return this.getImageCS();
case GFPDXImage.S_MASK:
case GFPDXImage.MASK:
case GFPDXObject.OPI:
case GFPDXImage.ALTERNATES:
case GFPDXImage.JPX_STREAM:
Expand Down Expand Up @@ -154,4 +155,9 @@ private List<CosRenderingIntent> getIntent() {
}
return Collections.emptyList();
}

@Override
public Boolean getisMask() {
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* This file is part of veraPDF Validation, a module of the veraPDF project.
* Copyright (c) 2015-2024, veraPDF Consortium <[email protected]>
* All rights reserved.
*
* veraPDF Validation is free software: you can redistribute it and/or modify
* it under the terms of either:
*
* The GNU General public license GPLv3+.
* You should have received a copy of the GNU General Public License
* along with veraPDF Validation as the LICENSE.GPL file in the root of the source
* tree. If not, see http://www.gnu.org/licenses/ or
* https://www.gnu.org/licenses/gpl-3.0.en.html.
*
* The Mozilla Public License MPLv2+.
* You should have received a copy of the Mozilla Public License along with
* veraPDF Validation as the LICENSE.MPL file in the root of the source tree.
* If a copy of the MPL was not distributed with this file, you can obtain one at
* http://mozilla.org/MPL/2.0/.
*/
package org.verapdf.gf.model.impl.pd.images;

import org.verapdf.gf.model.impl.pd.util.PDResourcesHandler;
import org.verapdf.model.baselayer.Object;
import org.verapdf.model.pdlayer.PDMaskImage;
import org.verapdf.pd.images.PDXImage;

import java.util.Collections;
import java.util.List;

/**
* @author Maxim Plushchov
*/
public class GFPDMaskImage extends GFPDXImage implements PDMaskImage {

public static final String MASK_IMAGE_TYPE = "PDMaskImage";

public GFPDMaskImage(PDXImage simplePDObject, PDResourcesHandler resourcesHandler) {
super(simplePDObject, resourcesHandler, null, MASK_IMAGE_TYPE);
}

@Override
public List<? extends Object> getLinkedObjects(String link) {
switch (link) {
case INTENT:
case IMAGE_CS:
case MASK:
return Collections.emptyList();
default:
return super.getLinkedObjects(link);
}
}

@Override
public Boolean getisMask() {
return true;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public GFPDSMaskImage(PDXImage simplePDObject, PDResourcesHandler resourcesHandl
public List<? extends Object> getLinkedObjects(String link) {
switch (link) {
case IMAGE_CS:
case MASK:
case S_MASK:
case ALTERNATES:
return Collections.emptyList();
default:
return super.getLinkedObjects(link);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.verapdf.model.coslayer.CosRenderingIntent;
import org.verapdf.model.external.JPEG2000;
import org.verapdf.model.pdlayer.PDColorSpace;
import org.verapdf.model.pdlayer.PDMaskImage;
import org.verapdf.model.pdlayer.PDSMaskImage;
import org.verapdf.model.pdlayer.PDXImage;

Expand All @@ -51,6 +52,7 @@ public class GFPDXImage extends GFPDXObject implements PDXImage {
public static final String INTENT = "Intent";
public static final String JPX_STREAM = "jpxStream";
public static final String S_MASK = "SMask";
public static final String MASK = "Mask";

private List<JPEG2000> jpeg2000List = null;
private final org.verapdf.pd.colors.PDColorSpace inheritedFillCS;
Expand Down Expand Up @@ -81,6 +83,11 @@ public Long getBitsPerComponent() {
return ((org.verapdf.pd.images.PDXImage) simplePDObject).getBitsPerComponent();
}

@Override
public Boolean getisMask() {
return false;
}

@Override
public List<? extends Object> getLinkedObjects(String link) {
switch (link) {
Expand All @@ -94,6 +101,8 @@ public List<? extends Object> getLinkedObjects(String link) {
return this.getJPXStream();
case S_MASK:
return this.getSMask();
case MASK:
return this.getMask();
default:
return super.getLinkedObjects(link);
}
Expand All @@ -102,9 +111,19 @@ public List<? extends Object> getLinkedObjects(String link) {
protected List<PDSMaskImage> getSMask() {
org.verapdf.pd.images.PDXImage smask = ((org.verapdf.pd.images.PDXObject) simplePDObject).getSMask();
if (smask != null) {
List<PDSMaskImage> mask = new ArrayList<>(MAX_NUMBER_OF_ELEMENTS);
mask.add(new GFPDSMaskImage(smask, this.resourcesHandler));
return Collections.unmodifiableList(mask);
List<PDSMaskImage> smasks = new ArrayList<>(MAX_NUMBER_OF_ELEMENTS);
smasks.add(new GFPDSMaskImage(smask, this.resourcesHandler));
return Collections.unmodifiableList(smasks);
}
return Collections.emptyList();
}

protected List<PDMaskImage> getMask() {
org.verapdf.pd.images.PDXImage mask = ((org.verapdf.pd.images.PDXObject) simplePDObject).getMask();
if (mask != null) {
List<PDMaskImage> masks = new ArrayList<>(MAX_NUMBER_OF_ELEMENTS);
masks.add(new GFPDMaskImage(mask, this.resourcesHandler));
return Collections.unmodifiableList(masks);
}
return Collections.emptyList();
}
Expand Down

0 comments on commit 4c367d4

Please sign in to comment.