<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>Undocumented Matlab &#187; JIDE</title> <atom:link href="http://undocumentedmatlab.com/blog/tag/jide/feed/" rel="self" type="application/rss+xml" /><link>http://undocumentedmatlab.com</link> <description>Charting Matlab's unsupported hidden underbelly</description> <lastBuildDate>Thu, 02 Feb 2012 00:24:18 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.1.1</generator> <item><title>Uitable cell colors</title><link>http://undocumentedmatlab.com/blog/uitable-cell-colors/</link> <comments>http://undocumentedmatlab.com/blog/uitable-cell-colors/#comments</comments> <pubDate>Thu, 27 Oct 2011 01:51:53 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[GUI]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[Medium risk of breaking in future versions]]></category> <category><![CDATA[UI controls]]></category> <category><![CDATA[FindJObj]]></category> <category><![CDATA[HTML]]></category> <category><![CDATA[JIDE]]></category> <category><![CDATA[uitable]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=2476</guid> <description><![CDATA[A few Java-based customizations can transform a plain-looking data table into a lively colored one.<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/uitable-customization-report/' rel='bookmark' title='Uitable customization report'>Uitable customization report</a> <small>In last week&#8217;s report about uitable sorting, I offered a report that I have written which covers uitable customization in detail. Several people have asked for more details about the...</small></li><li><a
href='http://undocumentedmatlab.com/blog/uitable-sorting/' rel='bookmark' title='Uitable sorting'>Uitable sorting</a> <small>Matlab's uitables can be sortable using simple undocumented features...</small></li><li><a
href='http://undocumentedmatlab.com/blog/uitab-colors-icons-images/' rel='bookmark' title='Uitab colors, icons and images'>Uitab colors, icons and images</a> <small>Matlab's semi-documented tab panels can be customized using some undocumented hacks...</small></li><li><a
href='http://undocumentedmatlab.com/blog/changing-matlab-command-window-colors/' rel='bookmark' title='Changing Matlab&#8217;s Command Window colors'>Changing Matlab&#8217;s Command Window colors</a> <small>Matlab's Command Window foreground and background colors can be modified programmatically, using some of Matlab's undocumented internal Java classes. Here's how....</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p>A client recently asked me to develop an application that will help discover technical indicators for trading on the stock market. The application was very data-intensive and the analysis naturally required visual presentations of number-crunching results in a readable manner. One of the requirements was to present numeric results in a data table, so we naturally use <i><b>uitable</b></i> for this.</p><p>Today I will show how using some not-so-complex Java we can transform the standard Matlab <i><b>uitable</b></i> into something much more useful.</p><h3 id="basic">First pass &#8211; basic data table</h3><p>We start by displaying the data in a simple <i><b>uitable</b></i>. The essence of the relevant code snippet was something like this:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">headers = <span style="color: #080;">&#123;</span><span style="color:#A020F0;">'Periods'</span>, <span style="color: #F0F;">...</span>
           <span style="color:#A020F0;">'&lt;html&gt;&lt;center&gt;Any period&lt;br /&gt;returns&lt;/center&gt;&lt;/html&gt;'</span>, <span style="color: #F0F;">...</span>
           <span style="color:#A020F0;">'&lt;html&gt;&lt;center&gt;Avg return&lt;br /&gt;signal&lt;/center&gt;&lt;/html&gt;'</span>, <span style="color: #F0F;">...</span>
           <span style="color:#A020F0;">'&lt;html&gt;&lt;center&gt;Avg&lt;br /&gt;gain&lt;/center&gt;&lt;/html&gt;'</span>, <span style="color: #F0F;">...</span>
           <span style="color:#A020F0;">'&lt;html&gt;&lt;center&gt;Avg&lt;br /&gt;draw&lt;/center&gt;&lt;/html&gt;'</span>, <span style="color: #F0F;">...</span>
           <span style="color:#A020F0;">'&lt;html&gt;&lt;center&gt;Gain/draw&lt;br /&gt;ratio&lt;/center&gt;&lt;/html&gt;'</span>, <span style="color: #F0F;">...</span>
           <span style="color:#A020F0;">'&lt;html&gt;&lt;center&gt;Max&lt;br /&gt;gain&lt;/center&gt;&lt;/html&gt;'</span>, <span style="color: #F0F;">...</span>
           <span style="color:#A020F0;">'&lt;html&gt;&lt;center&gt;Max&lt;br /&gt;draw&lt;/center&gt;&lt;/html&gt;'</span>, <span style="color: #F0F;">...</span>
           <span style="color:#A020F0;">'&lt;html&gt;&lt;center&gt;Random&lt;br /&gt;% pos&lt;/center&gt;&lt;/html&gt;'</span>, <span style="color: #F0F;">...</span>
           <span style="color:#A020F0;">'&lt;html&gt;&lt;center&gt;Signal&lt;br /&gt;% pos&lt;/center&gt;&lt;/html&gt;'</span>, <span style="color: #F0F;">...</span>
           <span style="color:#A020F0;">'Payout'</span>, <span style="color:#A020F0;">'% p-value'</span><span style="color: #080;">&#125;</span>;
hTable = uitable<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'Data'</span>,data, <span style="color:#A020F0;">'ColumnEditable'</span>,<span style="color: #0000FF;">false</span>, <span style="color: #F0F;">...</span>
           <span style="color:#A020F0;">'ColumnName'</span>,headers, <span style="color:#A020F0;">'RowName'</span>,<span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>, <span style="color: #F0F;">...</span>
           <span style="color:#A020F0;">'ColumnFormat'</span>,<span style="color: #080;">&#91;</span><span style="color:#A020F0;">'numeric'</span>,<span style="color: #0000FF;">repmat</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#123;</span><span style="color:#A020F0;">'bank'</span><span style="color: #080;">&#125;</span>,<span style="color: #33f;">1</span>,<span style="color: #33f;">11</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#93;</span>, <span style="color: #F0F;">...</span>
           <span style="color:#A020F0;">'ColumnWidth'</span>,<span style="color:#A020F0;">'auto'</span>, <span style="color: #F0F;">...</span>
           <span style="color:#A020F0;">'Units'</span>,<span style="color:#A020F0;">'norm'</span>, <span style="color:#A020F0;">'Position'</span>,<span style="color: #080;">&#91;</span><span style="color: #33f;">0</span>,.75,<span style="color: #33f;">1</span>,.25<span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>;</pre></div></div><p><center><div
class="wp-caption aligncenter" style="width: 606px"><img
alt="Plain data table - so boooooring..." src="http://UndocumentedMatlab.com/images/uitable_plain1.png" title="Plain data table - so boooooring..." width="596" /><p
class="wp-caption-text">Plain data table - so boooooring...</p></div></center></p><p>We can see from this simple example how I have used HTML to format the header labels into two rows, to enable compact columns. I have already <a
target="_blank" href="http://undocumentedmatlab.com/blog/html-support-in-matlab-uicomponents/">described</a> using HTML formatting in Matlab controls in several articles on this website. I have not done this here, but you can easily use HTML formatting for other effect such as superscript (&lt;sup&gt;), subscript (&lt;sub&gt;), bold (&lt;b&gt;), italic (&lt;i&gt;), font sizes and colors (&lt;font&gt;) and other standard HTML effects.</p><p>Even with the multi-line headers, the default column width appears to be too wide. This is apparently an internal Matlab bug, not taking HTML into consideration. This causes only part of the information to be displayed on screen, and requires the user to either scroll right and left, or to manually resize the columns.</p><h3 id="auto-resizing">Second pass &#8211; auto-resizing that actually works&#8230;</h3><p>To solve the auto-resizing issue, we resort to a bit of Java magic powder. We start by using the <a
target="_blank" href="http://UndocumentedMatlab.com/blog/findjobj-find-underlying-java-object/"><i><b>findjobj</b></i> utility</a> to get the table&#8217;s underlying Java reference handle. This is the containing scrollpane, and we are interested in the actual data table inside. We then use the <i>setAutoResizeMode</i>, as <a
target="_blank" rel="nofollow" href="http://download.oracle.com/javase/6/docs/api/javax/swing/JTable.html#setAutoResizeMode%28int%29">described</a> in the official Java documentation.</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">jScroll = findjobj<span style="color: #080;">&#40;</span>hTable<span style="color: #080;">&#41;</span>;
jTable = jScroll.<span style="">getViewport</span>.<span style="">getView</span>;
jTable.<span style="">setAutoResizeMode</span><span style="color: #080;">&#40;</span>jTable.<span style="">AUTO_RESIZE_SUBSEQUENT_COLUMNS</span><span style="color: #080;">&#41;</span>;</pre></div></div><p><center><div
class="wp-caption aligncenter" style="width: 606px"><img
alt="Auto-resized columns that actually work" src="http://UndocumentedMatlab.com/images/uitable_plain2.png" title="Auto-resized columns that actually work" width="596" /><p
class="wp-caption-text">Auto-resized columns that actually work</p></div></center></p><h3 id="colors">Third pass &#8211; adding colors</h3><p>There are still quite a few other customizations needed here: enable <a
target="_blank" href="http://undocumentedmatlab.com/blog/uitable-sorting/">sorting</a>; remove the border outline; set a white background; set row (rather than cell) selection and several other fixes that may seem trivial by themselves but together giver a much more stylish look to the table&#8217;s look and feel. I&#8217;ll skip these for now (interested readers can read all about them, and more, in my detailed <a
target="_blank" href="http://undocumentedmatlab.com/blog/uitable-customization-report/"><i><b>uitable</b></i> customization report</a>).</p><p>One of the more important customizations is to add colors depending on the data. In my client&#8217;s case, there were three requirements:</p><ul><li>data that could be positive or negative should be colored in <b><font
color="green">green</font></b> or <b><font
color="red">red</font></b> foreground color respectively</li><li>large payouts (abs &gt; 2) should be colored in <b><font
color="blue">blue</font></b></li><li>data rows that have statistical significance (%p-value &lt; 5) should have a <span
style="background-color:#ffff00;">yellow background highlight</span></li></ul><p>While we could easily use HTML or CSS formatting to do this, this would be bad for performance in a large data table, may cause some issues when editing table cells or sorting columns. I chose to use the alternative method of <a
target="_blank" rel="nofollow" href="http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#renderer">cell renderers</a>.</p><p><code>ColoredFieldCellRenderer</code> is a simple table cell renderer that enables setting cell-specific foreground/background colors and tooltip messages (it also has a few other goodies like smart text alignment etc.). This requires some Java knowledge to program, but in this case you can simply <a
href="http://UndocumentedMatlab.com/files/ColoredFieldCellRenderer.zip">download</a> the ColoredFieldCellRenderer.zip file and use it, even if you don&#8217;t know Java. The source code is included in the zip file, for anyone who is interested.</p><p>After using <i><b>javaaddpath</b></i> to add the zip file to the dynamic Java classpath (you can add it to the static <i>classpath.txt</i> file instead), the contained Java class file is available for use in Matlab. We configure it according to our data and then assign it to all our table&#8217;s columns.</p><p>Java savvy readers might complain that the data-processing should perhaps be done in the renderer class rather than in Matlab. I have kept it in Matlab because this would enable very easy modification of the highlighting algorithm, without any need to modify the generic Java renderer class.</p><p>Unfortunately, in the new <i><b>uitable</b></i> design (the version available since R2008a), JIDE and Matlab have apparently broken the <a
target="_blank" rel="nofollow" href="http://java.sun.com/products/jfc/tsc/articles/architecture">standard MVC approach</a> by using a table model that not only controls the data but also sets the table&#8217;s appearance (row-striping background colors, for example), and disregards column cell-renderers. In order for our custom cell renderer to have any effect, we must therefore replace Matlab&#8217;s standard <code>DefaultUIStyleTableModel</code> with a simple <code>DefaultTableModel</code>. This in itself is not enough – we also need to ensure that the <i><b>uitable</b></i> has an empty <strong>ColumnFormat</strong> property, because if it is non-empty then it overrides our cell-renderer.</p><p>In the following code, note that Java row and column indices start at 0, not at 1 like in Matlab. We need to be careful about indices when programming java in Matlab.</p><p>The rest of the code should be pretty much self explanatory (again &#8211; more details can be found in the above-mentioned report):</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% Initialize our custom cell renderer class object</span>
javaaddpath<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'ColoredFieldCellRenderer.zip'</span><span style="color: #080;">&#41;</span>;
cr = ColoredFieldCellRenderer<span style="color: #080;">&#40;</span>java.<span style="">awt</span>.<span style="">Color</span>.<span style="">white</span><span style="color: #080;">&#41;</span>;
cr.<span style="">setDisabled</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">% to bg-color the entire column</span>
&nbsp;
<span style="color: #228B22;">% Set specific cell colors (background and/or foreground)</span>
<span style="color: #0000FF;">for</span> rowIdx = <span style="color: #33f;">1</span> <span style="color: #F0F;">:</span> <span style="color: #0000FF;">size</span><span style="color: #080;">&#40;</span>data,<span style="color: #33f;">1</span><span style="color: #080;">&#41;</span>
&nbsp;
  <span style="color: #228B22;">% Red/greed foreground color for the numeric data</span>
  <span style="color: #0000FF;">for</span> colIdx = <span style="color: #33f;">2</span> <span style="color: #F0F;">:</span> <span style="color: #33f;">8</span>
    <span style="color: #0000FF;">if</span> data<span style="color: #080;">&#40;</span>rowIdx,colIdx<span style="color: #080;">&#41;</span> &lt; <span style="color: #33f;">0</span>
      cr.<span style="">setCellFgColor</span><span style="color: #080;">&#40;</span>rowIdx-<span style="color: #33f;">1</span>,colIdx-<span style="color: #33f;">1</span>,java.<span style="">awt</span>.<span style="">Color</span><span style="color: #080;">&#40;</span><span style="color: #33f;">1</span>,<span style="color: #33f;">0</span>,<span style="color: #33f;">0</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;    <span style="color: #228B22;">% red</span>
    <span style="color: #0000FF;">elseif</span> data<span style="color: #080;">&#40;</span>rowIdx,colIdx<span style="color: #080;">&#41;</span> &gt; <span style="color: #33f;">0</span>
      cr.<span style="">setCellFgColor</span><span style="color: #080;">&#40;</span>rowIdx-<span style="color: #33f;">1</span>,colIdx-<span style="color: #33f;">1</span>,java.<span style="">awt</span>.<span style="">Color</span><span style="color: #080;">&#40;</span><span style="color: #33f;">0</span>,<span style="color: #33f;">0.5</span>,<span style="color: #33f;">0</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">% green</span>
    <span style="color: #0000FF;">end</span>
  <span style="color: #0000FF;">end</span>
&nbsp;
  <span style="color: #228B22;">% Yellow background for significant rows based on p-value</span>
  <span style="color: #0000FF;">if</span> data<span style="color: #080;">&#40;</span>rowIdx,<span style="color: #33f;">12</span><span style="color: #080;">&#41;</span> &lt; = <span style="color: #33f;">5</span> <span style="color: #F0F;">&amp;&amp;</span> data<span style="color: #080;">&#40;</span>rowIdx,<span style="color: #33f;">11</span><span style="color: #080;">&#41;</span>~=<span style="color: #33f;">0</span>
    <span style="color: #0000FF;">for</span> colIdx = <span style="color: #33f;">1</span> <span style="color: #F0F;">:</span> <span style="color: #0000FF;">length</span><span style="color: #080;">&#40;</span>headers<span style="color: #080;">&#41;</span>
      cr.<span style="">setCellBgColor</span><span style="color: #080;">&#40;</span>rowIdx-<span style="color: #33f;">1</span>,colIdx-<span style="color: #33f;">1</span>,java.<span style="">awt</span>.<span style="">Color</span><span style="color: #080;">&#40;</span><span style="color: #33f;">1</span>,<span style="color: #33f;">1</span>,<span style="color: #33f;">0</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;    <span style="color: #228B22;">% yellow</span>
    <span style="color: #0000FF;">end</span>
  <span style="color: #0000FF;">end</span>
&nbsp;
  <span style="color: #228B22;">% Bold blue foreground for significant payouts</span>
  <span style="color: #0000FF;">if</span> <span style="color: #0000FF;">abs</span><span style="color: #080;">&#40;</span>data<span style="color: #080;">&#40;</span>rowIdx,<span style="color: #33f;">11</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span> &gt;= <span style="color: #33f;">2</span>
    cr.<span style="">setCellFgColor</span><span style="color: #080;">&#40;</span>rowIdx-<span style="color: #33f;">1</span>,<span style="color: #33f;">10</span>,java.<span style="">awt</span>.<span style="">Color</span><span style="color: #080;">&#40;</span><span style="color: #33f;">0</span>,<span style="color: #33f;">0</span>,<span style="color: #33f;">1</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;    <span style="color: #228B22;">% blue</span>
&nbsp;
    <span style="color: #228B22;">% Note: the following could easily be done in the renderer, just like the colors</span>
    boldPayoutStr = <span style="color: #080;">&#91;</span><span style="color:#A020F0;">'&lt;html&gt;&lt;b&gt;'</span> <span style="color: #0000FF;">num2str</span><span style="color: #080;">&#40;</span>data<span style="color: #080;">&#40;</span>rowIdx,<span style="color: #33f;">11</span><span style="color: #080;">&#41;</span>,<span style="color:#A020F0;">'%.2f'</span><span style="color: #080;">&#41;</span> <span style="color:#A020F0;">'&lt;/b&gt;&lt;/html&gt;'</span><span style="color: #080;">&#93;</span>;
    <span style="color: #228B22;">%jTable.setValueAt(boldPayoutStr,rowIdx-1,10);  % this is no good: overridden when table model is replaced below...</span>
    dataCells<span style="color: #080;">&#123;</span>rowIdx,<span style="color: #33f;">11</span><span style="color: #080;">&#125;</span> = boldPayoutStr;
  <span style="color: #0000FF;">end</span>
<span style="color: #0000FF;">end</span>
&nbsp;
<span style="color: #228B22;">% Replace Matlab's table model with something more renderer-friendly...</span>
jTable.<span style="">setModel</span><span style="color: #080;">&#40;</span>javax.<span style="">swing</span>.<span style="">table</span>.<span style="">DefaultTableModel</span><span style="color: #080;">&#40;</span>dataCells,headers<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>hTable,<span style="color:#A020F0;">'ColumnFormat'</span>,<span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% Finally assign the renderer object to all the table columns</span>
<span style="color: #0000FF;">for</span> colIdx = <span style="color: #33f;">1</span> <span style="color: #F0F;">:</span> <span style="color: #0000FF;">length</span><span style="color: #080;">&#40;</span>headers<span style="color: #080;">&#41;</span>
  jTable.<span style="">getColumnModel</span>.<span style="">getColumn</span><span style="color: #080;">&#40;</span>colIdx-<span style="color: #33f;">1</span><span style="color: #080;">&#41;</span>.<span style="">setCellRenderer</span><span style="color: #080;">&#40;</span>cr<span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">end</span></pre></div></div><p><center><div
