Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for complex types - basic implemented #348

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ of HDF5 and HDF4. Previous releases of HDFView that were based on HDF5 1.8,
| 3.3.0 | 1.14.0 | 4.2.16 | HDF5 1.12 (new-style) references, Single-Writer/Multiple-Readers (SWMR) reads, bug fixes |
| 3.3.1 | 1.14.2 | 4.2.16-2 | Fixes a critical HDF4 + HDFView bug |
| 3.3.2 | 1.14.4 | 4.3.0 | Float16 support |
| 3.3.3 | 1.16.0 | 4.4.0 | Complex number support |
| 3.4.0 | 2.0.0 | 4.4.0 | Complex number support |


PREVIOUS RELEASES AND SOURCE CODE
Expand Down
2 changes: 1 addition & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@
<property name="release.dir" value="${build.dir}/HDF_Group/${ant.project.name}/${app.version}" />
<property name="includeantruntime" value="false" />
<property name="jre.version" value="${ant.java.version}" />
<property name="version.slf4j" value="-2.0.6" />
<property name="version.slf4j" value="-2.0.16" />

<!-- Define the SonarQube global properties (the most usual way is to pass these properties via the command line) -->
<property name="sonar.host.url" value="http://localhost:9000" />
Expand Down
Binary file added lib/extra/slf4j-api-2.0.16-javadoc.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed lib/extra/slf4j-api-2.0.6-javadoc.jar
Binary file not shown.
Binary file removed lib/extra/slf4j-api-2.0.6-sources.jar
Binary file not shown.
Binary file removed lib/extra/slf4j-api-2.0.6.jar
Binary file not shown.
Binary file added lib/extra/slf4j-nop-2.0.16-javadoc.jar
Binary file not shown.
Binary file added lib/extra/slf4j-nop-2.0.16-sources.jar
Binary file not shown.
Binary file added lib/extra/slf4j-nop-2.0.16.jar
Binary file not shown.
Binary file removed lib/extra/slf4j-nop-2.0.6-javadoc.jar
Binary file not shown.
Binary file removed lib/extra/slf4j-nop-2.0.6-sources.jar
Binary file not shown.
Binary file removed lib/extra/slf4j-nop-2.0.6.jar
Binary file not shown.
Binary file added lib/extra/slf4j-simple-2.0.16-javadoc.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed lib/extra/slf4j-simple-2.0.6-javadoc.jar
Binary file not shown.
Binary file removed lib/extra/slf4j-simple-2.0.6-sources.jar
Binary file not shown.
Binary file removed lib/extra/slf4j-simple-2.0.6.jar
Binary file not shown.
Binary file added lib/slf4j-api-2.0.16.jar
Binary file not shown.
Binary file removed lib/slf4j-api-2.0.6.jar
Binary file not shown.
Binary file added lib/slf4j-nop-2.0.16.jar
Binary file not shown.
Binary file removed lib/slf4j-nop-2.0.6.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ else if (dtype.isOpaque() || dtype.isBitField())
converter = new BitfieldDataDisplayConverter(dtype);
else if (dtype.isRef())
converter = new RefDataDisplayConverter(dtype);
else if (dtype.isComplex())
converter = new ComplexDataDisplayConverter(dtype);
}
catch (Exception ex) {
log.debug(
Expand Down Expand Up @@ -963,4 +965,141 @@ public Object canonicalToDisplayValue(Object value)
return buffer;
}
}

private static class ComplexDataDisplayConverter extends HDFDisplayConverter {
private static final Logger log = LoggerFactory.getLogger(ComplexDataDisplayConverter.class);

private final HDFDisplayConverter baseTypeConverter;
private final StringBuilder buffer;

ComplexDataDisplayConverter(final Datatype dtype) throws Exception
{
super(dtype);

if (!dtype.isComplex()) {
log.debug("exit: datatype is not a complex type");
throw new Exception("ComplexDataDisplayConverter: datatype is not a complex type");
}

Datatype baseType = dtype.getDatatypeBase();

if (baseType == null) {
log.debug("exit: base datatype is null");
throw new Exception("ComplexDataDisplayConverter: base datatype is null");
}

try {
baseTypeConverter = getDataDisplayConverter(baseType);

/*
* Make base datatype converter inherit the data conversion settings.
*/
baseTypeConverter.setShowAsHex(this.showAsHex);
baseTypeConverter.setShowAsBin(this.showAsBin);
baseTypeConverter.setNumberFormat(this.numberFormat);
baseTypeConverter.setConvertEnum(this.isEnumConverted);
}
catch (Exception ex) {
log.debug("exit: couldn't get DataDisplayConverter for base datatype: ", ex);
throw new Exception(
"ComplexDataDisplayConverter: couldn't get DataDisplayConverter for base datatype: " +
ex.getMessage());
}

buffer = new StringBuilder();
}

@Override
public Object canonicalToDisplayValue(ILayerCell cell, IConfigRegistry configRegistry, Object value)
{
cellRowIdx = cell.getRowIndex();
cellColIdx = cell.getColumnIndex();
log.trace("canonicalToDisplayValue({}): cellRowIdx={} cellRowIdx={}", value, cellRowIdx,
cellRowIdx);
return canonicalToDisplayValue(value);
}

@Override
public Object canonicalToDisplayValue(Object value)
{
log.trace("canonicalToDisplayValue({}): start", value);

if (value instanceof String)
return value;

if (value == null) {
log.debug("canonicalToDisplayValue({}): value is null", value);
return DataFactoryUtils.nullStr;
}

buffer.setLength(0); // clear the old string

/*
* Pass the cell's row and column index down in case there is a CompoundDataDisplayConverter at
* the bottom of the chain.
*/
baseTypeConverter.cellRowIdx = cellRowIdx;
baseTypeConverter.cellColIdx = cellColIdx;

try {
Object obj;
Object convertedValue;
int arrLen = Array.getLength(value);

log.trace("canonicalToDisplayValue({}): array length={}", value, arrLen);

for (int i = 0; i < arrLen; i++) {
if (i > 0)
buffer.append("+");

obj = Array.get(value, i);

convertedValue = baseTypeConverter.canonicalToDisplayValue(obj);

buffer.append(convertedValue);
}

buffer.append("i");
}
catch (Exception ex) {
log.debug("canonicalToDisplayValue({}): failure: ", value, ex);
buffer.setLength(0);
buffer.append(DataFactoryUtils.errStr);
}

return buffer;
}

@Override
public void setNumberFormat(NumberFormat format)
{
super.setNumberFormat(format);

baseTypeConverter.setNumberFormat(format);
}

@Override
public void setShowAsHex(boolean asHex)
{
super.setShowAsHex(asHex);

baseTypeConverter.setShowAsHex(asHex);
}

@Override
public void setShowAsBin(boolean asBin)
{
super.setShowAsBin(asBin);

baseTypeConverter.setShowAsBin(asBin);
}

@Override
public void setConvertEnum(boolean convert)
{
super.setConvertEnum(convert);

baseTypeConverter.setConvertEnum(convert);
}
}
}
Loading