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