App
BrightnessLUTLayer.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.BitmapInfo;
7 import mhr.appcore.bitmap.ChannelCount;
8 import mhr.appcore.bitmap.ColorMode;
9 import mhr.appcore.bitmap.NBitmap;
10 import mhr.appcore.bitmap.exceptions.BitmapAllocationException;
11 import mhr.appcore.bitmap.exceptions.UnsupportedBitmapException;
12 import mhr.appcore.blending.BlendMode;
13 import mhr.appcore.exceptions.AlreadyDisposedException;
14 import mhr.appcore.image.Image;
15 import mhr.appcore.image.exceptions.InvalidLayerSpecificPresentationSuppliedException;
16 import mhr.appcore.image.exceptions.LayerCreationException;
17 import mhr.appcore.image.layers.Layer;
18 import mhr.appcore.image.layers.LayerPDInfo;
19 import mhr.appcore.image.layers.LayerType;
20 import mhr.appcore.interfaces.ImageFile;
21 import mhr.appcore.interfaces.PDBitmap;
22 import mhr.appcore.pointops.LUT;
23 import mhr.appcore.pointops.LUTAllocationException;
24 import mhr.appcore.utils.Rect;
25 
29 public class BrightnessLUTLayer extends LUTLayer {
30 
31  //===== INTERFACES, CLASSES, ENUMS ==========================================================================================================//
32  //----- NON-PUBLIC --------------------------------------------------------------------------------------------------------------------------//
33  //----- PUBLIC ------------------------------------------------------------------------------------------------------------------------------//
34 
35  //===== FIELDS ==============================================================================================================================//
36  //----- NON-PUBLIC --------------------------------------------------------------------------------------------------------------------------//
37  protected double bias = 0;
38  //----- PUBLIC ------------------------------------------------------------------------------------------------------------------------------//
39 
40  //===== CONSTRUCTORS, DESTRUCTORS, RELATED METHODS ==========================================================================================//
41  //----- NON-PUBLIC --------------------------------------------------------------------------------------------------------------------------//
42  @Override
43  protected void finalize() throws Throwable {
44  dispose();
45  super.finalize();
46  }
47 
48 
49  protected BrightnessLUTLayer(BrightnessLUTLayer l, int newId) {
50  super(l, newId);
52  }
53  //----- PUBLIC ------------------------------------------------------------------------------------------------------------------------------//
63  super(owner, id);
65  }
66 
67  public BrightnessLUTLayer(Image owner, Element i, ImageFile f) {
68  super(owner, i, f);
69  try {
70  bias = Double.parseDouble(i.getElementsByTagName("Bias").item(0).getTextContent());
71  } catch (Exception e) {
72  throw new LayerCreationException(e);
73  }
75  }
76 
77  @Override
78  public synchronized int dispose() {
79  super.dispose();
80  return 0;
81  }
82 
83  //===== METHODS =============================================================================================================================//
84  //----- NON-PUBLIC --------------------------------------------------------------------------------------------------------------------------//
85  protected void fillSpecificElement(Document d, ImageFile f, Element e) {
86  appendLeafElement(d, e, "Bias", Double.toString(bias));
87  }
88 
89 
90  //----- PUBLIC ------------------------------------------------------------------------------------------------------------------------------//
91  @Override
92  public Layer duplicate(int newId) {
93  return new BrightnessLUTLayer(this, newId);
94  }
95 
96  @Override
97  public LayerType getType() {
99  }
100 
101 
102 //----- Pole --------------------------------------------------------------------------------------------------------------------------------//
103 
104 //----- Accessory a primitivní metody -------------------------------------------------------------------------------------------------------//
105 
106 //----- Pomocné metody ----------------------------------------------------------------------------------------------------------------------//
107 //----- Konstruktory ------------------------------------------------------------------------------------------------------------------------//
108 
109 //----- Destruktory -------------------------------------------------------------------------------------------------------------------------//
110 
111 //----- Metody ------------------------------------------------------------------------------------------------------------------------------//
112 
113  @Override
114  protected void updateSpecificData(LayerPDInfo info) {
116  p.bias = bias;
117  info.extra = p;
118  }
119 
120  @Override
121  public void updateFromSpecificPresentation(LayerPDInfo presentation) {
122  if (!(presentation.extra instanceof BrightnessLUTLayerSpecificPresentation)) {
123  throw new InvalidLayerSpecificPresentationSuppliedException("Invalid specific data supplied");
124  }
125  BrightnessLUTLayerSpecificPresentation p = (BrightnessLUTLayerSpecificPresentation) presentation.extra;
126  bias = p.bias;
127  if (lut != null) {
128  lut.dispose();
129  }
131 
132  presentation.isChanged = true;
133  }
134 }