-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
295 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- develop | ||
pull_request: | ||
branches: | ||
- develop | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up JDK | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: '8' | ||
distribution: 'adopt' | ||
- name: Build | ||
run: mvn --batch-mode --update-snapshots verify |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
src/main/java/org/jnbis/api/model/record/UserDefinedTestingImage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package org.jnbis.api.model.record; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import org.jnbis.internal.record.BaseImageRecord; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* @author TeeSofteis | ||
*/ | ||
public class UserDefinedTestingImage extends BaseImageRecord { | ||
|
||
// 16.003 - 16.005 and 16.013 - 16.998 | ||
@JsonProperty("user_defined_fields") | ||
private Map<Integer, String> userDefinedFields; | ||
|
||
public Map<Integer, String> getUserDefinedFields() { | ||
return userDefinedFields; | ||
} | ||
|
||
public void setUserDefinedFields(Map<Integer, String> userDefinedFields) { | ||
this.userDefinedFields = userDefinedFields; | ||
} | ||
|
||
public void addUserDefinedField(int key, String value) { | ||
if (userDefinedFields == null) { | ||
userDefinedFields = new HashMap<>(); | ||
} | ||
userDefinedFields.put(key, value); | ||
} | ||
|
||
// 16.008 - SLC | ||
@JsonProperty("scale_units") | ||
private String scaleUnits; | ||
|
||
// 16.009 - HPS | ||
@JsonProperty("horizontal_pixel_scale") | ||
private String horizontalPixelScale; | ||
|
||
// 16.010 - VPS | ||
@JsonProperty("vertical_pixel_scale") | ||
private String verticalPixelScale; | ||
|
||
// 16.012 - BPX | ||
@JsonProperty("bits_per_pixel") | ||
private String bitsPerPixel; | ||
|
||
public String getScaleUnits() { | ||
return scaleUnits; | ||
} | ||
|
||
public void setScaleUnits(String scaleUnits) { | ||
this.scaleUnits = scaleUnits; | ||
} | ||
|
||
public String getHorizontalPixelScale() { | ||
return horizontalPixelScale; | ||
} | ||
|
||
public void setHorizontalPixelScale(String horizontalPixelScale) { | ||
this.horizontalPixelScale = horizontalPixelScale; | ||
} | ||
|
||
public String getVerticalPixelScale() { | ||
return verticalPixelScale; | ||
} | ||
|
||
public void setVerticalPixelScale(String verticalPixelScale) { | ||
this.verticalPixelScale = verticalPixelScale; | ||
} | ||
|
||
public String getBitsPerPixel() { | ||
return bitsPerPixel; | ||
} | ||
|
||
public void setBitsPerPixel(String bitsPerPixel) { | ||
this.bitsPerPixel = bitsPerPixel; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
src/main/java/org/jnbis/internal/record/reader/UserDefinedTestingImageReader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package org.jnbis.internal.record.reader; | ||
|
||
import org.jnbis.internal.NistHelper; | ||
import org.jnbis.api.model.record.UserDefinedTestingImage; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
|
||
/** | ||
* @author TeeSofteis | ||
*/ | ||
public class UserDefinedTestingImageReader extends RecordReader { | ||
@Override | ||
public UserDefinedTestingImage read(NistHelper.Token token) { | ||
if (token.pos >= token.buffer.length) { | ||
throw new RuntimeException("T16::NULL pointer to T16 record"); | ||
} | ||
|
||
UserDefinedTestingImage userDefinedTestingImage = new UserDefinedTestingImage(); | ||
|
||
int start = token.pos; | ||
|
||
NistHelper.Tag tag = getTagInfo(token); | ||
if (tag.field != 1) { | ||
throw new RuntimeException("T16::Invalid Record type = " + tag.type); | ||
} | ||
|
||
Integer length = Integer.parseInt(nextWord(token, NistHelper.TAG_SEP_GSFS, NistHelper.FIELD_MAX_LENGTH - 1, false)); | ||
userDefinedTestingImage.setLogicalRecordLength(length.toString()); | ||
|
||
while (true) { | ||
token.pos++; | ||
tag = getTagInfo(token); | ||
|
||
if (tag.field == 999) { | ||
byte[] data = new byte[length - (token.pos - start)]; | ||
System.arraycopy(token.buffer, token.pos, data, 0, data.length); | ||
token.pos = token.pos + data.length; | ||
userDefinedTestingImage.setImageData(data); | ||
break; | ||
} | ||
|
||
String word = nextWord(token, NistHelper.TAG_SEP_GSFS, NistHelper.FIELD_MAX_LENGTH - 1, false); | ||
switch (tag.field) { | ||
case 1: | ||
userDefinedTestingImage.setLogicalRecordLength(word); | ||
break; | ||
case 2: | ||
userDefinedTestingImage.setImageDesignationCharacter(word); | ||
break; | ||
case 6: | ||
userDefinedTestingImage.setHorizontalLineLength(word); | ||
break; | ||
case 7: | ||
userDefinedTestingImage.setVerticalLineLength(word); | ||
break; | ||
case 8: | ||
userDefinedTestingImage.setScaleUnits(word); | ||
break; | ||
case 9: | ||
userDefinedTestingImage.setHorizontalPixelScale(word); | ||
break; | ||
case 10: | ||
userDefinedTestingImage.setVerticalPixelScale(word); | ||
break; | ||
case 11: | ||
userDefinedTestingImage.setCompressionAlgorithm(word); | ||
break; | ||
case 12: | ||
userDefinedTestingImage.setBitsPerPixel(word); | ||
break; | ||
default: | ||
if ((2 < tag.field && tag.field < 6) || (12 < tag.field && tag.field < 999)) { | ||
// User defined fields could be found at tag 3-5 and 13-998. As the name implies, | ||
// it is not obvious which format the data has. From my point of view, the best | ||
// solution is to handle the data as an array of text, therefore split data into | ||
// sub fields and items as you need. | ||
userDefinedTestingImage.addUserDefinedField(tag.field, word); | ||
} | ||
break; | ||
} | ||
} | ||
return userDefinedTestingImage; | ||
} | ||
} |
Oops, something went wrong.