App
ContrastLUTLayer.java
Go to the documentation of this file.
1 package mhr.appcore.image.layers.lut;
2 
3 import org.w3c.dom.Document;
4 import org.w3c.dom.Element;
5 
6 import mhr.appcore.bitmap.NBitmap;
7 import mhr.appcore.bitmap.exceptions.BitmapAllocationException;
8 import mhr.appcore.bitmap.exceptions.UnsupportedBitmapException;
9 import mhr.appcore.exceptions.AlreadyDisposedException;
10 import mhr.appcore.image.Image;
11 import mhr.appcore.image.exceptions.InvalidLayerSpecificPresentationSuppliedException;
12 import mhr.appcore.image.exceptions.LayerCreationException;
13 import mhr.appcore.image.layers.ColorLayer;
14 import mhr.appcore.image.layers.Layer;
15 import mhr.appcore.image.layers.LayerPDInfo;
16 import mhr.appcore.image.layers.LayerType;
17 import mhr.appcore.interfaces.ImageFile;
18 import mhr.appcore.pointops.LUT;
19 import mhr.appcore.pointops.LUTAllocationException;
20 import mhr.appcore.utils.Rect;
21 
25 public class ContrastLUTLayer extends LUTLayer {
26 
27  //===== INTERFACES, CLASSES, ENUMS ==========================================================================================================//
28  //----- NON-PUBLIC --------------------------------------------------------------------------------------------------------------------------//
29  //----- PUBLIC ------------------------------------------------------------------------------------------------------------------------------//
30 
31  //===== FIELDS ==============================================================================================================================//
32  //----- NON-PUBLIC --------------------------------------------------------------------------------------------------------------------------//
33  protected double bias = 0;
34  //----- PUBLIC ------------------------------------------------------------------------------------------------------------------------------//
35 
36  //===== CONSTRUCTORS, DESTRUCTORS, RELATED METHODS ==========================================================================================//
37  //----- NON-PUBLIC --------------------------------------------------------------------------------------------------------------------------//
38  @Override
39  protected void finalize() throws Throwable {
40  dispose();
41  super.finalize();
42  }
43 
44  protected ContrastLUTLayer(ContrastLUTLayer l, int newId) {
45  super(l, newId);
47  }
48  //----- PUBLIC ------------------------------------------------------------------------------------------------------------------------------//
58  super(owner, id);
60  }
61 
62  public ContrastLUTLayer(Image owner, Element i, ImageFile f) {
63  super(owner, i, f);
64  try {
65  bias = Double.parseDouble(i.getElementsByTagName("Bias").item(0).getTextContent());
66  } catch (Exception e) {
67  throw new LayerCreationException(e);
68  }
69 
71  }
72 
73  @Override
74  public synchronized int dispose() {
75  super.dispose();
76  return 0;
77  }
78 
79  //===== METHODS =============================================================================================================================//
80  //----- NON-PUBLIC --------------------------------------------------------------------------------------------------------------------------//
81  protected void fillSpecificElement(Document d, ImageFile f, Element e) {
82  appendLeafElement(d, e, "Bias", Double.toString(bias));
83  }
84 
85  //----- PUBLIC ------------------------------------------------------------------------------------------------------------------------------//
86 
87  @Override
88  public Layer duplicate(int newId) {
89  return new ContrastLUTLayer(this, newId);
90  }
91 
92  @Override
93  public LayerType getType() {
95  }
96 
97 
98 //----- Pole --------------------------------------------------------------------------------------------------------------------------------//
99 
100 //----- Accessory a primitivní metody -------------------------------------------------------------------------------------------------------//
101 
102 //----- Pomocné metody ----------------------------------------------------------------------------------------------------------------------//
103 //----- Konstruktory ------------------------------------------------------------------------------------------------------------------------//
104 
105 //----- Destruktory -------------------------------------------------------------------------------------------------------------------------//
106 
107 //----- Metody ------------------------------------------------------------------------------------------------------------------------------//
108 
109  @Override
110  protected void updateSpecificData(LayerPDInfo info) {
112  p.bias = bias;
113  info.extra = p;
114  }
115 
116  @Override
117  public void updateFromSpecificPresentation(LayerPDInfo presentation) {
118  if (!(presentation.extra instanceof ContrastLUTLayerSpecificPresentation)) {
119  throw new InvalidLayerSpecificPresentationSuppliedException("Invalid specific data supplied");
120  }
121  ContrastLUTLayerSpecificPresentation p = (ContrastLUTLayerSpecificPresentation) presentation.extra;
122  bias = p.bias;
123  if (lut != null) {
124  lut.dispose();
125  }
127 
128  presentation.isChanged = true;
129  }
130 }