View Javadoc
1   /*
2    * Copyright (c) 2005, The JUNG Authors
3    * All rights reserved.
4    * 
5    * This software is open-source under the BSD license; see either "license.txt"
6    * or https://github.com/jrtom/jung/blob/master/LICENSE for a description.
7    * 
8    * Created on Oct 9, 2004
9    *
10    */
11  package edu.uci.ics.jung.visualization.layout;
12  
13  import java.awt.geom.Point2D;
14  import java.io.IOException;
15  import java.io.Serializable;
16  
17  import edu.uci.ics.jung.algorithms.layout.Layout;
18  
19  /**
20   * interface for PersistentLayout
21   * Also holds a nested class Point to serialize the
22   * Vertex locations
23   * 
24   * @author Tom Nelson 
25   */
26  public interface PersistentLayout<V, E> extends Layout<V,E> {
27      
28      void persist(String fileName) throws IOException;
29  
30      void restore(String fileName) throws IOException, ClassNotFoundException;
31      
32      void lock(boolean state);
33      
34      /**
35       * a serializable class to save locations
36       */
37      @SuppressWarnings("serial")
38  	static class Point implements Serializable {
39          public double x;
40          public double y;
41          public Point(double x, double y) {
42              this.x=x;
43              this.y=y;
44          }
45          public Point(Point2D p) {
46          	this.x = p.getX();
47          	this.y = p.getY();
48          }
49      }
50  
51  }