class="wp-caption aligncenter" style="width: 600px"><img
alt="Finally something lively!" src="http://UndocumentedMatlab.com/images/uitable_colored.png" title="Finally something lively!" width="590" /><p
class="wp-caption-text">Finally something lively!</p></div></center></p><p>This may not take a beauty contest prize, but you must admit that it now looks more useful than the original table at the top of this article.</p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/uitable-customization-report/' rel='bookmark' title='Uitable customization report'>Uitable customization report</a> <small>In last week&#8217;s report about uitable sorting, I offered a report that I have written which covers uitable customization in detail. Several people have asked for more details about the...</small></li><li><a
href='http://undocumentedmatlab.com/blog/uitable-sorting/' rel='bookmark' title='Uitable sorting'>Uitable sorting</a> <small>Matlab's uitables can be sortable using simple undocumented features...</small></li><li><a
href='http://undocumentedmatlab.com/blog/uitab-colors-icons-images/' rel='bookmark' title='Uitab colors, icons and images'>Uitab colors, icons and images</a> <small>Matlab's semi-documented tab panels can be customized using some undocumented hacks...</small></li><li><a
href='http://undocumentedmatlab.com/blog/changing-matlab-command-window-colors/' rel='bookmark' title='Changing Matlab&#8217;s Command Window colors'>Changing Matlab&#8217;s Command Window colors</a> <small>Matlab's Command Window foreground and background colors can be modified programmatically, using some of Matlab's undocumented internal Java classes. Here's how....</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/uitable-cell-colors/feed/</wfw:commentRss> <slash:comments>6</slash:comments> </item> <item><title>Tri-state checkbox</title><link>http://undocumentedmatlab.com/blog/tri-state-checkbox/</link> <comments>http://undocumentedmatlab.com/blog/tri-state-checkbox/#comments</comments> <pubDate>Wed, 19 Oct 2011 14:04:20 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[GUI]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[Medium risk of breaking in future versions]]></category> <category><![CDATA[UI controls]]></category> <category><![CDATA[Undocumented feature]]></category> <category><![CDATA[FindJObj]]></category> <category><![CDATA[Internal component]]></category> <category><![CDATA[JIDE]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=2467</guid> <description><![CDATA[Matlab checkboxes can easily be made to support tri-state functionality.<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/recovering-previous-editor-state/' rel='bookmark' title='Recovering previous editor state'>Recovering previous editor state</a> <small>Recovering the previous state of the Matlab editor and its loaded documents is possible using a built-in backup config file. ...</small></li><li><a
href='http://undocumentedmatlab.com/blog/determining-axes-zoom-state/' rel='bookmark' title='Determining axes zoom state'>Determining axes zoom state</a> <small>The information of whether or not an axes is zoomed or panned can easily be inferred from an internal undocumented object....</small></li><li><a
href='http://undocumentedmatlab.com/blog/jide-property-grids/' rel='bookmark' title='JIDE Property Grids'>JIDE Property Grids</a> <small>The JIDE components pre-bundled in Matlab enable creating user-customized property grid tables...</small></li><li><a
href='http://undocumentedmatlab.com/blog/findjobj-gui-display-container-hierarchy/' rel='bookmark' title='FindJObj GUI &#8211; display container hierarchy'>FindJObj GUI &#8211; display container hierarchy</a> <small>The FindJObj utility can be used to present a GUI that displays a Matlab container's internal Java components, properties and callbacks....</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p>When presenting information visually in graphical user interfaces (GUIs), we often need to present and enable interaction with state data (such as On/Off). In most cases, we would naturally use a checkbox to present the information and enable interaction. But What can we do if the data has three possible states. For example, Yes/No/Maybe, or: Full/Empty/Partial, or: Up/Down/Undetermined ?</p><p>Until today, Matlab GUIs had to resort to using drop-down (aka combo-box or popup-menu) or radio-button controls to present such information. However, would it not be nicer if we could still use a checkbox? Outside Matlab, such a control is known as a tri-state checkbox and many modern GUI frameworks support it. Well, surprise surprise, so does Matlab (although you would never guess it from the documentation).</p><h3 id="CheckBoxTree">CheckBoxTree</h3><p>Last year, I have already <a
target="_blank" href="http://undocumentedmatlab.com/blog/customizing-uitree-nodes-2/#Built-in-classes">described</a> a built-in Matlab tree control whose nodes have tri-state checkboxes:</p><p><center><div
class="wp-caption aligncenter" style="width: 321px"><img
alt="a regular MJTree (left) and a CheckBoxTree (right)" src="http://UndocumentedMatlab.com/images/CheckBoxTree.png" title="a regular MJTree (left) and a CheckBoxTree (right)" width="311" height="218" /><p
class="wp-caption-text">a regular MJTree (left) and a CheckBoxTree (right)</p></div></center></p><p>Today I will show how we can use these checkboxes as independent GUI controls.</p><h3 id="uicontrol">Modifying the standard Matlab checkbox uicontrol</h3><p>In order to modify the standard Matlab checkbox <i><b>uicontrol</b></i>, we need to first get its underlying Java component reference. This is done using the <a
target="_blank" href="http://undocumentedmatlab.com/blog/findjobj-find-underlying-java-object/"><i><b>findjobj</b></i> utility</a>. We then update its UI wrapper to be the same as the <code>CheckBoxTree</code>&#8216;s checkbox control.</p><p>To programmatically set a mixed state we update the &#8216;selectionState&#8217; client property to <code>SelectionState.MIXED</code> (<code>SelectionState</code> also has the <code>SELECTED</code> and <code>NOT_SELECTED</code> values).</p><p>Here is an end-to-end example:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">hCB = <span style="color: #0000FF;">uicontrol</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'Style'</span>,<span style="color:#A020F0;">'checkbox'</span>, <span style="color: #F0F;">...</span><span style="color: #080;">&#41;</span>;
jCB = findjobj<span style="color: #080;">&#40;</span>hCB<span style="color: #080;">&#41;</span>;
jCB.<span style="">setUI</span><span style="color: #080;">&#40;</span>com.<span style="">mathworks</span>.<span style="">mwswing</span>.<span style="">checkboxtree</span>.<span style="">TriStateButtonUI</span><span style="color: #080;">&#40;</span>jCB.<span style="">getUI</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% Update the checkbox state to MIXED</span>
newState = com.<span style="">mathworks</span>.<span style="">mwswing</span>.<span style="">checkboxtree</span>.<span style="">SelectionState</span>.<span style="">MIXED</span>;
jCB.<span style="">putClientProperty</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'selectionState'</span>, newState<span style="color: #080;">&#41;</span>;
jCB.<span style="">repaint</span>;</pre></div></div><p><center><div
class="wp-caption aligncenter" style="width: 299px"><img
alt="Matlab checkboxes displaying mixed states" src="http://UndocumentedMatlab.com/images/CheckBox_TriState.png" title="Matlab checkboxes displaying mixed states" width="289" /><p
class="wp-caption-text">Matlab checkboxes displaying mixed states</p></div></center></p><h3 id="independent">Displaying as an independent Java control</h3><p>Instead of retrofitting a standard Matlab <i><b>uicontrol</b></i> as described above, we can directly use the standard <code>javax.swing.JCheckBox</code> which does not normally support tri-state (it only has two states), displaying it in our GUI with the built-in <a
target="_blank" href="http://undocumentedmatlab.com/blog/javacomponent/"><i><b>javacomponent</b></i> function</a>:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% Display the checkbox (UNSELECTED state at first)</span>
jCB = javax.<span style="">swing</span>.<span style="">JCheckBox</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'JCheckBox - mixed'</span>,<span style="color: #33f;">0</span><span style="color: #080;">&#41;</span>;
javacomponent<span style="color: #080;">&#40;</span>jCB, <span style="color: #080;">&#91;</span><span style="color: #33f;">10</span>,<span style="color: #33f;">70</span>,<span style="color: #33f;">150</span>,<span style="color: #33f;">20</span><span style="color: #080;">&#93;</span>, <span style="color: #0000FF;">gcf</span><span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% Update the checkbox state to MIXED</span>
import com.<span style="">mathworks</span>.<span style="">mwswing</span>.<span style="">checkboxtree</span>.*
jCB.<span style="">setUI</span><span style="color: #080;">&#40;</span>TriStateButtonUI<span style="color: #080;">&#40;</span>jCB.<span style="">getUI</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
jCB.<span style="">putClientProperty</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'selectionState'</span>, SelectionState.<span style="">MIXED</span><span style="color: #080;">&#41;</span>;
jCB.<span style="">repaint</span>;</pre></div></div><p>Note that instead of using <code>javax.swing.JCheckBox</code>, we could use the internal Matlab class <code>com.mathworks.mwswing.MJCheckBox</code>, which directly extends <code>JCheckBox</code> and adds mnemonic (shortcut-key) support, but is otherwise fully compatible with <code>JCheckBox</code>. Actually, it is <code>MJCheckBox</code> which is the underlying Java component of the standard Matlab checkbox <i><b>uicontrol</b></i>.</p><h3 id="alternatives">Alternative controls</h3><p>Now that we have seen that Matlab includes built-in support (well, at least support in the technical sense, not the official customer-support sense), would you be surprised to learn that it includes similar support in other internal components as well?</p><p>The internal Matlab class <code>com.mathworks.mwt.MWCheckbox</code> directly supports a tri-state (yes/no/maybe) checkbox, without any need to update its UI, as follows:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% Display the checkbox (UNSELECTED state at first)</span>
jCB = com.<span style="">mathworks</span>.<span style="">mwt</span>.<span style="">MWCheckbox</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'MWCheckbox - mixed'</span>,<span style="color: #33f;">0</span><span style="color: #080;">&#41;</span>;
javacomponent<span style="color: #080;">&#40;</span>jCB, <span style="color: #080;">&#91;</span><span style="color: #33f;">10</span>,<span style="color: #33f;">70</span>,<span style="color: #33f;">150</span>,<span style="color: #33f;">20</span><span style="color: #080;">&#93;</span>, <span style="color: #0000FF;">gcf</span><span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% Update the checkbox state to MIXED</span>
jCB.<span style="">setMixedState</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% Retrieve the current state</span>
isMixedFlag = jCB.<span style="">isMixedState</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">% true/false</span></pre></div></div><p><center><div
class="wp-caption aligncenter" style="width: 299px"><img
alt="MJCheckBox vs. MWCheckbox" src="http://UndocumentedMatlab.com/images/CheckBox_MWT_MWSwing.png" title="MJCheckBox vs. MWCheckbox" width="289" /><p
class="wp-caption-text">MJCheckBox vs. MWCheckbox</p></div></center></p><p>Note that the State property, which controls the standard selected/unselected state, is entirely independent from the MixedState property. Both State and MixedState are boolean properties, so to get the actual checkbox state we need to query both of these properties.</p><p>Another internal Matlab class that we can use is JIDE&#8217;s <code>com.jidesoft.swing.TristateCheckBox</code> (which is pre-bundled in Matlab and is fully documented <a
target="_blank" rel="nofollow" href="http://www.jidesoft.com/javadoc/com/jidesoft/swing/TristateCheckBox.html">here</a>).</p><p>There are many other tri-state checkbox alternatives available online (for example, <a
target="_blank" rel="nofollow" href="https://forums.oracle.com/forums/search.jspa?threadID=&#038;q=%28tri-state+OR+tristate%29+AND+checkbox&#038;objID=c285&#038;dateRange=all&#038;userID=&#038;numResults=30&#038;rankBy=10001">here</a>, <a
target="_blank" rel="nofollow" href="http://www.javaspecialists.eu/archive/Issue145.html">here</a> and <a
target="_blank" rel="nofollow" href="http://stackoverflow.com/questions/1263323/tristate-checkboxes-in-java">here</a>). We can easily include them in our Matlab GUI with the <i><b>javacomponent</b></i> function. Using external components we can be more certain of the compatibility issues in past and future Matlab releases. On the other hand, internal Matlab classes do have the advantage of being inherently accessible on all platforms of the same Matlab release, whereas non-Matlab components must be included in our deployment package.</p><p>Do you use any tri-state controls, either Matlab or external, in your work? If so, please share your experience in a <a
href="http://UndocumentedMatlab.com/blog/tri-state-checkbox/#respond">comment below</a>.</p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/recovering-previous-editor-state/' rel='bookmark' title='Recovering previous editor state'>Recovering previous editor state</a> <small>Recovering the previous state of the Matlab editor and its loaded documents is possible using a built-in backup config file. ...</small></li><li><a
href='http://undocumentedmatlab.com/blog/determining-axes-zoom-state/' rel='bookmark' title='Determining axes zoom state'>Determining axes zoom state</a> <small>The information of whether or not an axes is zoomed or panned can easily be inferred from an internal undocumented object....</small></li><li><a
href='http://undocumentedmatlab.com/blog/jide-property-grids/' rel='bookmark' title='JIDE Property Grids'>JIDE Property Grids</a> <small>The JIDE components pre-bundled in Matlab enable creating user-customized property grid tables...</small></li><li><a
href='http://undocumentedmatlab.com/blog/findjobj-gui-display-container-hierarchy/' rel='bookmark' title='FindJObj GUI &#8211; display container hierarchy'>FindJObj GUI &#8211; display container hierarchy</a> <small>The FindJObj utility can be used to present a GUI that displays a Matlab container's internal Java components, properties and callbacks....</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/tri-state-checkbox/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Uitable customization report</title><link>http://undocumentedmatlab.com/blog/uitable-customization-report/</link> <comments>http://undocumentedmatlab.com/blog/uitable-customization-report/#comments</comments> <pubDate>Wed, 03 Aug 2011 18:00:25 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[GUI]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[Medium risk of breaking in future versions]]></category> <category><![CDATA[Stock Matlab function]]></category> <category><![CDATA[Undocumented feature]]></category> <category><![CDATA[HTML]]></category> <category><![CDATA[Internal component]]></category> <category><![CDATA[JIDE]]></category> <category><![CDATA[Semi-documented function]]></category> <category><![CDATA[uitable]]></category> <category><![CDATA[uitable report]]></category> <category><![CDATA[uitools]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=2396</guid> <description><![CDATA[In last week&#8217;s report about uitable sorting, I offered a report that I have written which covers uitable customization in detail. Several people have asked for more details about the contents of this report. This is a reasonable request, and [...]<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/uitable-sorting/' rel='bookmark' title='Uitable sorting'>Uitable sorting</a> <small>Matlab's uitables can be sortable using simple undocumented features...</small></li><li><a
href='http://undocumentedmatlab.com/blog/uitable-cell-colors/' rel='bookmark' title='Uitable cell colors'>Uitable cell colors</a> <small>A few Java-based customizations can transform a plain-looking data table into a lively colored one. ...</small></li><li><a
href='http://undocumentedmatlab.com/blog/guide-customization/' rel='bookmark' title='GUIDE customization'>GUIDE customization</a> <small>Matlab's GUI Design Editor (GUIDE) has several interesting undocumented features. This post describes how to customize GUIDE rulers....</small></li><li><a
href='http://undocumentedmatlab.com/blog/button-customization/' rel='bookmark' title='Button customization'>Button customization</a> <small>Matlab's button uicontrols (pushbutton and togglebutton) are basically wrappers for a Java Swing JButton object. This post describes how the buttons can be customized using this Java object in ways...</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p>In last week&#8217;s report about <a
target="_blank" href="http://undocumentedmatlab.com/blog/uitable-sorting/"><i><b>uitable</b></i> sorting</a>, I offered a report that I have written which covers <i><b>uitable</b></i> customization in detail. Several people have asked for more details about the contents of this report. This is a reasonable request, and so in today&#8217;s post I will discuss in a bit more detail the highlights of what can be achieved to customize Matlab <i><b>uitable</b></i>s. For the fine details, well, <a
target="_blank" rel="nofollow" href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&#038;business=ymasoftware@gmail.com&#038;currency_code=USD&#038;amount=35&#038;return=&#038;item_name=Matlab-uitable-report">get the report</a>&#8230;</p><h3 id="Introduction">1. Introduction</h3><p>Here I discuss the evolution of the <i><b>uitable</b></i> control over the past decade, from its initially semi-documented status to today. I explain the similarities and differences between the control&#8217;s versions and explain how they can both be accessed today.</p><p>I also provide references to online resources for both Matlab&#8217;s <i><b>uitable</b></i>&#8216;s underlying Java components, as well as multiple alternatives using different technologies, that have been used and reported over the years.</p><h3 id="Customization">2. Customizing uitable</h3><p>In this section I explore the sub-component hierarchy of the <i><b>uitable</b></i> control (both new and old). I show how the scrollbar sub-components can be accessed (this will be used in section 4 below), as well as the table header and data grid.<br
/><center><div
class="wp-caption aligncenter" style="width: 322px"><img
alt="annotated uitable sub-components" src="http://undocumentedmatlab.com/images/uitable_new2b.png" title="annotated uitable sub-components" width="312" /><p
class="wp-caption-text">annotated <i><b>uitable</b></i> sub-components</p></div></center></p><p>I explain how individual cells can be modified without requiring the entire data set to be updated. This is very important in large data sets, to prevent flicker and improve performance.</p><p>I show how HTML can be used to format data cell contents (even images) and tooltips:<br
/><center><div
class="wp-caption aligncenter" style="width: 259px"><img
alt="uitable with HTML cell contents and tooltip" src="http://undocumentedmatlab.com/images/uitable2.png" title="uitable with HTML cell contents and tooltip" width="249" /><p
class="wp-caption-text"><i><b>uitable</b></i> with HTML cell contents and tooltip</p></div></center></p><p>I then explain the role of the cell-renderer in the visual appearance of the cell, and of cell-editors in the way that cells interact with the user for data modification. I explain such customizations from the simple (setting a column&#8217;s background color) to the complex (cell-specific tooltips and colors; color-selection cell-editor):<br
/><center><div
class="wp-caption aligncenter" style="width: 590px"><img
alt="uitable with a non-standard cell-renderer" src="http://undocumentedmatlab.com/images/uitable5b.png" title="uitable with a non-standard cell-renderer" width="288" /><img
alt="uitable with a non-standard cell-editor" src="http://undocumentedmatlab.com/images/uitable_lookup.png" title="uitable with a non-standard cell-editor" width="280" /><p
class="wp-caption-text"><i><b>uitable</b></i> with a non-standard cell-renderer (left) and cell-editor (right)</p></div><br
/><div
class="wp-caption aligncenter" style="width: 318px"><img
alt="uitable with custom CellRenderer and CellEditor" src="http://UndocumentedMatlab.com/images/ColorCellEditor_Renderer.png" title="uitable with custom CellRenderer and CellEditor" width="308" /><p
class="wp-caption-text"><i><b>uitable</b></i> with custom CellRenderer and CellEditor</p></div></center></p><h3 id="Callbacks">3. Table callbacks</h3><p>This section presents the different callback properties that are settable in the old and new <i><b>uitable</b></i>, for events such as cell selection, data modification, key press, and mouse click. The discussion includes a working code example for validating user input and reverting invalid edits. The section also includes a discussion of how to avoid and overcome problems that may occur with the callback execution.</p><h3 id="Scrollbars">4. Customizing scrollbars, column widths and selection behavior</h3><p>This section explains how to control the scrollbars behavior. For example, hiding the horizontal (bottom) scrollbar, automatically displaying it when the data width is larger than the table width. I also show how to control the column widths.</p><p>I then show how to customize the data selection policy: Can multiple cells be selected? perhaps only one cell at a time? or maybe a single large interval of cells? &#8211; this is all customizable. I then explain how the selection can be done and accessed programmatically. Ever wanted to set the cursor on cell A1 after some system event has occurred? &#8211; this will show you how to do it. Ever wanted to use non-standard selection colors (background/foreground)? &#8211; this can also be done.</p><h3 id="Sorting">5. Data sorting</h3><p>Table sorting was discussed in last week&#8217;s <a
target="_blank" href="http://undocumentedmatlab.com/blog/uitable-sorting/">article</a>. This section expands on that article, and explains how the sorting can be customized, controlled, and accessed programmatically, and how sorted rows can be retrieved by the user.<br
/><center><div
class="wp-caption aligncenter" style="width: 270px"><img
alt="Multi-column sorting with blue sort-order numbers" src="http://UndocumentedMatlab.com/images/JIDE_Table_sort3a.png" title="Multi-column sorting with blue sort-order numbers" width="260" /><p
class="wp-caption-text">Multi-column sorting with blue sort-order numbers</p></div></center></p><h3 id="Filtering">6. Data filtering</h3><p>Data filtering is the ability to filter only a specified sub-set of rows for display (just like in Excel). This section explains how to do it (it&#8217;s so easy!).<br
/><center><div
class="wp-caption aligncenter" style="width: 418px"><img
alt="uitable data filtering" src="http://UndocumentedMatlab.com/images/004x013b.png" title="uitable data filtering" width="408" /><p
class="wp-caption-text"><i><b>uitable</b></i> data filtering</p></div></center></p><h3 id="JIDE">7. JIDE customizations</h3><p>The new <i><b>uitable</b></i> is based on an underlying JIDE table. This sectino explains how we can use this to our advantage for some simple and useful. Customization.</p><p>For example: have you wondered some time why is it that columns can only be resized by dragging the tiny divider in the table header? Why can&#8217;t the columns and rows be resized by dragging the grid lines? Well, it turns out that they can, with just a tiny bit of JIDE magic powder, explained here:<br
/><center><div
class="wp-caption aligncenter" style="width: 270px"><img
alt="Resizing columns" src="http://UndocumentedMatlab.com/images/004x014.png" title="Resizing columns" width="260" /><p
class="wp-caption-text">Resizing columns</p></div></center></p><p>Similarly, this section explains how we can use JIDE to merge together adjacent cells:<br
/><center><div
class="wp-caption aligncenter" style="width: 270px"><img
alt="Example of two table cell-spans (1x2 and 2x2)" src="http://UndocumentedMatlab.com/images/004x016.png" title="Example of two table cell-spans (1x2 and 2x2)" width="260" /><p
class="wp-caption-text">Example of two table cell-spans (1x2 and 2x2)</p></div></center></p><h3 id="Structure">8. Controlling the table structure (adding/removing rows)</h3><p>This section discusses the matter of dynamically adding and removing table rows. While this is easy to do in the old <i><b>uitable</b></i>, this is unfortunately not the case in the new <i><b>uitable</b></i>.</p><h3 id="Final">9. Final remarks</h3><p>Here I present a workaround for a long-time table bug. Also, I present my <i><b>createTable</b></i> utility that wraps table creation in Matlab:<br
/><center><div
class="wp-caption aligncenter" style="width: 607px"><img
alt="createTable utility screenshot (note the action buttons, sortable columns, and customized CellEditor)" src="http://UndocumentedMatlab.com/images/table.png" title="createTable utility screenshot (note the action buttons, sortable columns, and customized CellEditor)" width="597" /><p
class="wp-caption-text"><i><b>createTable</b></i> utility screenshot (note the action buttons, sortable columns, and customized CellEditor)</p></div></center></p><h3 id="JIDE-Grids">Appendix – JIDE Grids</h3><p>Finally, this appendix presents an overview of the wide array of components provided by JIDE and available in Matlab. <i><b>uitable</b></i> uses only one of these components (the <code>SortableTable</code>). In fact, there are many more such controls that we can use in our GUIs.</p><p>These include a wide selection of combo-box (drop-down) controls &#8211; calculator, file/folder selection, date selection, color selection, multi-elements selection etc. In addition, a very wide selection of lists, trees and table types is available.</p><p>Also included is a set of specialized editbox controls for accepting IP addresses and credit card numbers:<br
/><center><div
class="wp-caption aligncenter" style="width: 360px"><img
alt="IP address entry box" src="http://UndocumentedMatlab.com/images/JIDE_IPTextField.png" title="IP address entry box" width="100" /><img
alt="credit-card entry box" src="http://UndocumentedMatlab.com/images/JIDE_CreditCard_invalid.png" title="credit-card entry box" width="100" /><img
alt="credit-card entry box" src="http://UndocumentedMatlab.com/images/JIDE_CreditCard_Visa.png" title="credit-card entry box" width="100" /><p
class="wp-caption-text">IP address and credit-card entry boxes</p></div></center></p><p>While not explaining all these controls in detail (this could take hundreds of pages), this section does say a few words on each of them, and includes links to online resources for further exploration.</p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/uitable-sorting/' rel='bookmark' title='Uitable sorting'>Uitable sorting</a> <small>Matlab's uitables can be sortable using simple undocumented features...</small></li><li><a
href='http://undocumentedmatlab.com/blog/uitable-cell-colors/' rel='bookmark' title='Uitable cell colors'>Uitable cell colors</a> <small>A few Java-based customizations can transform a plain-looking data table into a lively colored one. ...</small></li><li><a
href='http://undocumentedmatlab.com/blog/guide-customization/' rel='bookmark' title='GUIDE customization'>GUIDE customization</a> <small>Matlab's GUI Design Editor (GUIDE) has several interesting undocumented features. This post describes how to customize GUIDE rulers....</small></li><li><a
href='http://undocumentedmatlab.com/blog/button-customization/' rel='bookmark' title='Button customization'>Button customization</a> <small>Matlab's button uicontrols (pushbutton and togglebutton) are basically wrappers for a Java Swing JButton object. This post describes how the buttons can be customized using this Java object in ways...</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/uitable-customization-report/feed/</wfw:commentRss> <slash:comments>9</slash:comments> </item> <item><title>Uitable sorting</title><link>http://undocumentedmatlab.com/blog/uitable-sorting/</link> <comments>http://undocumentedmatlab.com/blog/uitable-sorting/#comments</comments> <pubDate>Tue, 26 Jul 2011 18:00:01 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[GUI]]></category> <category><![CDATA[Handle graphics]]></category> <category><![CDATA[Hidden property]]></category> <category><![CDATA[High risk of breaking in future versions]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[Semi-documented function]]></category> <category><![CDATA[Stock Matlab function]]></category> <category><![CDATA[Undocumented feature]]></category> <category><![CDATA[HTML]]></category> <category><![CDATA[Internal component]]></category> <category><![CDATA[JIDE]]></category> <category><![CDATA[uitable]]></category> <category><![CDATA[uitools]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=2391</guid> <description><![CDATA[Matlab's uitables can be sortable using simple undocumented features<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/uitable-customization-report/' rel='bookmark' title='Uitable customization report'>Uitable customization report</a> <small>In last week&#8217;s report about uitable sorting, I offered a report that I have written which covers uitable customization in detail. Several people have asked for more details about the...</small></li><li><a
href='http://undocumentedmatlab.com/blog/uitable-cell-colors/' rel='bookmark' title='Uitable cell colors'>Uitable cell colors</a> <small>A few Java-based customizations can transform a plain-looking data table into a lively colored one. ...</small></li><li><a
href='http://undocumentedmatlab.com/blog/matlab-and-the-event-dispatch-thread-edt/' rel='bookmark' title='Matlab and the Event Dispatch Thread (EDT)'>Matlab and the Event Dispatch Thread (EDT)</a> <small>The Java Swing Event Dispatch Thread (EDT) is very important for Matlab GUI timings. This article explains the potential pitfalls and their avoidance using undocumented Matlab functionality....</small></li><li><a
href='http://undocumentedmatlab.com/blog/tab-panels-uitab-and-relatives/' rel='bookmark' title='Tab panels &#8211; uitab and relatives'>Tab panels &#8211; uitab and relatives</a> <small>This article describes several undocumented Matlab functions that support tab-panels...</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p><a
target="_blank" rel="nofollow" href="http://www.mathworks.com/help/techdoc/ref/uitable.html"><i><b>uitable</b></i></a> is probably the most complex basic GUI controls available in Matlab. It displays data in a table within a figure, with settable properties as with any other Matlab Handle-Graphics (HG) control. After many years in which the <i><b>uitable</b></i> was available but <a
target="_blank" href="http://undocumentedmatlab.com/blog/legend-semi-documented-feature/#Semi-documented">semi-documented</a> and not officially supported in Matlab, it finally became fully documented and supported in R2008a (aka Matlab 7.6). At that time its internal implementation has changed from a MathWorks-developed Java table to a <a
target="_blank" href="http://undocumentedmatlab.com/blog/tag/JIDE/">JIDE</a>-based Java table (another JIDE-derived table was described <a
target="_blank" href="http://undocumentedmatlab.com/blog/jide-property-grids/">here</a> last year). Since R2008a, both versions of <i><b>uitable</b></i> are available &#8211; the old version is available by adding the &#8216;v0&#8242; input arg.</p><p>Matlab&#8217;s <i><b>uitable</b></i> exposes only a very limited subset of functionalities and properties to the user. Numerous other functionalities are available by accessing the underlying Java table and hidden Matlab properties. Today I will describe a very <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/answers/1880-uitable-can-the-headers-be-made-clickable">common need</a> in GUI tables, that for some unknown reason is missing in Matlab&#8217;s <i><b>uitable</b></i>: Sorting table data columns.</p><p>Last week I <a
target="_blank" href="http://undocumentedmatlab.com/blog/running-vb-code-in-matlab/">explained</a> how we can modify table headers of an ActiveX table control to display sorting icons. In that case, sorting was built-in the control, and the question was just how to display the sorting arrow icon. Unfortunately, Matlab&#8217;s <i><b>uitable</b></i> does not have sorting built-in, although it&#8217;s quite easy to add it, as I shall now show.</p><h3 id="Old">Old uitable sorting</h3><p>The old <i><b>uitable</b></i> is the default control used until R2007b, or that can be selected with the &#8216;v0&#8242; input arg since R2008a. It was based on an internal MathWorks extension of the standard Java Swing <a
target="_blank" rel="nofollow" href="http://download.oracle.com/javase/tutorial/uiswing/components/table.html">JTable</a> &#8211; a class called <code>com.mathworks.widgets.spreadsheet.SpreadsheetTable</code>.</p><p>Users will normally try to sort columns by clicking the header. This has been a deficiency of JTable for ages. To solve this for the old (pre-R2008a) <i><b>uitable</b></i>, download one of several available JTable sorter classes, or my TableSorter class (available <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/14225-java-based-data-table">here</a>).  Add the TableSorter.jar file to your static java classpath (via <code>edit('classpath.txt')</code>) or your dynamic classpath (<code>javaaddpath('TableSorter.jar')</code>).</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% Display the uitable and get its underlying Java object handle</span>
<span style="color: #080;">&#91;</span>mtable,hcontainer<span style="color: #080;">&#93;</span> = uitable<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'v0'</span>, <span style="color: #0000FF;">gcf</span>, <span style="color: #0000FF;">magic</span><span style="color: #080;">&#40;</span><span style="color: #33f;">3</span><span style="color: #080;">&#41;</span>, <span style="color: #080;">&#123;</span><span style="color:#A020F0;">'A'</span>, <span style="color:#A020F0;">'B'</span>, <span style="color:#A020F0;">'C'</span><span style="color: #080;">&#125;</span><span style="color: #080;">&#41;</span>;   <span style="color: #228B22;">% discard the 'v0' in R2007b and earlier</span>
jtable = mtable.<span style="">getTable</span>;   <span style="color: #228B22;">% or: get(mtable,'table');</span>
&nbsp;
<span style="color: #228B22;">% We want to use sorter, not data model...</span>
<span style="color: #228B22;">% Unfortunately, UitablePeer expects DefaultTableModel not TableSorter so we need a modified UitablePeer class</span>
<span style="color: #228B22;">% But UitablePeer is a Matlab class, so use a modified TableSorter &amp; attach it to the Model</span>
<span style="color: #0000FF;">if</span> ~<span style="color: #0000FF;">isempty</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">which</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'TableSorter'</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
   <span style="color: #228B22;">% Add TableSorter as TableModel listener</span>
   sorter = TableSorter<span style="color: #080;">&#40;</span>jtable.<span style="">getModel</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
   jtable.<span style="">setModel</span><span style="color: #080;">&#40;</span>sorter<span style="color: #080;">&#41;</span>;
   sorter.<span style="">setTableHeader</span><span style="color: #080;">&#40;</span>jtable.<span style="">getTableHeader</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
&nbsp;
   <span style="color: #228B22;">% Set the header tooltip (with sorting instructions)</span>
   jtable.<span style="">getTableHeader</span>.<span style="">setToolTipText</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'&lt;html&gt;&amp;nbsp;&lt;b&gt;Click&lt;/b&gt; to sort up; &lt;b&gt;Shift-click&lt;/b&gt; to sort down&lt;br /&gt;&amp;nbsp;...&lt;/html&gt;'</span><span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #0000FF;">else</span>
   <span style="color: #228B22;">% Set the header tooltip (no sorting instructions...)</span>
   jtable.<span style="">getTableHeader</span>.<span style="">setToolTipText</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'&lt;html&gt;&amp;nbsp;&lt;b&gt;Click&lt;/b&gt; to select entire column&lt;br /&gt;&amp;nbsp;&lt;b&gt;Ctrl-click&lt;/b&gt; (or &lt;b&gt;Shift-click&lt;/b&gt;) to select multiple columns&amp;nbsp;&lt;/html&gt;'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">end</span></pre></div></div><p><center><div
class="wp-caption aligncenter" style="width: 607px"><img
alt="Sorted uitable - old version" src="http://www.mathworks.com/matlabcentral/fx_files/14225/1/table.png" title="Sorted uitable - old version" width="597" /><p
class="wp-caption-text">Sorted <i><b>uitable</b></i> - old version</p></div></center></p><h3 id="New">New uitable sorting</h3><p>The new <i><b>uitable</b></i> is based on JIDE&#8217;s <code>com.jidesoft.grid.SortableTable</code> and so has built-in sorting support – all you need to do is to turn it on. First get the underlying Java object using my <a
target="_blank" href="http://undocumentedmatlab.com/blog/findjobj-find-underlying-java-object/">FindJObj utility</a>:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% Display the uitable and get its underlying Java object handle</span>
mtable = uitable<span style="color: #080;">&#40;</span><span style="color: #0000FF;">gcf</span>, <span style="color:#A020F0;">'Data'</span>,<span style="color: #0000FF;">magic</span><span style="color: #080;">&#40;</span><span style="color: #33f;">3</span><span style="color: #080;">&#41;</span>, <span style="color:#A020F0;">'ColumnName'</span>,<span style="color: #080;">&#123;</span><span style="color:#A020F0;">'A'</span>, <span style="color:#A020F0;">'B'</span>, <span style="color:#A020F0;">'C'</span><span style="color: #080;">&#125;</span><span style="color: #080;">&#41;</span>;
jscrollpane = findjobj<span style="color: #080;">&#40;</span>mtable<span style="color: #080;">&#41;</span>;
jtable = jscrollpane.<span style="">getViewport</span>.<span style="">getView</span>;
&nbsp;
<span style="color: #228B22;">% Now turn the JIDE sorting on</span>
jtable.<span style="">setSortable</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;		<span style="color: #228B22;">% or: set(jtable,'Sortable','on');</span>
jtable.<span style="">setAutoResort</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;
jtable.<span style="">setMultiColumnSortable</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;
jtable.<span style="">setPreserveSelectionsAfterSorting</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;</pre></div></div><p>Note: the Matlab <code>mtable</code> handle has a hidden <b>Sortable</b> property, but it has no effect – use the Java property mentioned above instead. I assume that the hidden <b>Sortable</b> property was meant to implement the sorting behavior in R2008a, but MathWorks never got around to actually implement it, and so it remains this way to this day.</p><h3 id="Report">A more detailed report</h3><p>I have prepared a 30-page report about using and customizing Matlab&#8217;s <i><b>uitable</b></i>, which greatly expands on the above. This report is available for a small fee <a
target="_blank" rel="nofollow" href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&#038;business=ymasoftware@gmail.com&#038;currency_code=USD&#038;amount=35&#038;return=&#038;item_name=Matlab-uitable-report">here</a> (please allow up to 48 hours for email delivery). The report includes the following:</p><ul><li>comparison of the old vs. the new <i><b>uitable</b></i> implementations</li><li>description of the <i><b>uitable</b></i> properties and callbacks</li><li>alternatives to <i><b>uitable</b></i> using a variety of technologies</li><li>updating a specific cell&#8217;s value</li><li>setting background and foreground colors for a cell or column</li><li>using dedicated cell renderer and editor components</li><li>HTML processing</li><li>setting dynamic cell-specific tooltip</li><li>setting dynamic cell-specific drop-down selection options</li><li>using a color-selection drop-down for cells</li><li>customizing scrollbars</li><li>customizing column widths and resizing</li><li>customizing selection behavior</li><li>data sorting (expansion of today&#8217;s article)</li><li>data filtering (similar to Excel&#8217;s data filtering control)</li><li>merging table cells</li><li>programmatically adding/removing rows</li><li>numerous links to online resources</li><li>overview of the JIDE grids package, which contains numerous extremely useful GUI controls and components</li></ul><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/uitable-customization-report/' rel='bookmark' title='Uitable customization report'>Uitable customization report</a> <small>In last week&#8217;s report about uitable sorting, I offered a report that I have written which covers uitable customization in detail. Several people have asked for more details about the...</small></li><li><a
href='http://undocumentedmatlab.com/blog/uitable-cell-colors/' rel='bookmark' title='Uitable cell colors'>Uitable cell colors</a> <small>A few Java-based customizations can transform a plain-looking data table into a lively colored one. ...</small></li><li><a
href='http://undocumentedmatlab.com/blog/matlab-and-the-event-dispatch-thread-edt/' rel='bookmark' title='Matlab and the Event Dispatch Thread (EDT)'>Matlab and the Event Dispatch Thread (EDT)</a> <small>The Java Swing Event Dispatch Thread (EDT) is very important for Matlab GUI timings. This article explains the potential pitfalls and their avoidance using undocumented Matlab functionality....</small></li><li><a
href='http://undocumentedmatlab.com/blog/tab-panels-uitab-and-relatives/' rel='bookmark' title='Tab panels &#8211; uitab and relatives'>Tab panels &#8211; uitab and relatives</a> <small>This article describes several undocumented Matlab functions that support tab-panels...</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/uitable-sorting/feed/</wfw:commentRss> <slash:comments>16</slash:comments> </item> <item><title>Syntax highlighted labels &amp; panels</title><link>http://undocumentedmatlab.com/blog/syntax-highlighted-labels-panels/</link> <comments>http://undocumentedmatlab.com/blog/syntax-highlighted-labels-panels/#comments</comments> <pubDate>Wed, 14 Jul 2010 16:02:26 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[GUI]]></category> <category><![CDATA[High risk of breaking in future versions]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[HTML]]></category> <category><![CDATA[Internal component]]></category> <category><![CDATA[JIDE]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=1738</guid> <description><![CDATA[Syntax-highlighted labels and edit-boxes can easily be displayed in Matlab GUI - this article explains how.<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/customizing-matlab-labels/' rel='bookmark' title='Customizing Matlab labels'>Customizing Matlab labels</a> <small>Matlab's text uicontrol is not very customizable, and does not support HTML or Tex formatting. This article shows how to display HTML labels in Matlab and some undocumented customizations...</small></li><li><a
href='http://undocumentedmatlab.com/blog/tab-panels-uitab-and-relatives/' rel='bookmark' title='Tab panels &#8211; uitab and relatives'>Tab panels &#8211; uitab and relatives</a> <small>This article describes several undocumented Matlab functions that support tab-panels...</small></li><li><a
href='http://undocumentedmatlab.com/blog/uitable-sorting/' rel='bookmark' title='Uitable sorting'>Uitable sorting</a> <small>Matlab's uitables can be sortable using simple undocumented features...</small></li><li><a
href='http://undocumentedmatlab.com/blog/rich-matlab-editbox-contents/' rel='bookmark' title='Rich Matlab editbox contents'>Rich Matlab editbox contents</a> <small>The Matlab editbox uicontrol does not handle HTML contents as do other uicontrols. In this article I show how this limitation can be removed....</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p>A few weeks ago, a reader of my article about <a
target="_blank" href="http://undocumentedmatlab.com/blog/rich-matlab-editbox-contents/#comment-10760">rich Matlab editbox contents</a> asked whether it is possible to display syntax-highlighted contents, i.e. contents whose color changes based on its underlying text, often called <i>syntax hilite</i> in affection. I gave a very specific answer in a reply comment, which I expand in today&#8217;s full-length article.<br
/></p><p>Matlab has two built-in Java classes that can present syntax-highlighted text: <b>SyntaxTextLabel</b> presents single-line labels, while <b>SyntaxTextPane</b> presents a multi-line editor pane. Both of these classes support C, HTML/XML, Java and Matlab syntax highlighting, as well as standard plaint-text. Some related <a
target="_blank" href="http://undocumentedmatlab.com/blog/tag/JIDE/">JIDE</a> classes are also described.</p><h3 id="SyntaxTextLabel">SyntaxTextLabel</h3><p>SyntaxTextLabel is used to display a syntax-highlighted single-line text label according to the specified programming language: C_STYLE, HTML_STYLE, JAVA_STYLE, PLAIN_STYLE and of course M_STYLE for Matlab code:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">str = <span style="color:#A020F0;">'for id=1:3, set(h(id),'</span><span style="color:#A020F0;">'string'</span><span style="color:#A020F0;">',num2str(id)); end  % Matlab code'</span>;
codeType = com.<span style="">mathworks</span>.<span style="">widgets</span>.<span style="">SyntaxTextLabel</span>.<span style="">M_STYLE</span>;
jCodeLabel = com.<span style="">mathworks</span>.<span style="">widgets</span>.<span style="">SyntaxTextLabel</span><span style="color: #080;">&#40;</span>str,codeType<span style="color: #080;">&#41;</span>
<span style="color: #080;">&#91;</span>jhLabel,hContainer<span style="color: #080;">&#93;</span> = javacomponent<span style="color: #080;">&#40;</span>jCodeLabel,<span style="color: #080;">&#91;</span><span style="color: #33f;">10</span>,<span style="color: #33f;">10</span>,<span style="color: #33f;">300</span>,<span style="color: #33f;">20</span><span style="color: #080;">&#93;</span>,<span style="color: #0000FF;">gcf</span><span style="color: #080;">&#41;</span>;</pre></div></div><p><center><div
class="wp-caption aligncenter" style="width: 330px"><img
alt="SyntaxTextLabels (different code styles)" src="http://UndocumentedMatlab.com/images/SyntaxTextLabel.png" title="SyntaxTextLabels (different code styles)" width="320" height="95" /><p
class="wp-caption-text">SyntaxTextLabels (different code styles)</p></div></center></p><h3 id="StyledLabel">StyledLabel</h3><p>More flexibility in the displayed label styles can be achieved with <a
target="_blank" href="http://undocumentedmatlab.com/blog/html-support-in-matlab-uicomponents/">HTML/CSS</a>, and the bundled JIDE class <a
target="_blank" rel="nofollow" href="http://www.jidesoft.com/javadoc/com/jidesoft/swing/StyledLabel.html">com.jidesoft.swing.StyledLabel</a> provides even more flexibility:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">import java.<span style="">awt</span>.*
import com.<span style="">jidesoft</span>.<span style="">swing</span>.*
str = <span style="color:#A020F0;">'Mixed Underlined Strikethrough Super and Subscript combo Styles'</span>;
com.<span style="">mathworks</span>.<span style="">mwswing</span>.<span style="">MJUtilities</span>.<span style="">initJIDE</span>;
jStyledLabel = StyledLabel<span style="color: #080;">&#40;</span>str<span style="color: #080;">&#41;</span>; 
styles = <span style="color: #080;">&#91;</span>StyleRange<span style="color: #080;">&#40;</span><span style="color: #33f;">0</span>,<span style="color: #33f;">5</span>,  Font.<span style="">BOLD</span>,   Color.<span style="">BLUE</span><span style="color: #080;">&#41;</span>, <span style="color: #F0F;">...</span>
          <span style="">StyleRange</span><span style="color: #080;">&#40;</span><span style="color: #33f;">6</span>,<span style="color: #33f;">10</span>, Font.<span style="">PLAIN</span>,StyleRange.<span style="">STYLE_UNDERLINED</span><span style="color: #080;">&#41;</span>,<span style="color: #F0F;">...</span>
          <span style="">StyleRange</span><span style="color: #080;">&#40;</span><span style="color: #33f;">17</span>,<span style="color: #33f;">13</span>,Font.<span style="">PLAIN</span>,  Color.<span style="">RED</span>,   <span style="color: #F0F;">...</span>
                           <span style="">StyleRange</span>.<span style="">STYLE_STRIKE_THROUGH</span><span style="color: #080;">&#41;</span>, <span style="color: #F0F;">...</span>
          <span style="">StyleRange</span><span style="color: #080;">&#40;</span><span style="color: #33f;">31</span>,<span style="color: #33f;">5</span>, Font.<span style="">PLAIN</span>,  Color.<span style="">BLUE</span>,  <span style="color: #F0F;">...</span>
                           <span style="">StyleRange</span>.<span style="">STYLE_SUPERSCRIPT</span><span style="color: #080;">&#41;</span>, <span style="color: #F0F;">...</span>
          <span style="">StyleRange</span><span style="color: #080;">&#40;</span><span style="color: #33f;">37</span>,<span style="color: #33f;">3</span>, Font.<span style="">ITALIC</span>, Color.<span style="">BLACK</span><span style="color: #080;">&#41;</span>, <span style="color: #F0F;">...</span>
          <span style="">StyleRange</span><span style="color: #080;">&#40;</span><span style="color: #33f;">41</span>,<span style="color: #33f;">9</span>, Font.<span style="">PLAIN</span>,  Color.<span style="">BLUE</span>,  <span style="color: #F0F;">...</span>
                           <span style="">StyleRange</span>.<span style="">STYLE_SUBSCRIPT</span><span style="color: #080;">&#41;</span>, <span style="color: #F0F;">...</span>
          <span style="">StyleRange</span><span style="color: #080;">&#40;</span><span style="color: #33f;">51</span>,<span style="color: #33f;">5</span>, Font.<span style="">PLAIN</span>,  StyleRange.<span style="">STYLE_WAVED</span> + <span style="color: #F0F;">...</span>
                           <span style="">StyleRange</span>.<span style="">STYLE_STRIKE_THROUGH</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#93;</span>;
jStyledLabel.<span style="">setStyleRanges</span><span style="color: #080;">&#40;</span>styles<span style="color: #080;">&#41;</span>;
<span style="color: #080;">&#91;</span>jhLabel,hContainer<span style="color: #080;">&#93;</span> = javacomponent<span style="color: #080;">&#40;</span>jStyledLabel,<span style="color: #080;">&#91;</span><span style="color: #33f;">10</span>,<span style="color: #33f;">10</span>,<span style="color: #33f;">300</span>,<span style="color: #33f;">20</span><span style="color: #080;">&#93;</span>,<span style="color: #0000FF;">gcf</span><span style="color: #080;">&#41;</span>;</pre></div></div><p><center><div
class="wp-caption aligncenter" style="width: 310px"><img
alt="JIDE StyledLabel (different font styles)" src="http://UndocumentedMatlab.com/images/StyledLabel.png" title="JIDE StyledLabel (different font styles)" width="300" height="20" /><p
class="wp-caption-text">JIDE StyledLabel (different font styles)</p></div></center></p><p>StyledLabels have subclasses that can be used to present styled text in tables, trees or lists. JIDE also provides the convenient <a
target="_blank" rel="nofollow" href="http://www.jidesoft.com/javadoc/com/jidesoft/swing/StyledLabelBuilder.html">StyledLabelBuilder</a>,  which enables easy multi-style text construction.</p><p>Finally, JIDE provides the <a
target="_blank" rel="nofollow" href="http://www.jidesoft.com/javadoc/com/jidesoft/swing/ClickThroughStyledLabel.html">ClickThroughStyledLabel</a>, a StyledLabel extension that allows setting a target component, so that mouse clicks on the label will actually trigger the target component. This can be useful in forms where components have adjacent descriptive labels.</p><h3 id="SyntaxTextPane">SyntaxTextPane</h3><p>Multi-line syntax-highlighted code can be displayed with Matlab&#8217;s SyntaxTextPane class. SyntaxTextPane uses <a
target="_blank" rel="nofollow" href="http://en.wikipedia.org/wiki/MIME">MIME</a> types rather than styles for syntax-highlighting, but the end-result appears similar:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">jCodePane = com.<span style="">mathworks</span>.<span style="">widgets</span>.<span style="">SyntaxTextPane</span>;
codeType = jCodePane.<span style="">M_MIME_TYPE</span>;  <span style="color: #228B22;">% ='text/m-MATLAB'</span>
jCodePane.<span style="">setContentType</span><span style="color: #080;">&#40;</span>codeType<span style="color: #080;">&#41;</span>
str = <span style="color: #080;">&#91;</span><span style="color:#A020F0;">'% create a file for output\n'</span> <span style="color: #F0F;">...</span>
       <span style="color:#A020F0;">'!touch testFile.txt\n'</span> <span style="color: #F0F;">...</span>
       <span style="color:#A020F0;">'fid = fopen('</span><span style="color:#A020F0;">'testFile.txt'</span><span style="color:#A020F0;">', '</span><span style="color:#A020F0;">'w'</span><span style="color:#A020F0;">');\n'</span> <span style="color: #F0F;">...</span>
       <span style="color:#A020F0;">'for i=1:10\n'</span> <span style="color: #F0F;">...</span>
       <span style="color:#A020F0;">'    % Unterminated string:\n'</span> <span style="color: #F0F;">...</span>
       <span style="color:#A020F0;">'    fprintf(fid,'</span><span style="color:#A020F0;">'%6.2f \\n, i);\n'</span> <span style="color: #F0F;">...</span>
       <span style="color:#A020F0;">'end'</span><span style="color: #080;">&#93;</span>;
str = <span style="color: #0000FF;">sprintf</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">strrep</span><span style="color: #080;">&#40;</span>str,<span style="color:#A020F0;">'%'</span>,<span style="color:#A020F0;">'%%'</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
jCodePane.<span style="">setText</span><span style="color: #080;">&#40;</span>str<span style="color: #080;">&#41;</span>
jScrollPane = com.<span style="">mathworks</span>.<span style="">mwswing</span>.<span style="">MJScrollPane</span><span style="color: #080;">&#40;</span>jCodePane<span style="color: #080;">&#41;</span>;
<span style="color: #080;">&#91;</span>jhPanel,hContainer<span style="color: #080;">&#93;</span> = javacomponent<span style="color: #080;">&#40;</span>jScrollPane,<span style="color: #080;">&#91;</span><span style="color: #33f;">10</span>,<span style="color: #33f;">10</span>,<span style="color: #33f;">300</span>,<span style="color: #33f;">100</span><span style="color: #080;">&#93;</span>,<span style="color: #0000FF;">gcf</span><span style="color: #080;">&#41;</span>;</pre></div></div><p><center><div
class="wp-caption aligncenter" style="width: 340px"><img
alt="SyntaxTextPane panel (Matlab MIME type)" src="http://UndocumentedMatlab.com/images/SyntaxTextPane.png" title="SyntaxTextPane panel (Matlab MIME type)" width="330" height="202" /><p
class="wp-caption-text">SyntaxTextPane panel (Matlab MIME type)</p></div></center></p><p>The nice thing about SyntaxTextPane is that it syntax-highlights on-the-fly as you type or edit in the SyntaxTextPane (assuming you have not disabled editing with the <em>setEditable</em>(flag) method). This is exactly the behavior we have come to expect in the full-blown Matlab editor, and can now be embedded as a simple panel within our GUI.</p><p>Despite its misleadingly-simple look, SyntaxTextPane actually has most capabilities of the full-blown editor, not just syntax highlighting. This includes multiple undo/redo actions; smart indentation/commenting; automatic indication of corresponding block elements (if-end, for-end, etc. – also known as delimiter matching); search/replace, drag-and-drop and cut-copy-paste support; and many more.</p><p>Interested readers can use the <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/17935-uiinspect-display-methodspropertiescallbacks-of-an-object"><i><b>uiinspect</b></i></a> and <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/26947-checkclass"><i><b>checkClass</b></i></a> utilities to explore the full capabilities offered by SyntaxTextPane. In this respect it would be helpful to also look at its super-class (SyntaxTextPaneBase) and the related SyntaxTextPaneUtilities class.</p><h3 id="Summary">Summary</h3><p>These Java classes are examples of built-in classes that can be used in Matlab applications, enabling a much richer GUI experience than possible using the standard (documented/supported) Matlab widgets.</p><p>As I have shown above, using these classes is extremely easy, and requires absolutely no Java knowledge. On the flip side, these internal Matlab classes may easily break in any future Matlab release, so be extra careful when deciding to use them. Future articles in this website will describe other similarly-useful built-in classes.</p><p>Have you found any other useful built-in Matlab class? If so, please <a
href="#respond">post a comment</a>.</p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/customizing-matlab-labels/' rel='bookmark' title='Customizing Matlab labels'>Customizing Matlab labels</a> <small>Matlab's text uicontrol is not very customizable, and does not support HTML or Tex formatting. This article shows how to display HTML labels in Matlab and some undocumented customizations...</small></li><li><a
href='http://undocumentedmatlab.com/blog/tab-panels-uitab-and-relatives/' rel='bookmark' title='Tab panels &#8211; uitab and relatives'>Tab panels &#8211; uitab and relatives</a> <small>This article describes several undocumented Matlab functions that support tab-panels...</small></li><li><a
href='http://undocumentedmatlab.com/blog/uitable-sorting/' rel='bookmark' title='Uitable sorting'>Uitable sorting</a> <small>Matlab's uitables can be sortable using simple undocumented features...</small></li><li><a
href='http://undocumentedmatlab.com/blog/rich-matlab-editbox-contents/' rel='bookmark' title='Rich Matlab editbox contents'>Rich Matlab editbox contents</a> <small>The Matlab editbox uicontrol does not handle HTML contents as do other uicontrols. In this article I show how this limitation can be removed....</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/syntax-highlighted-labels-panels/feed/</wfw:commentRss> <slash:comments>6</slash:comments> </item> <item><title>Modifying Matlab&#8217;s Look-and-Feel</title><link>http://undocumentedmatlab.com/blog/modifying-matlab-look-and-feel/</link> <comments>http://undocumentedmatlab.com/blog/modifying-matlab-look-and-feel/#comments</comments> <pubDate>Wed, 07 Jul 2010 16:42:00 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[Desktop]]></category> <category><![CDATA[GUI]]></category> <category><![CDATA[Low risk of breaking in future versions]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[JIDE]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=1721</guid> <description><![CDATA[Matlab's entire Look-and-Feel (PLAF, or L&#038;F) can be modified at the control or application level - this article shows how<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/modifying-default-toolbar-menubar-actions/' rel='bookmark' title='Modifying default toolbar/menubar actions'>Modifying default toolbar/menubar actions</a> <small>The default Matlab figure toolbar and menu actions can easily be modified using simple pure-Matlab code. This article explains how....</small></li><li><a
href='http://undocumentedmatlab.com/blog/setting-line-position-in-edit-box-uicontrol/' rel='bookmark' title='Setting line position in an edit-box uicontrol'>Setting line position in an edit-box uicontrol</a> <small>Matlab uicontrols have many useful features that are only available via Java. Here's how to access them....</small></li><li><a
href='http://undocumentedmatlab.com/blog/setting-system-tray-icons/' rel='bookmark' title='Setting system tray icons'>Setting system tray icons</a> <small>System-tray icons can be programmatically set and controlled from within Matlab, using new functionality available since R2007b....</small></li><li><a
href='http://undocumentedmatlab.com/blog/setting-status-bar-text/' rel='bookmark' title='Setting status-bar text'>Setting status-bar text</a> <small>The Matlab desktop and figure windows have a usable statusbar which can only be set using undocumented methods. This post shows how to set the status-bar text....</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p>A couple of days ago, a reader of this blog <a
target="_blank" href="http://undocumentedmatlab.com/blog/changing-matlab-command-window-colors/#comment-12043">posted a comment</a>, asking whether it is possible to change Matlab&#8217;s Desktop color scheme, and its general UI look. Instead of providing a short answer, I will use the opportunity to answer in a full article. So this is for you, Egon <img
src='http://undocumentedmatlab.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /></p><h3 id="PLAF">Matlab&#8217;s underlying Look-and-Feel</h3><p>One of Matlab&#8217;s great advantages is cross-platform compatibility. Generally speaking, Matlab applications written on Windows will work as-is on Macintosh and Linux.</p><p>Java has similar cross-platform compatibilities, but enables much greater control over the <em>look-and-feel</em> (L&#038;F or <em><a
target="_blank" rel="nofollow" href="http://java.sun.com/docs/books/tutorial/uiswing/lookandfeel/plaf.html">PLAF</a></em>) of application GUI. In a nutshell, L&#038;Fs affect the appearance and behavior of menus, controls, color schemes etc., using a <a
target="_blank" rel="nofollow" href="http://java.sun.com/products/jfc/tsc/articles/architecture/#pluggable">properties plug-in architecture</a>. Java programmers can choose to use either a platform-independent L&#038;F (called the <em>Metal L&#038;F</em>), or a platform-specific L&#038;F. The benefit of using Metal is that the application looks essentially the same on all Java-supported platforms; the drawback is that they do not look like native applications on any platform&#8230;</p><p><center><div
class="wp-caption aligncenter" style="width: 380px"><img
alt="Metal L&#038;F" src="http://UndocumentedMatlab.com/images/plaf_metal2.png" title="Metal L&#038;F" width="122" height="42" /> &nbsp; <img
alt="Motif L&#038;F" src="http://UndocumentedMatlab.com/images/plaf_motif2.png" title="Motif L&#038;F" width="100" height="48" /> &nbsp; <img
alt="Windows L&#038;F" src="http://UndocumentedMatlab.com/images/plaf_windows2.png" title="Windows L&#038;F" width="101" height="44" /><p
class="wp-caption-text">Metal, Motif &#038; Windows L&#038;F</p></div></center></p><p>Matlab, whose GUI is based on Java (not surprising to readers of this website), has chosen to use a platform-specific L&#038;F on each of the platforms on which it is supported. So, Matlab on Windows looks like a native Windows application, whereas on Macs it looks similar to Mac apps (notwithstanding the well-known <a
target="_blank" rel="nofollow" href="http://blogs.mathworks.com/desktop/2009/08/31/pouncing-on-snow-leopard/">X11 migration issues</a>). Of course, this means that Windows Matlab looks and behaves differently from Mac/Linux Matlabs. Note that the differences only affect the Desktop, tools/utilities (Editor etc.) and the general L&#038;F &#8211; it does not affect the displayed plots. In practice, the differences are visible but easily understandable.</p><h3 id="Change_PLAF">Changing the L&#038;F</h3><p>We can get the list of available L&#038;Fs on our system as follows (below is the list on my Windows system):</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">&gt;&gt; lafs = javax.<span style="">swing</span>.<span style="">UIManager</span>.<span style="">getInstalledLookAndFeels</span>
lafs =
javax.<span style="">swing</span>.<span style="">UIManager</span>$LookAndFeelInfo<span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span><span style="color: #F0F;">:</span>
    <span style="color: #080;">&#91;</span>javax.<span style="">swing</span>.<span style="">UIManager</span>$LookAndFeelInfo<span style="color: #080;">&#93;</span>
    <span style="color: #080;">&#91;</span>javax.<span style="">swing</span>.<span style="">UIManager</span>$LookAndFeelInfo<span style="color: #080;">&#93;</span>
    <span style="color: #080;">&#91;</span>javax.<span style="">swing</span>.<span style="">UIManager</span>$LookAndFeelInfo<span style="color: #080;">&#93;</span>
    <span style="color: #080;">&#91;</span>javax.<span style="">swing</span>.<span style="">UIManager</span>$LookAndFeelInfo<span style="color: #080;">&#93;</span>
    <span style="color: #080;">&#91;</span>javax.<span style="">swing</span>.<span style="">UIManager</span>$LookAndFeelInfo<span style="color: #080;">&#93;</span>
