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    
8    public class LibraryUserRep implements LibraryUser {
9    
10     CartoFrame frame = null;
11     Class targetclass = Box.class;;
12   
13     public LibraryUserRep(CartoFrame frame,Class targetclass) {
14       this.frame = frame;
15       this.targetclass = targetclass;
16     }
17   
18     public LibraryUserRep(CartoFrame frame) {
19       this.frame = frame;
20     }
21   
22     public void libSymbol(Symbol sym) {
23       if (frame.lastselected==null) return;
24       if (sym==null) throw new NullPointerException("Null library symbol");
25       CompPane pane = ((CompEditor)frame.lastselected).pane;
26   //    if (pane.selection.isEmpty()) return;
27   
28       if (targetclass==Fill.class) {
29         pane.setFill(new Fill(sym));
30       }
31       else {
32         pane.setMode(CompPane.NEW);
33         pane.newtype = targetclass;
34         sym.stripSurveys();
35         pane.newarg = sym;
36         ((CompEditor)frame.lastselected).setMode(CompPane.NEW);
37       }
38     }
39   
40     public Symbol libSave() {
41       if (frame.lastselected==null) return(null);
42       CompPane pane = ((CompEditor)frame.lastselected).pane;
43       if (pane.sel.selection.isEmpty()) return(null);
44       Comp savesym = new Comp();
45       savesym.members = pane.contents.sortSet(pane.sel.selection);
46       return(savesym);
47     }
48   
49   }
50