Skip to content

Commit

Permalink
topcat: display array-valued column aux metadata properly.
Browse files Browse the repository at this point in the history
This is a bit of a hack.  The display in the ColumnInfoWindow is not
paying attention to the ValueInfo's formatValue method, which is in
any case not a very good place for that functionality.  But it now
works for scalars and normal arrays.
  • Loading branch information
mbtaylor committed Jul 4, 2013
1 parent d429a0a commit 209c8ec
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
21 changes: 20 additions & 1 deletion table/src/main/uk/ac/starlink/table/DefaultValueInfo.java
Expand Up @@ -286,7 +286,26 @@ public static ValueInfo generalise( ValueInfo vi1, ValueInfo vi2 ) {

/* Otherwise we will need to create a new one with characteristics
* build up from the supplied ones. */
DefaultValueInfo vi = new DefaultValueInfo( vi1 );
DefaultValueInfo vi = new DefaultValueInfo( vi1 ) {
public String formatValue( Object obj, int leng ) {
try {
return super.formatValue( obj, leng );
}
catch ( RuntimeException e ) {
String rep = String.valueOf( obj );
return rep.length() > leng ? rep.substring( 0, leng )
: rep;
}
}
public Object unformatString( String rep ) {
try {
return super.unformatString( rep );
}
catch ( RuntimeException e ) {
return null;
}
}
};

/* Cancel the units if not consistent. */
if ( vi1.getUnitString() != null &&
Expand Down
8 changes: 8 additions & 0 deletions topcat/src/docs/sun253.xml
Expand Up @@ -18190,6 +18190,14 @@ introduced since the last version:
</dl>
</p></dd>

<dt>Next Version</dt>
<dd><p>
<ul>
<li>Array-valued per-column extra metadata items is now displayed
properly.</li>
</ul>
</p></dd>

</dl>
</p>

Expand Down
10 changes: 3 additions & 7 deletions topcat/src/main/uk/ac/starlink/topcat/ColumnInfoWindow.java
Expand Up @@ -38,6 +38,7 @@
import uk.ac.starlink.table.DescribedValue;
import uk.ac.starlink.table.UCD;
import uk.ac.starlink.table.ValueInfo;
import uk.ac.starlink.table.gui.NumericCellRenderer;
import uk.ac.starlink.table.gui.StarJTable;
import uk.ac.starlink.table.gui.StarTableColumn;
import uk.ac.starlink.table.gui.TableRowHeader;
Expand Down Expand Up @@ -318,11 +319,7 @@ public boolean isCellEditable( int irow, int icol ) {
/* Construct and place a JTable to contain it. */
jtab = new JTable( metaTableModel ) {
public TableCellRenderer getDefaultRenderer( Class clazz ) {
TableCellRenderer rend = super.getDefaultRenderer( clazz );
if ( rend == null ) {
rend = super.getDefaultRenderer( Object.class );
}
return rend;
return new NumericCellRenderer( clazz );
}
};
jtab.setAutoResizeMode( JTable.AUTO_RESIZE_OFF );
Expand Down Expand Up @@ -588,8 +585,7 @@ public Object getValue( int irow ) {
Object value = auxDatum.getValue();
if ( value != null &&
vclass.isAssignableFrom( value.getClass() ) ) {
return isFormattable ? value
: vinfo.formatValue( value, 64 );
return value;
}
}
return null;
Expand Down

0 comments on commit 209c8ec

Please sign in to comment.