Package com.storedobject.svg
Class Document
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<Node>,Collection<Node>,List<Node>,RandomAccess,SequencedCollection<Node>
The Document class represents a collection of
Node objects and provides functionality
to generate scalable vector graphic (SVG) output for the collection. It allows the
storage and management of Node instances while adding SVG-specific methods to generate
graphical representations of the contained nodes.- Author:
- Syam
- See Also:
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionRetrieves the combined coordinates of all nodes within the Document.final StringGet the SVG output that fills its container (100% width and height).final StringgetScaledSvg(double scaleWidthPercentage, double scaleHeightPercentage) Get the SVG output with specified scale percentages for width and height.final StringgetSvg()Get the SVG output using its default dimensions.toString()Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, addFirst, addLast, clear, clone, contains, ensureCapacity, equals, forEach, get, getFirst, getLast, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeFirst, removeIf, removeLast, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSizeMethods inherited from class java.util.AbstractCollection
containsAllMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, stream, toArrayMethods inherited from interface java.util.List
containsAll, reversed
-
Constructor Details
-
Document
public Document()Default constructor for the Document class. Initializes a new instance of the Document without any content or nodes. -
Document
Constructs a new Document object, initializing it with a single Node.- Parameters:
node- The Node to be added to the Document during its creation.
-
-
Method Details
-
getCoordinates
Retrieves the combined coordinates of all nodes within the Document. If the Document is empty, default coordinates are returned.The method iterates over all nodes in the Document, ensuring that each node is built before accessing or combining their coordinates. Default coordinates (0, 0, 0.1, 0.1) are returned if the Document contains no nodes.
- Returns:
- A
Coordinatesobject representing either the combined coordinates of all nodes or default coordinates if the Document is empty.
-
getSvg
-
getFilledSvg
Get the SVG output that fills its container (100% width and height).- Returns:
- SVG string.
-
getScaledSvg
Get the SVG output with specified scale percentages for width and height. For keeping the aspect ratio, use negative values for the percentage.- Parameters:
scaleWidthPercentage- Scale percentage for width (0 to 100). An out-of-range value means "auto" width to keep the aspect ratio.scaleHeightPercentage- Scale percentage for height (0 to 100). An out-of-range value means "auto" height to keep the aspect ratio.- Returns:
- SVG string.
-
toString
- Overrides:
toStringin classAbstractCollection<Node>
-