本文整理汇总了Java中org.dcm4che2.data.DicomElement类的典型用法代码示例。如果您正苦于以下问题:Java DicomElement类的具体用法?Java DicomElement怎么用?Java DicomElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DicomElement类属于org.dcm4che2.data包,在下文中一共展示了DicomElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: matches
import org.dcm4che2.data.DicomElement; //导入依赖的package包/类
@Override
public boolean matches(DicomElement el)
{
if (el == null)
{
return false; // unless the value should/must be null/empty
// string,etc.
}
if (el.tag() != tagNr)
return false;
String valStr = DicomWrapper.element2String(el, null);
int result = StringUtil.compare(valStr, theValue, ignoreCase);
logger.debugPrintf("MinMaxFilter:Checking: <%s>('%s'=='%s') == %d \n",
DicomUtil.getTagName(tagNr), valStr, theValue, result);
return (result == 0);
}
示例2: getTagNames
import org.dcm4che2.data.DicomElement; //导入依赖的package包/类
public List<String> getTagNames(boolean sort)
{
StringList names = new StringList();
Iterator<DicomElement> it = dicom.datasetIterator();
for (DicomElement el = null; it.hasNext();)
{
el = it.next(); //
String name = DicomUtil.getTagName(el.tag());
// unknown tag:
if (name != null)
names.add(name);
// else
// names.add("#0x"+Integer.toHexString(el.tag()));
}
if (sort)
names.sort(true);
return names;
}
示例3: getDateTime
import org.dcm4che2.data.DicomElement; //导入依赖的package包/类
/**
* Returns combination of a Date and a Time tag in one Java Data object.
*/
public Date getDateTime(int dateTag, int timeTag)
{
// need at least a date tag:
DicomElement dateVal = dicom.get(dateTag);
if (dateVal == null)
return null;
// optional:
DicomElement timeVal = dicom.get(timeTag);
if (timeVal == null)
{
return element2Date(dateVal);
}
else
{
return element2DateTime(dateVal, timeVal, getTimeZone());
}
}
示例4: getTimeZone
import org.dcm4che2.data.DicomElement; //导入依赖的package包/类
/**
* Returns TimeZone or default TimeZone if not set in the Dicom File
*/
public TimeZone getTimeZone()
{
DicomElement tzOffset = dicom.get(Tag.TimezoneOffsetFromUTC);
if (tzOffset == null)
{
return defaultTZ; // TimeZone.getDefault(); //
// TimeZone.getTimeZone("UTC");
}
String tzStr = element2String(tzOffset, null);
// [+|-]HHMM
// int tzInt=element2Int(tzOffset, 0);
char c = tzStr.charAt(0);
if ((c != '-') && (c != '+'))
tzStr = "+" + tzStr;
TimeZone tz = TimeZone.getTimeZone("GMT" + tzStr);
return tz;
}
示例5: setTag
import org.dcm4che2.data.DicomElement; //导入依赖的package包/类
/**
* Write integer or other short value. Auto converts to actual VR type
*
* @throws Exception
*/
public void setTag(int tagNr, int intValue) throws Exception
{
if (this.canModify == false)
throw new Exception("Unmodifyable Dicom");
DicomElement el = this.dicom.get(tagNr);
VR vr;
if (el != null)
vr = el.vr();
else
vr = DicomUtil.getVRofTag(tagNr);
dicom.putInt(tagNr, vr, intValue);
this.isModified = true;
}
示例6: setDateValue
import org.dcm4che2.data.DicomElement; //导入依赖的package包/类
public void setDateValue(int tagNr, Date date) throws Exception
{
if (this.canModify == false)
throw new Exception("Unmodifyable Dicom");
// check float ?
DicomElement el = this.dicom.get(tagNr);
VR vr;
if (el != null)
vr = el.vr();
else
vr = DicomUtil.getVRofTag(tagNr);
// Assert Date/Time ?
dicom.putDate(tagNr, vr, date);
this.isModified = true;
}
示例7: element2Int
import org.dcm4che2.data.DicomElement; //导入依赖的package包/类
/**
* Returns Integer value, as Java Integer Object, of element or NULL(!) if not defined.
*/
public static Integer element2Int(DicomElement el)
{
if (el == null)
{
return null;
}
byte bytes[] = el.getBytes();
// happens in SPI files! Element is set, but NO bytes.
if ((bytes == null) || (bytes.length <= 0))
{
return null;
}
return el.vr().toInt(bytes, el.bigEndian());
}
示例8: setDateTo01jan1900
import org.dcm4che2.data.DicomElement; //导入依赖的package包/类
protected void setDateTo01jan1900(DicomElement el, boolean skipIfNotSet) throws Exception
{
int tagNr = el.tag();
Date date = DicomWrapper.element2Date(el);
if (date == null)
{
if (skipIfNotSet)
return;
date = Presentation.now();
// already anonimized: field is null!
logger.warnPrintf("setDateTo01jan1900(): Date is already NULL (element=%s)\n", el.toString());
}
GregorianCalendar cal = new GregorianCalendar();
cal.setTime(date);
int year = 1900;
int month = Calendar.JANUARY; // cal.get(Calendar.Calendar.MONTH);
int day = 1; // cal.get(Calendar.DAY_OF_MONTH);
cal.set(year, month, day);
date = cal.getTime();
dicom.setDateValue(tagNr, date);
}
示例9: setDateTo01jan1950
import org.dcm4che2.data.DicomElement; //导入依赖的package包/类
protected void setDateTo01jan1950(DicomElement el, boolean skipIfNotSet) throws Exception
{
int tagNr = el.tag();
Date date = DicomWrapper.element2Date(el);
if (date == null)
{
if (skipIfNotSet)
return;
date = Presentation.now();
// already anonimized: field is null!
logger.warnPrintf("setDateTo01jan1950():Date is already NULL (element=%s)\n", el.toString());
return;
}
GregorianCalendar cal = new GregorianCalendar();
cal.setTime(date);
int year = 1950;
int month = Calendar.JANUARY; // cal.get(Calendar.Calendar.MONTH);
int day = 1; // cal.get(Calendar.DAY_OF_MONTH);
cal.set(year, month, day);
date = cal.getTime();
dicom.setDateValue(tagNr, date);
}
示例10: setDateTo01Jan
import org.dcm4che2.data.DicomElement; //导入依赖的package包/类
protected void setDateTo01Jan(DicomElement el, boolean skipIfNotSet) throws Exception
{
int tagNr = el.tag();
Date date = DicomWrapper.element2Date(el);
if (date == null)
{
if (skipIfNotSet)
return;
date = Presentation.now();
// already anonimized: field is null!
logger.warnPrintf("setDateTo01Jan():Date is already NULL (element=%s)\n", el.toString());
}
GregorianCalendar cal = new GregorianCalendar();
cal.setTime(date);
int year = cal.get(Calendar.YEAR);
int month = Calendar.JANUARY;// Note January is Month 0!
// month=cal.get(Calendar.Calendar.MONTH);
int day = 1; // cal.get(Calendar.DAY_OF_MONTH);
cal.set(year, month, day);
date = cal.getTime();
dicom.setDateValue(tagNr, date);
}
示例11: doEncryptTag
import org.dcm4che2.data.DicomElement; //导入依赖的package包/类
protected void doEncryptTag(DicomElement el) throws Exception
{
int tagNr = el.tag();
VRType vrType = VRType.valueOf(el.vr());
if (vrType.isString())
{
String newValue = null;
String strValue = DicomWrapper.element2String(el, null);
newValue = crypter.encryptToBase64(strValue);
dicom.setTag(tagNr, newValue);
logger.debugPrintf("> CRYPT RESULT:%s\n", dicom.getElement(tagNr));
}
// else if (vrType.isBinary()) {} // could encrypt bytes here.
else
{
// number values could be encrypted and stored as encrypted
// numerical value;
throw new Exception("Cannot encrypt non String tags!:" + el);
}
}
示例12: hashUIDTag
import org.dcm4che2.data.DicomElement; //导入依赖的package包/类
/**
* Hash the UID and convert the hash bytes back to an UID like (dotted decimal) String.
*/
protected void hashUIDTag(DicomElement el) throws Exception
{
int tagNr = el.tag();
VRType vrType = VRType.valueOf(el.vr());
if (vrType.isString())
{
String uid = DicomWrapper.element2String(el, null);
// 32 bytes hash (SHA-256 = 256 bits)
byte hashBytes[] = hash(uid);
String hashedUid = hashToUidString(hashBytes);
dicom.setTag(tagNr, hashedUid);
logger.debugPrintf("> HASH UID RESULT:%s\n", dicom.getElement(tagNr));
}
else
throw new Exception("Cannot hash non String tags (yet) !:" + el);
}
示例13: doEncryptAndHashUIDTag
import org.dcm4che2.data.DicomElement; //导入依赖的package包/类
protected void doEncryptAndHashUIDTag(DicomElement el) throws Exception
{
int tagNr = el.tag();
VRType vrType = VRType.valueOf(el.vr());
if (vrType.isString())
{
byte cryptBytes[] = null;
String strValue = DicomWrapper.element2String(el, null);
// first encrypt, then hash, then UID encode.
cryptBytes = crypter.encrypt(strValue);
byte hashBytes[] = hash(cryptBytes);
String hashedUid = hashToUidString(hashBytes);
dicom.setTag(tagNr, hashedUid);
logger.debugPrintf("> CRYPT&HASH UID RESULT:%s\n", dicom.getElement(tagNr));
}
// else if (vrType.isBinary()) {} // could encrypt bytes here.
else
{
// number values could be encrypted and stored as encrypted
// numerical value;
throw new Exception("Cannot encrypt non String tags!:" + el);
}
}
示例14: outFragment
import org.dcm4che2.data.DicomElement; //导入依赖的package包/类
private void outFragment(DicomInputStream in) throws IOException {
// System.out.println("outFragment");
outTag(in);
outLen(in);
in.readValue(in);
DicomElement sq = in.sq();
byte[] data = sq.removeFragment(0);
boolean bigEndian = in.getTransferSyntax().bigEndian();
line.append(" [-------");
sq.vr().promptValue(data, bigEndian, null, cbuf, maxValLen, line);
line.append("-------------]");
outLine(in);
}
示例15: promptStgCmt
import org.dcm4che2.data.DicomElement; //导入依赖的package包/类
private static void promptStgCmt(DicomObject cmtrslt, float seconds) {
DicomElement refSOPSq = cmtrslt.get(Tag.ReferencedSOPSequence);
System.out.print(refSOPSq.countItems());
System.out.println(" successful");
DicomElement failedSOPSq = cmtrslt.get(Tag.FailedSOPSequence);
if (failedSOPSq != null) {
System.out.print(failedSOPSq.countItems());
System.out.println(" FAILED!");
}
}