package org.djutils.draw; import java.io.Serializable; import java.util.Iterator; import org.djutils.draw.point.Point; /** * Drawable is an interface to indicate zero or more points can be retrieved to draw the object. *
* Copyright (c) 2020-2021 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
* BSD-style license. See DJUTILS License.
*
The point type (2d or 3d)
* @param The space type (2d or 3d)
*/
public interface Drawable
, S extends Space> extends Serializable { /** * Retrieve, or generate all points that make up the object. * @return Iterable<Point2d>; an iterator that generates all points that make up the object */ Iterator extends P> getPoints(); /** * Retrieve the number of points that make up the object. * @return int; the number of points that make up the object */ int size(); /** * Produce a string describing the Drawable using default conversion for the (double) coordinate values. Regrettably, it is * not allowed to provide a default implementation here. * @return String; a string describing the Drawable */ @Override String toString(); /** * Produce a String describing the Drawable. * @param doubleFormat String; a format string (something like "%6.3f") which will be used to render every coordinate value) * @param doNotIncludeClassName boolean; if true; the output of toString is not prefixed by the class name. This is * useful for concatenating the textual representation of lots of Drawables (e.g. an array, or a List). * @return String; textual representation of the Drawable */ String toString(String doubleFormat, boolean doNotIncludeClassName); /** * Produce a String describing the Drawable. * @param doubleFormat String; a format string (something like "%6.3f") which will be used to render every coordinate value) * @return String; textual representation of the Drawable */ default String toString(final String doubleFormat) { return toString(doubleFormat, false); } /** * Produce a String describing the Drawable. * @param doNotIncludeClassName boolean; if true; the output of toString is not prefixed by the class name. This is * useful for concatenating the textual representation of lots of Drawables (e.g. an array, or a List). * @return String; textual representation of the Drawable */ default String toString(final boolean doNotIncludeClassName) { return toString("%f", doNotIncludeClassName); } }