MasterScan  Lab_Matlab_control Master Branch
List of all members | Static Methods
topsGUIUtilities Class Reference

Overview

Static utility methods for making Tower of Psych GUIs.

topsGUIUtilities provides static methods for creating and working with Tower of Psych graphical user interfaces (GUIs). They deal with tasks like manipulating strings and positions.

Static Methods

static fig openBasicGUI (item, itemName)
 Open a GUI that can explore any item. More...
 
static merged mergePositions (varargin)
 Calculate a position that bounds other positions. More...
 
static col getColorForString (string, colors)
 Pick a color for the given string, based on its spelling. More...
 
static tableCell mapCell makeTableForCellArray (cellArray, colors)
 Summarize a cell array as a 2D cell array of strings. More...
 
static tableCell mapCell fields makeTableForStructArray (structArray, colors)
 Summarize a struct array as a 2D cell array of strings. More...
 
static title makeTitleForItem (item, name, color)
 Make a descriptive title for an item. More...
 
static info makeSummaryForItem (item, colors)
 Make a descriptive summary of an item. More...
 
static string htmlWrapFormat (string, color, isEmphasis, isStrong)
 Wrap the given string with HTML font tags. More...
 
static string htmlStripTags (string, isPreserveText, stripExtra)
 Strip out HTML tags from the given string. More...
 
static string htmlBreakAtLines (string)
 Replace newline characters with HTML break tags. More...
 
static string spaceInstadOfLines (string)
 Replace newline characters with spaces in the given string. More...
 
static string underscoreInsteadOfNonwords (string)
 Replace non-word characters with underscores in the given string. More...
 

Methods

◆ openBasicGUI()

static fig openBasicGUI ( item  ,
itemName   
)
static

Open a GUI that can explore any item.

Parameters
itemany item
itemNamestring name to display for item

Opens a new GUI figure for summarizing the given item and "driling down" to explore any elements, fields, and properties, to arbitrary depth. If itemName is provided, displays itemName to represent item.

◆ mergePositions()

static merged mergePositions ( varargin  )
static

Calculate a position that bounds other positions.

Parameters
vararginone or more position rectangles

Merges one or more position rectangles of the form [x y width height] into one big position that bounds all of the given rectangles.

◆ getColorForString()

static col getColorForString ( string  ,
colors   
)
static

Pick a color for the given string, based on its spelling.

Parameters
stringany string
colorsnx3 matrix with one color per row (RGB, 0-1)

Maps the given string to one of the rows in colors, based on the spelling of string. The same string will always map to the same row. Multiple strings will also map to each row.

◆ makeTableForCellArray()

static tableCell mapCell makeTableForCellArray ( cellArray  ,
colors   
)
static

Summarize a cell array as a 2D cell array of strings.

Parameters
cellArrayany cell array
colorsnx3 matrix with one color per row (RGB, 0-1)

Summarizes the given cellArray for display as a table. Returns a 2D cell array of strings in which each element summarizes one element of cellArray.

Quoted 'strings' in the value summaries summary will be colored in based on their spelling and the given @colors. The summaries will contain HTML tags.

If cellArray is 1D or 2D, rows and columns arrangements are are preserved in the returned cell array. For higher-dimensional cell arrays, columns are preserved and all other dimensions are folded into rows.

Also returns as a second output a cell array of strings for mapping 2D table elements back to elements of the original cellArray. This is most useful when cellArray is higher-dimensional.

Each mapping string contains comma-separated subscripts into cellArray, enclosed in curly braces. For example, if cellArray is three-dimensional, the first mapping string would be '{1,1,1}'.

◆ makeTableForStructArray()

static tableCell mapCell fields makeTableForStructArray ( structArray  ,
colors   
)
static

Summarize a struct array as a 2D cell array of strings.

Parameters
structArrayany struct or object array
colorsnx3 matrix with one color per row (RGB, 0-1)

Summarizes the given structArray for display as a table. Returns a 2D cell array of strings in which each element summarizes one value within structArray. Each row in the 2D cell array corresponds to an element of structArray. structArray is treated as one-dimensional. Each column in the 2D cell array corresponds to one of the fields of structArray.

Quoted 'strings' in the value summaries summary will be colored in based on their spelling and the given @colors. The summaries will contain HTML color tags.

Also returns as a second output a cell array of strings for mapping 2D table elements back to velues withing the original structArray.

Each mapping string contains an index into structArray enclosed in parentheses, plus a 'dot' reference into one of the fields of structArray. For example, if structArray has a field called 'myField', one of the mapping strings would be '(1).myField'.

Also returns as a third output a cell array of field names, suitable as table row headers.

◆ makeTitleForItem()

static title makeTitleForItem ( item  ,
name  ,
color   
)
static

Make a descriptive title for an item.

Parameters
itemany item
itemname a name to display for item
colora color for the description (RGB, 0-1)

Makes a title for the given item, based on the item class, size, and the given name, with HTML formatting. name will appear in the default foreground color, the rest of the title will appear in the given color.

◆ makeSummaryForItem()

static info makeSummaryForItem ( item  ,
colors   
)
static

Make a descriptive summary of an item.

Parameters
itemany item
colorsnx3 matrix with one color per row (RGB, 0-1) Makes a summary for the given item, based on the built-in disp() function. Quoted 'strings' in the summary will be colored in based on their spelling and the given @colors. The summary will contain HTML color tags.

◆ htmlWrapFormat()

static string htmlWrapFormat ( string  ,
color  ,
isEmphasis  ,
isStrong   
)
static

Wrap the given string with HTML font tags.

Parameters
stringany string
color1x3 color (RGB, 0-1)
isEmphasiswhether to apply emphasis formatting
isStrongwhether to apply strong formatting

Wraps the given string in HTML tags which specify font formatting. color must contain RBG components in the range 0-1. isEmphasis specifies whether to apply emphasis (true) or not. isStrong specifies whether to apply strong formatting or not. color, isEmphasis, or isStrong may be omitted empty, in which case no formatting is specified.

Returns the given string, wrapped in HTML tags.

◆ htmlStripTags()

static string htmlStripTags ( string  ,
isPreserveText  ,
stripExtra   
)
static

Strip out HTML tags from the given string.

Parameters
stringany string
isPreserveTextwhether to leave in text between tags
stripExtraadditional regexp to strip around each tag

Strips out angle-bracketed tags (like myText, etc.) from the given string. By default, also strips out the text between opening and closing tags (like 'myText'), along with the tags themselves. If isPreserverText is provided and true, leaves the text in place and only strips the angle-bracketed tags themselves.

If stripExtra is provided, it must be a regular expression. stripExtra is added to the front and back of the regular expression that matches tags, to strip out additional surrounding text. This is useful for stripping out things like a comma-separated list of tags.

Returns the updated string.

◆ htmlBreakAtLines()

static string htmlBreakAtLines ( string  )
static

Replace newline characters with HTML break tags.

Parameters
stringany string

Replaces any newline (
) or return carriage (\r) characters in the given string with HTML
break tags. Returns the updated string.

◆ spaceInstadOfLines()

static string spaceInstadOfLines ( string  )
static

Replace newline characters with spaces in the given string.

Parameters
stringany string

Replaces any newline (
) or return carriage (\r) characters in the given string with a single space. Returns the updated string.

◆ underscoreInsteadOfNonwords()

static string underscoreInsteadOfNonwords ( string  )
static

Replace non-word characters with underscores in the given string.

Parameters
stringany string

Replaces any non-word characters in the given string with a single underscore (_). "Non-word" means anything besides letters, numbers, and underscores (regular expression '\W'). Returns the updated string.


The documentation for this class was generated from the following file: