/** * @param ds * @param outFile * @return * @throws IOException */ private RIDResponseObject handleSVG(Dataset ds, BaseDocument doc) throws IOException { OutputStream out = doc.getOutputStream(); try { DcmElement elem = ds.get(Tags.WaveformSeq); WaveformGroup wfgrp = new WaveformGroup( ds.getString(Tags.SOPClassUID), elem, 0, ridSupport.getWaveformCorrection()); // TODO all groups if (log.isDebugEnabled()) log.debug(wfgrp); WaveformInfo wfInfo = new WaveformInfo(ds); SVGCreator svgCreator = new SVGCreator(wfgrp, wfInfo, new Float(27.6f), new Float(20.3f)); svgCreator.toXML(out); out.close(); return new RIDStreamResponseObjectImpl( doc.getInputStream(), CONTENT_TYPE_SVGXML, HttpServletResponse.SC_OK, null); } catch (Throwable t) { if (out != null) try { out.close(); } catch (IOException e) { } log.error("Cant create SVG for Waveform!", t); log.error("Waveform Dataset:"); log.error(ds); return new RIDStreamResponseObjectImpl( null, RIDSupport.CONTENT_TYPE_HTML, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Error while creating waveform SVG! Reason:" + t.getMessage()); } }
/** * @param cuid * @param elem * @return */ private WaveformGroup[] getWaveformGroups(DcmElement elem, String cuid) { float corr = ridSupport.getWaveformCorrection(); int nrOfWFGroups = elem.countItems(); if (nrOfWFGroups == 1) return new WaveformGroup[] {new WaveformGroup(cuid, elem, 0, corr)}; // dont // check // the // only // one ArrayList l = new ArrayList(nrOfWFGroups); for (int i = 0; i < nrOfWFGroups; i++) { try { l.add(new WaveformGroup(cuid, elem, i, corr)); } catch (Exception x) { log.warn("Item " + i + " in Waveform Sequence is not valid! Ignored!!"); } } return (WaveformGroup[]) l.toArray(new WaveformGroup[l.size()]); }