MATLAB Answers

Steve
0

I would like to add a 'display-all' hyperlink functionality to a class.

Asked by Steve
on 13 Feb 2019
Latest activity Answered by Steve
on 19 Feb 2019
I've created a series of classes which serve as a convienient front end for some standard data sources which are ubiquitous in our organization.
I've been storing the data in a structure [in it's native form] and I've created alot of dependent properties to access the data convieniently. In addition, many of these dependent properties do alot of indexing in and [sometimes time consuming] calculations to identify good/bad/ugly regions and other things.... stuff which I want to only see sometimes.
I've tried hiding some properties, but it's easy to forget what they are and it's harder to hand off data to someone who maybe isn't as intimate with the source.
Currently, I've defined some custom display routines so not all of the data is displayed when something is queried in the command line. I can over-ride the custom display and use MATLAB's builtin display routines when I need to.
What would be very helpful is to add a hyperlink (like the display for graphic handle objects below) to quickly display various subsets (or groups of properites) of my data.
I haven't figured out how to get a hyperlink reference to a specific instance of my class... it appears to only have access to the base workspace.... Any thoughts?
K>> foo = figure
foo =
Figure (3) with properties:
Number: 3
Name: ''
Color: [1×3 double]
Position: [680 678 560 420]
Units: 'pixels'
Show all properties
classdef foo < matlab.mixin.CustomDisplay
properties
this = 1;
that = 2;
theother = 'harbinger to lots of other properties';
end
methods (Access = protected)
function g = getPropertyGroups(obj)
g = matlab.mixin.util.PropertyGroup({'this','that'},'important stuff:');
end
function f = getFooter(obj)
f = sprintf('<a href = "??matlab: CAN-ONLY-ACCESS-BASE-SPACE-FROM-HERE??" >display all</a>');
end
end
end

  0 Comments

Sign in to comment.

2 Answers

Answer by Yair Altman on 16 Feb 2019
 Accepted Answer

It is true that desktop hyperlinks only work at the base workspace level, but you can still access specific object instances if you store them somewhere that is accessible from the base workspace. For example, if your object instance include a unique ID:
uniqueId = char(java.util.UUID.randomUUID); % e.g. '221a5ecd-437e-4fa2-b4dd-de1bff77c9fd'
Then you can create a public static method that searches for and displays this object using its ID. For example, you can store all the active object references (list of uniqueIds vs. handles) in some global variable, and then the hyperlink will run a Matlab function that searches for the specific uniqueId, fetches the corresponding instance reference, and then displays its internals as you wish.

  0 Comments

Sign in to comment.


Answer by Steve
on 19 Feb 2019

Hmmmm..... I'll try that. Thanks for the randomUUID reference, that will be key to making something work.
Thanks for your help!

  0 Comments

Sign in to comment.