summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/bindings
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/bindings')
-rw-r--r--Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/bindings/Binding.lua33
-rw-r--r--Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/bindings/BindingToPGF.lua98
2 files changed, 66 insertions, 65 deletions
diff --git a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/bindings/Binding.lua b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/bindings/Binding.lua
index 5b60d90ccd6..6ffb4168f52 100644
--- a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/bindings/Binding.lua
+++ b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/bindings/Binding.lua
@@ -38,7 +38,7 @@ local Storage = require "pgf.gd.lib.Storage"
--
-- @field storage A |Storage| storing the information passed from the
-- display layer. The interpretation of this left to the actual
--- binding.
+-- binding.
local Binding = {
storage = Storage.newTableStorage ()
@@ -71,7 +71,7 @@ end
-- of the display layer to make the parameter |t.key| available to the
-- parsing process. Furthermore, if |t.initial| is not |nil|, the
-- display layer must convert it into a value that is stored as the
--- initial value and call |InterfaceToDisplay.setOptionInitial|.
+-- initial value and call |InterfaceToDisplay.setOptionInitial|.
--
-- @param t See |InterfaceToAlgorithms.declare| for details.
@@ -105,7 +105,7 @@ end
---
--- This function and the correspoding |...Stop...| functions are
+-- This function and the corresponding |...Stop...| functions are
-- called whenever a collection kind should be rendered. See
-- |InterfaceToDisplay.render_collections| for details.
--
@@ -141,7 +141,7 @@ end
---
--- This function and the correspoding |...Stop...| functions are
+-- This function and the corresponding |...Stop...| functions are
-- called whenever a vertex should be rendered. See
-- |InterfaceToDisplay.render_vertices| for details.
--
@@ -191,7 +191,7 @@ end
---
--- This function and the correspoding |...Stop...| functions are
+-- This function and the corresponding |...Stop...| functions are
-- called whenever an edge should be rendered. See
-- |InterfaceToDisplay.render_edges| for details.
--
@@ -237,21 +237,22 @@ end
-- vertex. This call will be made while an algorithm is running. It is
-- now the job of the binding to cause the display layer to create the
-- node. This is done by calling the |yield| method of the scope's
--- coroutine.
+-- coroutine.
--
-- @param init A table of initial values for the node. The following
-- fields will be used:
+-- %
-- \begin{itemize}
--- \item |name| If present, this name will be given to the
--- node. If not present, an iternal name is generated. Note that,
--- unless the node is a subgraph node, this name may not be the name
--- of an already present node of the graph; in this case an error
--- results.
--- \item |shape| If present, a shape of the node.
--- \item |generated_options| A table that is passed back to the
--- display layer as a list of key-value pairs.
--- \item |text| The text of the node, to be passed back to the
--- higher layer. This is what should be displayed as the node's text.
+-- \item |name| If present, this name will be given to the
+-- node. If not present, an internal name is generated. Note that,
+-- unless the node is a subgraph node, this name may not be the name
+-- of an already present node of the graph; in this case an error
+-- results.
+-- \item |shape| If present, a shape of the node.
+-- \item |generated_options| A table that is passed back to the
+-- display layer as a list of key--value pairs.
+-- \item |text| The text of the node, to be passed back to the
+-- higher layer. This is what should be displayed as the node's text.
-- \end{itemize}
function Binding:createVertex(init)
diff --git a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/bindings/BindingToPGF.lua b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/bindings/BindingToPGF.lua
index 90519e23d55..5324a1652e6 100644
--- a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/bindings/BindingToPGF.lua
+++ b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/bindings/BindingToPGF.lua
@@ -20,7 +20,7 @@ local Storage = require "pgf.gd.lib.Storage"
-- drawing system to the \pgfname\ display system by overriding (that
-- is, implementing) the methods of the |Binding| class. As a typical
-- example, consider the implementation of the function |renderVertex|:
---
+-- %
--\begin{codeexample}[code only, tikz syntax=false]
--function BindingToPGF:renderVertex(v)
-- local info = assert(self.infos[v], "thou shalt not modify the syntactic digraph")
@@ -44,7 +44,7 @@ local Storage = require "pgf.gd.lib.Storage"
-- (new) position for the node. For almost all methods of the
-- |Binding| class there is a corresponding ``callback'' macro on the
-- \TeX\ layer, all of which are implemented in the \pgfname\ library
--- |graphdrawing|. For details on these callbacks,
+-- |graphdrawing|. For details on these callbacks,
-- please consult the code of that file and of the class
-- |BindingToPGF| (they are not documented here since they are local
-- to the binding and should not be called by anyone other than the
@@ -81,7 +81,7 @@ local coordinate_in_pgf_syntax
function BindingToPGF:resumeGraphDrawingCoroutine(text)
tex.print(text)
- tex.print("\\pgfgdresumecoroutinetrue")
+ tex.print("\\pgfgdresumecoroutinetrue")
end
@@ -108,7 +108,7 @@ end
function BindingToPGF:renderCollection(collection)
tex.print("\\pgfgdcallbackrendercollection{".. collection.kind .. "}{"
- .. table_in_pgf_syntax(collection.generated_options) .. "}")
+ .. table_in_pgf_syntax(collection.generated_options) .. "}")
end
function BindingToPGF:renderCollectionStartKind(kind, layer)
@@ -133,11 +133,11 @@ local box_count = 0
function BindingToPGF:everyVertexCreation(v)
local info = self.storage[v]
-
+
-- Save the box!
box_count = box_count + 1
boxes[box_count] = node.copy_list(tex.box[info.tex_box_number])
-
+
-- Special tex stuff, should not be considered by gd algorithm
info.box_count = box_count
end
@@ -180,12 +180,12 @@ local function rigid(x)
end
end
-
+
-- Managing edges
function BindingToPGF:renderEdge(e)
local info = assert(self.storage[e], "thou shalt not modify the syntactic digraph")
-
+
local function get_anchor(e, anchor)
local a = e.options[anchor]
if a and a ~= "" then
@@ -194,7 +194,7 @@ function BindingToPGF:renderEdge(e)
return ""
end
end
-
+
local callback = {
'\\pgfgdcallbackedge',
'{', e.tail.name .. get_anchor(e, "tail anchor"), '}',
@@ -205,12 +205,12 @@ function BindingToPGF:renderEdge(e)
'{', table_in_pgf_syntax(e.generated_options), '}',
'{'
}
-
+
local i = 1
while i <= #e.path do
local c = e.path[i]
assert (type(c) == "string", "illegal path operand")
-
+
if c == "lineto" then
i = i + 1
local d = rigid(e.path[i])
@@ -231,19 +231,19 @@ function BindingToPGF:renderEdge(e)
.. to_pt(d2.x) .. ',' .. to_pt(d2.y) .. ')..'
callback [#callback + 1] = '(' .. to_pt(d3.x) .. ',' .. to_pt(d3.y) .. ')'
i = i + 1
- else
+ else
error("illegal operation in edge path")
end
end
callback [#callback + 1] = '}'
callback [#callback + 1] = '{' .. animations_in_pgf_syntax(e.animations) .. '}'
-
+
-- hand TikZ code over to TeX
tex.print(table.concat(callback))
end
-
-
+
+
function BindingToPGF:renderEdgesStart()
tex.print("\\pgfgdcallbackbeginedgeshipout")
end
@@ -275,12 +275,12 @@ function table_in_pgf_syntax (t)
local prefix = "/graph drawing/"
local suffix = "/.try"
return table.concat( lib.imap( t, function(table)
- if table.value then
- return prefix .. table.key .. suffix .. "={" .. tostring(table.value) .. "}"
- else
- return prefix .. table.key .. suffix
- end
- end), ",")
+ if table.value then
+ return prefix .. table.key .. suffix .. "={" .. tostring(table.value) .. "}"
+ else
+ return prefix .. table.key .. suffix
+ end
+ end), ",")
end
@@ -288,29 +288,29 @@ function animations_in_pgf_syntax (a)
return
table.concat(
lib.imap(
- a,
- function(animation)
- return "\\pgfanimateattribute{" .. animation.attribute .. "}{whom=pgf@gd," ..
- table.concat(
- lib.imap (
- animation.entries,
- function (entry)
- return "entry={" .. entry.t .. "s}{" .. to_pgf(entry.value) .. "}"
- end
- ), ",") ..
- "," ..
- table.concat(
- lib.imap(
- animation.options or {},
- function(table)
- if table.value then
- return table.key .. "={" .. to_pgf(table.value) .. "}"
- else
- return table.key
- end
- end), ",")
- .. "}"
- end)
+ a,
+ function(animation)
+ return "\\pgfanimateattribute{" .. animation.attribute .. "}{whom=pgf@gd," ..
+ table.concat(
+ lib.imap (
+ animation.entries,
+ function (entry)
+ return "entry={" .. entry.t .. "s}{" .. to_pgf(entry.value) .. "}"
+ end
+ ), ",") ..
+ "," ..
+ table.concat(
+ lib.imap(
+ animation.options or {},
+ function(table)
+ if table.value then
+ return table.key .. "={" .. to_pgf(table.value) .. "}"
+ else
+ return table.key
+ end
+ end), ",")
+ .. "}"
+ end)
)
end
@@ -332,12 +332,12 @@ end
function path_in_pgf_syntax (p)
local s = {}
-
+
local i = 1
while i <= #p do
local c = p[i]
assert (type(c) == "string", "illegal path operand")
-
+
if c == "lineto" then
i = i + 1
local d = rigid(p[i])
@@ -355,10 +355,10 @@ function path_in_pgf_syntax (p)
local d1, d2, d3 = rigid(p[i+1]), rigid(p[i+2]), rigid(p[i+3])
i = i + 3
s [#s + 1] = '\\pgfpathcurveto{\\pgfqpoint{' .. to_pt(d1.x) .. '}{' .. to_pt(d1.y) .. '}}{\\pgfqpoint{'
- .. to_pt(d2.x) .. '}{' .. to_pt(d2.y) .. '}}{\\pgfqpoint{'
- .. to_pt(d3.x) .. '}{' .. to_pt(d3.y) .. '}}'
+ .. to_pt(d2.x) .. '}{' .. to_pt(d2.y) .. '}}{\\pgfqpoint{'
+ .. to_pt(d3.x) .. '}{' .. to_pt(d3.y) .. '}}'
i = i + 1
- else
+ else
error("illegal operation in edge path")
end
end