App
PDImageDataPresentation.java
Go to the documentation of this file.
1 package mhr.appcore.interfaces;
2 
3 import java.util.ArrayList;
4 import java.util.LinkedList;
5 
6 import mhr.appcore.image.ImageSelectedState;
7 import mhr.appcore.image.exceptions.LayerNotFoundException;
8 import mhr.appcore.image.layers.LayerPDInfo;
9 
15 public abstract class PDImageDataPresentation {
16 
17  //===================================================================================================================================================//
18  //===== PUBLIC ==============================================================================================================================//
19  //----- interface a třídy -------------------------------------------------------------------------------------------------------------------//
20  //----- pole --------------------------------------------------------------------------------------------------------------------------------//
22  public int selectedLayerId;
24  public boolean masterMaskActive;
25 
26  //----- acesory a primitivní metody ---------------------------------------------------------------------------------------------------------//
27  //----- konstruktory ------------------------------------------------------------------------------------------------------------------------//
28  //----- destruktory -------------------------------------------------------------------------------------------------------------------------//
29  //----- metody ------------------------------------------------------------------------------------------------------------------------------//
34  public void addLayerInfo(LayerPDInfo info ) {
35  layers.add(info);
36  }
37 
43  public void addLayerInfo(LayerPDInfo info, int overId) {
44  layers.add(getLayerPosition(overId) + 1, info);
45  }
46 
51  public abstract PDBitmap createLayerThumb();
52 
57  public abstract PDBitmap createMaskThumb();
58 
62  public abstract void hasChanged();
63 
71  for (LayerPDInfo l : layers) {
72  if (l.id == id) {
73  return l;
74  }
75  }
76  throw new LayerNotFoundException("Layer info not found");
77  }
78 
83  public int getLayersCount() {
84  return layers.size();
85  }
86 
92  public void removeLayer(int id) throws LayerNotFoundException {
93  layers.remove(getLayerInfo(id));
94  }
95 
97 
103  public void moveLayer(int id, int beforeId) throws LayerNotFoundException {
104  LayerPDInfo l = getLayerInfo(id);
105  int oldIndex = layers.indexOf(l);
106  int newIndex = (beforeId < 0) ? layers.size() : layers.indexOf(getLayerInfo(beforeId));
107  layers.remove(l);
108  if (oldIndex < newIndex) {
109  newIndex--;
110  }
111  layers.add(newIndex, l);
112  }
113 
118  public ArrayList<LayerPDInfo> getLayers() {
119  return layers;
120  }
121 
122  //===================================================================================================================================================//
123  //===== NON-PUBLIC ==========================================================================================================================//
124  //----- interface a třídy -------------------------------------------------------------------------------------------------------------------//
125  //----- pole --------------------------------------------------------------------------------------------------------------------------------//
126  protected ArrayList<LayerPDInfo> layers = new ArrayList<LayerPDInfo>();
127 
128  //----- acesory a primitivní metody ---------------------------------------------------------------------------------------------------------//
134  protected int getLayerPosition(int id) {
135  LayerPDInfo l = getLayerInfo(id);
136  return layers.indexOf(l);
137  }
138  //----- konstruktory ------------------------------------------------------------------------------------------------------------------------//
139  //----- destruktory -------------------------------------------------------------------------------------------------------------------------//
140  //----- metody ------------------------------------------------------------------------------------------------------------------------------//
141 
142  //===================================================================================================================================================//
143  //===== DEPRECATED ==========================================================================================================================//
144 }