&nbsp;
&gt;&gt; <span style="color: #0000FF;">for</span> lafIdx = <span style="color: #33f;">1</span><span style="color: #F0F;">:</span><span style="color: #0000FF;">length</span><span style="color: #080;">&#40;</span>lafs<span style="color: #080;">&#41;</span>,  <span style="color: #0000FF;">disp</span><span style="color: #080;">&#40;</span>lafs<span style="color: #080;">&#40;</span>lafIdx<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;  <span style="color: #0000FF;">end</span>
javax.<span style="">swing</span>.<span style="">UIManager</span>$LookAndFeelInfo<span style="color: #080;">&#91;</span>Metal javax.<span style="">swing</span>.<span style="">plaf</span>.<span style="">metal</span>.<span style="">MetalLookAndFeel</span><span style="color: #080;">&#93;</span>
javax.<span style="">swing</span>.<span style="">UIManager</span>$LookAndFeelInfo<span style="color: #080;">&#91;</span>Nimbus com.<span style="">sun</span>.<span style="">java</span>.<span style="">swing</span>.<span style="">plaf</span>.<span style="">nimbus</span>.<span style="">NimbusLookAndFeel</span><span style="color: #080;">&#93;</span>
javax.<span style="">swing</span>.<span style="">UIManager</span>$LookAndFeelInfo<span style="color: #080;">&#91;</span>CDE/Motif com.<span style="">sun</span>.<span style="">java</span>.<span style="">swing</span>.<span style="">plaf</span>.<span style="">motif</span>.<span style="">MotifLookAndFeel</span><span style="color: #080;">&#93;</span>
javax.<span style="">swing</span>.<span style="">UIManager</span>$LookAndFeelInfo<span style="color: #080;">&#91;</span>Windows com.<span style="">sun</span>.<span style="">java</span>.<span style="">swing</span>.<span style="">plaf</span>.<span style="">windows</span>.<span style="">WindowsLookAndFeel</span><span style="color: #080;">&#93;</span>
javax.<span style="">swing</span>.<span style="">UIManager</span>$LookAndFeelInfo<span style="color: #080;">&#91;</span>Windows Classic com.<span style="">sun</span>.<span style="">java</span>.<span style="">swing</span>.<span style="">plaf</span>.<span style="">windows</span>.<span style="">WindowsClassicLookAndFeel</span><span style="color: #080;">&#93;</span></pre></div></div><p>We can change the L&#038;F to any of the installed L&#038;Fs, as follows:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">javax.<span style="">swing</span>.<span style="">UIManager</span>.<span style="">setLookAndFeel</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'javax.swing.plaf.metal.MetalLookAndFeel'</span><span style="color: #080;">&#41;</span>;</pre></div></div><p>Although not listed in the installed L&#038;Fs, Matlab also enables access to a 3rd-party L&#038;F called <a
target="_blank" rel="nofollow" href="http://www.jgoodies.com/freeware/looks/index.html">Plastic3D</a> by <a
target="_blank" rel="nofollow" href="http://www.jgoodies.com">www.jgoodies.com</a>. Plastic3D L&#038;F generates slick stylish GUI:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">javax.<span style="">swing</span>.<span style="">UIManager</span>.<span style="">setLookAndFeel</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'com.jgoodies.looks.plastic.Plastic3DLookAndFeel'</span><span style="color: #080;">&#41;</span></pre></div></div><p><center><div
class="wp-caption aligncenter" style="width: 116px"><img
alt="Plastic3D L&#038;F" src="http://UndocumentedMatlab.com/images/plaf_plastic2.png" title="Plastic3D L&#038;F" width="106" height="44" /><p
class="wp-caption-text">Plastic3D L&#038;F</p></div></center></p><p>The <a
target="_blank" href="http://UndocumentedMatlab.com/blog/tag/jide/">JIDE class library</a> by <a
target="_blank" rel="nofollow" href="http://www.jidesoft.com">www.jidesoft.com</a>, which is bundled with Matlab, and specifically its jide-common.jar file, contains a separate set of 3rd-party L&#038;Fs: Aqua, Eclipse (Metal &#038; Windows variants), Office2003, VSNet (Metal &#038; Windows variants) and Xerto. Unfortunately, in Matlab releases starting around 2009, JIDE stopped including full L&#038;F classes in jide-common.jar, and started using L&#038;F extensions using their <a
target="_blank" rel="nofollow" href="http://www.jidesoft.com/javadoc/com/jidesoft/plaf/LookAndFeelFactory.html">com.jidesoft.plaf.LookAndFeelFactory</a> class. I have not been able to use this class properly, but readers are welcome to try (please tell me if you succeed).</p><p>External L&#038;Fs can also be downloaded and then used in Matlab. For example: <a
target="_blank" rel="nofollow" href="http://lookandfeel.incors.com/">Alloy</a>, <a
target="_blank" rel="nofollow" href="http://www.javasoft.de/synthetica/">Synthetica</a> and many others.</p><p>The current and standard L&#038;Fs can be retrieved by using the respective static methods javax.swing.UIManager.<em>getLookAndFeel()</em> and <em>getSystemLookAndFeelClassName()</em>.</p><p>Matlab also has a utility class com.mathworks.mwswing.plaf.PlafUtils that contains static methods that query the current L&#038;F: <em>isPlasticLookAndFeel(), isAquaLookAndFeel(),  isMetalLookAndFeel(), isMotifLookAndFeel()</em> and <em>isWindowsLookAndFeel()</em>. For some reason there is no method for the new (R2010a+) <a
target="_blank" rel="nofollow" href="http://java.sun.com/docs/books/tutorial/uiswing/lookandfeel/nimbus.html">Nimbus L&#038;F</a>.</p><p>Nimbus L&#038;F offers great potential for a cross-platform vectorized appearance, the ability to customize/skin pretty much every aspect of the visual appearance and component behavior, replacing Swing&#8217;s <a
target="_blank" rel="nofollow" href="http://java.sun.com/docs/books/tutorial/uiswing/lookandfeel/synth.html">Synth L&#038;F</a> which was used for such customizations in earlier Matlab/Java releases. Nimbus is pre-installed as a non-default L&#038;F in Matlab R2010a (7.10) onward, because it seems that most designers who target a single platform still <a
target="_blank" rel="nofollow" href="http://www.jasperpotts.com/blog/2009/03/breakdown-of-what-should-be-default-laf-for-java-7/">prefer the native L&#038;F</a>.</p><h3 id="Component_PLAF">Component-specific L&#038;F</h3><p>You can also modify the L&#038;F of specific components, not just the entire Matlab. To do this, simply modify the L&#038;F immediately before creating your GUI component, and restore the original L&#038;F afterward (note how you can use either the L&#038;F class name or its class reference):</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% Update the current L&amp;F</span>
originalLnF = javax.<span style="">swing</span>.<span style="">UIManager</span>.<span style="">getLookAndFeel</span>;  <span style="color: #228B22;">%class</span>
newLnF = <span style="color:#A020F0;">'javax.swing.plaf.metal.MetalLookAndFeel'</span>;  <span style="color: #228B22;">%string</span>
javax.<span style="">swing</span>.<span style="">UIManager</span>.<span style="">setLookAndFeel</span><span style="color: #080;">&#40;</span>newLnF<span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% Create GUI using the modified L&amp;F</span>
hFig = <span style="color: #0000FF;">figure</span><span style="color: #080;">&#40;</span><span style="color: #F0F;">...</span><span style="color: #080;">&#41;</span>;
hComponent = <span style="color: #0000FF;">uicontrol</span><span style="color: #080;">&#40;</span><span style="color: #F0F;">...</span><span style="color: #080;">&#41;</span>;
jComponent = javacomponent<span style="color: #080;">&#40;</span><span style="color: #F0F;">...</span><span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% Restore the original L&amp;F</span>
javax.<span style="">swing</span>.<span style="">UIManager</span>.<span style="">setLookAndFeel</span><span style="color: #080;">&#40;</span>originalLnF<span style="color: #080;">&#41;</span>;</pre></div></div><p>Components can update their L&#038;F to the current L&#038;F using their jComponent.<em>updateUI()</em> method. Components that are not specifically updated by invoking their <em>updateUI()</em> method will retain their existing (original) L&#038;F – the L&#038;F which was active when the components were created or last updated.</p><h3 id="Properties">Fine-grained L&#038;F property control</h3><p>The default settings for the L&#038;F can be retrieved using the static method javax.swing.UIManager.<em>getDefaults()</em>, which returns an enumeration of the thousand or so default settings:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">&gt;&gt; defaults = javax.<span style="">swing</span>.<span style="">UIManager</span>.<span style="">getDefaults</span>;
&gt;&gt; propValues = defaults.<span style="">elements</span>; propKeys = defaults.<span style="">keys</span>;
&gt;&gt; <span style="color: #0000FF;">while</span> propKeys.<span style="">hasMoreElements</span>
     key = propKeys.<span style="">nextElement</span>;
     value = propValues.<span style="">nextElement</span>;
     <span style="color: #0000FF;">disp</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#91;</span><span style="color: #0000FF;">char</span><span style="color: #080;">&#40;</span>key<span style="color: #080;">&#41;</span> <span style="color:#A020F0;">' = '</span> <span style="color: #0000FF;">evalc</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'disp(value)'</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>;
   <span style="color: #0000FF;">end</span>
