~cezary-bartosiak/gephi/spread-simulator

« back to all changes in this revision

Viewing changes to ComplexGeneratorPluginUI/src/org/gephi/ui/complexgenerator/plugin/BarabasiAlbertUIImpl.java

  • Committer: Cezary Bartosiak
  • Date: 2011-02-21 07:47:23 UTC
  • mfrom: (2044.4.7 generators)
  • Revision ID: cezary.bartosiak@gmail.com-20110221074723-ul2u6nkg1evjvh0a
* merged with generators

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2008-2010 Gephi
 
3
 * Authors : Cezary Bartosiak
 
4
 * Website : http://www.gephi.org
 
5
 * 
 
6
 * This file is part of Gephi.
 
7
 *
 
8
 * Gephi is free software: you can redistribute it and/or modify
 
9
 * it under the terms of the GNU General Public License as published by
 
10
 * the Free Software Foundation, either version 3 of the License, or
 
11
 * (at your option) any later version.
 
12
 *
 
13
 * Gephi is distributed in the hope that it will be useful,
 
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
 * GNU General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU General Public License
 
19
 * along with Gephi.  If not, see <http://www.gnu.org/licenses/>.
 
20
 */
 
21
package org.gephi.ui.complexgenerator.plugin;
 
22
 
 
23
import javax.swing.JPanel;
 
24
import org.gephi.io.complexgenerator.plugin.BarabasiAlbert;
 
25
import org.gephi.io.complexgenerator.plugin.BarabasiAlbertUI;
 
26
import org.gephi.io.generator.spi.Generator;
 
27
import org.openide.util.lookup.ServiceProvider;
 
28
 
 
29
/**
 
30
 * 
 
31
 *
 
32
 * @author Cezary Bartosiak
 
33
 */
 
34
@ServiceProvider(service = BarabasiAlbertUI.class)
 
35
public class BarabasiAlbertUIImpl implements BarabasiAlbertUI {
 
36
        private BarabasiAlbertPanel panel;
 
37
        private BarabasiAlbert barabasiAlbert;
 
38
 
 
39
        public BarabasiAlbertUIImpl() { }
 
40
 
 
41
        public JPanel getPanel() {
 
42
                if (panel == null)
 
43
                        panel = new BarabasiAlbertPanel();
 
44
                return BarabasiAlbertPanel.createValidationPanel(panel);
 
45
        }
 
46
 
 
47
        public void setup(Generator generator) {
 
48
                this.barabasiAlbert = (BarabasiAlbert)generator;
 
49
 
 
50
                if (panel == null)
 
51
                        panel = new BarabasiAlbertPanel();
 
52
 
 
53
                panel.NField.setText(String.valueOf(barabasiAlbert.getN()));
 
54
                panel.m0Field.setText(String.valueOf(barabasiAlbert.getm0()));
 
55
                panel.MField.setText(String.valueOf(barabasiAlbert.getM()));
 
56
        }
 
57
 
 
58
        public void unsetup() {
 
59
                barabasiAlbert.setN(Integer.parseInt(panel.NField.getText()));
 
60
                barabasiAlbert.setm0(Integer.parseInt(panel.m0Field.getText()));
 
61
                barabasiAlbert.setM(Integer.parseInt(panel.MField.getText()));
 
62
                panel = null;
 
63
        }
 
64
}