Skip to main content

ArrayPointCollection Class

A collection of point arrays that specify ink annotation paths.

Declaration

public class ArrayPointCollection extends TrackedObjectCollection<PointF[]>

Remarks

Call the InkAnnotation.setInks(value) method to specify ink annotation paths. Each collection item is a PointF array that specifies a single path.

The collection implements the java.util.List interface and does not accept null items. If you add or insert a null item or replace an item with null, the API throws an ArgumentNullException. If you pass an index outside the collection bounds, the API throws an ArgumentOutOfRangeException.

Refer to the following help topic for additional information: Drawing Annotations.

Example

Add a Freehand Drawing to a Page

The following code snippet adds a freehand drawing to the first page:

Ink Annotation, DevExpress PDF Document API for Java

package pdf;

import com.devexpress.docs.pdf.*;
import com.devexpress.system.drawing.*;

import java.nio.channels.*;
import java.nio.file.*;
import java.util.List;

public class Main {
    public static void main(String[] args) throws Exception {
        try (FileChannel fileChannel = FileChannel.open(Path.of("Document.pdf"));
             PdfDocument pdfDocument = new PdfDocument(fileChannel)) {

            Page page = pdfDocument.getPages().getFirst();

            createInkAnnotation(page);

            try (WritableByteChannel channel =
                         FileChannel.open(Path.of("Result.pdf"),
                                 StandardOpenOption.CREATE,
                                 StandardOpenOption.WRITE,
                                 StandardOpenOption.TRUNCATE_EXISTING)) {

                pdfDocument.save(channel);
            }
        }
    }

    static void createInkAnnotation(Page page) {
        List<PointF[]> inks = List.of(
                new PointF[] { new PointF(100, 300),
                        new PointF(120, 290),
                        new PointF(150, 305),
                        new PointF(180, 295)
                },
                new PointF[] {
                        new PointF(210, 320),
                        new PointF(240, 340),
                        new PointF(270, 330)
                }
        );

        InkAnnotation annotation = new InkAnnotation(new RectangleF(80, 780, 260, 120));
        annotation.setInks(new ArrayPointCollection(inks));
        annotation.setTitle("Reviewer");
        annotation.setContent("Handwritten note.");
        annotation.setColor(PdfColor.getBlue());

        page.getAnnotations().add(annotation);
    }
}

Inherited Members

com.devexpress.java.internal.collections.JListAdapter.add(T)
com.devexpress.java.internal.collections.JListAdapter.add(int,T)
com.devexpress.java.internal.collections.JListAdapter.clear()
com.devexpress.java.internal.collections.JListAdapter.contains(java.lang.Object)
com.devexpress.java.internal.collections.JListAdapter.get(int)
com.devexpress.java.internal.collections.JListAdapter.indexOf(java.lang.Object)
com.devexpress.java.internal.collections.JListAdapter.remove(int)
com.devexpress.java.internal.collections.JListAdapter.remove(java.lang.Object)
com.devexpress.java.internal.collections.JListAdapter.set(int,T)
com.devexpress.java.internal.collections.JListAdapter.size()
java.lang.Object.clone()
java.lang.Object.finalize()
java.lang.Object.getClass()
java.lang.Object.notify()
java.lang.Object.notifyAll()
java.lang.Object.wait()
java.lang.Object.wait(long)
java.lang.Object.wait(long,int)
java.util.AbstractCollection.<T>toArray(T[])
java.util.AbstractCollection.addAll(java.util.Collection<? extends E>)
java.util.AbstractCollection.containsAll(java.util.Collection<?>)
java.util.AbstractCollection.isEmpty()
java.util.AbstractCollection.removeAll(java.util.Collection<?>)
java.util.AbstractCollection.retainAll(java.util.Collection<?>)
java.util.AbstractCollection.toArray()
java.util.AbstractCollection.toString()
java.util.AbstractList.add(E)
java.util.AbstractList.add(int,E)
java.util.AbstractList.addAll(int,java.util.Collection<? extends E>)
java.util.AbstractList.equals(java.lang.Object)
java.util.AbstractList.hashCode()
java.util.AbstractList.iterator()
java.util.AbstractList.lastIndexOf(java.lang.Object)
java.util.AbstractList.listIterator()
java.util.AbstractList.listIterator(int)
java.util.AbstractList.removeRange(int,int)
java.util.AbstractList.set(int,E)
java.util.AbstractList.subList(int,int)

Inheritance

Object
java.util.AbstractCollection
java.util.AbstractList
JListAdapter
TrackedObjectCollection<T>
ArrayPointCollection

Constructors

ArrayPointCollection() Constructor

Initializes a new instance of the ArrayPointCollection class.

Declaration

public ArrayPointCollection()

ArrayPointCollection(Iterable<PointF[]> points) Constructor

Initializes a new instance of the ArrayPointCollection class with the specified point arrays.

Declaration

public ArrayPointCollection(Iterable<PointF[]> points)

Parameters

Name Type Description
points java.lang.Iterable<com.devexpress.system.drawing.PointF[]>

Point arrays to add to the collection.

Exceptions

Type Description
ArgumentNullException

Thrown if the points collection contains a null item.

Methods

getSource() Method

Returns the internal collection that stores collection items.

Declaration

public ArrayPointCollection getSource()

Returns

Type Description
com.devexpress.docs.pdf.internal.ArrayPointCollection

The internal collection.

Remarks

The getSource() method supports the internal infrastructure of the PDF Document API. Do not call the getSource() method in your code.

objectClone() Method

Returns a copy of the collection.

Declaration

public ArrayPointCollection objectClone()

Returns

Type Description
ArrayPointCollection

A new collection that contains the same point arrays.

Remarks

The objectClone method does not copy point arrays. The copy and the source collection contain the same PointF array instances.