&nbsp;
com.<span style="">sun</span>.<span style="">java</span>.<span style="">swing</span>.<span style="">plaf</span>.<span style="">windows</span>.<span style="">WindowsLabelUI</span> = <span style="color: #0000FF;">class</span> com.<span style="">sun</span>.<span style="">java</span>.<span style="">swing</span>.<span style="">plaf</span>.<span style="">windows</span>.<span style="">WindowsLabelUI</span>
<span style="color: #F0F;">...</span> <span style="color: #080;">&#40;</span>~<span style="color: #33f;">1000</span> other property settings<span style="color: #080;">&#41;</span>
SplitPane.<span style="">dividerSize</span> =      <span style="color: #33f;">5</span>
DockableFrameTitlePane.<span style="">stopAutohideIcon</span> = javax.<span style="">swing</span>.<span style="">ImageIcon</span>@1f4e4c0
FormattedTextField.<span style="">caretBlinkRate</span> =    <span style="color: #33f;">500</span>
Table.<span style="">gridColor</span> = javax.<span style="">swing</span>.<span style="">plaf</span>.<span style="">ColorUIResource</span><span style="color: #080;">&#91;</span>r=<span style="color: #33f;">128</span>,g=<span style="color: #33f;">128</span>,b=<span style="color: #33f;">128</span><span style="color: #080;">&#93;</span></pre></div></div><p>Specific settings can be modified by using javax.swing.UIManager.<em>put(key,newValue)</em>.</p><p>Have you found any useful L&#038;F or property that you are using in your application? If so, please share them in the <a
href="#respond">comments</a> section below.</p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/modifying-default-toolbar-menubar-actions/' rel='bookmark' title='Modifying default toolbar/menubar actions'>Modifying default toolbar/menubar actions</a> <small>The default Matlab figure toolbar and menu actions can easily be modified using simple pure-Matlab code. This article explains how....</small></li><li><a
href='http://undocumentedmatlab.com/blog/setting-line-position-in-edit-box-uicontrol/' rel='bookmark' title='Setting line position in an edit-box uicontrol'>Setting line position in an edit-box uicontrol</a> <small>Matlab uicontrols have many useful features that are only available via Java. Here's how to access them....</small></li><li><a
href='http://undocumentedmatlab.com/blog/setting-system-tray-icons/' rel='bookmark' title='Setting system tray icons'>Setting system tray icons</a> <small>System-tray icons can be programmatically set and controlled from within Matlab, using new functionality available since R2007b....</small></li><li><a
href='http://undocumentedmatlab.com/blog/setting-status-bar-text/' rel='bookmark' title='Setting status-bar text'>Setting status-bar text</a> <small>The Matlab desktop and figure windows have a usable statusbar which can only be set using undocumented methods. This post shows how to set the status-bar text....</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/modifying-matlab-look-and-feel/feed/</wfw:commentRss> <slash:comments>37</slash:comments> </item> <item><title>Date selection components</title><link>http://undocumentedmatlab.com/blog/date-selection-components/</link> <comments>http://undocumentedmatlab.com/blog/date-selection-components/#comments</comments> <pubDate>Wed, 30 Jun 2010 06:43:53 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[GUI]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[Medium risk of breaking in future versions]]></category> <category><![CDATA[Undocumented feature]]></category> <category><![CDATA[Handle graphics]]></category> <category><![CDATA[Internal component]]></category> <category><![CDATA[JIDE]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=1684</guid> <description><![CDATA[The JIDE package, pre-bundled in Matlab, contains several GUI controls for selecting dates - this article explains how they can be used<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/color-selection-components/' rel='bookmark' title='Color selection components'>Color selection components</a> <small>Matlab has several internal color-selection components that can easily be integrated in Matlab GUI...</small></li><li><a
href='http://undocumentedmatlab.com/blog/plot-type-selection-components/' rel='bookmark' title='Plot-type selection components'>Plot-type selection components</a> <small>Several built-in components enable programmatic plot-type selection in Matlab GUI - this article explains how...</small></li><li><a
href='http://undocumentedmatlab.com/blog/setting-status-bar-components/' rel='bookmark' title='Setting status-bar components'>Setting status-bar components</a> <small>Matlab status-bars are Java containers in which we can add GUI controls such as progress-bars, not just simple text labels...</small></li><li><a
href='http://undocumentedmatlab.com/blog/figure-toolbar-components/' rel='bookmark' title='Figure toolbar components'>Figure toolbar components</a> <small>Matlab's toolbars can be customized using a combination of undocumented Matlab and Java hacks. This article describes how to access existing toolbar icons and how to add non-button toolbar components....</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p>Have you ever wondered why Matlab does not have standard GUI date-handling components?</p><p>Matlab has many built-in date-handling functions (<i><b>calendar, date, datestr, datenum, datetick, datevec</b></i> etc.). Unfortunately, this built-in support does not extend to Matlab GUI. If we need a date-selection drop-down or calendar panel we have to design it ourselves, or use a third-party Java component or ActiveX control.</p><h3 id="JIDE">JIDE Components</h3><p>Luckily, we have a much better alternative, right within Matlab. This relies on the undocumented fact that Matlab uses <a
target="_blank" rel="nofollow" href="http://www.jidesoft.com">JIDE components</a> for many of its GUI components. As already explained <a
target="_blank" href="http://undocumentedmatlab.com/blog/jide-property-grids/">earlier</a>, JIDE controls are pre-bundled in Matlab (/java/jarext/jide/jide-grids.jar under the Matlab root). You can find further details on JIDE Grids in the <a
target="_blank" rel="nofollow" href="http://www.jidesoft.com/products/JIDE_Grids_Developer_Guide.pdf">Developer Guide</a> (pages 28-35) and the <a
target="_blank" rel="nofollow" href="http://www.jidesoft.com/javadoc/">Javadoc documentation</a>.</p><p>In particular, JIDE Grids includes the following date-selection controls:</p><ul><li><a
target="_blank" rel="nofollow" href="http://www.jidesoft.com/javadoc/com/jidesoft/combobox/DateChooserPanel.html">DateChooserPanel</a> &#8211; an extension of Swing&#8217;s JPanel that displays a single month and enables selecting one or more days</li><li><a
target="_blank" rel="nofollow" href="http://www.jidesoft.com/javadoc/com/jidesoft/combobox/CalendarViewer.html">CalendarViewer</a> &#8211; a similar panel, that displays several months in a table-format (e.g., 4&#215;3 months)</li><li><a
target="_blank" rel="nofollow" href="http://www.jidesoft.com/javadoc/com/jidesoft/combobox/DateComboBox.html">DateComboBox</a> &#8211; a combo-box (drop-down/popup menu) that presents a DateChooserPanel for selecting a date</li><li><a
target="_blank" rel="nofollow" href="http://www.jidesoft.com/javadoc/com/jidesoft/combobox/DateSpinnerComboBox.html">DateSpinnerComboBox</a> &#8211; presents a date-selection combo-box that includes both the DateComboBox and a spinner control (this control is only available in the latest Matlab releases)</li><li><a
target="_blank" rel="nofollow" href="http://www.jidesoft.com/javadoc/com/jidesoft/combobox/MonthChooserPanel.html">MonthChooserPanel</a> &#8211; a panel that enables selection of entire months (not specific dates)</li><li><a
target="_blank" rel="nofollow" href="http://www.jidesoft.com/javadoc/com/jidesoft/combobox/MonthComboBox.html">MonthComboBox</a> &#8211; a month selection combo-box, similar to DateComboBox but without the ability to select individual days</li></ul><p>Usage of these controls is very similar, so I&#8217;ll just show the basics here. First, to present any control, we need to use the built-in <i><b>javacomponent</b></i> function or the <i><b><a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/14583-uicomponent-expands-uicontrol-to-all-java-classes">uicomponent</a></b></i> utility:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% Initialize JIDE's usage within Matlab</span>
com.<span style="">mathworks</span>.<span style="">mwswing</span>.<span style="">MJUtilities</span>.<span style="">initJIDE</span>;
&nbsp;
<span style="color: #228B22;">% Display a DateChooserPanel</span>
jPanel = com.<span style="">jidesoft</span>.<span style="">combobox</span>.<span style="">DateChooserPanel</span>;
<span style="color: #080;">&#91;</span>hPanel,hContainer<span style="color: #080;">&#93;</span> = javacomponent<span style="color: #080;">&#40;</span>jPanel,<span style="color: #080;">&#91;</span><span style="color: #33f;">10</span>,<span style="color: #33f;">10</span>,<span style="color: #33f;">200</span>,<span style="color: #33f;">200</span><span style="color: #080;">&#93;</span>,<span style="color: #0000FF;">gcf</span><span style="color: #080;">&#41;</span></pre></div></div><p><center><br
/><div
class="wp-caption aligncenter" style="width: 420px"><img
alt="DateChooserPanel" src="http://UndocumentedMatlab.com/images/JIDE_DateChooserPanel.png" title="DateChooserPanel" width="200" height="200" /> &nbsp; <img
alt="MonthChooserPanel" src="http://UndocumentedMatlab.com/images/JIDE_MonthChooserPanel.png" title="MonthChooserPanel" width="200" height="200" /><p
class="wp-caption-text">DateChooserPanel and MonthChooserPanel components</p></div></p><p><div
class="wp-caption aligncenter" style="width: 410px"><img
alt="CalendarViewer" src="http://UndocumentedMatlab.com/images/JIDE_CalendarViewer.png" title="CalendarViewer" width="400" height="300" /><p
class="wp-caption-text">2x2 CalendarViewer component</p></div><br
/></center></p><p>Just as with any Java object, properties may either be accessed with the Java accessor methods (e.g. <em>getName()</em> or <em>setName(name)</em>), or the Matlab get/set semantics (e.g. <i><b>get</b></i>(prop,&#8217;Name&#8217;)  or <i><b>set</b></i>(prop,&#8217;Name&#8217;,value)). When using the Matlab syntax, remember to wrap the Java object in a <i><b>handle</b></i>() call, to prevent a memory leak (or use hPanel rather than jPanel):</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">jPanel.<span style="">setShowWeekNumbers</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">false</span><span style="color: #080;">&#41;</span>;    <span style="color: #228B22;">% Java syntax</span>
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>hPanel,<span style="color:#A020F0;">'ShowTodayButton'</span>,<span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">% Matlab syntax</span></pre></div></div><p>Retrieving the selected date is easy:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">&gt;&gt; selectedDate = jPanel.<span style="">getSelectedDate</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>
selectedDate =
Sun Jun <span style="color: #33f;">27</span> 00<span style="color: #F0F;">:</span>00<span style="color: #F0F;">:</span>00 IDT <span style="color: #33f;">2010</span>
<span style="color: #228B22;">% or: selectedDate = get(jPanel,'SelectedDate');</span>
&nbsp;
<span style="color: #228B22;">% Note: selectedDate is a java.util.Date object:</span>
&gt;&gt; selectedDate.<span style="color: #0000FF;">get</span>
	<span style="color: #0000FF;">Class</span> = <span style="color: #080;">&#91;</span> <span style="color: #080;">&#40;</span><span style="color: #33f;">1</span> by <span style="color: #33f;">1</span><span style="color: #080;">&#41;</span> java.<span style="">lang</span>.<span style="color: #0000FF;">Class</span> array<span style="color: #080;">&#93;</span>
	<span style="color: #0000FF;">Date</span> = <span style="color: #080;">&#91;</span><span style="color: #33f;">27</span><span style="color: #080;">&#93;</span>
	Day = <span style="color: #080;">&#91;</span><span style="color: #33f;">0</span><span style="color: #080;">&#93;</span>
	Hours = <span style="color: #080;">&#91;</span><span style="color: #33f;">0</span><span style="color: #080;">&#93;</span>
	Minutes = <span style="color: #080;">&#91;</span><span style="color: #33f;">0</span><span style="color: #080;">&#93;</span>
	Month = <span style="color: #080;">&#91;</span><span style="color: #33f;">5</span><span style="color: #080;">&#93;</span>
	Seconds = <span style="color: #080;">&#91;</span><span style="color: #33f;">0</span><span style="color: #080;">&#93;</span>
	Time = <span style="color: #080;">&#91;</span>1.27759e+012<span style="color: #080;">&#93;</span>
	TimezoneOffset = <span style="color: #080;">&#91;</span>-<span style="color: #33f;">180</span><span style="color: #080;">&#93;</span>
	Year = <span style="color: #080;">&#91;</span><span style="color: #33f;">110</span><span style="color: #080;">&#93;</span></pre></div></div><p>We can enable selection of multiple dates (SINGLE_SELECTION=0, SINGLE_INTERVAL_SELECTION=1,MULTIPLE_INTERVAL_SELECTION=2):</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">jModel = hPanel.<span style="">getSelectionModel</span>;  <span style="color: #228B22;">% a com.jidesoft.combobox.DefaultDateSelectionModel object</span>
jModel.<span style="">setSelectionMode</span><span style="color: #080;">&#40;</span>jModel.<span style="">MULTIPLE_INTERVAL_SELECTION</span><span style="color: #080;">&#41;</span>;
&nbsp;
&gt;&gt; hPanel.<span style="">getSelectionModel</span>.<span style="">getSelectedDates</span>
<span style="color: #0000FF;">ans</span> =
java.<span style="">util</span>.<span style="color: #0000FF;">Date</span><span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span><span style="color: #F0F;">:</span>
    <span style="color: #080;">&#91;</span>java.<span style="">util</span>.<span style="color: #0000FF;">Date</span><span style="color: #080;">&#93;</span>
    <span style="color: #080;">&#91;</span>java.<span style="">util</span>.<span style="color: #0000FF;">Date</span><span style="color: #080;">&#93;</span>
    <span style="color: #080;">&#91;</span>java.<span style="">util</span>.<span style="color: #0000FF;">Date</span><span style="color: #080;">&#93;</span></pre></div></div><p>And of course we can set a callback for whenever the user modifies the selected date(s):</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">hModel = handle<span style="color: #080;">&#40;</span>hPanel.<span style="">getSelectionModel</span>, <span style="color:#A020F0;">'CallbackProperties'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>hPanel, <span style="color:#A020F0;">'ValueChangedCallback'</span>, @myCallbackFunction<span style="color: #080;">&#41;</span>;</pre></div></div><p>For the combo-box (drop-down/popup menus) controls, we obviously need to modify the displayed size (in the <i><b>javacomponent</b></i> call) to something much more compact, such as [10,10,100,20]. These components display one of the above panels as their pop-up selection panels. Users can access and customize these panels using the combo-box control&#8217;s <em>getPopupPanel()</em> function (or <strong>PopupPanel</strong> property).<br
/><center><div
class="wp-caption aligncenter" style="width: 420px"><img
alt="DateComboBox" src="http://UndocumentedMatlab.com/images/JIDE_DateComboBox.png" title="DateComboBox" width="200" height="166" /> &nbsp; <img
alt="DateSpinnerComboBox" src="http://UndocumentedMatlab.com/images/JIDE_DateSpinnerComboBox.png" title="DateSpinnerComboBox" width="200" height="166" /><p
class="wp-caption-text">DateComboBox and DateSpinnerComboBox components</p></div></center></p><p>Numerous other customizations are possible with these JIDE components &#8211; have fun exploring (my <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/17935-uiinspect-display-methodspropertiescallbacks-of-an-object"><i><b>uiinspect</b></i> utility</a> can be quite handy in this)! Just remember that JIDE evolves with Matlab, and so JIDE&#8217;s online documentation, which refers to the latest JIDE version, may be partially inapplicable if you use an old Matlab version. The older your Matlab, the more such inconsistencies that you may find.</p><h3 id="Alternatives">Alternative components</h3><p>There are several alternatives to the JIDE components:</p><p>If we have Matlab&#8217;s Financial toolbox, we can use the <i><b><a
target="_blank" rel="nofollow" href="http://www.mathworks.com/access/helpdesk/help/toolbox/finance/uicalendar.html">uicalendar</a></b></i> function. Unfortunately, this control is not available if you don&#8217;t own the expensive Financial toolbox.</p><p>If we only target Windows-based platforms, we could use third-party ActiveXes such as the Microsoft Date-and-Time-Picker (MSComCtl2.DTPicker.2), Microsoft MonthView (MSComCtl2.MonthView.2) or the Microsoft Office Calendar (MSCAL.Calendar.7) ActiveX controls. Depending on your installed applications, you may have other similar controls. For example, if you have Symantec&#8217;s EndPoint Protection (SEP), you have access to the SEP Date Control (LDDATETIME.LDDateCtrl.1). Of course, these controls will not work on non-Windows platforms, or platforms that do not have these ActiveX controls installed.</p><p>We can also use other (non-JIDE) third-party Java controls from places like javashareware.com, swinglabs.org, downloadthat.com, sharewareconnection.com, easyfreeware.com, l2fprod.com,  fileheap.com/software/components.html, swing-components.safe-install.com and many others. One specific example is <a
target="_blank" rel="nofollow" href="http://nachocalendar.sourceforge.net/">NachoCalendar</a>, from SourceForge.com.</p><p>Finally, we could use some of the utilities posted on the Matlab File Exchange: <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/15913-yet-another-calendar">uical</a>, <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/5915-uisetdate">uisetdate</a>, <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/26560-calender">calender</a> (sic) and several others.</p><p>In my own biased opinion, none of these alternatives comes close to the ease-of-use and functionality of the JIDE components presented above. What do you think? Please add your comments <a
target="_blank" rel="nofollow" href="#respond">here</a>.</p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/color-selection-components/' rel='bookmark' title='Color selection components'>Color selection components</a> <small>Matlab has several internal color-selection components that can easily be integrated in Matlab GUI...</small></li><li><a
href='http://undocumentedmatlab.com/blog/plot-type-selection-components/' rel='bookmark' title='Plot-type selection components'>Plot-type selection components</a> <small>Several built-in components enable programmatic plot-type selection in Matlab GUI - this article explains how...</small></li><li><a
href='http://undocumentedmatlab.com/blog/setting-status-bar-components/' rel='bookmark' title='Setting status-bar components'>Setting status-bar components</a> <small>Matlab status-bars are Java containers in which we can add GUI controls such as progress-bars, not just simple text labels...</small></li><li><a
href='http://undocumentedmatlab.com/blog/figure-toolbar-components/' rel='bookmark' title='Figure toolbar components'>Figure toolbar components</a> <small>Matlab's toolbars can be customized using a combination of undocumented Matlab and Java hacks. This article describes how to access existing toolbar icons and how to add non-button toolbar components....</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/date-selection-components/feed/</wfw:commentRss> <slash:comments>10</slash:comments> </item> <item><title>Advanced JIDE Property Grids</title><link>http://undocumentedmatlab.com/blog/advanced-jide-property-grids/</link> <comments>http://undocumentedmatlab.com/blog/advanced-jide-property-grids/#comments</comments> <pubDate>Thu, 22 Apr 2010 06:01:19 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[Guest bloggers]]></category> <category><![CDATA[GUI]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[Medium risk of breaking in future versions]]></category> <category><![CDATA[Undocumented feature]]></category> <category><![CDATA[Callbacks]]></category> <category><![CDATA[Internal component]]></category> <category><![CDATA[JIDE]]></category> <category><![CDATA[Levente Hunyadi]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=1316</guid> <description><![CDATA[JIDE property grids can use complex cell renderer and editor components and can signal property change events asynchronously to Matlab callbacks<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/jide-property-grids/' rel='bookmark' title='JIDE Property Grids'>JIDE Property Grids</a> <small>The JIDE components pre-bundled in Matlab enable creating user-customized property grid tables...</small></li><li><a
href='http://undocumentedmatlab.com/blog/plot-linesmoothing-property/' rel='bookmark' title='Plot LineSmoothing property'>Plot LineSmoothing property</a> <small>LineSmoothing is a hidden and undocumented plot line property that creates anti-aliased (smooth unpixelized) lines in Matlab plots...</small></li><li><a
href='http://undocumentedmatlab.com/blog/axes-looseinset-property/' rel='bookmark' title='Axes LooseInset property'>Axes LooseInset property</a> <small>Matlab plot axes have an undocumented LooseInset property that sets empty margins around the axes, and can be set to provide a tighter fit of the axes to their surroundings....</small></li><li><a
href='http://undocumentedmatlab.com/blog/date-selection-components/' rel='bookmark' title='Date selection components'>Date selection components</a> <small>The JIDE package, pre-bundled in Matlab, contains several GUI controls for selecting dates - this article explains how they can be used...</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p><i>Once again, I would like to welcome guest blogger <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/authors/60898">Levente Hunyadi</a>.</i></p><h3 id="renderers">Non-standard property renderers and editors</h3><p>Last week, I discussed JIDE&#8217;s property table and showed how we can add custom properties and present this table in our Matlab GUI. Today, I will extend the previous week&#8217;s example to include more sophisticated renderers and editors.</p><p><a
target="_blank" rel="nofollow" href="http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#editrender">Cell renderers and editors</a> are the backbone of JTable implementations, JIDE&#8217;s property grid included. Each property is associated with a type, and a renderer and an editor may be registered for a type. The cell renderer controls how the property value is displayed, while the editor determines how it is edited. For example, flags (Java <em>Boolean</em>s) are often both rendered and edited using a checkbox, but can also use a text renderer with a combo-box editor. <em>PropertyTable</em> automatically assigns a default renderer and editor to each property, based on its type: Flags are assigned a combo-box editor of true/false values, and similarly for other types.</p><p>Let us now modify the preassigned editor. First, let&#8217;s set a <a
target="_blank" rel="nofollow" href="http://java.sun.com/docs/books/tutorial/uiswing/components/button.html#checkbox">checkbox</a> editor (<a
target="_blank" rel="nofollow" href="http://www.jidesoft.com/javadoc/com/jidesoft/grid/BooleanCheckBoxCellEditor.html"><em>BooleanCheckBoxCellEditor</em></a>) for flags and a <a
target="_blank" rel="nofollow" href="http://java.sun.com/docs/books/tutorial/uiswing/components/spinner.html">spinner</a> for numbers:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% Initialize JIDE's usage within Matlab</span>
com.<span style="">mathworks</span>.<span style="">mwswing</span>.<span style="">MJUtilities</span>.<span style="">initJIDE</span>;
&nbsp;
<span style="color: #228B22;">% Prepare the properties list:</span>
<span style="color: #228B22;">% First two logical values (flags)</span>
list = java.<span style="">util</span>.<span style="">ArrayList</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>;
prop1 = com.<span style="">jidesoft</span>.<span style="color: #0000FF;">grid</span>.<span style="">DefaultProperty</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>;
prop1.<span style="">setName</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'mylogical'</span><span style="color: #080;">&#41;</span>;
prop1.<span style="">setType</span><span style="color: #080;">&#40;</span>javaclass<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'logical'</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
prop1.<span style="">setValue</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;
list.<span style="">add</span><span style="color: #080;">&#40;</span>prop1<span style="color: #080;">&#41;</span>;
&nbsp;
prop2 = com.<span style="">jidesoft</span>.<span style="color: #0000FF;">grid</span>.<span style="">DefaultProperty</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>;
prop2.<span style="">setName</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'mycheckbox'</span><span style="color: #080;">&#41;</span>;
prop2.<span style="">setType</span><span style="color: #080;">&#40;</span>javaclass<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'logical'</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
prop2.<span style="">setValue</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;
prop2.<span style="">setEditorContext</span><span style="color: #080;">&#40;</span>com.<span style="">jidesoft</span>.<span style="color: #0000FF;">grid</span>.<span style="">BooleanCheckBoxCellEditor</span>.<span style="">CONTEXT</span><span style="color: #080;">&#41;</span>;
list.<span style="">add</span><span style="color: #080;">&#40;</span>prop2<span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% Now integers (note the different way to set property values):</span>
prop3 = com.<span style="">jidesoft</span>.<span style="color: #0000FF;">grid</span>.<span style="">DefaultProperty</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>;
javatype = javaclass<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'int32'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>prop3,<span style="color:#A020F0;">'Name'</span>,<span style="color:#A020F0;">'myinteger'</span>,<span style="color:#A020F0;">'Type'</span>,javatype,<span style="color:#A020F0;">'Value'</span>,<span style="color: #0000FF;">int32</span><span style="color: #080;">&#40;</span><span style="color: #33f;">1</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
list.<span style="">add</span><span style="color: #080;">&#40;</span>prop3<span style="color: #080;">&#41;</span>;
&nbsp;
prop4 = com.<span style="">jidesoft</span>.<span style="color: #0000FF;">grid</span>.<span style="">DefaultProperty</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>prop4,<span style="color:#A020F0;">'Name'</span>,<span style="color:#A020F0;">'myspinner'</span>,<span style="color:#A020F0;">'Type'</span>,javatype,<span style="color:#A020F0;">'Value'</span>,<span style="color: #0000FF;">int32</span><span style="color: #080;">&#40;</span><span style="color: #33f;">1</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>prop4,<span style="color:#A020F0;">'EditorContext'</span>,com.<span style="">jidesoft</span>.<span style="color: #0000FF;">grid</span>.<span style="">SpinnerCellEditor</span>.<span style="">CONTEXT</span><span style="color: #080;">&#41;</span>;
list.<span style="">add</span><span style="color: #080;">&#40;</span>prop4<span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% Prepare a properties table containing the list</span>
model = com.<span style="">jidesoft</span>.<span style="color: #0000FF;">grid</span>.<span style="">PropertyTableModel</span><span style="color: #080;">&#40;</span>list<span style="color: #080;">&#41;</span>;
model.<span style="">expandAll</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">grid</span> = com.<span style="">jidesoft</span>.<span style="color: #0000FF;">grid</span>.<span style="">PropertyTable</span><span style="color: #080;">&#40;</span>model<span style="color: #080;">&#41;</span>;
pane = com.<span style="">jidesoft</span>.<span style="color: #0000FF;">grid</span>.<span style="">PropertyPane</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">grid</span><span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% Display the properties pane onscreen</span>
hFig = <span style="color: #0000FF;">figure</span>;
panel = uipanel<span style="color: #080;">&#40;</span>hFig<span style="color: #080;">&#41;</span>;
javacomponent<span style="color: #080;">&#40;</span>pane, <span style="color: #080;">&#91;</span><span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">200</span> <span style="color: #33f;">200</span><span style="color: #080;">&#93;</span>, panel<span style="color: #080;">&#41;</span>;</pre></div></div><p><center><div
class="wp-caption aligncenter" style="width: 310px"><img
alt="A property grid with checkbox and spinner controls" src="http://UndocumentedMatlab.com/images/PropertyGrid_types.png" title="A property grid with checkbox and spinner controls" width="200" height="165" /><p
class="wp-caption-text">A property grid with checkbox and spinner controls</p></div></center></p><p>Notice how the <b>EditorContext</b> is used to specify a non-standard renderer/editor for myspinner and mycheckbox: The mylogical flag displays as a string label, while mycheckbox displays as a checkbox; myinteger uses a regular integer editor that accepts whole numbers, while myspinner uses a spinner control to modify the value.</p><p>Note that instead of creating an entirely new properties list and table, we could have run last week&#8217;s example, modified <em>list</em> and then simply called <em>model.refresh()</em> to update the display.</p><p>Also note that Matlab types are automatically converted to Java types, but we must be careful that the results of the conversion should match our <em>setType</em> declaration. The logical value <i><b>true</b></i> converts to <em>java.lang.Boolean</em>, but 1 by default would be a double, which is the standard numeric type in Matlab. The <i><b>int32</b></i> wrapper is needed to force a conversion to a <em>java.lang.Integer</em>.</p><p>Spinners with indefinite value bounds are seldom useful. The following shows how to register a new editor to restrict values to a fixed range. Remember to unregister the editor when it is no longer used:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">javatype = javaclass<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'int32'</span><span style="color: #080;">&#41;</span>;
value  = <span style="color: #0000FF;">int32</span><span style="color: #080;">&#40;</span><span style="color: #33f;">0</span><span style="color: #080;">&#41;</span>;
minVal = <span style="color: #0000FF;">int32</span><span style="color: #080;">&#40;</span>-<span style="color: #33f;">2</span><span style="color: #080;">&#41;</span>;
maxVal = <span style="color: #0000FF;">int32</span><span style="color: #080;">&#40;</span><span style="color: #33f;">5</span><span style="color: #080;">&#41;</span>;
step   = <span style="color: #0000FF;">int32</span><span style="color: #080;">&#40;</span><span style="color: #33f;">1</span><span style="color: #080;">&#41;</span>;
spinner = javax.<span style="">swing</span>.<span style="">SpinnerNumberModel</span><span style="color: #080;">&#40;</span>value, minVal, maxVal, step<span style="color: #080;">&#41;</span>;
editor = com.<span style="">jidesoft</span>.<span style="color: #0000FF;">grid</span>.<span style="">SpinnerCellEditor</span><span style="color: #080;">&#40;</span>spinner<span style="color: #080;">&#41;</span>;
context = com.<span style="">jidesoft</span>.<span style="color: #0000FF;">grid</span>.<span style="">EditorContext</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'spinnereditor'</span><span style="color: #080;">&#41;</span>;
com.<span style="">jidesoft</span>.<span style="color: #0000FF;">grid</span>.<span style="">CellEditorManager</span>.<span style="">registerEditor</span><span style="color: #080;">&#40;</span>javatype, editor, context<span style="color: #080;">&#41;</span>;
&nbsp;
prop = com.<span style="">jidesoft</span>.<span style="color: #0000FF;">grid</span>.<span style="">DefaultProperty</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>prop, <span style="color:#A020F0;">'Name'</span>,<span style="color:#A020F0;">'myspinner'</span>, <span style="color:#A020F0;">'Type'</span>,javatype, <span style="color: #F0F;">...</span>
          <span style="color:#A020F0;">'Value'</span>,<span style="color: #0000FF;">int32</span><span style="color: #080;">&#40;</span><span style="color: #33f;">1</span><span style="color: #080;">&#41;</span>, <span style="color:#A020F0;">'EditorContext'</span>,context<span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% [do something useful here...]</span>
&nbsp;
com.<span style="">jidesoft</span>.<span style="color: #0000FF;">grid</span>.<span style="">CellEditorManager</span>.<span style="">unregisterEditor</span><span style="color: #080;">&#40;</span>javatype, context<span style="color: #080;">&#41;</span>;</pre></div></div><p>The principle is the same for <a
target="_blank" rel="nofollow" href="http://java.sun.com/docs/books/tutorial/uiswing/components/combobox.html">combo-boxes</a>:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">javatype = javaclass<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'char'</span>, <span style="color: #33f;">1</span><span style="color: #080;">&#41;</span>;
options = <span style="color: #080;">&#123;</span><span style="color:#A020F0;">'spring'</span>, <span style="color:#A020F0;">'summer'</span>, <span style="color:#A020F0;">'fall'</span>, <span style="color:#A020F0;">'winter'</span><span style="color: #080;">&#125;</span>;
editor = com.<span style="">jidesoft</span>.<span style="color: #0000FF;">grid</span>.<span style="">ListComboBoxCellEditor</span><span style="color: #080;">&#40;</span>options<span style="color: #080;">&#41;</span>;
context = com.<span style="">jidesoft</span>.<span style="color: #0000FF;">grid</span>.<span style="">EditorContext</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'comboboxeditor'</span><span style="color: #080;">&#41;</span>;
com.<span style="">jidesoft</span>.<span style="color: #0000FF;">grid</span>.<span style="">CellEditorManager</span>.<span style="">registerEditor</span><span style="color: #080;">&#40;</span>javatype, editor, context<span style="color: #080;">&#41;</span>;
&nbsp;
prop = com.<span style="">jidesoft</span>.<span style="color: #0000FF;">grid</span>.<span style="">DefaultProperty</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>prop, <span style="color:#A020F0;">'Name'</span>,<span style="color:#A020F0;">'season'</span>, <span style="color:#A020F0;">'Type'</span>,javatype, <span style="color: #F0F;">...</span>
          <span style="color:#A020F0;">'Value'</span>,<span style="color:#A020F0;">'spring'</span>, <span style="color:#A020F0;">'EditorContext'</span>,context<span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% [do something useful here...]</span>
&nbsp;
com.<span style="">jidesoft</span>.<span style="color: #0000FF;">grid</span>.<span style="">CellEditorManager</span>.<span style="">unregisterEditor</span><span style="color: #080;">&#40;</span>javatype, context<span style="color: #080;">&#41;</span>;</pre></div></div><p><center><div
class="wp-caption aligncenter" style="width: 260px"><img
alt="A property grid with a combobox control" src="http://UndocumentedMatlab.com/images/PropertyGrid_combobox.png" title="A property grid with a combobox control" width="200" height="165" /><p
class="wp-caption-text">A property grid with a combobox control</p></div></center></p><h3 id="nested">Nested properties</h3><p>Properties can act as a parent node for other properties. A typical example is an object&#8217;s dimensions: a parent node value may be edited as a 2-by-1 matrix, but width and height may also be exposed individually. Nested properties are created as regular properties. However, rather than adding them directly to a <em>PropertyTableModel</em>, they are added under a <em>Property</em> instance using its <em>addChild</em> method:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">propdimensions = com.<span style="">jidesoft</span>.<span style="color: #0000FF;">grid</span>.<span style="">DefaultProperty</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>;
propdimensions.<span style="">setName</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'dimensions'</span><span style="color: #080;">&#41;</span>;
propdimensions.<span style="">setEditable</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">false</span><span style="color: #080;">&#41;</span>;
&nbsp;
propwidth = com.<span style="">jidesoft</span>.<span style="color: #0000FF;">grid</span>.<span style="">DefaultProperty</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>;
propwidth.<span style="">setName</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'width'</span><span style="color: #080;">&#41;</span>;
propwidth.<span style="">setType</span><span style="color: #080;">&#40;</span>javaclass<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'int32'</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
propwidth.<span style="">setValue</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">int32</span><span style="color: #080;">&#40;</span><span style="color: #33f;">100</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
propdimensions.<span style="">addChild</span><span style="color: #080;">&#40;</span>propwidth<span style="color: #080;">&#41;</span>;
&nbsp;
propheight = com.<span style="">jidesoft</span>.<span style="color: #0000FF;">grid</span>.<span style="">DefaultProperty</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>;
propheight.<span style="">setName</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'height'</span><span style="color: #080;">&#41;</span>;
propheight.<span style="">setType</span><span style="color: #080;">&#40;</span>javaclass<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'int32'</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
propheight.<span style="">setValue</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">int32</span><span style="color: #080;">&#40;</span><span style="color: #33f;">100</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
propdimensions.<span style="">addChild</span><span style="color: #080;">&#40;</span>propheight<span style="color: #080;">&#41;</span>;</pre></div></div><p><center><div
class="wp-caption aligncenter" style="width: 210px"><img
alt="A property grid with nested property" src="http://UndocumentedMatlab.com/images/PropertyGrid_nested.png" title="A property grid with nested property" width="200" height="165" /><p
class="wp-caption-text">A property grid with nested property</p></div></center></p><p><em>PropertyTableModel</em> accesses properties in a hierarchical naming scheme. This means that the parts of nested properties are separated with a dot (.). In the above example, these two fully-qualified names are <em>dimensions.width</em> and <em>dimensions.height</em>.</p><h3 id="callback">Trapping property change events</h3><p>Sometimes it is desirable to subscribe to the PropertyChange event. This event is fired by <em>PropertyTableModel</em> whenever any property value is updated. To expose Java events to Matlab, we use the two-parameter form of the <i><b>handle</b></i> function with the optional CallbackProperties parameter.</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">hModel = handle<span style="color: #080;">&#40;</span>model, <span style="color:#A020F0;">'CallbackProperties'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>hModel, <span style="color:#A020F0;">'PropertyChangeCallback'</span>, @callback_onPropertyChange<span style="color: #080;">&#41;</span>;</pre></div></div><p>The callback function receives two input arguments: The first is the <em>PropertyTableModel</em> object that fired the event, the second is a <em>PropertyChangeEvent</em> object with properties <b>PropertyName</b>, <b>OldValue</b> and <b>NewValue</b>. The <em>PropertyTableModel</em>&#8216;s <em>getProperty(PropertyName)</em> method may be used to fetch the <em>Property</em> instance that has changed.</p><p>Callbacks enable property value validation: <b>OldValue</b> can be used to restore the original property value, if <b>NewValue</b> fails to meet some criteria that cannot be programmed into the cell editor. We may, for instance, set the property type to a string; then, in our callback function, use <i><b>str2num</b></i> as a validator to try to convert <b>NewValue</b> to a numeric matrix. If the conversion fails, we restore the <b>OldValue</b>:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #0000FF;">function</span> callback_onPropertyChange<span style="color: #080;">&#40;</span>model, event<span style="color: #080;">&#41;</span>
   string = event.<span style="">getNewValue</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>;
   <span style="color: #080;">&#91;</span>value, isvalid<span style="color: #080;">&#93;</span> = <span style="color: #0000FF;">str2num</span><span style="color: #080;">&#40;</span>string<span style="color: #080;">&#41;</span>; <span style="color: #228B22;">%#ok</span>
   prop = model.<span style="">getProperty</span><span style="color: #080;">&#40;</span>event.<span style="">getPropertyName</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
   <span style="color: #0000FF;">if</span> isvalid  <span style="color: #228B22;">% standardize value entered</span>
      string = <span style="color: #0000FF;">mat2str</span><span style="color: #080;">&#40;</span>value<span style="color: #080;">&#41;</span>;
   <span style="color: #0000FF;">else</span>  <span style="color: #228B22;">% restore previous value</span>
      string = event.<span style="">getOldValue</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>;
   <span style="color: #0000FF;">end</span>
   prop.<span style="">setValue</span><span style="color: #080;">&#40;</span>string<span style="color: #080;">&#41;</span>;
   model.<span style="color: #0000FF;">refresh</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">% refresh value onscreen</span></pre></div></div><p>The JIDE packages that are pre-bundled in Matlab contain numerous other useful classes. Some of these will be described in future articles.</p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/jide-property-grids/' rel='bookmark' title='JIDE Property Grids'>JIDE Property Grids</a> <small>The JIDE components pre-bundled in Matlab enable creating user-customized property grid tables...</small></li><li><a
href='http://undocumentedmatlab.com/blog/plot-linesmoothing-property/' rel='bookmark' title='Plot LineSmoothing property'>Plot LineSmoothing property</a> <small>LineSmoothing is a hidden and undocumented plot line property that creates anti-aliased (smooth unpixelized) lines in Matlab plots...</small></li><li><a
href='http://undocumentedmatlab.com/blog/axes-looseinset-property/' rel='bookmark' title='Axes LooseInset property'>Axes LooseInset property</a> <small>Matlab plot axes have an undocumented LooseInset property that sets empty margins around the axes, and can be set to provide a tighter fit of the axes to their surroundings....</small></li><li><a
href='http://undocumentedmatlab.com/blog/date-selection-components/' rel='bookmark' title='Date selection components'>Date selection components</a> <small>The JIDE package, pre-bundled in Matlab, contains several GUI controls for selecting dates - this article explains how they can be used...</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/advanced-jide-property-grids/feed/</wfw:commentRss> <slash:comments>17</slash:comments> </item> <item><title>JIDE Property Grids</title><link>http://undocumentedmatlab.com/blog/jide-property-grids/</link> <comments>http://undocumentedmatlab.com/blog/jide-property-grids/#comments</comments> <pubDate>Thu, 22 Apr 2010 00:37:52 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[Guest bloggers]]></category> <category><![CDATA[GUI]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[Medium risk of breaking in future versions]]></category> <category><![CDATA[Undocumented feature]]></category> <category><![CDATA[FindJObj]]></category> <category><![CDATA[Internal component]]></category> <category><![CDATA[JIDE]]></category> <category><![CDATA[Levente Hunyadi]]></category> <category><![CDATA[Memory]]></category> <category><![CDATA[UIInspect]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=1287</guid> <description><![CDATA[The JIDE components pre-bundled in Matlab enable creating user-customized property grid tables<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/advanced-jide-property-grids/' rel='bookmark' title='Advanced JIDE Property Grids'>Advanced JIDE Property Grids</a> <small>JIDE property grids can use complex cell renderer and editor components and can signal property change events asynchronously to Matlab callbacks...</small></li><li><a
href='http://undocumentedmatlab.com/blog/plot-linesmoothing-property/' rel='bookmark' title='Plot LineSmoothing property'>Plot LineSmoothing property</a> <small>LineSmoothing is a hidden and undocumented plot line property that creates anti-aliased (smooth unpixelized) lines in Matlab plots...</small></li><li><a
href='http://undocumentedmatlab.com/blog/axes-looseinset-property/' rel='bookmark' title='Axes LooseInset property'>Axes LooseInset property</a> <small>Matlab plot axes have an undocumented LooseInset property that sets empty margins around the axes, and can be set to provide a tighter fit of the axes to their surroundings....</small></li><li><a
href='http://undocumentedmatlab.com/blog/tri-state-checkbox/' rel='bookmark' title='Tri-state checkbox'>Tri-state checkbox</a> <small>Matlab checkboxes can easily be made to support tri-state functionality....</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p><i>I would like to welcome guest blogger <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/authors/60898">Levente Hunyadi</a>.</i></p><h3>Matlab&#8217;s property inspector</h3><p>We often wish to edit properties of heterogeneous objects using a common interface. Matlab&#8217;s property inspector, invoked with the built-in <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/inspect.html"><i><b>inspect</b></i></a> function, answers this need. The inspector is based on a two-column table of property names and values. Properties and their values are populated automatically, and the user can edit values in-place. The inspector enables property categorization, sub-categorization and sorting, which help users find and modify properties easily. For each property, the inspector displays a matching edit control: editbox/combobox/checkbox etc. This simplifies property value editing and prevents illegal value entry. Matlab&#8217;s GUI builder, <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/access/helpdesk/help/techdoc/creating_guis/f7-998368.html">GUIDE</a>, uses the inspector to let users edit GUI properties such as position, color etc. It is also used by other tools such as the <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/access/helpdesk/help/techdoc/creating_plots/f9-47085.html#f9-43456">Plot Editor</a>.</p><p><center><div
class="wp-caption aligncenter" style="width: 365px"><img
alt="Matlab's built-in property inspector" src="http://UndocumentedMatlab.com/images/Inspector_mde_cropped.gif" title="Matlab's built-in property inspector" width="355" height="271" /><p
class="wp-caption-text">Matlab's built-in property inspector</p></div></center></p><p>The Matlab inspector can be embedded, with not-too-much effort, within Matlab GUI applications. Examples of this can be found in the <a
target="_blank" href="http://undocumentedmatlab.com/blog/findjobj-gui-display-container-hierarchy/">FindJObj</a> and <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/17935">UIInspect</a> utilities.</p><p><center><div
class="wp-caption aligncenter" style="width: 460px"><a
href="http://undocumentedmatlab.com/images/findjobj.png" target="_blank"><img
alt="FindJObj - embedded property inspector" src="http://undocumentedmatlab.com/images/findjobj.png" title="FindJObj - embedded property inspector" width="450" height="405" /></a><p
class="wp-caption-text">FindJObj - embedded property inspector</p></div></center></p><p>Unfortunately, Matlab&#8217;s property inspector is limited to Handle Graphics, Java and COM objects, and cannot be used for structures or user-defined Matlab classes. We shall see below how to set up our own property grid, populate it with data, and subscribe to property change events. This is a rather procedural approach. It is usually more convenient to use a declarative approach in which a structure or Matlab class is passed to a function that automatically discovers its properties and their meta-information. The <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/28732">Property Grid</a> utility at Matlab File Exchange provides these services.</p><h3 id="simple">A simple property grid</h3><p>Matlab&#8217;s property inspector is based on a property grid control by <a
target="_blank" rel="nofollow" href="http://www.jidesoft.com">JIDE Software</a>. JIDE Grids is a collection of components that extend the standard Java Swing <a
target="_blank" rel="nofollow" href="http://java.sun.com/docs/books/tutorial/uiswing/components/table.html">JTable</a> component, and is included in each Matlab installation (/java/jarext/jide/jide-grids.jar under the Matlab root). In particular, JIDE Grids includes the <em>PropertyTable</em> class, which is a fully customizable property grid component. You can find further details on JIDE Grids in the <a
target="_blank" rel="nofollow" href="http://www.jidesoft.com/products/JIDE_Grids_Developer_Guide.pdf">Developer Guide</a> and the <a
target="_blank" rel="nofollow" href="http://www.jidesoft.com/javadoc/">Javadoc documentation</a>.</p><p>There are several related classes associated with the <a
target="_blank" rel="nofollow" href="http://www.jidesoft.com/javadoc/com/jidesoft/grid/PropertyTable.html"><em>PropertyTable</em></a> class. First, a <a
target="_blank" rel="nofollow" href="http://www.jidesoft.com/javadoc/com/jidesoft/grid/PropertyTableModel.html"><em>PropertyTableModel</em></a> encapsulates all properties that are visualized in the property grid. Each property derives from the <a
target="_blank" rel="nofollow" href="http://www.jidesoft.com/javadoc/com/jidesoft/grid/Property.html"><em>Property</em></a> abstract class, which features some common actions to properties, most notably to get and set property value. <a
target="_blank" rel="nofollow" href="http://www.jidesoft.com/javadoc/com/jidesoft/grid/DefaultProperty.html"><em>DefaultProperty</em></a> is a default concrete subclass of <em>Property</em>. Finally, <a
target="_blank" rel="nofollow" href="http://www.jidesoft.com/javadoc/com/jidesoft/grid/PropertyPane.html"><em>PropertyPane</em></a> decorates a property grid with icons for changing category view to alphabetically sorted view as well as expanding and collapsing categories, and a description text box at the bottom that can be shown or hidden.</p><p>Here are the <i>DefaultProperty</i> fields and their respective roles:</p><table><tbody><tr><th>Field</th><th>Role</th></tr><tr><td>Name</td><td>Interal property name, not necessarily displayed, used as a key to identify the property.</td></tr><tr><td>DisplayName</td><td>A short property name shown in the left column of the property grid.</td></tr><tr><td>Description</td><td>A concise description of the property, shown at the bottom of the property pane, below the grid.</td></tr><tr><td>Type</td><td>The Java type associated with the property, used to invoke the appropriate renderer or editor.</td></tr><tr><td>EditorContext</td><td>An editor context object. If set, both the type and the context are used to look up the renderer or editor to use. This lets, for instance, one flag value to display as a true/false label, while another as a checkbox.</td></tr><tr><td>Category</td><td>A string specifying the property&#8217;s category, for grouping purposes.</td></tr><tr><td>Editable</td><td>Specifies whether the property value is modifiable or read-only.</td></tr><tr><td>Value</td><td>The current property value, as a Java object.</td></tr></tbody></table><p>Just as with any Java object, these fields may either be accessed with the Java get/set semantics (e.g. <i>getName()</i> or <i>setName(name)</i>), or the Matlab <i><b>get/set</b></i> semantics (e.g. <i><b>get</b>(prop,&#8217;Name&#8217;)</i> or <i><b>set</b>(prop,&#8217;Name&#8217;,name)</i>). When using the Matlab syntax, remember to wrap the Java object in a <i><b>handle()</b></i> call, to prevent a <a
target="_blank" href="http://undocumentedmatlab.com/blog/uicontrol-callbacks/#memory_leak">memory leak</a>.</p><p>To use a property grid in Matlab, first construct a set of <i>DefaultProperty</i> objects. For each object, set at least the name, type and initial value. Next, add the properties to a table model. Finally, construct a property grid with the given table model and encapsulate in a property pane:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% Initialize JIDE's usage within Matlab</span>
com.<span style="">mathworks</span>.<span style="">mwswing</span>.<span style="">MJUtilities</span>.<span style="">initJIDE</span>;
&nbsp;
<span style="color: #228B22;">% Prepare the properties list</span>
list = java.<span style="">util</span>.<span style="">ArrayList</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>;
prop1 = com.<span style="">jidesoft</span>.<span style="color: #0000FF;">grid</span>.<span style="">DefaultProperty</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>;
prop1.<span style="">setName</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'stringProp'</span><span style="color: #080;">&#41;</span>;
prop1.<span style="">setType</span><span style="color: #080;">&#40;</span>javaclass<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'char'</span>,<span style="color: #33f;">1</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
prop1.<span style="">setValue</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'initial value'</span><span style="color: #080;">&#41;</span>;
prop1.<span style="">setCategory</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'My Category'</span><span style="color: #080;">&#41;</span>;
prop1.<span style="">setDisplayName</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'Editable string property'</span><span style="color: #080;">&#41;</span>;
prop1.<span style="">setDescription</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'A concise description for my property.'</span><span style="color: #080;">&#41;</span>;
prop1.<span style="">setEditable</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;
list.<span style="">add</span><span style="color: #080;">&#40;</span>prop1<span style="color: #080;">&#41;</span>;
&nbsp;
prop2 = com.<span style="">jidesoft</span>.<span style="color: #0000FF;">grid</span>.<span style="">DefaultProperty</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>;
prop2.<span style="">setName</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'flagProp'</span><span style="color: #080;">&#41;</span>;
prop2.<span style="">setType</span><span style="color: #080;">&#40;</span>javaclass<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'logical'</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
prop2.<span style="">setValue</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;
prop2.<span style="">setCategory</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'My Category'</span><span style="color: #080;">&#41;</span>;
prop2.<span style="">setDisplayName</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'Read-only flag property'</span><span style="color: #080;">&#41;</span>;
prop2.<span style="">setEditable</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">false</span><span style="color: #080;">&#41;</span>;
list.<span style="">add</span><span style="color: #080;">&#40;</span>prop2<span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% Prepare a properties table containing the list</span>
model = com.<span style="">jidesoft</span>.<span style="color: #0000FF;">grid</span>.<span style="">PropertyTableModel</span><span style="color: #080;">&#40;</span>list<span style="color: #080;">&#41;</span>;
model.<span style="">expandAll</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">grid</span> = com.<span style="">jidesoft</span>.<span style="color: #0000FF;">grid</span>.<span style="">PropertyTable</span><span style="color: #080;">&#40;</span>model<span style="color: #080;">&#41;</span>;
pane = com.<span style="">jidesoft</span>.<span style="color: #0000FF;">grid</span>.<span style="">PropertyPane</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">grid</span><span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% Display the properties pane onscreen</span>
hFig = <span style="color: #0000FF;">figure</span>;
panel = uipanel<span style="color: #080;">&#40;</span>hFig<span style="color: #080;">&#41;</span>;
javacomponent<span style="color: #080;">&#40;</span>pane, <span style="color: #080;">&#91;</span><span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">200</span> <span style="color: #33f;">200</span><span style="color: #080;">&#93;</span>, panel<span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% Wait for figure window to close &amp; display the prop value</span>
uiwait<span style="color: #080;">&#40;</span>hFig<span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">disp</span><span style="color: #080;">&#40;</span>prop1.<span style="">getValue</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;</pre></div></div><p>Here, <em>com.mathworks.mwswing.MJUtilities.initJIDE</em> is called to initialize JIDE&#8217;s usage within Matlab. Without this call, we may see a JIDE warning message in some Matlab releases. We only need to <em>initJIDE</em> once per Matlab session, although there is no harm in repeated calls.</p><p><i><b>javaclass</b></i> is a function (included in the <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/28732">Property Grid</a> utility, or directly downloadable from <a
target="_blank" rel="nofollow" href="http://undocumentedmatlab.com/files/javaclass.m">here</a>) that returns a Java class for the corresponding Matlab type with the given dimension: <em><b>javaclass</b>(&#8216;logical&#8217;)</em> or <em><b>javaclass</b>(&#8216;logical&#8217;,0)</em> (a single logical flag value) returns a <em>java.lang.Boolean</em> class; <em><b>javaclass</b>(&#8216;char&#8217;,1)</em> (a character array) returns a <em>java.lang.String</em> class; <em><b>javaclass</b>(&#8216;double&#8217;,2)</em> (a matrix of double-precision floating point values) returns <em>double[][]</em>.</p><p><i><b>javacomponent</b></i> is the undocumented built-in Matlab function that adds Java Swing components to a Matlab figure, using the given dimensions and parent handle. When the user closes the figure, prop.<em>getValue()</em> fetches and displays the new property value.</p><p><center><div
class="wp-caption aligncenter" style="width: 312px"><img
alt="A simple user-defined property grid" src="http://UndocumentedMatlab.com/images/PropertyGrid_simple2.png" title="A simple user-defined property grid" width="302" height="294" /><p
class="wp-caption-text">A simple user-defined property grid</p></div></center></p><p>Next week&#8217;s article will show how to add more complex renderers and editors (display the flag value as a checkbox for example), define nested properties, and subscribe to property value change events. So stay tuned&#8230;</p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/advanced-jide-property-grids/' rel='bookmark' title='Advanced JIDE Property Grids'>Advanced JIDE Property Grids</a> <small>JIDE property grids can use complex cell renderer and editor components and can signal property change events asynchronously to Matlab callbacks...</small></li><li><a
href='http://undocumentedmatlab.com/blog/plot-linesmoothing-property/' rel='bookmark' title='Plot LineSmoothing property'>Plot LineSmoothing property</a> <small>LineSmoothing is a hidden and undocumented plot line property that creates anti-aliased (smooth unpixelized) lines in Matlab plots...</small></li><li><a
href='http://undocumentedmatlab.com/blog/axes-looseinset-property/' rel='bookmark' title='Axes LooseInset property'>Axes LooseInset property</a> <small>Matlab plot axes have an undocumented LooseInset property that sets empty margins around the axes, and can be set to provide a tighter fit of the axes to their surroundings....</small></li><li><a
href='http://undocumentedmatlab.com/blog/tri-state-checkbox/' rel='bookmark' title='Tri-state checkbox'>Tri-state checkbox</a> <small>Matlab checkboxes can easily be made to support tri-state functionality....</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/jide-property-grids/feed/</wfw:commentRss> <slash:comments>12</slash:comments> </item> <item><title>FindJObj GUI &#8211; display container hierarchy</title><link>http://undocumentedmatlab.com/blog/findjobj-gui-display-container-hierarchy/</link> <comments>http://undocumentedmatlab.com/blog/findjobj-gui-display-container-hierarchy/#comments</comments> <pubDate>Tue, 12 Jan 2010 13:47:18 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[Figure window]]></category> <category><![CDATA[GUI]]></category> <category><![CDATA[Handle graphics]]></category> <category><![CDATA[High risk of breaking in future versions]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[UI controls]]></category> <category><![CDATA[Undocumented feature]]></category> <category><![CDATA[FindJObj]]></category> <category><![CDATA[JIDE]]></category> <category><![CDATA[uicontrol]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=908</guid> <description><![CDATA[The FindJObj utility can be used to present a GUI that displays a Matlab container's internal Java components, properties and callbacks.<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/findjobj-find-underlying-java-object/' rel='bookmark' title='FindJObj &#8211; find a Matlab component&#8217;s underlying Java object'>FindJObj &#8211; find a Matlab component&#8217;s underlying Java object</a> <small>The FindJObj utility can be used to access and display the internal components of Matlab controls and containers. This article explains its uses and inner mechanism....</small></li><li><a
href='http://undocumentedmatlab.com/blog/cprintf-display-formatted-color-text-in-command-window/' rel='bookmark' title='cprintf &#8211; display formatted color text in the Command Window'>cprintf &#8211; display formatted color text in the Command Window</a> <small>cprintf is a utility that utilized undocumented Matlab desktop functionalities to display color and underline-styled formatted text in the Command Window...</small></li><li><a
href='http://undocumentedmatlab.com/blog/uitree/' rel='bookmark' title='uitree'>uitree</a> <small>This article describes the undocumented Matlab uitree function, which displays data in a GUI tree component...</small></li><li><a
href='http://undocumentedmatlab.com/blog/tri-state-checkbox/' rel='bookmark' title='Tri-state checkbox'>Tri-state checkbox</a> <small>Matlab checkboxes can easily be made to support tri-state functionality....</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p>In my previous post, I explained how the <b><i>findjobj</i></b> utility can be used to access a Matlab component&#8217;s underlying Java component. <b><i>Findjobj</i></b> has another role: displaying the component hierarchy of complex Matlab containers such as the <a
target="_blank" href="http://undocumentedmatlab.com/blog/figure-toolbar-customizations/">figure window</a>, <a
target="_blank" href="http://undocumentedmatlab.com/blog/guide-customization/">GUIDE</a> or the <a
target="_blank" href="http://undocumentedmatlab.com/blog/accessing-the-matlab-editor/">Editor</a>.</p><p>When <b><i>findjobj</i></b> is called with no output arguments, the function infers that the user requests to see the GUI version, rather than to get the control&#8217;s Java handle:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">&gt;&gt; findjobj<span style="color: #080;">&#40;</span><span style="color: #0000FF;">gcf</span><span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">% or: findjobj(gcf)</span></pre></div></div><p><center><div
class="wp-caption aligncenter" style="width: 460px"><a
href="http://UndocumentedMatlab.com/images/findjobj9.png" target="_blank"><img
alt="FindJObj GUI (click to zoom)" src="http://UndocumentedMatlab.com/images/findjobj9.png" title="FindJObj GUI (click to zoom)" width="450" height="296" /></a><p
class="wp-caption-text">FindJObj GUI (click to zoom)</p></div></center></p><p>There are several note-worthy aspects in this graphical hierarchy presentation:</p><p>The hierarchy tree itself is displayed using the internal com.mathworks.hg.peer.UITreePeer Java object. This is the object that underlies the semi-documented <b><i>uitree</i></b> function. The hierarchy sub-components are presented as tree nodes, each having a separate icon based on the component type. In some cases (toolbar buttons for example), the component&#8217;s icon image is used for its corresponding tree node. A javax.swing.JProgressBar is presented while the tree is being populated, an action that can take a few seconds depending on the target figure&#8217;s complexity. Some tree branches which are normally uninteresting are automatically collapsed: hidden containers (these are also grayed-out), menubars, toolbars and scrollbars. In parallel to the Java container hierarchy, a separate tree branch is presented with the corresponding Matlab (Handle-Graphics, or HG) hierarchy.</p><p><center><div
class="wp-caption aligncenter" style="width: 430px"><img
alt="Another GUI example - note the hidden (gray) items, the HG tree branch and the auto-collapsed MJToolBar container" src="http://undocumentedmatlab.com/images/statusbar6d2.png" title="Another GUI example - note the hidden (gray) items, the HG tree branch and the auto-collapsed MJToolBar container" width="420" height="509" /><p
class="wp-caption-text">Another GUI example - note the hidden (gray) items, the HG tree branch and the auto-collapsed MJToolBar container</p></div></center></p><p>Each node item gets a unique tooltip (see top screenshot above). Similarly, a unique context-menu (right-click menu) is attached to each node item with actions that are relevant for that node:</p><p><center><div
class="wp-caption aligncenter" style="width: 321px"><img
alt="Item-specific context-menu" src="http://UndocumentedMatlab.com/images/findjobj_contextmenu.png" title="Item-specific context-menu" width="311" height="171" /><p
class="wp-caption-text">Item-specific context-menu</p></div></center></p><p>Finally, a node-selection callback is attached to the tree, that will flash a red border around the GUI control when its corresponding Java node-item is clicked/selected:</p><p><center><div
class="wp-caption aligncenter" style="width: 460px"><a
href="http://undocumentedmatlab.com/images/findjobj.png" target="_blank"><img
alt="FindJObj - flashing red border around a toolbar icon" src="http://undocumentedmatlab.com/images/findjobj.png" title="FindJObj - flashing red border around a toolbar icon" width="450" height="405" /></a><p
class="wp-caption-text">FindJObj - flashing red border around a toolbar icon</p></div></center></p><p>Once the tree was done, I set out to display and enable modifications of component properties and callbacks in separate adjacent panels. I used the internal com.mathworks.mlwidgets.inspector.PropertyView component to display the properties (this is the JIDE component that underlies the built-in <b><i>inspect</i></b> function). To prevent a JIDE run-time alert, I called com.mathworks.mwswing.MJUtilities.initJIDE. A label is added to the table&#8217;s header, displaying the currently selected sub-component&#8217;s class (e.g., &#8220;javax.swing.JButton&#8221;), and a tooltip with a color-coded list of all the control&#8217;s properties.</p><p>The callbacks table was implemented using com.jidesoft.grid.TreeTable to enable easy column resizing, but this is otherwise used as a simple data table. A checkbox was added to filter out the 30-odd standard <a
target="_blank" href="http://undocumentedmatlab.com/blog/uicontrol-callbacks/">Swing callbacks</a>, which are non-unique to the selected sub-component (tree node). All the panels &#8211; tree, properties and callbacks &#8211; are then placed in resizable javax.swing.JSplitPanes and presented to the user.</p><p>I have omitted mention of some other undocumented features in <b><i>findjobj</i></b>. After all, space here is limited and the function is over 2500 lines long. I encourage you to <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/14317">download the utility</a> and explore the code, and I gladly welcome your feedback.</p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/findjobj-find-underlying-java-object/' rel='bookmark' title='FindJObj &#8211; find a Matlab component&#8217;s underlying Java object'>FindJObj &#8211; find a Matlab component&#8217;s underlying Java object</a> <small>The FindJObj utility can be used to access and display the internal components of Matlab controls and containers. This article explains its uses and inner mechanism....</small></li><li><a
href='http://undocumentedmatlab.com/blog/cprintf-display-formatted-color-text-in-command-window/' rel='bookmark' title='cprintf &#8211; display formatted color text in the Command Window'>cprintf &#8211; display formatted color text in the Command Window</a> <small>cprintf is a utility that utilized undocumented Matlab desktop functionalities to display color and underline-styled formatted text in the Command Window...</small></li><li><a
href='http://undocumentedmatlab.com/blog/uitree/' rel='bookmark' title='uitree'>uitree</a> <small>This article describes the undocumented Matlab uitree function, which displays data in a GUI tree component...</small></li><li><a
href='http://undocumentedmatlab.com/blog/tri-state-checkbox/' rel='bookmark' title='Tri-state checkbox'>Tri-state checkbox</a> <small>Matlab checkboxes can easily be made to support tri-state functionality....</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/findjobj-gui-display-container-hierarchy/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> </channel> </rss>

<!-- W3 Total Cache: Minify debug info:
Engine:             disk: basic
Theme:              b7666
Template:           tag
-->
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: undocumentedmatlab.com @ 2012-02-04 02:49:51 -->

<!-- W3 Total Cache: Page cache debug info:
Engine:             disk: enhanced
Cache key:          blog/tag/jide/feed/_index.xml_gzip
Caching:            enabled
Status:             not cached
Creation Time:      2.197s
Header info:
X-Pingback:         http://undocumentedmatlab.com/blog/xmlrpc.php
Set-Cookie:         wpgb_visit_last_php-default=1328348989; expires=Sun, 03-Feb-2013 09:49:49 GMT; path=/
Content-Type:       text/xml; charset=UTF-8
Last-Modified:      Sat, 04 Feb 2012 09:49:51 GMT
Vary:               Accept-Encoding, Cookie
Expires:            Sat, 04 Feb 2012 10:49:51 GMT
Pragma:             public
Cache-Control:      public, must-revalidate, proxy-revalidate
Etag:               5770d9aab075f493ef87c013cf0263d2
Content-Encoding:   gzip
-->
