1+ # ' Display format module
2+ # '
3+ # ' Shiny module for displaying format and color options
4+ # '
5+ # ' @name mod_display_format
6+ # '
7+ # ' @inheritParams mod_plot
8+ # '
9+ # ' @details
10+ # ' This module displays the app color and format options, including:
11+ # ' color palette options, line types, line widths, symbols, and fonts
12+ # '
13+ # ' @returns The UI function returns a [shinydashboard::tabItem()] object
14+ # '
15+ # ' The server function returns nothing
16+ # '
17+ # ' @export
18+ mod_display_format_ui <- function (id ) {
19+ ns <- NS(id )
20+
21+ tabItem(
22+ tabName = " dispColor" ,
23+ fluidRow(
24+ box(
25+ title = " Color/Format Options" , status = " primary" , solidHeader = TRUE , width = 12 ,
26+ plotOutput(ns(" plot_display_format" ))
27+ ),
28+ column(12 , actionButton(ns(" display_redraw" ), " Redraw display" ))
29+ )
30+ )
31+ }
32+
33+
34+ # ' @name mod_display_format
35+ # ' @export
36+ mod_display_format_server <- function (id ) {
37+ moduleServer(id , function (input , output , session ) {
38+ cruzDisplaySymbolProp <- reactive({
39+ input $ display_redraw
40+
41+ plot.max <- length(symbol.col ) + length(symbol.col.gray ) + 3
42+ plot.h1 <- plot.max - 1.5 + 1
43+ plot.h2 <- plot.max - 1.75 + 1
44+ plot.h3 <- plot.max - 1.85 + 1
45+ plot.h4 <- plot.max - 2 + 1
46+ plot.h5 <- plot.max - 3 + 1
47+ plot.h6 <- plot.max - 14 + 1
48+
49+ plot.gs <- plot.h3 - 1.15 - length(symbol.col )
50+
51+ oldpar <- par(mar = rep(1 , 4 ), family = " sans" )
52+ plot(c(0 , 1 ), c(0 , plot.max ), type = " n" , axes = FALSE , bty = " n" )
53+
54+ # Top labels
55+ text(c(0.05 , 0.32 , 0.7 , 0.95 ), rep(plot.h1 , 4 ), c(" Symbols" , " Colors" , " Line Types" , " Widths" ), cex = 1.4 )
56+ # text(c(0.05,0.3,0.7,0.95),rep(26.5,4),c("(pch= )","(col= )","(lty= )","(lwd= )"),cex=1.3)
57+
58+ # Symbols
59+ for (i in 0 : 20 ) {
60+ text(0.02 , plot.h5 - (i * 1.25 ), i , cex = 1 )
61+ points(.08 , plot.h5 - (i * 1.25 ), pch = i , cex = 1.8 )
62+ }
63+
64+ # Colors used in CruzPlot
65+ for (i in 1 : length(symbol.col )) {
66+ text(0.33 , plot.h3 - (i + .25 ), symbol.col [i ], cex = 1 , pos = 2 )
67+ points(.35 , plot.h2 - (i + .25 ), pch = 15 , cex = 2.1 , col = symbol.col.code [i ])
68+ }
69+ points(0.35 , (plot.h2 - (length(symbol.col ) + .25 )), pch = 0 , cex = 2.0 ) # puts box around white
70+ text(0.24 , plot.max - 13 , " Color" , srt = 90 , cex = 1.2 , pos = 4 )
71+
72+ # Greyscale palette
73+ palette(gray((0 : 5 ) / 5 ))
74+ for (i in 1 : 6 ) {
75+ text(0.33 , plot.gs - i , symbol.col.gray [i ], cex = 1 , pos = 2 )
76+ points(0.35 , plot.gs - i + 0.1 , pch = 15 , cex = 2.1 , col = symbol.col.code.gray [i ])
77+ }
78+ points(0.35 , plot.gs - 6 + 0.11 , pch = 0 , cex = 2.0 ) # puts box around white
79+ text(0.24 , 0.1 , " Gray Scale" , srt = 90 , cex = 1.2 , pos = 4 )
80+
81+ # Line types
82+ for (i in 1 : 6 ) {
83+ text(0.55 , plot.h5 - i , i , cex = 1.1 )
84+ lines(c(0.6 , 0.7 , 0.85 ), c(plot.h5 - i , plot.h4 - i , plot.h4 - i ), lty = i )}
85+ # line widths
86+ for (i in 1 : 6 ) {
87+ lines(c(0.9 , 1 ), c(plot.h4 - i , plot.h4 - i ), lwd = i )
88+ }
89+
90+ # Typefaces
91+ text(0.75 , plot.h6 , " Fonts" , cex = 1.4 )
92+ plot.h6b <- plot.h6 + 0.5
93+ for (i in 1 : 3 ) {
94+ i.m <- i * 1.5
95+ text(0.75 , plot.h6b - 0.0 - (i.m * 2.3 ), names(font.family )[i ], cex = 1.2 , adj = 0.5 , family = font.family.vals [i ])
96+ text(0.75 , plot.h6b - 0.9 - (i.m * 2.3 ), paste(LETTERS , collapse = " " ), cex = 1 , adj = 0.5 , family = font.family.vals [i ])
97+ text(0.75 , plot.h6b - 1.8 - (i.m * 2.3 ), paste(c(letters , " " , 0 : 9 ), collapse = " " ), cex = 1 , adj = 0.5 , family = font.family.vals [i ])
98+ }
99+
100+ palette(" default" )
101+ par(oldpar )
102+ })
103+
104+
105+ output $ plot_display_format <- renderPlot({
106+ cruzDisplaySymbolProp()
107+ })
108+ })
109+ }
0 commit comments