|
SageTV Studio Discussion related to the SageTV Studio application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the Studio software application should be posted here. |
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
2D table - can't get the data to display
Hi everyone,
I'm trying to fill a simple 2D table using Java. I'm using the Chap 12 example as my template. I get the column headers and row headers displayed fine but I'm having problems with the data cells. Could you please take a quick look at my attachments and see what I'm doing wrong? It would be much appreciated! Thanks, Chris |
#2
|
||||
|
||||
For a 2D table you don't pass in an array of data values to the Cell component; you perform an indexing calculation to retrieve the element for a specific row and column and pass in that single element. Sage will take care of iterating over the rows and columns to fill in the entire table.
So in your case you'd want some function GetItem(theRowHeader, theColumnHeader) to pick out the element for the given row and column. I realize this is just a toy example, but your Java code is not doing anything here that couldn't be done much more easily by CreateArray(). However if you do continue to use Java to populate this table, I'd suggest the following changes: 1. Don't reuse the same list for different purposes (row headers, column headers, and cell data) in your class methods. All of those quantities are needed simultaneously to display the table, and you don't want them stepping on each other by overwriting a shared list. Have each method create its own list internally, populate it, and return it. 2. You don't need to generate new data every time the table is displayed (as you're doing now). If the data is relatively static, call your Java methods once at menu load time, save the results in attribute variables, and use those saved variables to feed the table display. If the data changes in response to some user action, then you can call the Java code again to refresh the variables. This will result in better display performance and a lot less object churn in the Java heap. 3. You don't need to say "this" everywhere. Just refer to your member variables by name within your class methods. Qualifying them with "this" all the time (in my opinion) just clutters the code unnecessarily and detracts from readability. The only times you need "this" are when you're trying to access a member variable that's been masked by a method parameter or local variable (itself a questionable practice), or when you need to pass a reference to your object in to a method of some other class.
__________________
-- Greg |
#3
|
|||
|
|||
Thanks Greg for your very helpful response and suggestions. I really appreciate them.
I'll try this tonight. This statement in the Studio documentation kind of threw me off... (I should have stuck with the info in the Chap 12 examples section.) Quote:
Last edited by chrishallowell; 08-12-2010 at 07:08 AM. |
#4
|
||||
|
||||
I agree the wording on that is somewhat confusing, but you really don't want to be instantiating the entire data array on what could potentially be a very large table. All you need are the elements that actually show on screen. (You do need all the row and column headers, though, so Sage knows how big the table actually is for scrolling purposes.)
__________________
-- Greg |
#5
|
|||
|
|||
Ok, I got it working.
Ok, I got it working. I attached the files for reference in case someone else needs an example of how to populate a 2D table using java. Just keep in mind the java code is not a practical example (See Greg's comments).
Thanks again Greg. Also you can use TableRow and TableCol, like this: Studio Action: HelloTable_HelloTableClass_getData2(theHelloTable, TableRow, TableCol) java method: Quote:
Last edited by chrishallowell; 08-12-2010 at 10:14 PM. |
#6
|
||||
|
||||
This is definitely an improvement, but I'd still suggest some further changes.
1. Your theDataCells component is not receiving a unique value for each cell. Rather, all cells are receiving the string value "REM Populate the data". You're displaying a different caption for each cell, but any additional code you might write that would want to refer to the actual cell value (such as calls to SetFocusForVariable and the like) will not work correctly unless you pass in the unique cell value to the Cell component, like so: Code:
"REM Populate the data" HelloTable_HelloTableClass(theHelloTable, theRowHeader, theColumnHeader) theDataCells ... Code:
"REM Show the recording quality's format" theDataCells (untitled Text widget) Code:
public List<String> getRestColHeaders() { List<String> l = new List<String>(); l.add("CH1"); l.add("CH2"); return l; } Code:
public List<String> getRestColHeaders() { return java.util.Arrays.asList("CH1", "CH2"); }
__________________
-- Greg |
#7
|
|||
|
|||
Ok, another go at it.... (Maybe the last? )
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
SageTV display cutoff using secondary display | chrishallowell | SageTV Software | 1 | 02-09-2008 08:44 AM |
After Upgrade, Sage Client Will not display CC Data | DocLove | SageTV Software | 5 | 04-05-2005 08:25 PM |
Dual Display & forcing Sage into Other Display | PaulG | SageTV Software | 12 | 09-27-2004 04:14 PM |