~keheliya-gallaba/gephi/maven-build

« back to all changes in this revision

Viewing changes to ExportPluginUI/src/main/java/org/gephi/ui/exporter/plugin/UIExporterGraphML.java

  • Committer: Keheliya Gallaba
  • Date: 2011-08-01 13:01:30 UTC
  • Revision ID: keheliya.gallaba@gmail.com-20110801130130-0u2qgcufi8bvqwxv
Adding Export Plugin, Export Plugin UI, Filters Impl

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
Copyright 2008-2010 Gephi
 
3
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
 
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 Affero General Public License as
 
10
published by the Free Software Foundation, either version 3 of the
 
11
License, or (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 Affero General Public License for more details.
 
17
 
 
18
You should have received a copy of the GNU Affero General Public License
 
19
along with Gephi.  If not, see <http://www.gnu.org/licenses/>.
 
20
*/
 
21
package org.gephi.ui.exporter.plugin;
 
22
 
 
23
import javax.swing.JPanel;
 
24
import org.gephi.io.exporter.plugin.ExporterGraphML;
 
25
import org.gephi.io.exporter.spi.Exporter;
 
26
import org.gephi.io.exporter.spi.ExporterUI;
 
27
import org.openide.util.NbBundle;
 
28
import org.openide.util.lookup.ServiceProvider;
 
29
 
 
30
/**
 
31
 *
 
32
 * @author Mathieu Bastian
 
33
 */
 
34
@ServiceProvider(service = ExporterUI.class)
 
35
public class UIExporterGraphML implements ExporterUI {
 
36
 
 
37
    private UIExporterGraphMLPanel panel;
 
38
    private ExporterGraphML exporterGraphML;
 
39
    private ExporterGraphMLSettings settings =  new ExporterGraphMLSettings();
 
40
 
 
41
    public void setup(Exporter exporter) {
 
42
        exporterGraphML = (ExporterGraphML) exporter;
 
43
        settings.load(exporterGraphML);
 
44
        panel.setup(exporterGraphML);
 
45
    }
 
46
 
 
47
    public void unsetup(boolean update) {
 
48
        if (update) {
 
49
            panel.unsetup(exporterGraphML);
 
50
            settings.save(exporterGraphML);
 
51
        }
 
52
        panel = null;
 
53
        exporterGraphML = null;
 
54
    }
 
55
 
 
56
    public JPanel getPanel() {
 
57
        panel = new UIExporterGraphMLPanel();
 
58
        return panel;
 
59
    }
 
60
 
 
61
    public boolean isUIForExporter(Exporter exporter) {
 
62
        return exporter instanceof ExporterGraphML;
 
63
    }
 
64
 
 
65
    public String getDisplayName() {
 
66
        return NbBundle.getMessage(UIExporterGraphML.class, "UIExporterGraphML.name");
 
67
    }
 
68
 
 
69
    private static class ExporterGraphMLSettings {
 
70
 
 
71
        private boolean normalize = false;
 
72
        private boolean exportColors = true;
 
73
        private boolean exportPosition = true;
 
74
        private boolean exportSize = true;
 
75
        private boolean exportAttributes = true;
 
76
        private boolean exportHierarchy = false;
 
77
 
 
78
        private void save(ExporterGraphML exporterGraphML) {
 
79
            this.normalize = exporterGraphML.isNormalize();
 
80
            this.exportColors = exporterGraphML.isExportColors();
 
81
            this.exportPosition = exporterGraphML.isExportPosition();
 
82
            this.exportSize = exporterGraphML.isExportSize();
 
83
            this.exportAttributes = exporterGraphML.isExportAttributes();
 
84
            this.exportHierarchy = exporterGraphML.isExportHierarchy();
 
85
        }
 
86
 
 
87
        private void load(ExporterGraphML exporterGraphML) {
 
88
            exporterGraphML.setNormalize(normalize);
 
89
            exporterGraphML.setExportColors(exportColors);
 
90
            exporterGraphML.setExportAttributes(exportAttributes);
 
91
            exporterGraphML.setExportPosition(exportPosition);
 
92
            exporterGraphML.setExportSize(exportSize);
 
93
            exporterGraphML.setExportHierarchy(exportHierarchy);
 
94
        }
 
95
    }
 
96
}