1    /*
2    Copyright 2000 by Ralph Hartley
3    This software is licenced under the terms of the
4    Gnu Public Licence
5    */
6    import java.util.*;
7    import java.io.*;
8    import java.awt.*;
9    import javax.swing.*;
10   
11   public class Layer extends FileDefaultable implements Serializable{
12   
13     private static final long serialVersionUID = Version.getSUID();
14   
15     static public String ALL = "All";
16     static public String NONE = "None";
17   
18     static public Layer all;
19     static public Layer none;
20   
21     public static TreeSet defaults;
22     public static TreeSet mindefaults = new TreeSet();
23     public static TreeSet file = new TreeSet();
24     public static TreeSet fixed = new TreeSet();
25   
26     public String name;
27   
28     static {
29       fixed.add(all=new Layer(ALL));
30       fixed.add(none = new Layer(NONE));
31   
32       fixed.add(new LayerClass(Curve.class));
33       fixed.add(new LayerClass(Line.class));
34       fixed.add(new LayerClass(Vertex.class));
35       fixed.add(new LayerClass(Segment.class));
36       fixed.add(new LayerClass(Survey.class));
37       fixed.add(new LayerClass(PointSym.class));
38       fixed.add(new LayerClass(Sub.class));
39       fixed.add(new LayerClass(Box.class));
40       fixed.add(new LayerClass(Page.class));
41       fixed.add(new LayerClass(Glyph.class));
42   //    fixed.add(new LayerClass(Stamp.class));
43       fixed.add(new LayerClass(Text.class));
44       fixed.add(new LayerClass(String.class));
45   
46       fixed.add(new LayerProb(0.25));
47       fixed.add(new LayerProb(0.5));
48       fixed.add(new LayerProb(0.75));
49   
50       defaults = (TreeSet)mindefaults.clone();
51   
52       fixedmap.put(Layer.class,fixed);
53       defmap.put(Layer.class,defaults);
54   
55       mindefaults.add(new LayerList("In"));
56       mindefaults.add(new LayerList("Out",new Vector()));
57   
58       minmap.put(Layer.class,mindefaults);
59       filemap.put(Layer.class,file);
60     }
61   
62     public Object clone() {
63       return((Object)new Layer(name));
64     }
65   
66     public void copy(FileDefaultable thatitem) {
67       name = thatitem.getName();
68     }
69   
70     public Layer(String name) {
71       this.name=name;
72     }
73   
74     Layer() {}
75   
76     public String getName() {return(name);}
77   
78     public boolean edit(JFrame owner) {
79       JOptionPane.showMessageDialog(owner,
80           			 name+" can not be edited."+
81           			 "\nIt is a special Layer with properties that are"+
82           			 "\npredefined and unchangable", 
83           			 "No Edit",
84           			 JOptionPane.ERROR_MESSAGE);
85       return(false);
86     }
87   
88     public boolean isMember(Object target) {
89       if (this.name.equals(ALL)) return(true);
90       if (this.name.equals(NONE)) return(false);
91       return(false);
92     }
93   
94     public Object readResolve() throws ObjectStreamException {
95       return((Object)getGlobal(Layer.class));
96     }
97   }
98