aboutsummaryrefslogtreecommitdiff
path: root/src/GraphTypeHolder.java
blob: 1fcac0983650f13855816a568502809639402fb4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*     */ import java.io.File;
/*     */ import java.io.FileInputStream;
/*     */ import java.io.FileOutputStream;
/*     */ import java.io.IOException;
/*     */ import java.io.ObjectInputStream;
/*     */ import java.io.ObjectOutputStream;
/*     */ import java.io.Serializable;
/*     */ import java.util.ArrayList;
/*     */ 
/*     */ public class GraphTypeHolder
/*     */   implements Serializable
/*     */ {
/*     */   private static final long serialVersionUID = -5227701003145329653L;
/*  21 */   private ArrayList<GraphTypeStateChangedListener> listeners = new ArrayList();
/*  22 */   private Point2DMaker graphType = new Euclidean2DPointMaker();
/*     */   private static GraphTypeHolder instance;
/*     */   private String[] equations;
/*     */ 
/*     */   public GraphTypeHolder()
/*     */   {
/*  27 */     for (int i = 0; i < this.listeners.size(); i++)
/*  28 */       ((GraphTypeStateChangedListener)this.listeners.get(i)).graphTypeChanged(this.graphType);
/*     */   }
/*     */ 
/*     */   public void setGraphPointMaker(Point2DMaker maker) {
/*  32 */     this.graphType = maker;
/*  33 */     fireGraphTypeStateChanged();
/*     */   }
/*     */   public void fireGraphTypeStateChanged() {
/*  36 */     for (int i = 0; i < this.listeners.size(); i++)
/*  37 */       ((GraphTypeStateChangedListener)this.listeners.get(i)).graphTypeChanged(this.graphType);
/*     */   }
/*     */ 
/*     */   public Point2DMaker getGraphPointMaker() {
/*  41 */     return this.graphType;
/*     */   }
/*     */   public void addGraphTypeStateChangedListener(GraphTypeStateChangedListener g) {
/*  44 */     if (g == null) return;
/*  45 */     this.listeners.add(g);
/*     */   }
/*     */   public String[] getEquations() {
/*  48 */     return this.equations;
/*     */   }
/*     */   public void setEquations(String[] equations) {
/*  51 */     this.equations = equations;
/*     */   }
/*     */   public static GraphTypeHolder getInstance() {
/*  54 */     if (instance == null) instance = new GraphTypeHolder();
/*  55 */     return instance;
/*     */   }
/*     */   public void serialize() {
/*  58 */     File file = null;
/*     */     try {
/*  60 */       file = new File(new File(".").getCanonicalFile(), "LastGraph.ser");
/*     */     }
/*     */     catch (IOException e) {
/*  63 */       e.printStackTrace();
/*  64 */       return;
/*     */     }
/*  66 */     FileOutputStream fos = null;
/*  67 */     ObjectOutputStream out = null;
/*     */     try
/*     */     {
/*  70 */       fos = new FileOutputStream(file);
/*  71 */       out = new ObjectOutputStream(fos);
/*  72 */       out.writeObject(this);
/*  73 */       out.close();
/*     */     }
/*     */     catch (IOException ex)
/*     */     {
/*  77 */       ex.printStackTrace();
/*     */     }
/*     */   }
/*     */ 
/*  81 */   private static GraphTypeHolder read() { File file = null;
/*     */     try {
/*  83 */       file = new File(new File(".").getCanonicalFile(), "LastGraph.ser");
/*     */     }
/*     */     catch (IOException e) {
/*  86 */       e.printStackTrace();
/*     */     }
/*     */ 
/*  89 */     FileInputStream fis = null;
/*  90 */     ObjectInputStream in = null;
/*  91 */     GraphTypeHolder ret = null;
/*     */     try
/*     */     {
/*  94 */       fis = new FileInputStream(file);
/*  95 */       in = new ObjectInputStream(fis);
/*  96 */       ret = (GraphTypeHolder)in.readObject();
/*  97 */       in.close();
/*  98 */       return ret;
/*     */     }
/*     */     catch (IOException ex)
/*     */     {
/* 102 */       ex.printStackTrace();
/*     */     }
/*     */     catch (ClassNotFoundException ex)
/*     */     {
/* 106 */       ex.printStackTrace();
/*     */     }
/* 108 */     return null;
/*     */   }
/*     */ }

/* Location:           Modulus.jar
 * Qualified Name:     GraphTypeHolder
 * JD-Core Version:    0.6.2
 */