diff --git a/src/Contexts.jl b/src/Contexts.jl index 0581699..fbbc9fb 100644 --- a/src/Contexts.jl +++ b/src/Contexts.jl @@ -174,7 +174,7 @@ mutable struct Context <: AbstractContext dim::Pair{Int64, Int64} margin::Pair{Int64, Int64} Context(wind::Component{:svg}, margin::Pair{Int64, Int64}) = begin - new(wind, randstring(), wind[:width] => wind[:height], + new(wind, gen_ref(5), wind[:width] => wind[:height], margin)::Context end Context(width::Int64 = 1280, height::Int64 = 720, @@ -316,7 +316,7 @@ are used to create scaling with `group` and create layers with `group!`. ------------------ ##### constructors ```julia -Group(name::String = randstring(), width::Int64 = 1280, height::Int64 = 720, +Group(name::String = gen_ref(5), width::Int64 = 1280, height::Int64 = 720, margin::Pair{Int64, Int64} = 0 => 0) ``` """ @@ -325,7 +325,7 @@ mutable struct Group <: AbstractContext uuid::String dim::Pair{Int64, Int64} margin::Pair{Int64, Int64} - Group(name::String = randstring(), width::Int64 = 1280, height::Int64 = 720, + Group(name::String = gen_ref(5), width::Int64 = 1280, height::Int64 = 720, margin::Pair{Int64, Int64} = 0 => 0) = begin window::Component{:g} = ToolipsSVG.g("$name", width = width, height = height) new(window, name, width => height, margin) diff --git a/src/Gattino.jl b/src/Gattino.jl index faf9fd4..bd9dd23 100644 --- a/src/Gattino.jl +++ b/src/Gattino.jl @@ -73,8 +73,7 @@ module Gattino using ToolipsSVG import Base: getindex, setindex!, show, display, vcat, push!, hcat, size, reshape, string import ToolipsSVG: position, set_position!, set_size!, style!, set_shape, SVGShape -import ToolipsSVG.ToolipsServables: Servable, Component, AbstractComponent, br -using Random: randstring +import ToolipsSVG.ToolipsServables: Servable, Component, AbstractComponent, br, gen_ref include("context_plotting.jl") diff --git a/src/context_plotting.jl b/src/context_plotting.jl index 67cc75f..159f1c2 100644 --- a/src/context_plotting.jl +++ b/src/context_plotting.jl @@ -13,7 +13,7 @@ function text!(con::AbstractContext, x::Number, y::Number, text::String, styles: if length(styles) == 0 styles = ("fill" => "black", "font-size" => 13pt) end - t = ToolipsSVG.text(randstring(), x = x, y = y, text = text) + t = ToolipsSVG.text(gen_ref(5), x = x, y = y, text = text) style!(t, styles ...) draw!(con, [t]) nothing::Nothing @@ -50,7 +50,7 @@ function line!(con::AbstractContext, first::Pair{<:Number, <:Number}, if length(styles) == 0 styles = ("fill" => "none", "stroke" => "black", "stroke-width" => "4") end - ln = ToolipsSVG.line(randstring(), x1 = first[1], y1 = first[2], + ln = ToolipsSVG.line(gen_ref(5), x1 = first[1], y1 = first[2], x2 = second[1], y2 = second[2]) style!(ln, styles ...) draw!(con, [ln]) @@ -312,7 +312,7 @@ function points!(con::AbstractContext, x::Vector{<:Number}, y::Vector{<:Number}, draw!(con, Vector{Servable}([begin cx = Int64(round(percvec_x[i] * (con.dim[1] - 1) + con.margin[1])) cy = Int64(round(con.dim[2] - percvec_y[i] * (con.dim[2] - 1) + con.margin[2])) - c = circle(randstring(), cx = cx, cy = cy, r = r) + c = circle(gen_ref(5), cx = cx, cy = cy, r = r) style!(c, styles...) c end for i in 1:length(x)])) @@ -398,7 +398,7 @@ function bars!(con::AbstractContext, x::Vector{<:Any}, y::Vector{<:Number}, styl block_width = Int64(round(con.dim[1] / n_features)) rects = Vector{Servable}([begin scaled_y::Number = Int64(round(con.dim[2] * percvec_y[e])) - rct = ToolipsSVG.rect(randstring(), x = Int64(round(n)) + con.margin[1], y = con.dim[2] - scaled_y + con.margin[2], + rct = ToolipsSVG.rect(gen_ref(5), x = Int64(round(n)) + con.margin[1], y = con.dim[2] - scaled_y + con.margin[2], width = block_width, height = con.dim[2] - (con.dim[2] - scaled_y)) style!(rct, styles ...) n += block_width @@ -471,7 +471,7 @@ function v_bars!(con::AbstractContext, x::Vector{<:AbstractString}, y::Vector{<: block_width = Int64(round(con.dim[2] / n_features)) rects = Vector{Servable}([begin scaled_y::Number = Int64(round(con.dim[2] * percvec_y[e])) - rct = ToolipsSVG.rect(randstring(), x = 0, y = n, + rct = ToolipsSVG.rect(gen_ref(5), x = 0, y = n, width = con.dim[1] - (con.dim[1] - scaled_y), height = block_width) style!(rct, styles ...) n += block_width