Skip to content

Commit

Permalink
New docs
Browse files Browse the repository at this point in the history
  • Loading branch information
scheinerman committed Sep 29, 2024
1 parent 65569da commit 60028b5
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 18 deletions.
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "HasseDiagrams"
uuid = "eda30fb7-e799-4e1d-8790-5b2716643197"
authors = ["Ed Scheinerman <ers@jhu.edu>"]
version = "0.1.2"
version = "0.1.3"

[deps]
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
Expand All @@ -10,6 +10,7 @@ Optim = "429524aa-4258-5aef-a3af-852621145aeb"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Posets = "9a158a65-591e-4f68-ac4f-9ffef2fc51f2"
SimpleDrawing = "d78a06e8-ae74-583c-9a07-0d6572347000"
SimpleDrawingObjects = "89d8b4ea-5f62-47ee-b8a8-d90862f742b0"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
Expand All @@ -19,4 +20,5 @@ Optim = "1"
Plots = "1"
Posets = "0.3"
SimpleDrawing = "0.2"
SimpleDrawingObjects = "0.0.3, 0.1"
julia = "1"
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,16 @@ end
Here is the result of `draw_bool(4)`:

![](bool4.png)


## Extra Control: Drawing Objects

Much greater control of the appearance of a `HasseDiagram` can be achieved using the
`make_objects` function. The input to `make_objects` is a `HasseDiagram` and the output
is a list of `Segment` and `Point` objects from [SimpleDrawingObjects](https://github.com/scheinerman/SimpleDrawingObjects.jl). This list begins with `Segment` objects representing the edges of the
`HasseDiagram` following by `Point` objects representing the vertices. This allows the user to
specify various attributes for the objects. For example, this would enable changing the colors of
selected vertices (as opposed to using `set_fill_color!` which sets all vertices to the same color).

Note that modifying the objects in the output of `make_objects(h)` does not modify `h` or its
attributes. It simply gives a list of objects that can be individually modified.
2 changes: 1 addition & 1 deletion docs/build/.documenter-siteinfo.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"documenter":{"julia_version":"1.10.5","generation_timestamp":"2024-09-28T16:52:56","documenter_version":"1.6.0"}}
{"documenter":{"julia_version":"1.10.5","generation_timestamp":"2024-09-29T19:58:43","documenter_version":"1.6.0"}}
4 changes: 2 additions & 2 deletions docs/build/index.html

Large diffs are not rendered by default.

Binary file modified docs/build/objects.inv
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/build/search_index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,16 @@ end
Here is the result of `draw_bool(4)`:

![](bool4.png)


## Extra Control: Drawing Objects

Much greater control of the appearance of a `HasseDiagram` can be achieved using the
`make_objects` function. The input to `make_objects` is a `HasseDiagram` and the output
is a list of `Segment` and `Point` objects from [SimpleDrawingObjects](https://github.com/scheinerman/SimpleDrawingObjects.jl). This list begins with `Segment` objects representing the edges of the
`HasseDiagram` following by `Point` objects representing the vertices. This allows the user to
specify various attributes for the objects. For example, this would enable changing the colors of
selected vertices (as opposed to using `set_fill_color!` which sets all vertices to the same color).

Note that modifying the objects in the output of `make_objects(h)` does not modify `h` or its
attributes. It simply gives a list of objects that can be individually modified.
8 changes: 4 additions & 4 deletions extras/logo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ function hasse_logo()
h = HasseDiagram(p)
set_xy!(h, force_layout)
scalex!(h, 1.5)
set_radius!(h,32)
set_font_size!(h,30)
set_radius!(h, 32)
set_font_size!(h, 30)

draw(h)
expand_canvas()
finish()
return finish()
end
2 changes: 2 additions & 0 deletions src/HasseDiagrams.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module HasseDiagrams
using Posets
using Graphs
using SimpleDrawing
using SimpleDrawingObjects
using Plots
using LayeredLayouts
using Optim
Expand All @@ -15,6 +16,7 @@ export HasseDiagram,
dim2_layout,
layered_layout,
layered_layout_2,
make_objects,
draw,
force_layout,
get_font_size,
Expand Down
32 changes: 23 additions & 9 deletions src/draw.jl
Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
"""
draw!(h::HasseDiagram)
make_objects(h::HasseDiagram)
Draw the Hasse diagram without first erasing the canvas.
Create a list of `SimpleDrawingObject`s representing the edges and vertices of `h`.
The list starts with all the edges followed by all the vertices.
"""
function draw!(h::HasseDiagram)
function make_objects(h::HasseDiagram)
p = h.p
n = nv(p)
g = cover_digraph(p)

for e in edges(g)
u = src(e)
v = dst(e)
draw_segment(h.xy[u]..., h.xy[v]...; linecolor=:black)
e_list = [Segment(h.xy[src(e)]..., h.xy[dst(e)]...) for e in edges(g)]
v_list = [Point(h.xy[v]...) for v in 1:n]

for p in v_list
set_pointsize!(p, h.radius)
set_fillcolor!(p, h.fill_color)
end

for v in 1:nv(p)
draw_point(h.xy[v]...; marker=h.radius, linecolor=:black, color=h.fill_color)
return [e_list; v_list]
end

"""
draw!(h::HasseDiagram)
Draw the Hasse diagram without first erasing the canvas.
"""
function draw!(h::HasseDiagram)
draw(make_objects(h))

for v in 1:nv(h.p)
if h.font_size > 0
annotate!(h.xy[v]..., h.labels[v], h.font_size)
end
Expand Down

0 comments on commit 60028b5

Please sign in to comment.