class PerspectiveControllerImpl implements PerspectiveController {

    private static final String SELECTED_PERSPECTIVE_PREFERENCE = "PerspectiveControllerImpl_selectedPerspective";
    private final Perspective[] perspectives;
    //Data
    private String selectedPerspective;

    public PerspectiveControllerImpl() {
        //Load perspectives
        perspectives = Lookup.getDefault().lookupAll(Perspective.class).toArray(new Perspective[0]);

        //Find if there is a default
        String firstPerspective = perspectives.length > 0 ? perspectives[0].getName() : null;
        String defaultPerspectiveName = System.getProperty("org.gephi.perspective.default");
        if (defaultPerspectiveName != null) {
            for (Perspective p : perspectives) {
                if (p.getName().equals(defaultPerspectiveName)) {
                    selectedPerspective = p.getName();
                    break;
                }
            }
        }
        if (selectedPerspective == null) {
            selectedPerspective = NbPreferences.root().get(SELECTED_PERSPECTIVE_PREFERENCE, firstPerspective);
        }

        //Store selected in prefs
        NbPreferences.root().put(SELECTED_PERSPECTIVE_PREFERENCE, selectedPerspective);

        Perspective selectedPerspectiveInstance = getSelectedPerspective();

        openAndCloseMembers(selectedPerspectiveInstance);

        WindowManager.getDefault().addWindowSystemListener(new WindowSystemListener() {
            private Dimension lastDimension = null;
            private Integer lastState = null;
            private Point lastLocation = null;

            @Override
            public void beforeLoad(WindowSystemEvent event) {
            }

            @Override
            public void afterLoad(WindowSystemEvent event) {
                Frame mainWindow = WindowManager.getDefault().getMainWindow();
                if (mainWindow != null) {
                    if (lastDimension != null) {
                        mainWindow.setSize(lastDimension);
                    }
                    if (lastLocation != null) {
                        mainWindow.setLocation(lastLocation);
                    }
                    if (lastState != null) {
                        mainWindow.setState(lastState);
                    }
                }
            }

            @Override
            public void beforeSave(WindowSystemEvent event) {<FILL_FUNCTION_BODY>}

            @Override
            public void afterSave(WindowSystemEvent event) {
            }
        });
    }

    @Override
    public Perspective[] getPerspectives() {
        return perspectives;
    }

    @Override
    public Perspective getSelectedPerspective() {
        for (Perspective p : perspectives) {
            if (p.getName().equals(selectedPerspective)) {
                return p;
            }
        }
        return null;
    }

    @Override
    public void selectPerspective(Perspective perspective) {
        if (perspective.getName().equals(selectedPerspective)) {
            return;
        }

        openAndCloseMembers(perspective);

        selectedPerspective = perspective.getName();
        NbPreferences.root().put(SELECTED_PERSPECTIVE_PREFERENCE, selectedPerspective);
    }

    private void openAndCloseMembers(final Perspective perspective) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                WindowManager.getDefault().setRole(perspective.getName());
            }
        });
    }
}

                Frame mainWindow = WindowManager.getDefault().getMainWindow();
                if (mainWindow != null) {
                    lastDimension = mainWindow.getSize();
                    lastLocation = mainWindow.getLocation();
                    lastState = mainWindow.getExtendedState();
                }
            
<no_super_class>