Class TikzExporter
- All Implemented Interfaces:
VectorSink
PIXELS_PER_CM and the Y axis is inverted (TikZ grows
upwards while the screen grows downwards). Edge geometry is taken verbatim from
EdgeGeometry: curved edges are emitted with their exact control point
(.. controls (cx,cy) ..), never re-approximated with to[bend].
The styles are emitted once at the top as a \tikzset block with the names
tnnode, tnnode-contingent, tnnode-observer, tnedge-requirement,
tnedge-contingent, tnedge-derived, tnedge-wait and
tn-negative-cycle, so that all figures of an article stay homogeneous and the author can
redefine them in his own preamble. In standaloneDocument mode a compilable standalone
document is emitted; otherwise only the tikzpicture environment. Both modes open with a
comment listing the required packages.
Labels are LaTeX-escaped (see the escaping table in the report); node identifiers are sanitized so that TikZ accepts them while the visible label keeps the original text.
This class implements VectorSink and is driven by VectorTraversal; use
export(TemporalConstraintGraph, NodePositions, GraphStyle, ExportOptions, CurvatureSource, Writer) to export
a whole graph.
- Author:
- posenato
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleConversion factor from pixels (model units) to centimetres: 96 dpi per inch, 2.54 cm per inch. -
Method Summary
Modifier and TypeMethodDescriptionvoidannotation(GraphAnnotation annotation) Emits a graph annotation.voidbeginDocument(Rectangle2D modelBounds, ExportOptions options) Called once before any node or edge.voidEmits a single directed edge.voidCalled once after every node and edge has been emitted.static voidexport(TemporalConstraintGraph<?> graph, NodePositions positions, GraphStyle style, ExportOptions options, CurvatureSource curvatures, Writer out) Exportsgraphas TikZ toout.voidnode(LabeledNode node, double centerX, double centerY, double radius, String label, Paint fill, Paint outline) Emits a single node.
-
Field Details
-
PIXELS_PER_CM
public static final double PIXELS_PER_CMConversion factor from pixels (model units) to centimetres: 96 dpi per inch, 2.54 cm per inch.- See Also:
-
-
Method Details
-
export
public static void export(@Nonnull TemporalConstraintGraph<?> graph, @Nonnull NodePositions positions, @Nonnull GraphStyle style, @Nonnull ExportOptions options, @Nonnull CurvatureSource curvatures, @Nonnull Writer out) throws IOException Exportsgraphas TikZ toout.- Parameters:
graph- the graph to export, not nullpositions- the node positions, not nullstyle- the visual style, not nulloptions- the export options, not nullcurvatures- the source of explicit per-edge curvature factors, not null; passCurvatureSource.none()when no explicit curvature is availableout- the destination writer, not null; it is flushed but not closed by this method- Throws:
IOException- if an I/O error occurs while writing
-
beginDocument
Description copied from interface:VectorSinkCalled once before any node or edge.- Specified by:
beginDocumentin interfaceVectorSink- Parameters:
modelBounds- the bounding box, in model space, of the whole drawing (node circles grown by their outline stroke, every edge curve grown by its stroke width, arrow heads and edge labels), not nulloptions- the export options in effect, not null
-
node
public void node(@Nonnull LabeledNode node, double centerX, double centerY, double radius, @Nonnull String label, @Nonnull Paint fill, @Nonnull Paint outline) Description copied from interface:VectorSinkEmits a single node.- Specified by:
nodein interfaceVectorSink- Parameters:
node- the node, not nullcenterX- the x coordinate of the node centre in model spacecenterY- the y coordinate of the node centre in model spaceradius- the node radius in model spacelabel- the text label to emit, not null (maybe empty)fill- the fill paint (already resolved for the export, i.e. selection never applied), not nulloutline- the outline paint (already resolved for the export, negative-cycle highlighting applied only if requested by the options), not null
-
edge
public void edge(@Nonnull Edge edge, @Nonnull EdgeGeometry.EdgeShape shape, @Nonnull String label, @Nonnull Paint paint, @Nonnull Stroke stroke) Description copied from interface:VectorSinkEmits a single directed edge.- Specified by:
edgein interfaceVectorSink- Parameters:
edge- the edge, not nullshape- the edge geometry as computed byEdgeGeometry, not null; the sink must use it as-is and never recompute itlabel- the text label to emit, not null (maybe empty)paint- the paint for the edge (already resolved for the export, selection never applied), not nullstroke- the stroke for the edge, not null
-
annotation
Description copied from interface:VectorSinkEmits a graph annotation. Sinks which do not support annotations may leave this callback at its default no-op implementation.- Specified by:
annotationin interfaceVectorSink- Parameters:
annotation- the annotation, not null
-
endDocument
public void endDocument()Description copied from interface:VectorSinkCalled once after every node and edge has been emitted.- Specified by:
endDocumentin interfaceVectorSink
-