private static Predicate<Attributes> isSequenceApplicable(DicomImageElement img) { return attributes -> isModuleAppicable(attributes, img); }
Attributes dcmobj = reader.getDcmobj(); if (dcmobj != null) { Sequence gams = dcmobj.getSequence(Tag.GraphicAnnotationSequence); String graphicLayerName = gram.getString(Tag.GraphicLayer); Attributes glm = glms.get(graphicLayerName); if (glm == null || !PresentationStateReader.isModuleAppicable(gram, img)) { continue; PresentationStateReader.getRGBColor(grayVal == null ? 255 : grayVal, colorLab, colorRgb); float[] lab = CIELab.convertToFloatLab(style.getInts(Tag.PatternOnColorCIELabValue)); if (lab != null) { rgb = PresentationStateReader.getRGBColor(255, lab, (int[]) null);
public static void setShutterColor(Tagable tagable, Attributes attributes) { Integer psVal = (Integer) TagD.get(Tag.ShutterPresentationValue).getValue(attributes); tagable.setTagNoNull(TagW.ShutterPSValue, TagD.get(Tag.ShutterPresentationValue).getValue(attributes)); float[] rgb = CIELab.convertToFloatLab((int[]) TagD.get(Tag.ShutterPresentationColorCIELabValue).getValue(attributes)); Color color = rgb == null ? null : PresentationStateReader.getRGBColor(psVal == null ? 0 : psVal, rgb, (int[]) null); tagable.setTagNoNull(TagW.ShutterRGBColor, color); }
reader.applySpatialTransformationModule(actionsInView); List<PresetWindowLevel> presets = reader.getPresetCollection(img); ImageOpNode node = view.getDisplayOpManager().getNode(WindowOp.OP_NAME); if (node != null) { GraphicModel graphicModel = PrGraphicUtil.getPresentationModel(reader.getDcmobj());
private static Attributes bluildLabelAndAnchor(AnnotationGraphic g) { Rectangle2D bound = g.getLabelBounds(); Point2D anchor = g.getAnchorPoint(); String text = Arrays.stream(g.getLabels()).collect(Collectors.joining("\r\n")); //$NON-NLS-1$ Attributes attributes = new Attributes(7); attributes.setString(Tag.BoundingBoxAnnotationUnits, VR.CS, PIXEL); attributes.setFloat(Tag.AnchorPoint, VR.FL, (float) anchor.getX(), (float) anchor.getY()); attributes.setString(Tag.AnchorPointVisibility, VR.CS, "Y"); //$NON-NLS-1$ Sequence style = attributes.newSequence(Tag.LineStyleSequence, 1); Attributes styles = new Attributes(); styles.setFloat(Tag.LineThickness, VR.FL, g.getLineThickness()); if (g.getColorPaint() instanceof Color) { Color color = (Color) g.getColorPaint(); float[] rgb = PresentationStateReader.colorToLAB(color); if (rgb != null) { styles.setInt(Tag.PatternOnColorCIELabValue, VR.US, CIELab.convertToDicomLab(rgb)); } } style.add(styles); attributes.setDouble(Tag.BoundingBoxTopLeftHandCorner, VR.FL, new double[] { bound.getMinX(), bound.getMinY() }); attributes.setDouble(Tag.BoundingBoxBottomRightHandCorner, VR.FL, new double[] { bound.getMaxX(), bound.getMaxY() }); // In text strings (value representation ST, LT, or UT) a new line shall be represented as CR LF. // see http://dicom.nema.org/medical/dicom/current/output/chtml/part05/chapter_6.html attributes.setString(Tag.UnformattedTextValue, VR.ST, text); return attributes; }
val instanceof PRSpecialElement ? new PresentationStateReader((PRSpecialElement) val) : null; actionsInView.put(PresentationStateReader.TAG_PR_READER, pr); boolean spatialTransformation = actionsInView.get(ActionW.PREPROCESSING.cmd()) != null;
float[] rgb = CIELab.convertToFloatLab(style.getInts(Tag.PatternOnColorCIELabValue)); if (rgb != null) { color = PresentationStateReader.getRGBColor(255, rgb, (int[]) null);
private static void writeGraphics(GraphicModel model, Attributes attributes) { List<GraphicLayer> layers = model.getLayers(); Sequence annotationSeq = attributes.newSequence(Tag.GraphicAnnotationSequence, layers.size()); Sequence layerSeq = attributes.newSequence(Tag.GraphicLayerSequence, layers.size()); for (int i = 0; i < layers.size(); i++) { GraphicLayer layer = layers.get(i); if (layer.getSerializable()) { String layerName = layer.getType().name(); List<Graphic> graphics = getGraphicsByLayer(model, layer.getUuid()); Attributes l = new Attributes(2); l.setString(Tag.GraphicLayer, VR.CS, layerName); l.setInt(Tag.GraphicLayerOrder, VR.IS, i); float[] lab = PresentationStateReader .colorToLAB(Optional.ofNullable(MeasureTool.viewSetting.getLineColor()).orElse(Color.YELLOW)); if (lab != null) { l.setInt(Tag.GraphicLayerRecommendedDisplayCIELabValue, VR.US, CIELab.convertToDicomLab(lab)); } l.setString(Tag.GraphicLayerDescription, VR.LO, layer.toString()); layerSeq.add(l); Attributes a = new Attributes(2); a.setString(Tag.GraphicLayer, VR.CS, layerName); Sequence graphicSeq = a.newSequence(Tag.GraphicObjectSequence, graphics.size()); Sequence textSeq = a.newSequence(Tag.TextObjectSequence, graphics.size()); for (Graphic graphic : graphics) { buildDicomGraphic(graphic, graphicSeq, textSeq); } annotationSeq.add(a); } } }
float[] rgb = CIELab.convertToFloatLab(style.getInts(Tag.PatternOnColorCIELabValue)); if (rgb != null) { color = PresentationStateReader.getRGBColor(255, rgb, (int[]) null);
public static boolean isModuleAppicable(Attributes[] refSeriesSeqParent, DicomImageElement img) { if (refSeriesSeqParent != null) { for (Attributes refImgSeqParent : refSeriesSeqParent) { String seriesUID = TagD.getTagValue(img, Tag.SeriesInstanceUID, String.class); if (seriesUID.equals(refImgSeqParent.getString(Tag.SeriesInstanceUID))) { return isModuleAppicable(refImgSeqParent, img); } } } return false; }
private static Attributes getBasicGraphic(Graphic graphic) { Attributes dcm = new Attributes(5); dcm.setString(Tag.GraphicAnnotationUnits, VR.CS, PIXEL); dcm.setInt(Tag.GraphicDimensions, VR.US, 2); dcm.setString(Tag.GraphicFilled, VR.CS, graphic.getFilled() ? "Y" : "N"); //$NON-NLS-1$ //$NON-NLS-2$ Sequence style = dcm.newSequence(Tag.LineStyleSequence, 1); Attributes styles = new Attributes(); styles.setFloat(Tag.LineThickness, VR.FL, graphic.getLineThickness()); if (graphic.getColorPaint() instanceof Color) { Color color = (Color) graphic.getColorPaint(); float[] rgb = PresentationStateReader.colorToLAB(color); if (rgb != null) { styles.setInt(Tag.PatternOnColorCIELabValue, VR.US, CIELab.convertToDicomLab(rgb)); } } style.add(styles); return dcm; }
Color color1 = PresentationStateReader.getRGBColor(255, null, rgb); Color color2 = new Color(color1.getRed(), color1.getGreen(), color1.getBlue(), structureFillTransparency);
DicomImageElement img = view.getImage(); if (img != null) { if (PresentationStateReader.isModuleAppicable( TagD.getTagValue(specialElement, Tag.ReferencedSeriesSequence, Attributes[].class), img)) {