private JComponent createPlanView3DPane(final Home home, UserPreferences preferences,
final HomeController controller) {
JComponent planView = (JComponent)controller.getPlanController().getView();
if (planView != null) {
// Create plan view popup menu
JPopupMenu planViewPopup = new JPopupMenu();
addActionToPopupMenu(ActionType.UNDO, planViewPopup);
addActionToPopupMenu(ActionType.REDO, planViewPopup);
planViewPopup.addSeparator();
addActionToPopupMenu(ActionType.CUT, planViewPopup);
addActionToPopupMenu(ActionType.COPY, planViewPopup);
addActionToPopupMenu(ActionType.PASTE, planViewPopup);
planViewPopup.addSeparator();
addActionToPopupMenu(ActionType.DELETE, planViewPopup);
addActionToPopupMenu(ActionType.SELECT_ALL, planViewPopup);
planViewPopup.addSeparator();
addToggleActionToPopupMenu(ActionType.SELECT,
this.selectToggleModel, true, planViewPopup);
addToggleActionToPopupMenu(ActionType.PAN,
this.panToggleModel, true, planViewPopup);
addToggleActionToPopupMenu(ActionType.CREATE_WALLS,
this.createWallsToggleModel, true, planViewPopup);
addToggleActionToPopupMenu(ActionType.CREATE_ROOMS,
this.createRoomsToggleModel, true, planViewPopup);
addToggleActionToPopupMenu(ActionType.CREATE_DIMENSION_LINES,
this.createDimensionLinesToggleModel, true, planViewPopup);
addToggleActionToPopupMenu(ActionType.CREATE_LABELS,
this.createLabelsToggleModel, true, planViewPopup);
planViewPopup.addSeparator();
JMenuItem lockUnlockBasePlanMenuItem = createLockUnlockBasePlanMenuItem(home, true);
if (lockUnlockBasePlanMenuItem != null) {
planViewPopup.add(lockUnlockBasePlanMenuItem);
}
addActionToPopupMenu(ActionType.MODIFY_FURNITURE, planViewPopup);
addActionToPopupMenu(ActionType.GROUP_FURNITURE, planViewPopup);
addActionToPopupMenu(ActionType.UNGROUP_FURNITURE, planViewPopup);
addActionToPopupMenu(ActionType.MODIFY_COMPASS, planViewPopup);
addActionToPopupMenu(ActionType.MODIFY_WALL, planViewPopup);
addActionToPopupMenu(ActionType.REVERSE_WALL_DIRECTION, planViewPopup);
addActionToPopupMenu(ActionType.SPLIT_WALL, planViewPopup);
addActionToPopupMenu(ActionType.MODIFY_ROOM, planViewPopup);
addActionToPopupMenu(ActionType.MODIFY_LABEL, planViewPopup);
planViewPopup.add(createTextStyleMenu(home, preferences, true));
planViewPopup.addSeparator();
JMenuItem importModifyBackgroundImageMenuItem = createImportModifyBackgroundImageMenuItem(home, true);
if (importModifyBackgroundImageMenuItem != null) {
planViewPopup.add(importModifyBackgroundImageMenuItem);
}
JMenuItem hideShowBackgroundImageMenuItem = createHideShowBackgroundImageMenuItem(home, true);
if (hideShowBackgroundImageMenuItem != null) {
planViewPopup.add(hideShowBackgroundImageMenuItem);
}
addActionToPopupMenu(ActionType.DELETE_BACKGROUND_IMAGE, planViewPopup);
planViewPopup.addSeparator();
addActionToPopupMenu(ActionType.ZOOM_OUT, planViewPopup);
addActionToPopupMenu(ActionType.ZOOM_IN, planViewPopup);
planViewPopup.addSeparator();
addActionToPopupMenu(ActionType.EXPORT_TO_SVG, planViewPopup);
SwingTools.hideDisabledMenuItems(planViewPopup);
planView.setComponentPopupMenu(planViewPopup);
if (planView instanceof Scrollable) {
final JScrollPane planScrollPane = new HomeScrollPane(planView);
setPlanRulersVisible(planScrollPane, controller, preferences.isRulersVisible());
final JComponent lockUnlockBasePlanButton = createLockUnlockBasePlanButton(home);
if (lockUnlockBasePlanButton != null) {
planScrollPane.setCorner(JScrollPane.UPPER_LEADING_CORNER, lockUnlockBasePlanButton);
planScrollPane.addPropertyChangeListener("componentOrientation",
new PropertyChangeListener () {
public void propertyChange(PropertyChangeEvent ev) {
if (lockUnlockBasePlanButton.getParent() != null) {
planScrollPane.setCorner(JScrollPane.UPPER_LEADING_CORNER, lockUnlockBasePlanButton);
}
}
});
}
// Add a listener to update rulers visibility in preferences
preferences.addPropertyChangeListener(UserPreferences.Property.RULERS_VISIBLE,
new RulersVisibilityChangeListener(this, planScrollPane, controller));
// Restore viewport position if it exists
final JViewport viewport = planScrollPane.getViewport();
Integer viewportX = (Integer)home.getVisualProperty(PLAN_VIEWPORT_X_VISUAL_PROPERTY);
Integer viewportY = (Integer)home.getVisualProperty(PLAN_VIEWPORT_Y_VISUAL_PROPERTY);
if (viewportX != null && viewportY != null) {
viewport.setViewPosition(new Point(viewportX, viewportY));
}
viewport.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
Point viewportPosition = viewport.getViewPosition();
controller.setVisualProperty(PLAN_VIEWPORT_X_VISUAL_PROPERTY, viewportPosition.x);
controller.setVisualProperty(PLAN_VIEWPORT_Y_VISUAL_PROPERTY, viewportPosition.y);
}
});
planView = planScrollPane;
}
}
// Configure 3D view
JComponent view3D = (JComponent)controller.getHomeController3D().getView();
if (view3D != null) {
view3D.setPreferredSize(planView != null
? planView.getPreferredSize()
: new Dimension(400, 400));
view3D.setMinimumSize(new Dimension(0, 0));
// Create 3D view popup menu
JPopupMenu view3DPopup = new JPopupMenu();
addToggleActionToPopupMenu(ActionType.VIEW_FROM_TOP,
this.viewFromTopToggleModel, true, view3DPopup);
addToggleActionToPopupMenu(ActionType.VIEW_FROM_OBSERVER,
this.viewFromObserverToggleModel, true, view3DPopup);
addActionToPopupMenu(ActionType.STORE_POINT_OF_VIEW, view3DPopup);
view3DPopup.add(createGoToPointOfViewMenu(home, preferences, controller));
view3DPopup.addSeparator();
JMenuItem attachDetach3DViewMenuItem = createAttachDetach3DViewMenuItem(controller, true);
if (attachDetach3DViewMenuItem != null) {
view3DPopup.add(attachDetach3DViewMenuItem);
}
addActionToPopupMenu(ActionType.MODIFY_3D_ATTRIBUTES, view3DPopup);
view3DPopup.addSeparator();
addActionToPopupMenu(ActionType.CREATE_PHOTO, view3DPopup);
addActionToPopupMenu(ActionType.CREATE_VIDEO, view3DPopup);
view3DPopup.addSeparator();
addActionToPopupMenu(ActionType.EXPORT_TO_OBJ, view3DPopup);
SwingTools.hideDisabledMenuItems(view3DPopup);
view3D.setComponentPopupMenu(view3DPopup);
if (view3D instanceof Scrollable) {