From 45a8fa929980b350b28b6071fbd9484073a67125 Mon Sep 17 00:00:00 2001 From: Maxim Date: Thu, 10 Oct 2024 21:30:00 +0300 Subject: [PATCH] Add GFPDMaskImage --- .../model/impl/pd/images/GFPDInlineImage.java | 6 ++ .../model/impl/pd/images/GFPDMaskImage.java | 59 +++++++++++++++++++ .../model/impl/pd/images/GFPDSMaskImage.java | 3 + .../gf/model/impl/pd/images/GFPDXImage.java | 25 +++++++- 4 files changed, 90 insertions(+), 3 deletions(-) create mode 100644 validation-model/src/main/java/org/verapdf/gf/model/impl/pd/images/GFPDMaskImage.java diff --git a/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/images/GFPDInlineImage.java b/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/images/GFPDInlineImage.java index 7faeffd4e..0dd3f599f 100644 --- a/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/images/GFPDInlineImage.java +++ b/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/images/GFPDInlineImage.java @@ -99,6 +99,7 @@ public List 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: @@ -154,4 +155,9 @@ private List getIntent() { } return Collections.emptyList(); } + + @Override + public Boolean getisMask() { + return false; + } } diff --git a/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/images/GFPDMaskImage.java b/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/images/GFPDMaskImage.java new file mode 100644 index 000000000..0bd6e7ae2 --- /dev/null +++ b/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/images/GFPDMaskImage.java @@ -0,0 +1,59 @@ +/** + * This file is part of veraPDF Validation, a module of the veraPDF project. + * Copyright (c) 2015-2024, veraPDF Consortium + * 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 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; + } + +} diff --git a/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/images/GFPDSMaskImage.java b/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/images/GFPDSMaskImage.java index 84bbb94f9..6320a28db 100644 --- a/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/images/GFPDSMaskImage.java +++ b/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/images/GFPDSMaskImage.java @@ -43,6 +43,9 @@ public GFPDSMaskImage(PDXImage simplePDObject, PDResourcesHandler resourcesHandl public List getLinkedObjects(String link) { switch (link) { case IMAGE_CS: + case MASK: + case S_MASK: + case ALTERNATES: return Collections.emptyList(); default: return super.getLinkedObjects(link); diff --git a/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/images/GFPDXImage.java b/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/images/GFPDXImage.java index c2a11ca24..e0cc5439f 100644 --- a/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/images/GFPDXImage.java +++ b/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/images/GFPDXImage.java @@ -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; @@ -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 jpeg2000List = null; private final org.verapdf.pd.colors.PDColorSpace inheritedFillCS; @@ -81,6 +83,11 @@ public Long getBitsPerComponent() { return ((org.verapdf.pd.images.PDXImage) simplePDObject).getBitsPerComponent(); } + @Override + public Boolean getisMask() { + return false; + } + @Override public List getLinkedObjects(String link) { switch (link) { @@ -94,6 +101,8 @@ public List getLinkedObjects(String link) { return this.getJPXStream(); case S_MASK: return this.getSMask(); + case MASK: + return this.getMask(); default: return super.getLinkedObjects(link); } @@ -102,9 +111,19 @@ public List getLinkedObjects(String link) { protected List getSMask() { org.verapdf.pd.images.PDXImage smask = ((org.verapdf.pd.images.PDXObject) simplePDObject).getSMask(); if (smask != null) { - List mask = new ArrayList<>(MAX_NUMBER_OF_ELEMENTS); - mask.add(new GFPDSMaskImage(smask, this.resourcesHandler)); - return Collections.unmodifiableList(mask); + List smasks = new ArrayList<>(MAX_NUMBER_OF_ELEMENTS); + smasks.add(new GFPDSMaskImage(smask, this.resourcesHandler)); + return Collections.unmodifiableList(smasks); + } + return Collections.emptyList(); + } + + protected List getMask() { + org.verapdf.pd.images.PDXImage mask = ((org.verapdf.pd.images.PDXObject) simplePDObject).getMask(); + if (mask != null) { + List masks = new ArrayList<>(MAX_NUMBER_OF_ELEMENTS); + masks.add(new GFPDMaskImage(mask, this.resourcesHandler)); + return Collections.unmodifiableList(masks); } return Collections.emptyList(); }